Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.jms.component » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    * 
    9    *       http://www.apache.org/licenses/LICENSE-2.0
   10    * 
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   package org.apache.webbeans.jms.component;
   18   
   19   import java.lang.annotation.Annotation;
   20   
   21   import javax.jms.Queue;
   22   import javax.jms.QueueConnection;
   23   import javax.jms.QueueReceiver;
   24   import javax.jms.QueueSender;
   25   import javax.jms.QueueSession;
   26   import javax.jms.Topic;
   27   import javax.jms.TopicConnection;
   28   import javax.jms.TopicPublisher;
   29   import javax.jms.TopicSession;
   30   import javax.jms.TopicSubscriber;
   31   
   32   import org.apache.webbeans.annotation.DependentScopeLiteral;
   33   import org.apache.webbeans.annotation.StandardLiteral;
   34   import org.apache.webbeans.jms.JMSModel;
   35   import org.apache.webbeans.jms.JMSModel.JMSType;
   36   import org.apache.webbeans.util.Asserts;
   37   
   38   public final class JmsComponentFactory
   39   {
   40       private static JmsComponentFactory instance = new JmsComponentFactory();
   41   
   42       private JmsComponentFactory()
   43       {
   44           
   45       }
   46       
   47       public static JmsComponentFactory getJmsComponentFactory()
   48       {
   49           return instance;
   50       }
   51       
   52       public <T> JmsBean<T> getJmsComponent(JMSModel model)
   53       {
   54           Asserts.assertNotNull(model,"model parameter can not be null");
   55           
   56           JmsBean<T> component = new JmsBean<T>(model);
   57           
   58           if(model.getJmsType().equals(JMSType.QUEUE))
   59           {
   60               component.addApiType(Queue.class);
   61               component.addApiType(QueueConnection.class);
   62               component.addApiType(QueueSession.class);
   63               component.addApiType(QueueSender.class);
   64               component.addApiType(QueueReceiver.class);
   65           }
   66           else
   67           {
   68               component.addApiType(Topic.class);
   69               component.addApiType(TopicConnection.class);
   70               component.addApiType(TopicSession.class);
   71               component.addApiType(TopicPublisher.class);
   72               component.addApiType(TopicSubscriber.class);
   73           }
   74           
   75           component.setImplScopeType(new DependentScopeLiteral());
   76           component.setType(new StandardLiteral());
   77           
   78           Annotation[] anns = model.getBindings();
   79           
   80           for(Annotation a : anns)
   81           {
   82               component.addQualifier(a);
   83           }
   84           
   85           return component;
   86       }
   87   }

Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.jms.component » [javadoc | source]