Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2010-09-25 00:50:36 +0000
committerslewis2010-09-25 00:50:36 +0000
commite0d8b521519c56f887162266298fd676a1d20468 (patch)
treeeff533e554e9e49afd214d655e23a100be45e879 /examples
parent61c44ec9dd7fb63da0bb3c5449131dc02a05b1e5 (diff)
downloadorg.eclipse.ecf-e0d8b521519c56f887162266298fd676a1d20468.tar.gz
org.eclipse.ecf-e0d8b521519c56f887162266298fd676a1d20468.tar.xz
org.eclipse.ecf-e0d8b521519c56f887162266298fd676a1d20468.zip
Simplified example
Diffstat (limited to 'examples')
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.loadbalancing.consumer/src/org/eclipse/ecf/internal/examples/loadbalancing/consumer/DataProcessorConsumerApplication.java38
1 files changed, 23 insertions, 15 deletions
diff --git a/examples/bundles/org.eclipse.ecf.examples.loadbalancing.consumer/src/org/eclipse/ecf/internal/examples/loadbalancing/consumer/DataProcessorConsumerApplication.java b/examples/bundles/org.eclipse.ecf.examples.loadbalancing.consumer/src/org/eclipse/ecf/internal/examples/loadbalancing/consumer/DataProcessorConsumerApplication.java
index 55aca0381..b9258eab3 100644
--- a/examples/bundles/org.eclipse.ecf.examples.loadbalancing.consumer/src/org/eclipse/ecf/internal/examples/loadbalancing/consumer/DataProcessorConsumerApplication.java
+++ b/examples/bundles/org.eclipse.ecf.examples.loadbalancing.consumer/src/org/eclipse/ecf/internal/examples/loadbalancing/consumer/DataProcessorConsumerApplication.java
@@ -10,6 +10,7 @@ package org.eclipse.ecf.internal.examples.loadbalancing.consumer;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.IContainerManager;
import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.examples.loadbalancing.IDataProcessor;
import org.eclipse.ecf.remoteservice.IRemoteService;
import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
@@ -35,7 +36,8 @@ public class DataProcessorConsumerApplication implements IApplication {
// changed by using the -topicId launch parameter...e.g.
// -topicId tcp://myjmdnsbrokerdnsname:61616/myTopicName
private String topicId = DEFAULT_TOPIC_ID;
- // Container type is the load balancing service consumer container type, which is normal client
+ // Container type is the load balancing service consumer container type,
+ // which is normal client
private String containerType = LB_SVCCONSUMER_CONTAINER_TYPE;
// Container instance that connects us with the ActiveMQ queue as a message
@@ -50,15 +52,26 @@ public class DataProcessorConsumerApplication implements IApplication {
private final Object remoteServiceReceivedLock = new Object();
private boolean remoteServiceReceived = false;
- // Remote service. The RemoteServiceTrackerCustomizer sets this
+ // Remote service. The RemoteServiceTrackerCustomizer sets this
IRemoteService remoteService;
class RemoteServiceTrackerCustomizer implements
IRemoteServiceTrackerCustomizer {
public IRemoteService addingService(IRemoteServiceReference reference) {
- remoteService = remoteServiceAdapter
- .getRemoteService(reference);
+ remoteService = remoteServiceAdapter.getRemoteService(reference);
+ try {
+ IDataProcessor dataProcessorProxy = (IDataProcessor) remoteService
+ .getProxy();
+ System.out.println("Calling remote service with input data="
+ + inputData);
+ // And then call it
+ String result = dataProcessorProxy.processData(inputData);
+ // And print out results
+ System.out.println("\tremote service result=" + result);
+ } catch (ECFException e) {
+ e.printStackTrace();
+ }
synchronized (remoteServiceReceivedLock) {
remoteServiceReceived = true;
remoteServiceReceivedLock.notify();
@@ -95,21 +108,16 @@ public class DataProcessorConsumerApplication implements IApplication {
// Open it
tracker.open();
- // Connect to topic
+ // Connect to topic. This should trigger remote service registration to be asynchronously
+ // added, and in turn call RemoteServiceTrackerCustomizer.addingService (see impl of that
+ // method above
container.connect(
IDFactory.getDefault().createID(
container.getConnectNamespace(), topicId), null);
-
- // Wait for remote service tracker to receive proxy
- waitForRemoteService();
- IDataProcessor dataProcessorProxy = (IDataProcessor) remoteService.getProxy();
- System.out.println("Calling remote service with input data="
- + inputData);
- // And then call it
- String result = dataProcessorProxy.processData(inputData);
- // And print out results
- System.out.println("\tremote service result=" + result);
+ // Wait for remote service tracker to receive proxy and execute. See
+ // RemoteServiceTrackerCustomizer.addingService above
+ waitForRemoteService();
return IApplication.EXIT_OK;
}

Back to the top