Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2015-07-02 20:54:14 +0000
committerslewis2015-07-02 20:54:14 +0000
commit6c62176fca4ba492e4349b219d14375fbea4504e (patch)
tree3dc0e4d82bfb13ef99e5486b290ba664ae2b27cf /examples/bundles
parent3988dafe379699d08dd2e600b73363f83c507e96 (diff)
downloadorg.eclipse.ecf-6c62176fca4ba492e4349b219d14375fbea4504e.tar.gz
org.eclipse.ecf-6c62176fca4ba492e4349b219d14375fbea4504e.tar.xz
org.eclipse.ecf-6c62176fca4ba492e4349b219d14375fbea4504e.zip
Fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=471745
Diffstat (limited to 'examples/bundles')
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.host/META-INF/MANIFEST.MF2
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/Activator.java67
2 files changed, 46 insertions, 23 deletions
diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/META-INF/MANIFEST.MF b/examples/bundles/com.mycorp.examples.timeservice.host/META-INF/MANIFEST.MF
index 29dba50dc..08a03c681 100644
--- a/examples/bundles/com.mycorp.examples.timeservice.host/META-INF/MANIFEST.MF
+++ b/examples/bundles/com.mycorp.examples.timeservice.host/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ECF RS Example Timeservice Host
Bundle-SymbolicName: com.mycorp.examples.timeservice.host
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.1.100.qualifier
Bundle-Vendor: Eclipse.org - ECF
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/Activator.java b/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/Activator.java
index 3e1aa4f82..83e241239 100644
--- a/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/Activator.java
+++ b/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/Activator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Composent, Inc. All rights reserved. This
+ * Copyright (c) 2015 Composent, Inc. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -22,21 +22,24 @@ import com.mycorp.examples.timeservice.ITimeService;
public class Activator implements BundleActivator {
+ private static final boolean verbose = Boolean.valueOf(System.getProperty(
+ "verboseRemoteServiceAdmin", "true"));
+
+ private ServiceRegistration<ITimeService> timeServiceRegistration;
+
public void start(BundleContext context) throws Exception {
- // If the verboseRemoteServiceAdmin system property is set
- // then register debug listener
- if (Boolean.getBoolean("verboseRemoteServiceAdmin"))
+ // If verbose is not turned off then register debug listener
+ if (verbose)
context.registerService(RemoteServiceAdminListener.class,
new DebugRemoteServiceAdminListener(), null);
- // Create remote service properties...see
- // createRemoteServiceProperties()
+ // Create remote service properties
Dictionary<String, Object> props = createRemoteServiceProperties();
// Create MyTimeService impl and register/export as a remote service
- ServiceRegistration<ITimeService> timeServiceRegistration = context
- .registerService(ITimeService.class, new TimeServiceImpl(),
- props);
+ // via the remote service properties
+ timeServiceRegistration = context.registerService(ITimeService.class,
+ new TimeServiceImpl(), props);
// Print out that ITimeService remote service registration
System.out.println("TimeService host registered with registration="
@@ -44,25 +47,45 @@ public class Activator implements BundleActivator {
}
public void stop(BundleContext context) throws Exception {
- // do nothing
+ if (timeServiceRegistration != null) {
+ timeServiceRegistration.unregister();
+ timeServiceRegistration = null;
+ }
}
+ private static final String SERVICE_EXPORTED_CONFIGS = "service.exported.configs";
+ private static final String DEFAULT_CONFIG = "ecf.generic.server";
+
private Dictionary<String, Object> createRemoteServiceProperties() {
// This is the only required service property to trigger remote services
- Dictionary<String, Object> result = new Hashtable<String, Object>();
+ Hashtable<String, Object> result = new Hashtable<String, Object>();
+ // This property is required by the Remote Services specification
+ // (chapter 100 in enterprise specification), and when set results
+ // in RSA impl exporting as a remote service
result.put("service.exported.interfaces", "*");
+ // async interfaces is an ECF Remote Services service property
+ // that allows any declared asynchronous interfaces
+ // to be used by consumers.
+ // See https://wiki.eclipse.org/ECF/Asynchronous_Remote_Services
+ result.put("ecf.exported.async.interfaces", "*");
+ // get system properties
Properties props = System.getProperties();
- String config = props.getProperty("service.exported.configs");
- if (config != null) {
- result.put("service.exported.configs", config);
- String configProps = config + ".";
- for (Object k : props.keySet()) {
- if (k instanceof String) {
- String key = (String) k;
- if (key.startsWith(configProps)
- || key.equals("ecf.exported.async.interfaces"))
- result.put(key, props.getProperty(key));
- }
+ // Get OSGi service.exported.configs property
+ String config = props.getProperty(SERVICE_EXPORTED_CONFIGS);
+ if (config == null) {
+ config = DEFAULT_CONFIG;
+ result.put(DEFAULT_CONFIG + ".port", "3288");
+ result.put(DEFAULT_CONFIG + ".hostname", "localhost");
+ }
+
+ result.put(SERVICE_EXPORTED_CONFIGS, config);
+ // add any config properties. config properties start with
+ // the config name '.' property
+ for (Object k : result.keySet()) {
+ if (k instanceof String) {
+ String key = (String) k;
+ if (key.startsWith(config))
+ result.put(key, result.get(key));
}
}
return result;

Back to the top