[weld-commits] Weld SVN: r5446 - in core/trunk/impl/src/main/java/org/jboss/weld/bean: interceptor and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Tue Jan 12 09:04:29 EST 2010


Author: pete.muir at jboss.org
Date: 2010-01-12 09:04:29 -0500 (Tue, 12 Jan 2010)
New Revision: 5446

Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/NewManagedBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/NewSessionBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java
Log:
cleanup, use generics a bit more properly

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java	2010-01-12 13:40:14 UTC (rev 5445)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java	2010-01-12 14:04:29 UTC (rev 5446)
@@ -287,7 +287,7 @@
       }
       else
       {
-         ProxyClassConstructorInjectionPointWrapper<T> constructorInjectionPointWrapper = new ProxyClassConstructorInjectionPointWrapper(this, constructorForAbstractDecorator, getConstructor());
+         ProxyClassConstructorInjectionPointWrapper<T> constructorInjectionPointWrapper = new ProxyClassConstructorInjectionPointWrapper<T>(this, constructorForAbstractDecorator, getConstructor());
          T instance = constructorInjectionPointWrapper.newInstance(beanManager, ctx);
          Proxies.attachMethodHandler(instance, new AbstractDecoratorMethodHandler(annotatedDelegateItem, getDelegateInjectionPoint(), constructorInjectionPointWrapper.getInjectedDelegate()));
          return instance;

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java	2010-01-12 13:40:14 UTC (rev 5445)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/InterceptorImpl.java	2010-01-12 14:04:29 UTC (rev 5446)
@@ -84,7 +84,7 @@
    {
       try
       {
-         return new DirectClassInterceptionHandler(instance, getType()).invoke(ctx.getTarget(), org.jboss.interceptor.model.InterceptionType.valueOf(type.name()), ctx);
+         return new DirectClassInterceptionHandler<T>(instance, getType()).invoke(ctx.getTarget(), org.jboss.interceptor.model.InterceptionType.valueOf(type.name()), ctx);
       } catch (Exception e)
       {
          throw new WeldException(e);

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2010-01-12 13:40:14 UTC (rev 5445)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2010-01-12 14:04:29 UTC (rev 5446)
@@ -380,9 +380,9 @@
                DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator;
                decoratorClass = decoratorBean.getWeldAnnotated();
             }
-            else if (decorator instanceof CustomDecoratorWrapper)
+            else if (decorator instanceof CustomDecoratorWrapper<?>)
             {
-               decoratorClass = ((CustomDecoratorWrapper) decorator).getWeldAnnotated();
+               decoratorClass = ((CustomDecoratorWrapper<?>) decorator).getWeldAnnotated();
             }
             else
             {
@@ -435,7 +435,7 @@
          throw new DefinitionException(SPECIALIZING_BEAN_MUST_EXTEND_A_BEAN, this);
       }
       AbstractClassBean<?> specializedBean = environment.getClassBean(getWeldAnnotated().getWeldSuperclass());
-      if (!(specializedBean instanceof ManagedBean))
+      if (!(specializedBean instanceof ManagedBean<?>))
       {
          throw new DefinitionException(SPECIALIZING_BEAN_MUST_EXTEND_A_BEAN, this);
       } else
@@ -470,7 +470,7 @@
          if (hasCdiBoundInterceptors())
          {
             interceptionRegistries.add(beanManager.getCdiInterceptorsRegistry());
-            interceptionHandlerFactories.add(new CdiInterceptorHandlerFactory(creationalContext, beanManager));
+            interceptionHandlerFactories.add(new CdiInterceptorHandlerFactory<T>(creationalContext, beanManager));
          }
          if (interceptionRegistries.size() > 0)
             instance = new InterceptorProxyCreatorImpl(interceptionRegistries, interceptionHandlerFactories).createProxyFromInstance(instance, getType());

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/NewManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/NewManagedBean.java	2010-01-12 13:40:14 UTC (rev 5445)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/NewManagedBean.java	2010-01-12 14:04:29 UTC (rev 5446)
@@ -60,7 +60,9 @@
       this.bindings = new HashSet<Annotation>();
       this.bindings.add(new NewLiteral()
       {
-         
+
+         private static final long serialVersionUID = -6678013994309291500L;
+
          @Override
          public Class<?> value()
          {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/NewSessionBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/NewSessionBean.java	2010-01-12 13:40:14 UTC (rev 5445)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/NewSessionBean.java	2010-01-12 14:04:29 UTC (rev 5446)
@@ -64,6 +64,8 @@
       this.bindings.add(new NewLiteral()
       {
          
+         private static final long serialVersionUID = 3953682907943246693L;
+
          @Override
          public Class<?> value()
          {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java	2010-01-12 13:40:14 UTC (rev 5445)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandler.java	2010-01-12 14:04:29 UTC (rev 5446)
@@ -10,17 +10,20 @@
 /**
  * @author Marius Bogoevici
  */
-public class CdiInterceptorHandler extends AbstractClassInterceptionHandler implements Serializable
+public class CdiInterceptorHandler<T> extends AbstractClassInterceptionHandler implements Serializable
 {
 
-   private final SerializableContextualInstance<Interceptor<Object>, Object> serializableContextualInstance;
+   private static final long serialVersionUID = -1614068925228599196L;
+   
+   private final SerializableContextualInstance<Interceptor<T>, T> serializableContextualInstance;
 
-   public CdiInterceptorHandler(SerializableContextualInstance<Interceptor<Object>, Object> serializableContextualInstance, Class<?> clazz)
+   public CdiInterceptorHandler(SerializableContextualInstance<Interceptor<T>, T> serializableContextualInstance, Class<?> clazz)
    {
       super(clazz);
       this.serializableContextualInstance = serializableContextualInstance;
    }
 
+   @Override
    public Object getInterceptorInstance()
    {
       return serializableContextualInstance.getInstance();

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java	2010-01-12 13:40:14 UTC (rev 5445)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/CdiInterceptorHandlerFactory.java	2010-01-12 14:04:29 UTC (rev 5446)
@@ -22,19 +22,19 @@
 
 import org.jboss.interceptor.proxy.InterceptionHandler;
 import org.jboss.interceptor.proxy.InterceptionHandlerFactory;
+import org.jboss.weld.context.SerializableContextualInstanceImpl;
 import org.jboss.weld.manager.BeanManagerImpl;
 import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
-import org.jboss.weld.context.SerializableContextualInstanceImpl;
 
 /**
  * @author Marius Bogoevici
 */
-public class CdiInterceptorHandlerFactory implements InterceptionHandlerFactory<SerializableContextual<Interceptor<Object>, Object>>
+public class CdiInterceptorHandlerFactory<T> implements InterceptionHandlerFactory<SerializableContextual<Interceptor<T>, T>>
 {
-   private final CreationalContext creationalContext;
+   private final CreationalContext<T> creationalContext;
    private BeanManagerImpl manager;
 
-   public CdiInterceptorHandlerFactory(CreationalContext creationalContext, BeanManagerImpl manager)
+   public CdiInterceptorHandlerFactory(CreationalContext<T> creationalContext, BeanManagerImpl manager)
    {
       this.creationalContext = creationalContext;
       this.manager = manager;
@@ -45,12 +45,10 @@
       return manager;
    }
 
-   @SuppressWarnings("unchecked")
-   public InterceptionHandler createFor(final SerializableContextual<Interceptor<Object>, Object> serializableContextual)
+   public InterceptionHandler createFor(final SerializableContextual<Interceptor<T>, T> serializableContextual)
    {
-      Object instance = getManager().getReference(serializableContextual.get(), creationalContext, false);
-      return new CdiInterceptorHandler(new SerializableContextualInstanceImpl<Interceptor<Object>, Object>(serializableContextual, instance, creationalContext),
-            serializableContextual.get().getBeanClass());
+      T instance = (T) getManager().getReference(serializableContextual.get(), creationalContext, false);
+      return new CdiInterceptorHandler<T>(new SerializableContextualInstanceImpl<Interceptor<T>, T>(serializableContextual, instance, creationalContext), serializableContextual.get().getBeanClass());
    }
 
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java	2010-01-12 13:40:14 UTC (rev 5445)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/interceptor/ClassInterceptionHandlerFactory.java	2010-01-12 14:04:29 UTC (rev 5446)
@@ -31,27 +31,27 @@
 /**
  * @author Marius Bogoevici
 */
-public class ClassInterceptionHandlerFactory implements InterceptionHandlerFactory<Class>
+public class ClassInterceptionHandlerFactory<T> implements InterceptionHandlerFactory<Class<T>>
 {
-   private final CreationalContext<?> creationalContext;
+   private final CreationalContext<T> creationalContext;
    private BeanManagerImpl manager;
 
-   public ClassInterceptionHandlerFactory(CreationalContext<?> creationalContext, BeanManagerImpl manager)
+   public ClassInterceptionHandlerFactory(CreationalContext<T> creationalContext, BeanManagerImpl manager)
    {
       this.creationalContext = creationalContext;
       this.manager = manager;
    }
 
-   public InterceptionHandler createFor(Class clazz)
+   public InterceptionHandler createFor(Class<T> clazz)
    {
       try
       {
          // this is not a managed instance - assume no-argument constructor exists
-         Constructor constructor = SecureReflections.getDeclaredConstructor(clazz);
-         Object interceptorInstance = constructor.newInstance();
+         Constructor<T> constructor = (Constructor<T>) SecureReflections.getDeclaredConstructor(clazz);
+         T interceptorInstance = constructor.newInstance();
          // inject
          manager.createInjectionTarget(manager.createAnnotatedType(clazz)).inject(interceptorInstance, creationalContext);
-         return new DirectClassInterceptionHandler(interceptorInstance, clazz);
+         return new DirectClassInterceptionHandler<T>(interceptorInstance, clazz);
       }
       catch (Exception e)
       {



More information about the weld-commits mailing list