You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2013/04/24 16:09:55 UTC
svn commit: r1471422 - in /karaf/cellar/branches/cellar-2.3.x/dosgi/src:
main/java/org/apache/karaf/cellar/dosgi/
main/java/org/apache/karaf/cellar/dosgi/shell/
main/resources/OSGI-INF/blueprint/ test/java/org/apache/karaf/cellar/dosgi/
Author: jbonofre
Date: Wed Apr 24 14:09:55 2013
New Revision: 1471422
URL: http://svn.apache.org/r1471422
Log:
Code cleanup.
Modified:
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
karaf/cellar/branches/cellar-2.3.x/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java
karaf/cellar/branches/cellar-2.3.x/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java Wed Apr 24 14:09:55 2013
@@ -13,6 +13,9 @@
*/
package org.apache.karaf.cellar.dosgi;
+/**
+ * Cellar DOSGi Constants.
+ */
public abstract class Constants {
public static final String SEPARATOR = "/";
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java Wed Apr 24 14:09:55 2013
@@ -32,7 +32,7 @@ import java.util.Map;
import java.util.Set;
/**
- * Listener on the export service action.
+ * Listener on the export service.
*/
public class ExportServiceListener implements ServiceListener {
@@ -42,9 +42,9 @@ public class ExportServiceListener imple
private EventTransportFactory eventTransportFactory;
private BundleContext bundleContext;
- private Map<String,EndpointDescription> remoteEndpoints;
+ private Map<String, EndpointDescription> remoteEndpoints;
- private final Map<String,EventConsumer> consumers = new HashMap<String,EventConsumer>();
+ private final Map<String, EventConsumer> consumers = new HashMap<String, EventConsumer>();
private Node node;
@@ -53,7 +53,7 @@ public class ExportServiceListener imple
remoteEndpoints = clusterManager.getMap(Constants.REMOTE_ENDPOINTS);
bundleContext.addServiceListener(this);
- //Lookup for already exported services.
+ // lookup for already exported services.
ServiceReference[] references = null;
try {
String filter = "(" + Constants.EXPORTED_INTERFACES + "=" + Constants.ALL_INTERFACES + ")";
@@ -65,40 +65,40 @@ public class ExportServiceListener imple
}
}
} catch (InvalidSyntaxException e) {
- LOGGER.error("CELLAR DOSGI: unable to export existing remote services", e);
+ LOGGER.error("CELLAR DOSGI: failed to export existing remote services", e);
}
}
public void destroy() {
bundleContext.removeServiceListener(this);
- for(Map.Entry<String,EventConsumer> consumerEntry:consumers.entrySet()) {
- EventConsumer consumer = consumerEntry.getValue();
- consumer.stop();
- }
- consumers.clear();
+ for (Map.Entry<String, EventConsumer> consumerEntry : consumers.entrySet()) {
+ EventConsumer consumer = consumerEntry.getValue();
+ consumer.stop();
+ }
+ consumers.clear();
}
@Override
public void serviceChanged(ServiceEvent event) {
- if (event != null) {
- switch (event.getType()) {
- case ServiceEvent.REGISTERED:
- exportService(event.getServiceReference());
- break;
- case ServiceEvent.UNREGISTERING:
- unExportService(event.getServiceReference());
- break;
- case ServiceEvent.MODIFIED:
- case ServiceEvent.MODIFIED_ENDMATCH:
- default:
- break;
- }
+ if (event != null) {
+ switch (event.getType()) {
+ case ServiceEvent.REGISTERED:
+ exportService(event.getServiceReference());
+ break;
+ case ServiceEvent.UNREGISTERING:
+ unExportService(event.getServiceReference());
+ break;
+ case ServiceEvent.MODIFIED:
+ case ServiceEvent.MODIFIED_ENDMATCH:
+ default:
+ break;
}
+ }
}
/**
- * Registers {@link EventConsumer}s for consuming remote service calls.
+ * Register {@link EventConsumer}s for consuming remote service calls.
*
* @param serviceReference The reference of the service to be exported.
*/
@@ -116,7 +116,7 @@ public class ExportServiceListener imple
Set<String> exportedInterfaces = getServiceInterfaces(service, interfaces);
for (String iface : exportedInterfaces) {
- //Add endpoint description to the set.
+ // add endpoint description to the set.
Version version = serviceReference.getBundle().getVersion();
String endpointId = iface + Constants.SEPARATOR + version.toString();
@@ -126,17 +126,17 @@ public class ExportServiceListener imple
endpoint = remoteEndpoints.get(endpointId);
endpoint.getNodes().add(node);
} else {
- endpoint = new EndpointDescription(endpointId,node);
+ endpoint = new EndpointDescription(endpointId, node);
}
remoteEndpoints.put(endpointId, endpoint);
- //Register the endpoint consumer
+ // register the endpoint consumer
EventConsumer consumer = consumers.get(endpointId);
- if(consumer == null) {
+ if (consumer == null) {
consumer = eventTransportFactory.getEventConsumer(Constants.INTERFACE_PREFIX + Constants.SEPARATOR + endpointId, false);
consumers.put(endpointId, consumer);
- } else if(!consumer.isConsuming()) {
+ } else if (!consumer.isConsuming()) {
consumer.start();
}
}
@@ -147,12 +147,12 @@ public class ExportServiceListener imple
}
/**
- * Removes {@link EventConsumer}s for consuming remote service calls.
+ * Remove {@link EventConsumer}s for consuming remote service calls.
*
* @param serviceReference
*/
public void unExportService(ServiceReference serviceReference) {
- ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
String exportedServices = (String) serviceReference.getProperty(Constants.EXPORTED_INTERFACES);
@@ -164,15 +164,15 @@ public class ExportServiceListener imple
Set<String> exportedInterfaces = getServiceInterfaces(service, interfaces);
for (String iface : exportedInterfaces) {
- //Add endpoint description to the set.
+ // add endpoint description to the set.
Version version = serviceReference.getBundle().getVersion();
String endpointId = iface + Constants.SEPARATOR + version.toString();
EndpointDescription endpointDescription = remoteEndpoints.remove(endpointId);
endpointDescription.getNodes().remove(node);
- //If the endpoint is used for export from other nodes too, then put it back.
- if(endpointDescription.getNodes().size() > 0) {
- remoteEndpoints.put(endpointId,endpointDescription);
+ // if the endpoint is used for export from other nodes too, then put it back.
+ if (endpointDescription.getNodes().size() > 0) {
+ remoteEndpoints.put(endpointId, endpointDescription);
}
EventConsumer eventConsumer = consumers.remove(endpointId);
@@ -185,11 +185,11 @@ public class ExportServiceListener imple
}
/**
- * Returns a Set of interfaces that match the actual exported service interfaces of a service.
+ * Return a Set of interfaces that match the actual exported service interfaces of a service.
*
- * @param service
- * @param services
- * @return
+ * @param service the service.
+ * @param services the services.
+ * @return the set of interfaces.
*/
public Set<String> getServiceInterfaces(Object service, String[] services) {
Set<String> interfaceList = new LinkedHashSet<String>();
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java Wed Apr 24 14:09:55 2013
@@ -14,7 +14,6 @@
package org.apache.karaf.cellar.dosgi;
import org.apache.karaf.cellar.core.ClusterManager;
-import org.apache.karaf.cellar.core.Producer;
import org.apache.karaf.cellar.core.command.ClusteredExecutionContext;
import org.apache.karaf.cellar.core.command.CommandStore;
import org.apache.karaf.cellar.core.command.ExecutionContext;
@@ -78,6 +77,7 @@ public class ImportServiceListener imple
producers.clear();
}
+ @Override
public void run() {
for (ListenerInfo listener : pendingListeners) {
checkListener(listener);
@@ -96,7 +96,7 @@ public class ImportServiceListener imple
}
pendingListeners.add(listenerInfo);
- // Make sure we only import remote services
+ // make sure we only import remote services
checkListener(listenerInfo);
}
} finally {
@@ -114,9 +114,9 @@ public class ImportServiceListener imple
continue;
}
- // Make sure we only import remote services
+ // make sure we only import remote services
String filter = "(&" + listenerInfo.getFilter() + "(!(" + Constants.ENDPOINT_FRAMEWORK_UUID + "=" + clusterManager.getNode().getId() + ")))";
- // Iterate through known services and import them if needed
+ // iterate through known services and import them if needed
Set<EndpointDescription> matches = new LinkedHashSet<EndpointDescription>();
for (Map.Entry<String, EndpointDescription> entry : remoteEndpoints.entrySet()) {
EndpointDescription endpointDescription = entry.getValue();
@@ -126,7 +126,7 @@ public class ImportServiceListener imple
}
for (EndpointDescription endpoint : matches) {
- unimportService(endpoint);
+ unImportService(endpoint);
}
pendingListeners.remove(listenerInfo);
@@ -137,15 +137,15 @@ public class ImportServiceListener imple
}
/**
- * Checks if there is a match for the current {@link ListenerInfo}.
+ * Check if there is a match for the current {@link ListenerInfo}.
*
- * @param listenerInfo
+ * @param listenerInfo the listener info.
*/
private void checkListener(ListenerInfo listenerInfo) {
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- // Iterate through known services and import them if needed
+ // iterate through known services and import them if needed
Set<EndpointDescription> matches = new LinkedHashSet<EndpointDescription>();
for (Map.Entry<String, EndpointDescription> entry : remoteEndpoints.entrySet()) {
EndpointDescription endpointDescription = entry.getValue();
@@ -162,10 +162,10 @@ public class ImportServiceListener imple
}
/**
- * Imports a remote service to the service registry.
+ * Import a remote service to the service registry.
*
- * @param endpoint
- * @param listenerInfo
+ * @param endpoint the endpoint description.
+ * @param listenerInfo the listener info.
*/
private void importService(EndpointDescription endpoint, ListenerInfo listenerInfo) {
LOGGER.debug("CELLAR DOSGI: importing remote service");
@@ -199,11 +199,11 @@ public class ImportServiceListener imple
}
/**
- * Unregisters an imported service
+ * Un-register an imported service.
*
- * @param endpoint
+ * @param endpoint the endpoint description.
*/
- private void unimportService(EndpointDescription endpoint) {
+ private void unImportService(EndpointDescription endpoint) {
ServiceRegistration registration = registrations.get(endpoint);
registration.unregister();
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java Wed Apr 24 14:09:55 2013
@@ -18,7 +18,7 @@ import org.apache.karaf.cellar.core.comm
import java.util.List;
/**
- * Call to a remote service.
+ * Cluster remote service call event.
*/
public class RemoteServiceCall extends Command<RemoteServiceResult> {
@@ -27,11 +27,6 @@ public class RemoteServiceCall extends C
private String serviceClass;
private List<Object> arguments;
- /**
- * Constructor
- *
- * @param id
- */
public RemoteServiceCall(String id) {
super(id);
}
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java Wed Apr 24 14:09:55 2013
@@ -32,7 +32,7 @@ import java.lang.reflect.InvocationTarge
import java.lang.reflect.Method;
/**
- * Handler on a remote service call.
+ * Handler for cluster remote service call event.
*/
public class RemoteServiceCallHandler extends CellarSupport implements EventHandler<RemoteServiceCall> {
@@ -61,25 +61,20 @@ public class RemoteServiceCallHandler ex
ServiceReference[] serviceReferences = null;
try {
-
serviceReferences = bundleContext.getServiceReferences(event.getServiceClass(), null);
if (serviceReferences != null && serviceReferences.length > 0) {
targetService = bundleContext.getService(serviceReferences[0]);
bundleContext.ungetService(serviceReferences[0]);
}
-
} catch (InvalidSyntaxException e) {
LOGGER.error("CELLAR DOSGI: unable to lookup service", e);
}
if (targetService != null) {
-
Class[] classes = new Class[0];
-
if (event.getArguments() != null && event.getArguments().size() > 0) {
classes = new Class[event.getArguments().size()];
int i = 0;
-
for (Object obj : event.getArguments()) {
classes[i++] = obj.getClass();
}
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java Wed Apr 24 14:09:55 2013
@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.List;
/**
- * Remote service factory.
+ * Factory for remote service.
*/
public class RemoteServiceFactory implements ServiceFactory {
@@ -43,12 +43,12 @@ public class RemoteServiceFactory implem
ClassLoader classLoader = new RemoteServiceProxyClassLoader(bundle);
List<Class> interfaces = new ArrayList<Class>();
String interfaceName = description.getServiceClass();
- try {
- interfaces.add(classLoader.loadClass(interfaceName));
- } catch (ClassNotFoundException e) {
- // Ignore
- }
- RemoteServiceInvocationHandler handler = new RemoteServiceInvocationHandler(description.getId(), interfaceName,clusterManager,executionContext);
+ try {
+ interfaces.add(classLoader.loadClass(interfaceName));
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ RemoteServiceInvocationHandler handler = new RemoteServiceInvocationHandler(description.getId(), interfaceName, clusterManager, executionContext);
return Proxy.newProxyInstance(classLoader, interfaces.toArray(new Class[interfaces.size()]), handler);
}
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java Wed Apr 24 14:09:55 2013
@@ -19,13 +19,13 @@ import org.osgi.framework.hooks.service.
import java.util.Collection;
/**
- * Remote service finder.
+ * Hook for remote service finder.
*/
public class RemoteServiceFindHook implements FindHook {
@Override
public void find(BundleContext context, String name, String filter, boolean allServices, Collection references) {
-
+ // nothing to do
}
}
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java Wed Apr 24 14:09:55 2013
@@ -24,7 +24,7 @@ import java.util.List;
import java.util.Map;
/**
- * Handler on a remote service invocation.
+ * Handler for cluster remote service invocation event.
*/
public class RemoteServiceInvocationHandler implements InvocationHandler {
@@ -33,13 +33,6 @@ public class RemoteServiceInvocationHand
private ClusterManager clusterManager;
private ExecutionContext executionContext;
- /**
- * Constructor
- * @param endpointId
- * @param serviceClass
- * @param clusterManager
- * @param executionContext
- */
public RemoteServiceInvocationHandler(String endpointId,String serviceClass, ClusterManager clusterManager, ExecutionContext executionContext) {
this.endpointId = endpointId;
this.serviceClass = serviceClass;
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java Wed Apr 24 14:09:55 2013
@@ -16,17 +16,12 @@ package org.apache.karaf.cellar.dosgi;
import org.apache.karaf.cellar.core.command.Result;
/**
- * Result of a remote service call.
+ * Cluster remote service result event.
*/
public class RemoteServiceResult extends Result {
private Object result;
- /**
- * Constructor
- *
- * @param id
- */
public RemoteServiceResult(String id) {
super(id);
}
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java Wed Apr 24 14:09:55 2013
@@ -16,7 +16,7 @@ package org.apache.karaf.cellar.dosgi;
import org.apache.karaf.cellar.core.command.ResultHandler;
/**
- * Handler on a remote service result.
+ * Handler for cluster remote service result event.
*/
public class RemoteServiceResultHandler extends ResultHandler<RemoteServiceResult> {
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java Wed Apr 24 14:09:55 2013
@@ -22,7 +22,7 @@ import org.apache.karaf.cellar.dosgi.End
import java.util.Map;
import java.util.Set;
-@Command(scope = "cluster", name = "service-list", description = "List the cluster distributed services.")
+@Command(scope = "cluster", name = "service-list", description = "List the services available on the cluster")
public class ListDistributedServicesCommand extends CellarCommandSupport {
private static final String LIST_FORMAT = "%-80s %-20s";
@@ -44,9 +44,8 @@ public class ListDistributedServicesComm
serviceClass = "";
}
}
-
} else {
- System.out.println("There are no distributed service");
+ System.out.println("No services available on the cluster");
}
} finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml Wed Apr 24 14:09:55 2013
@@ -16,22 +16,22 @@
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<!-- Import Service Listener -->
- <bean id="importListener" class="org.apache.karaf.cellar.dosgi.ImportServiceListener" init-method="init" destroy-method="destroy">
+ <bean id="importServiceListener" class="org.apache.karaf.cellar.dosgi.ImportServiceListener" init-method="init" destroy-method="destroy">
<property name="clusterManager" ref="clusterManager"/>
<property name="commandStore" ref="commandStore"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="eventTransportFactory" ref="eventTransportFactory"/>
</bean>
- <service ref="importListener" interface="org.osgi.framework.hooks.service.ListenerHook"/>
+ <service ref="importServiceListener" interface="org.osgi.framework.hooks.service.ListenerHook"/>
<!-- Export Service Listener -->
- <bean id="exportListener" class="org.apache.karaf.cellar.dosgi.ExportServiceListener" init-method="init" destroy-method="destroy">
+ <bean id="exportServiceListener" class="org.apache.karaf.cellar.dosgi.ExportServiceListener" init-method="init" destroy-method="destroy">
<property name="clusterManager" ref="clusterManager"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="eventTransportFactory" ref="eventTransportFactory"/>
</bean>
- <!-- Cluster Event Handler -->
+ <!-- Cluster Remote Service Call Event Handler -->
<bean id="remoteServiceCallHandler" class="org.apache.karaf.cellar.dosgi.RemoteServiceCallHandler">
<property name="clusterManager" ref="clusterManager"/>
<property name="eventTransportFactory" ref="eventTransportFactory"/>
@@ -44,13 +44,12 @@
</service-properties>
</service>
- <!-- Cluster Event Handler -->
+ <!-- Cluster Remote Service Result Event Handler -->
<bean id="remoteServiceResultHandler" class="org.apache.karaf.cellar.dosgi.RemoteServiceResultHandler">
<property name="commandStore" ref="commandStore"/>
</bean>
<service ref="remoteServiceResultHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
- <!-- Cluster Core Services -->
<reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
<reference id="eventTransportFactory" interface="org.apache.karaf.cellar.core.event.EventTransportFactory"/>
<reference id="commandStore" interface="org.apache.karaf.cellar.core.command.CommandStore"/>
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml Wed Apr 24 14:09:55 2013
@@ -14,7 +14,6 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
- <!-- Command Bundle -->
<command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
<command name="cluster/service-list">
<action class="org.apache.karaf.cellar.dosgi.shell.ListDistributedServicesCommand">
@@ -23,5 +22,4 @@
</command>
</command-bundle>
-
</blueprint>
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java Wed Apr 24 14:09:55 2013
@@ -22,13 +22,11 @@ import org.junit.Test;
public class EndpointDescriptionTest {
String objectClass = "org.apache.karaf.cellar.dosgi.Test";
- String frameworkUUID1 = "192.168.1.101:5701";
- String frameworkUUID2 = "192.168.1.102:5702";
String filterPattern = "(&(objectClass=%s))";
@Test
public void testMatches() throws Exception {
- //This is a dummy test for testing the behaviour of matches method.
+ // this is a dummy test for testing the behaviour of matches method
String testEndpointFilter = String.format(filterPattern,objectClass);
String endpointId = objectClass+Constants.SEPARATOR+"1.0.0";
@@ -36,7 +34,6 @@ public class EndpointDescriptionTest {
EndpointDescription endpointDescription2 = new EndpointDescription(endpointId,null);
Assert.assertTrue(endpointDescription1.matches(testEndpointFilter));
Assert.assertTrue(endpointDescription2.matches(testEndpointFilter));
-
}
}
Modified: karaf/cellar/branches/cellar-2.3.x/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java?rev=1471422&r1=1471421&r2=1471422&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.3.x/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java (original)
+++ karaf/cellar/branches/cellar-2.3.x/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java Wed Apr 24 14:09:55 2013
@@ -13,9 +13,7 @@
*/
package org.apache.karaf.cellar.dosgi;
-import org.junit.After;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
@@ -29,16 +27,6 @@ public class ExportServiceListenerTest {
private ExportServiceListener listener = new ExportServiceListener();
- @Before
- public void setUp() throws Exception {
-
- }
-
- @After
- public void tearDown() throws Exception {
-
- }
-
@Test
public void testGetServiceInterfaces() throws Exception {
System.out.println("Test Service interfaces with null service");
@@ -49,7 +37,7 @@ public class ExportServiceListenerTest {
result = listener.getServiceInterfaces(null,new String[] {"*"});
Assert.assertEquals(expectedResult,result);
- System.out.println("Test Service interfaces with ArrayList and wildchard services");
+ System.out.println("Test Service interfaces with ArrayList and wildcard services");
result = listener.getServiceInterfaces(new ArrayList(),new String[] {"*"});
Assert.assertTrue(result.contains("java.util.List"));