KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > walend > somnifugi > SomniDestination


1 package net.walend.somnifugi;
2
3 import java.io.Serializable JavaDoc;
4
5 import java.util.Hashtable JavaDoc;
6
7 import net.walend.somnifugi.channel.Channel;
8 import net.walend.somnifugi.channel.Puttable;
9 import net.walend.somnifugi.channel.ChannelFactory;
10
11 import javax.naming.Context JavaDoc;
12 import javax.naming.NamingException JavaDoc;
13
14 import javax.jms.Destination JavaDoc;
15 import javax.jms.JMSException JavaDoc;
16 import javax.jms.Message JavaDoc;
17
18 /**
19 An SomniDestination is an abstraction for SomniTopics and SomniQueues. It contains one method of interest, createChannel(), which makes Channels.
20
21 @author <a HREF="http://walend.net">David Walend</a> <a HREF="mailto:david@walend.net">david@walend.net</a>
22  */

23
24 public abstract class SomniDestination
25     implements Destination JavaDoc, Serializable JavaDoc
26 {
27     private ChannelFactory<Message JavaDoc> factory;
28
29     private String JavaDoc name;
30
31     private String JavaDoc copyMode = SomniProperties.DEEPCOPY;
32
33     private Context JavaDoc context;
34
35     protected SomniDestination(String JavaDoc name,ChannelFactory<Message JavaDoc> factory,Context JavaDoc context)
36         throws SomniNamingException
37     {
38         try
39         {
40             this.factory = factory;
41             this.name = name;
42             
43             this.context = context;
44
45             Hashtable JavaDoc props = context.getEnvironment();
46             
47             String JavaDoc copyModeKey = SomniProperties.DEFAULT+"."+SomniProperties.COPYMODE;
48             if(props.containsKey(copyModeKey))
49             {
50                 copyMode = (String JavaDoc)props.get(copyModeKey);
51                 SomniLogger.IT.config("Set "+name+" copy mode to "+copyMode);
52             }
53             
54             copyModeKey = name+"."+SomniProperties.COPYMODE;
55             if(props.containsKey(copyModeKey))
56             {
57                 copyMode = (String JavaDoc)props.get(copyModeKey);
58                 SomniLogger.IT.config("Set "+name+" copy mode to "+copyMode);
59             }
60         }
61         catch(NamingException JavaDoc ne)
62         {
63             throw new SomniNamingException(ne);
64         }
65     }
66
67     ChannelFactory<Message JavaDoc> getChannelFactory()
68     {
69         return factory;
70     }
71     
72     Context JavaDoc getContext()
73     {
74         return context;
75     }
76     
77     public String JavaDoc getName()
78     {
79         return name;
80     }
81
82     final String JavaDoc getCopyMode()
83     {
84         return copyMode;
85     }
86 }
87
88 /* Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 David Walend
89 All rights reserved.
90
91 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
92
93 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
94
95 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
96
97 Neither the name of the SomnifugiJMS Project, walend.net, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission from David Walend.
98
99 Credits in redistributions in source or binary forms must include a link to http://somnifugi.sourceforge.net .
100
101 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102 The net.walend.somnifugi.sql92 package is modified code from the openmq project, https://mq.dev.java.net/ , Copyright (c) of Sun, and carries the CDDL license, repeated here: You can obtain a copy of the license at https://glassfish.dev.java.net/public/CDDLv1.0.html. See the License for the specific language governing permissions and limitations under the License.
103
104 =================================================================================
105
106 For more information and the latest version of this software, please see http://somnifugi.sourceforge.net and http://walend.net or email <a HREF="mailto:david@walend.net">david@walend.net</a>.
107  */

108
Popular Tags