Code cleanup. git-svn-id: https://svn.apache.org/repos/asf/karaf/cellar/trunk@1471419 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/2184d484 Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/2184d484 Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/2184d484 Branch: refs/heads/master Commit: 2184d48476c222ebc370bcc5c57878b4bbb6ea32 Parents: 4574b21 Author: jbonofre <jbonofre@13f79535-47bb-0310-9956-ffa450edef68> Authored: Wed Apr 24 13:58:25 2013 +0000 Committer: jbonofre <jbonofre@13f79535-47bb-0310-9956-ffa450edef68> Committed: Wed Apr 24 13:58:25 2013 +0000 ---------------------------------------------------------------------- .../apache/karaf/cellar/dosgi/Constants.java | 3 + .../cellar/dosgi/ExportServiceListener.java | 99 ++++++++++---------- .../cellar/dosgi/ImportServiceListener.java | 31 +++--- .../karaf/cellar/dosgi/RemoteServiceCall.java | 7 +- .../cellar/dosgi/RemoteServiceCallHandler.java | 26 +++-- .../cellar/dosgi/RemoteServiceFactory.java | 3 +- .../cellar/dosgi/RemoteServiceFindHook.java | 4 +- .../dosgi/RemoteServiceInvocationHandler.java | 9 +- .../karaf/cellar/dosgi/RemoteServiceResult.java | 7 +- .../dosgi/RemoteServiceResultHandler.java | 7 +- .../shell/ListDistributedServicesCommand.java | 4 +- .../resources/OSGI-INF/blueprint/blueprint.xml | 10 +- .../OSGI-INF/blueprint/shell-dosgi.xml | 2 - .../cellar/dosgi/EndpointDescriptionTest.java | 4 +- .../cellar/dosgi/ExportServiceListenerTest.java | 14 +-- 15 files changed, 107 insertions(+), 123 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java index cb87db1..c26b686 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java @@ -13,6 +13,9 @@ */ package org.apache.karaf.cellar.dosgi; +/** + * DOSGi Constants. + */ public abstract class Constants { public static final String SEPARATOR = "/"; http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java index f12921b..fff299b 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java @@ -32,7 +32,7 @@ import java.util.Map; import java.util.Set; /** - * Listener for service export. + * Listener called when a new service is exported. */ public class ExportServiceListener implements ServiceListener { @@ -42,9 +42,9 @@ public class ExportServiceListener implements ServiceListener { 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,17 +53,17 @@ public class ExportServiceListener implements ServiceListener { 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+")"; + String filter = "(" + Constants.EXPORTED_INTERFACES + "=" + Constants.ALL_INTERFACES + ")"; references = bundleContext.getServiceReferences((String) null, filter); - if (references != null) { - for (ServiceReference reference : references) { - exportService(reference); + if (references != null) { + for (ServiceReference reference : references) { + exportService(reference); + } } - } } catch (InvalidSyntaxException e) { LOGGER.error("CELLAR DOSGI: error exporting existing remote services", e); } @@ -71,35 +71,38 @@ public class ExportServiceListener implements ServiceListener { 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(); } - + /** + * Callback method called when a service has change. + * + * @param event the local service change event. + */ @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 a cluster event consumer on a local service reference, in order to consume remote service calls. * * @param serviceReference The reference of the service to be exported. */ @@ -110,14 +113,14 @@ public class ExportServiceListener implements ServiceListener { String exportedServices = (String) serviceReference.getProperty(Constants.EXPORTED_INTERFACES); if (exportedServices != null && exportedServices.length() > 0) { - LOGGER.debug("CELLAR DOSGI: Exporting remote service"); + LOGGER.debug("CELLAR DOSGI: registering services {} in the cluster", exportedServices); String[] interfaces = exportedServices.split(Constants.INTERFACE_SEPARATOR); Object service = bundleContext.getService(serviceReference); 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(); @@ -127,17 +130,17 @@ public class ExportServiceListener implements ServiceListener { 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(); } } @@ -148,32 +151,32 @@ public class ExportServiceListener implements ServiceListener { } /** - * Removes {@link EventConsumer}s for consuming remote service calls. + * Remove the cluster event consumer, and stop to consume remote service calls. * - * @param serviceReference + * @param serviceReference the service to stop to expose on the cluster. */ 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); if (exportedServices != null && exportedServices.length() > 0) { - LOGGER.debug("CELLAR DOSGI: un-exporting remote service"); + LOGGER.debug("CELLAR DOSGI: un-register service {} from the cluster", exportedServices); String[] interfaces = exportedServices.split(Constants.INTERFACE_SEPARATOR); Object service = bundleContext.getService(serviceReference); 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); @@ -186,11 +189,11 @@ public class ExportServiceListener implements ServiceListener { } /** - * Returns a Set of interfaces that match the actual exported service interfaces of a service. + * Get the interfaces that match the exported service interfaces. * - * @param service - * @param services - * @return + * @param service the service. + * @param services the service interfaces. + * @return the matched service interface. */ public Set<String> getServiceInterfaces(Object service, String[] services) { Set<String> interfaceList = new LinkedHashSet<String>(); http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java index 6a166f3..c37da89 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java @@ -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; @@ -33,7 +32,6 @@ import java.util.Hashtable; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; -import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -79,7 +77,7 @@ public class ImportServiceListener implements ListenerHook, Runnable { producers.clear(); } - + @Override public void run() { for (ListenerInfo listener : pendingListeners) { checkListener(listener); @@ -98,9 +96,8 @@ public class ImportServiceListener implements ListenerHook, Runnable { } pendingListeners.add(listenerInfo); - // Make sure we only import remote services + // make sure we only import remote services checkListener(listenerInfo); - } } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); @@ -117,9 +114,9 @@ public class ImportServiceListener implements ListenerHook, Runnable { 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(); @@ -129,7 +126,7 @@ public class ImportServiceListener implements ListenerHook, Runnable { } for (EndpointDescription endpoint : matches) { - unimportService(endpoint); + unImportService(endpoint); } pendingListeners.remove(listenerInfo); @@ -140,15 +137,15 @@ public class ImportServiceListener implements ListenerHook, Runnable { } /** - * 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(); @@ -166,10 +163,10 @@ public class ImportServiceListener implements ListenerHook, Runnable { } /** - * Imports a remote service to the service registry. + * Import a remote service to the service registry. * - * @param endpoint - * @param listenerInfo + * @param endpoint the endpoint to import. + * @param listenerInfo the associated listener info. */ private void importService(EndpointDescription endpoint, ListenerInfo listenerInfo) { LOGGER.debug("CELLAR DOSGI: importing remote service"); @@ -202,11 +199,11 @@ public class ImportServiceListener implements ListenerHook, Runnable { } /** - * Unregisters an imported service + * Un-register an imported service. * - * @param endpoint + * @param endpoint the endpoint to un-register. */ - private void unimportService(EndpointDescription endpoint) { + private void unImportService(EndpointDescription endpoint) { ServiceRegistration registration = registrations.get(endpoint); registration.unregister(); http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java index f337f6b..7ffcba4 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java @@ -18,7 +18,7 @@ import org.apache.karaf.cellar.core.command.Command; 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 Command<RemoteServiceResult> { private String serviceClass; private List<Object> arguments; - /** - * Constructor - * - * @param id - */ public RemoteServiceCall(String id) { super(id); } http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java index c29053f..cfe8e27 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java @@ -32,7 +32,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** - * Call handler for remote service. + * Handler for cluster remote service call event. */ public class RemoteServiceCallHandler extends CellarSupport implements EventHandler<RemoteServiceCall> { @@ -46,6 +46,11 @@ public class RemoteServiceCallHandler extends CellarSupport implements EventHand private EventTransportFactory eventTransportFactory; + /** + * Handle a cluster remote service call event. + * + * @param event the cluster event to handle. + */ @Override public void handle(RemoteServiceCall event) { @@ -58,28 +63,22 @@ public class RemoteServiceCallHandler extends CellarSupport implements EventHand Object targetService = null; if (event != null) { - 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: could not lookup service", e); + LOGGER.error("CELLAR DOSGI: failed 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(); } @@ -111,12 +110,21 @@ public class RemoteServiceCallHandler extends CellarSupport implements EventHand } } - + /** + * Get the event type that this handler can handle. + * + * @return the remote service call event type. + */ @Override public Class<RemoteServiceCall> getType() { return RemoteServiceCall.class; } + /** + * Get the handler switch. + * + * @return the handler switch. + */ @Override public Switch getSwitch() { // load the switch status from the config http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java index 51db5c3..11d1321 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.List; /** - * Remote service factory. + * Factory for remote service. */ public class RemoteServiceFactory implements ServiceFactory { @@ -54,6 +54,7 @@ public class RemoteServiceFactory implements ServiceFactory { @Override public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { + // nothing to do } } http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java index 3d2d71c..2584d2b 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java @@ -19,13 +19,13 @@ import org.osgi.framework.hooks.service.FindHook; import java.util.Collection; /** - * Remote service finder. + * Hook for remote service find. */ public class RemoteServiceFindHook implements FindHook { @Override public void find(BundleContext context, String name, String filter, boolean allServices, Collection references) { - + // nothing to do } } http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java index 8f4afe2..fc82ed4 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Map; /** - * Handler for the remote service invocation. + * Handler for cluster remote service invocation event. */ public class RemoteServiceInvocationHandler implements InvocationHandler { @@ -33,13 +33,6 @@ public class RemoteServiceInvocationHandler implements InvocationHandler { 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; http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java index 5c07b37..81bb7f6 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java @@ -16,17 +16,12 @@ package org.apache.karaf.cellar.dosgi; import org.apache.karaf.cellar.core.command.Result; /** - * Remote service call result. + * Cluster remote service result event. */ public class RemoteServiceResult extends Result { private Object result; - /** - * Constructor - * - * @param id - */ public RemoteServiceResult(String id) { super(id); } http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java index f5b2a50..334f2ed 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java @@ -16,10 +16,15 @@ package org.apache.karaf.cellar.dosgi; import org.apache.karaf.cellar.core.command.ResultHandler; /** - * Handler for a remote service result. + * Handler for cluster remote service result event. */ public class RemoteServiceResultHandler extends ResultHandler<RemoteServiceResult> { + /** + * Get the event type that this handler is able to handle. + * + * @return the cluster remote service result event type. + */ @Override public Class<RemoteServiceResult> getType() { return RemoteServiceResult.class; http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java ---------------------------------------------------------------------- diff --git a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java index 975d9d2..7abcadf 100644 --- a/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java +++ b/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java @@ -22,7 +22,7 @@ import org.apache.karaf.shell.commands.Command; 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 cluster distributed services") public class ListDistributedServicesCommand extends CellarCommandSupport { private static final String LIST_FORMAT = "%-80s %-20s"; @@ -46,7 +46,7 @@ public class ListDistributedServicesCommand extends CellarCommandSupport { } } else { - System.out.println("There are no distributed service"); + System.out.println("No distributed service"); } } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml index 58c699a..51171fc 100644 --- a/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ b/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -16,21 +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> + <!-- 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"/> @@ -43,13 +44,12 @@ </service-properties> </service> - <!-- Cluster Event Handler --> + <!-- 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"/> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml ---------------------------------------------------------------------- diff --git a/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml b/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml index 1de4eb5..4aafd27 100644 --- a/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml +++ b/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml @@ -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> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java ---------------------------------------------------------------------- diff --git a/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java b/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java index f79dfac..c13f52d 100644 --- a/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java +++ b/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java @@ -19,13 +19,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"; http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/2184d484/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java ---------------------------------------------------------------------- diff --git a/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java b/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java index e40a010..41849b0 100644 --- a/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java +++ b/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java @@ -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; @@ -26,16 +24,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"); @@ -46,7 +34,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"));