[webbeans-commits] Webbeans SVN: r2950 - ri/trunk/impl/src/main/java/org/jboss/webbeans and 14 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Jul 1 17:07:15 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-07-01 17:07:14 -0400 (Wed, 01 Jul 2009)
New Revision: 2950

Added:
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Chicken.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Cow.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Pig.java
Removed:
   ri/trunk/api/src/main/java/javax/inject/Obtains.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/ObtainsLiteral.java
Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/FacadeBeanResolvableTransformer.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ServletConversationManager.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/Field.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/current/Field.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletLifecycleTest.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListInstance.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListStringInstance.java
   ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/lookup/LookupInstanceTest.java
   ri/trunk/tests/unit-tests.xml
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/registerUsingEvent/FinchKeeper.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/registerUsingEvent/OrangeCheekedWaxbill.java
Log:
Fix most tests, remove @Obtains, fix transformer

Deleted: ri/trunk/api/src/main/java/javax/inject/Obtains.java
===================================================================
--- ri/trunk/api/src/main/java/javax/inject/Obtains.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/api/src/main/java/javax/inject/Obtains.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -1,44 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed 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 javax.inject;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.enterprise.inject.BindingType;
-
-/**
- * Annotates a variable to be injected with an Instance object.
- * 
- * @author Gavin King
- */
-
- at BindingType
- at Retention(RUNTIME)
- at Target( { TYPE, METHOD, FIELD, PARAMETER })
- at Documented
- at Deprecated
-public @interface Obtains
-{
-}

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -24,6 +24,7 @@
 import java.lang.reflect.WildcardType;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
@@ -94,6 +95,7 @@
 import org.jboss.webbeans.util.Observers;
 import org.jboss.webbeans.util.Proxies;
 import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.collections.Iterators;
 import org.jboss.webbeans.util.collections.multi.ConcurrentListHashMultiMap;
 import org.jboss.webbeans.util.collections.multi.ConcurrentListMultiMap;
 
@@ -176,30 +178,46 @@
     * ***********************************
     */
    
+   // Contexts are shared across the application
    private transient final ConcurrentListMultiMap<Class<? extends Annotation>, Context> contexts;
+   
+   // Client proxies can be used application wide
    private transient final ClientProxyProvider clientProxyProvider;
+   
+   // We want to generate unique id's across the whole deployment
    private transient final AtomicInteger ids;
+   
+   // TODO review this structure
    private transient final Map<String, RIBean<?>> riBeans;
+   
+   // TODO review this structure
    private transient final Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeans;
    
-   /*
-    * Archive scoped services
-    * *********************** 
-    */
+   // TODO This isn't right, specialization should follow accessibility rules, but I think we can enforce these in resolve()
+   private transient final Map<Contextual<?>, Contextual<?>> specializedBeans;
    
    /*
     * Archive scoped data structures
     * ******************************
     */
+   
+   /* These data structures are all non-transitive in terms of bean deployment 
+    * archive accessibility, and the configuration for this bean deployment
+    * archive
+    */
    private transient List<Class<? extends Annotation>> enabledDeploymentTypes;
    private transient List<Class<?>> enabledDecoratorClasses;
    private transient List<Class<?>> enabledInterceptorClasses;
-   private transient final Set<CurrentActivity> currentActivities;
-   private transient final Map<Contextual<?>, Contextual<?>> specializedBeans;
+   private transient final Set<CurrentActivity> currentActivities;   
 
    /*
     * Activity scoped services 
     * *************************
+    */ 
+   
+   /* These services are scoped to this activity only, but use data 
+    * structures that are transitive accessible from other bean deployment 
+    * archives
     */
    private transient final TypeSafeResolver<Bean<?>> beanResolver;
    private transient final TypeSafeResolver<DecoratorBean<?>> decoratorResolver;
@@ -212,11 +230,30 @@
     * Activity scoped data structures 
     * ********************************
     */
+    
+   /* These data structures are scoped to this bean deployment archive activity
+    * only and represent the beans, decorators, interceptors, namespaces and 
+    * observers deployed in this bean deployment archive activity
+    */
    private transient final List<Bean<?>> beans;
    private transient final List<DecoratorBean<?>> decorators;
    private transient final List<String> namespaces;
    private transient final List<EventObserver<?>> observers;
    
+   /*
+    * These data structures represent the beans, decorators, interceptors, 
+    * namespaces and observers *accessible* from this bean deployment archive
+    * activity
+    */
+   private transient final Set<Iterable<Iterable<Bean<?>>>> accessibleBeans;
+   private transient final Set<Iterable<Iterable<DecoratorBean<?>>>> accessibleDecorators;
+   private transient final Set<Iterable<Iterable<String>>> accessibleNamespaces;
+   private transient final Set<Iterable<Iterable<EventObserver<?>>>> accessibleObservers;
+   
+   /*
+    * This data structures represents child activities for this activity, it is
+    * not transitively accessible
+    */
    private transient final Set<BeanManagerImpl> childActivities;
    
    private final Integer id;
@@ -299,7 +336,7 @@
          ServiceRegistry serviceRegistry, 
          List<Bean<?>> beans, 
          List<DecoratorBean<?>> decorators, 
-         List<EventObserver<?>> registeredObservers, 
+         List<EventObserver<?>> observers, 
          List<String> namespaces,
          Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeans, 
          Map<String, RIBean<?>> riBeans, 
@@ -321,17 +358,30 @@
       this.contexts = contexts;
       this.currentActivities = currentActivities;
       this.specializedBeans = specializedBeans;
-      this.observers = registeredObservers;
+      this.observers = observers;
       setEnabledDeploymentTypes(enabledDeploymentTypes);
       setEnabledDecoratorClasses(enabledDecoratorClasses);
       this.namespaces = namespaces;
       this.ids = ids;
       this.id = ids.incrementAndGet();
+      
+      // Set up the structures to store accessible beans etc.
+      
+      this.accessibleBeans = new HashSet<Iterable<Iterable<Bean<?>>>>();
+      this.accessibleDecorators = new HashSet<Iterable<Iterable<DecoratorBean<?>>>>();
+      this.accessibleNamespaces = new HashSet<Iterable<Iterable<String>>>();
+      this.accessibleObservers = new HashSet<Iterable<Iterable<EventObserver<?>>>>();
+      
+      // Add this bean deployment archvies beans etc. to the accessible
+      add(accessibleBeans, beans);
+      add(accessibleDecorators, decorators);
+      add(accessibleNamespaces, namespaces);
+      add(accessibleObservers, observers);
 
-      this.beanResolver = new TypeSafeBeanResolver<Bean<?>>(this, beans);
-      this.decoratorResolver = new TypeSafeDecoratorResolver(this, decorators);
-      this.observerResolver = new TypeSafeObserverResolver(this, registeredObservers);
-      this.nameBasedResolver = new NameBasedResolver(this, beans);
+      this.beanResolver = new TypeSafeBeanResolver<Bean<?>>(this, Iterators.concat(getAccessibleBeans()));
+      this.decoratorResolver = new TypeSafeDecoratorResolver(this, Iterators.concat(getAccessibleDecorators()));
+      this.observerResolver = new TypeSafeObserverResolver(this, Iterators.concat(getAccessibleObservers()));
+      this.nameBasedResolver = new NameBasedResolver(this, Iterators.concat(getAccessibleBeans()));
       this.webbeansELResolver = new WebBeansELResolverImpl(this);
       this.childActivities = new CopyOnWriteArraySet<BeanManagerImpl>();
       
@@ -344,6 +394,41 @@
          }
       };
    }
+   
+   private static <X> void add(Collection<Iterable<Iterable<X>>> collection, Iterable<X> instance)
+   {
+      Collection<Iterable<X>> c = new ArrayList<Iterable<X>>();
+      c.add(instance);
+      collection.add(c);
+   }
+   
+   public void addAccessibleBeanManager(BeanManagerImpl accessibleBeanManager)
+   {
+      accessibleBeans.add(accessibleBeanManager.getAccessibleBeans());
+      accessibleDecorators.add(accessibleBeanManager.getAccessibleDecorators());
+      accessibleNamespaces.add(accessibleBeanManager.getAccessibleNamespaces());
+      accessibleObservers.add(accessibleBeanManager.getAccessibleObservers());
+   }
+   
+   protected Iterable<Iterable<Bean<?>>> getAccessibleBeans()
+   {
+      return Iterators.concat(accessibleBeans);
+   }
+   
+   protected Iterable<Iterable<String>> getAccessibleNamespaces()
+   {
+      return Iterators.concat(accessibleNamespaces);
+   }
+   
+   protected Iterable<Iterable<DecoratorBean<?>>> getAccessibleDecorators()
+   {
+      return Iterators.concat(accessibleDecorators);
+   }
+   
+   protected Iterable<Iterable<EventObserver<?>>> getAccessibleObservers()
+   {
+      return Iterators.concat(accessibleObservers);
+   }
 
    /**
     * Set up the enabled deployment types, if none are specified by the user,
@@ -1065,7 +1150,7 @@
       return ids;
    }
    
-   protected Set<CurrentActivity> getCurrentActivities()
+   private Set<CurrentActivity> getCurrentActivities()
    {
       return currentActivities;
    }
@@ -1085,7 +1170,7 @@
       // TODO I don't like this lazy init
       if (rootNamespace == null)
       {
-         rootNamespace = new Namespace(getNamespaces());
+         rootNamespace = new Namespace(Iterators.concat(getAccessibleNamespaces()));
       }
       return rootNamespace;
    }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -149,8 +149,7 @@
       }
       initDefaultBindings();
       initPrimitive();
-      if (log.isDebugEnabled())
-         log.debug("Building Web Bean bean metadata for " + getType());
+      log.trace("Building Web Bean bean metadata for #0", getType());
       initName();
       initDeploymentType();
       checkDeploymentType();

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -23,8 +23,8 @@
 import java.util.Set;
 
 import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
 import javax.enterprise.inject.TypeLiteral;
-import javax.inject.Obtains;
 
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.event.EventImpl;
@@ -38,8 +38,8 @@
    private static final Set<Type>                        DEFAULT_TYPES             = new HashSet<Type>(Arrays.asList(TYPE, Object.class));
    private static final Annotation                       ANY                       = new AnyLiteral();
    private static final Set<Annotation>                  DEFAULT_BINDINGS          = new HashSet<Annotation>(Arrays.asList(ANY));
-   public static final ResolvableTransformer          TRANSFORMER               = new FacadeBeanResolvableTransformer(Event.class, ANY);
-   private static final Set<Class<? extends Annotation>> FILTERED_ANNOTATION_TYPES = new HashSet<Class<? extends Annotation>>(Arrays.asList(Obtains.class));
+   public static final ResolvableTransformer          TRANSFORMER               = new FacadeBeanResolvableTransformer(TYPE);
+   private static final Set<Class<? extends Annotation>> FILTERED_ANNOTATION_TYPES = new HashSet<Class<? extends Annotation>>(Arrays.asList(Any.class));
    
    
    public static AbstractFacadeBean<Event<?>> of(BeanManagerImpl manager)

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/FacadeBeanResolvableTransformer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/FacadeBeanResolvableTransformer.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/FacadeBeanResolvableTransformer.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -18,11 +18,13 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.enterprise.inject.Any;
+
+import org.jboss.webbeans.literal.AnyLiteral;
 import org.jboss.webbeans.resolution.ForwardingResolvable;
 import org.jboss.webbeans.resolution.Resolvable;
 import org.jboss.webbeans.resolution.ResolvableTransformer;
@@ -36,16 +38,20 @@
 public class FacadeBeanResolvableTransformer implements ResolvableTransformer
 {
 
+   private static final Set<Annotation> bindings;
+   
+   static
+   {
+      bindings = new HashSet<Annotation>();
+      bindings.add(new AnyLiteral());
+   }
+
    private final Class<?> clazz;
-   private final Annotation annotation;
-   private final Set<Annotation> bindings;
    private final HashSet<Type> types;
 
-   public FacadeBeanResolvableTransformer(Class<?> clazz, Annotation annotation)
+   public FacadeBeanResolvableTransformer(Class<?> clazz)
    {
       this.clazz = clazz;
-      this.annotation = annotation;
-      this.bindings = new HashSet<Annotation>(Arrays.asList(annotation));
       this.types = new HashSet<Type>();
       types.add(clazz);
    }
@@ -54,44 +60,40 @@
    {
       if (resolvable.isAssignableTo(clazz))
       {
-         if (resolvable.isAnnotationPresent(annotation.annotationType()))
+         return new ForwardingResolvable()
          {
 
-            return new ForwardingResolvable()
+            @Override
+            protected Resolvable delegate()
             {
+               return resolvable;
+            }
 
-               @Override
-               protected Resolvable delegate()
-               {
-                  return resolvable;
-               }
+            @Override
+            public Set<Annotation> getBindings()
+            {
+               return Collections.unmodifiableSet(bindings);
+            }
 
-               @Override
-               public Set<Annotation> getBindings()
-               {
-                  return Collections.unmodifiableSet(bindings);
-               }
+            @Override
+            public Set<Type> getTypeClosure()
+            {
+               return Collections.unmodifiableSet(types);
+            }
 
-               @Override
-               public Set<Type> getTypeClosure()
-               {
-                  return Collections.unmodifiableSet(types);
-               }
+            @Override
+            public boolean isAssignableTo(Class<?> c)
+            {
+               return c.isAssignableFrom(clazz);
+            }
 
-               @Override
-               public boolean isAssignableTo(Class<?> clazz)
-               {
-                  return clazz.isAssignableFrom(clazz);
-               }
+            @Override
+            public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+            {
+               return Any.class.equals(annotationType);
+            }
 
-               @Override
-               public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
-               {
-                  return annotation.annotationType().equals(annotationType);
-               }
-
-            };
-         }
+         };
       }
       return resolvable;
    }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -22,13 +22,13 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.enterprise.inject.Any;
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.TypeLiteral;
-import javax.inject.Obtains;
 
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.InstanceImpl;
-import org.jboss.webbeans.literal.ObtainsLiteral;
+import org.jboss.webbeans.literal.AnyLiteral;
 import org.jboss.webbeans.resolution.ResolvableTransformer;
 
 public class InstanceBean extends AbstractFacadeBean<Instance<?>>
@@ -36,10 +36,10 @@
 
    private static final Class<Instance<?>> TYPE = new TypeLiteral<Instance<?>>() {}.getRawType();
    private static final Set<Type> DEFAULT_TYPES = new HashSet<Type>(Arrays.asList(TYPE, Object.class));
-   private static final Obtains OBTAINS = new ObtainsLiteral();
-   private static final Set<Annotation> DEFAULT_BINDINGS = new HashSet<Annotation>(Arrays.asList(OBTAINS));
-   private static final Set<Class<? extends Annotation>> FILTERED_ANNOTATION_TYPES = new HashSet<Class<? extends Annotation>>(Arrays.asList(Obtains.class));
-   public static final ResolvableTransformer TRANSFORMER = new FacadeBeanResolvableTransformer(TYPE, OBTAINS);
+   private static final Any ANY = new AnyLiteral();
+   private static final Set<Annotation> DEFAULT_BINDINGS = new HashSet<Annotation>(Arrays.asList(ANY));
+   private static final Set<Class<? extends Annotation>> FILTERED_ANNOTATION_TYPES = new HashSet<Class<? extends Annotation>>(Arrays.asList(Any.class));
+   public static final ResolvableTransformer TRANSFORMER = new FacadeBeanResolvableTransformer(TYPE);
    
    
    public static AbstractFacadeBean<Instance<?>> of(BeanManagerImpl manager)

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ServletConversationManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ServletConversationManager.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ServletConversationManager.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -25,9 +25,9 @@
 import java.io.Serializable;
 
 import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Current;
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.Produces;
-import javax.inject.Obtains;
 import javax.servlet.http.HttpSession;
 
 import org.jboss.webbeans.WebBean;
@@ -54,7 +54,7 @@
    private static final long CONVERSATION_CONCURRENT_ACCESS_TIMEOUT_IN_MS = 1 * 1000;
    private static final String CONVERSATION_ID_NAME = "cid";
    
-   @Obtains Instance<HttpSession> httpSession;
+   @Current Instance<HttpSession> httpSession;
 
    @Override
    public BeanStore getBeanStore(String cid)

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/ObtainsLiteral.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/ObtainsLiteral.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/ObtainsLiteral.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -1,25 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.webbeans.literal;
-
-import javax.enterprise.inject.AnnotationLiteral;
-import javax.inject.Obtains;
-
-public class ObtainsLiteral extends AnnotationLiteral<Obtains> implements Obtains
-{
-   
-}

Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/Field.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/Field.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/Field.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -1,12 +1,11 @@
 package org.jboss.webbeans.test.unit.activities;
 
 import javax.enterprise.inject.Instance;
-import javax.inject.Obtains;
 
 class Field
 {
    
-   @Obtains @Tame Instance<Cow> instance;
+   @Tame Instance<Cow> instance;
    
    public Cow get()
    {

Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/current/Field.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/current/Field.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/activities/current/Field.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -1,12 +1,11 @@
 package org.jboss.webbeans.test.unit.activities.current;
 
 import javax.enterprise.inject.Instance;
-import javax.inject.Obtains;
 
 class Field
 {
    
-   @Obtains @Tame Instance<Cow> instance;
+   @Tame Instance<Cow> instance;
    
    public Cow get()
    {

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -0,0 +1,102 @@
+package org.jboss.webbeans.test.unit.deployment.structure;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.bean.SimpleBean;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
+import org.jboss.webbeans.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.jlr.WBClassImpl;
+import org.jboss.webbeans.metadata.TypeStore;
+import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
+import org.jboss.webbeans.resources.ClassTransformer;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class AccessibleManagerResolutionTest
+{
+   
+   private ClassTransformer classTransformer;
+   private ServiceRegistry services;
+   
+   @BeforeMethod
+   public void beforeMethod()
+   {
+      this.classTransformer = new ClassTransformer(new TypeStore());
+      this.services = new SimpleServiceRegistry();
+      this.services.add(MetaAnnotationStore.class, new MetaAnnotationStore(classTransformer));
+      
+   }
+   
+   private void addBean(BeanManagerImpl manager, Class<?> c)
+   {
+      WBClass<?> clazz = WBClassImpl.of(c, classTransformer);
+      RIBean<?> bean = SimpleBean.of(clazz, manager);
+      manager.addBean(bean);
+      BeanDeployerEnvironment environment = new BeanDeployerEnvironment(new EjbDescriptorCache(), manager);
+      bean.initialize(environment);
+   }
+   
+   @Test
+   public void testAccessibleSingleLevel()
+   {
+      BeanManagerImpl root = BeanManagerImpl.newRootManager(services);
+      BeanManagerImpl child = BeanManagerImpl.newRootManager(services);
+      addBean(root, Cow.class);
+      assert root.getBeans(Cow.class).size() == 1;
+      assert child.getBeans(Cow.class).size() == 0;
+      child.addAccessibleBeanManager(root);
+      assert child.getBeans(Cow.class).size() == 1;
+      addBean(child, Chicken.class);
+      assert child.getBeans(Chicken.class).size() == 1;
+      assert root.getBeans(Chicken.class).size() == 0;
+   }
+   
+   @Test
+   public void testAccessibleTwoLevels()
+   {
+      BeanManagerImpl root = BeanManagerImpl.newRootManager(services);
+      BeanManagerImpl child = BeanManagerImpl.newRootManager(services);
+      BeanManagerImpl grandchild = BeanManagerImpl.newRootManager(services);
+      grandchild.addAccessibleBeanManager(child);
+      child.addAccessibleBeanManager(root);
+      addBean(root, Cow.class);
+      addBean(child, Chicken.class);
+      addBean(grandchild, Pig.class);
+      assert root.getBeans(Pig.class).size() == 0;
+      assert root.getBeans(Chicken.class).size() == 0;
+      assert root.getBeans(Cow.class).size() == 1;
+      assert child.getBeans(Pig.class).size() == 0;
+      assert child.getBeans(Chicken.class).size() == 1;
+      assert child.getBeans(Cow.class).size() == 1;
+      assert grandchild.getBeans(Pig.class).size() == 1;
+      assert grandchild.getBeans(Chicken.class).size() == 1;
+      assert grandchild.getBeans(Cow.class).size() == 1;
+   }
+   
+   @Test
+   public void testSameManagerAddedTwice()
+   {
+      BeanManagerImpl root = BeanManagerImpl.newRootManager(services);
+      BeanManagerImpl child = BeanManagerImpl.newRootManager(services);
+      BeanManagerImpl grandchild = BeanManagerImpl.newRootManager(services);
+      grandchild.addAccessibleBeanManager(child);
+      child.addAccessibleBeanManager(root);
+      grandchild.addAccessibleBeanManager(root);
+      addBean(root, Cow.class);
+      addBean(child, Chicken.class);
+      addBean(grandchild, Pig.class);
+      assert root.getBeans(Pig.class).size() == 0;
+      assert root.getBeans(Chicken.class).size() == 0;
+      assert root.getBeans(Cow.class).size() == 1;
+      assert child.getBeans(Pig.class).size() == 0;
+      assert child.getBeans(Chicken.class).size() == 1;
+      assert child.getBeans(Cow.class).size() == 1;
+      assert grandchild.getBeans(Pig.class).size() == 1;
+      assert grandchild.getBeans(Chicken.class).size() == 1;
+      assert grandchild.getBeans(Cow.class).size() == 1;
+   }
+   
+}


Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Chicken.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Chicken.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Chicken.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.test.unit.deployment.structure;
+
+/**
+ * @author pmuir
+ *
+ */
+public class Chicken
+{
+
+}


Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Chicken.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Cow.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Cow.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Cow.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.test.unit.deployment.structure;
+
+/**
+ * @author pmuir
+ *
+ */
+public class Cow
+{
+
+}


Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Cow.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Pig.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Pig.java	                        (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Pig.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.test.unit.deployment.structure;
+
+/**
+ * @author pmuir
+ *
+ */
+public class Pig
+{
+
+}


Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/Pig.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletEnvironmentTest.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -16,7 +16,6 @@
 import org.jboss.webbeans.mock.MockServletLifecycle;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
 
 public class ServletEnvironmentTest
 {
@@ -46,7 +45,6 @@
       lifecycle = null;
    }
    
-   @Test(groups="incontainer-broken")
    public void testSimpleBeans()
    {
       Map<Class<?>, Bean<?>> beans = new HashMap<Class<?>, Bean<?>>();
@@ -69,7 +67,6 @@
       manager.getInstanceByType(Sole.class, new AnnotationLiteral<Whitefish>() {}).ping();
    }
    
-   @Test(groups="incontainer-broken")
    public void testProducerMethodBean()
    {
       Map<Class<?>, Bean<?>> beans = new HashMap<Class<?>, Bean<?>>();
@@ -89,7 +86,6 @@
       manager.getInstanceByType(Tarantula.class, new AnnotationLiteral<Tame>() {}).ping();
    }
    
-   @Test(groups="incontainer-broken")
    public void testSingleEnterpriseBean()
    {
       List<Bean<?>> beans = manager.getBeans();

Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletLifecycleTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletLifecycleTest.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/environments/servlet/ServletLifecycleTest.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -15,14 +15,21 @@
 import org.testng.annotations.Test;
 
 /**
- * A set of tests that validates that the contexts are properly created
- * and destroyed from the perspective of a servlet environment.
+ * A set of tests that validates that the contexts are properly created and
+ * destroyed from the perspective of a servlet environment.
  * 
+ * TODO PLM this test is severely broken in design due to a lack of
+ * understanding of how lifecycle is built (it is an application singleton, it
+ * can't just be replaced). If it starts to fail, it needs rewriting to be an
+ * i/c test that runs in a servlet container OR without using the deployment
+ * arch
+ * 
  * @author Dan Allen
  */
 @Artifact
 public class ServletLifecycleTest extends AbstractWebBeansTest
 {
+
    @Test(groups = "incontainer-broken")
    public void testEndSessionWithActiveRequestAndSessionContexts()
    {
@@ -30,17 +37,17 @@
       BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
       RequestContext.instance().setBeanStore(requestBeanStore);
       RequestContext.instance().setActive(true);
-      
+
       BeanStore sessionBeanStore = new ConcurrentHashMapBeanStore();
       SessionContext.instance().setBeanStore(sessionBeanStore);
       SessionContext.instance().setActive(true);
-      
+
       HttpSession session = new MockHttpSession("99");
       servletLifecycle.endSession(session);
       assert Boolean.FALSE.equals(SessionContext.instance().isActive()) : "Session context should no longer be active";
       assert Boolean.TRUE.equals(RequestContext.instance().isActive()) : "Request context should still be active";
    }
-   
+
    @Test(groups = "incontainer-broken")
    public void testEndSessionWithActiveRequestContextOnly()
    {
@@ -48,24 +55,24 @@
       BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
       RequestContext.instance().setBeanStore(requestBeanStore);
       RequestContext.instance().setActive(true);
-      
+
       HttpSession session = new MockHttpSession("99");
       servletLifecycle.endSession(session);
       assert Boolean.FALSE.equals(SessionContext.instance().isActive()) : "Session context should no longer be active";
       assert Boolean.TRUE.equals(RequestContext.instance().isActive()) : "Request context should still be active";
    }
-   
+
    @Test(groups = "incontainer-broken")
    public void testEndSessionWithNoActiveRequestOrSessionContexts()
    {
       ServletLifecycle servletLifecycle = new ServletLifecycle(new ContextLifecycle());
-      
+
       HttpSession session = new MockHttpSession("99");
       servletLifecycle.endSession(session);
       assert Boolean.FALSE.equals(SessionContext.instance().isActive()) : "Session context should no longer be active";
       assert Boolean.FALSE.equals(RequestContext.instance().isActive()) : "Temporary request context should have been deactivated";
    }
-   
+
    @BeforeMethod(groups = "incontainer-broken")
    public void beforeMethod()
    {

Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListInstance.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListInstance.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListInstance.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -2,12 +2,12 @@
 
 import java.util.List;
 
+import javax.enterprise.inject.Any;
 import javax.enterprise.inject.Instance;
-import javax.inject.Obtains;
 
 public class ListInstance
 {
-   @Obtains
+   @Any
    Instance<List> instance;
    
    public List get()

Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListStringInstance.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListStringInstance.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/producer/field/ListStringInstance.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -2,12 +2,12 @@
 
 import java.util.List;
 
+import javax.enterprise.inject.Any;
 import javax.enterprise.inject.Instance;
-import javax.inject.Obtains;
 
 public class ListStringInstance
 {
-   @Obtains Instance<List<String>> instance;
+   @Any Instance<List<String>> instance;
 
    public List<String> get()
    {

Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/lookup/LookupInstanceTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/lookup/LookupInstanceTest.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/lookup/LookupInstanceTest.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -6,7 +6,7 @@
 import javax.enterprise.inject.TypeLiteral;
 
 import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.webbeans.literal.ObtainsLiteral;
+import org.jboss.webbeans.literal.CurrentLiteral;
 import org.jboss.webbeans.test.AbstractWebBeansTest;
 import org.testng.annotations.Test;
 
@@ -18,7 +18,7 @@
    @Test
    public void testLookupInstance() throws Exception
    {
-      assert createContextualInstance(new TypeLiteral<Instance<List<?>>>(){}.getRawType(), new ObtainsLiteral()) == null; 
+      assert createContextualInstance(new TypeLiteral<Instance<List<?>>>(){}.getRawType(), new CurrentLiteral()) == null; 
    }
    
 }

Modified: ri/trunk/tests/unit-tests.xml
===================================================================
--- ri/trunk/tests/unit-tests.xml	2009-07-01 20:04:16 UTC (rev 2949)
+++ ri/trunk/tests/unit-tests.xml	2009-07-01 21:07:14 UTC (rev 2950)
@@ -57,6 +57,7 @@
          <package name="org.jboss.webbeans.test.unit.bootstrap.environments.singleSimple" />
          <package name="org.jboss.webbeans.test.unit.context" />
          <package name="org.jboss.webbeans.test.unit.definition" />
+         <package name="org.jboss.webbeans.test.unit.deployment.structure" />
          <package name="org.jboss.webbeans.test.unit.event" />
          <package name="org.jboss.webbeans.test.unit.implementation" />
          <package name="org.jboss.webbeans.test.unit.implementation.annotatedItem" />

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/registerUsingEvent/FinchKeeper.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/registerUsingEvent/FinchKeeper.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/registerUsingEvent/FinchKeeper.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -2,6 +2,7 @@
 
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
 
 import org.jboss.jsr299.tck.tests.event.observer.registerUsingEvent.StarFinch.Mess;
 
@@ -10,7 +11,7 @@
 {
    private boolean newMessDetected = false;
 
-   public void observesMesses(@Observes Mess aNewMess)
+   public void observesMesses(@Tame @Any @Observes Mess aNewMess)
    {
       newMessDetected = true;
    }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/registerUsingEvent/OrangeCheekedWaxbill.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/registerUsingEvent/OrangeCheekedWaxbill.java	2009-07-01 20:04:16 UTC (rev 2949)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/observer/registerUsingEvent/OrangeCheekedWaxbill.java	2009-07-01 21:07:14 UTC (rev 2950)
@@ -15,7 +15,7 @@
    {
    }
 
-   public @Initializer void theInitializerMethod(@Any @Tame Event<Mess> eventObject)
+   public @Initializer void theInitializerMethod(@Any Event<Mess> eventObject)
    {
       // Create a new mess and fire the event for it
       someMess = new Mess("tameMess");




More information about the weld-commits mailing list