summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebig2008-02-27 10:04:50 (EST)
committerStefan Liebig2008-02-27 10:04:50 (EST)
commitdcd1c282872e7fd699835af320ecd4d2b0f90c55 (patch)
tree68d8364f6f0670d4be8b806fa904da5f7e646e58
parent2997105e72f792e2109a17ac24659db59233996b (diff)
downloadorg.eclipse.riena-dcd1c282872e7fd699835af320ecd4d2b0f90c55.zip
org.eclipse.riena-dcd1c282872e7fd699835af320ecd4d2b0f90c55.tar.gz
org.eclipse.riena-dcd1c282872e7fd699835af320ecd4d2b0f90c55.tar.bz2
real logging
-rw-r--r--org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/factory/RemoteServiceFactory.java15
-rw-r--r--org.eclipse.riena.communication.factory.hessian/src/org/eclipse/riena/internal/communication/factory/hessian/RienaHessianProxyFactory.java20
-rw-r--r--org.eclipse.riena.communication.publisher.hessian/src/org/eclipse/riena/internal/communication/publisher/hessian/HessianRemoteServicePublisher.java138
-rw-r--r--org.eclipse.riena.communication.publisher/src/org/eclipse/riena/internal/communication/publisher/ServicePublishEventDispatcher.java33
4 files changed, 104 insertions, 102 deletions
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 0ed6786..45545cb 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
@@ -162,7 +162,7 @@ public class RemoteServiceFactory {
// create proxy first
final IRemoteServiceReference rsRef = createProxy(rsDesc);
if (rsRef == null) {
- LOGGER.log(LogService.LOG_ERROR, "Riena::RemoteServiceFactory::could not create proxy for " + rsDesc);
+ LOGGER.log(LogService.LOG_ERROR, "could not create proxy for " + rsDesc);
return null;
}
rsRef.setHostId(hostId);
@@ -266,9 +266,8 @@ public class RemoteServiceFactory {
}
// no factory for this protocol
if (references == null) {
- LOGGER.log(LogService.LOG_WARNING,
- "Riena::RemoteServiceFactory:: no IRemoteServiceFactory serviceRef available protocol ["
- + rsd.getProtocol() + "]");
+ LOGGER.log(LogService.LOG_WARNING, "no IRemoteServiceFactory serviceRef available protocol ["
+ + rsd.getProtocol() + "]");
return null;
}
@@ -284,13 +283,11 @@ public class RemoteServiceFactory {
// could not get instance for existing reference
if (factory == null) {
- LOGGER.log(LogService.LOG_WARNING,
- "Riena::RemoteServiceFactory:: no IRemoteServiceFactory service available protocol ["
- + rsd.getProtocol() + "] id [" + rsd.getServiceInterfaceClassName() + "]");
+ LOGGER.log(LogService.LOG_WARNING, "no IRemoteServiceFactory service available protocol ["
+ + rsd.getProtocol() + "] id [" + rsd.getServiceInterfaceClassName() + "]");
return null;
}
- LOGGER.log(LogService.LOG_INFO, "Riena::RemoteServiceFactory:: IRemoteServiceFactory found protocol ["
- + rsd.getProtocol() + "] " + factory);
+ LOGGER.log(LogService.LOG_INFO, "found protocol [" + rsd.getProtocol() + "] " + factory);
// ask factory to create a proxy for me, and intercept the calls with a
// CallHooksProxy instance
diff --git a/org.eclipse.riena.communication.factory.hessian/src/org/eclipse/riena/internal/communication/factory/hessian/RienaHessianProxyFactory.java b/org.eclipse.riena.communication.factory.hessian/src/org/eclipse/riena/internal/communication/factory/hessian/RienaHessianProxyFactory.java
index af31eaa..447ce6e 100644
--- a/org.eclipse.riena.communication.factory.hessian/src/org/eclipse/riena/internal/communication/factory/hessian/RienaHessianProxyFactory.java
+++ b/org.eclipse.riena.communication.factory.hessian/src/org/eclipse/riena/internal/communication/factory/hessian/RienaHessianProxyFactory.java
@@ -20,11 +20,13 @@ import java.util.Dictionary;
import java.util.List;
import java.util.Map;
+import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.communication.core.hooks.ICallMessageContext;
import org.eclipse.riena.communication.core.hooks.ICallMessageContextAccessor;
import org.eclipse.riena.communication.core.publisher.RSDPublisherProperties;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;
+import org.osgi.service.log.LogService;
import com.caucho.hessian.client.HessianProxyFactory;
import com.caucho.hessian.io.AbstractSerializerFactory;
@@ -39,6 +41,7 @@ public class RienaHessianProxyFactory extends HessianProxyFactory implements Man
private ICallMessageContextAccessor mca;
private static ThreadLocal<HttpURLConnection> connections = new ThreadLocal<HttpURLConnection>();
private URL url;
+ private final static Logger LOGGER = Activator.getDefault().getLogger(RienaHessianProxyFactory.class.getName());
public RienaHessianProxyFactory() {
super();
@@ -98,17 +101,16 @@ public class RienaHessianProxyFactory extends HessianProxyFactory implements Man
@SuppressWarnings("unchecked")
public void updated(Dictionary properties) throws ConfigurationException {
- if (properties == null) {
+ if (properties == null)
return;
- }
String urlStr = (String) properties.get(RSDPublisherProperties.PROP_REMOTE_PATH);
- if (urlStr != null) {
- try {
- URL tmpUrl = new URL(urlStr);
- this.url = tmpUrl;
- } catch (MalformedURLException e) {
- System.out.println("invalid url " + urlStr + e);
- }
+ if (urlStr == null)
+ return;
+
+ try {
+ this.url = new URL(urlStr);
+ } catch (MalformedURLException e) {
+ LOGGER.log(LogService.LOG_ERROR, "invalid url " + urlStr, e);
}
}
diff --git a/org.eclipse.riena.communication.publisher.hessian/src/org/eclipse/riena/internal/communication/publisher/hessian/HessianRemoteServicePublisher.java b/org.eclipse.riena.communication.publisher.hessian/src/org/eclipse/riena/internal/communication/publisher/hessian/HessianRemoteServicePublisher.java
index bfd3b9f..5c14e52 100644
--- a/org.eclipse.riena.communication.publisher.hessian/src/org/eclipse/riena/internal/communication/publisher/hessian/HessianRemoteServicePublisher.java
+++ b/org.eclipse.riena.communication.publisher.hessian/src/org/eclipse/riena/internal/communication/publisher/hessian/HessianRemoteServicePublisher.java
@@ -14,96 +14,96 @@ import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.util.HashMap;
+import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.communication.core.RemoteServiceDescription;
import org.eclipse.riena.communication.core.hooks.IServiceMessageContext;
import org.eclipse.riena.communication.core.hooks.IServiceMessageContextAccessor;
import org.eclipse.riena.communication.core.publisher.IServicePublisher;
+import org.osgi.service.log.LogService;
/**
- * This is a Hessian based implementation of {@link IServicePublisher}. it publish or unpublish OSGi Services as
- * service end points for Hessian protocol.
+ * This is a Hessian based implementation of {@link IServicePublisher}. it
+ * publish or unpublish OSGi Services as service end points for Hessian
+ * protocol.
* <p>
- * HessianRemoteServicePublisher becomes registered as OSGi Service with name {@link IServicePublisher#ID}. The OSGi
- * Service set the property "riena.protocol=hessian".
+ * HessianRemoteServicePublisher becomes registered as OSGi Service with name
+ * {@link IServicePublisher#ID}. The OSGi Service set the property
+ * "riena.protocol=hessian".
*
* @author Alexander Ziegler
* @author Christian Campo
*
*/
public class HessianRemoteServicePublisher implements IServicePublisher {
- private final static String PROTOCOL = "hessian";
- private final static String SERVLET_PATH = "/hessian";
- private IServiceMessageContextAccessor mca = new MsgCxtAcc();
+ private final static String PROTOCOL = "hessian";
+ private final static String SERVLET_PATH = "/hessian";
+ private IServiceMessageContextAccessor mca = new MsgCxtAcc();
- private HashMap<String, RemoteServiceDescription> webServiceDescriptions;
+ private HashMap<String, RemoteServiceDescription> webServiceDescriptions;
- public HessianRemoteServicePublisher() {
- webServiceDescriptions = new HashMap<String, RemoteServiceDescription>();
- }
+ private final static Logger LOGGER = Activator.getDefault()
+ .getLogger(HessianRemoteServicePublisher.class.getName());
- public void log(String message) {
- System.out.println(message);
- }
+ public HessianRemoteServicePublisher() {
+ webServiceDescriptions = new HashMap<String, RemoteServiceDescription>();
+ }
- public void log(String message, Exception e) {
- System.out.println(message + "(" + e.getMessage() + ")");
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see xeval.rcplabs.hessianx.server.IWebServicePublisher#publishService(RemoteServiceDescription
+ * rsd )
+ */
+ public synchronized String publishService(RemoteServiceDescription rsd) {
+ String localhost = "localhost";
+ try {
+ localhost = Inet4Address.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e) {
+ }
+ String url = "http://" + localhost + SERVLET_PATH + rsd.getPath();
+ rsd.setURL(url);
+ webServiceDescriptions.put(SERVLET_PATH + rsd.getPath(), rsd);
+ LOGGER.log(LogService.LOG_DEBUG, "published web service. " + rsd);
+ LOGGER.log(LogService.LOG_DEBUG, "web service count: " + webServiceDescriptions.size());
+ return url;
+ }
- /*
- * (non-Javadoc)
- *
- * @see xeval.rcplabs.hessianx.server.IWebServicePublisher#publishService(RemoteServiceDescription rsd )
- */
- public synchronized String publishService(RemoteServiceDescription rsd) {
- String localhost = "localhost";
- try {
- localhost = Inet4Address.getLocalHost().getHostAddress();
- } catch (UnknownHostException e) {
- }
- String url = "http://" + localhost + SERVLET_PATH + rsd.getPath();
- rsd.setURL(url);
- webServiceDescriptions.put(SERVLET_PATH + rsd.getPath(), rsd);
- log("Riena:Communication::HessianRemoteServicePublisher:: DEBUG: published web service. " + rsd);
- log("Riena:Communication::HessianRemoteServicePublisher:: DEBUG: web service count: " + webServiceDescriptions.size());
- return url;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see xeval.rcplabs.hessianx.server.IWebServicePublisher#unpublishService(java.lang.String)
+ */
+ public synchronized void unpublishService(String path) {
+ RemoteServiceDescription rsd = webServiceDescriptions.remove(SERVLET_PATH + path);
+ LOGGER.log(LogService.LOG_DEBUG, "unpublished web service. " + rsd);
+ LOGGER.log(LogService.LOG_DEBUG, "web service count: " + webServiceDescriptions.size());
+ }
- /*
- * (non-Javadoc)
- *
- * @see xeval.rcplabs.hessianx.server.IWebServicePublisher#unpublishService(java.lang.String)
- */
- public synchronized void unpublishService(String path) {
- RemoteServiceDescription rsd = webServiceDescriptions.remove(SERVLET_PATH + path);
- log("Riena:communication::HessianRemoteServicePublisher:: DEBUG: unpublished web service. " + rsd);
- log("Riena:communication::HessianRemoteServicePublisher:: DEBUG: web service count: " + webServiceDescriptions.size());
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.riena.communication.core.IRemoteServiceProtocol#getProtocol()
+ */
+ public String getProtocol() {
+ return PROTOCOL;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.riena.communication.core.IRemoteServiceProtocol#getProtocol()
- */
- public String getProtocol() {
- return PROTOCOL;
- }
+ public synchronized RemoteServiceDescription findService(String requestURI) {
+ RemoteServiceDescription rsd = webServiceDescriptions.get(requestURI);
+ return rsd;
+ }
- public synchronized RemoteServiceDescription findService(String requestURI) {
- RemoteServiceDescription rsd = webServiceDescriptions.get(requestURI);
- return rsd;
- }
+ public IServiceMessageContextAccessor getMessageContextAccessor() {
+ return mca;
+ }
- public IServiceMessageContextAccessor getMessageContextAccessor() {
- return mca;
- }
+ class MsgCxtAcc implements IServiceMessageContextAccessor {
+ MsgCxtAcc() {
+ super();
+ }
- class MsgCxtAcc implements IServiceMessageContextAccessor {
- MsgCxtAcc() {
- super();
- }
-
- public IServiceMessageContext getMessageContext() {
- return MessageContextAccessor.getMessageContext();
- }
- }
+ public IServiceMessageContext getMessageContext() {
+ return MessageContextAccessor.getMessageContext();
+ }
+ }
} \ No newline at end of file
diff --git a/org.eclipse.riena.communication.publisher/src/org/eclipse/riena/internal/communication/publisher/ServicePublishEventDispatcher.java b/org.eclipse.riena.communication.publisher/src/org/eclipse/riena/internal/communication/publisher/ServicePublishEventDispatcher.java
index 4f46465..85ed93b 100644
--- a/org.eclipse.riena.communication.publisher/src/org/eclipse/riena/internal/communication/publisher/ServicePublishEventDispatcher.java
+++ b/org.eclipse.riena.communication.publisher/src/org/eclipse/riena/internal/communication/publisher/ServicePublishEventDispatcher.java
@@ -18,14 +18,17 @@ import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.communication.core.RemoteServiceDescription;
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.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
/**
*
@@ -42,6 +45,9 @@ public class ServicePublishEventDispatcher implements IServicePublishEventDispat
private BundleContext context;
+ private final static Logger LOGGER = Activator.getDefault()
+ .getLogger(ServicePublishEventDispatcher.class.getName());
+
public ServicePublishEventDispatcher(BundleContext context) {
super();
this.context = context;
@@ -83,7 +89,7 @@ public class ServicePublishEventDispatcher implements IServicePublishEventDispat
public void bind(IServicePublisher publisher) {
servicePublishers.put(publisher.getProtocol(), publisher);
- System.out.println("Riena::UpdatServicePublishEventDispatcher: DEBUG servicePublish=" + publisher.getProtocol()
+ LOGGER.log(LogService.LOG_DEBUG, "servicePublish=" + publisher.getProtocol()
+ " REGISTER...publishing all services that were waiting for him");
// check for services which are missing a publisher
@@ -92,7 +98,7 @@ public class ServicePublishEventDispatcher implements IServicePublishEventDispat
public void unbind(IServicePublisher publisher) {
String protocol = publisher.getProtocol();
- System.out.println("Riena::ServicePublishEventDispatcher:: DEBUG servicePublish=" + publisher.getProtocol()
+ LOGGER.log(LogService.LOG_DEBUG, "servicePublish=" + publisher.getProtocol()
+ " UNREGISTER...unpublishing all its services");
// unregister all web services for this type
@@ -113,7 +119,7 @@ public class ServicePublishEventDispatcher implements IServicePublishEventDispat
Object service = context.getService(serviceRef);
ServiceHooksProxy handler = new ServiceHooksProxy(service);
// create remote service description
- String[] interfaces = (String[]) serviceRef.getProperty("objectClass");
+ String[] interfaces = (String[]) serviceRef.getProperty(Constants.OBJECTCLASS);
assert interfaces.length == 1 : "OSGi only with one interface supported";
String interfaceName = interfaces[0];
Class interfaceClazz = serviceRef.getBundle().loadClass(interfaceName);
@@ -123,27 +129,23 @@ public class ServicePublishEventDispatcher implements IServicePublishEventDispat
handler.setRemoteServiceDescription(rsDesc);
RemoteServiceDescription rsDescFound = rsDescs.get(rsDesc.getProtocol() + "::" + rsDesc.getPath());
if (rsDescFound != null && rsDescFound.getType() == RemoteServiceDescription.STATUS_REGISTERED) {
- System.out.println("Riena::ServicePublishEventDispatcher:: WARN: A service endpoint with path=["
- + rsDesc.getPath() + "] and remoteType=[" + rsDesc.getProtocol()
- + "] already published... ignored");
+ LOGGER.log(LogService.LOG_WARNING, "A service endpoint with path=[" + rsDesc.getPath()
+ + "] and remoteType=[" + rsDesc.getProtocol() + "] already published... ignored");
return;
}
if (rsDescFound == null) {
if (rsDesc.getPath() == null) {
- System.out.println("Riena::ServicePublishEventDispatcher:: WARN: no path for service: "
- + service.toString() + " Service not published remote");
+ LOGGER.log(LogService.LOG_WARNING, "no path for service: " + service.toString()
+ + " Service not published remote");
return;
}
if (!servicePublishers.containsKey(rsDesc.getProtocol())) {
- System.out
- .println("Riena::ServicePublishEventDispatcher:: DEBUG: no publisher found for protocol "
- + rsDesc.getProtocol());
+ LOGGER.log(LogService.LOG_DEBUG, "no publisher found for protocol " + rsDesc.getProtocol());
return;
}
rsDescs.put(rsDesc.getProtocol() + "::" + rsDesc.getPath(), rsDesc);
- System.out.println("Riena::ServicePublishEventDispatcher:: DEBUG: service endpoints count: "
- + rsDescs.size());
+ LOGGER.log(LogService.LOG_DEBUG, "service endpoints count: " + rsDescs.size());
} else if (rsDescFound.getType() == RemoteServiceDescription.STATUS_UNREGISTERED) {
rsDesc = rsDescFound;
@@ -151,7 +153,8 @@ public class ServicePublishEventDispatcher implements IServicePublishEventDispat
publish(rsDesc, handler);
} catch (ClassNotFoundException e) {
- System.out.println(e);
+ LOGGER.log(LogService.LOG_DEBUG,
+ "Could not load class for remote service interface for service reference " + serviceRef, e);
}
}
@@ -204,7 +207,7 @@ public class ServicePublishEventDispatcher implements IServicePublishEventDispat
} finally {
context.ungetService(serviceRef);
}
- System.out.println("Riena::ServicePublisherHessian:: DEBUG: service endpoints count: " + rsDescs.size());
+ LOGGER.log(LogService.LOG_DEBUG, "service endpoints count: " + rsDescs.size());
}
}