Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
ECF/tooling/remote-service-development-user-guide
Contents
Summary
This project introduce a new developer tool which can be use to generate eclipse ECF remote-service and client related codes. Specially ECF has introduced asynchronous remote services which need a little bit complex interface. Using this tool you can generate these interface in seconds by defining two simple annotation.
Functionalities
- Generate Asyn service interface and Impl template class by pointing a exsiting interface.
- Generate service impl class template by pointing exsiting service interface.
- Generate a method to register the service
- A Wizard to create a new service client project
- Generate client code for exsisitng project
Note:-All above code generation support for generating any type of return statements , parameters and exceptions and relavant dependancies will be automatically added into tje project
pre-requires
Install eclipse ecf [1]-http://www.eclipse.org/ecf/downloads.php
I have used Eclipse Kepler for development and Testing with JDK 1.7
Downloads
Git repository github.com/Salindauwu/gsoc2013salinda
How to use
This tool introduce following two main annotations which is used to identify the service type, Asynchornus service or synchronus service.
- RemoteService - This is for general remote services
- AsyncRemoteService - This is for Asynchoruns remote services
@RemoteService.
This a type annotation, this is used to identify the remote service class.If use this annotaion your method should be synchronus.Now you can generate Service Impl class and Service Register class for this service.you have to right click on the project,file or package then select Generetae R-service option from the right click menu then all above class will be geretaed as shown in the figure.All your runtime properties ex: service container type will be save in a peroperty file called service.properties.you can use this file to edit the runtime informations and relevant dependancies will be add into the Manifest.MF if you see the Manifest.MF after code generation there will be more import packages which are needed for register the service.
Note:- you may need to import "org.eclipse.ecf.tools.serviceGenerator.annotations" package to use above annotation.
adding the annotation
Generating the code for this interface
generated classes
@AyncRemoteService
This is used to define the asynchronus remote service interface.using this you can convert genral service interface into a asynchronus service interface.When you using this interface method should also be asynchronus using @Async annotation you can convert general method into a async method as follows.
@Async.
This a method annotaion,can be used to modify the method as
@Async(type=AsyncType.BOTH) pubic void foo(int i);
Async method can be crates 3 ways
creating a method using IFuture.
create a method using callback handler.
creat methods useing both types.
(Note :- You can use "AsyncType" class to defiene above options)
this argument can be pass a annotation option as follows if the method use IFuture
@Async(type=AsyncType.FUTURE) pubic void foo(int i);. if the method use callback handler @Async(type=AsyncType.CALLBACK) pubic void foo(int i);</u
<u>if user want to create both above methods @Async(type=AsyncType.BOTH) pubic void foo(int i);
Once you done above declarations, right click on the file and select "generate ecf service" option from the right click menu.Async service interface and service impl class will be generated.
If your service type is sync then no need to define any annotations for methods, just right click on the interface and select the service generation option from the right click menu,Service impl class will be generated.
Following figures will show step by step to generate Async service by using general service interface.
Generate Async interface using the above general interface
Generate classes
Generated classes
Generated classes body
Generating Remote Service Client
There two ways to generate client codes
1) Right click on exsiting plugin project select the select Client Gen option as shown in the figure
2)you can use new project wizard to start this wizard as shown in the figure.
Generating client using wizard
List the workspace Plugin project and gave a option to create new plugin project
creating a new plugin project using the given option
New plugin project now can selec using the project selector combo
Generate the client code
Generated Client codes
Generated client code body
Runtime properties listed in a property file
Dependancies added into the Manifest.MF
Demostration
Create syn or Asyn service, register and service client within seconds watch here - http://youtu.be/ObSQL5mogEU (use google chrome browser to see this video)