Migrating from GraniteDS 3.0.0.M3 to 3.0.0.RC1 (JavaFX) | Granite Data Services

Cocomonio


News and Updates


Migrating from GraniteDS 3.0.0.M3 to 3.0.0.RC1 (JavaFX)

By Franck October 15th, 2013 GraniteDS, JavaFX No Comments

There have been once again some changes in the client APIs which will require changing your code.

Package names

Several packages have been renamed to a more consistent convention under the prefix ‘org.granite.client.javafx’. Usually a simple ‘Optimize imports’ or search/replace in your IDE should be enough to do the necessary changes.

ChannelFactory API

The ChannelFactory API has been slighly changed to allow different channel types:

ChannelFactory channelFactory = new JMFChannelFactory();
channelFactory.start();
MessagingChannel channel = channelFactory.newMessagingChannel("long-polling",
    "longPollingChannel", "http://localhost:8080/gravityamf/amf.txt")
Consumer consumer = new Consumer(channel, "stocks", "europe");

For a websocket channel, you will also have to configure the transport:

ChannelFactory channelFactory = new JMFChannelFactory();
channelFactory.setMessagingTransport("websocket",
    new JettyWebSocketTransport());
channelFactory.start();
MessagingChannel channel = channelFactory.newMessagingChannel("websocket",
    "websocketChannel", "ws://localhost:8080/myapp/gravityamf/amf")
Consumer consumer = new Consumer(channel, "stocks", "europe");

For a UDP channel, assuming the granite-client-java-udp.jar library is present:

ChannelFactory channelFactory = new JMFChannelFactory();
channelFactory.start();
MessagingChannel channel = channelFactory.newMessagingChannel("udp",
    "udpChannel", "http://localhost:8080/myapp/gravityamf/amf.txt")
Consumer consumer = new Consumer(channel, "stocks", "europe");

Of course you can mix all these channels and get them from the same ChannelFactory.

Additionally you can use the ServerApp API if you don’t want to build the url yourself:

ServerApp serverApp = new ServerApp("/myapp", false, "localhost", 8080);
ChannelFactory channelFactory = new JMFChannelFactory();
channelFactory.start();
MessagingChannel lpChannel = channelFactory.newMessagingChannel("long-polling",
    "longPollingChannel", serverApp);
MessagingChannel wsChannel = channelFactory.newMessagingChannel("websocket",
    "websocketChannel", serverApp);
MessagingChannel udpChannel = channelFactory.newMessagingChannel("udp",
    "udpChannel", serverApp);
ServerSession API

The ServerSession API has also been updated.

You can now use the ServerSession to build Consumer and Producer objects:

ServerSession serverSession = new ServerSession("/myapp", "localhost", 8080);
serverSession.setMessagingTransport("websocket",
    new JettyWebSocketTransport());
serverSession.start();
Consumer lpConsumer = serverSession.getConsumer("long-polling",
    "stocks", "europe");
Consumer wsConsumer = serverSession.getConsumer("websocket",
    "stocks", "usa");
Consumer udpConsumer = serverSession.getConsumer("websocket",
    "stocks", "asia");

The GraniteDS Team.



Post Comment


Your email address will not be published. Required fields are marked *