openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r751846 - in /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/ config/ ejb/ event/ intercept/ spi/deployer/ spi/ee/deployer/ util/
Date Mon, 09 Mar 2009 21:22:51 GMT
Author: gerdogdu
Date: Mon Mar  9 21:22:50 2009
New Revision: 751846

URL: http://svn.apache.org/viewvc?rev=751846&view=rev
Log:
Updating for TCK tests.

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerComponentImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldComponent.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/SimpleWebBeansConfigurator.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerComponentImpl.java?rev=751846&r1=751845&r2=751846&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerComponentImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerComponentImpl.java
Mon Mar  9 21:22:50 2009
@@ -13,6 +13,7 @@
  */
 package org.apache.webbeans.component;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
@@ -228,7 +229,10 @@
 
     protected Object getParentInstance()
     {
-        Object parentInstance = getManager().getInstance(this.parent);
+        Annotation[] anns = new Annotation[this.parent.getBindings().size()];
+        anns = this.parent.getBindings().toArray(anns);
+        
+        Object parentInstance = getManager().getInstanceByType(this.parent.getReturnType(),anns);
 
         return parentInstance;
     }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldComponent.java?rev=751846&r1=751845&r2=751846&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldComponent.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldComponent.java
Mon Mar  9 21:22:50 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.webbeans.component;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 
 import javax.context.CreationalContext;
@@ -113,7 +114,16 @@
     
     protected Object getParentInstance()
     {
-        return getManager().getInstance(this.ownerComponent);
+        //return getManager().getInstance(this.ownerComponent);
+        
+        //Added for most specialized bean
+        Annotation[] anns = new Annotation[this.ownerComponent.getBindings().size()];
+        anns = this.ownerComponent.getBindings().toArray(anns);
+        
+        Object parentInstance = getManager().getInstanceByType(this.ownerComponent.getReturnType(),anns);
+        
+        return parentInstance;
+        
     }
     
     @Override

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=751846&r1=751845&r2=751846&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
Mon Mar  9 21:22:50 2009
@@ -31,6 +31,7 @@
 import javax.decorator.Decorates;
 import javax.event.Fires;
 import javax.event.Observes;
+import javax.inject.Current;
 import javax.inject.DeploymentType;
 import javax.inject.Disposes;
 import javax.inject.Initializer;
@@ -289,10 +290,8 @@
         }
     }
 
-    public static <T> void defineStereoTypes(Component<?> component, Class<T>
clazz)
+    public static <T> void defineStereoTypes(Component<?> component, Annotation[]
anns)
     {
-        Annotation[] anns = clazz.getDeclaredAnnotations();
-
         if (AnnotationUtil.isStereoTypeMetaAnnotationExist(anns))
         {
             Annotation[] steroAnns = AnnotationUtil.getStereotypeMetaAnnotations(anns);
@@ -472,7 +471,9 @@
             if (isRealizes)
             {
                 int modifiers = field.getModifiers();
-                if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+                //if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+                //TODO : TCK Test Suite is broken if we exlude the private fields
+                if (Modifier.isStatic(modifiers))
                 {
                     continue;
                 }
@@ -487,19 +488,24 @@
                 {
                     if (isRealizes)
                     {
-                        // Add Binding types from the parent and removes from
-                        // the generic super class via @Realizes
+                        //Add component that extends the super class binding types other
than current
                         Set<Annotation> fromParents = component.getBindings();
                         for (Annotation fromParent : fromParents)
                         {
-                            newComponent.addBindingType(fromParent);
+                            if(!fromParent.annotationType().equals(Current.class))
+                            {
+                                newComponent.addBindingType(fromParent);   
+                            }                            
                         }
 
                         // Removes the @BindingTypes from @Realizes
                         Annotation[] fromGenerics = AnnotationUtil.getBindingAnnotations(component.getReturnType().getSuperclass().getDeclaredAnnotations());
                         for (Annotation fromGeneric : fromGenerics)
                         {
-                            newComponent.getBindings().remove(fromGeneric);
+                            if(!fromGeneric.annotationType().equals(Current.class))
+                            {
+                                newComponent.getBindings().remove(fromGeneric);   
+                            }
                         }
 
                         // Deployment type is the same as parent
@@ -557,7 +563,9 @@
         for (Method declaredMethod : realizedProducers)
         {
             int modifiers = declaredMethod.getModifiers();
-            if (!Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers))
+            //if (!Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers))
+            //TODO TCK broken if check private
+            if (!Modifier.isStatic(modifiers))
             {
                 createProducerComponentsWithReliazes(component, producerComponents, declaredMethod,
clazz.getSuperclass(), isSpecializes, true);
             }
@@ -599,14 +607,20 @@
                     Set<Annotation> fromParents = component.getBindings();
                     for (Annotation fromParent : fromParents)
                     {
-                        newComponent.addBindingType(fromParent);
+                        if(!fromParent.annotationType().equals(Current.class))
+                        {
+                            newComponent.addBindingType(fromParent);   
+                        }
                     }
 
                     // Removes the @BindingTypes from @Realizes
                     Annotation[] fromGenerics = AnnotationUtil.getBindingAnnotations(component.getReturnType().getSuperclass().getDeclaredAnnotations());
                     for (Annotation fromGeneric : fromGenerics)
                     {
-                        newComponent.getBindings().remove(fromGeneric);
+                        if(!fromGeneric.annotationType().equals(Current.class))
+                        {
+                            newComponent.getBindings().remove(fromGeneric);   
+                        }
                     }
 
                     // Deployment type is the same as parent
@@ -637,6 +651,7 @@
         }
 
         defineSerializable(component);
+        defineStereoTypes(component, method.getDeclaredAnnotations());
 
         Class<? extends Annotation> deploymentType = DefinitionUtil.defineDeploymentType(component,
method.getDeclaredAnnotations(), "There are more than one @DeploymentType annotation in the
component class : " + component.getReturnType().getName());
 
@@ -669,6 +684,7 @@
         }
 
         defineSerializable(component);
+        defineStereoTypes(component, field.getDeclaredAnnotations());
 
         Class<? extends Annotation> deploymentType = DefinitionUtil.defineDeploymentType(component,
field.getDeclaredAnnotations(), "There are more than one @DeploymentType annotation in the
component class : " + component.getReturnType().getName());
 
@@ -719,7 +735,9 @@
             if (isRealizes)
             {
                 int modifiers = declaredMethod.getModifiers();
-                if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+                //if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+                //TODO //TCK broken if we check private
+                if (Modifier.isStatic(modifiers))
                 {
                     continue;
                 }
@@ -853,17 +871,20 @@
                         {
                             // Check that field is already exist
                             Set<Field> definedInjectedFields = component.getInjectedFields();
+                            boolean defined = false;
                             for (Field defineInjectedField : definedInjectedFields)
                             {
                                 if (defineInjectedField.getName().equals(field.getName())
&& defineInjectedField.getType().equals(field.getType()))
                                 {
+                                    defined = true;
                                     break;
                                 }
-                                else
-                                {
-                                    component.addInjectedField(field);
-                                    addFieldInjectionPointMetaData(component, field);
-                                }
+                            }
+                            
+                            if(!defined)
+                            {
+                                component.addInjectedField(field);
+                                addFieldInjectionPointMetaData(component, field);       
                        
                             }
                         }
                     }
@@ -940,17 +961,20 @@
                 else
                 {
                     Set<Method> injectedMethods = component.getInjectedMethods();
+                    boolean defined = false;
                     for (Method definedInjectedMethod : injectedMethods)
                     {
                         if (definedInjectedMethod.getName().equals(method.getName()) &&
Arrays.equals(definedInjectedMethod.getParameterTypes(), method.getParameterTypes()))
                         {
+                            defined = true;
                             break;
                         }
-                        else
-                        {
-                            component.addInjectedMethod(method);
-                            addMethodInjectionPointMetaData(component, method);
-                        }
+                    }
+                    
+                    if(!defined)
+                    {
+                        component.addInjectedMethod(method);
+                        addMethodInjectionPointMetaData(component, method);             
          
                     }
                 }
 
@@ -1050,7 +1074,9 @@
             if (isRealizes)
             {
                 int modifiers = candidateMethod.getModifiers();
-                if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+                //if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+                //TODO TCK broken if we check private
+                if (Modifier.isStatic(modifiers))                    
                 {
                     continue;
                 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/SimpleWebBeansConfigurator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/SimpleWebBeansConfigurator.java?rev=751846&r1=751845&r2=751846&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/SimpleWebBeansConfigurator.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/SimpleWebBeansConfigurator.java
Mon Mar  9 21:22:50 2009
@@ -117,7 +117,7 @@
         ComponentImpl<T> component = new ComponentImpl<T>(clazz, type);
         
         DefinitionUtil.defineSerializable(component);
-        DefinitionUtil.defineStereoTypes(component, clazz);
+        DefinitionUtil.defineStereoTypes(component, clazz.getDeclaredAnnotations());
         
         Class<? extends Annotation> deploymentType = DefinitionUtil.defineDeploymentType(component,
clazz.getDeclaredAnnotations(), "There are more than one @DeploymentType annotation in the
component class : " + component.getReturnType().getName());
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBUtil.java?rev=751846&r1=751845&r2=751846&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/ejb/EJBUtil.java
Mon Mar  9 21:22:50 2009
@@ -16,6 +16,7 @@
 import javax.ejb.MessageDriven;
 import javax.ejb.Stateful;
 import javax.ejb.Stateless;
+import javax.persistence.Entity;
 
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
@@ -51,6 +52,22 @@
     {
         return (AnnotationUtil.isAnnotationExistOnClass(clazz, Stateless.class) || AnnotationUtil.isAnnotationExistOnClass(clazz,
Stateful.class));
     }
+    
+    public static boolean isEJBSessionStatefulClass(Class<?> clazz)
+    {
+        return (AnnotationUtil.isAnnotationExistOnClass(clazz, Stateful.class));
+    }
+    
+    public static boolean isEJBSessionStateless(Class<?> clazz)
+    {
+        return (AnnotationUtil.isAnnotationExistOnClass(clazz, Stateless.class));
+    }    
+    
+    public static boolean isEJBEntityBean(Class<?> clazz)
+    {
+        return (AnnotationUtil.isAnnotationExistOnClass(clazz, Entity.class));
+    }        
+    
 
     /**
      * Check the given class is an EJB is MDB class or not.

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java?rev=751846&r1=751845&r2=751846&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/BeanObserverImpl.java
Mon Mar  9 21:22:50 2009
@@ -24,6 +24,7 @@
 import javax.context.Dependent;
 import javax.event.Observer;
 import javax.event.Observes;
+import javax.inject.manager.Bean;
 
 import org.apache.webbeans.annotation.CurrentLiteral;
 import org.apache.webbeans.component.AbstractComponent;
@@ -71,15 +72,21 @@
                 dependentContext = true;
             }
             
+            //Added for most specialized beans
+            Annotation[] anns = new Annotation[baseComponent.getBindings().size()];
+            anns = baseComponent.getBindings().toArray(anns);
+
+            Bean<Object> specializedComponent = manager.resolveByType(baseComponent.getReturnType(),
anns).iterator().next();
+            
             context = manager.getContext(baseComponent.getScopeType());
 
             if (ifExist)
             {
-                object = context.get(baseComponent);
+                object = context.get(specializedComponent);
             }
             else
             {
-                object = context.get((AbstractComponent<Object>) baseComponent, CreationalContextFactory.getInstance().getCreationalContext(baseComponent));
+                object = context.get((AbstractComponent<Object>) specializedComponent,
CreationalContextFactory.getInstance().getCreationalContext(specializedComponent));
             }
             
             

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java?rev=751846&r1=751845&r2=751846&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
Mon Mar  9 21:22:50 2009
@@ -13,6 +13,7 @@
  */
 package org.apache.webbeans.intercept;
 
+import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.Collections;
@@ -36,15 +37,17 @@
 
 import javassist.util.proxy.MethodHandler;
 
-public class InterceptorHandler implements MethodHandler
+public class InterceptorHandler implements MethodHandler, Serializable
 {
-    private static WebBeansLogger logger = WebBeansLogger.getLogger(InterceptorHandler.class);
+    private static final long serialVersionUID = 1657109769733323541L;
+
+    private transient static WebBeansLogger logger = WebBeansLogger.getLogger(InterceptorHandler.class);
 
     private AbstractComponent<?> component = null;
 
-    private Method calledMethod = null;
+    private transient Method calledMethod = null;
 
-    private boolean isSameDecMethod = false;
+    private transient boolean isSameDecMethod = false;
 
     public InterceptorHandler(AbstractComponent<?> component)
     {

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java?rev=751846&r1=751845&r2=751846&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/deployer/AbstractMetaDataDiscovery.java
Mon Mar  9 21:22:50 2009
@@ -44,6 +44,10 @@
                 ANNOTATION_DB = new AnnotationDB();
                 ANNOTATION_DB.setScanClassAnnotations(true);
                 ANNOTATION_DB.crossReferenceMetaAnnotations();    
+                ANNOTATION_DB.setScanFieldAnnotations(false);
+                ANNOTATION_DB.setScanMethodAnnotations(false);
+                ANNOTATION_DB.setScanParameterAnnotations(false);
+
             }            
             
         }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java?rev=751846&r1=751845&r2=751846&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/spi/ee/deployer/WarMetaDataDiscoveryImpl.java
Mon Mar  9 21:22:50 2009
@@ -58,6 +58,7 @@
                 arcs.toArray(urls);
 
                 ANNOTATION_DB.scanArchives(urls);
+                
                 configure = true;
             }
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=751846&r1=751845&r2=751846&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Mon Mar  9 21:22:50 2009
@@ -1068,13 +1068,27 @@
     public static String getProducerDefaultName(String methodName)
     {
         StringBuffer buffer = new StringBuffer(methodName);
-
-        if (buffer.substring(0, 3).equals("get"))
+            
+        if (buffer.length() > 3 &&  (buffer.substring(0, 3).equals("get") || buffer.substring(0,
3).equals("set")))                
         {
-            buffer.setCharAt(3, Character.toLowerCase(buffer.charAt(3)));
+            
+            if(Character.isUpperCase(buffer.charAt(3)))
+            {
+                buffer.setCharAt(3, Character.toLowerCase(buffer.charAt(3)));   
+            }
 
             return buffer.substring(3);
         }
+        else if ((buffer.length() > 2 &&  buffer.substring(0, 2).equals("is")))
               
+        {            
+            if(Character.isUpperCase(buffer.charAt(2)))
+            {
+                buffer.setCharAt(2, Character.toLowerCase(buffer.charAt(2)));   
+            }
+
+            return buffer.substring(2);
+        }
+        
         else
         {
             buffer.setCharAt(0, Character.toLowerCase(buffer.charAt(0)));
@@ -1365,11 +1379,15 @@
         if(AnnotationUtil.isMethodHasAnnotation(superMethod, Named.class))
         {
           Named named =  superMethod.getAnnotation(Named.class);
+          hasName = true;
           if(!named.value().equals(""))
           {
-              hasName = true;
               name = named.value();
           }
+          else
+          {
+              name = getProducerDefaultName(superMethod.getName());
+          }
         }
         else 
         {
@@ -1390,14 +1408,16 @@
             if(AnnotationUtil.isMethodHasAnnotation(method, Named.class))
             {
                 throw new DefinitionException("Specialized method : " + method.getName()
+ " in class : " + component.getReturnType().getName() + " may not define @Named annotation");
-            }                        
-        }
-        
-        else
-        {
+            }
+            
             component.setName(name);
         }
         
+//        else
+//        {
+//            component.setName(name);
+//        }
+        
     }
     
     public static void checkInjectedMethodParameterConditions(Method method, Class<?>
clazz)



Mime
View raw message