geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r768730 [1/2] - in /geronimo/sandbox/blueprint: ./ blueprint-api/src/main/java/org/osgi/service/blueprint/context/ blueprint-bundle/ blueprint-compendium/ blueprint-compendium/src/ blueprint-compendium/src/main/ blueprint-compendium/src/mai...
Date Sun, 26 Apr 2009 17:53:49 GMT
Author: gnodet
Date: Sun Apr 26 17:53:47 2009
New Revision: 768730

URL: http://svn.apache.org/viewvc?rev=768730&view=rev
Log:
Support for compendium namespaces and enhancements for better support of custom namespaces

Added:
    geronimo/sandbox/blueprint/blueprint-compendium/   (with props)
    geronimo/sandbox/blueprint/blueprint-compendium/pom.xml
    geronimo/sandbox/blueprint/blueprint-compendium/src/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/CompendiumNamespaceHandler.java
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/CompendiumPropertyPlaceholder.java
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/OSGI-INF/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/OSGI-INF/blueprint/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/OSGI-INF/blueprint/compendium.xml
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/org/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/org/apache/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/org/apache/geronimo/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/org/apache/geronimo/blueprint/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/org/apache/geronimo/blueprint/compendium/
    geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/org/apache/geronimo/blueprint/compendium/blueprint-compendium.xsd
      - copied, changed from r768493, geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint-compendium.xsd
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintExtender.java
      - copied, changed from r768493, 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/ComponentDefinitionRegistryProcessor.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedBlueprintContext.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedComponentDefinitionRegistry.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedParserContext.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/AbstractPropertyPlaceholder.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/SystemPropertyPlaceholder.java
Removed:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint-compendium.xsd
Modified:
    geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/context/BlueprintContext.java
    geronimo/sandbox/blueprint/blueprint-bundle/pom.xml
    geronimo/sandbox/blueprint/blueprint-core/pom.xml
    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/Instanciator.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ValueRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/ComponentDefinitionRegistryImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/NamespaceHandlerRegistryImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/ParserContextImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/AbstractBlueprintTest.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
    geronimo/sandbox/blueprint/blueprint-itests/pom.xml
    geronimo/sandbox/blueprint/blueprint-itests/src/test/java/org/apache/geronimo/blueprint/itests/TestBlueprintContext.java
    geronimo/sandbox/blueprint/blueprint-itests/src/test/java/org/apache/geronimo/blueprint/itests/TestReferences.java
    geronimo/sandbox/blueprint/blueprint-sample/src/main/resources/OSGI-INF/blueprint/config.xml
    geronimo/sandbox/blueprint/pom.xml

Modified: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/context/BlueprintContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/context/BlueprintContext.java?rev=768730&r1=768729&r2=768730&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/context/BlueprintContext.java (original)
+++ geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/context/BlueprintContext.java Sun Apr 26 17:53:47 2009
@@ -21,6 +21,9 @@
 
 import org.osgi.framework.BundleContext;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
 
 public interface BlueprintContext {
     
@@ -28,17 +31,17 @@
    
     static final int BUNDLE_STOPPING = 2;
 
-    Set getComponentNames();
+    Set<String> getComponentNames();
 
     Object getComponent(String name) throws NoSuchComponentException;
 
     ComponentMetadata getComponentMetadata(String name) throws NoSuchComponentException;
 
-    Collection getReferencedServicesMetadata();
+    Collection<ServiceReferenceMetadata> getReferencedServicesMetadata();
 
-    Collection getExportedServicesMetadata();
+    Collection<ServiceMetadata> getExportedServicesMetadata();
 
-    Collection getBeanComponentsMetadata();
+    Collection<BeanMetadata> getBeanComponentsMetadata();
 
     BundleContext getBundleContext();
 

Modified: geronimo/sandbox/blueprint/blueprint-bundle/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-bundle/pom.xml?rev=768730&r1=768729&r2=768730&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-bundle/pom.xml (original)
+++ geronimo/sandbox/blueprint/blueprint-bundle/pom.xml Sun Apr 26 17:53:47 2009
@@ -32,6 +32,10 @@
             <artifactId>blueprint-core</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.geronimo</groupId>
+            <artifactId>blueprint-compendium</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.apache.xbean</groupId>
             <artifactId>xbean-reflect</artifactId>
         </dependency>
@@ -46,7 +50,7 @@
                 <configuration>
                     <instructions>
                         <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Activator>org.apache.geronimo.blueprint.Activator</Bundle-Activator>
+                        <Bundle-Activator>org.apache.geronimo.blueprint.BlueprintExtender</Bundle-Activator>
                         <Import-Package>
                             org.apache.tools.ant*;resolution:=optional,
                             *
@@ -85,8 +89,9 @@
                                     <include>org.apache.xbean:xbean-reflect</include>
                                     <include>asm:asm-all</include>
                                     <include>cglib:cglib</include>
-                                    <include>org.apache.geronimo:blueprint-core</include>
                                     <include>org.apache.geronimo:blueprint-api</include>
+                                    <include>org.apache.geronimo:blueprint-core</include>
+                                    <include>org.apache.geronimo:blueprint-compendium</include>
                                 </includes>
                             </artifactSet>
                             <filters>
@@ -109,13 +114,19 @@
                                     </excludes>
                                 </filter>
                                 <filter>
+                                    <artifact>org.apache.geronimo:blueprint-api</artifact>
+                                    <excludes>
+                                        <exclude>org/**</exclude>
+                                    </excludes>
+                                </filter>
+                                <filter>
                                     <artifact>org.apache.geronimo:blueprint-core</artifact>
                                     <excludes>
                                         <exclude>org/**</exclude>
                                     </excludes>
                                 </filter>
                                 <filter>
-                                    <artifact>org.apache.geronimo:blueprint-api</artifact>
+                                    <artifact>org.apache.geronimo:blueprint-compendium</artifact>
                                     <excludes>
                                         <exclude>org/**</exclude>
                                     </excludes>
@@ -176,6 +187,11 @@
                                             <artifactId>blueprint-core</artifactId>
                                             <classifier>sources</classifier>
                                         </artifactItem>
+                                        <artifactItem>
+                                            <groupId>org.apache.geronimo</groupId>
+                                            <artifactId>blueprint-compendium</artifactId>
+                                            <classifier>sources</classifier>
+                                        </artifactItem>
                                     </artifactItems>
                                     <outputDirectory>${project.build.directory}/sources</outputDirectory>
                                 </configuration>

Propchange: geronimo/sandbox/blueprint/blueprint-compendium/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Apr 26 17:53:47 2009
@@ -0,0 +1,2 @@
+*.iml
+target

Added: geronimo/sandbox/blueprint/blueprint-compendium/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-compendium/pom.xml?rev=768730&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-compendium/pom.xml (added)
+++ geronimo/sandbox/blueprint/blueprint-compendium/pom.xml Sun Apr 26 17:53:47 2009
@@ -0,0 +1,55 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project>
+ <parent>
+    <groupId>org.apache.geronimo</groupId>
+    <artifactId>blueprint</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>blueprint-compendium</artifactId>
+  <name>Apache Geronimo Blueprint Compendium</name>
+  <packaging>bundle</packaging>
+  
+  <dependencies>
+      <dependency>
+          <groupId>org.apache.geronimo</groupId>
+          <artifactId>blueprint-core</artifactId>
+      </dependency>
+  </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.0.0</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>org.apache.geronimo.blueprint*;version="${pom.version}"</Export-Package>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+  
+</project>

Added: geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/CompendiumNamespaceHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/CompendiumNamespaceHandler.java?rev=768730&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/CompendiumNamespaceHandler.java (added)
+++ geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/CompendiumNamespaceHandler.java Sun Apr 26 17:53:47 2009
@@ -0,0 +1,149 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.blueprint.compendium;
+
+import java.net.URL;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.geronimo.blueprint.ExtendedComponentDefinitionRegistry;
+import org.apache.geronimo.blueprint.ExtendedParserContext;
+import org.apache.geronimo.blueprint.context.Parser;
+import org.apache.geronimo.blueprint.reflect.BeanPropertyImpl;
+import org.apache.geronimo.blueprint.reflect.PropsMetadataImpl;
+import org.apache.geronimo.blueprint.reflect.RefMetadataImpl;
+import org.apache.geronimo.blueprint.reflect.ReferenceMetadataImpl;
+import org.apache.geronimo.blueprint.reflect.ValueMetadataImpl;
+import org.apache.geronimo.blueprint.mutable.MutableBeanMetadata;
+import org.osgi.service.blueprint.context.ComponentDefinitionException;
+import org.osgi.service.blueprint.namespace.ComponentDefinitionRegistry;
+import org.osgi.service.blueprint.namespace.NamespaceHandler;
+import org.osgi.service.blueprint.namespace.ParserContext;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.MapMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+/**
+ * TODO
+ *
+ * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
+ * @version $Rev: 766508 $, $Date: 2009-04-19 22:09:27 +0200 (Sun, 19 Apr 2009) $
+ */
+public class CompendiumNamespaceHandler implements NamespaceHandler {
+
+    public static final String BLUEPRINT_COMPENDIUM_NAMESPACE = "http://www.osgi.org/xmlns/blueprint-compendium/v1.0.0";
+
+    public static final String PROPERTY_PLACEHOLDER_ELEMENT = "property-placeholder";
+    public static final String MANAGED_PROPERTIES_ELEMENT = "managed-properties";
+    public static final String MANAGED_SERVICE_FACTORY_ELEMENT = "managed-service-factory";
+    public static final String CM_PROPERTIES_ELEMENT = "cm-properties";
+    public static final String DEFAULT_PROPERTIES_ELEMENT = "default-properties";
+
+    public static final String ID_ATTRIBUTE = "id";
+    public static final String PERSISTENT_ID_ATTRIBUTE = "persistent-id";
+    public static final String PLACEHOLDER_PREFIX_ATTRIBUTE = "placeholder-prefix";
+    public static final String PLACEHOLDER_SUFFIX_ATTRIBUTE = "placeholder-suffix";
+    public static final String DEFAULTS_REF_ATTRIBUTE = "defaults-ref";
+    public static final String UPDATE_STRATEGY_ATTRIBUTE = "update-strategy";
+    public static final String UPDATE_METHOD_ATTRIBUTE = "update-method";
+
+    public static final String CONFIG_ADMIN_REFERENCE_NAME = "blueprint.configadmin";
+
+    public URL getSchemaLocation(String namespace) {
+        return getClass().getResource("/org/apache/geronimo/blueprint/compendium/blueprint-compendium.xsd");
+    }
+
+    public ComponentMetadata parse(Element element, ParserContext ctx) {
+        ExtendedParserContext context = (ExtendedParserContext) ctx;
+        ExtendedComponentDefinitionRegistry registry = (ExtendedComponentDefinitionRegistry) context.getComponentDefinitionRegistry();
+        Parser parser = new Parser("compendium-");
+        createConfigAdminProxy(registry);
+        if (nodeNameEquals(element, PROPERTY_PLACEHOLDER_ELEMENT)) {
+            MutableBeanMetadata metadata = context.createMetadata(MutableBeanMetadata.class);
+            metadata.setId(parser.getName(element));
+            metadata.setClassName(CompendiumPropertyPlaceholder.class.getName());
+            metadata.addProperty(new BeanPropertyImpl("blueprintContext", new RefMetadataImpl("blueprintContext")));
+            metadata.addProperty(new BeanPropertyImpl("configAdmin", new RefMetadataImpl(CONFIG_ADMIN_REFERENCE_NAME)));
+            metadata.addProperty(new BeanPropertyImpl("persistentId",
+                                                      new ValueMetadataImpl(element.getAttribute(PERSISTENT_ID_ATTRIBUTE))));
+            String prefix = element.hasAttribute(PLACEHOLDER_PREFIX_ATTRIBUTE)
+                                        ? element.getAttribute(PLACEHOLDER_PREFIX_ATTRIBUTE)
+                                        : "${";
+            metadata.addProperty(new BeanPropertyImpl("placeholderPrefix", new ValueMetadataImpl(prefix)));
+            String suffix = element.hasAttribute(PLACEHOLDER_SUFFIX_ATTRIBUTE)
+                                        ? element.getAttribute(PLACEHOLDER_SUFFIX_ATTRIBUTE)
+                                        : "}";
+            metadata.addProperty(new BeanPropertyImpl("placeholderSuffix", new ValueMetadataImpl(suffix)));
+            String defaultsRef = element.hasAttribute(DEFAULTS_REF_ATTRIBUTE) ? element.getAttribute(DEFAULTS_REF_ATTRIBUTE) : null;
+            if (defaultsRef != null) {
+                metadata.addProperty(new BeanPropertyImpl("defaultProperties", new RefMetadataImpl("defaultsRef")));
+            }
+            // Parse elements
+            NodeList nl = element.getChildNodes();
+            for (int i = 0; i < nl.getLength(); i++) {
+                Node node = nl.item(i);
+                if (node instanceof Element) {
+                    Element e = (Element) node;
+                    if (BLUEPRINT_COMPENDIUM_NAMESPACE.equals(e.getNamespaceURI())) {
+                        if (nodeNameEquals(e, DEFAULT_PROPERTIES_ELEMENT)) {
+                            if (defaultsRef != null) {
+                                throw new ComponentDefinitionException("Only one of " + DEFAULTS_REF_ATTRIBUTE + " attribute or " + DEFAULT_PROPERTIES_ELEMENT + " element is allowed");
+                            }
+                            MapMetadata map = parser.parseMap(e, metadata);
+                            metadata.addProperty(new BeanPropertyImpl("defaultProperties", new PropsMetadataImpl(map.getEntries())));
+                        }
+                    }
+                }
+            }
+            return metadata;
+        } else {
+            // TODO: parse other compendium elements.
+            throw new ComponentDefinitionException("Unsupported element: " + element.getNodeName());
+        }
+    }
+
+    /**
+     * Create a reference to the ConfigurationAdmin service if not already done
+     * and add it to the registry.
+     *
+     * @param registry the registry to add the config admin reference to
+     */
+    private void createConfigAdminProxy(ComponentDefinitionRegistry registry) {
+        if (registry.getComponentDefinition(CONFIG_ADMIN_REFERENCE_NAME) == null) {
+            ReferenceMetadataImpl reference = new ReferenceMetadataImpl();
+            reference.setId(CONFIG_ADMIN_REFERENCE_NAME);
+            reference.addInterfaceName(ConfigurationAdmin.class.getName());
+            reference.setAvailability(ReferenceMetadata.MANDATORY_AVAILABILITY);
+            reference.setTimeout(300000);
+            registry.registerComponentDefinition(reference);
+        }
+    }
+
+    public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
+        throw new ComponentDefinitionException("Illegal use of blueprint compendium namespace");
+    }
+
+    private static boolean nodeNameEquals(Node node, String name) {
+        return (name.equals(node.getNodeName()) || name.equals(node.getLocalName()));
+    }
+
+}

Added: geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/CompendiumPropertyPlaceholder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/CompendiumPropertyPlaceholder.java?rev=768730&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/CompendiumPropertyPlaceholder.java (added)
+++ geronimo/sandbox/blueprint/blueprint-compendium/src/main/java/org/apache/geronimo/blueprint/compendium/CompendiumPropertyPlaceholder.java Sun Apr 26 17:53:47 2009
@@ -0,0 +1,145 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.blueprint.compendium;
+
+import java.util.Map;
+import java.util.List;
+import java.util.Dictionary;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.osgi.service.blueprint.context.BlueprintContext;
+import org.osgi.service.blueprint.context.ComponentDefinitionException;
+import org.osgi.service.blueprint.namespace.ComponentDefinitionRegistry;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.RefCollectionMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+import org.osgi.service.blueprint.reflect.BeanArgument;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
+import org.osgi.service.blueprint.reflect.BeanProperty;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.MapEntry;
+import org.osgi.service.blueprint.reflect.RegistrationListener;
+import org.osgi.service.blueprint.reflect.CollectionMetadata;
+import org.osgi.service.blueprint.reflect.MapMetadata;
+import org.osgi.service.blueprint.reflect.PropsMetadata;
+import org.osgi.service.blueprint.reflect.Listener;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.cm.Configuration;
+import org.apache.geronimo.blueprint.ComponentDefinitionRegistryProcessor;
+import org.apache.geronimo.blueprint.beans.AbstractPropertyPlaceholder;
+import org.apache.geronimo.blueprint.mutable.MutableValueMetadata;
+
+/**
+ * TODO: javadoc
+ *
+ * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
+ * @version $Rev: 766508 $, $Date: 2009-04-19 22:09:27 +0200 (Sun, 19 Apr 2009) $
+ */
+public class CompendiumPropertyPlaceholder extends AbstractPropertyPlaceholder {
+
+    private BlueprintContext blueprintContext;
+    private ConfigurationAdmin configAdmin; 
+    private String persistentId;
+    private Map defaultProperties;
+
+    public BlueprintContext getBlueprintContext() {
+        return blueprintContext;
+    }
+
+    public void setBlueprintContext(BlueprintContext blueprintContext) {
+        this.blueprintContext = blueprintContext;
+    }
+
+    public ConfigurationAdmin getConfigAdmin() {
+        return configAdmin;
+    }
+
+    public void setConfigAdmin(ConfigurationAdmin configAdmin) {
+        this.configAdmin = configAdmin;
+    }
+
+    public String getPersistentId() {
+        return persistentId;
+    }
+
+    public void setPersistentId(String persistentId) {
+        this.persistentId = persistentId;
+    }
+
+    public Map getDefaultProperties() {
+        return defaultProperties;
+    }
+
+    public void setDefaultProperties(Map defaultProperties) {
+        this.defaultProperties = defaultProperties;
+    }
+
+    @Override
+    protected Metadata processValueMetadata(ValueMetadata metadata) {
+        return new LateBindingValueMetadata(metadata.getStringValue(), metadata.getTypeName());
+    }
+
+    protected String getProperty(String val) {
+        Object v = null;
+        try {
+            Configuration config = configAdmin.getConfiguration(persistentId);
+            Dictionary props = config.getProperties();
+            if (props != null) {
+                v = props.get(val);
+            }
+        } catch (Throwable t) {
+            t.printStackTrace();
+            // TODO: log ?
+        }
+        if (v == null && defaultProperties.containsKey(val)) {
+            v = defaultProperties.get(val);
+        }
+        return v instanceof String ? (String) v : null;
+    }
+
+    public class LateBindingValueMetadata implements MutableValueMetadata {
+
+        private String stringValue;
+        private String typeName;
+
+        public LateBindingValueMetadata(String stringValue, String typeName) {
+            this.stringValue = stringValue;
+            this.typeName = typeName;
+        }
+
+        public String getStringValue() {
+            return processString(stringValue);
+        }
+
+        public void setStringValue(String stringValue) {
+            this.stringValue = stringValue;
+        }
+
+        public String getTypeName() {
+            return typeName;
+        }
+
+        public void setTypeName(String typeName) {
+            this.typeName = typeName;
+        }
+    }
+
+}

Added: geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/OSGI-INF/blueprint/compendium.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/OSGI-INF/blueprint/compendium.xml?rev=768730&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/OSGI-INF/blueprint/compendium.xml (added)
+++ geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/OSGI-INF/blueprint/compendium.xml Sun Apr 26 17:53:47 2009
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <service interface="org.osgi.service.blueprint.namespace.NamespaceHandler">
+        <service-properties>
+            <entry key="org.osgi.blueprint.namespace" value="http://www.osgi.org/xmlns/blueprint-compendium/v1.0.0"/>
+        </service-properties>
+        <bean class="org.apache.geronimo.blueprint.compendium.CompendiumNamespaceHandler"/>
+
+    </service>
+</blueprint>
\ No newline at end of file

Copied: geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/org/apache/geronimo/blueprint/compendium/blueprint-compendium.xsd (from r768493, geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint-compendium.xsd)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/org/apache/geronimo/blueprint/compendium/blueprint-compendium.xsd?p2=geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/org/apache/geronimo/blueprint/compendium/blueprint-compendium.xsd&p1=geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint-compendium.xsd&r1=768493&r2=768730&rev=768730&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint-compendium.xsd (original)
+++ geronimo/sandbox/blueprint/blueprint-compendium/src/main/resources/org/apache/geronimo/blueprint/compendium/blueprint-compendium.xsd Sun Apr 26 17:53:47 2009
@@ -26,7 +26,7 @@
             attributeFormDefault="unqualified"
             version="1.0.0">
 
-    <xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0"/>
+    <xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0" schemaLocation="../../../../../../../../../blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint.xsd"/>
 
     <!-- property placeholder -->
 
@@ -34,7 +34,7 @@
 
     <xsd:complexType name="TpropertyPlaceholder">
         <xsd:complexContent>
-            <xsd:extension base="osgi:Tidentified">
+            <xsd:extension base="osgi:Tcomponent">
                 <xsd:sequence>
                     <!-- nested properties declaration -->
                     <xsd:element name="default-properties" type="TdefaultProperties" minOccurs="0" maxOccurs="1"/>
@@ -44,7 +44,7 @@
                 <xsd:attribute name="persistent-id" type="xsd:string" use="required"/>
                 <xsd:attribute name="placeholder-prefix" type="xsd:string" use="optional" default="${"/>
                 <xsd:attribute name="placeholder-suffix" type="xsd:string" use="optional" default="}"/>
-                <xsd:attribute name="defaults-ref" type="Tidref" use="optional"/>
+                <xsd:attribute name="defaults-ref" type="osgi:Tidref" use="optional"/>
             </xsd:extension>
         </xsd:complexContent>
     </xsd:complexType>

Modified: geronimo/sandbox/blueprint/blueprint-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/pom.xml?rev=768730&r1=768729&r2=768730&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/pom.xml (original)
+++ geronimo/sandbox/blueprint/blueprint-core/pom.xml Sun Apr 26 17:53:47 2009
@@ -70,7 +70,7 @@
                     <instructions>
                         <Export-Package>org.apache.geronimo.blueprint*;version="${pom.version}"</Export-Package>
                         <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Activator>org.apache.geronimo.blueprint.Activator</Bundle-Activator>
+                        <Bundle-Activator>org.apache.geronimo.blueprint.BlueprintExtender</Bundle-Activator>
                     </instructions>
                 </configuration>
             </plugin>

Copied: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintExtender.java (from r768493, 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/BlueprintExtender.java?p2=geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BlueprintExtender.java&p1=geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java&r1=768493&r2=768730&rev=768730&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/BlueprintExtender.java Sun Apr 26 17:53:47 2009
@@ -38,6 +38,7 @@
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.SynchronousBundleListener;
+import org.osgi.service.blueprint.context.BlueprintContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,9 +48,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 Activator implements BundleActivator, SynchronousBundleListener {
+public class BlueprintExtender implements BundleActivator, SynchronousBundleListener {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(BlueprintExtender.class);
 
     private final ExecutorService executors = Executors.newSingleThreadExecutor();
     private final Map<Bundle, BlueprintContextImpl> contextMap = new HashMap<Bundle, BlueprintContextImpl>();
@@ -96,13 +97,13 @@
     private void destroyContext(Bundle bundle) {
         BlueprintContextImpl moduleContext = contextMap.remove(bundle);
         if (moduleContext != null) {
-            LOGGER.debug("Destroying BlueprintContext for bundle " + bundle.getSymbolicName());
+            LOGGER.debug("Destroying BlueprintContext for bundle {}", bundle.getSymbolicName());
             moduleContext.destroy();
         }
     }
     
     private void checkBundle(Bundle bundle) {
-        LOGGER.debug("Scanning bundle " + bundle.getSymbolicName() + " for blueprint application");
+        LOGGER.debug("Scanning bundle {} for blueprint application", bundle.getSymbolicName());
 
         List<URL> urls = new ArrayList<URL>();
         Dictionary headers = bundle.getHeaders();
@@ -126,12 +127,26 @@
             }
         }
         if (!urls.isEmpty()) {
-            LOGGER.debug("Found blueprint application in bundle " + bundle.getSymbolicName() + " with urls: " + urls);
-            final BlueprintContextImpl moduleContext = new BlueprintContextImpl(bundle.getBundleContext(), sender, handlers, executors, urls);
-            contextMap.put(bundle, moduleContext);
-            executors.submit(moduleContext);
+            LOGGER.debug("Found blueprint application in bundle {} with urls: {}", bundle.getSymbolicName(), urls);
+
+            // Check compatibility
+            boolean compatible;
+            try {
+                Class clazz = bundle.getBundleContext().getBundle().loadClass(BlueprintContext.class.getName());
+                compatible = (clazz == BlueprintContext.class);
+            } catch (ClassNotFoundException e) {
+                compatible = true;
+            }
+            if (compatible) {
+                final BlueprintContextImpl moduleContext = new BlueprintContextImpl(bundle.getBundleContext(), sender, handlers, executors, urls);
+                contextMap.put(bundle, moduleContext);
+                executors.submit(moduleContext);
+            } else {
+                LOGGER.info("Bundle {} is not compatible with this blueprint extender", bundle.getSymbolicName());
+            }
+
         } else {
-            LOGGER.debug("No blueprint application found in bundle " + bundle.getSymbolicName());
+            LOGGER.debug("No blueprint application found in bundle {}", bundle.getSymbolicName());
         }
     }
 

Added: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ComponentDefinitionRegistryProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ComponentDefinitionRegistryProcessor.java?rev=768730&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ComponentDefinitionRegistryProcessor.java (added)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ComponentDefinitionRegistryProcessor.java Sun Apr 26 17:53:47 2009
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.blueprint;
+
+import org.osgi.service.blueprint.namespace.ComponentDefinitionRegistry;
+import org.osgi.service.blueprint.context.ComponentDefinitionException;
+
+/**
+ * TODO
+ *
+ * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
+ * @version $Rev: 766508 $, $Date: 2009-04-19 22:09:27 +0200 (Sun, 19 Apr 2009) $
+ */
+public interface ComponentDefinitionRegistryProcessor {
+
+    public void process(ComponentDefinitionRegistry registry);
+
+}

Added: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedBlueprintContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedBlueprintContext.java?rev=768730&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedBlueprintContext.java (added)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedBlueprintContext.java Sun Apr 26 17:53:47 2009
@@ -0,0 +1,34 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.blueprint;
+
+import java.util.List;
+
+import org.osgi.service.blueprint.context.BlueprintContext;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+
+/**
+ * TODO: javadoc
+ *
+ * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
+ * @version $Rev: 766508 $, $Date: 2009-04-19 22:09:27 +0200 (Sun, 19 Apr 2009) $
+ */
+public interface ExtendedBlueprintContext extends BlueprintContext {
+
+    <T  extends ComponentMetadata> List<T> getComponentsMetadata(Class<T> type);
+
+}

Added: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedComponentDefinitionRegistry.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedComponentDefinitionRegistry.java?rev=768730&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedComponentDefinitionRegistry.java (added)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedComponentDefinitionRegistry.java Sun Apr 26 17:53:47 2009
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.blueprint;
+
+import java.util.List;
+
+import org.osgi.service.blueprint.namespace.ComponentDefinitionRegistry;
+import org.osgi.service.blueprint.reflect.Target;
+
+/**
+ * An extended ComponentDefinitionRegistry that allows converters and processors to be registered.
+ *
+ * @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 ExtendedComponentDefinitionRegistry extends ComponentDefinitionRegistry {
+
+    String getDefaultInitMethod();
+
+    void setDefaultInitMethod(String defaultInitMethod);
+
+    String getDefaultDestroyMethod();
+
+    void setDefaultDestroyMethod(String defaultDestroyMethod);
+}

Added: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedParserContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedParserContext.java?rev=768730&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedParserContext.java (added)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedParserContext.java Sun Apr 26 17:53:47 2009
@@ -0,0 +1,16 @@
+package org.apache.geronimo.blueprint;
+
+import org.osgi.service.blueprint.namespace.ParserContext;
+import org.osgi.service.blueprint.reflect.Metadata;
+
+/**
+ * An extended ParserContext that also acts as a factory of Metadata objects.
+ *
+ * @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 ExtendedParserContext extends ParserContext {
+
+    <T extends Metadata> T createMetadata(Class<T> type);
+
+}

Added: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/AbstractPropertyPlaceholder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/AbstractPropertyPlaceholder.java?rev=768730&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/AbstractPropertyPlaceholder.java (added)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/AbstractPropertyPlaceholder.java Sun Apr 26 17:53:47 2009
@@ -0,0 +1,229 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.blueprint.beans;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.geronimo.blueprint.ComponentDefinitionRegistryProcessor;
+import org.apache.geronimo.blueprint.mutable.MutableValueMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableBeanArgument;
+import org.apache.geronimo.blueprint.mutable.MutableBeanProperty;
+import org.apache.geronimo.blueprint.mutable.MutableBeanMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableServiceMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableRegistrationListener;
+import org.apache.geronimo.blueprint.mutable.MutableReferenceMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableListener;
+import org.apache.geronimo.blueprint.mutable.MutableRefCollectionMetadata;
+import org.apache.geronimo.blueprint.mutable.MutablePropsMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableMapMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableMapEntry;
+import org.apache.geronimo.blueprint.mutable.MutableCollectionMetadata;
+import org.osgi.service.blueprint.namespace.ComponentDefinitionRegistry;
+import org.osgi.service.blueprint.context.ComponentDefinitionException;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.RefCollectionMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
+import org.osgi.service.blueprint.reflect.CollectionMetadata;
+import org.osgi.service.blueprint.reflect.MapMetadata;
+import org.osgi.service.blueprint.reflect.PropsMetadata;
+import org.osgi.service.blueprint.reflect.BeanArgument;
+import org.osgi.service.blueprint.reflect.BeanProperty;
+import org.osgi.service.blueprint.reflect.RegistrationListener;
+import org.osgi.service.blueprint.reflect.Listener;
+import org.osgi.service.blueprint.reflect.MapEntry;
+import org.osgi.service.blueprint.reflect.Target;
+import org.osgi.service.blueprint.reflect.NonNullMetadata;
+
+/**
+ * Abstract class for property placeholders.
+ *
+ * TODO: enhance to use MutableXxx to allow replacement of Metadata if needed.
+ * In particular, replacing the ValueMetadataImpl may be needed to allow property
+ * replacement at instanciation time instead of replacing the properties at parsing time.
+ *
+ * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
+ * @version $Rev: 766508 $, $Date: 2009-04-19 22:09:27 +0200 (Sun, 19 Apr 2009) $
+ */
+public abstract class AbstractPropertyPlaceholder implements ComponentDefinitionRegistryProcessor {
+
+    private String placeholderPrefix;
+    private String placeholderSuffix;
+    private Pattern pattern;
+
+    public String getPlaceholderPrefix() {
+        return placeholderPrefix;
+    }
+
+    public void setPlaceholderPrefix(String placeholderPrefix) {
+        this.placeholderPrefix = placeholderPrefix;
+    }
+
+    public String getPlaceholderSuffix() {
+        return placeholderSuffix;
+    }
+
+    public void setPlaceholderSuffix(String placeholderSuffix) {
+        this.placeholderSuffix = placeholderSuffix;
+    }
+
+    public void process(ComponentDefinitionRegistry registry) throws ComponentDefinitionException {
+        for (String name : registry.getComponentDefinitionNames()) {
+            processMetadata(registry.getComponentDefinition(name));
+        }
+    }
+
+    protected Metadata processMetadata(Metadata metadata) {
+        if (metadata instanceof BeanMetadata) {
+            return processBeanMetadata((BeanMetadata) metadata);
+        } else if (metadata instanceof RefCollectionMetadata) {
+            return processRefCollectionMetadata((RefCollectionMetadata) metadata);
+        } else if (metadata instanceof ReferenceMetadata) {
+            return processReferenceMetadata((ReferenceMetadata) metadata);
+        } else if (metadata instanceof ServiceMetadata) {
+            return processServiceMetadata((ServiceMetadata) metadata);
+        } else if (metadata instanceof CollectionMetadata) {
+            return processCollectionMetadata((CollectionMetadata) metadata);
+        } else if (metadata instanceof MapMetadata) {
+            return processMapMetadata((MapMetadata) metadata);
+        } else if (metadata instanceof PropsMetadata) {
+            return processPropsMetadata((PropsMetadata) metadata);
+        } else if (metadata instanceof ValueMetadata) {
+            return processValueMetadata((ValueMetadata) metadata);
+        } else {
+            return metadata;
+        }
+    }
+
+    protected Metadata processBeanMetadata(BeanMetadata component) {
+        for (BeanArgument arg :  component.getArguments()) {
+            ((MutableBeanArgument) arg).setValue(processMetadata(arg.getValue()));
+        }
+        for (BeanProperty prop : component.getProperties()) {
+            ((MutableBeanProperty) prop).setValue(processMetadata(prop.getValue()));
+        }
+        ((MutableBeanMetadata) component).setFactoryComponent((Target) processMetadata(component.getFactoryComponent()));
+        return component;
+    }
+
+    protected Metadata processServiceMetadata(ServiceMetadata component) {
+        ((MutableServiceMetadata) component).setServiceComponent((Target) processMetadata(component.getServiceComponent()));
+        List<MapEntry> entries = new ArrayList<MapEntry>(component.getServiceProperties());
+        for (MapEntry entry : entries) {
+            ((MutableServiceMetadata) component).removeServiceProperty(entry);
+        }
+        for (MapEntry entry : processMapEntries(entries)) {
+            ((MutableServiceMetadata) component).addServiceProperty(entry);
+        }
+        for (RegistrationListener listener : component.getRegistrationListeners()) {
+            ((MutableRegistrationListener) listener).setListenerComponent((Target) processMetadata(listener.getListenerComponent()));
+        }
+        return component;
+    }
+
+    protected Metadata processReferenceMetadata(ReferenceMetadata component) {
+        for (Listener listener : component.getServiceListeners()) {
+            ((MutableListener) listener).setListenerComponent((Target) processMetadata(listener.getListenerComponent()));
+        }
+        return component;
+    }
+
+    protected Metadata processRefCollectionMetadata(RefCollectionMetadata component) {
+        for (Listener listener : component.getServiceListeners()) {
+            ((MutableListener) listener).setListenerComponent((Target) processMetadata(listener.getListenerComponent()));
+        }
+        ((MutableRefCollectionMetadata) component).setComparator((Target) processMetadata(component.getComparator()));
+        return component;
+    }
+
+    protected Metadata processPropsMetadata(PropsMetadata metadata) {
+        List<MapEntry> entries = new ArrayList<MapEntry>(metadata.getEntries());
+        for (MapEntry entry : entries) {
+            ((MutablePropsMetadata) metadata).removeEntry(entry);
+        }
+        for (MapEntry entry : processMapEntries(entries)) {
+            ((MutablePropsMetadata) metadata).addEntry(entry);
+        }
+        return metadata;
+    }
+
+    protected Metadata processMapMetadata(MapMetadata metadata) {
+        List<MapEntry> entries = new ArrayList<MapEntry>(metadata.getEntries());
+        for (MapEntry entry : entries) {
+            ((MutableMapMetadata) metadata).removeEntry(entry);
+        }
+        for (MapEntry entry : processMapEntries(entries)) {
+            ((MutableMapMetadata) metadata).addEntry(entry);
+        }
+        return metadata;
+    }
+
+    protected List<MapEntry> processMapEntries(List<MapEntry> entries) {
+        for (MapEntry entry : entries) {
+            ((MutableMapEntry) entry).setKey((NonNullMetadata) processMetadata(entry.getKey()));
+            ((MutableMapEntry) entry).setValue(processMetadata(entry.getValue()));
+        }
+        return entries;
+    }
+
+    protected Metadata processCollectionMetadata(CollectionMetadata metadata) {
+        List<Metadata> values = new ArrayList<Metadata>(metadata.getValues());
+        for (Metadata value : values) {
+            ((MutableCollectionMetadata) metadata).removeValue(value);
+        }
+        for (Metadata value : values) {
+            ((MutableCollectionMetadata) metadata).addValue(processMetadata(value));
+        }
+        return metadata;
+    }
+
+    protected Metadata processValueMetadata(ValueMetadata metadata) {
+        ((MutableValueMetadata) metadata).setStringValue(processString(metadata.getStringValue()));
+        return metadata;
+    }
+
+    protected String processString(String str) {
+        Matcher matcher = getPattern().matcher(str);
+        while (matcher.find()) {
+            String rep = getProperty(matcher.group(1));
+            if (rep != null) {
+                str = str.replace(matcher.group(0), rep);
+                matcher.reset(str);
+            }
+        }
+        return str;
+    }
+
+    protected String getProperty(String val) {
+        return null;
+    }
+
+    protected Pattern getPattern() {
+        if (pattern == null) {
+            pattern = Pattern.compile("\\Q" + placeholderPrefix + "\\E(.+)\\Q" + placeholderSuffix + "\\E");
+        }
+        return pattern;
+    }
+
+}

Added: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/SystemPropertyPlaceholder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/SystemPropertyPlaceholder.java?rev=768730&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/SystemPropertyPlaceholder.java (added)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/beans/SystemPropertyPlaceholder.java Sun Apr 26 17:53:47 2009
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.blueprint.beans;
+
+/**
+ * Property placeholder that looks for properties in the System properties.
+ *
+ * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
+ * @version $Rev: 766508 $, $Date: 2009-04-19 22:09:27 +0200 (Sun, 19 Apr 2009) $
+ */
+public class SystemPropertyPlaceholder extends AbstractPropertyPlaceholder {
+
+    protected String getProperty(String val) {
+        return System.getProperty(val);
+    }
+
+}

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=768730&r1=768729&r2=768730&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 Sun Apr 26 17:53:47 2009
@@ -29,16 +29,18 @@
 import java.util.Set;
 import java.util.Properties;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.concurrent.ExecutorService;
 
 import org.apache.geronimo.blueprint.BlueprintConstants;
 import org.apache.geronimo.blueprint.utils.HeaderParser;
+import org.apache.geronimo.blueprint.utils.BundleDelegatingClassLoader;
 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.SatisfiableRecipe;
+import org.apache.geronimo.blueprint.ComponentDefinitionRegistryProcessor;
+import org.apache.geronimo.blueprint.ExtendedBlueprintContext;
 import org.apache.geronimo.blueprint.convert.ConversionServiceImpl;
 import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
 import org.apache.xbean.recipe.ObjectGraph;
@@ -50,7 +52,6 @@
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.ServiceReference;
 import org.osgi.service.blueprint.context.BlueprintContext;
 import org.osgi.service.blueprint.context.NoSuchComponentException;
 import org.osgi.service.blueprint.convert.ConversionService;
@@ -69,7 +70,7 @@
  * @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 BlueprintContextImpl implements BlueprintContext, NamespaceHandlerRegistry.Listener, Runnable, SatisfiableRecipe.SatisfactionListener {
+public class BlueprintContextImpl implements ExtendedBlueprintContext, NamespaceHandlerRegistry.Listener, Runnable, SatisfiableRecipe.SatisfactionListener {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(BlueprintContextImpl.class);
 
@@ -87,6 +88,7 @@
     private final ModuleContextEventSender sender;
     private final NamespaceHandlerRegistry handlers;
     private final List<URL> urls;
+    private final ComponentDefinitionRegistryImpl helperComponentDefinitionRegistry;
     private final ComponentDefinitionRegistryImpl componentDefinitionRegistry;
     private final ConversionServiceImpl conversionService;
     private final ExecutorService executors;
@@ -98,6 +100,7 @@
     private boolean waitForNamespaceHandlersEventSent;
     private Map<String, Destroyable> destroyables = new HashMap<String, Destroyable>();
     private Map<String, List<SatisfiableRecipe>> satisfiables;
+    private ClassLoader classLoader;
 
     public BlueprintContextImpl(BundleContext bundleContext, ModuleContextEventSender sender, NamespaceHandlerRegistry handlers, ExecutorService executors, List<URL> urls) {
         this.bundleContext = bundleContext;
@@ -105,8 +108,14 @@
         this.handlers = handlers;
         this.urls = urls;
         this.conversionService = new ConversionServiceImpl();
+        this.helperComponentDefinitionRegistry = new ComponentDefinitionRegistryImpl();
         this.componentDefinitionRegistry = new ComponentDefinitionRegistryImpl();
         this.executors = executors;
+        this.classLoader = new BundleDelegatingClassLoader(bundleContext.getBundle(), getClass().getClassLoader());
+    }
+
+    public ClassLoader getClassLoader() {
+        return classLoader;
     }
 
     public void addDestroyable(String name, Destroyable destroyable) {
@@ -160,14 +169,16 @@
                                 return;
                             }
                         }
-                        parser.populate(handlers, componentDefinitionRegistry);
+                        parser.populateHelperSection(handlers, helperComponentDefinitionRegistry);
+                        parser.populateMainSection(handlers, componentDefinitionRegistry);
+                        // TODO: need to wait for references from the helper section, such as ConfigAdmin or Converter from the OSGi registry
+                        processHelperSection();
                         state = State.Populated;
                         break;
                     case Populated:
                         Instanciator i = new Instanciator(this);
-                        Repository repository = i.createRepository();
+                        Repository repository = i.createRepository(componentDefinitionRegistry);
                         objectGraph = new ObjectGraph(repository);
-                        registerTypeConverters();
                         instanciateServiceReferences();
                         if (checkAllSatisfiables()) {
                             state = State.InitialReferencesSatisfied;
@@ -186,11 +197,6 @@
                         break;
                     case InitialReferencesSatisfied:
                         instantiateComponents();
-
-                        // TODO: access to any OSGi reference proxy is currently a problem at this point, because calling toString() will
-                        // TODO:      wait for a service to be available.  We may need to catch toString(), equals() and hashCode() and make them
-                        // TODO:      work even if there's no service available.
-
                         registerAllServices();
 
                         // Register the ModuleContext in the OSGi registry
@@ -219,19 +225,22 @@
         }
     }
 
-    private void registerTypeConverters() {
-        List<String> typeConvertersNames = componentDefinitionRegistry.getTypeConverterNames();
-        Map<String, Object> typeConverters = objectGraph.createAll(typeConvertersNames);
-        System.out.println("Type converters: " + typeConverters);
-        for (String name : typeConvertersNames) {
-            Object typeConverterInstance = typeConverters.get(name);
-            if (typeConverterInstance instanceof Converter) {
-                Converter converter = (Converter) typeConverterInstance;
-                conversionService.registerConverter(converter);
-            } else {
-                // TODO: throw exception or log
+    private void processHelperSection() throws Exception {
+        Instanciator i = new Instanciator(this);
+        Repository repository = i.createRepository(helperComponentDefinitionRegistry);
+        ObjectGraph graph = new ObjectGraph(repository);
+        Map<String, Object> objects = graph.createAll(new ArrayList<String>(helperComponentDefinitionRegistry.getComponentDefinitionNames()));
+        for (Object obj : objects.values()) {
+            if (obj instanceof Converter) {
+                conversionService.registerConverter((Converter) obj);
+            }
+        }
+        for (Object obj : objects.values()) {
+            if (obj instanceof ComponentDefinitionRegistryProcessor) {
+                ((ComponentDefinitionRegistryProcessor) obj).process(componentDefinitionRegistry);
             }
         }
+        // TODO: need to destroy those objects at the end
     }
 
     private Map<String, List<SatisfiableRecipe>> getSatisfiableDependenciesMap() {
@@ -394,26 +403,26 @@
     }
 
     public Collection<ServiceReferenceMetadata> getReferencedServicesMetadata() {
-        return getMetadata(ServiceReferenceMetadata.class);
+        return getComponentsMetadata(ServiceReferenceMetadata.class);
     }
 
     public Collection<ServiceMetadata> getExportedServicesMetadata() {
-        return getMetadata(ServiceMetadata.class);
+        return getComponentsMetadata(ServiceMetadata.class);
     }
 
     public Collection<BeanMetadata> getBeanComponentsMetadata() {
-        return getMetadata(BeanMetadata.class);
+        return getComponentsMetadata(BeanMetadata.class);
     }
 
-    private <T> Collection<T> getMetadata(Class<T> clazz) {
-        Collection<T> metadatas = new ArrayList<T>();
+    public <T extends ComponentMetadata> List<T> getComponentsMetadata(Class<T> clazz) {
+        List<T> metadatas = new ArrayList<T>();
         for (String name : componentDefinitionRegistry.getComponentDefinitionNames()) {
             ComponentMetadata component = componentDefinitionRegistry.getComponentDefinition(name);
             if (clazz.isInstance(component)) {
                 metadatas.add(clazz.cast(component));
             }
         }
-        metadatas = Collections.unmodifiableCollection(metadatas);
+        metadatas = Collections.unmodifiableList(metadatas);
         return metadatas;
 
     }
@@ -422,10 +431,6 @@
         return objectGraph;
     }
     
-    protected ComponentDefinitionRegistryImpl getComponentDefinitionRegistry() {
-        return componentDefinitionRegistry;
-    }
-    
     protected ConversionService getConversionService() {
         return conversionService;
     }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java?rev=768730&r1=768729&r2=768730&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java Sun Apr 26 17:53:47 2009
@@ -20,19 +20,17 @@
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
-import java.util.Comparator;
 
-import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
-import org.apache.geronimo.blueprint.reflect.ServiceMetadataImpl;
+import org.apache.geronimo.blueprint.ExtendedComponentDefinitionRegistry;
 import org.apache.geronimo.blueprint.reflect.MapMetadataImpl;
+import org.apache.geronimo.blueprint.reflect.ServiceMetadataImpl;
 import org.apache.geronimo.blueprint.utils.ReflectionUtils;
 import org.apache.xbean.recipe.ArrayRecipe;
 import org.apache.xbean.recipe.CollectionRecipe;
@@ -43,27 +41,25 @@
 import org.apache.xbean.recipe.Recipe;
 import org.apache.xbean.recipe.ReferenceRecipe;
 import org.apache.xbean.recipe.Repository;
-import org.osgi.service.blueprint.context.BlueprintContext;
 import org.osgi.service.blueprint.convert.ConversionService;
-import org.osgi.service.blueprint.namespace.ComponentDefinitionRegistry;
 import org.osgi.service.blueprint.reflect.BeanArgument;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.BeanProperty;
+import org.osgi.service.blueprint.reflect.CollectionMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.IdRefMetadata;
+import org.osgi.service.blueprint.reflect.Listener;
+import org.osgi.service.blueprint.reflect.MapEntry;
 import org.osgi.service.blueprint.reflect.MapMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
 import org.osgi.service.blueprint.reflect.NullMetadata;
 import org.osgi.service.blueprint.reflect.PropsMetadata;
-import org.osgi.service.blueprint.reflect.IdRefMetadata;
+import org.osgi.service.blueprint.reflect.RefCollectionMetadata;
 import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
 import org.osgi.service.blueprint.reflect.RegistrationListener;
 import org.osgi.service.blueprint.reflect.ServiceMetadata;
 import org.osgi.service.blueprint.reflect.ValueMetadata;
-import org.osgi.service.blueprint.reflect.Metadata;
-import org.osgi.service.blueprint.reflect.ReferenceMetadata;
-import org.osgi.service.blueprint.reflect.RefCollectionMetadata;
-import org.osgi.service.blueprint.reflect.Listener;
-import org.osgi.service.blueprint.reflect.BeanProperty;
-import org.osgi.service.blueprint.reflect.CollectionMetadata;
-import org.osgi.service.blueprint.reflect.MapEntry;
 
 /**
  * TODO: javadoc
@@ -89,6 +85,7 @@
     }
     
     private BlueprintContextImpl blueprintContext;
+    private ExtendedComponentDefinitionRegistry registry;
 
     public Instanciator(BlueprintContextImpl blueprintContext) {
         this.blueprintContext = blueprintContext;
@@ -96,33 +93,21 @@
     
     private void addBuiltinComponents(Repository repository) {
         if (blueprintContext != null) {
-            repository.add("moduleContext", blueprintContext);
+            repository.add("blueprintContext", blueprintContext);
             repository.add("bundleContext", blueprintContext.getBundleContext());
             repository.add("bundle", blueprintContext.getBundleContext().getBundle());
             repository.add("conversionService", blueprintContext.getConversionService());
         }
     }
     
-    public Repository createRepository() throws Exception {
-        ComponentDefinitionRegistryImpl registry = getComponentDefinitionRegistry();
+    public Repository createRepository(ExtendedComponentDefinitionRegistry registry) throws Exception {
+        this.registry = registry;
+
         Repository repository = new ScopedRepository();
         addBuiltinComponents(repository);
         
-        // Create type-converter recipes
-        for (Metadata value : registry.getTypeConverters()) {
-            if (value instanceof ComponentMetadata) {
-                Recipe recipe = (Recipe) getValue(value, null);
-                repository.add(recipe.getName(), recipe);
-            } else if (value instanceof RefMetadata) {
-                ReferenceRecipe recipe = (ReferenceRecipe) getValue(value, null);
-                repository.add(recipe.getReferenceName(), recipe);
-            } else {
-                throw new RuntimeException("Unexpected converter type: " + value);
-            }
-        }
-        
         // Create component recipes
-        for (String name : (Set<String>) registry.getComponentDefinitionNames()) {
+        for (String name : registry.getComponentDefinitionNames()) {
             ComponentMetadata component = registry.getComponentDefinition(name);
             Recipe recipe = createRecipe(component);
             repository.add(name, recipe);
@@ -132,7 +117,7 @@
 
     private Recipe createRecipe(ComponentMetadata component) throws Exception {
         if (component instanceof BeanMetadata) {
-            return createComponentRecipe((BeanMetadata) component);
+            return createBeanRecipe((BeanMetadata) component);
         } else if (component instanceof ServiceMetadata) {
             return createServiceRecipe((ServiceMetadata) component);
         } else if (component instanceof ReferenceMetadata) {
@@ -148,7 +133,7 @@
         CollectionRecipe listenersRecipe = null;
         if (metadata.getServiceListeners() != null) {
             listenersRecipe = new CollectionRecipe(ArrayList.class);
-            for (Listener listener : (Collection<Listener>) metadata.getServiceListeners()) {
+            for (Listener listener : metadata.getServiceListeners()) {
                 listenersRecipe.add(createRecipe(listener));
             }
         }
@@ -170,7 +155,7 @@
         CollectionRecipe listenersRecipe = null;
         if (metadata.getServiceListeners() != null) {
             listenersRecipe = new CollectionRecipe(ArrayList.class);
-            for (Listener listener : (Collection<Listener>) metadata.getServiceListeners()) {
+            for (Listener listener : metadata.getServiceListeners()) {
                 listenersRecipe.add(createRecipe(listener));
             }
         }
@@ -190,7 +175,7 @@
         recipe.setProperty("moduleContext", blueprintContext);
         BeanMetadata exportedComponent = getLocalServiceComponent(serviceExport.getServiceComponent());
         if (exportedComponent != null && BeanMetadata.SCOPE_BUNDLE.equals(exportedComponent.getScope())) {
-            BlueprintObjectRecipe exportedComponentRecipe = createComponentRecipe(exportedComponent);
+            BlueprintObjectRecipe exportedComponentRecipe = createBeanRecipe(exportedComponent);
             recipe.setProperty("service", new BundleScopeServiceFactory(blueprintContext, exportedComponentRecipe));
         } else {
             recipe.setProperty("service", getValue(serviceExport.getServiceComponent(), null));
@@ -204,7 +189,7 @@
         }
         if (serviceExport.getRegistrationListeners() != null) {
             CollectionRecipe listenersRecipe = new CollectionRecipe(ArrayList.class);
-            for (RegistrationListener listener : (Collection<RegistrationListener>)serviceExport.getRegistrationListeners()) {
+            for (RegistrationListener listener : serviceExport.getRegistrationListeners()) {
                 listenersRecipe.add(createRecipe(listener));
             }
             recipe.setProperty("listeners", listenersRecipe);
@@ -212,7 +197,7 @@
         return recipe;
     }
 
-    private BlueprintObjectRecipe createComponentRecipe(BeanMetadata local) throws Exception {
+    private BlueprintObjectRecipe createBeanRecipe(BeanMetadata local) throws Exception {
         BlueprintObjectRecipe recipe = new BlueprintObjectRecipe(blueprintContext, loadClass(local.getClassName()));
         recipe.allow(Option.PRIVATE_PROPERTIES);
         recipe.setName(local.getId());
@@ -224,7 +209,6 @@
         if (BeanMetadata.SCOPE_PROTOTYPE.equals(local.getScope())) {
             recipe.setKeepRecipe(true);
         }
-        ComponentDefinitionRegistryImpl registry = getComponentDefinitionRegistry();
         // check for init-method and set it on Recipe
         String initMethod = local.getInitMethodName();
         if (initMethod == null) {
@@ -293,7 +277,6 @@
         ComponentMetadata metadata = null;
         if (value instanceof RefMetadata) {
             RefMetadata ref = (RefMetadata) value;
-            ComponentDefinitionRegistry registry = getComponentDefinitionRegistry();
             metadata = registry.getComponentDefinition(ref.getComponentId());
         } else if (value instanceof ComponentMetadata) {
             metadata = (ComponentMetadata) value;
@@ -312,9 +295,8 @@
             return createRecipe((ComponentMetadata) v);
         } else if (v instanceof ValueMetadata) {
             ValueMetadata stringValue = (ValueMetadata) v;
-            String value = stringValue.getStringValue();
             Class type = loadClass(stringValue.getTypeName());
-            return new ValueRecipe(getConversionService(), value, type, groupingType);
+            return new ValueRecipe(getConversionService(), stringValue, type, groupingType);
         } else if (v instanceof RefMetadata) {
             String componentName = ((RefMetadata) v).getComponentId();
             return new ReferenceRecipe(componentName);
@@ -362,10 +344,6 @@
         }
     }
     
-    protected ComponentDefinitionRegistryImpl getComponentDefinitionRegistry() {
-        return blueprintContext.getComponentDefinitionRegistry();
-    }
-    
     protected ConversionService getConversionService() {
         return blueprintContext.getConversionService();
     }
@@ -374,7 +352,7 @@
         return loadClass(blueprintContext, typeName);
     }
     
-    public static Class loadClass(BlueprintContext context, String typeName) throws ClassNotFoundException {
+    public static Class loadClass(BlueprintContextImpl context, String typeName) throws ClassNotFoundException {
         if (typeName == null) {
             return null;
         }
@@ -385,12 +363,13 @@
                 ClassLoader loader = Thread.currentThread().getContextClassLoader();
                 clazz = loader.loadClass(typeName);
             } else {
-                clazz = context.getBundleContext().getBundle().loadClass(typeName);
+                // TODO: use a mixed classloader while the classloading + namespace handler problem is solved
+                clazz = context.getClassLoader().loadClass(typeName);
             }
         }
         return clazz;
     }
-    
+
     private static class BeanArgumentComparator implements Comparator<BeanArgument> {
         public int compare(BeanArgument object1, BeanArgument object2) {
             return object1.getIndex() - object2.getIndex();

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java?rev=768730&r1=768729&r2=768730&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java Sun Apr 26 17:53:47 2009
@@ -41,7 +41,7 @@
 import org.w3c.dom.NodeList;
 
 import org.apache.geronimo.blueprint.NamespaceHandlerRegistry;
-import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
+import org.apache.geronimo.blueprint.ExtendedComponentDefinitionRegistry;
 import org.apache.geronimo.blueprint.namespace.ParserContextImpl;
 import org.apache.geronimo.blueprint.reflect.ListenerImpl;
 import org.apache.geronimo.blueprint.reflect.RefCollectionMetadataImpl;
@@ -86,7 +86,6 @@
 public class Parser {
 
     public static final String BLUEPRINT_NAMESPACE = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
-    public static final String BLUEPRINT_COMPENDIUM_NAMESPACE = "http://www.osgi.org/xmlns/blueprint-compendium/v1.0.0";
 
     public static final String BLUEPRINT_ELEMENT = "blueprint";
     public static final String DESCRIPTION_ELEMENT = "description";
@@ -169,7 +168,7 @@
     public static final String AVAILABILITY_MANDATORY = "mandatory";
     public static final String AVAILABILITY_OPTIONAL = "optional";
     public static final String AVAILABILITY_DEFAULT = AVAILABILITY_MANDATORY;
-    public static final String TIMEOUT_DEFAULT = "30000";
+    public static final String TIMEOUT_DEFAULT = "300000";
     public static final String MEMBER_TYPE_SERVICES = "service-instance";
     public static final String MEMBER_TYPE_SERVICE_REFERENCE = "service-reference";
     public static final String ORDERING_BASIS_SERVICES = "services";
@@ -177,18 +176,24 @@
     public static final String LAZY_INIT_DEFAULT = BOOLEAN_FALSE;
 
     private List<Document> documents;
-    private ComponentDefinitionRegistryImpl registry;
+    private ExtendedComponentDefinitionRegistry registry;
     private NamespaceHandlerRegistry namespaceHandlerRegistry;
+    private String namePrefix = "component-";
     private int nameCounter;
     private String defaultTimeout;
     private String defaultAvailability;
     private String defaultLazyInit;
     private String defaultInitMethod;
     private String defaultDestroyMethod;
+    private boolean mainSection;
 
     public Parser() {
     }
 
+    public Parser(String namePrefix) {
+        this.namePrefix = namePrefix;
+    }
+
     public void parse(List<URL> urls) throws Exception {
         List<Document> documents = new ArrayList<Document>();
         // Create document builder factory
@@ -223,7 +228,7 @@
     private void findNamespaces(Set<URI> namespaces, Node node) {
         if (node instanceof Element || node instanceof Attr) {
             String ns = node.getNamespaceURI();
-            if (ns != null && !isBlueprintNamespace(ns) && !isBlueprintCompendiumNamespace(ns)) {
+            if (ns != null && !isBlueprintNamespace(ns)) {
                 namespaces.add(URI.create(ns));
             }
         }
@@ -233,13 +238,25 @@
         }
     }
 
-    public void populate(NamespaceHandlerRegistry handlers,
-                         ComponentDefinitionRegistryImpl registry) {
+    public void populateHelperSection(NamespaceHandlerRegistry handlers,
+                                      ExtendedComponentDefinitionRegistry registry) {
+        doPopulate(handlers, registry, false);
+    }
+
+    public void populateMainSection(NamespaceHandlerRegistry handlers,
+                                    ExtendedComponentDefinitionRegistry registry) {
+        doPopulate(handlers, registry, true);
+    }
+
+    private void doPopulate(NamespaceHandlerRegistry handlers,
+                            ExtendedComponentDefinitionRegistry registry,
+                            boolean mainSection) {
         if (this.documents == null) {
             throw new IllegalStateException("Documents should be parsed before populating the registry");
         }
         this.namespaceHandlerRegistry = handlers;
         this.registry = registry;
+        this.mainSection = mainSection;
         // Parse components
         for (Document doc : this.documents) {
             loadComponents(doc);
@@ -291,6 +308,7 @@
             }
         }
         */
+
         // Parse elements
         NodeList nl = root.getChildNodes();
         for (int i = 0; i < nl.getLength(); i++) {
@@ -298,14 +316,15 @@
             if (node instanceof Element) {
                 Element element = (Element) node;
                 String namespaceUri = element.getNamespaceURI();
-                if (isBlueprintNamespace(namespaceUri)) {
-                    parseBlueprintElement(element);
-                } else if (isBlueprintCompendiumNamespace(namespaceUri)) {
-                    parseBlueprintCompendiumElement(element);
-                } else {
-                    ComponentMetadata component = parseCustomElement(element, null);
-                    if (component != null) {
-                        registry.registerComponentDefinition(component);
+                boolean parse = mainSection ^ (isBlueprintNamespace(namespaceUri) && nodeNameEquals(element, TYPE_CONVERTERS_ELEMENT));
+                if (parse) {
+                    if (isBlueprintNamespace(namespaceUri)) {
+                        parseBlueprintElement(element);
+                    } else {
+                        ComponentMetadata component = parseCustomElement(element, null);
+                        if (component != null) {
+                            registry.registerComponentDefinition(component);
+                        }
                     }
                 }
             }
@@ -320,6 +339,8 @@
         } else if (nodeNameEquals(element, BEAN_ELEMENT)) {
             ComponentMetadata component = parseBeanMetadata(element);
             registry.registerComponentDefinition(component);
+        } else if (nodeNameEquals(element, REF_ELEMENT)) {
+            // TODO: what about those top-level refs elements
         } else if (nodeNameEquals(element, SERVICE_ELEMENT)) {
             ComponentMetadata service = parseService(element);
             registry.registerComponentDefinition(service);
@@ -337,23 +358,19 @@
         }
     }
 
-    private void parseBlueprintCompendiumElement(Element element) {
-        // TODO: maybe use a namespace handler instead?
-        throw new ComponentDefinitionException("Unknown element " + element.getNodeName() + " in namespace " + BLUEPRINT_COMPENDIUM_NAMESPACE);
-    }
-
     private void parseTypeConverters(Element element) {
         NodeList nl = element.getChildNodes();
         for (int i = 0; i < nl.getLength(); i++) {
             Node node = nl.item(i);
             if (node instanceof Element) {
                 Element e = (Element) node;
-                if (nodeNameEquals(e, BEAN_ELEMENT)) {
-                    ComponentMetadata metadata = parseBeanMetadata(e);
-                    registry.registerTypeConverter((Target) metadata);
-                } else if (nodeNameEquals(e, REF_ELEMENT)) {
-                    String componentName = e.getAttribute(COMPONENT_ATTRIBUTE);
-                    registry.registerTypeConverter(new RefMetadataImpl(componentName));
+                if (isBlueprintNamespace(e.getNamespaceURI())) {
+                    parseBlueprintElement(e);
+                } else {
+                    ComponentMetadata component = parseCustomElement(e, null);
+                    if (component != null) {
+                        registry.registerComponentDefinition(component);
+                    }
                 }
             }
         }
@@ -556,7 +573,7 @@
         return new PropsMetadataImpl(entries);
     }
 
-    private MapMetadata parseMap(Element element, ComponentMetadata enclosingComponent) {
+    public MapMetadata parseMap(Element element, ComponentMetadata enclosingComponent) {
         // Parse attributes
         String keyType = element.hasAttribute(KEY_TYPE_ATTRIBUTE) ? element.getAttribute(KEY_TYPE_ATTRIBUTE) : null;
         String valueType = element.hasAttribute(VALUE_TYPE_ATTRIBUTE) ? element.getAttribute(VALUE_TYPE_ATTRIBUTE) : null;
@@ -986,22 +1003,18 @@
         return handler;
     }
     
-    private String getName(Element element) {
+    public String getName(Element element) {
         if (element.hasAttribute(ID_ATTRIBUTE)) {
             return element.getAttribute(ID_ATTRIBUTE);
         } else {
-            return "component-" + ++nameCounter;
+            return namePrefix + ++nameCounter;
         }
     }
 
-    private static boolean isBlueprintNamespace(String ns) {
+    public static boolean isBlueprintNamespace(String ns) {
         return BLUEPRINT_NAMESPACE.equals(ns);
     }
 
-    private static boolean isBlueprintCompendiumNamespace(String ns) {
-        return BLUEPRINT_COMPENDIUM_NAMESPACE.equals(ns);
-    }
-
     private static boolean nodeNameEquals(Node node, String name) {
         return (name.equals(node.getNodeName()) || name.equals(node.getLocalName()));
     }



Mime
View raw message