[webbeans-commits] Webbeans SVN: r2421 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/bean/ee/jms and 4 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Apr 15 14:36:37 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-04-15 14:36:37 -0400 (Wed, 15 Apr 2009)
New Revision: 2421

Added:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/ConnectionContextual.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/MessageConsumerContextual.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/MessageProducerContextual.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/SessionContextual.java
Removed:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsQueueBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsQueueMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsTopicBean.java
Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractResourceMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceMethodHandler.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceMethodHandler.java
   ri/trunk/spi/pom.xml
   ri/trunk/spi/src/main/java/org/jboss/webbeans/messaging/spi/JmsServices.java
   ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJmsServices.java
   ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJmsServices.java
Log:
Add JMS lifecycle

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceMethodHandler.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractJavaEEResourceMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -16,6 +16,7 @@
  */
 package org.jboss.webbeans.bean.ee;
 
+import java.io.Serializable;
 import java.lang.reflect.Method;
 
 import javassist.util.proxy.MethodHandler;
@@ -30,9 +31,11 @@
  * @author Pete Muir
  *
  */
-public abstract class AbstractJavaEEResourceMethodHandler implements MethodHandler
+public abstract class AbstractJavaEEResourceMethodHandler implements MethodHandler, Serializable
 {
    
+   private static final long serialVersionUID = -3171683636451762591L;
+   
    private static final transient Log log = Logging.getLog(AbstractJavaEEResourceMethodHandler.class);
 
    /**
@@ -63,12 +66,12 @@
     */
    public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
    {
-      Object proxiedInstance = getProxiedInstance();
+      Object proxiedInstance = getProxiedInstance(null);
       Object returnValue = Reflections.invokeAndWrap(method, proxiedInstance, args);
       log.trace("Executed {0} on {1} with parameters {2} and got return value {3}", method, proxiedInstance, args, returnValue);
       return returnValue;
    }
    
-   protected abstract Object getProxiedInstance();
+   protected abstract Object getProxiedInstance(Class<?> declaringClass);
 
 }
\ No newline at end of file

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractResourceMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractResourceMethodHandler.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/AbstractResourceMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -23,6 +23,8 @@
 public abstract class AbstractResourceMethodHandler extends AbstractJavaEEResourceMethodHandler
 {
 
+   private static final long serialVersionUID = 8977780996027839558L;
+   
    private final String mappedName;
    private final String jndiName;
    

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsQueueBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsQueueBean.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsQueueBean.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -1,72 +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.bean.ee;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import javassist.util.proxy.MethodHandler;
-
-import javax.jms.Queue;
-import javax.jms.QueueConnection;
-import javax.jms.QueueSender;
-import javax.jms.QueueSession;
-
-import org.jboss.webbeans.ManagerImpl;
-
-
-/**
- * @author Pete Muir
- *
- */
-public class JmsQueueBean extends AbstractResourceBean<Object>
-{
-   
-   private final String id;
-
-   /**
-    * @param manager
-    * @param deploymentType
-    * @param bindings
-    * @param type
-    */
-   public JmsQueueBean(ManagerImpl manager, Class<? extends Annotation> deploymentType, Set<Annotation> bindings, String jndiName, String mappedName)
-   {
-      super(manager, 
-            deploymentType, 
-            bindings, 
-            null, 
-            jndiName, 
-            mappedName, 
-            Queue.class, QueueConnection.class, QueueSession.class, QueueSender.class);
-      this.id = createId("JmsQueue-");
-   }
-
-   @Override
-   protected MethodHandler newMethodHandler()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   @Override
-   public String getId()
-   {
-      return id;
-   }
-
-}

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsQueueMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsQueueMethodHandler.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsQueueMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -1,43 +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.bean.ee;
-
-
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.messaging.spi.JmsServices;
-
-/**
- * Proxy for persistence unit Java EE web services
- * 
- * @author Pete Muir
- *
- */
-public class JmsQueueMethodHandler extends AbstractResourceMethodHandler
-{
-   
-   public JmsQueueMethodHandler(String jndiName, String mappedName)
-   {
-      super(jndiName, mappedName);
-   }
-
-   @Override
-   protected Object getProxiedInstance()
-   {
-      return CurrentManager.rootManager().getServices().get(JmsServices.class).resolveDestination(getJndiName(), getMappedName());
-   }
-
-}

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsTopicBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsTopicBean.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsTopicBean.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -1,72 +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.bean.ee;
-
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import javassist.util.proxy.MethodHandler;
-
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicPublisher;
-import javax.jms.TopicSession;
-
-import org.jboss.webbeans.ManagerImpl;
-
-
-/**
- * @author Pete Muir
- *
- */
-public class JmsTopicBean extends AbstractResourceBean<Object>
-{
-   
-   private final String id;
-
-   /**
-    * @param manager
-    * @param deploymentType
-    * @param bindings
-    * @param type
-    */
-   public JmsTopicBean(ManagerImpl manager, Class<? extends Annotation> deploymentType, Set<Annotation> bindings, String jndiName, String mappedName)
-   {
-      super(manager, 
-            deploymentType, 
-            bindings, 
-            null, 
-            jndiName, 
-            mappedName, 
-            Topic.class, TopicConnection.class, TopicSession.class, TopicPublisher.class);
-      this.id = createId("JmsQueue-");
-   }
-
-   @Override
-   protected MethodHandler newMethodHandler()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   @Override
-   public String getId()
-   {
-      return id;
-   }
-
-}

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextMethodHandler.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -27,6 +27,8 @@
  */
 public class PersistenceContextMethodHandler extends AbstractJavaEEResourceMethodHandler
 {
+
+   private static final long serialVersionUID = 6111824732958101382L;
    
    private final String unitName;
    
@@ -36,7 +38,7 @@
    }
    
    @Override
-   protected Object getProxiedInstance()
+   protected Object getProxiedInstance(Class<?> declaringClass)
    {
       return CurrentManager.rootManager().getServices().get(JpaServices.class).resolvePersistenceContext(unitName);
    }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitMethodHandler.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceUnitMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -29,6 +29,8 @@
 public class PersistenceUnitMethodHandler extends AbstractJavaEEResourceMethodHandler
 {
    
+   private static final long serialVersionUID = -7936320009903622051L;
+   
    private final String unitName;
    
    public PersistenceUnitMethodHandler(String unitName)
@@ -37,7 +39,7 @@
    }
    
    @Override
-   protected Object getProxiedInstance()
+   protected Object getProxiedInstance(Class<?> declaringClass)
    {
       return CurrentManager.rootManager().getServices().get(JpaServices.class).resolvePersistenceUnit(unitName);
    }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbMethodHandler.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/RemoteEjbMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -28,6 +28,8 @@
  */
 public class RemoteEjbMethodHandler extends AbstractResourceMethodHandler
 {
+
+   private static final long serialVersionUID = 8192691377739747596L;
    
    private final String ejbLink;
    
@@ -38,7 +40,7 @@
    }
 
    @Override
-   protected Object getProxiedInstance()
+   protected Object getProxiedInstance(Class<?> declaringClass)
    {
       return CurrentManager.rootManager().getServices().get(EjbServices.class).resolveRemoteEjb(getJndiName(), getMappedName(), ejbLink);
    }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceMethodHandler.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/ResourceMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -29,13 +29,15 @@
 public class ResourceMethodHandler extends AbstractResourceMethodHandler
 {
    
+   private static final long serialVersionUID = -8835529913294253208L;
+
    public ResourceMethodHandler(String jndiName, String mappedName)
    {
       super(jndiName, mappedName);
    }
 
    @Override
-   protected Object getProxiedInstance()
+   protected Object getProxiedInstance(Class<?> declaringClass)
    {
       return CurrentManager.rootManager().getServices().get(ResourceServices.class).resolveResource(getJndiName(), getMappedName());
    }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceMethodHandler.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/WebServiceMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -29,13 +29,15 @@
 public class WebServiceMethodHandler extends AbstractResourceMethodHandler
 {
    
+   private static final long serialVersionUID = 6719454070840346045L;
+
    public WebServiceMethodHandler(String jndiName, String mappedName)
    {
       super(jndiName, mappedName);
    }
 
    @Override
-   protected Object getProxiedInstance()
+   protected Object getProxiedInstance(Class<?> declaringClass)
    {
       return CurrentManager.rootManager().getServices().get(WebServices.class).resolveResource(getJndiName(), getMappedName());
    }

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/ConnectionContextual.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/ConnectionContextual.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/ConnectionContextual.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -0,0 +1,64 @@
+/*
+ * 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.bean.ee.jms;
+
+import java.io.Serializable;
+
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.inject.ExecutionException;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+
+/**
+ * Contextual in which we can store the connection
+ * 
+ * @author Pete Muir
+ *
+ */
+abstract class ConnectionContextual<T extends Connection> implements Contextual<T>, Serializable
+{
+
+   private static final long serialVersionUID = -4333311257129016113L;
+
+   public T create(CreationalContext<T> creationalContext)
+   {
+      try
+      {
+         return createConnection();
+      }
+      catch (JMSException e)
+      {
+         throw new ExecutionException("Error creating connection ", e);
+      }
+   }
+   
+   protected abstract T createConnection() throws JMSException;
+
+   public void destroy(T instance)
+   {
+      try
+      {
+         instance.close();
+      }
+      catch (JMSException e)
+      {
+         throw new ExecutionException("Error creating connection ", e);
+      }
+   }
+   
+}
\ No newline at end of file


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/ConnectionContextual.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsMethodHandler.java (from rev 2414, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsQueueMethodHandler.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsMethodHandler.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -0,0 +1,140 @@
+/*
+ * 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.bean.ee.jms;
+
+
+
+import java.lang.reflect.Method;
+
+import javax.context.CreationalContext;
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.jboss.webbeans.bean.ee.AbstractResourceMethodHandler;
+import org.jboss.webbeans.context.ApplicationContext;
+import org.jboss.webbeans.context.DependentContext;
+
+/**
+ * JMS method handler that knows how to create a proxy
+ * 
+ * @author Pete Muir
+ *
+ * @param <C> the JMS connection
+ * @param <S> the JMS session
+ * @param <MP> the JMS message producer
+ * @param <MC> the JMS message consumer
+ */
+abstract class JmsMethodHandler<C extends Connection, S extends Session, MP extends MessageProducer, MC extends MessageConsumer> extends AbstractResourceMethodHandler
+{
+   
+   private static final long serialVersionUID = -2598920314236475437L;
+   
+   public JmsMethodHandler(String jndiName, String mappedName)
+   {
+      super(jndiName, mappedName);
+   }
+   
+   @Override
+   public Object invoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
+   {
+      if (method.getName().equals("close"))
+      {
+         throw new UnsupportedOperationException("Cannot call close on a Web Beans managed JMS resource");
+      }
+      return super.invoke(self, method, proceed, args);
+   }
+
+   @Override
+   protected Object getProxiedInstance(Class<?> declaringClass)
+   {
+      if (Connection.class.isAssignableFrom(declaringClass))
+      {
+         return getConnection(getConnectionContextual());
+      }
+      else if (Session.class.isAssignableFrom(declaringClass))
+      {
+         return getSession(getSessionContextual());
+      }
+      else if (MessageConsumer.class.isAssignableFrom(declaringClass))
+      {
+         return getQueueReceiver(getMessageConsumerContextual());
+      }
+      else if (MessageProducer.class.isAssignableFrom(declaringClass))
+      {
+         return getMessageProducer(getMessageProducerContextual());
+      }
+      else
+      {
+         throw new IllegalStateException("Cannot create proxy for " + declaringClass);
+      }
+   }
+   
+   protected abstract ConnectionContextual<C> getConnectionContextual();
+   
+   protected abstract SessionContextual<S> getSessionContextual();
+   
+   protected abstract MessageConsumerContextual<MC> getMessageConsumerContextual();
+   
+   protected abstract MessageProducerContextual<MP> getMessageProducerContextual();
+   
+   protected abstract S createSessionFromConnection(ConnectionContextual<C> connectionContexual);
+   
+   protected C getConnection(ConnectionContextual<C> connectionContexual)
+   {
+      return ApplicationContext.instance().get(connectionContexual, new CreationalContext<C>() 
+      {
+
+         public void push(C incompleteInstance) {}
+         
+      });
+   }
+   
+   private S getSession(SessionContextual<S> sessionContextual)
+   {
+      return DependentContext.instance().get(sessionContextual, new CreationalContext<S>() 
+      {
+
+         public void push(S incompleteInstance) {}
+         
+      });
+   }
+   
+   private MP getMessageProducer(MessageProducerContextual<MP> messageProducerContextual)
+   {
+      return DependentContext.instance().get(messageProducerContextual, new CreationalContext<MP>() 
+      {
+
+         public void push(MP incompleteInstance) {}
+         
+      });
+   }
+   
+   private MC getQueueReceiver(MessageConsumerContextual<MC> messageConsumerContextual)
+   {
+      return DependentContext.instance().get(messageConsumerContextual, new CreationalContext<MC>() 
+      {
+
+         public void push(MC incompleteInstance) {}
+         
+      });
+   }
+   
+
+
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsMethodHandler.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueBean.java (from rev 2414, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsQueueBean.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueBean.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueBean.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -0,0 +1,74 @@
+/*
+ * 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.bean.ee.jms;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javassist.util.proxy.MethodHandler;
+
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.bean.ee.AbstractResourceBean;
+
+
+/**
+ * A bean which represents a JMS queue
+ * 
+ * @author Pete Muir
+ *
+ */
+public class JmsQueueBean extends AbstractResourceBean<Object>
+{
+   
+   private final String id;
+
+   /**
+    * @param manager
+    * @param deploymentType
+    * @param bindings
+    * @param type
+    */
+   public JmsQueueBean(ManagerImpl manager, Class<? extends Annotation> deploymentType, Set<Annotation> bindings, String jndiName, String mappedName)
+   {
+      super(manager, 
+            deploymentType, 
+            bindings, 
+            null, 
+            jndiName, 
+            mappedName, 
+            Queue.class, QueueConnection.class, QueueSession.class, QueueSender.class);
+      this.id = createId("JmsQueue-");
+   }
+
+   @Override
+   protected MethodHandler newMethodHandler()
+   {
+      return new JmsQueueMethodHandler(getJndiName(), getMappedName());
+   }
+
+   @Override
+   public String getId()
+   {
+      return id;
+   }
+
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueMethodHandler.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -0,0 +1,154 @@
+/*
+ * 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.bean.ee.jms;
+
+import javax.inject.ExecutionException;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.messaging.spi.JmsServices;
+
+/**
+ * @author Pete Muir
+ *
+ */
+class JmsQueueMethodHandler extends JmsMethodHandler<QueueConnection, QueueSession, QueueSender, QueueReceiver>
+{
+
+   private static final long serialVersionUID = -1498128944732531956L;
+   
+   private final ConnectionContextual<QueueConnection> connectionContexual;
+   private final SessionContextual<QueueSession> sessionContextual;
+   private final MessageProducerContextual<QueueSender> messageProducerContextual;
+   private final MessageConsumerContextual<QueueReceiver> messageConsumerContextual;
+
+   public JmsQueueMethodHandler(String jndiName, String mappedName)
+   {
+      super(jndiName, mappedName);
+      final JmsServices jmsServices = CurrentManager.rootManager().getServices().get(JmsServices.class);
+      this.connectionContexual = new ConnectionContextual<QueueConnection>()
+      {
+
+         private static final long serialVersionUID = 7830020942920371399L;
+
+         @Override
+         protected QueueConnection createConnection() throws JMSException
+         {
+            return jmsServices.getQueueConnectionFactory().createQueueConnection();
+         }
+
+      };
+      this.sessionContextual = new SessionContextual<QueueSession>()
+      {
+
+         private static final long serialVersionUID = -5964106446504141417L;
+
+         @Override
+         protected QueueSession createSession() throws JMSException
+         {
+            return createSessionFromConnection(connectionContexual);
+         }
+
+      };
+      this.messageProducerContextual = new MessageProducerContextual<QueueSender>()
+      {
+
+         private static final long serialVersionUID = 3215720243380210179L;
+
+         @Override
+         protected QueueSender createMessageProducer() throws JMSException
+         {
+            Queue queue = jmsServices.resolveDestination(getJndiName(), getMappedName());
+            try
+            {
+               return createSessionFromConnection(connectionContexual).createSender(queue);
+            }
+            catch (JMSException e)
+            {
+               throw new ExecutionException("Error creating QueueSender", e);
+            }
+         }
+
+      };
+      this.messageConsumerContextual = new MessageConsumerContextual<QueueReceiver>()
+      {
+
+         private static final long serialVersionUID = -5461921479716229659L;
+
+         @Override
+         protected QueueReceiver createMessageConsumer() throws JMSException
+         {
+            Queue queue = jmsServices.resolveDestination(getJndiName(), getMappedName());
+            try
+            {
+               return createSessionFromConnection(connectionContexual).createReceiver(queue);
+            }
+            catch (JMSException e)
+            {
+               throw new ExecutionException("Error creating QueueReceiver", e);
+            }
+         }
+
+      };
+   }
+
+   @Override
+   protected QueueSession createSessionFromConnection(ConnectionContextual<QueueConnection> connectionContexual)
+   {
+      try
+      {
+         return getConnection(connectionContexual).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+      }
+      catch (JMSException e)
+      {
+         throw new ExecutionException("Error creating session", e);
+      }
+   }
+
+   @Override
+   protected ConnectionContextual<QueueConnection> getConnectionContextual()
+   {
+      return connectionContexual;
+   }
+
+   @Override
+   protected MessageConsumerContextual<QueueReceiver> getMessageConsumerContextual()
+   {
+      return messageConsumerContextual;
+   }
+
+   @Override
+   protected MessageProducerContextual<QueueSender> getMessageProducerContextual()
+   {
+      return messageProducerContextual;
+   }
+
+   @Override
+   protected SessionContextual<QueueSession> getSessionContextual()
+   {
+      return sessionContextual;
+   }
+   
+   
+
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsQueueMethodHandler.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicBean.java (from rev 2414, ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/JmsTopicBean.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicBean.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicBean.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -0,0 +1,74 @@
+/*
+ * 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.bean.ee.jms;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javassist.util.proxy.MethodHandler;
+
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.bean.ee.AbstractResourceBean;
+
+
+/**
+ * A bean which represents a JMS topic
+ * 
+ * @author Pete Muir
+ *
+ */
+public class JmsTopicBean extends AbstractResourceBean<Object>
+{
+   
+   private final String id;
+
+   /**
+    * @param manager
+    * @param deploymentType
+    * @param bindings
+    * @param type
+    */
+   public JmsTopicBean(ManagerImpl manager, Class<? extends Annotation> deploymentType, Set<Annotation> bindings, String jndiName, String mappedName)
+   {
+      super(manager, 
+            deploymentType, 
+            bindings, 
+            null, 
+            jndiName, 
+            mappedName, 
+            Topic.class, TopicConnection.class, TopicSession.class, TopicPublisher.class);
+      this.id = createId("JmsQueue-");
+   }
+
+   @Override
+   protected MethodHandler newMethodHandler()
+   {
+      return new JmsTopicMethodHandler(getJndiName(), getMappedName());
+   }
+
+   @Override
+   public String getId()
+   {
+      return id;
+   }
+
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicBean.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicMethodHandler.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicMethodHandler.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -0,0 +1,158 @@
+/*
+ * 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.bean.ee.jms;
+
+import javax.inject.ExecutionException;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.jms.TopicConnection;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
+import javax.jms.TopicSubscriber;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.messaging.spi.JmsServices;
+
+/**
+ * @author Pete Muir
+ *
+ */
+class JmsTopicMethodHandler extends JmsMethodHandler<TopicConnection, TopicSession, TopicPublisher, TopicSubscriber>
+{
+
+   private static final long serialVersionUID = 5209925842290226027L;
+   
+   private final ConnectionContextual<TopicConnection> connectionContexual;
+   private final SessionContextual<TopicSession> sessionContextual;
+   private final MessageProducerContextual<TopicPublisher> messageProducerContextual;
+   private final MessageConsumerContextual<TopicSubscriber> messageConsumerContextual;
+
+   /**
+    * @param jndiName
+    * @param mappedName
+    */
+   public JmsTopicMethodHandler(String jndiName, String mappedName)
+   {
+      super(jndiName, mappedName);
+      final JmsServices jmsServices = CurrentManager.rootManager().getServices().get(JmsServices.class);
+      this.connectionContexual = new ConnectionContextual<TopicConnection>()
+      {
+
+         private static final long serialVersionUID = 7830020942920371399L;
+
+         @Override
+         protected TopicConnection createConnection() throws JMSException
+         {
+            return jmsServices.getTopicConnectionFactory().createTopicConnection();
+         }
+
+      };
+      this.sessionContextual = new SessionContextual<TopicSession>()
+      {
+
+         private static final long serialVersionUID = -5964106446504141417L;
+
+         @Override
+         protected TopicSession createSession() throws JMSException
+         {
+            return createSessionFromConnection(connectionContexual);
+         }
+
+      };
+      this.messageProducerContextual = new MessageProducerContextual<TopicPublisher>()
+      {
+
+         private static final long serialVersionUID = 3215720243380210179L;
+
+         @Override
+         protected TopicPublisher createMessageProducer() throws JMSException
+         {
+            Topic topic = jmsServices.resolveDestination(getJndiName(), getMappedName());
+            try
+            {
+               return createSessionFromConnection(connectionContexual).createPublisher(topic);
+            }
+            catch (JMSException e)
+            {
+               throw new ExecutionException("Error creating TopicPublisher", e);
+            }
+         }
+
+      };
+      this.messageConsumerContextual = new MessageConsumerContextual<TopicSubscriber>()
+      {
+
+         private static final long serialVersionUID = -5461921479716229659L;
+
+         @Override
+         protected TopicSubscriber createMessageConsumer() throws JMSException
+         {
+            Topic topic = jmsServices.resolveDestination(getJndiName(), getMappedName());
+            try
+            {
+               return createSessionFromConnection(connectionContexual).createSubscriber(topic);
+            }
+            catch (JMSException e)
+            {
+               throw new ExecutionException("Error creating TopicSubscriber", e);
+            }
+         }
+
+      };
+   }
+
+   @Override
+   protected TopicSession createSessionFromConnection(ConnectionContextual<TopicConnection> connectionContexual)
+   {
+      try
+      {
+         return getConnection(connectionContexual).createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+      }
+      catch (JMSException e)
+      {
+         throw new ExecutionException("Error creating session", e);
+      }
+   }
+
+   @Override
+   protected ConnectionContextual<TopicConnection> getConnectionContextual()
+   {
+      return connectionContexual;
+   }
+
+   @Override
+   protected MessageConsumerContextual<TopicSubscriber> getMessageConsumerContextual()
+   {
+      return messageConsumerContextual;
+   }
+
+   @Override
+   protected MessageProducerContextual<TopicPublisher> getMessageProducerContextual()
+   {
+      return messageProducerContextual;
+   }
+
+   @Override
+   protected SessionContextual<TopicSession> getSessionContextual()
+   {
+      return sessionContextual;
+   }
+   
+   
+
+}


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/JmsTopicMethodHandler.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/MessageConsumerContextual.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/MessageConsumerContextual.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/MessageConsumerContextual.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -0,0 +1,58 @@
+/*
+ * 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.bean.ee.jms;
+
+import java.io.Serializable;
+
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.inject.ExecutionException;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+
+abstract class MessageConsumerContextual<T extends MessageConsumer> implements Contextual<T>, Serializable
+{
+
+   private static final long serialVersionUID = -4333311257129016113L;
+
+   public T create(CreationalContext<T> creationalContext)
+   {
+      try
+      {
+         return createMessageConsumer();
+      }
+      catch (JMSException e)
+      {
+         throw new ExecutionException("Error creating connection ", e);
+      }
+   }
+   
+   protected abstract  T createMessageConsumer() throws JMSException;
+
+   public void destroy(T instance)
+   {
+      try
+      {
+         instance.close();
+      }
+      catch (JMSException e)
+      {
+         throw new ExecutionException("Error creating connection ", e);
+      }
+   }
+   
+}
\ No newline at end of file


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/MessageConsumerContextual.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/MessageProducerContextual.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/MessageProducerContextual.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/MessageProducerContextual.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -0,0 +1,58 @@
+/*
+ * 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.bean.ee.jms;
+
+import java.io.Serializable;
+
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.inject.ExecutionException;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+
+abstract class MessageProducerContextual<T extends MessageProducer> implements Contextual<T>, Serializable
+{
+
+   private static final long serialVersionUID = -4333311257129016113L;
+
+   public T create(CreationalContext<T> creationalContext)
+   {
+      try
+      {
+         return createMessageProducer();
+      }
+      catch (JMSException e)
+      {
+         throw new ExecutionException("Error creating connection ", e);
+      }
+   }
+   
+   protected abstract  T createMessageProducer() throws JMSException;
+
+   public void destroy(T instance)
+   {
+      try
+      {
+         instance.close();
+      }
+      catch (JMSException e)
+      {
+         throw new ExecutionException("Error creating connection ", e);
+      }
+   }
+   
+}
\ No newline at end of file


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/MessageProducerContextual.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/SessionContextual.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/SessionContextual.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/SessionContextual.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -0,0 +1,58 @@
+/*
+ * 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.bean.ee.jms;
+
+import java.io.Serializable;
+
+import javax.context.Contextual;
+import javax.context.CreationalContext;
+import javax.inject.ExecutionException;
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+abstract class SessionContextual<T extends Session> implements Contextual<T>, Serializable
+{
+
+   private static final long serialVersionUID = -4333311257129016113L;
+
+   public T create(CreationalContext<T> creationalContext)
+   {
+      try
+      {
+         return createSession();
+      }
+      catch (JMSException e)
+      {
+         throw new ExecutionException("Error creating connection ", e);
+      }
+   }
+   
+   protected abstract  T createSession() throws JMSException;
+
+   public void destroy(T instance)
+   {
+      try
+      {
+         instance.close();
+      }
+      catch (JMSException e)
+      {
+         throw new ExecutionException("Error creating connection ", e);
+      }
+   }
+   
+}
\ No newline at end of file


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ee/jms/SessionContextual.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/spi/pom.xml
===================================================================
--- ri/trunk/spi/pom.xml	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/spi/pom.xml	2009-04-15 18:36:37 UTC (rev 2421)
@@ -52,6 +52,11 @@
       	<artifactId>jsr250-api</artifactId>
       	<optional>true</optional>
       </dependency>
+      
+      <dependency>
+      	<groupId>javax.jms</groupId>
+      	<artifactId>jms</artifactId>
+    	</dependency>
 
    </dependencies>
 

Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/messaging/spi/JmsServices.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/messaging/spi/JmsServices.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/messaging/spi/JmsServices.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -1,6 +1,10 @@
 package org.jboss.webbeans.messaging.spi;
 
 
+import javax.jms.Destination;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.TopicConnectionFactory;
+
 import org.jboss.webbeans.bootstrap.api.Service;
 
 /**
@@ -22,6 +26,10 @@
     * @throws IllegalStateException
     *            if no resource can be resolved for injection
     */
-   public Object resolveDestination(String jndiName, String mappedName);
+   public <T extends Destination> T resolveDestination(String jndiName, String mappedName);
    
+   public QueueConnectionFactory getQueueConnectionFactory();
+   
+   public TopicConnectionFactory getTopicConnectionFactory();
+   
 }
\ No newline at end of file

Modified: ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJmsServices.java
===================================================================
--- ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJmsServices.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/spi/src/test/java/org/jboss/webbeans/bootstrap/api/test/MockJmsServices.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -1,13 +1,28 @@
 package org.jboss.webbeans.bootstrap.api.test;
 
+import javax.jms.Destination;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.TopicConnectionFactory;
+
 import org.jboss.webbeans.messaging.spi.JmsServices;
 
 public class MockJmsServices implements JmsServices
 {
 
-   public Object resolveDestination(String jndiName, String mappedName)
+   public <T extends Destination> T resolveDestination(String jndiName, String mappedName)
    {
       return null;
    }
+   
+   public QueueConnectionFactory getQueueConnectionFactory() 
+   {
+      return null;
+   }
+   
+   public TopicConnectionFactory getTopicConnectionFactory() 
+   {
+      return null;
+   }
+   
 
 }

Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJmsServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJmsServices.java	2009-04-15 17:42:07 UTC (rev 2420)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockJmsServices.java	2009-04-15 18:36:37 UTC (rev 2421)
@@ -16,6 +16,10 @@
  */
 package org.jboss.webbeans.mock;
 
+import javax.jms.Destination;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.TopicConnectionFactory;
+
 import org.jboss.webbeans.messaging.spi.JmsServices;
 
 /**
@@ -24,10 +28,20 @@
  */
 public class MockJmsServices implements JmsServices
 {
-
-   public Object resolveDestination(String jndiName, String mappedName)
+   
+   public QueueConnectionFactory getQueueConnectionFactory() 
    {
+		return null;
+	}
+   
+   public TopicConnectionFactory getTopicConnectionFactory()
+   {
       return null;
    }
+   
+   public <T extends Destination> T resolveDestination(String jndiName, String mappedName)
+   {
+      return null;
+   }
 
 }




More information about the weld-commits mailing list