karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1471419 - in /karaf/cellar/trunk/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/
Date Wed, 24 Apr 2013 13:58:25 GMT
Author: jbonofre
Date: Wed Apr 24 13:58:25 2013
New Revision: 1471419

URL: http://svn.apache.org/r1471419
Log:
Code cleanup.

Modified:
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java
    karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
    karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
    karaf/cellar/trunk/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java
    karaf/cellar/trunk/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java

Modified: karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java (original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/Constants.java Wed
Apr 24 13:58:25 2013
@@ -13,6 +13,9 @@
  */
 package org.apache.karaf.cellar.dosgi;
 
+/**
+ * DOSGi Constants.
+ */
 public abstract class Constants {
 
     public static final String SEPARATOR = "/";

Modified: karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java
(original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ExportServiceListener.java
Wed Apr 24 13:58:25 2013
@@ -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 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,17 +53,17 @@ 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+")";
+            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 imple
 
     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 imple
 
             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 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();
                     }
                 }
@@ -148,32 +151,32 @@ public class ExportServiceListener imple
     }
 
     /**
-     * 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 imple
     }
 
     /**
-     * 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>();

Modified: karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java
(original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/ImportServiceListener.java
Wed Apr 24 13:58:25 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;
@@ -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 imple
         producers.clear();
     }
 
-
+    @Override
     public void run() {
         for (ListenerInfo listener : pendingListeners) {
             checkListener(listener);
@@ -98,9 +96,8 @@ public class ImportServiceListener imple
                 }
 
                 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 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();
@@ -129,7 +126,7 @@ public class ImportServiceListener imple
                 }
 
                 for (EndpointDescription endpoint : matches) {
-                    unimportService(endpoint);
+                    unImportService(endpoint);
                 }
 
                 pendingListeners.remove(listenerInfo);
@@ -140,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();
@@ -166,10 +163,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 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 imple
     }
 
     /**
-     * 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();
 

Modified: karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java
(original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCall.java
Wed Apr 24 13:58:25 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/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
(original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceCallHandler.java
Wed Apr 24 13:58:25 2013
@@ -32,7 +32,7 @@ import java.lang.reflect.InvocationTarge
 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 ex
 
     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 ex
         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 ex
         }
     }
 
-
+    /**
+     * 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

Modified: karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java
(original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFactory.java
Wed Apr 24 13:58:25 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 {
 
@@ -54,6 +54,7 @@ public class RemoteServiceFactory implem
 
     @Override
     public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
{
+        // nothing to do
     }
 
 }

Modified: karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java
(original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceFindHook.java
Wed Apr 24 13:58:25 2013
@@ -19,13 +19,13 @@ import org.osgi.framework.hooks.service.
 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
     }
 
 }

Modified: karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java
(original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceInvocationHandler.java
Wed Apr 24 13:58:25 2013
@@ -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 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/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java
(original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResult.java
Wed Apr 24 13:58:25 2013
@@ -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);
     }

Modified: karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java
(original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/RemoteServiceResultHandler.java
Wed Apr 24 13:58:25 2013
@@ -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;

Modified: karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
(original)
+++ karaf/cellar/trunk/dosgi/src/main/java/org/apache/karaf/cellar/dosgi/shell/ListDistributedServicesCommand.java
Wed Apr 24 13:58:25 2013
@@ -22,7 +22,7 @@ import org.apache.karaf.shell.commands.C
 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 ListDistributedServicesComm
                 }
 
             } else {
-                System.out.println("There are no distributed service");
+                System.out.println("No distributed service");
             }
         } finally {
             Thread.currentThread().setContextClassLoader(originalClassLoader);

Modified: karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml (original)
+++ karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/blueprint.xml Wed Apr 24
13:58:25 2013
@@ -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"/>

Modified: karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml (original)
+++ karaf/cellar/trunk/dosgi/src/main/resources/OSGI-INF/blueprint/shell-dosgi.xml Wed Apr
24 13:58:25 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/trunk/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java
(original)
+++ karaf/cellar/trunk/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/EndpointDescriptionTest.java
Wed Apr 24 13:58:25 2013
@@ -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";
 

Modified: karaf/cellar/trunk/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java?rev=1471419&r1=1471418&r2=1471419&view=diff
==============================================================================
--- karaf/cellar/trunk/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java
(original)
+++ karaf/cellar/trunk/dosgi/src/test/java/org/apache/karaf/cellar/dosgi/ExportServiceListenerTest.java
Wed Apr 24 13:58:25 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;
@@ -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"));
 



Mime
View raw message