geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r777260 - in /geronimo/sandbox/blueprint: blueprint-api/src/main/java/org/osgi/service/blueprint/container/ blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/
Date Thu, 21 May 2009 21:16:25 GMT
Author: gnodet
Date: Thu May 21 21:16:20 2009
New Revision: 777260

URL: http://svn.apache.org/viewvc?rev=777260&view=rev
Log:
Add missing constructor to the ComponentDefinitionException, add some debug logging, remove
unneeded methods on the BlueprintContainerImpl

Modified:
    geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java
    geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/ComponentDefinitionException.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceExportRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ConstructionException.java

Modified: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java?rev=777260&r1=777259&r2=777260&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java
Thu May 21 21:16:20 2009
@@ -24,7 +24,7 @@
 
 public interface BlueprintContainer {
     
-    static final int CONFIGURATION_ADMIN_OBJECT_DELTED = 1;
+    static final int CONFIGURATION_ADMIN_OBJECT_DELETED = 1;
    
     static final int BUNDLE_STOPPING = 2;
 

Modified: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/ComponentDefinitionException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/ComponentDefinitionException.java?rev=777260&r1=777259&r2=777260&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/ComponentDefinitionException.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/ComponentDefinitionException.java
Thu May 21 21:16:20 2009
@@ -17,9 +17,19 @@
 package org.osgi.service.blueprint.container;
 
 public class ComponentDefinitionException extends RuntimeException {
-    
+
+    public ComponentDefinitionException() {
+    }
+
     public ComponentDefinitionException(String explanation) {
         super(explanation);
     }
-      
+
+    public ComponentDefinitionException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public ComponentDefinitionException(Throwable cause) {
+        super(cause);
+    }
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java?rev=777260&r1=777259&r2=777260&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
Thu May 21 21:16:20 2009
@@ -21,7 +21,6 @@
 import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.HashMap;
@@ -32,6 +31,7 @@
 import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.Collection;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeoutException;
 
@@ -419,7 +419,7 @@
 
     private void processProcessors() throws Exception {
         // Instanciate ComponentDefinitionRegistryProcessor and BeanProcessor
-        for (BeanMetadata bean : getBeanComponentsMetadata()) {
+        for (BeanMetadata bean : getMetadata(BeanMetadata.class)) {
             if (bean instanceof ExtendedBeanMetadata && !((ExtendedBeanMetadata)
bean).isProcessor()) {
                 continue;
             }
@@ -599,7 +599,7 @@
         } catch (ComponentDefinitionException e) {
             throw e;
         } catch (Throwable t) {
-            throw (ComponentDefinitionException) new ComponentDefinitionException("Unable
to instantiate components").initCause(t);
+            throw new ComponentDefinitionException("Unable to instantiate components", t);
         }
     }
 
@@ -638,7 +638,7 @@
             ExecutionContext.setContext(new DefaultExecutionContext(this, instantiator.getRepository()));
         }
         try {
-            for (ServiceMetadata service : getExportedServicesMetadata()) {
+            for (ServiceMetadata service : getMetadata(ServiceMetadata.class)) {
                 // Trigger services are only created for services without listeners and explicitly
defined interface classes
                 if (service.getRegistrationListeners().isEmpty() && !service.getInterfaceNames().isEmpty())
{
                     TriggerService triggerService = new TriggerService(service, this);
@@ -697,41 +697,29 @@
         } catch (ComponentDefinitionException e) {
             throw e;
         } catch (Throwable t) {
-            throw (ComponentDefinitionException) new ComponentDefinitionException("Cound
not create component instance for " + id).initCause(t);
+            throw new ComponentDefinitionException("Cound not create component instance for
" + id, t);
         }
     }
 
-    public ComponentMetadata getComponentMetadata(String name) {
-        ComponentMetadata metadata = componentDefinitionRegistry.getComponentDefinition(name);
+    public ComponentMetadata getComponentMetadata(String id) {
+        ComponentMetadata metadata = componentDefinitionRegistry.getComponentDefinition(id);
         if (metadata == null) {
-            throw new NoSuchComponentException(name);
+            throw new NoSuchComponentException(id);
         }
         return metadata;
     }
 
-    public Collection<ServiceReferenceMetadata> getReferencedServicesMetadata() {
-        return getMetadata(ServiceReferenceMetadata.class);
-    }
-
-    public Collection<ServiceMetadata> getExportedServicesMetadata() {
-        return getMetadata(ServiceMetadata.class);
-    }
-
-    public Collection<BeanMetadata> getBeanComponentsMetadata() {
-        return getMetadata(BeanMetadata.class);
-    }
-
-    public <T extends ComponentMetadata> List<T> getMetadata(Class<T> clazz)
{
-        List<T> metadatas = new ArrayList<T>();
+    public <T extends ComponentMetadata> Collection<T> getMetadata(Class<T>
clazz) {
+        Collection<T> metadatas = new ArrayList<T>();
         for (String name : componentDefinitionRegistry.getComponentDefinitionNames()) {
             ComponentMetadata component = componentDefinitionRegistry.getComponentDefinition(name);
-            getComponentsMetadata(clazz, component, metadatas);
+            getMetadata(clazz, component, metadatas);
         }
-        metadatas = Collections.unmodifiableList(metadatas);
+        metadatas = Collections.unmodifiableCollection(metadatas);
         return metadatas;
     }
 
-    private <T extends ComponentMetadata> void getComponentsMetadata(Class<T>
clazz, Metadata component, List<T> metadatas) {
+    private <T extends ComponentMetadata> void getMetadata(Class<T> clazz, Metadata
component, Collection<T> metadatas) {
         if (component == null) {
             return;
         }
@@ -739,47 +727,47 @@
             metadatas.add(clazz.cast(component));
         }
         if (component instanceof BeanMetadata) {
-            getComponentsMetadata(clazz, ((BeanMetadata) component).getFactoryComponent(),
metadatas);
+            getMetadata(clazz, ((BeanMetadata) component).getFactoryComponent(), metadatas);
             for (BeanArgument arg : ((BeanMetadata) component).getArguments()) {
-                getComponentsMetadata(clazz, arg.getValue(), metadatas);
+                getMetadata(clazz, arg.getValue(), metadatas);
             }
             for (BeanProperty prop : ((BeanMetadata) component).getProperties()) {
-                getComponentsMetadata(clazz, prop.getValue(), metadatas);
+                getMetadata(clazz, prop.getValue(), metadatas);
             }
         }
         if (component instanceof CollectionMetadata) {
             for (Metadata m : ((CollectionMetadata) component).getValues()) {
-                getComponentsMetadata(clazz, m, metadatas);
+                getMetadata(clazz, m, metadatas);
             }
         }
         if (component instanceof MapMetadata) {
             for (MapEntry m : ((MapMetadata) component).getEntries()) {
-                getComponentsMetadata(clazz, m.getKey(), metadatas);
-                getComponentsMetadata(clazz, m.getValue(), metadatas);
+                getMetadata(clazz, m.getKey(), metadatas);
+                getMetadata(clazz, m.getValue(), metadatas);
             }
         }
         if (component instanceof PropsMetadata) {
             for (MapEntry m : ((PropsMetadata) component).getEntries()) {
-                getComponentsMetadata(clazz, m.getKey(), metadatas);
-                getComponentsMetadata(clazz, m.getValue(), metadatas);
+                getMetadata(clazz, m.getKey(), metadatas);
+                getMetadata(clazz, m.getValue(), metadatas);
             }
         }
         if (component instanceof ServiceReferenceMetadata) {
             for (Listener l : ((ServiceReferenceMetadata) component).getServiceListeners())
{
-                getComponentsMetadata(clazz, l.getListenerComponent(), metadatas);
+                getMetadata(clazz, l.getListenerComponent(), metadatas);
             }
         }
         if (component instanceof RefCollectionMetadata) {
-            getComponentsMetadata(clazz, ((RefCollectionMetadata) component).getComparator(),
metadatas);
+            getMetadata(clazz, ((RefCollectionMetadata) component).getComparator(), metadatas);
         }
         if (component instanceof ServiceMetadata) {
-            getComponentsMetadata(clazz, ((ServiceMetadata) component).getServiceComponent(),
metadatas);
+            getMetadata(clazz, ((ServiceMetadata) component).getServiceComponent(), metadatas);
             for (MapEntry m : ((ServiceMetadata) component).getServiceProperties()) {
-                getComponentsMetadata(clazz, m.getKey(), metadatas);
-                getComponentsMetadata(clazz, m.getValue(), metadatas);
+                getMetadata(clazz, m.getKey(), metadatas);
+                getMetadata(clazz, m.getValue(), metadatas);
             }
             for (RegistrationListener l : ((ServiceMetadata) component).getRegistrationListeners())
{
-                getComponentsMetadata(clazz, l.getListenerComponent(), metadatas);
+                getMetadata(clazz, l.getListenerComponent(), metadatas);
             }
         }
     }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java?rev=777260&r1=777259&r2=777260&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
Thu May 21 21:16:20 2009
@@ -296,7 +296,7 @@
                 schema.newValidator().validate(new DOMSource(doc));
             }
         } catch (Exception e) {
-            throw (RuntimeException) new ComponentDefinitionException("Unable to validate
xml").initCause(e);
+            throw new ComponentDefinitionException("Unable to validate xml", e);
         } finally {
             for (StreamSource s : schemaSources) {
                 try {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceExportRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceExportRecipe.java?rev=777260&r1=777259&r2=777260&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceExportRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceExportRecipe.java
Thu May 21 21:16:20 2009
@@ -45,7 +45,7 @@
  */
 public class ServiceExportRecipe extends AbstractRecipe implements ServiceRegistration {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceRegistrationProxy.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceExportRecipe.class);
 
     private BlueprintContainerImpl blueprintContainer;
     private ServiceMetadata metadata;
@@ -127,6 +127,7 @@
             // TODO: shouldn't listeners be called before unregistering the service?
             registration.unregister();
             if (listeners != null) {
+                LOGGER.debug("Calling listeners for service unregistration");
                 for (Listener listener : listeners) {
                     listener.unregister(this);
                 }
@@ -141,19 +142,25 @@
     }
 
     public Object getService(Bundle bundle, ServiceRegistration registration) {
+        LOGGER.debug("Retrieving service for bundle {} and service registration {}", bundle,
registration);
         // Create initial service
         if (this.service == null) {
             synchronized (this) {
                 if (this.service == null) {
                     bundleScope = isBundleScope(metadata.getServiceComponent());
+                    LOGGER.debug("Creating service instance (bundle scope = {})", bundleScope);
                     this.service = createInstance(false);
+                    LOGGER.debug("Service created: {}", this.service);
                     // When the service is first requested, we need to create listeners and
call them
                     if (listeners == null) {
+                        LOGGER.debug("Creating listeners");
                         if (listenersRecipe != null) {
                             listeners = (List) createSimpleRecipe(listenersRecipe);
                         } else {
                             listeners = Collections.emptyList();
                         }
+                        LOGGER.debug("Listeners created: {}", listeners);
+                        LOGGER.debug("Calling listeners for service registration");
                         for (Listener listener : listeners) {
                             listener.register(this);
                         }
@@ -224,7 +231,7 @@
                 recipe = (Recipe) objectRepository.get(((ReferenceRecipe) recipe).getReferenceName());
             }
             DefaultRepository repository = new DefaultRepository((DefaultRepository) objectRepository);
-            repository.set(recipe.getName(), recipe);
+            repository.putRecipe(recipe.getName(), recipe);
             BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(blueprintContainer,
repository);
             return graph.create(recipe.getName());
         } else {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ConstructionException.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ConstructionException.java?rev=777260&r1=777259&r2=777260&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ConstructionException.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ConstructionException.java
Thu May 21 21:16:20 2009
@@ -31,8 +31,7 @@
     }
 
     public ConstructionException(String message, Throwable cause) {
-        super(message);
-        initCause(cause);
+        super(message, cause);
     }
 
     public ConstructionException(Throwable cause) {



Mime
View raw message