[jboss-cvs] JBossAS SVN: r60491 - in projects/microcontainer/trunk: container/src/main/org/jboss/metadata/spi/scope and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 12 10:20:09 EST 2007


Author: alesj
Date: 2007-02-12 10:20:09 -0500 (Mon, 12 Feb 2007)
New Revision: 60491

Added:
   projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/DeploymentScope.java
   projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/DeploymentScopeFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKeyFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKeyFactoryLookup.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/MetaDataRepositoryInstaller.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentAnnotationInterceptor.java
Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/InstanceScopeFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeFactory.java
   projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeFactoryLookup.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAnnotationMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/factory/GenericBeanFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractScopeMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/policy/ScopeMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java
   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/DeploymentHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/ScopeHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/deployment/KernelDeployment.java
   projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_1_0.xsd
   projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_2_0.xsd
Log:
Added annotations on KernelDeployment, changed ScopeMetaData (still todo), added some additional Scope annotations.

Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/DeploymentScope.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/DeploymentScope.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/DeploymentScope.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -0,0 +1,35 @@
+/*
+* 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.metadata.plugins.scope;
+
+import org.jboss.metadata.spi.scope.ScopeFactoryLookup;
+
+/**
+ * Deployment scope annotation.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at ScopeFactoryLookup(DeploymentScopeFactory.class)
+public @interface DeploymentScope
+{
+   String value() default "";
+}

Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/DeploymentScopeFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/DeploymentScopeFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/DeploymentScopeFactory.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -0,0 +1,40 @@
+/*
+* 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.metadata.plugins.scope;
+
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.Scope;
+import org.jboss.metadata.spi.scope.ScopeFactory;
+
+/**
+ * Factory for creating Deployment scope key
+ * from DeploymentScope annotation.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DeploymentScopeFactory implements ScopeFactory<DeploymentScope>
+{
+   public Scope create(DeploymentScope annotation)
+   {
+      return new Scope(CommonLevels.DEPLOYMENT, annotation.value());
+   }
+}

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/InstanceScopeFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/InstanceScopeFactory.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/plugins/scope/InstanceScopeFactory.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -22,8 +22,8 @@
 package org.jboss.metadata.plugins.scope;
 
 import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.Scope;
 import org.jboss.metadata.spi.scope.ScopeFactory;
-import org.jboss.metadata.spi.scope.ScopeKey;
 
 /**
  * Factory for creating Instance scope key
@@ -33,8 +33,8 @@
  */
 public class InstanceScopeFactory implements ScopeFactory<InstanceScope>
 {
-   public ScopeKey create(InstanceScope annotation)
+   public Scope create(InstanceScope annotation)
    {
-      return new ScopeKey(CommonLevels.INSTANCE, annotation.value());
+      return new Scope(CommonLevels.INSTANCE, annotation.value());
    }
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeFactory.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeFactory.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -24,7 +24,7 @@
 import java.lang.annotation.Annotation;
 
 /**
- * Factory to create ScopeKey from annotation.
+ * Factory to create Scope from annotation.
  *
  * @param <T> the scope annotation
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
@@ -37,5 +37,5 @@
     * @param annotation scope annotation
     * @return scope key from scope annotation
     */
-   ScopeKey create(T annotation);
+   Scope create(T annotation);
 }

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeFactoryLookup.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeFactoryLookup.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeFactoryLookup.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -21,12 +21,19 @@
 */
 package org.jboss.metadata.spi.scope;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
 /**
- * Defining the factory class to create actual ScopeKey
+ * Defining the factory class to create actual Scope
  * from annotated scope annotation.
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.ANNOTATION_TYPE})
 public @interface ScopeFactoryLookup
 {
    Class<? extends ScopeFactory> value();

Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKeyFactory.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKeyFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKeyFactory.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -0,0 +1,41 @@
+/*
+* 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.metadata.spi.scope;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Factory to create ScopeKey from annotation.
+ *
+ * @param <T> the scope key annotation
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface ScopeKeyFactory<T extends Annotation>
+{
+   /**
+    * Create ScopeKey from scope annotation instance
+    *
+    * @param annotation scope annotation
+    * @return scope key from scope annotation
+    */
+   ScopeKey create(T annotation);
+}

Added: projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKeyFactoryLookup.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKeyFactoryLookup.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/metadata/spi/scope/ScopeKeyFactoryLookup.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -0,0 +1,40 @@
+/*
+* 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.metadata.spi.scope;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Defining the factory class to create actual ScopeKey
+ * from annotated scope key annotation.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.ANNOTATION_TYPE})
+public @interface ScopeKeyFactoryLookup
+{
+   Class<? extends ScopeKeyFactory> value();
+}

Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -63,6 +63,9 @@
    /** The contexts that are currently being installed */
    protected Set<ControllerContext> installing = CollectionsFactory.createCopyOnWriteSet();
 
+   /** The child controllers */
+   protected Set<Controller> childControllers;
+
    /** Whether an on demand context has been enabled */
    protected boolean onDemandEnabled = true;
 
@@ -243,6 +246,8 @@
       lockWrite();
       try
       {
+         // TODO - add scoping here
+
          Object name = context.getName();
 
          if (allContexts.get(name) != null)

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAnnotationMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAnnotationMetaData.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractAnnotationMetaData.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -128,4 +128,24 @@
    {
       buffer.append(ann);
    }
+
+/*
+   protected int getHashCode()
+   {
+      return annotation.hashCode();
+   }
+
+   public boolean equals(Object object)
+   {
+      if (object == null || object instanceof AbstractAnnotationMetaData == false)
+         return false;
+
+      AbstractAnnotationMetaData amd = (AbstractAnnotationMetaData)object;
+      if (replace != amd.replace)
+         return false;
+
+      return annotation.equals(amd.annotation);
+   }
+*/
+
 }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/factory/GenericBeanFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/factory/GenericBeanFactory.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/factory/GenericBeanFactory.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -39,7 +39,7 @@
 import org.jboss.kernel.spi.config.KernelConfigurator;
 
 /**
- * Collection metadata.
+ * Bean factory metadata.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractScopeMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractScopeMetaData.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractScopeMetaData.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -22,8 +22,18 @@
 package org.jboss.beans.metadata.plugins.policy;
 
 import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.Iterator;
 
+import org.jboss.annotation.factory.AnnotationCreator;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.beans.metadata.spi.policy.ScopeMetaData;
+import org.jboss.metadata.spi.scope.ScopeFactory;
+import org.jboss.metadata.spi.scope.ScopeFactoryLookup;
+import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.scope.ScopeLevel;
+import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.util.JBossObject;
 import org.jboss.util.JBossStringBuilder;
 
@@ -36,9 +46,64 @@
 {
    private static final long serialVersionUID = 1;
 
+   private String scope;
    private String level;
    private String qualifier;
 
+   public Object getUnderlyingValue()
+   {
+      return scope;
+   }
+
+   public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
+   {
+      if (scope != null)
+      {
+         Annotation annotation = (Annotation)AnnotationCreator.createAnnotation(scope, cl);
+         ScopeFactoryLookup scopeFactoryLookup = annotation.getClass().getAnnotation(ScopeFactoryLookup.class);
+         if (scopeFactoryLookup != null)
+         {
+            ScopeFactory scopeFactory = scopeFactoryLookup.value().newInstance();
+            return scopeFactory.create(annotation);
+         }
+         else
+         {
+            // todo - annotation.value();
+            return createScopeKey(annotation.getClass().getSimpleName(), annotation.toString());
+         }
+      }
+      else
+      {
+         return createScopeKey(level, qualifier);
+      }
+   }
+
+   private ScopeKey createScopeKey(String name, String qualifier)
+   {
+      int level = ScopeLevel.getScopeLevel(name);
+      return new ScopeKey(new ScopeLevel(level, name), qualifier);
+   }
+
+   public void initialVisit(MetaDataVisitor vistor)
+   {
+      vistor.initialVisit(this);
+   }
+
+   public void describeVisit(MetaDataVisitor vistor)
+   {
+      vistor.describeVisit(this);
+   }
+
+   public Iterator<? extends MetaDataVisitorNode> getChildren()
+   {
+      return null;
+   }
+
+   public String getScope()
+   {
+      return scope;
+   }
+
    public String getLevel()
    {
       return level;
@@ -49,6 +114,11 @@
       return qualifier;
    }
 
+   public void setScope(String scope)
+   {
+      this.scope = scope;
+   }
+
    public void setLevel(String level)
    {
       this.level = level;
@@ -61,12 +131,15 @@
 
    public void toString(JBossStringBuilder buffer)
    {
-      buffer.append("level=").append(level);
+      buffer.append("scope=").append(scope);
+      buffer.append(" level=").append(level);
       buffer.append(" qualifier=").append(qualifier);
    }
 
    public void toShortString(JBossStringBuilder buffer)
    {
+      buffer.append(scope);
+      buffer.append('/');
       buffer.append(level);
       buffer.append('/');
       buffer.append(qualifier);

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/MetaDataRepositoryInstaller.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/MetaDataRepositoryInstaller.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/MetaDataRepositoryInstaller.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -0,0 +1,99 @@
+   /*
+* 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.beans.metadata.plugins.policy;
+
+   import java.util.Map;
+   import java.util.Set;
+
+   import org.jboss.kernel.Kernel;
+   import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
+   import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+   import org.jboss.metadata.spi.MutableMetaData;
+   import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
+   import org.jboss.metadata.spi.retrieval.MetaDataItem;
+   import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+   import org.jboss.metadata.spi.scope.Scope;
+   import org.jboss.metadata.spi.scope.ScopeKey;
+
+   /**
+ * POJO binding bean meta data to scoped repository.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MetaDataRepositoryInstaller
+{
+   private Kernel underlyingKernel;
+   private Set<Scope> scopes;
+   private Map<String, Object> bindings;
+
+   public void setKernel(Kernel kernel)
+   {
+      this.underlyingKernel = kernel;
+   }
+
+   public void setScopes(Set<Scope> scopes)
+   {
+      this.scopes = scopes;
+   }
+
+   public void setBindings(Map<String, Object> bindings)
+   {
+      this.bindings = bindings;
+   }
+
+   public void start()
+   {
+      KernelMetaDataRepository kmdr = underlyingKernel.getMetaDataRepository();
+      MutableMetaDataRepository mmdr = kmdr.getMetaDataRepository();
+      ScopeKey scopeKey = new ScopeKey(scopes);
+      MetaDataRetrieval retrieval = mmdr.getMetaDataRetrieval(scopeKey);
+      // Not found create it
+      if (retrieval == null)
+      {
+         retrieval = new MemoryMetaDataLoader(scopeKey);
+         mmdr.addMetaDataRetrieval(retrieval);
+      }
+      MutableMetaData mmd = (MutableMetaData)retrieval;
+      // deploy against this kernel
+      Kernel kernel = underlyingKernel;
+      // Get the parent scope - if exists
+      ScopeKey parent = scopeKey.getParent();
+      if (parent != null)
+      {
+         MetaDataRetrieval pretrieval = mmdr.getMetaDataRetrieval(parent);
+         MetaDataItem<Kernel> item = pretrieval.retrieveMetaData(Kernel.class);
+         if (item != null)
+            kernel = item.getValue();
+      }
+      // Create a scoped kernel Kernel
+      Kernel scopedKernel = null;//new ScopedKernel(kernel);
+
+      mmd.addMetaData(scopedKernel, Kernel.class);
+
+   }
+
+   public void stop()
+   {
+
+   }
+
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/policy/ScopeMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/policy/ScopeMetaData.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/policy/ScopeMetaData.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -21,14 +21,23 @@
 */
 package org.jboss.beans.metadata.spi.policy;
 
+import org.jboss.beans.metadata.spi.ValueMetaData;
+
 /**
  * Scope definition.
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public interface ScopeMetaData
+public interface ScopeMetaData extends ValueMetaData
 {
    /**
+    * Get the scope annotation name
+    *
+    * @return scope annotation
+    */
+   String getScope();
+
+   /**
     * Get the level
     *
     * @return scope level

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployment.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -21,12 +21,15 @@
 */
 package org.jboss.kernel.plugins.deployment;
 
+import java.io.IOException;
 import java.io.Serializable;
-import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
 import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
@@ -55,6 +58,12 @@
    /** The installed contexts */
    protected transient List<KernelControllerContext> installedContexts = new CopyOnWriteArrayList<KernelControllerContext>();
 
+   /** Is deployment scoped */
+   protected Boolean scoped;
+
+   /** The annotations */
+   protected Set<AnnotationMetaData> annotations;
+
    /** The beans List<BeanMetaDataFactory> */
    protected List<BeanMetaDataFactory> beanFactories;
 
@@ -136,15 +145,47 @@
       if (beanFactories == null || beanFactories.size() == 0)
          return null;
       List<BeanMetaData> result = new ArrayList<BeanMetaData>(beanFactories.size());
-      for (int i = 0; i < beanFactories.size(); ++i)
+      for (BeanMetaDataFactory factory : beanFactories)
       {
-         BeanMetaDataFactory factory = beanFactories.get(i);
          List<BeanMetaData> beans = factory.getBeans();
+         // add all deployment annotations to bean's annotations
+         if (annotations != null && annotations.isEmpty() == false)
+         {
+            for (BeanMetaData bmd : beans)
+            {
+               Set<AnnotationMetaData> annotationsBMD = bmd.getAnnotations();
+               if (annotationsBMD == null)
+               {
+                  annotationsBMD = new HashSet<AnnotationMetaData>();
+               }
+               annotationsBMD.addAll(annotations);
+            }
+         }
          result.addAll(beans);
       }
       return result;
    }
 
+   public Boolean isScoped()
+   {
+      return scoped;
+   }
+
+   public void setScoped(Boolean scoped)
+   {
+      this.scoped = scoped;
+   }
+
+   public Set<AnnotationMetaData> getAnnotations()
+   {
+      return annotations;
+   }
+
+   public void setAnnotations(Set<AnnotationMetaData> annotations)
+   {
+      this.annotations = annotations;
+   }
+
    public List<BeanMetaDataFactory> getBeanFactories()
    {
       return beanFactories;

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-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -44,6 +44,9 @@
    {
       deploymentType.setHandler(DeploymentHandler.HANDLER);
 
+      // deployment has annotations
+      deploymentType.pushInterceptor(BeanSchemaBinding20.annotationQName, DeploymentAnnotationInterceptor.INTERCEPTOR);
+
       // deployment has a classloader
       deploymentType.pushInterceptor(BeanSchemaBinding20.classloaderQName, DeploymentClassLoaderInterceptor.INTERCEPTOR);
 

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentAnnotationInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentAnnotationInterceptor.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentAnnotationInterceptor.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -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.spi.AnnotationMetaData;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * DeploymentAnnotationInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DeploymentAnnotationInterceptor extends DefaultElementInterceptor
+{
+   /** The interceptor */
+   public static final DeploymentAnnotationInterceptor INTERCEPTOR = new DeploymentAnnotationInterceptor();
+
+   public void add(Object parent, Object child, QName name)
+   {
+      AbstractKernelDeployment deployment = (AbstractKernelDeployment) parent;
+      AbstractAnnotationMetaData annotation = (AbstractAnnotationMetaData) child;
+      Set<AnnotationMetaData> annotations = deployment.getAnnotations();
+      if (annotations == null)
+      {
+         annotations = new HashSet<AnnotationMetaData>();
+         deployment.setAnnotations(annotations);
+      }
+      annotations.add(annotation);
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentHandler.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DeploymentHandler.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -21,11 +21,13 @@
 */
 package org.jboss.kernel.plugins.deployment.xml;
 
+import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 
 import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
 import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
 import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
 
 /**
  * DeploymentHandler.
@@ -42,4 +44,18 @@
    {
       return new AbstractKernelDeployment();
    }
+
+   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+   {
+      AbstractKernelDeployment deployment = (AbstractKernelDeployment)o;
+      for (int i = 0; i < attrs.getLength(); ++i)
+      {
+         String localName = attrs.getLocalName(i);
+         if ("name".equals(localName))
+            deployment.setName(attrs.getValue(i));
+         else if ("scoped".equals(localName))                       
+            deployment.setScoped(Boolean.parseBoolean(attrs.getValue(i)));
+      }
+   }
+
 }

Modified: 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	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/ScopeHandler.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -36,7 +36,9 @@
  */
 public class ScopeHandler extends DefaultElementHandler
 {
-   /** The scope handler */
+   /**
+    * The scope handler
+    */
    public static final ScopeHandler HANDLER = new ScopeHandler();
 
    public Object startElement(Object parent, QName name, ElementBinding element)
@@ -57,4 +59,18 @@
       }
    }
 
+   public Object endElement(Object o, QName qName, ElementBinding element)
+   {
+      AbstractScopeMetaData scopeMetaData = (AbstractScopeMetaData)o;
+      String scope = scopeMetaData.getScope();
+      if (scope != null && scope.length() > 0)
+      {
+         if (scope.startsWith("@") == false)
+         {
+            throw new IllegalArgumentException("<scope/> content must be a fully qualified annotation type name prefixed with '@'");
+         }
+      }
+      return scopeMetaData;
+   }
+
 }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/deployment/KernelDeployment.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/deployment/KernelDeployment.java	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/deployment/KernelDeployment.java	2007-02-12 15:20:09 UTC (rev 60491)
@@ -22,7 +22,9 @@
 package org.jboss.kernel.spi.deployment;
 
 import java.util.List;
+import java.util.Set;
 
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
 import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
@@ -64,8 +66,22 @@
     * @param installed true when installed
     */
    void setInstalled(boolean installed);
-   
+
    /**
+    * Is deployment scoped
+    *
+    * @return true if scoped, false if isolated, null by default
+    */
+   Boolean isScoped();
+
+   /**
+    * Get the deployment annotations.
+    *
+    * @return the annotations
+    */
+   Set<AnnotationMetaData> getAnnotations();
+
+   /**
     * Get the classloader for this deployment
     *
     * @return the classloader 

Modified: projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_1_0.xsd
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_1_0.xsd	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_1_0.xsd	2007-02-12 15:20:09 UTC (rev 60491)
@@ -51,6 +51,7 @@
          </xsd:documentation>
       </xsd:annotation>
       <xsd:choice minOccurs="0" maxOccurs="unbounded">
+         <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
          <xsd:element name="classloader" type="classloaderType" minOccurs="0"/>
          <xsd:element name="bean" type="beanType" minOccurs="0" maxOccurs="unbounded"/>
          <xsd:element name="beanfactory" type="beanfactoryType" minOccurs="0" maxOccurs="unbounded"/>

Modified: projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_2_0.xsd
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_2_0.xsd	2007-02-12 14:07:31 UTC (rev 60490)
+++ projects/microcontainer/trunk/kernel/src/resources/schema/bean-deployer_2_0.xsd	2007-02-12 15:20:09 UTC (rev 60491)
@@ -48,6 +48,7 @@
          </xsd:documentation>
       </xsd:annotation>
       <xsd:choice minOccurs="0" maxOccurs="unbounded">
+         <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
          <xsd:element name="classloader" type="classloaderType" minOccurs="0"/>
          <xsd:element name="bean" type="beanType" minOccurs="0" maxOccurs="unbounded"/>
          <xsd:element name="beanfactory" type="beanfactoryType" minOccurs="0" maxOccurs="unbounded"/>
@@ -58,6 +59,7 @@
          </xsd:any>
       </xsd:choice>
       <xsd:attribute name="name" type="xsd:string" use="optional"/>
+      <xsd:attribute name="scoped" type="xsd:boolean" use="optional"/>
    </xsd:complexType>
 
    <xsd:complexType name="beanType">




More information about the jboss-cvs-commits mailing list