KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > jms > serverless > GroupConnectionFactory


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.jms.serverless;
8
9 import org.jboss.logging.Logger;
10 import javax.jms.ConnectionFactory JavaDoc;
11 import javax.jms.Connection JavaDoc;
12 import javax.jms.JMSException JavaDoc;
13 import java.net.URL JavaDoc;
14
15 /**
16  *
17  * @author Ovidiu Feodorov <ovidiu@jboss.org>
18  * @version $Revision: 1.1 $ $Date: 2004/04/15 22:54:19 $
19  *
20  **/

21 public class GroupConnectionFactory implements ConnectionFactory JavaDoc {
22
23     private static final Logger log = Logger.getLogger(GroupConnectionFactory.class);
24
25     private String JavaDoc stackConfigFileName;
26
27     public GroupConnectionFactory(String JavaDoc stackConfigFileName) {
28         this.stackConfigFileName = stackConfigFileName;
29     }
30
31     /**
32      * The Connection is stopped, but it is active (ready to send and receive traffic),
33      * which means the method throws an exception if the group cannot be contacted for some
34      * reason.
35      *
36      * @see javax.jms.ConnectionFactory#createConnection()
37      *
38      **/

39     public Connection JavaDoc createConnection() throws JMSException JavaDoc {
40
41         URL JavaDoc url = getClass().getClassLoader().getResource(stackConfigFileName);
42         if (url == null) {
43             String JavaDoc msg =
44                 "The channel configuration file (" + stackConfigFileName + ") not found! "+
45                 "Make sure it is in classpath.";
46             throw new JMSException JavaDoc(msg);
47         }
48
49         GroupConnection c = new GroupConnection(url);
50         c.connect();
51         return c;
52
53     }
54
55     public String JavaDoc toString() {
56         return
57             getClass().getName().toString()+"@"+Integer.toHexString(hashCode())+"["+
58             stackConfigFileName+"]";
59     }
60
61     /**
62      * The Connection is stopped, but it is active (ready to send and receive traffic),
63      * which means the method throws an exception if the group cannot be contacted for some
64      * reason.
65      *
66      * @see javax.jms.ConnectionFactory#createConnection(String, String)
67      **/

68     public Connection JavaDoc createConnection(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc {
69         throw new NotImplementedException();
70     }
71
72 }
73
Popular Tags