Issue Details (XML | Word | Printable)

Key: GDS-439
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Franck Wolff
Reporter: Francesco Faraone
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
GraniteDS

Gas3: RemoteObject generator for remote Service Beans

Created: 05/Jun/09 11:08 AM   Updated: 23/Oct/09 04:58 PM   Resolved: 30/Sep/09 12:49 PM
Component/s: AS3 code generation, Granite Eclipse Builder
Affects Version/s: 2.0.0_RC1
Fix Version/s: 2.1.0_RC1

File Attachments: 1. Zip Archive granite_builder_2.0.0_RC1_remotedest_changedfiles.zip (21 kB) 05/Jun/09 11:08 AM - Francesco Faraone
2. File PersonServiceBeanBase.as (4 kB) 05/Jun/09 11:08 AM - Francesco Faraone
3. File remoteBase.gsp (4 kB) 11/Jun/09 04:36 PM - Francesco Faraone



 Description  « Hide
n a J2EE/GraniteDS platform where all the entities on the client side are generated with the graniteds-generator, we felt the need to give the developers of the client part a set of preconfigured remote objects, on which they could use code completion and parameter type to ease the use of remote services. The best candidate to carry out this job was of course the graniteds-generator, providing in it the right support of some new classes.

My coworker Saverio Trioni (saveriotrioni@me.com) and me developed what seems a quite good solution, that I hope you could consider to integrate into the main development line. In that case, I would be thankful if you would credit both of us, not only me, for the contribution.


As for the modifications we send in, a Service Bean annotated with @RemoteDestination will be translated into a subclass of ...mxml.RemoteObject, in which there is
1) an initialization method, where the channel/destination/etc. info provided in the server side annotation is used to connect to the right channel
2) one method (with the correct type for the parameters) for each method in the Service Bean, which calls the remote operation
3) two methods to add and remove listeners to the operations, which take a Function object as first argument and then add or remove the listener to the operation corresponding to the passed Function (which should be a method of the same object)

Example use of the "add listener" method (suppose PersonServiceBean.as is generate and there is a method getAllPersons() ):


var svc:PersonServiceBean = new PersonServiceBean()
svc.addOperationListener(svc.getAllPerson, ResultEvent.RESULT, handlerFunction)


To add a listener over all the RemoteObject just use the standard notation, as it is really a RemoteObject.


Note: The @RemoteDestination annotation must be added to the granite-generator-share.jar package for the builder to support this configuration. (done in main graniteds project)


I attach an archive of all the modified files, and the output of translating the PersonServiceBean in the graniteds_ejb3 example project.


==================================================

Explanation of the modifications:


== org.granite.generator.as3.reflect.JavaRemoteDestination

This is the only new class, that is a subclass of JavaAbstractType like the others in the package.
This class ignores the properties and attributes, collecting just the methods as they are, with full parameter information, and also stores the as3 types for all teh parameters.


== org.granite.generator.as3.reflect.JavaMethod

Heavy modifications are done on the JavaMethod class, because for service methods we need to store much more information than for javabean accessors. So a new constructor is made available which, if passed a JavaTypeFactory as argument, stores parameter types in both java and as3 in the class.


== org.granite.generator.template.remote.gsp
== org.granite.generator.template.remoteBase.gsp

New templates


== org.granite.generator.as3.reflect.JavaType
== org.granite.generator.as3.reflect.JavaAbstractType
== org.granite.generator.as3.JavaAs3GroovyTransformer
== org.granite.generator.template.StandardTemplateUris
== org.granite.generator.ant.AntJavaAs3Task
== org.granite.builder.properties.GraniteProperties

Slight modifications to take into accout the new category of translatable classes and the new templates.


Regards
Francesco

Franck Wolff added a comment - 05/Jun/09 11:18 AM
Sounds great! It was planned for a long time to extend the generator for services, but I didn't have time to implement it... I don't think it is safe to integrate it the 2.0.0.GA (feature freeze), but It will certainly fit in a 2.1 release.

Thanks, Franck.

Francesco Faraone added a comment - 11/Jun/09 04:36 PM
fixed: wrong import of mx.messaging.config.ServerConfig

William Draï added a comment - 26/Aug/09 04:41 PM
It's now included in the trunk. We made small changes to make it work with Tide templates and allow future integrations with Spring and Seam. It can also work now with @RemoteDestination on the service interface and not only on the implementation.
Just run :
<gas3 remotedestinationfactory="org.granite.generator.as3.DefaultRemoteDestinationFactory" .../>

Please check that it works for you.

Thanks again. Obviously we'll credit you and your coworker for this contribution in the next release.

Franck Wolff added a comment - 30/Sep/09 12:49 PM
Now fully integrated with GDS builder.

Thanks again.

Francesco Faraone added a comment - 23/Oct/09 04:58 PM
HI,
I've installed the build 209 of the granite builder

http://www.graniteds.org/bamboo/download/GDS-BUILDER/artifacts/build-209/org.granite.builder.jar/org.granite.builder_2.0.0.GA.jar

but when I try to set the sources for generation I got this error:

Granite properties load failed:
com.thoughtworks.xstream.converters.ConversionException: No enum const class
org.granite.generator.as3.reflect.JavaType$Kind.REMOTEDESTINATION : No enum
const class org.granite.generator.as3.reflect.JavaType$Kind.REMOTEDESTINATION
---- Debugging information ---- message : No enum const class
org.granite.generator.as3.reflect.JavaType$Kind.REMOTEDESTINATION
cause-exception : java.lang.IllegalArgumentException cause-message :
No enum const class
org.granite.generator.as3.reflect.JavaType$Kind.REMOTEDESTINATION class
: org.granite.builder.properties.GraniteProperties required-type :
org.granite.builder.properties.Gas3Template path :
/graniteProperties/gas3/template[5] line number : 10
-------------------------------

I've tested this release with eclipse 3.4.2 J2EE 32bit carbon with Flex Builder 3.2 on snow leopard.

Regards
Francesco