Where to find Open SCA Specification?

Look here http://docs.oasis-open.org/opencsa/

Unfortunately the official links are defunct (like this http://www.oasis-opencsa.org/display/Main/Service+Component+Architecture+Specifications )


How to override default OpenJDK in Fedora with SUN/Oracle JDK

I always did it pretty straight, I installed SUN JDK, I put-in SUN’s “java” executable into PATH variable, “export JAVA_HOME”, I did it usually in some “*.sh” file in to “/etc/profile.d”, and well actually it is not a good place for it. However, Fedora manages mapping between “java” link and real target executable via system of symbolic links (managed via “alternatives” utility). Alas, SUN’s JDK does not “invoke alternatives” to declare its alternatives.
But today I had a time to solve this problem as it must have been solved:
Meet “add-java.sh”:

JAVA_HOME=`readlink -f "$JAVA_HOME"`
if [ -n "$2" ]; then
alternatives --verbose --install /usr/bin/java java "${JAVA_HOME}/bin/java" ${PRIORITY} \
	--slave /usr/bin/javaws javaws "${JAVA_HOME}/bin/javaws" \
	--slave /usr/bin/keytool keytool "${JAVA_HOME}/bin/keytool" \
	--slave /usr/bin/orbd orbd "${JAVA_HOME}/bin/orbd" \
	--slave /usr/bin/pack200 pack200 "${JAVA_HOME}/bin/pack200" \
	--slave /usr/bin/rmid rmid "${JAVA_HOME}/bin/rmid" \
	--slave /usr/bin/rmiregistry rmiregistry "${JAVA_HOME}/bin/rmiregistry" \
	--slave /usr/bin/servertool servertool "${JAVA_HOME}/bin/servertool" \
	--slave /usr/bin/tnameserv orbd "${JAVA_HOME}/bin/tnameserv" \
	--slave /usr/bin/unpack200 unpack200 "${JAVA_HOME}/bin/unpack200" \
	--slave /usr/lib/jvm-exports/jre jre_exports "${JAVA_HOME}/jre" \
	--slave /usr/lib/jvm/jre jre "${JAVA_HOME}/jre" \
	--slave /usr/share/man/man1/java.1 java.1 "${JAVA_HOME}/man/man1/java.1" \
	--slave /usr/share/man/man1/javaws.1 javaws.1 "${JAVA_HOME}/man/man1/javaws.1" \
	--slave /usr/share/man/man1/keytool.1 keytool.1 "${JAVA_HOME}/man/man1/keytool.1" \
	--slave /usr/share/man/man1/orbd.1 orbd.1 "${JAVA_HOME}/man/man1/orbd.1" \
	--slave /usr/share/man/man1/pack200.1 pack200.1 "${JAVA_HOME}/man/man1/pack200.1" \
	--slave /usr/share/man/man1/rmid.1 rmid.1 "${JAVA_HOME}/man/man1/rmid.1" \
	--slave /usr/share/man/man1/rmiregistry.1 rmiregistry.1 "${JAVA_HOME}/man/man1/rmiregistry.1" \
	--slave /usr/share/man/man1/servertool.1 servertool.1 "${JAVA_HOME}/man/man1/servertool.1" \
	--slave /usr/share/man/man1/tnameserv.1 tnameserv.1 "${JAVA_HOME}/man/man1/tnameserv.1" \
	--slave /usr/share/man/man1/unpack200.1 unpack200.1 "${JAVA_HOME}/man/man1/unpack200.1"

Run it under root:

./add-java.sh /usr/java/latest

NOTE: /usr/java/latest is what would be JAVA_HOME if you selected “classical” approach.
And now you may run (again as root):

# alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/java/latest/bin/java

Enter to keep the current selection[+], or type selection number: 

Select 2 and it will result in:

# java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)

If you rerun alternatives --config java and select 1 you will return to the previous configuration:

# java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.7) (fedora-
OpenJDK Server VM (build 19.0-b09, mixed mode)

The advantage is that such a toggle is immediate, you should not relogin to force files from profile.d to run.

Как запустить приложение собранное maven и отладить его

На вопрос: “Почему вы не используете maven?”, средний разработчик как-то странно пожимает плечами, затягивая: “Ну понимаете…”
“Понимаю”: причина в том что всё так красиво и простая команда mvn package творит чудеса, но вот когда доходит до того что бы отладить приложение, народ пасует — производителям сред разработки так нужно было посадить программеров на свои среды и отладчики, что они таки добились… того что люди не только боятся коммандной строки — они не знают и не разбираются и не хотят разбираться, как отлаживается приложения запущенные не из под коммандной строки. А ведь всё очень просто запускаем приложение так:
env MAVEN_OPTS="-agentlib:jdwp=transport=dt_socket,address=" mvn -Dexec.mainClass=zy.alex.uluru.donothingapplication.Main exec:java

Сочувствую если у вас не Linux 🙂 то тогда просто сделайет set для MAVEN_OPTS в cmd.exe
получить вы должны что то вроде этого:

ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
Aborted (core dumped)

это по тому что мы предварительно не запустили локальное приложение, которое будет слушать на порту 8000 и предоставлять среду для отладки

в NetBeans это достигается Debug > Attach Debugger

В Eclipse это достигается Run > Debug Configurations > Remote Java Application

Ну а дальше все просто, стоит только отметить то, что для того что бы поставить break point необходимы исходники, в NetBeans придётся закачать все исходники которые вам необходимы и засунуть в один проект, в этом плане Eclipse значительно удобнее.

Yet Another Maven plugin for Eclipse

A friend of mine found http://code.google.com/p/q4e/
looks like it is an alternative to famous http://m2eclipse.codehaus.org/ .
However we failed to run it 🙂 on Eclipse 3.3.1.x and have no time for experiments.

Proposal for {}-expressions in JavaFX

I have wrote a proposal to send it to openjfx-compiler project… But I found that some of features I propose is already implemented in the language… see upcoming post. I feel my self as Gray being overtaking by Bell 😦 But positive side is that I am on the same page with people creating this language 🙂
Anyway that is what I wanted to sent to openjfx-compiler mail.list:

Proposal to have {} to evaluate to some value.

I was inspired for this idea by if-then-else construct.
As far as I remember it was the old ALGOL-60 language which enables “IF cond THEN v1 ELSE v2” first, and that time it looks exactly the same syntax.
However I think it would only look OK in Pascal or Modula-2, but not in JavaFX.
Because JavaFX tends to be expression language I propose to have { } construct to evaluate to some value. How it could help?
1. if-then-else will not be needed any longer one could write:

	var result = if (operation = "-") {x-y} else {x+y}
	or even better example:
	var result = if (operation = "-") {x-y} else if (operation = "+") {x + y} else if (operation = "*") {x * y} else if (operation ="/") { if(y == 0) {throw DivisionByZeroException{};} else {x/y}};

2. we could write as simple as (w/o return):

	function mediana(a: Integer, b:Integer) {
		(a + b) / 2 // NOTE: semicolon (;) to be ommited

3. we could put some additional computation in { } only the last one operator(expression) in { } will be a result expression.

	 * Overflow protected version of mediana
	function mediana(a: Integer, b:Integer) {
		var sumOfHalves = a/2 + b/2;
		var remainders = a%2 + b%2;
		sumOfHalves + remainders

4. I have some ideas about JavaFX variant of servlets/JSP. Look! how pretty could look {}-expression in the strings, it could substitute both JSP’s expression (<%= %>) and JSP’s scriptlet (<% %>):

		String title = request.getAttribute("title");
	if ( (!"".equals(title) {
		<title><%= escape(title) %></title>
	else {
		<title>Home Page</title>


			var title = request.getAttribute("title");
			if ("" <> title) {
				"<title>{escape(title)}</title>" //NOTE: this "if" is an "if" between 2 string expressions!
			else {
				"<title>Home Page</title>"


5. the only exception where there should not be {}-expression is finally {}-block of try-catch-finally:

	transactionOK = false;
	try {
		transactionOK = true;
		someValue // some expression
	catch(SomeExceptionToHandle e) {
		transactionOK = true;
		someOtherValue // some expression
	catch(SomeCriticalExpection e) {
		throw AnotherException{};	
        finally {
		if (treansactionOK) {
		else {
		// here expression may not be set

6. (OPTIONALY) for cycles for and while, evaluation of {}-block may automaically create sequence:

	var primesUpTo100:Integer[] = while(x <= 100) {
		if (isPrime(x)) {
		else {

	var primesUpTo100 = while(x <= 100) {
		if (isPrime(x)) {
			var prime = x;
			x = x + 1;
		else {
			x = x + 1;

7. The similair feature exists in C language: it is comma operator (,) however its idea is vice-versa — to unstructurize code and write everithing in one line: y = (x=1, z=2, x*z);

Strings in terms of codepoints? Kill Java char type!

Wrote a message to dev@openjfx-compiler
copy it here:
I think, JavaFX should have a separate String class. Which should be
automatically converted to Java’s string and back. Why?

In Java 6 the was introduced idea of code points, because Java strings
is no longer a Unicode strings (currently Unicode character does not fit
16 bit char type. So Java’s native encoding is no longer Unicode but
UTF-16. This means that char type is just 16bit and is not a character.
The charactet(one visible sign) is a “code point”:
see method
public int codePointAt(int index) in

SO I propose to have special class for String in JavaFX.

package javafx.lang;
class String {
	length() : Integer; // Actually retuns Java's codePointCount()
	charAt(i: Integer) : String; // Actually returns Java's codepoint
	... + and all useful methods from Java's String.
         ... - all methods for code points
         ... + may be some methods to work with char's but make their 
names so that anybody understands they are auxillary

After introduction of code points existing Swing code should actually be
rewritten to work in terms of code points. Because if you have input
field for username as 8 characters, the user expects he/she could enter
8 real charaters. But if you apply limit of 8 to
java.lang.String.length() you will allow to enter only 4 of some new
Unicode characters from extended set. I think it would be good if JavaFX
users forgot about char and knew nothing about difference in length()
and codePointsCount().

Currently I see that JavaFX only partially hides presence of Character type:

var ca = ClassA {
     s: "Hello!";

var c = ca.s.charAt(0);

it prints:

class java.lang.Character

however because idea of JavaFX to have only Integer Number String
Boolean i would expect c to be of type Integer. But this is not so.

Also may be having separate String class will allow to have not nullable
string attribute? As we currently have for Integer, Number and Boolean?

Please consider!

Could JavaFX has the common syntax for object literal, anonymous classes, and AOP?

I have one idea, I could not say it is stupid or not, but looks amazing.
What the following construct is?

Frame {
    title: "Ch1 Demo"
    width: 300
    height: 250
    visible: true

Well it is equivalent of:

x = Frame;
x.title= "Ch1 Demo"
x.width= 300
x.height= 250
x.visible= true

or Java’s equivalent (informal, because javafx.ui.Frame is not directly avalable in Java):

Frame x = new Frame();
x.setTitle("Ch1 Demo");
// and so on

Of course this is just one of the possible equiv in Java… “Straight forward” I could say…

But I begin to think about alternative equivalents:

Frame x = new Frame() {
   // there is no way to add new constructor or initialization code, but let us imagine there is overloadable init() method called from Frame constructor:
   protected init() {
       setTitle("Ch1 Demo");

So I propose the following:
Let the object literal construct to allow also method overriding, adding triggers and so on, just for example:
Let’s assume our frame has paint() method (bad example I know — but let assume such method exists). So let it be possible:

Frame {
    title: "Hello, Wolrd!" on replace {
      throw ModificationProhibitedException; // we prohibit further modification of attribute
    width: 300;
    // and so on
    paint() {
      System.out.println("before paint");
      System.out.println("after paint");

Implementation of such feature may be:
1. As I have already introduced via a kind of “anonymous” classes.
2. Via proxifying original class (using mechanism similar to java.lang.reflect.Proxy or LIBGC).

Of course if there is no method overriding or trigger, then object literal will be as simple as object initialization.

OK let’s assume we have variant 2.

Then it would be possible to extend object literal construct to the following.
Say we already have:

var frame = Frame {title: "Name"};

if we allow following syntax:

frame { // from small letter -- because we would like the following will be applied on specified variable only:
     title on replace {
         System.out.println("title is changed :) ");
     paint() {
         ... // we could intercept paint() method.

thus it would be possible to assign a pretty a lot of attributes with one shot:

frame {
    title: "new title"; // frame.title = "new title"
    width: 200; // frame.width = 200;

So varialble{} will resemble PASCAL’s WITH operator 🙂 in such usage scenario.
I could evolve this idea even further
we could treat simple block of code in curly brackets as

Void {

because void is nothing this is just a piece of code… — there is no attribute or method to reference.

How all this may be implemented?
Well I think one of the possible way: for each object to have a data record + some “proxy” over it. This proxy will register overriding original methods and triggers… And constructions like frame { … } should be freely casted to original Frame class and may be “frame instanceof Frame” should return true (not like proxies in Java).

What do you think, mates?