Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2010-04-26 23:07:43 +0000
committerslewis2010-04-26 23:07:43 +0000
commit5f8150c36e0a10b25a5752da46449a74a66bb064 (patch)
treec57bfd51178ec83b30091baea86e3f7459b45fb2 /examples/bundles
parent025e34d292785f59c4fdcc0413f2f0720e00520b (diff)
downloadorg.eclipse.ecf-5f8150c36e0a10b25a5752da46449a74a66bb064.tar.gz
org.eclipse.ecf-5f8150c36e0a10b25a5752da46449a74a66bb064.tar.xz
org.eclipse.ecf-5f8150c36e0a10b25a5752da46449a74a66bb064.zip
Updated service host, and service server to support being more general, and enhancement https://bugs.eclipse.org/bugs/show_bug.cgi?id=310522. Also added async service interface IDataProcessorAsync.
Diffstat (limited to 'examples/bundles')
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/.settings/org.eclipse.jdt.core.prefs67
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/META-INF/MANIFEST.MF1
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/products/Data Processor Service Host (activemq).product3
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/src/org/eclipse/ecf/internal/examples/loadbalancing/servicehost/DataProcessorServiceHostApplication.java73
4 files changed, 132 insertions, 12 deletions
diff --git a/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/.settings/org.eclipse.jdt.core.prefs b/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/.settings/org.eclipse.jdt.core.prefs
index 89fb0efd3..edcc14a20 100644
--- a/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/.settings/org.eclipse.jdt.core.prefs
+++ b/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/.settings/org.eclipse.jdt.core.prefs
@@ -1,8 +1,73 @@
-#Mon Oct 19 11:04:06 PDT 2009
+#Mon Apr 26 15:40:50 PDT 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.5
diff --git a/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/META-INF/MANIFEST.MF b/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/META-INF/MANIFEST.MF
index b74458d12..f8731e4e6 100644
--- a/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/META-INF/MANIFEST.MF
+++ b/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/META-INF/MANIFEST.MF
@@ -9,6 +9,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.eclipse.ecf.core,
org.eclipse.ecf.core.identity;version="3.0.0",
org.eclipse.ecf.examples.loadbalancing,
+ org.eclipse.ecf.osgi.services.distribution,
org.eclipse.ecf.remoteservice,
org.eclipse.equinox.app;version="1.0.0",
org.osgi.framework;version="1.3.0",
diff --git a/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/products/Data Processor Service Host (activemq).product b/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/products/Data Processor Service Host (activemq).product
index 7eabfdb0a..58d1606aa 100644
--- a/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/products/Data Processor Service Host (activemq).product
+++ b/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/products/Data Processor Service Host (activemq).product
@@ -21,8 +21,11 @@
<plugin id="org.eclipse.ecf.examples.loadbalancing"/>
<plugin id="org.eclipse.ecf.examples.loadbalancing.servicehost"/>
<plugin id="org.eclipse.ecf.identity"/>
+ <plugin id="org.eclipse.ecf.osgi.services.discovery"/>
+ <plugin id="org.eclipse.ecf.osgi.services.distribution"/>
<plugin id="org.eclipse.ecf.provider"/>
<plugin id="org.eclipse.ecf.provider.datashare"/>
+ <plugin id="org.eclipse.ecf.provider.jmdns"/>
<plugin id="org.eclipse.ecf.provider.jms"/>
<plugin id="org.eclipse.ecf.provider.jms.activemq"/>
<plugin id="org.eclipse.ecf.provider.remoteservice"/>
diff --git a/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/src/org/eclipse/ecf/internal/examples/loadbalancing/servicehost/DataProcessorServiceHostApplication.java b/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/src/org/eclipse/ecf/internal/examples/loadbalancing/servicehost/DataProcessorServiceHostApplication.java
index d5324f8a9..be4234374 100644
--- a/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/src/org/eclipse/ecf/internal/examples/loadbalancing/servicehost/DataProcessorServiceHostApplication.java
+++ b/examples/bundles/org.eclipse.ecf.examples.loadbalancing.servicehost/src/org/eclipse/ecf/internal/examples/loadbalancing/servicehost/DataProcessorServiceHostApplication.java
@@ -12,15 +12,17 @@ import java.util.Properties;
import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.IContainerManager;
import org.eclipse.ecf.examples.loadbalancing.IDataProcessor;
+import org.eclipse.ecf.osgi.services.distribution.IDistributionConstants;
import org.eclipse.ecf.remoteservice.Constants;
import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
import org.eclipse.ecf.remoteservice.IRemoteServiceRegistration;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;
-public class DataProcessorServiceHostApplication implements IApplication {
+public class DataProcessorServiceHostApplication implements IApplication, IDistributionConstants {
private static final String LB_SVCHOST_CONTAINER_TYPE = "ecf.jms.activemq.tcp.manager.lb.svchost";
public static final String DEFAULT_QUEUE_ID = "tcp://localhost:61616/exampleQueue";
@@ -29,6 +31,8 @@ public class DataProcessorServiceHostApplication implements IApplication {
private BundleContext bundleContext;
private ServiceTracker containerManagerServiceTracker;
+ private String containerType = LB_SVCHOST_CONTAINER_TYPE;
+
// JMS Queue URI that we will attach to as queue message producer (to issue
// actual remote method/invocation
// requests to server consumers). Note that this queueId can be changed by
@@ -42,6 +46,15 @@ public class DataProcessorServiceHostApplication implements IApplication {
// -topicId tcp://myjmdnsbrokerdnsname:61616/myTopicName
private String topicId = DEFAULT_TOPIC_ID;
+ // The local service registration when using the osgi remote services
+ private ServiceRegistration dataProcessorServiceServiceRegistration;
+
+ private boolean useECFRemoteServices = false;
+ // The following two member variables are only used if the useECFRemoteServices
+ // flag is set to true via command line argument...e.g. -useECFRemoteServices
+ // The default is to use OSGi remote services, and so these two members
+ // will be null
+
// Container instance that connects us with the ActiveMQ queue as a message
// producer and publishes the service on the topicId
private IContainer container;
@@ -54,13 +67,46 @@ public class DataProcessorServiceHostApplication implements IApplication {
// Process Arguments...i.e. set queueId and topicId if specified
processArgs(appContext);
+ // Register and publish as OSGi remote service
+ if (useECFRemoteServices) registerECFRemoteService();
+ else registerOSGiRemoteService();
+
+ // wait for remote service requests until stopped
+ waitForDone();
+
+ return IApplication.EXIT_OK;
+ }
+
+ private void registerOSGiRemoteService() throws Exception {
+ // Setup properties for remote service distribution, as per OSGi 4.2 remote services
+ // specification (chap 13 in compendium spec)
+ Properties props = new Properties();
+ // add OSGi service property indicated export of all interfaces exposed by service (wildcard)
+ props.put(IDistributionConstants.SERVICE_EXPORTED_INTERFACES, IDistributionConstants.SERVICE_EXPORTED_INTERFACES_WILDCARD);
+ // add OSGi service property specifying config
+ props.put(IDistributionConstants.SERVICE_EXPORTED_CONFIGS, containerType);
+ // add ECF container arguments
+ props.put(IDistributionConstants.SERVICE_EXPORTED_CONTAINER_FACTORY_ARGUMENTS, new String[] { topicId, queueId });
+ // This is setting (currently) magical service property that indicates
+ // that this service registration is a load balancing service host
+ props.put(Constants.SERVICE_REGISTER_PROXY, "true");
+ // register remote service
+ dataProcessorServiceServiceRegistration = bundleContext.registerService(IDataProcessor.class
+ .getName(), new IDataProcessor() {
+ public String processData(String data) {
+ return null;
+ }}, props);
+ // tell everyone
+ System.out.println("LB Service Host: DataProcessor Registered via OSGi Remote Services topic="+topicId);
+ }
+
+ private void registerECFRemoteService() throws Exception {
// Create container of appropriate type, and with the topicId and
// queueId set
// upon construction
container = getContainerManagerService().getContainerFactory()
- .createContainer(LB_SVCHOST_CONTAINER_TYPE,
+ .createContainer(containerType,
new Object[] { topicId, queueId });
-
// Get IRemoteServiceContainerAdapter
IRemoteServiceContainerAdapter remoteServiceAdapter = (IRemoteServiceContainerAdapter) container
.getAdapter(IRemoteServiceContainerAdapter.class);
@@ -85,16 +131,14 @@ public class DataProcessorServiceHostApplication implements IApplication {
.registerRemoteService(new String[] { IDataProcessor.class
.getName() }, null, properties);
- System.out.println("Registered service host with registration="
- + dataProcessorServiceHostRegistration);
-
- // wait for remote service requests until stopped
- waitForDone();
-
- return IApplication.EXIT_OK;
+ System.out.println("LB Service Host: DataProcessor Registered via ECF Remote Services topic="+topicId);
}
-
+
public void stop() {
+ if (dataProcessorServiceServiceRegistration != null) {
+ dataProcessorServiceServiceRegistration.unregister();
+ dataProcessorServiceServiceRegistration = null;
+ }
if (dataProcessorServiceHostRegistration != null) {
dataProcessorServiceHostRegistration.unregister();
dataProcessorServiceHostRegistration = null;
@@ -109,6 +153,10 @@ public class DataProcessorServiceHostApplication implements IApplication {
containerManagerServiceTracker = null;
}
bundleContext = null;
+ synchronized (appLock) {
+ done = true;
+ notifyAll();
+ }
}
private void processArgs(IApplicationContext appContext) {
@@ -123,6 +171,9 @@ public class DataProcessorServiceHostApplication implements IApplication {
} else if (originalArgs[i].equals("-topicId")) {
topicId = originalArgs[i + 1];
i++;
+ } else if (originalArgs[i].equals("-containerType")) {
+ containerType = originalArgs[i + 1];
+ i++;
}
}
}

Back to the top