Home » apache-openwebbeans-1.0.0-incubating-M3-sources » org.apache.webbeans.sample.jms » [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.sample.jms;
   18   
   19   import javax.enterprise.context.RequestScoped;
   20   import javax.inject.Inject;
   21   import javax.inject.Named;
   22   import javax.jms.JMSException;
   23   import javax.jms.QueueSender;
   24   import javax.jms.QueueSession;
   25   import javax.jms.TextMessage;
   26   
   27   import org.apache.webbeans.sample.bindings.JmsBinding;
   28   
   29   @RequestScoped
   30   @Named("sender")
   31   public class JmsSenderBean
   32   {
   33       private @Inject @JmsBinding QueueSender queueSender;
   34       
   35       private @Inject @JmsBinding QueueSession queueSession;
   36       
   37       private String text;
   38   
   39       public JmsSenderBean()
   40       {
   41           
   42       }
   43       
   44       public String addMessage()
   45       {
   46           try
   47           {
   48               TextMessage message = queueSession.createTextMessage(this.text);
   49               queueSender.send(message);
   50           }
   51           catch (JMSException e)
   52           {
   53               e.printStackTrace();
   54           }
   55           
   56           return null;
   57       }
   58   
   59       /**
   60        * @return the text
   61        */
   62       public String getText()
   63       {
   64           return text;
   65       }
   66   
   67       /**
   68        * @param text the text to set
   69        */
   70       public void setText(String text)
   71       {
   72           this.text = text;
   73       }
   74       
   75       
   76   }

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