|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| JMSConnectionFactory.java | 75% | 100% | 100% | 96% |
|
||||||||||||||
| 1 | /** | |
| 2 | * JTRunner is free software; you can redistribute it and/or modify it under the | |
| 3 | * terms of the GNU General Public License as published by the Free Software | |
| 4 | * Foundation; either version 2, or (at your option) any later version. | |
| 5 | */ | |
| 6 | ||
| 7 | package jtr.config.jms; | |
| 8 | ||
| 9 | import java.io.Serializable; | |
| 10 | import java.util.*; | |
| 11 | ||
| 12 | /** | |
| 13 | * This class is the object oriented representation of the | |
| 14 | * <code>conn-factory</code> element of the <code>jtr.xml</code> | |
| 15 | * configuration file.<br> | |
| 16 | * This class logically maps itself to a | |
| 17 | * <code>javax.jms.ConnectionFactory</code> class.<br> | |
| 18 | * A <code>JMSConnectionFactory</code> holds a moltitude of | |
| 19 | * <code>JMSConnection</code>s. | |
| 20 | * | |
| 21 | * @author Francesco Russo (frusso@dev.java.net) | |
| 22 | * @version 4.0 | |
| 23 | * @since 1.1 | |
| 24 | * @see jtr.config.jms.JMSConnection | |
| 25 | */ | |
| 26 | public class JMSConnectionFactory implements Serializable { | |
| 27 | ||
| 28 | /** | |
| 29 | * Default constructor | |
| 30 | */ | |
| 31 | 1 | public JMSConnectionFactory() { |
| 32 | 1 | connections = new Vector<JMSConnection>(); |
| 33 | } | |
| 34 | ||
| 35 | /** | |
| 36 | * Set the JNDI name for the current JMS connection factory. | |
| 37 | * | |
| 38 | * @param jndi | |
| 39 | * The connection factory JNDI name | |
| 40 | */ | |
| 41 | 3 | public void setJndi(String jndi) { |
| 42 | 3 | this.jndi = jndi; |
| 43 | } | |
| 44 | ||
| 45 | /** | |
| 46 | * Get the JNDI name for the current JMS connection factory. | |
| 47 | * | |
| 48 | * @return The JNDI name | |
| 49 | */ | |
| 50 | 28 | public String getJndi() { |
| 51 | 28 | return jndi; |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * Set the name of the property of the concrete runner that will hold the | |
| 56 | * actual <code>ConnectionFactory</code> instance. | |
| 57 | * | |
| 58 | * @param property | |
| 59 | * The property name | |
| 60 | */ | |
| 61 | 3 | public void setProperty(String property) { |
| 62 | 3 | this.property = property; |
| 63 | } | |
| 64 | ||
| 65 | /** | |
| 66 | * Get the name of the property of the concrete runner that will hold the | |
| 67 | * actual <code>ConnectionFactory</code> instance. | |
| 68 | * | |
| 69 | * @return The property name | |
| 70 | */ | |
| 71 | 14 | public String getProperty() { |
| 72 | 14 | return property; |
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * Add a connection to the set of <code>Connections</code> that should be | |
| 77 | * instantiated using the current <code>ConnectionFactory</code>. | |
| 78 | * | |
| 79 | * @param conn | |
| 80 | * The <code>JMSConnection</code> representing a valid | |
| 81 | * <code>javax.jms.Connection</code> instance | |
| 82 | */ | |
| 83 | 1 | public void addConnection(JMSConnection conn) { |
| 84 | 1 | connections.add(conn); |
| 85 | } | |
| 86 | ||
| 87 | /** | |
| 88 | * Return all the configured connections shaped as a <code>Collection</code> | |
| 89 | * of <code>JMSConnection</code> instances. | |
| 90 | * | |
| 91 | * @return Collection The set of configured <code>JMSConnection</code>s. | |
| 92 | */ | |
| 93 | 14 | public Collection<JMSConnection> getConnections() { |
| 94 | 14 | return connections; |
| 95 | } | |
| 96 | ||
| 97 | /** | |
| 98 | * @see java.lang.Object#toString() | |
| 99 | */ | |
| 100 | 14 | public String toString() { |
| 101 | 14 | String res = "ConnectionFactory: JNDI " + jndi + " - bean property " + property + "\n"; |
| 102 | 14 | if (connections != null) { |
| 103 | 14 | Iterator iter = connections.iterator(); |
| 104 | 14 | while (iter.hasNext()) { |
| 105 | 14 | res = res + iter.next().toString(); |
| 106 | } | |
| 107 | } | |
| 108 | 14 | return res; |
| 109 | } | |
| 110 | ||
| 111 | private String jndi; | |
| 112 | ||
| 113 | private String property; | |
| 114 | ||
| 115 | private Collection<JMSConnection> connections; | |
| 116 | } |
|
||||||||||