mercredi 30 mars 2011

GraniteDS, Java EE 6 and Seam 3 at JAXLondon 2011

I really enjoy going to London for JAX 2011. I will be speaking about Flex and Java EE 6.
The timing is very interesting because Java EE 6 is now really getting a lot of traction (don't miss the sessions of the Java EE day) and the final Seam 3.0 is about to be released. I will be able to demonstrate some nice new stuff with Flex, GraniteDS and Seam 3.
I'm also happy to speak just after the keynote of Michaël Chaize from Adobe who will certainly show lots of awesome Flash & Flex demos on various mobile platforms.
If I can find enough time, I'll try to also do a short demonstration of a multiscreen Flex/AIR application on an Android phone.



See you there !

mardi 1 mars 2011

GraniteDS Wizard (technology preview)

The new GraniteDS Wizard Plugin is intended to facilitate the creation of new GraniteDS project under Eclipse.

1. Quick setup and usage:

In order to install and use it, you need at least an Eclipse 3.4+ bundle and, preferably, if you want to benefit from all of its features, the folowing plugins:
  • FlashBuilder 4.
  • GraniteDS Builder 2.2.
  • JBoss Tools 3 (with at least the archives tool, see here is you don't know what it is about).
You will also need a JBoss 5.1 distribution, as the default template that comes the wizard targets this application server.

Once you have setup this environment, donwload the new GraniteDS Wizard plugin on Github here and unzip it into your eclipse/plugins directory. Restart Eclipse and you should now be able to see a "GraniteDS" section in the "New Project" dialog when you select "File" -> "New" -> "Project..." in your Eclipse menu:


Select "GraniteDS Projects", click on the "Next" button and select the first available template in the next dialog:





Click again on the "Next" button and you should now see a standard project creation dialog with a specific "Template variables" section at the bottom:





Enter a project name, change the "JBoss installation directory" to your JBoss installation directory, accept all other default options (or change them if you want) and click on "Finish".

You should now see a new Flex / JavaEE project, configured for both FlashBuilder and GraniteDS builder, and with a ".package" file that automatically deploy the project in the choosen JBoss deployment directory.

Tip: unfortunatly, you should also have an error when the project is first build... This is FlashBuilder error (actually a known bug), complaining that it hasn't been able to create the html templates. Just right click on the error and ask it to recreate the template files.


2. Under the hood, modifying the template:

Project templates in this GraniteDS wizard tool are mostly made of Groovy scripts. Go to your "eclipse/plugin/org.granite.wizard_1.0.0.alpha1/resources" directory. You should see two subdirectories, "libs" and "templates".

The "libs" directory contains GraniteDS libraries that are referenced by templates (see below).

The "templates" directory contains actual templates. There is only one template at this time, in a directory called "jboss". If you open this directory, you will see two files and one directory:
  • template.properties: this file contains the name and description of the template, as they appear in the second screenshot above. The "title" property is the title of the third screenshot above. The last property ("controller") is for advanced use only, don't change it!
  • bindings.groovy: this file defines variables that are displayed in the "Template variables" section of the third screenshot and that will be used later for the actual project creation. You may modify the values in this file in order to get default values that fit your environment (in particular, you should change the "jbossDir" value so it will be set by default to your JBoss installation directory). The good thing is that you may do this change without restarting Eclipse: template files are reloaded each time you run the wizard.
  • project: this directory contains all files and directories that the template is made of. As you can see, some directory names are enclosed between ${} characters: this means that their names will be resolved against the actual values of templates variables, as defined in the bindings.groovy file and adjusted in the third dialog shown above. Some other files are ending with a ".gsp" extension: these are Groovy templates, similar to GraniteDS builder templates. Finally, you will even see files named "@libs!...": these files will be resolved by copying GDS libraries found in the "resources/lib" directory.
As you may now understand, this GraniteDS Wizard is completely generic and could be used in order to make projects that have nothing to do with GraniteDS: it is simply a general mecanism for displaying and editing variables before copying template files and directories.

Some more informations before a future proper documentation:
  • Binding variables use Groovy closures with dependencies: the jbossDeployDir value is { new File(jbossDir.value, "server/default/deploy") }, a closure that uses the value of the jbossDir variable. If you change the "JBoss installation directory" in the interface, you will see the JBoss deploy directory value changing accordingly. This is similar to Flex bindings, when you write something like text="The value is {bindableVariable}".
  • If a file shoudn't be generated for some configuration, you may throw a CancelFileGenerationException to prevent its generation (see the .flexProperties.gsp file for an example).
  • There are currently 4 types of supported UI controls: text input, checkbox, combobox and directory selection. The type of the variable must be set accordingly to String, Boolean, String (again) or File.
  • Input validation is made on the fly: use the "validation" and "errorMessage" attributes in the bindings.groovy file to set it up.
  • If you omit the "label" attribute, the variable won't be shown in the UI intterface.
  • You may disabled by default a variable in the UI interface if you set the "disabled" attribute to false: this may be done with the "false" literal, by a call to a method that returns a boolean value or even by a closure that uses another variable value (see bindings.groovy for examples).
  • You may create other templates by copying the "jboss" one and changing whatever you want. Again, you don't need to restart Eclipse in order to see your new template: just rerun the wizard, the new template will be displayed in the list shown in the second screenshot.
Don't forget this is an alpha work: we will improve this JBoss template and provide other ones for different environments.

samedi 22 janvier 2011

Maven archetypes updated with GDS 2.2 SP1

Following the release of GraniteDS 2.2.0 SP1, we have updated the Maven archetypes (now version 1.0.0.RC2).

Unfortunately because of some weird behaviour of the Maven archetype plugin, it is now necessary to specify the archetype repository 'central' to be able to use the latest version :
mvn archetype:generate
-DarchetypeGroupId=org.graniteds.archetypes
-DarchetypeArtifactId=graniteds-tide-spring-jpa-hibernate
-DarchetypeVersion=1.0.0.RC2
-DarchetypeRepository=central
-DgroupId=com.myapp
-DartifactId=example2
-Dversion=1.0-SNAPSHOT

There have been a few changes and fixes :
  • Upgrade to GDS 2.2 SP1
  • Upgrade to flexmojos 3.8 (so mvn flexmojos:flashbuilder should work)
  • Fixed bad default package name in Spring archetype
  • Changed Java compile options to 1.6


Update 25/01/2011 : seems the central archetype catalog is now up-to-date :
mvn archetype:generate
-DarchetypeGroupId=org.graniteds.archetypes
-DarchetypeArtifactId=graniteds-tide-spring-jpa-hibernate
-DgroupId=com.myapp
-DartifactId=example2
-Dversion=1.0-SNAPSHOT

samedi 27 novembre 2010

GraniteDS Maven archetypes 1.0 RC1 released

We have noticed from a long time that starting a new project with GraniteDS and the usual Java frameworks is not easy enough. We have tried to simplify the configuration as much as possible by allowing to configure GraniteDS directly in the Spring and Seam configuration files but yet there are many steps and caveeats that can take lots of time when setting up a project. It is even more painful when you add the setup of the build system with Ant or Maven.

Fortunately Maven provides a handy mechanism to bootstrap new projects in the form of archetypes. Along with the release of GraniteDS 2.2, we have also released a set of 4 archetypes for common use cases of GraniteDS :
  • graniteds-spring-jpa-hibernate: Flex 4 + Spring 3 + Hibernate/JPA + GraniteDS with standard RemoteObject API
  • graniteds-tide-spring-jpa-hibernate: Flex 4 + Spring 3 + Hibernate/JPA + GraniteDS with Tide API
  • graniteds-tide-seam-jpa-hibernate: Flex 4 + Seam 2.2 + Hibernate/JPA + GraniteDS with Tide API
  • graniteds-tide-cdi-jpa: Flex 4 + CDI/Weld 1.0 + JPA + GraniteDS with Tide API
It is recommended to use Maven 3 but Maven 2.2 should also work. You can run the archetypes from the command line :
mvn archetype:generate
-DarchetypeGroupId=org.graniteds.archetypes
-DarchetypeArtifactId=graniteds-tide-spring-jpa-hibernate
-DarchetypeVersion=1.0.0.RC1
-DgroupId=com.myapp
-DartifactId=example1 -Dversion=1.0-SNAPSHOT
This will create of project named example1 that you can directly build and run with maven :
cd example1
mvn install
cd webapp
mvn jetty:run-war
Then browse http://localhost:8080/example1/example1.swf. The generated project is a multimodule application skeleton with a Java module, a Flex module and a Web module. It includes basic security, service remoting and data synchronization. The default security configuration includes two hardcoded users: admin/admin and user/user.

It is a good starting point to build your own application, after removing the very few example parts. The most interesting thing in these archetypes is that the build poms are automatically created and that they reference selected versions of each framework (Flex, Spring, Seam, Hibernate...) and of build tools (Flexmojos, Jetty plugin...) that work together correctly.

Spring and Seam archetypes are built to be run inside Jetty (for example with the Maven Jetty plugin as shown before). The CDI/Weld example is built to be run inside GlassFish v3.0.1+ and should also work in JBoss 6 M4 (but not later as next versions include the newer and incompatible Weld 1.1). By default it can be run in embedded GlassFish with :
cd example1
mvn install
cd webapp
mvn embedded-glassfish:run
If you don't want to run inside an embedded container but in Tomcat or another container, and still want to use real-time messaging, you will have to change the Gravity servlet implementation in the web.xml file (implementation class names for Tomcat and JBoss 5+ are in comment in the generated web.xml). Then build a war to be deployed in any application server with :
cd webapp
mvn war:war
This is not a final release of these archetypes but they are already usable. They mostly miss the necessary Maven stuff to run unit tests for Flex and Java projects.

As always don't hesitate to give your feedback.

jeudi 25 novembre 2010

Upgrading from GraniteDS 2.1 to GraniteDS 2.2

GraniteDS 2.2 GA has just been released. There have been a few minor changes in APIs and configurations that require some work when upgrading from GDS 2.1 to GDS 2.2 :

API for PagedQuery

PagedQuery now supports sorting on multiple fields, so the API for server-side components has been changed accordingly and expects arrays for order and desc.
public Map find(Map filter, int first, int max, String[] order, boolean[] desc) {
...
}

Configuration property of server-side validator

The property name in services-config.xml has changed from validator-class-name to validatorClassName for consistency with other properties :
<destination id="seam">
<properties>
<validator-class-name>org.granite.tide.hibernate.HibernateValidator</validator-class-name>
</properties>
</destination>
With Spring, it's also possible to define a validator-name that is the name of a bean that implements org.granite.tide.validators.EntityValidator, the default name expected being "tideValidator".
<bean id="tideValidator" class="com.myapp.MyValidator"/>

mercredi 6 octobre 2010

Presentation of GraniteDS at 360|Flex DC

Franck and I were at the 360|Flex DC conference in September to give a presentation about GraniteDS. It was a very interesting time for us, as it was our first talk in the US and our first talk in a pure Flash/Flex conference. We met nice people there and it was a refreshing change to attend to sessions made by designers about user experience, visual effects and gaming instead of our usual boring enterprise Java stuff. Thanks again to John & Nicole for inviting us.

Our presentation was partly slides and partly demo code and some people asked if we could publish the demo application. After a bit of polishing, it is now available for download. There is an ear that can be deployed in a vanilla JBoss 4.2.3, and the eclipse project with the complete source code and configuration here.

Note that you will need two things in JBoss to run the example :
- Install APR (Apache Portable Runtime): download and install it from here, see install doc here.
- Comment out the "CommonHeadersFilter" section in jboss-4.2.3.GA/server/default/deploy/jboss-web.deployer/conf/web.xml:
<!--
<filter>
<filter-name>CommonHeadersFilter</filter-name>
<filter-class>org.jboss.web.tomcat.filters.ReplyHeaderFilter</filter-class>
<init-param>
<param-name>X-Powered-By</param-name>
<param-value>Servlet 2.4; JBoss-4.2.3.GA [...]</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>CommonHeadersFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->

Once deployed, it can be accessed from http://localhost:8080/gds-onlinebet/Onlinebet.html.

This demo will probably be included in the distribution examples in the next release of GraniteDS.

Finally if you are interested by the slides, they are available on SlideShare.

As always, don't hesitate to give your feedback.

mercredi 15 septembre 2010

At least you don't need a psychiatrist ;-)

WebORB marketing buzz is somewhere beyond the final frontier: to get to GraniteDS into their decision trees, you first have to go with Java, which doesn't even seem to be the most recommended option according to these guys. Then, you'll have to follow this frustrating path:
Complete messaging? No.
Complete data management? No
Complete code generation? No.
A psychiatrist? No. (if you happen to choose Yes here, you get LCDS ;-)
Scale beyond one server? Yes.
J2EE-centric? Yes.
Here you are: GraniteDS.
So, after refusing all the good things, you, as a GraniteDS user, avoid at least the cost of a therapy!

But the most funny thing is at the end of their post:
We respectfully request that the developers of the other integration servers mentioned herein join us (...)
You may guess that William and I are of course seriously studying this unexpected opportunity.