[seam-commits] Seam SVN: r13550 - in modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence: transaction/scope and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Aug 3 07:21:27 EDT 2010


Author: swd847
Date: 2010-08-03 07:21:26 -0400 (Tue, 03 Aug 2010)
New Revision: 13550

Added:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/InstanceResolver.java
Modified:
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/scope/TransactionScopeContext.java
Log:
update managed persistence context implementation



Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java	                        (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/AbstractManagedPersistenceContextBeanLifecycle.java	2010-08-03 11:21:26 UTC (rev 13550)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.seam.persistence;
+
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.weld.extensions.bean.BeanLifecycle;
+
+/**
+ * Class that is responsible for creating and destroying the seam managed
+ * persistence context
+ * 
+ * @author Stuart Douglas
+ * 
+ */
+public abstract class AbstractManagedPersistenceContextBeanLifecycle implements BeanLifecycle<EntityManager>
+{
+
+   static final Class<?> proxyClass = Proxy.getProxyClass(EntityManager.class.getClassLoader(), EntityManager.class, Serializable.class);
+
+   static final Constructor<?> proxyConstructor;
+
+   private final BeanManager manager;
+
+   protected AbstractManagedPersistenceContextBeanLifecycle(BeanManager manager)
+   {
+      this.manager = manager;
+   }
+
+   static
+   {
+      try
+      {
+         proxyConstructor = proxyClass.getConstructor(InvocationHandler.class);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   /**
+    * creates the proxy
+    */
+   public EntityManager create(Bean<EntityManager> bean, CreationalContext<EntityManager> arg0)
+   {
+      try
+      {
+         EntityManagerFactory emf = getEntityManagerFactory();
+         EntityManager entityManager = emf.createEntityManager();
+         ManagedPersistenceContextProxyHandler handler = new ManagedPersistenceContextProxyHandler(entityManager, manager);
+         EntityManager proxy = (EntityManager) proxyConstructor.newInstance(handler);
+         return proxy;
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public void destroy(Bean<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
+   {
+      em.close();
+      arg1.release();
+   }
+
+   protected abstract EntityManagerFactory getEntityManagerFactory();
+
+}

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java	2010-08-03 09:26:27 UTC (rev 13549)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContext.java	2010-08-03 11:21:26 UTC (rev 13550)
@@ -21,6 +21,8 @@
  */
 package org.jboss.seam.persistence;
 
+import java.io.Serializable;
+
 import javax.naming.NamingException;
 import javax.persistence.EntityManagerFactory;
 
@@ -28,26 +30,29 @@
 import org.jboss.weld.extensions.core.Veto;
 
 /**
- * Class that enabled the seam managed persitence context to be configured via
+ * Class that enabled the seam managed persistence context to be configured via
  * xml.
  * 
  * There are two ways to do this. Either the persistenceUnintJndi name can be
  * set, in which case the entityManagerFactory is looked up from JNDI.
  * 
- * Alternativly the @Inject annotation can be applied to the
- * entityManagerFactory propery along with any qualifiers needed and the
- * entityManagerFactory will be injected
+ * Alternatively the entityManagerFactory property can be set via el in seam-xml
  * 
- * Any qualifiers that are applied to this class are also applied to the managed
- * persistence context in question
+ * Any qualifier or scope annotations that are applied to this class are also
+ * applied to the managed persistence context in question
  * 
+ * 
  * @author Stuart Douglas
  * 
  */
 @Veto
-public class ManagedPersistenceContext
+public class ManagedPersistenceContext implements Serializable
 {
 
+   private String persistenceUnitJndiName;
+
+   private EntityManagerFactory entityManagerFactory;
+
    public String getPersistenceUnitJndiName()
    {
       return persistenceUnitJndiName;
@@ -79,8 +84,4 @@
       this.entityManagerFactory = entityManagerFactory;
    }
 
-   String persistenceUnitJndiName;
-
-   EntityManagerFactory entityManagerFactory;
-
 }

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java	2010-08-03 09:26:27 UTC (rev 13549)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java	2010-08-03 11:21:26 UTC (rev 13550)
@@ -21,53 +21,31 @@
  */
 package org.jboss.seam.persistence;
 
-import java.io.Serializable;
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
 import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
-import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 
-import org.jboss.weld.extensions.bean.BeanLifecycle;
-
 /**
- * Class that is responsible for creating and destroying the seam managed
- * persistence context
+ * SMPC lifecycle for SMPC's configured via @SeamManaged
  * 
  * @author Stuart Douglas
  * 
  */
-public class ManagedPersistenceContextBeanLifecycle implements BeanLifecycle<EntityManager>
+public class ManagedPersistenceContextBeanLifecycle extends AbstractManagedPersistenceContextBeanLifecycle
 {
 
+   protected final Annotation[] qualifiers;
+   protected final BeanManager manager;
+
    private EntityManagerFactory emf;
-   private final Annotation[] qualifiers;
-   private final BeanManager manager;
 
-   static final Class<?> proxyClass = Proxy.getProxyClass(EntityManager.class.getClassLoader(), EntityManager.class, Serializable.class);
-
-   static final Constructor<?> proxyConstructor;
-
-   static
-   {
-      try
-      {
-         proxyConstructor = proxyClass.getConstructor(InvocationHandler.class);
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
    public ManagedPersistenceContextBeanLifecycle(Set<Annotation> qualifiers, BeanManager manager)
    {
+      super(manager);
       this.qualifiers = new Annotation[qualifiers.size()];
       int i = 0;
       for (Annotation a : qualifiers)
@@ -78,34 +56,9 @@
    }
 
    /**
-    * creates the proxy
-    */
-   public EntityManager create(Bean<EntityManager> bean, CreationalContext<EntityManager> arg0)
-   {
-      try
-      {
-         EntityManagerFactory emf = getEntityManagerFactory();
-         EntityManager entityManager = emf.createEntityManager();
-         ManagedPersistenceContextProxyHandler handler = new ManagedPersistenceContextProxyHandler(entityManager, manager);
-         EntityManager proxy = (EntityManager) proxyConstructor.newInstance(handler);
-         return proxy;
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   public void destroy(Bean<EntityManager> bean, EntityManager em, CreationalContext<EntityManager> arg1)
-   {
-      em.close();
-      arg1.release();
-   }
-
-   /**
     * lazily resolve the relevant EMF
     */
-   private EntityManagerFactory getEntityManagerFactory()
+   protected EntityManagerFactory getEntityManagerFactory()
    {
       if (emf == null)
       {

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java	2010-08-03 09:26:27 UTC (rev 13549)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java	2010-08-03 11:21:26 UTC (rev 13550)
@@ -25,19 +25,15 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.persistence.EntityManager;
-import javax.persistence.Query;
 import javax.transaction.Synchronization;
 import javax.transaction.SystemException;
 
-import org.jboss.seam.persistence.transaction.DefaultTransaction;
 import org.jboss.seam.persistence.transaction.SeamTransaction;
 import org.jboss.seam.persistence.transaction.literal.DefaultTransactionLiteral;
-import org.jboss.weld.extensions.el.Expressions;
-import org.jboss.weld.extensions.literal.DefaultLiteral;
+import org.jboss.seam.persistence.util.InstanceResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,28 +45,24 @@
  * @author Stuart Douglas
  * 
  */
-public class ManagedPersistenceContextProxyHandler implements InvocationHandler, Serializable, Synchronization
+public class ManagedPersistenceContextProxyHandler extends PersistenceContextProxyHandler implements InvocationHandler, Serializable, Synchronization
 {
 
    private static final long serialVersionUID = -6539267789786229774L;
 
    private final EntityManager delegate;
 
-   private transient BeanManager beanManager;
+   private final Instance<SeamTransaction> userTransactionInstance;
 
-   private transient SeamTransaction userTransaction;
-
    private transient boolean synchronizationRegistered;
 
    static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextProxyHandler.class);
 
-   private final Bean<Expressions> expressionsBean;
-
    public ManagedPersistenceContextProxyHandler(EntityManager delegate, BeanManager beanManager)
    {
+      super(delegate, beanManager);
       this.delegate = delegate;
-      this.beanManager = beanManager;
-      this.expressionsBean = (Bean) beanManager.resolve(beanManager.getBeans(Expressions.class, DefaultLiteral.INSTANCE));
+      this.userTransactionInstance = InstanceResolver.getInstance(SeamTransaction.class, beanManager, DefaultTransactionLiteral.INSTANCE);
    }
 
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
@@ -79,16 +71,12 @@
       {
          joinTransaction();
       }
-      if ("createQuery".equals(method.getName()) && method.getParameterTypes().length > 0 && method.getParameterTypes()[0].equals(String.class))
-      {
-         return handleCreateQueryWithString(method, args);
-      }
-      return method.invoke(delegate, args);
+      return super.invoke(proxy, method, args);
    }
 
    private void joinTransaction() throws SystemException
    {
-      SeamTransaction transaction = getUserTransaction();
+      SeamTransaction transaction = userTransactionInstance.get();
       if (transaction.isActive())
       {
          transaction.enlist(delegate);
@@ -107,21 +95,6 @@
       }
    }
 
-   private SeamTransaction getUserTransaction()
-   {
-      if (userTransaction == null)
-      {
-         Bean<SeamTransaction> bean = (Bean) beanManager.resolve(beanManager.getBeans(SeamTransaction.class, DefaultTransactionLiteral.INSTANCE));
-         if (bean == null)
-         {
-            throw new RuntimeException("Could not find SeamTransaction bean with qualifier " + DefaultTransaction.class.getName());
-         }
-         CreationalContext<SeamTransaction> ctx = beanManager.createCreationalContext(bean);
-         userTransaction = (SeamTransaction) beanManager.getReference(bean, SeamTransaction.class, ctx);
-      }
-      return userTransaction;
-   }
-
    public void afterCompletion(int status)
    {
       synchronizationRegistered = false;
@@ -132,30 +105,4 @@
 
    }
 
-   protected Object handleCreateQueryWithString(Method method, Object[] args) throws Throwable
-   {
-      if (args[0] == null)
-      {
-         return method.invoke(delegate, args);
-      }
-      String ejbql = (String) args[0];
-      if (ejbql.indexOf('#') > 0)
-      {
-         CreationalContext<Expressions> ctx = beanManager.createCreationalContext(expressionsBean);
-         Expressions expressions = (Expressions) beanManager.getReference(expressionsBean, Expressions.class, ctx);
-         QueryParser qp = new QueryParser(expressions, ejbql);
-         Object[] newArgs = args.clone();
-         newArgs[0] = qp.getEjbql();
-         Query query = (Query) method.invoke(delegate, newArgs);
-         for (int i = 0; i < qp.getParameterValues().size(); i++)
-         {
-            query.setParameter(QueryParser.getParameterName(i), qp.getParameterValues().get(i));
-         }
-         return query;
-      }
-      else
-      {
-         return method.invoke(delegate, args);
-      }
-   }
 }

Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java	                        (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextProxyHandler.java	2010-08-03 11:21:26 UTC (rev 13550)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.seam.persistence;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.jboss.seam.persistence.util.InstanceResolver;
+import org.jboss.weld.extensions.el.Expressions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Proxy handler for the entity manager proxy that allows the use of EL in
+ * queries.
+ * 
+ * @author Stuart Douglas
+ * 
+ */
+public class PersistenceContextProxyHandler implements Serializable
+{
+
+   private static final long serialVersionUID = -6539267789786229774L;
+
+   private final EntityManager delegate;
+
+   private final Instance<Expressions> expressionsInstance;
+
+   static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextProxyHandler.class);
+
+   public PersistenceContextProxyHandler(EntityManager delegate, BeanManager beanManager)
+   {
+      this.delegate = delegate;
+      expressionsInstance = InstanceResolver.getInstance(Expressions.class, beanManager);
+   }
+
+   public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+   {
+      if ("createQuery".equals(method.getName()) && method.getParameterTypes().length > 0 && method.getParameterTypes()[0].equals(String.class))
+      {
+         return handleCreateQueryWithString(method, args);
+      }
+      return method.invoke(delegate, args);
+   }
+
+   protected Object handleCreateQueryWithString(Method method, Object[] args) throws Throwable
+   {
+      if (args[0] == null)
+      {
+         return method.invoke(delegate, args);
+      }
+      String ejbql = (String) args[0];
+      if (ejbql.indexOf('#') > 0)
+      {
+         Expressions expressions = expressionsInstance.get();
+         QueryParser qp = new QueryParser(expressions, ejbql);
+         Object[] newArgs = args.clone();
+         newArgs[0] = qp.getEjbql();
+         Query query = (Query) method.invoke(delegate, newArgs);
+         for (int i = 0; i < qp.getParameterValues().size(); i++)
+         {
+            query.setParameter(QueryParser.getParameterName(i), qp.getParameterValues().get(i));
+         }
+         return query;
+      }
+      else
+      {
+         return method.invoke(delegate, args);
+      }
+   }
+}

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/scope/TransactionScopeContext.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/scope/TransactionScopeContext.java	2010-08-03 09:26:27 UTC (rev 13549)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/scope/TransactionScopeContext.java	2010-08-03 11:21:26 UTC (rev 13550)
@@ -68,6 +68,10 @@
 
    }
 
+   /**
+    * we need to resolve the transaction bean lazily, after startup has
+    * completed
+    */
    private void lazyInitialization()
    {
       if (userTransaction == null)
@@ -88,6 +92,10 @@
       }
    }
 
+   /**
+    * registers a syncronization so that the beans can be destroyed when the
+    * transaction ends
+    */
    private void registerSyncronization()
    {
       TransactionScopeData data = contextData.get();
@@ -141,6 +149,9 @@
       }
    }
 
+   /**
+    * the transaction is done, destory the beans
+    */
    public void afterCompletion(int status)
    {
       TransactionScopeData data = contextData.get();

Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/InstanceResolver.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/InstanceResolver.java	                        (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/InstanceResolver.java	2010-08-03 11:21:26 UTC (rev 13550)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.seam.persistence.util;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.weld.extensions.literal.DefaultLiteral;
+
+/**
+ * Utillity class that can get an Instance<T> from the bean manager
+ * 
+ * @author stuart
+ * 
+ */
+public class InstanceResolver
+{
+   private InstanceResolver()
+   {
+
+   }
+
+   public static <T> Instance<T> getInstance(Class<T> type, BeanManager manager)
+   {
+      return getInstance(type, manager, DefaultLiteral.INSTANCE);
+   }
+
+   public static <T> Instance<T> getInstance(Class<T> type, BeanManager manager, Annotation... qualifiers)
+   {
+      Type instanceType = new InstanceParamatizedTypeImpl<T>(type);
+      Bean<?> bean = manager.resolve(manager.getBeans(instanceType, qualifiers));
+      CreationalContext ctx = manager.createCreationalContext(bean);
+      return (Instance<T>) manager.getInjectableReference(new InstanceInjectionPoint<T>(type, qualifiers), ctx);
+   }
+
+   private static class InstanceParamatizedTypeImpl<T> implements ParameterizedType
+   {
+      private final Class<T> type;
+
+      public InstanceParamatizedTypeImpl(Class<T> type)
+      {
+         this.type = type;
+      }
+
+      public Type[] getActualTypeArguments()
+      {
+         Type[] ret = new Type[1];
+         ret[0] = type;
+         return ret;
+      }
+
+      public Type getOwnerType()
+      {
+         return null;
+      }
+
+      public Type getRawType()
+      {
+         return Instance.class;
+      }
+
+   }
+
+   /**
+    * TODO: this is not portable, needs to be a proper implementation as this
+    * could cause a NPE due to some methods returning null
+    */
+   private static class InstanceInjectionPoint<T> implements InjectionPoint
+   {
+
+      private final Class<T> type;
+      private final Set<Annotation> qualifiers;
+
+      public InstanceInjectionPoint(Class<T> type, Annotation... quals)
+      {
+         this.type = type;
+         qualifiers = new HashSet<Annotation>();
+         for (Annotation a : quals)
+         {
+            qualifiers.add(a);
+         }
+      }
+
+      public Annotated getAnnotated()
+      {
+         return null;
+      }
+
+      public Bean<?> getBean()
+      {
+         return null;
+      }
+
+      public Member getMember()
+      {
+         return null;
+      }
+
+      public Set<Annotation> getQualifiers()
+      {
+
+         return qualifiers;
+      }
+
+      public Type getType()
+      {
+         return new InstanceParamatizedTypeImpl<T>(type);
+      }
+
+      public boolean isDelegate()
+      {
+         return false;
+      }
+
+      public boolean isTransient()
+      {
+         return false;
+      }
+
+   }
+}



More information about the seam-commits mailing list