geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r767673 - in /geronimo/sandbox/blueprint/blueprint-core/src: main/java/org/apache/geronimo/blueprint/ main/java/org/apache/geronimo/blueprint/context/ main/java/org/apache/geronimo/blueprint/utils/ test/java/org/apache/geronimo/blueprint/ t...
Date Wed, 22 Apr 2009 21:35:46 GMT
Author: gnodet
Date: Wed Apr 22 21:35:46 2009
New Revision: 767673

URL: http://svn.apache.org/viewvc?rev=767673&view=rev
Log:
Remove exception on Destroyable#destroy() method, move HeaderParser to utils package, add
some javadocs to NamespaceHandlerRegistry

Added:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java
  (contents, props changed)
      - copied, changed from r767394, geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/HeaderParser.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/utils/HeaderParserTest.java
  (contents, props changed)
      - copied, changed from r767394, geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/HeaderParserTest.java
Removed:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/HeaderParser.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/HeaderParserTest.java
Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Destroyable.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ModuleContextEventSender.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/NamespaceHandlerRegistry.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/DefaultModuleContextEventSender.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java?rev=767673&r1=767672&r2=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java
Wed Apr 22 21:35:46 2009
@@ -28,10 +28,11 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
-import org.apache.geronimo.blueprint.HeaderParser.PathElement;
+import org.apache.geronimo.blueprint.utils.HeaderParser.PathElement;
 import org.apache.geronimo.blueprint.context.DefaultModuleContextEventSender;
 import org.apache.geronimo.blueprint.context.BlueprintContextImpl;
 import org.apache.geronimo.blueprint.namespace.NamespaceHandlerRegistryImpl;
+import org.apache.geronimo.blueprint.utils.HeaderParser;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Destroyable.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Destroyable.java?rev=767673&r1=767672&r2=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Destroyable.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Destroyable.java
Wed Apr 22 21:35:46 2009
@@ -26,5 +26,5 @@
  */
 public interface Destroyable {
 
-    void destroy() throws Exception;
+    void destroy();
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ModuleContextEventSender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ModuleContextEventSender.java?rev=767673&r1=767672&r2=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ModuleContextEventSender.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ModuleContextEventSender.java
Wed Apr 22 21:35:46 2009
@@ -19,16 +19,14 @@
 package org.apache.geronimo.blueprint;
 
 import org.osgi.service.blueprint.context.BlueprintContext;
-import org.osgi.service.blueprint.context.EventConstants;
 
 /**
- * Created by IntelliJ IDEA.
- * User: gnodet
- * Date: Apr 13, 2009
- * Time: 11:18:06 PM
- * To change this template use File | Settings | File Templates.
+ * Interface used to send events related to blueprint context life cycle.
+ *
+ * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
+ * @version $Rev: 760378 $, $Date: 2009-03-31 11:31:38 +0200 (Tue, 31 Mar 2009) $
  */
-public interface ModuleContextEventSender extends EventConstants {
+public interface ModuleContextEventSender extends Destroyable {
 
     void sendCreating(BlueprintContext moduleContext);
     void sendCreated(BlueprintContext moduleContext);
@@ -38,6 +36,4 @@
     void sendFailure(BlueprintContext moduleContext, Throwable cause);
     void sendFailure(BlueprintContext moduleContext, Throwable cause, String[] serviceObjectClass,
String serviceFilter);
 
-    void destroy();
-
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/NamespaceHandlerRegistry.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/NamespaceHandlerRegistry.java?rev=767673&r1=767672&r2=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/NamespaceHandlerRegistry.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/NamespaceHandlerRegistry.java
Wed Apr 22 21:35:46 2009
@@ -23,12 +23,12 @@
 import org.osgi.service.blueprint.namespace.NamespaceHandler;
 
 /**
- * TODO: javadoc
+ * Registry of NamespaceHandler.
  *
  * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
  * @version $Rev: 760378 $, $Date: 2009-03-31 11:31:38 +0200 (Tue, 31 Mar 2009) $
  */
-public interface NamespaceHandlerRegistry {
+public interface NamespaceHandlerRegistry extends Destroyable {
 
     /**
      * Retrieve the <code>NamespaceHandler</code> for the specified URI
@@ -38,13 +38,41 @@
      */
     NamespaceHandler getNamespaceHandler(URI uri);
 
-    void destroy();
-
+    /**
+     * Add a new Listener to be called when namespace handlers are registerd or unregistered
+     *
+     * @param listener the listener to register
+     */
     void addListener(Listener listener);
+
+    /**
+     * Remove a previously registered Listener
+     *
+     * @param listener the listener to unregister
+     */
     void removeListener(Listener listener);
 
+    /**
+     * Interface used to listen to registered or unregistered namespace handlers.
+     *
+     * @see NamespaceHandlerRegistry#addListener(org.apache.geronimo.blueprint.NamespaceHandlerRegistry.Listener)
+     * @see NamespaceHandlerRegistry#removeListener(org.apache.geronimo.blueprint.NamespaceHandlerRegistry.Listener)
+     */
     public interface Listener {
+
+        /**
+         * Called when a NamespaceHandler has been registered for the specified URI.
+         *
+         * @param uri the URI of the newly registered namespace handler
+         */
         void namespaceHandlerRegistered(URI uri);
+
+        /**
+         * Called when a NamespaceHandler has been unregistered for the specified URI.
+         *
+         * @param uri the URI of the newly unregistered namespace handler
+         */
         void namespaceHandlerUnregistered(URI uri);
+
     }
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java?rev=767673&r1=767672&r2=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
Wed Apr 22 21:35:46 2009
@@ -32,14 +32,13 @@
 import java.util.concurrent.ExecutorService;
 
 import org.apache.geronimo.blueprint.BlueprintConstants;
-import org.apache.geronimo.blueprint.HeaderParser;
-import org.apache.geronimo.blueprint.HeaderParser.PathElement;
+import org.apache.geronimo.blueprint.utils.HeaderParser;
+import org.apache.geronimo.blueprint.utils.HeaderParser.PathElement;
 import org.apache.geronimo.blueprint.ModuleContextEventSender;
 import org.apache.geronimo.blueprint.NamespaceHandlerRegistry;
 import org.apache.geronimo.blueprint.Destroyable;
 import org.apache.geronimo.blueprint.convert.ConversionServiceImpl;
 import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
-import org.apache.geronimo.blueprint.namespace.NamespaceHandlerRegistryImpl;
 import org.apache.xbean.recipe.ObjectGraph;
 import org.apache.xbean.recipe.Repository;
 import org.osgi.framework.Bundle;
@@ -50,7 +49,6 @@
 import org.osgi.service.blueprint.context.NoSuchComponentException;
 import org.osgi.service.blueprint.convert.ConversionService;
 import org.osgi.service.blueprint.convert.Converter;
-import org.osgi.service.blueprint.namespace.ComponentDefinitionRegistry;
 import org.osgi.service.blueprint.namespace.NamespaceHandler;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.BeanMetadata;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java?rev=767673&r1=767672&r2=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
Wed Apr 22 21:35:46 2009
@@ -82,7 +82,7 @@
         }
         if (destroyMethod != null && blueprintContext != null) {
             Destroyable d = new Destroyable() {
-                public void destroy() throws Exception {
+                public void destroy() {
                     destroyInstance(obj);
                 }
             };

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java?rev=767673&r1=767672&r2=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
Wed Apr 22 21:35:46 2009
@@ -121,7 +121,7 @@
         }
     }
 
-    public void destroy() throws Exception {
+    public void destroy() {
         moduleContext.getBundleContext().removeServiceListener(this);
         List<ServiceDispatcher> dispatchers = new ArrayList<ServiceDispatcher>(collection.getDispatchers());
         for (ServiceDispatcher dispatcher : dispatchers) {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/DefaultModuleContextEventSender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/DefaultModuleContextEventSender.java?rev=767673&r1=767672&r2=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/DefaultModuleContextEventSender.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/DefaultModuleContextEventSender.java
Wed Apr 22 21:35:46 2009
@@ -33,6 +33,8 @@
 import org.osgi.service.blueprint.context.BlueprintContextListener;
 import org.apache.geronimo.blueprint.BlueprintConstants;
 import org.apache.geronimo.blueprint.ModuleContextEventSender;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * TODO: javadoc
@@ -40,7 +42,9 @@
  * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
  * @version $Rev: 760378 $, $Date: 2009-03-31 11:31:38 +0200 (Tue, 31 Mar 2009) $
  */
-public class DefaultModuleContextEventSender implements ModuleContextEventSender {
+public class DefaultModuleContextEventSender implements ModuleContextEventSender, EventConstants
{
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultModuleContextEventSender.class);
 
     private final Bundle extenderBundle;
     private final ServiceTracker eventAdminServiceTracker;
@@ -84,31 +88,18 @@
 
     public void sendEvent(BlueprintContext moduleContext, String topic, Throwable cause,
String[] serviceObjectClass, String serviceFilter) {
 
-        if (topic == TOPIC_CREATED || topic == TOPIC_FAILURE) {
-            Object[] listeners = contextListenerTracker.getServices();
-            if (listeners != null) {
-                for (Object listener : listeners) {
-                    try {
-                        if (topic == TOPIC_CREATED) {
-                            ((BlueprintContextListener) listener).contextCreated(moduleContext.getBundleContext().getBundle());
-                        } else if (topic == TOPIC_FAILURE) {
-                            ((BlueprintContextListener) listener).contextCreationFailed(moduleContext.getBundleContext().getBundle(),
cause);
-                        }
-                    } catch (Throwable t) {
-                        t.printStackTrace(); // TODO: log
-                    }
-                }
-            }
-        }
+        Bundle bundle = moduleContext.getBundleContext().getBundle();
+
+        LOGGER.debug("Sending blueprint context event {} for bundle {}", topic, bundle.getSymbolicName());
+
+        callListeners(moduleContext, topic, cause);
 
         EventAdmin eventAdmin = getEventAdmin();
         if (eventAdmin == null) {
             return;
         }
 
-        Bundle bundle = moduleContext.getBundleContext().getBundle();
-
-        Dictionary props = new Hashtable();
+        Dictionary<String,Object> props = new Hashtable<String,Object>();
         props.put(org.osgi.service.event.EventConstants.BUNDLE_SYMBOLICNAME, bundle.getSymbolicName());
         props.put(org.osgi.service.event.EventConstants.BUNDLE_ID, bundle.getBundleId());
         props.put(org.osgi.service.event.EventConstants.BUNDLE, bundle);
@@ -133,7 +124,27 @@
 
         Event event = new Event(topic, props);
         eventAdmin.postEvent(event);
-        System.out.println("Event sent: " + topic);
+    }
+
+    private void callListeners(BlueprintContext moduleContext, String topic, Throwable cause)
{
+        boolean created = TOPIC_CREATED.equals(topic);
+        boolean failure = TOPIC_FAILURE.equals(topic);
+        if (created || failure) {
+            Object[] listeners = contextListenerTracker.getServices();
+            if (listeners != null) {
+                for (Object listener : listeners) {
+                    try {
+                        if (created) {
+                            ((BlueprintContextListener) listener).contextCreated(moduleContext.getBundleContext().getBundle());
+                        } else {
+                            ((BlueprintContextListener) listener).contextCreationFailed(moduleContext.getBundleContext().getBundle(),
cause);
+                        }
+                    } catch (Throwable t) {
+                        LOGGER.info("Error calling blueprint context listener", t);
+                    }
+                }
+            }
+        }
     }
 
     private static Version getBundleVersion(Bundle bundle) {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java?rev=767673&r1=767672&r2=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/UnaryServiceReferenceRecipe.java
Wed Apr 22 21:35:46 2009
@@ -89,7 +89,7 @@
         return true;
     }
 
-    public void destroy() throws Exception {
+    public void destroy() {
         moduleContext.getBundleContext().removeServiceListener(this);
         unbind();
     }

Copied: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java
(from r767394, geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/HeaderParser.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java?p2=geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java&p1=geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/HeaderParser.java&r1=767394&r2=767673&rev=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/HeaderParser.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java
Wed Apr 22 21:35:46 2009
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.geronimo.blueprint;
+package org.apache.geronimo.blueprint.utils;
 
 import java.util.ArrayList;
 import java.util.HashMap;

Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/HeaderParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/utils/HeaderParserTest.java
(from r767394, geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/HeaderParserTest.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/utils/HeaderParserTest.java?p2=geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/utils/HeaderParserTest.java&p1=geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/HeaderParserTest.java&r1=767394&r2=767673&rev=767673&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/HeaderParserTest.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/utils/HeaderParserTest.java
Wed Apr 22 21:35:46 2009
@@ -16,13 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.geronimo.blueprint;
+package org.apache.geronimo.blueprint.utils;
 
 import java.util.List;
 
 import junit.framework.TestCase;
 
-import org.apache.geronimo.blueprint.HeaderParser.PathElement;
+import org.apache.geronimo.blueprint.utils.HeaderParser.PathElement;
+import org.apache.geronimo.blueprint.utils.HeaderParser;
 
 public class HeaderParserTest extends TestCase {
 

Propchange: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/utils/HeaderParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/utils/HeaderParserTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/utils/HeaderParserTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message