summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebig2008-02-27 10:04:07 (EST)
committerStefan Liebig2008-02-27 10:04:07 (EST)
commit2997105e72f792e2109a17ac24659db59233996b (patch)
tree499402d0b148e5ebe47a7d10fcfebd0f71ed60a3
parentbfc0fd3554dd9aee662bb9ce9153424648747e4a (diff)
downloadorg.eclipse.riena-2997105e72f792e2109a17ac24659db59233996b.zip
org.eclipse.riena-2997105e72f792e2109a17ac24659db59233996b.tar.gz
org.eclipse.riena-2997105e72f792e2109a17ac24659db59233996b.tar.bz2
based on abstract activator
-rw-r--r--org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/Activator.java32
-rw-r--r--org.eclipse.riena.communication.factory.hessian/src/org/eclipse/riena/internal/communication/factory/hessian/Activator.java42
-rw-r--r--org.eclipse.riena.communication.publisher.hessian/src/org/eclipse/riena/internal/communication/publisher/hessian/Activator.java92
-rw-r--r--org.eclipse.riena.communication.publisher/src/org/eclipse/riena/internal/communication/publisher/Activator.java31
4 files changed, 90 insertions, 107 deletions
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 2ec6298..f2076a8 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
@@ -16,19 +16,17 @@ 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.eclipse.riena.core.RienaActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
/**
* @author Alexander Ziegler
* @author Christian Campo
*
*/
-public class Activator implements BundleActivator {
+public class Activator extends RienaActivator {
- private static BundleContext CONTEXT;
- private LogUtil logUtil;
private static Activator plugin;
/*
@@ -37,23 +35,26 @@ public class Activator implements BundleActivator {
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
- CONTEXT = context;
+ super.start(context);
plugin = this;
+
+ final Logger logger = getLogger(Activator.class.getName());
context.registerService(ICallHook.ID, new ICallHook() {
public void afterCall(CallContext context) {
- System.out.println("after call (in hook) method=" + context.getMethodName());
+ logger.log(LogService.LOG_DEBUG, "after call (in hook) method=" + context.getMethodName());
Map<String, List<String>> headers = context.getMessageContext().listResponseHeaders();
if (headers != null) {
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
- System.out.println("header: name:" + entry.getKey() + " value: " + entry.getValue());
+ logger.log(LogService.LOG_DEBUG, "header: name:" + entry.getKey() + " value: "
+ + entry.getValue());
}
}
}
public void beforeCall(CallContext context) {
context.getMessageContext().addRequestHeader("Cookie", "x-scpclient-test-sessionid=222");
- System.out.println("before call (in hook) method=" + context.getMethodName());
+ logger.log(LogService.LOG_DEBUG, "before call (in hook) method=" + context.getMethodName());
}
}, null);
@@ -67,23 +68,12 @@ public class Activator implements BundleActivator {
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
- CONTEXT = null;
plugin = null;
- }
-
- public static BundleContext getContext() {
- return CONTEXT;
+ super.stop(context);
}
public static Activator getDefault() {
return plugin;
}
- public synchronized Logger getLogger(String name) {
- if (logUtil == null) {
- logUtil = new LogUtil(CONTEXT);
- }
- return logUtil.getLogger(name);
- }
-
}
diff --git a/org.eclipse.riena.communication.factory.hessian/src/org/eclipse/riena/internal/communication/factory/hessian/Activator.java b/org.eclipse.riena.communication.factory.hessian/src/org/eclipse/riena/internal/communication/factory/hessian/Activator.java
index 4f9c495..43f6350 100644
--- a/org.eclipse.riena.communication.factory.hessian/src/org/eclipse/riena/internal/communication/factory/hessian/Activator.java
+++ b/org.eclipse.riena.communication.factory.hessian/src/org/eclipse/riena/internal/communication/factory/hessian/Activator.java
@@ -14,30 +14,27 @@ import java.util.Hashtable;
import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.communication.core.factory.IRemoteServiceFactory;
-import org.eclipse.riena.core.logging.LogUtil;
-import org.osgi.framework.BundleActivator;
+import org.eclipse.riena.core.RienaActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.log.LogService;
-public class Activator implements BundleActivator {
+public class Activator extends RienaActivator {
private ServiceRegistration regFactory;
private RemoteServiceFactoryHessian factory;
- private LogUtil logUtil;
- private Logger LOGGER = null;
+ private Logger logger = null;
- private static BundleContext CONTEXT;
+ private static Activator plugin;
/*
- * (non-Javadoc)
- *
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ * @see org.eclipse.riena.core.RienaActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
- CONTEXT = context;
- LOGGER = getLogger(this.getClass().getName());
- LOGGER.log(LogService.LOG_INFO, "start hessian support on client");
+ super.start(context);
+ plugin = this;
+ logger = getLogger(this.getClass().getName());
+ logger.log(LogService.LOG_INFO, "start hessian support on client");
factory = new RemoteServiceFactoryHessian();
Hashtable<String, Object> properties = new Hashtable<String, Object>(1);
properties.put(IRemoteServiceFactory.PROP_PROTOCOL, factory.getProtocol());
@@ -55,24 +52,13 @@ public class Activator implements BundleActivator {
regFactory = null;
factory.dispose();
- CONTEXT = null;
- LOGGER.log(LogService.LOG_INFO, "stop hessian support on client");
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static BundleContext getContext() {
- return CONTEXT;
+ logger.log(LogService.LOG_INFO, "stop hessian support on client");
+ plugin = null;
+ super.stop(context);
}
- public synchronized Logger getLogger(String name) {
- if (logUtil == null) {
- logUtil = new LogUtil(CONTEXT);
- }
- return logUtil.getLogger(name);
+ public static Activator getDefault() {
+ return plugin;
}
}
diff --git a/org.eclipse.riena.communication.publisher.hessian/src/org/eclipse/riena/internal/communication/publisher/hessian/Activator.java b/org.eclipse.riena.communication.publisher.hessian/src/org/eclipse/riena/internal/communication/publisher/hessian/Activator.java
index e42be20..750ea45 100644
--- a/org.eclipse.riena.communication.publisher.hessian/src/org/eclipse/riena/internal/communication/publisher/hessian/Activator.java
+++ b/org.eclipse.riena.communication.publisher.hessian/src/org/eclipse/riena/internal/communication/publisher/hessian/Activator.java
@@ -12,64 +12,64 @@ package org.eclipse.riena.internal.communication.publisher.hessian;
import java.util.Hashtable;
+import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.communication.core.publisher.IServicePublisher;
-import org.osgi.framework.BundleActivator;
+import org.eclipse.riena.core.RienaActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-
+import org.osgi.service.log.LogService;
/**
* The activator class controls the plug-in life cycle
*/
-public class Activator implements BundleActivator {
- private static BundleContext CONTEXT;
- private ServiceRegistration publisherReg;
- private static HessianRemoteServicePublisher publisher;
+public class Activator extends RienaActivator {
+ private ServiceRegistration publisherReg;
+ private static HessianRemoteServicePublisher publisher;
+ private static Activator plugin;
+ private static Logger logger;
- /**
- * The constructor
- */
- public Activator() {
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- CONTEXT = context;
- System.out.println("start hessian support on server");
+ logger = getLogger(Activator.class.getName());
+ logger.log(LogService.LOG_INFO, "start hessian support on server");
- publisher = new HessianRemoteServicePublisher();
- Hashtable<String, Object> properties = new Hashtable<String, Object>(1);
- properties.put(IServicePublisher.PROP_PROTOCOL, publisher.getProtocol());
- publisherReg = context.registerService(IServicePublisher.ID, publisher, properties);
- }
+ publisher = new HessianRemoteServicePublisher();
+ Hashtable<String, Object> properties = new Hashtable<String, Object>(1);
+ properties.put(IServicePublisher.PROP_PROTOCOL, publisher.getProtocol());
+ publisherReg = context.registerService(IServicePublisher.ID, publisher, properties);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- publisherReg.unregister();
- publisherReg = null;
- publisher = null;
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ publisherReg.unregister();
+ publisherReg = null;
+ publisher = null;
+ plugin = null;
- CONTEXT = null;
- System.out.println("stop hessian support on server");
- }
+ logger.log(LogService.LOG_INFO, "stop hessian support on server");
+ super.stop(context);
+ }
- public static BundleContext getContext() {
- return CONTEXT;
- }
+ public static Activator getDefault() {
+ return plugin;
+ }
- /**
- *
- * @return the publisher or null if the bundle is stopped
- */
- public static HessianRemoteServicePublisher getPublisher() {
- return publisher;
- }
+ /**
+ *
+ * @return the publisher or null if the bundle is stopped
+ */
+ public static HessianRemoteServicePublisher getPublisher() {
+ return publisher;
+ }
}
diff --git a/org.eclipse.riena.communication.publisher/src/org/eclipse/riena/internal/communication/publisher/Activator.java b/org.eclipse.riena.communication.publisher/src/org/eclipse/riena/internal/communication/publisher/Activator.java
index 1d6c507..cfecae3 100644
--- a/org.eclipse.riena.communication.publisher/src/org/eclipse/riena/internal/communication/publisher/Activator.java
+++ b/org.eclipse.riena.communication.publisher/src/org/eclipse/riena/internal/communication/publisher/Activator.java
@@ -15,40 +15,45 @@ import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.communication.core.hooks.IServiceHook;
import org.eclipse.riena.communication.core.hooks.ServiceContext;
import org.eclipse.riena.communication.core.publisher.IServicePublishEventDispatcher;
import org.eclipse.riena.communication.core.publisher.IServicePublisher;
import org.eclipse.riena.communication.core.publisher.RSDPublisherProperties;
import org.eclipse.riena.communication.core.util.CommunicationUtil;
+import org.eclipse.riena.core.RienaActivator;
import org.eclipse.riena.core.service.Injector;
import org.eclipse.riena.core.service.ServiceId;
-import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
-public class Activator implements BundleActivator {
+public class Activator extends RienaActivator {
private ServicePublishEventDispatcher dispatcher;
private Injector publisherInjector;
private UpdateNotifierRemoteService updateNotifierRemoteService;
- private static BundleContext context;
+ private static Activator plugin;
+ private static Logger logger;
/*
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
- Activator.context = context;
+ super.start(context);
+ plugin = this;
+ logger = getLogger(Activator.class.getName());
dispatcher = new ServicePublishEventDispatcher(context);
publisherInjector = new ServiceId(IServicePublisher.ID).injectInto(dispatcher).andStart(context);
// register as OSGi service, the start will pick up the OSGi service and
// publish it
Dictionary<String, Object> properties = new Hashtable<String, Object>(3);
- properties.put(RSDPublisherProperties.PROP_IS_REMOTE, "true");
+ properties.put(RSDPublisherProperties.PROP_IS_REMOTE, Boolean.TRUE.toString());
properties.put(RSDPublisherProperties.PROP_REMOTE_PROTOCOL, "hessian");
properties.put(RSDPublisherProperties.PROP_REMOTE_PATH, "/ServicePublisherWS");
@@ -63,15 +68,15 @@ public class Activator implements BundleActivator {
context.registerService(IServiceHook.ID, new IServiceHook() {
public void afterService(ServiceContext context) {
- System.out.println("after service (in hook)");
+ logger.log(LogService.LOG_DEBUG, "after service (in hook)");
context.getMessageContext().addResponseHeader("Set-Cookie", "x-scpserver-test-sessionid=11");
}
public void beforeService(ServiceContext context) {
- System.out.println("before service (in hook)");
+ logger.log(LogService.LOG_DEBUG, "before service (in hook)");
Map<String, List<String>> headers = context.getMessageContext().listRequestHeaders();
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
- System.out.println("header: name:" + entry.getKey() + " value: " + entry.getValue());
+ logger.log(LogService.LOG_DEBUG, "header: name:" + entry.getKey() + " value: " + entry.getValue());
}
}
}, null);
@@ -89,11 +94,13 @@ public class Activator implements BundleActivator {
publisherInjector.stop();
publisherInjector = null;
updateNotifierRemoteService = null;
- Activator.context = null;
+ plugin = null;
+
+ super.stop(context);
}
- public static BundleContext getContext() {
- return context;
+ public static Activator getDefault() {
+ return plugin;
}
class UpdateNotifierRemoteService implements ServiceListener {
@@ -114,7 +121,7 @@ public class Activator implements BundleActivator {
if (remoteType == null || remoteType.length() == 0) {
return;
}
- if ("true".equals(isRemote)) {
+ if (Boolean.parseBoolean(isRemote)) {
if (event.getType() == ServiceEvent.UNREGISTERING) {
dispatcher.unpublish(event.getServiceReference());
} else if (event.getType() == ServiceEvent.REGISTERED) {