Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2015-04-09 23:32:43 +0000
committerslewis2015-04-09 23:32:43 +0000
commit46cf063609de706aff74dc6d204f4e45df0240ea (patch)
tree671db047efaf006e58b77d2dfc372565df2c3f1a /examples/bundles/com.mycorp.examples.timeservice.host/src
parent231a2d3ccbc2652a0a2265f4f698f65972c66635 (diff)
downloadorg.eclipse.ecf-46cf063609de706aff74dc6d204f4e45df0240ea.tar.gz
org.eclipse.ecf-46cf063609de706aff74dc6d204f4e45df0240ea.tar.xz
org.eclipse.ecf-46cf063609de706aff74dc6d204f4e45df0240ea.zip
Simplified timeservice host and consumer by using
DebugRemoteServiceAdminListener utility class for debug output Change-Id: I81e8a0ad0c97cb936532b25722173a192ec285af
Diffstat (limited to 'examples/bundles/com.mycorp.examples.timeservice.host/src')
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/Activator.java39
-rw-r--r--examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/ActivatorSimple.java38
2 files changed, 3 insertions, 74 deletions
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 997d05723..3e1aa4f82 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
@@ -12,10 +12,10 @@ import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Properties;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.DebugRemoteServiceAdminListener;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener;
import com.mycorp.examples.timeservice.ITimeService;
@@ -26,7 +26,8 @@ public class Activator implements BundleActivator {
// If the verboseRemoteServiceAdmin system property is set
// then register debug listener
if (Boolean.getBoolean("verboseRemoteServiceAdmin"))
- registerDebugListener(context);
+ context.registerService(RemoteServiceAdminListener.class,
+ new DebugRemoteServiceAdminListener(), null);
// Create remote service properties...see
// createRemoteServiceProperties()
@@ -67,38 +68,4 @@ public class Activator implements BundleActivator {
return result;
}
- // Register a RemoteServiceAdminListener so we can report to sdtout
- // when a remote service has actually been successfully exported by
- // the RSA implementation
- private void registerDebugListener(BundleContext context) {
- RemoteServiceAdminListener rsaListener = new RemoteServiceAdminListener() {
- public void remoteAdminEvent(RemoteServiceAdminEvent event) {
- switch (event.getType()) {
- case RemoteServiceAdminEvent.EXPORT_REGISTRATION:
- System.out
- .println("RSA: Service Exported. EndpointDescription="
- + event.getExportReference()
- .getExportedEndpoint()
- .getProperties());
- break;
- case RemoteServiceAdminEvent.EXPORT_ERROR:
- Throwable t = event.getException();
- System.err.println("RSA: EXPORT ERROR. Error message="
- + ((t == null) ? "none" : t.getMessage())
- + ". EndpointDescription="
- + event.getExportReference().getExportedEndpoint()
- .getProperties() + "");
- if (t != null)
- t.printStackTrace();
- break;
- }
- }
-
- };
- // Register our listener as service via whiteboard pattern, and
- // RemoteServiceAdmin will callback
- context.registerService(RemoteServiceAdminListener.class.getName(),
- rsaListener, null);
- }
-
}
diff --git a/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/ActivatorSimple.java b/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/ActivatorSimple.java
deleted file mode 100644
index 4406486df..000000000
--- a/examples/bundles/com.mycorp.examples.timeservice.host/src/com/mycorp/examples/timeservice/host/ActivatorSimple.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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
- *
- * Contributors: Scott Lewis - initial API and implementation
- ******************************************************************************/
-package com.mycorp.examples.timeservice.host;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-import com.mycorp.examples.timeservice.ITimeService;
-
-public class ActivatorSimple implements BundleActivator {
-
- public void start(BundleContext context) throws Exception {
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("service.exported.interfaces", "*");
- props.put("service.exported.configs","ecf.generic.server");
- props.put("ecf.generic.server.id", "ecftcp://localhost:3288/server");
- ServiceRegistration<ITimeService> timeServiceRegistration = context
- .registerService(ITimeService.class, new TimeServiceImpl(),
- props);
- System.out.println("MyTimeService host registered with registration="
- + timeServiceRegistration);
- }
-
- public void stop(BundleContext context) throws Exception {
- // do nothing
- }
-
-}

Back to the top