summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Campo2008-02-11 12:01:10 (EST)
committerChristian Campo2008-02-11 12:01:10 (EST)
commit202fced9b6f697e0963c0fcdcd979ece3a8ef05c (patch)
tree04d1ed3a58e440a7986f18316789290815b01a67
parentdf28e0cde7bee05ec84cedf0fc70abfd1dc8bf2f (diff)
downloadorg.eclipse.riena-202fced9b6f697e0963c0fcdcd979ece3a8ef05c.zip
org.eclipse.riena-202fced9b6f697e0963c0fcdcd979ece3a8ef05c.tar.gz
org.eclipse.riena-202fced9b6f697e0963c0fcdcd979ece3a8ef05c.tar.bz2
replaced System.out with logging
-rw-r--r--org.eclipse.riena.communication.console/META-INF/MANIFEST.MF6
-rw-r--r--org.eclipse.riena.communication.console/src/org/eclipse/riena/internal/communication/console/Activator.java94
-rw-r--r--org.eclipse.riena.communication.console/src/org/eclipse/riena/internal/communication/console/CommunicationConsole.java195
-rw-r--r--org.eclipse.riena.communication.core/META-INF/MANIFEST.MF11
-rw-r--r--org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceBuilder.java117
-rw-r--r--org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceFactory.java38
-rw-r--r--org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/Activator.java97
7 files changed, 307 insertions, 251 deletions
diff --git a/org.eclipse.riena.communication.console/META-INF/MANIFEST.MF b/org.eclipse.riena.communication.console/META-INF/MANIFEST.MF
index 19122c2..0b3fd07 100644
--- a/org.eclipse.riena.communication.console/META-INF/MANIFEST.MF
+++ b/org.eclipse.riena.communication.console/META-INF/MANIFEST.MF
@@ -4,7 +4,9 @@ Bundle-Name: Riena Communication Console (Incubation)
Bundle-SymbolicName: org.eclipse.riena.communication.console
Bundle-Version: 0.0.1
Bundle-Activator: org.eclipse.riena.internal.communication.console.Activator
-Import-Package: org.osgi.framework;version="1.4.0"
+Import-Package: org.osgi.framework;version="1.4.0",
+ org.osgi.service.log;version="1.3.0"
Require-Bundle: org.eclipse.riena.communication.core,
org.eclipse.osgi,
- org.eclipse.riena.core
+ org.eclipse.riena.core,
+ org.eclipse.equinox.log
diff --git a/org.eclipse.riena.communication.console/src/org/eclipse/riena/internal/communication/console/Activator.java b/org.eclipse.riena.communication.console/src/org/eclipse/riena/internal/communication/console/Activator.java
index 677a264..593017b 100644
--- a/org.eclipse.riena.communication.console/src/org/eclipse/riena/internal/communication/console/Activator.java
+++ b/org.eclipse.riena.communication.console/src/org/eclipse/riena/internal/communication/console/Activator.java
@@ -12,54 +12,78 @@ package org.eclipse.riena.internal.communication.console;
import java.util.Hashtable;
+import org.eclipse.equinox.log.Logger;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.eclipse.riena.communication.core.IRemoteServiceRegistry;
import org.eclipse.riena.communication.core.publisher.IServicePublishEventDispatcher;
import org.eclipse.riena.communication.core.publisher.RSDPublisherProperties;
+import org.eclipse.riena.core.logging.LogUtil;
import org.eclipse.riena.core.service.ServiceInjector;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-
public class Activator implements BundleActivator {
- private ServiceRegistration consoleReg;
- private ServiceInjector publisherInjector;
- private ServiceInjector registryInjector;
+ private ServiceRegistration consoleReg;
+ private ServiceInjector publisherInjector;
+ private ServiceInjector registryInjector;
+ private LogUtil logUtil;
+ private static BundleContext CONTEXT;
+ private static Activator plugin;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ CONTEXT = context;
+ plugin = this;
+ // register new OSGi command interpreter
+ CommunicationConsole console = new CommunicationConsole();
+ // the filter applies only if the service is living in this container
+ // e.g. server.
+ String filter = "(" + RSDPublisherProperties.PROP_IS_REMOTE + "=true)";
+ publisherInjector = new ServiceInjector(context, IServicePublishEventDispatcher.ID, filter, console,
+ "bindServicePublisher", "unbindServicePublisher");
+ publisherInjector.start();
+ registryInjector = new ServiceInjector(context, IRemoteServiceRegistry.ID, console, "bindServiceRegistry",
+ "unbindServiceRegistry");
+ registryInjector.start();
+
+ consoleReg = context.registerService(CommandProvider.class.getName(), console, new Hashtable<String, String>());
+
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- // register new OSGi command interpreter
- CommunicationConsole console = new CommunicationConsole();
- // the filter applies only if the service is living in this container
- // e.g. server.
- String filter = "(" + RSDPublisherProperties.PROP_IS_REMOTE + "=true)";
- publisherInjector = new ServiceInjector(context, IServicePublishEventDispatcher.ID, filter, console, "bindServicePublisher",
- "unbindServicePublisher");
- publisherInjector.start();
- registryInjector = new ServiceInjector(context, IRemoteServiceRegistry.ID, console, "bindServiceRegistry", "unbindServiceRegistry");
- registryInjector.start();
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ publisherInjector.dispose();
+ publisherInjector = null;
+ registryInjector.dispose();
+ registryInjector = null;
+ consoleReg.unregister();
+ consoleReg = null;
+ CONTEXT = null;
+ plugin = null;
+ }
- consoleReg = context.registerService(CommandProvider.class.getName(), console, new Hashtable<String, String>());
+ public static Activator getDefault() {
+ return plugin;
+ }
- }
+ public static BundleContext getContext() {
+ return CONTEXT;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- publisherInjector.dispose();
- publisherInjector = null;
- registryInjector.dispose();
- registryInjector = null;
- consoleReg.unregister();
- consoleReg = null;
- }
+ public Logger getLogger(String name) {
+ if (logUtil == null) {
+ logUtil = new LogUtil(CONTEXT);
+ }
+ return logUtil.getLogger(name);
+ }
} \ No newline at end of file
diff --git a/org.eclipse.riena.communication.console/src/org/eclipse/riena/internal/communication/console/CommunicationConsole.java b/org.eclipse.riena.communication.console/src/org/eclipse/riena/internal/communication/console/CommunicationConsole.java
index 8dca1c4..c709c7c 100644
--- a/org.eclipse.riena.communication.console/src/org/eclipse/riena/internal/communication/console/CommunicationConsole.java
+++ b/org.eclipse.riena.communication.console/src/org/eclipse/riena/internal/communication/console/CommunicationConsole.java
@@ -21,105 +21,100 @@ import org.eclipse.riena.communication.core.RemoteServiceDescription;
import org.eclipse.riena.communication.core.publisher.IServicePublishEventDispatcher;
public class CommunicationConsole implements CommandProvider {
- IServicePublishEventDispatcher servicePublisher;
- IRemoteServiceRegistry serviceRegistry;
-
- public String getHelp() {
- return "---riena communication---\n\tremotestatus - list all services";
- }
-
- public void _remotestatus(CommandInterpreter ci) throws Exception {
- printToPublishServices();
- printPublishedServices();
- printRegisteredRemoteServices();
-
- }
-
- private void printToPublishServices() {
- if (servicePublisher == null) {
- return;
- }
- RemoteServiceDescription[] rsDescs = servicePublisher.getAllServices();
-
- // boolean found = false;
- for (RemoteServiceDescription rsDesc : rsDescs) {
- if (rsDesc.getType() == RemoteServiceDescription.STATUS_UNREGISTERED) {
- // found = true;
- System.out.println("Riena:: not published end point=(" + rsDesc + ")");
- }
- }
- // if (!found) {
- // System.out.println("Riena:: no OSGi services to publish");
- // return;
- // }
-
- }
-
- private void printPublishedServices() {
- if (servicePublisher == null) {
- return;
- }
- RemoteServiceDescription[] rsDescs = servicePublisher.getAllServices();
- boolean found = false;
- for (RemoteServiceDescription rsDesc : rsDescs) {
- if (rsDesc.getType() == RemoteServiceDescription.STATUS_REGISTERED) {
- found = true;
- System.out.println("Riena:: published end point=(" + rsDesc + ")");
- }
- }
- if (!found) {
- System.out.println("Riena:: no OSGi services published");
- return;
- }
-
- }
-
- private void printRegisteredRemoteServices() {
- if (serviceRegistry == null) {
- // System.out.println("Riena:: no OSGi services registered");
- return;
- }
- List<IRemoteServiceRegistration> rsRegs = serviceRegistry.registeredServices("*");
- if (rsRegs.size() == 0) {
- System.out.println("Riena:: no Remote OSGi services registered");
- return;
- }
- for (IRemoteServiceRegistration rsReg : rsRegs) {
- IRemoteServiceReference rsRef = rsReg.getReference();
- System.out.println("Riena:: registered remoteServiceRef=(" + rsRef + ")");
- }
- }
-
- /**
- * @param servicePublisher
- * the servicePublisher to bind
- */
- public void bindServicePublisher(IServicePublishEventDispatcher servicePublisher) {
- this.servicePublisher = servicePublisher;
- }
-
- /**
- * @param servicePublisher
- * the servicePublisher to unbind
- */
- public void unbindServicePublisher(IServicePublishEventDispatcher servicePublisher) {
- this.servicePublisher = null;
- }
-
- /**
- * @param serviceRegistry
- * the serviceRegistry to bind
- */
- public void bindServiceRegistry(IRemoteServiceRegistry serviceRegistry) {
- this.serviceRegistry = serviceRegistry;
- }
-
- /**
- * @param serviceRegistry
- * the serviceRegistry to unbind
- */
- public void unbindServiceRegistry(IRemoteServiceRegistry serviceRegistry) {
- this.serviceRegistry = null;
- }
+ IServicePublishEventDispatcher servicePublisher;
+ IRemoteServiceRegistry serviceRegistry;
+
+ public String getHelp() {
+ return "---riena communication---\n\tremotestatus - list all services";
+ }
+
+ public void _remotestatus(CommandInterpreter ci) throws Exception {
+ printToPublishServices();
+ printPublishedServices();
+ printRegisteredRemoteServices();
+
+ }
+
+ private void printToPublishServices() {
+ if (servicePublisher == null) {
+ return;
+ }
+ RemoteServiceDescription[] rsDescs = servicePublisher.getAllServices();
+
+ // boolean found = false;
+ for (RemoteServiceDescription rsDesc : rsDescs) {
+ if (rsDesc.getType() == RemoteServiceDescription.STATUS_UNREGISTERED) {
+ // found = true;
+ System.out.println("Riena:: not published end point=(" + rsDesc + ")");
+ }
+ }
+ }
+
+ private void printPublishedServices() {
+ if (servicePublisher == null) {
+ return;
+ }
+ RemoteServiceDescription[] rsDescs = servicePublisher.getAllServices();
+ boolean found = false;
+ for (RemoteServiceDescription rsDesc : rsDescs) {
+ if (rsDesc.getType() == RemoteServiceDescription.STATUS_REGISTERED) {
+ found = true;
+ System.out.println("Riena:: published end point=(" + rsDesc + ")");
+ }
+ }
+ if (!found) {
+ System.out.println("Riena:: no OSGi services published");
+ return;
+ }
+
+ }
+
+ private void printRegisteredRemoteServices() {
+ if (serviceRegistry == null) {
+ // System.out.println("Riena:: no OSGi services registered");
+ return;
+ }
+ List<IRemoteServiceRegistration> rsRegs = serviceRegistry.registeredServices("*");
+ if (rsRegs.size() == 0) {
+ System.out.println("Riena:: no Remote OSGi services registered");
+ return;
+ }
+ for (IRemoteServiceRegistration rsReg : rsRegs) {
+ IRemoteServiceReference rsRef = rsReg.getReference();
+ System.out.println("Riena:: registered remoteServiceRef=(" + rsRef + ")");
+ }
+ }
+
+ /**
+ * @param servicePublisher
+ * the servicePublisher to bind
+ */
+ public void bindServicePublisher(IServicePublishEventDispatcher servicePublisher) {
+ this.servicePublisher = servicePublisher;
+ }
+
+ /**
+ * @param servicePublisher
+ * the servicePublisher to unbind
+ */
+ public void unbindServicePublisher(IServicePublishEventDispatcher servicePublisher) {
+ this.servicePublisher = null;
+ }
+
+ /**
+ * @param serviceRegistry
+ * the serviceRegistry to bind
+ */
+ public void bindServiceRegistry(IRemoteServiceRegistry serviceRegistry) {
+ this.serviceRegistry = serviceRegistry;
+ }
+
+ /**
+ * @param serviceRegistry
+ * the serviceRegistry to unbind
+ */
+ public void unbindServiceRegistry(IRemoteServiceRegistry serviceRegistry) {
+ this.serviceRegistry = null;
+ }
}
diff --git a/org.eclipse.riena.communication.core/META-INF/MANIFEST.MF b/org.eclipse.riena.communication.core/META-INF/MANIFEST.MF
index c6fe9f3..fccfdf2 100644
--- a/org.eclipse.riena.communication.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.riena.communication.core/META-INF/MANIFEST.MF
@@ -5,7 +5,10 @@ Bundle-SymbolicName: org.eclipse.riena.communication.core;singleton:=true
Bundle-Version: 0.0.1
Bundle-Activator: org.eclipse.riena.internal.communication.core.Activator
Import-Package: javax.servlet.http;version="2.4.0",
- org.osgi.framework;version="1.4.0"
+ org.osgi.framework;version="1.4.0",
+ org.osgi.service.cm;version="1.2.0",
+ org.osgi.service.component;version="1.0.0",
+ org.osgi.service.log;version="1.3.0"
Eclipse-LazyStart: true
Export-Package: org.eclipse.riena.communication.core,
org.eclipse.riena.communication.core.factory,
@@ -14,7 +17,7 @@ Export-Package: org.eclipse.riena.communication.core,
org.eclipse.riena.communication.core.util
Eclipse-BuddyPolicy: registered
Eclipse-RegisterBuddy: com.caucho.hessian
-Require-Bundle: org.eclipse.osgi.services,
- org.eclipse.core.runtime,
+Require-Bundle: org.eclipse.core.runtime,
com.caucho.hessian,
- org.eclipse.riena.core
+ org.eclipse.riena.core,
+ org.eclipse.equinox.log
diff --git a/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceBuilder.java b/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceBuilder.java
index a381879..14d16c1 100644
--- a/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceBuilder.java
+++ b/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceBuilder.java
@@ -19,30 +19,36 @@ import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
/**
- * The RemoteServiceBuilder creates, registers and unregisters OSGi Services by Service Declaration. A Service
- * Declaration defines an remote service end point by properties. The RemoteServiceBuilder use the properties to create
- * a proxy reference (see {@link IRemoteServiceFactory}) and register this For this purpose define RemoteServiceBuilder
- * as implementation class within the component declaration and sets follow properties:
+ * The RemoteServiceBuilder creates, registers and unregisters OSGi Services by
+ * Service Declaration. A Service Declaration defines an remote service end
+ * point by properties. The RemoteServiceBuilder use the properties to create a
+ * proxy reference (see {@link IRemoteServiceFactory}) and register this For
+ * this purpose define RemoteServiceBuilder as implementation class within the
+ * component declaration and sets follow properties:
* <p>
* <ul>
- * <li>'riena.interface' - defines the the interface class of the "remote OSGi Service. The OSGi Service become
- * registered with this name too</li>
- * <li>'riena.remote.path' - defines the context path for the remote service end point</li>
- * <li>'riena.remote.protocol' - defines the web service protocol. See also {@link IServicePublisher} and
- * {@link IRemoteServiceFactory}
+ * <li>'riena.interface' - defines the the interface class of the "remote OSGi
+ * Service. The OSGi Service become registered with this name too</li>
+ * <li>'riena.remote.path' - defines the context path for the remote service
+ * end point</li>
+ * <li>'riena.remote.protocol' - defines the web service protocol. See also
+ * {@link IServicePublisher} and {@link IRemoteServiceFactory}
* <li>
* </ul>
* <p>
* Usage e.g.
* <p>
*
- * &lt;component name=&quot;foo.my.component&quot; immediate=&quot;true&quot;&gt;<br>
+ * &lt;component name=&quot;foo.my.component&quot;
+ * immediate=&quot;true&quot;&gt;<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;implementation
* class=&quot;org.eclipse.riena.communication.core.factory.RemoteServiceBuilder&quot;/&gt;<br>
- * &nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=&quot;riena.interface&quot; value=&quot;foo.my.service.MyService&quot;/&gt;<br>
+ * &nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=&quot;riena.interface&quot;
+ * value=&quot;foo.my.service.MyService&quot;/&gt;<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=&quot;riena.remote.path&quot;
* value=&quot;http://localhost/hessian/MyServiceWS&quot;/&gt;<br>
- * &nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=&quot;riena.remote.protocol&quot; value=&quot;hessian&quot;/&gt;<br>
+ * &nbsp;&nbsp;&nbsp;&nbsp;&lt;property name=&quot;riena.remote.protocol&quot;
+ * value=&quot;hessian&quot;/&gt;<br>
* &lt;/component&gt;<br>
* <p>
*
@@ -51,54 +57,53 @@ import org.osgi.service.component.ComponentContext;
*/
public class RemoteServiceBuilder {
- private static final String HOST_ID = RemoteServiceBuilder.class.getName();
- private IRemoteServiceRegistration rsReg;
+ private static final String HOST_ID = RemoteServiceBuilder.class.getName();
+ private IRemoteServiceRegistration rsReg;
- /**
- * Create a instance of RemoteServiceBuilder
- */
- public RemoteServiceBuilder() {
- super();
- System.out.println("Riena::RemoteServiceBuilder:: debug construct");
- }
+ /**
+ * Create a instance of RemoteServiceBuilder
+ */
+ public RemoteServiceBuilder() {
+ super();
+ }
- /**
- * Creates a proxy reference for a end point described by Service Declaration. Register the proxy reference as
- * remote service into the {@link IRemoteServiceRegistry}. The "remote" service become registered as OSGi Service
- * within this client container. The property "riena.interface" defines the interface type and OSGi Service name.
- * The context holds the declarated properties for the remote end point.
- *
- * @param context
- */
- protected void activate(ComponentContext context) {
- System.out.println("Riena::RemoteServiceBuilder:: debug activate");
- try {
- String serviceClassName = (String) context.getProperties().get(RSDPublisherProperties.PROP_INTERFACE);
- Class<?> serviceClass = Class.forName(serviceClassName);
- String path = (String) context.getProperties().get(RSDPublisherProperties.PROP_REMOTE_PATH);
- String protocol = (String) context.getProperties().get(RSDPublisherProperties.PROP_REMOTE_PROTOCOL);
+ /**
+ * Creates a proxy reference for a end point described by Service
+ * Declaration. Register the proxy reference as remote service into the
+ * {@link IRemoteServiceRegistry}. The "remote" service become registered
+ * as OSGi Service within this client container. The property
+ * "riena.interface" defines the interface type and OSGi Service name. The
+ * context holds the declarated properties for the remote end point.
+ *
+ * @param context
+ */
+ protected void activate(ComponentContext context) {
+ try {
+ String serviceClassName = (String) context.getProperties().get(RSDPublisherProperties.PROP_INTERFACE);
+ Class<?> serviceClass = Class.forName(serviceClassName);
+ String path = (String) context.getProperties().get(RSDPublisherProperties.PROP_REMOTE_PATH);
+ String protocol = (String) context.getProperties().get(RSDPublisherProperties.PROP_REMOTE_PROTOCOL);
- RemoteServiceFactory factory = new RemoteServiceFactory();
- rsReg = factory.createAndRegisterProxy(serviceClass, path, protocol, null, HOST_ID);
+ RemoteServiceFactory factory = new RemoteServiceFactory();
+ rsReg = factory.createAndRegisterProxy(serviceClass, path, protocol, null, HOST_ID);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
- /**
- * Unregister the "remote" service from the {@link IRemoteServiceRegistry}.
- *
- * @param bundle
- * @param reg
- * @param service
- */
- public void ungetService(Bundle bundle, ServiceRegistration reg, Object service) {
- System.out.println("Riena::RemoteServiceBuilder:: debug ungetService");
- if (rsReg != null) {
- rsReg.unregister();
- rsReg = null;
- }
- }
+ /**
+ * Unregister the "remote" service from the {@link IRemoteServiceRegistry}.
+ *
+ * @param bundle
+ * @param reg
+ * @param service
+ */
+ public void ungetService(Bundle bundle, ServiceRegistration reg, Object service) {
+ if (rsReg != null) {
+ rsReg.unregister();
+ rsReg = null;
+ }
+ }
}
diff --git a/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceFactory.java b/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceFactory.java
index 304605c..0ed6786 100644
--- a/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceFactory.java
+++ b/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceFactory.java
@@ -13,6 +13,7 @@ package org.eclipse.riena.communication.core.factory;
import java.lang.reflect.Proxy;
import java.util.Hashtable;
+import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.communication.core.IRemoteServiceReference;
import org.eclipse.riena.communication.core.IRemoteServiceRegistration;
import org.eclipse.riena.communication.core.IRemoteServiceRegistry;
@@ -27,6 +28,7 @@ import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.ConfigurationPlugin;
+import org.osgi.service.log.LogService;
/**
* The IRemoteServiceFactory creates {@link IRemoteServiceReference} for given
@@ -60,6 +62,7 @@ public class RemoteServiceFactory {
private static final String HOST_ID = RemoteServiceFactory.class.getName();
private BundleContext context;
+ private Logger LOGGER = Activator.getDefault().getLogger(RemoteServiceFactory.class.getName());
/**
* Creates a RemoteServiceFactory instance with the default bundle context.
@@ -97,7 +100,8 @@ public class RemoteServiceFactory {
* @return the registration object or <code>null</code>
*
*/
- public IRemoteServiceRegistration createAndRegisterProxy(Class<?> interfaceClass, String url, String protocol, String configid) {
+ public IRemoteServiceRegistration createAndRegisterProxy(Class<?> interfaceClass, String url, String protocol,
+ String configid) {
return createAndRegisterProxy(interfaceClass, url, protocol, configid, HOST_ID);
}
@@ -118,7 +122,8 @@ public class RemoteServiceFactory {
* @param hostId
* @return the registration object or <code>null</code>
*/
- public IRemoteServiceRegistration createAndRegisterProxy(Class<?> interfaceClass, String url, String protocol, String configid, String hostId) {
+ public IRemoteServiceRegistration createAndRegisterProxy(Class<?> interfaceClass, String url, String protocol,
+ String configid, String hostId) {
RemoteServiceDescription rsd = createDescription(interfaceClass, url, protocol, configid);
return createAndRegisterProxy(rsd);
}
@@ -157,7 +162,7 @@ public class RemoteServiceFactory {
// create proxy first
final IRemoteServiceReference rsRef = createProxy(rsDesc);
if (rsRef == null) {
- System.out.println("Riena::RemoteServiceFactory::could not create proxy for " + rsDesc);
+ LOGGER.log(LogService.LOG_ERROR, "Riena::RemoteServiceFactory::could not create proxy for " + rsDesc);
return null;
}
rsRef.setHostId(hostId);
@@ -173,7 +178,8 @@ public class RemoteServiceFactory {
ServiceListener sl = new ServiceListener() {
public void serviceChanged(ServiceEvent event) {
ServiceReference refRegistry = event.getServiceReference();
- IRemoteServiceRegistry registry = (IRemoteServiceRegistry) Activator.getContext().getService(refRegistry);
+ IRemoteServiceRegistry registry = (IRemoteServiceRegistry) Activator.getContext().getService(
+ refRegistry);
if (registry != null) {
registry.registerService(rsRef);
}
@@ -204,7 +210,8 @@ public class RemoteServiceFactory {
return createProxy(rsd);
}
- private RemoteServiceDescription createDescription(Class<?> interfaceClass, String url, String protocol, String configid) {
+ private RemoteServiceDescription createDescription(Class<?> interfaceClass, String url, String protocol,
+ String configid) {
RemoteServiceDescription rsd = new RemoteServiceDescription();
rsd.setServiceInterfaceClass(interfaceClass);
rsd.setServiceInterfaceClassName(interfaceClass.getName());
@@ -225,11 +232,12 @@ public class RemoteServiceFactory {
*/
public IRemoteServiceReference createProxy(RemoteServiceDescription rsd) {
if (!RienaStartupStatus.getInstance().isStarted()) {
- System.out.println("WARN riena.core is not started. This will probably not work.");
+ LOGGER.log(LogService.LOG_WARNING, "riena.core is not started. This will probably not work.");
}
// consult ConfigurationPlugins for URL
try {
- ServiceReference[] pluginRefs = Activator.getContext().getServiceReferences(ConfigurationPlugin.class.getName(), null);
+ ServiceReference[] pluginRefs = Activator.getContext().getServiceReferences(
+ ConfigurationPlugin.class.getName(), null);
Hashtable<String, String> props = new Hashtable<String, String>();
props.put(RSDPublisherProperties.PROP_URL, rsd.getURL());
if (pluginRefs != null) {
@@ -258,7 +266,9 @@ public class RemoteServiceFactory {
}
// no factory for this protocol
if (references == null) {
- System.out.println("Riena::RemoteServiceFactory:: WARN no IRemoteServiceFactory serviceRef available protocol [" + rsd.getProtocol() + "]");
+ LOGGER.log(LogService.LOG_WARNING,
+ "Riena::RemoteServiceFactory:: no IRemoteServiceFactory serviceRef available protocol ["
+ + rsd.getProtocol() + "]");
return null;
}
@@ -274,11 +284,13 @@ public class RemoteServiceFactory {
// could not get instance for existing reference
if (factory == null) {
- System.out.println("Riena::RemoteServiceFactory:: WARN no IRemoteServiceFactory service available protocol [" + rsd.getProtocol() + "] id ["
- + rsd.getServiceInterfaceClassName() + "]");
+ LOGGER.log(LogService.LOG_WARNING,
+ "Riena::RemoteServiceFactory:: no IRemoteServiceFactory service available protocol ["
+ + rsd.getProtocol() + "] id [" + rsd.getServiceInterfaceClassName() + "]");
return null;
}
- System.out.println("Riena::RemoteServiceFactory:: DEBUG IRemoteServiceFactory found protocol [" + rsd.getProtocol() + "] " + factory);
+ LOGGER.log(LogService.LOG_INFO, "Riena::RemoteServiceFactory:: IRemoteServiceFactory found protocol ["
+ + rsd.getProtocol() + "] " + factory);
// ask factory to create a proxy for me, and intercept the calls with a
// CallHooksProxy instance
@@ -287,8 +299,8 @@ public class RemoteServiceFactory {
CallHooksProxy callHooksProxy = new CallHooksProxy(rsr.getServiceInstance());
callHooksProxy.setRemoteServiceDescription(rsd);
callHooksProxy.setMessageContextAccessor(factory.getMessageContextAccessor());
- rsr.setServiceInstance(Proxy.newProxyInstance(rsd.getServiceInterfaceClass().getClassLoader(), new Class[] { rsd.getServiceInterfaceClass() },
- callHooksProxy));
+ rsr.setServiceInstance(Proxy.newProxyInstance(rsd.getServiceInterfaceClass().getClassLoader(),
+ new Class[] { rsd.getServiceInterfaceClass() }, callHooksProxy));
return rsr;
} finally {
context.ungetService(refFactory);
diff --git a/org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/Activator.java b/org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/Activator.java
index 3b2829b..1a6256b 100644
--- a/org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/Activator.java
+++ b/org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/Activator.java
@@ -13,12 +13,13 @@ package org.eclipse.riena.internal.communication.core;
import java.util.List;
import java.util.Map;
+import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.communication.core.hooks.CallContext;
import org.eclipse.riena.communication.core.hooks.ICallHook;
+import org.eclipse.riena.core.logging.LogUtil;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-
/**
* @author Alexander Ziegler
* @author Christian Campo
@@ -26,51 +27,65 @@ import org.osgi.framework.BundleContext;
*/
public class Activator implements BundleActivator {
- private static BundleContext CONTEXT;
+ private static BundleContext CONTEXT;
+ private LogUtil logUtil;
+ private static Activator plugin;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ CONTEXT = context;
+ context.registerService(ICallHook.ID, new ICallHook() {
+
+ public void afterCall(CallContext context) {
+ System.out.println("after call (in hook) method=" + context.getMethodName());
+ Map<String, List<String>> headers = context.getMessageContext().listResponseHeaders();
+ if (headers != null) {
+ for (String hName : headers.keySet()) {
+ StringBuffer sb = new StringBuffer();
+ for (String hValue : headers.get(hName)) {
+ sb.append(hValue + ", ");
+ }
+ System.out.println("header: name:" + hName + " value:" + sb);
+ }
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- CONTEXT = context;
- context.registerService(ICallHook.ID, new ICallHook() {
+ public void beforeCall(CallContext context) {
+ context.getMessageContext().addRequestHeader("Cookie", "x-scpclient-test-sessionid=222");
+ System.out.println("before call (in hook) method=" + context.getMethodName());
+ }
+ }, null);
- public void afterCall(CallContext context) {
- System.out.println("after call (in hook) method=" + context.getMethodName());
- Map<String, List<String>> headers = context.getMessageContext().listResponseHeaders();
- if (headers != null) {
- for (String hName : headers.keySet()) {
- StringBuffer sb = new StringBuffer();
- for (String hValue : headers.get(hName)) {
- sb.append(hValue + ", ");
- }
- System.out.println("header: name:" + hName + " value:" + sb);
- }
- }
- }
+ // context.registerService(ConfigurationPlugin.class.getName(), new
+ // SymbolConfigPlugin(), null);
+ }
- public void beforeCall(CallContext context) {
- context.getMessageContext().addRequestHeader("Cookie", "x-scpclient-test-sessionid=222");
- System.out.println("before call (in hook) method=" + context.getMethodName());
- }
- }, null);
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ CONTEXT = null;
+ }
- // context.registerService(ConfigurationPlugin.class.getName(), new SymbolConfigPlugin(), null);
- }
+ public static BundleContext getContext() {
+ return CONTEXT;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- CONTEXT = null;
- }
+ public static Activator getDefault() {
+ return plugin;
+ }
- public static BundleContext getContext() {
- return CONTEXT;
- }
+ public Logger getLogger(String name) {
+ if (logUtil == null) {
+ logUtil = new LogUtil(CONTEXT);
+ }
+ return logUtil.getLogger(name);
+ }
}