geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r781042 - in /geronimo/sandbox/blueprint/blueprint-core/src/main: java/org/apache/geronimo/blueprint/ java/org/apache/geronimo/blueprint/ext/ resources/org/apache/geronimo/blueprint/ext/
Date Tue, 02 Jun 2009 14:23:26 GMT
Author: gnodet
Date: Tue Jun  2 14:23:26 2009
New Revision: 781042

URL: http://svn.apache.org/viewvc?rev=781042&view=rev
Log:
Add an attribute to identify beans as processors

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BeanProcessor.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/ext/ExtNamespaceHandler.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/ext/blueprint-ext.xsd

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BeanProcessor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BeanProcessor.java?rev=781042&r1=781041&r2=781042&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BeanProcessor.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/BeanProcessor.java
Tue Jun  2 14:23:26 2009
@@ -21,14 +21,11 @@
 /**
  * TODO: javadoc
  *
- * TODO: processors have to be advertized as being processors. currently
- * TODO: it can only be done by using a custom namespace and setting the
- * TODO: ExtendedBeanMetadata#isProcessor() flag
- * TODO: we need a namespace extension to add an attribute to the <bp:bean/>
- * TODO: element such as <bp:bean gbp:processor="true" ...
- * TODO: but we'll see later with the spec when it evolves to better support
- * TODO: namespaces
- *
+ * Processors must be advertized as being such.  This can be done by using
+ * the custom attribtue defined in the extension schema.
+ * <pre>
+ *    &lt;bp:bean ext:role="processor" ...&gt;
+ * </pre>
  *
  * @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) $

Modified: 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=781042&r1=781041&r2=781042&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ComponentDefinitionRegistryProcessor.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ComponentDefinitionRegistryProcessor.java
Tue Jun  2 14:23:26 2009
@@ -21,6 +21,12 @@
 /**
  * TODO
  *
+ * Processors must be advertized as being such.  This can be done by using
+ * the custom attribtue defined in the extension schema.
+ * <pre>
+ *    &lt;bp:bean ext:role="processor" ...&gt;
+ * </pre>
+ *
  * @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) $
  */

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/ExtNamespaceHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/ExtNamespaceHandler.java?rev=781042&r1=781041&r2=781042&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/ExtNamespaceHandler.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/ExtNamespaceHandler.java
Tue Jun  2 14:23:26 2009
@@ -87,6 +87,9 @@
     public static final String PROXY_METHOD_CLASSES = "classes";
     public static final String PROXY_METHOD_GREEDY = "greedy";
 
+    public static final String ROLE_ATTRIBUTE = "role";
+    public static final String ROLE_PROCESSOR = "processor";
+
     private static final Logger LOGGER = LoggerFactory.getLogger(ExtNamespaceHandler.class);
 
     private int idCounter;
@@ -107,11 +110,34 @@
     public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext
context) {
         if (node instanceof Attr && nodeNameEquals(node, PROXY_METHOD_ATTRIBUTE))
{
             return decorateProxyMethod(node, component, context);
+        } else if (node instanceof Attr && nodeNameEquals(node, ROLE_ATTRIBUTE))
{
+            return decorateRole(node, component, context);
         } else {
             throw new ComponentDefinitionException("Unsupported node: " + node.getNodeName());
         }
     }
 
+    private ComponentMetadata decorateRole(Node node, ComponentMetadata component, ParserContext
context) {
+        if (!(component instanceof BeanMetadata)) {
+            throw new ComponentDefinitionException("Attribute " + node.getNodeName() + "
can only be used on a <bean> element");
+        }
+        if (!(component instanceof MutableBeanMetadata)) {
+            throw new ComponentDefinitionException("Expected an instance of MutableBeanMetadata");
+        }
+        boolean processor = false;
+        String value = ((Attr) node).getValue();
+        String[] flags = value.trim().split(" ");
+        for (String flag : flags) {
+            if (ROLE_PROCESSOR.equals(flag)) {
+                processor = true;
+            } else {
+                throw new ComponentDefinitionException("Unknown proxy method: " + flag);
+            }
+        }
+        ((MutableBeanMetadata) component).setProcessor(processor);
+        return component;
+    }
+
     private ComponentMetadata decorateProxyMethod(Node node, ComponentMetadata component,
ParserContext context) {
         if (!(component instanceof ServiceReferenceMetadata)) {
             throw new ComponentDefinitionException("Attribute " + node.getNodeName() + "
can only be used on a <reference>, <ref-list> or <ref-set> element");

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/ext/blueprint-ext.xsd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/ext/blueprint-ext.xsd?rev=781042&r1=781041&r2=781042&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/ext/blueprint-ext.xsd
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/ext/blueprint-ext.xsd
Tue Jun  2 14:23:26 2009
@@ -83,4 +83,20 @@
         </xsd:simpleType>
     </xsd:attribute>
 
+    <xsd:attribute name="role">
+        <xsd:simpleType>
+            <xsd:restriction>
+                <xsd:simpleType>
+                    <xsd:list>
+                        <xsd:simpleType>
+                            <xsd:restriction base="xsd:NMTOKEN">
+                                <xsd:enumeration value="processor"/>
+                            </xsd:restriction>
+                        </xsd:simpleType>
+                    </xsd:list>
+                </xsd:simpleType>
+            </xsd:restriction>
+        </xsd:simpleType>
+    </xsd:attribute>
+
 </xsd:schema>



Mime
View raw message