[jboss-cvs] JBossAS SVN: r60385 - in projects/microcontainer/trunk/kernel/src: main/org/jboss/kernel/plugins/deployment/xml and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 7 11:34:30 EST 2007


Author: alesj
Date: 2007-02-07 11:34:30 -0500 (Wed, 07 Feb 2007)
New Revision: 60385

Added:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingCharactersHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingWildcardHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyAnnotationsInterceptor.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyBindingInterceptor.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaBinding.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaBindingHelper.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaInitializer.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyScopeInterceptor.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/ScopeHandler.java
Modified:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractBindingMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractPolicyMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java
   projects/microcontainer/trunk/kernel/src/resources/schema/policy_1_0.xsd
Log:
Policy meta data + XB.

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractBindingMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractBindingMetaData.java	2007-02-07 16:30:35 UTC (rev 60384)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractBindingMetaData.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -25,6 +25,7 @@
 import java.util.Collections;
 import java.util.Iterator;
 
+import org.jboss.beans.metadata.plugins.ValueMetaDataAware;
 import org.jboss.beans.metadata.spi.MetaDataVisitor;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.beans.metadata.spi.ValueMetaData;
@@ -37,7 +38,7 @@
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class AbstractBindingMetaData extends JBossObject implements BindingMetaData, Serializable
+public class AbstractBindingMetaData extends JBossObject implements BindingMetaData, ValueMetaDataAware, Serializable
 {
    private static final long serialVersionUID = 1;
 

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractPolicyMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractPolicyMetaData.java	2007-02-07 16:30:35 UTC (rev 60384)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractPolicyMetaData.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -102,7 +102,7 @@
       this.name = name;
    }
 
-   public void setExt(String ext)
+   public void setExtends(String ext)
    {
       this.ext = ext;
    }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java	2007-02-07 16:30:35 UTC (rev 60384)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -35,11 +35,6 @@
  */
 public class BeanSchemaBindingHelper
 {
-   public static void initAll(SchemaBinding schemaBinding)
-   {
-      
-   }
-   
    /**
     * Initialize the handlers for the deployment type
     * 

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingCharactersHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingCharactersHandler.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingCharactersHandler.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.beans.metadata.plugins.policy.AbstractBindingMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+
+/**
+ * BindingCharactersHandler.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BindingCharactersHandler extends StringValueCharactersHandler
+{
+   /** The interceptor */
+   public static final BindingCharactersHandler HANDLER = new BindingCharactersHandler();
+
+   public void setValue(QName qName, ElementBinding element, Object owner, Object value)
+   {
+      AbstractBindingMetaData binding = (AbstractBindingMetaData) owner;
+      StringValueMetaData svmd = (StringValueMetaData) value;
+      setStringValue(binding, svmd);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingHandler.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingHandler.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.policy.AbstractBindingMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * BindingHandler.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BindingHandler extends DefaultElementHandler
+{
+   /** The binding handler */
+   public static final BindingHandler HANDLER = new BindingHandler();
+
+   public Object startElement(Object parent, QName name, ElementBinding element)
+   {
+      return new AbstractBindingMetaData();
+   }
+
+   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+   {
+      AbstractBindingMetaData binding = (AbstractBindingMetaData)o;
+      for (int i = 0; i < attrs.getLength(); ++i)
+      {
+         String localName = attrs.getLocalName(i);
+         if ("name".equals(localName))
+            binding.setName(attrs.getValue(i));
+      }
+   }
+
+   public Object endElement(Object o, QName qName, ElementBinding element)
+   {
+      AbstractBindingMetaData binding = (AbstractBindingMetaData)o;
+      if (binding.getValue() == null)
+         throw new IllegalArgumentException("Binding must have a non-null value:" + binding);
+      return binding;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingWildcardHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingWildcardHandler.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingWildcardHandler.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.plugins.policy.AbstractBindingMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultWildcardHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+
+/**
+ * BindingWildcardHandler.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BindingWildcardHandler extends DefaultWildcardHandler
+{
+   /** The handler */
+   public static final BindingWildcardHandler WILDCARD = new BindingWildcardHandler();
+
+   public void setParent(Object parent, Object o, QName elementName, ElementBinding element, ElementBinding parentElement)
+   {
+      AbstractBindingMetaData binding = (AbstractBindingMetaData) parent;
+      if (o instanceof ValueMetaData)
+         binding.setValue((ValueMetaData)o);
+      else
+         binding.setValue(new AbstractValueMetaData(o));
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyAnnotationsInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyAnnotationsInterceptor.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyAnnotationsInterceptor.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData;
+import org.jboss.beans.metadata.plugins.policy.AbstractPolicyMetaData;
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * PolicyAnnotationsInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PolicyAnnotationsInterceptor extends DefaultElementInterceptor
+{
+   /** The interceptor */
+   public static final PolicyAnnotationsInterceptor INTERCEPTOR = new PolicyAnnotationsInterceptor();
+
+   public void add(Object parent, Object child, QName name)
+   {
+      AbstractPolicyMetaData policy = (AbstractPolicyMetaData) parent;
+      AbstractAnnotationMetaData annotation = (AbstractAnnotationMetaData) child;
+      Set<AnnotationMetaData> annotations = policy.getAnnotations();
+      if (annotations == null)
+      {
+         annotations = new HashSet<AnnotationMetaData>();
+         policy.setAnnotations(annotations);
+      }
+      annotations.add(annotation);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyBindingInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyBindingInterceptor.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyBindingInterceptor.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.policy.AbstractBindingMetaData;
+import org.jboss.beans.metadata.plugins.policy.AbstractPolicyMetaData;
+import org.jboss.beans.metadata.spi.policy.BindingMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * PolicyBindingInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PolicyBindingInterceptor extends DefaultElementInterceptor
+{
+   /** The interceptor */
+   public static final PolicyBindingInterceptor INTERCEPTOR = new PolicyBindingInterceptor();
+
+   public void add(Object parent, Object child, QName name)
+   {
+      AbstractPolicyMetaData policy = (AbstractPolicyMetaData) parent;
+      AbstractBindingMetaData binding = (AbstractBindingMetaData) child;
+      Set<BindingMetaData> bindings = policy.getBindings();
+      if (bindings == null)
+      {
+         bindings = new HashSet<BindingMetaData>();
+         policy.setBindings(bindings);
+      }
+      bindings.add(binding);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyHandler.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyHandler.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.policy.AbstractPolicyMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * PolicyHandler.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PolicyHandler extends DefaultElementHandler
+{
+   /** The policy handler */
+   public static final PolicyHandler HANDLER = new PolicyHandler();
+
+   public Object startElement(Object parent, QName name, ElementBinding element)
+   {
+      return new AbstractPolicyMetaData();
+   }
+
+   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+   {
+      AbstractPolicyMetaData policy = (AbstractPolicyMetaData)o;
+      for (int i = 0; i < attrs.getLength(); ++i)
+      {
+         String localName = attrs.getLocalName(i);
+         if ("name".equals(localName))
+            policy.setName(attrs.getValue(i));
+         else if ("extends".equals(localName))
+            policy.setExtends(attrs.getValue(i));
+      }
+   }
+   
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaBinding.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaBinding.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaBinding.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,83 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+
+/**
+ * The policy schema binding.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PolicySchemaBinding
+{
+   /** The namespace */
+   public static final String POLICY_NS = "urn:jboss:policy:1.0";
+
+   /** The policy binding */
+   public static final QName policyTypeQName = new QName(POLICY_NS, "policyType");
+
+   /** The scope binding */
+   public static final QName scopeTypeQName = new QName(POLICY_NS, "scopeType");
+
+   /** The scope element name */
+   public static final QName scopeQName = new QName(POLICY_NS, "scope");
+
+   /** The annotation binding */
+   public static final QName annotationTypeQName = new QName(POLICY_NS,  "annotationsType");
+
+   /** The annotation element name */
+   public static final QName annotationQName = new QName(POLICY_NS, "annotations");
+
+   /** The binding binding */
+   public static final QName bindingTypeQName = new QName(POLICY_NS, "bindingType");
+
+   /** The binding element name */
+   public static final QName bindingQName = new QName(POLICY_NS, "binding");
+
+   /**
+    * Initialize the schema binding
+    *
+    * @param schemaBinding the schema binding
+    */
+   public static void init(SchemaBinding schemaBinding)
+   {
+      // ignore XB property replacement
+      schemaBinding.setReplacePropertyRefs(false);
+      // init
+      TypeBinding policyType = schemaBinding.getType(policyTypeQName);
+      PolicySchemaBindingHelper.initPolicyHandlers(policyType);
+
+      TypeBinding scopeType = schemaBinding.getType(policyTypeQName);
+      PolicySchemaBindingHelper.initScopeHandlers(scopeType);
+
+      TypeBinding annotationsType = schemaBinding.getType(annotationTypeQName);
+      PolicySchemaBindingHelper.initAnnotationHandlers(annotationsType);
+
+      TypeBinding bindingsType = schemaBinding.getType(bindingTypeQName);
+      PolicySchemaBindingHelper.initBindingHandlers(bindingsType);
+   }
+
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaBindingHelper.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaBindingHelper.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaBindingHelper.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.WildcardBinding;
+
+/**
+ * PolicySchemaBindingHelper.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PolicySchemaBindingHelper
+{
+   public static void initPolicyHandlers(TypeBinding policyType)
+   {
+      policyType.setHandler(PolicyHandler.HANDLER);
+      // interceptors
+      policyType.pushInterceptor(PolicySchemaBinding.scopeQName, PolicyScopeInterceptor.INTERCEPTOR);
+      policyType.pushInterceptor(PolicySchemaBinding.annotationQName, PolicyAnnotationsInterceptor.INTERCEPTOR);
+      policyType.pushInterceptor(PolicySchemaBinding.bindingQName, PolicyBindingInterceptor.INTERCEPTOR);
+   }
+
+   public static void initScopeHandlers(TypeBinding scopeType)
+   {
+      scopeType.setHandler(ScopeHandler.HANDLER);
+   }
+
+   public static void initAnnotationHandlers(TypeBinding annotationType)
+   {
+      annotationType.setHandler(AnnotationHandler.HANDLER);
+   }
+
+   public static void initBindingHandlers(TypeBinding bindingType)
+   {
+      bindingType.setHandler(BindingHandler.HANDLER);
+      // binding can take characters
+      bindingType.setSimpleType(BindingCharactersHandler.HANDLER);
+      // type has wildcard
+      WildcardBinding wcb = bindingType.getWildcard();
+      if (wcb == null)
+         throw new IllegalStateException("Missing wildcard binding for type: " + bindingType.getQName());
+      wcb.setWildcardHandler(BindingWildcardHandler.WILDCARD);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaInitializer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaInitializer.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicySchemaInitializer.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingInitializer;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PolicySchemaInitializer implements SchemaBindingInitializer
+{
+   public SchemaBinding init(SchemaBinding schema)
+   {
+      PolicySchemaBinding.init(schema);
+      return schema;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyScopeInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyScopeInterceptor.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/PolicyScopeInterceptor.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.policy.AbstractPolicyMetaData;
+import org.jboss.beans.metadata.plugins.policy.AbstractScopeMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * PolicyScopeInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PolicyScopeInterceptor extends DefaultElementInterceptor
+{
+   /** The interceptor */
+   public static final PolicyScopeInterceptor INTERCEPTOR = new PolicyScopeInterceptor();
+
+   public void add(Object parent, Object child, QName name)
+   {
+      AbstractPolicyMetaData policy = (AbstractPolicyMetaData) parent;
+      AbstractScopeMetaData scope = (AbstractScopeMetaData) child;
+      policy.setScope(scope);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/ScopeHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/ScopeHandler.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/ScopeHandler.java	2007-02-07 16:34:30 UTC (rev 60385)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.policy.AbstractScopeMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * ScopeHandler.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ScopeHandler extends DefaultElementHandler
+{
+   /** The scope handler */
+   public static final ScopeHandler HANDLER = new ScopeHandler();
+
+   public Object startElement(Object parent, QName name, ElementBinding element)
+   {
+      return new AbstractScopeMetaData();
+   }
+
+   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+   {
+      AbstractScopeMetaData scope = (AbstractScopeMetaData)o;
+      for (int i = 0; i < attrs.getLength(); ++i)
+      {
+         String localName = attrs.getLocalName(i);
+         if ("level".equals(localName))
+            scope.setLevel(attrs.getValue(i));
+         else if ("qualifier".equals(localName))
+            scope.setQualifier(attrs.getValue(i));
+      }
+   }
+
+}

Modified: projects/microcontainer/trunk/kernel/src/resources/schema/policy_1_0.xsd
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/schema/policy_1_0.xsd	2007-02-07 16:30:35 UTC (rev 60384)
+++ projects/microcontainer/trunk/kernel/src/resources/schema/policy_1_0.xsd	2007-02-07 16:34:30 UTC (rev 60385)
@@ -41,9 +41,9 @@
          </xsd:documentation>
       </xsd:annotation>
       <xsd:sequence>
-         <xsd:element name="scope" type="scopeType" minOccurs="0"/>
-         <xsd:element name="annotations" type="annotationsType" minOccurs="0"/>
-         <xsd:element name="bindings" type="bindingsType" minOccurs="0"/>
+         <xsd:element name="scope" type="scopeType" minOccurs="0" maxOccurs="1"/>
+         <xsd:element name="annotation" type="mc:annotationType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="binding" type="bindingType" minOccurs="0" maxOccurs="unbounded"/>
       </xsd:sequence>
       <xsd:attribute name="name" type="xsd:string" use="optional"/>
       <xsd:attribute name="extends" type="xsd:string" use="optional"/>
@@ -66,24 +66,11 @@
       <xsd:attribute name="qualifier" type="xsd:string" use="optional"/>
    </xsd:complexType>
 
-   <xsd:complexType name="annotationsType">
+   <xsd:complexType name="bindingType" mixed="true">
       <xsd:annotation>
          <xsd:documentation>
-           <![CDATA[
-            The annotations.
-           ]]>
-         </xsd:documentation>
-      </xsd:annotation>
-      <xsd:sequence>
-         <xsd:element name="annotation" type="mc:annotationType" minOccurs="0"/>
-      </xsd:sequence>
-   </xsd:complexType>
-
-   <xsd:complexType name="bindingsType" mixed="true">
-      <xsd:annotation>
-         <xsd:documentation>
             <![CDATA[
-             The bindings.
+             The binding.
             ]]>
          </xsd:documentation>
       </xsd:annotation>




More information about the jboss-cvs-commits mailing list