Beside EJB3, Spring, Seam and Guice services, Granite DS supports Plain Old Java Object (POJO) services with three different scopes: "request" (the default), "session" and "application". When a RemoteObject is configured to use this kind of destination, Granite DS instanciates or retrieves an object (depending on the scope) on which it calls the desired method.
For a basic sample with Pojo and Granite DS, download graniteds-pojo-1.0.0.zip and import it as a new Eclipse project.
For example, you may implements a Pojo service as follow:
package test.pojo; public class PojoService { private int counter = 0; public int getCounter() { return ++counter; } }
You must also provide a services-config.xml file like this one:
<?xml version="1.0" encoding="UTF-8"?> <services-config> <services> <service id="granite-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage"> <destination id="pojo"> <channels> <channel ref="my-graniteamf"/> </channels> <properties> <scope>session</scope> <source>test.pojo.PojoService</source> </properties> </destination> </service> </services> <channels> <channel-definition id="my-graniteamf" class="mx.messaging.channels.AMFChannel"> <endpoint uri="http://{server.name}:{server.port}/{context.root}/graniteamf/amf" class="flex.messaging.endpoints.AMFEndpoint"/> </channel-definition> </channels> </services-config>
Then, a RemoteObject in your mxml file may call the getCounter method on the "pojo" destination. Since the scope is configured as "session", the counter will increment each time you call the method. There is no need to configure a factory for this to work. POJO factory is the default.
You may specify a "*" (wildcard) source instead of a fully qualified class name. In this case you will specify the source property at runtime on the RemotingMessage's source property (see Flex documentation here).
|
Browse Space |
Explore Confluence |
Your Account |
Add Content |
|
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.6.0 Build:#913 Sep 27, 2007) |
|
|
|