jstrachan 01/08/29 03:31:56
Modified: messenger build.xml
messenger/src/java/org/apache/commons/messenger
DefaultMessenger.java JNDISessionFactory.java
MessengerDigester.java SessionFactory.java
Log:
Made SessionFactory take an optional Properties object which makes it easy for
derived SessionFactories to work with things like JNDI and so on.
Revision Changes Path
1.7 +2 -1 jakarta-commons-sandbox/messenger/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/messenger/build.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- build.xml 2001/08/29 08:58:35 1.6
+++ build.xml 2001/08/29 10:31:55 1.7
@@ -1,4 +1,4 @@
-<!-- $Id: build.xml,v 1.6 2001/08/29 08:58:35 jstrachan Exp $ -->
+<!-- $Id: build.xml,v 1.7 2001/08/29 10:31:55 jstrachan Exp $ -->
<project name="messenger" default="test" basedir=".">
<!-- patternset describing files to be copied from the doc directory -->
@@ -163,6 +163,7 @@
<javadoc packagenames="org.*"
sourcepath="${workdir}"
destdir="${dest.doc.api}"
+ classpath="${classpath}"
windowtitle="${Name-Long}"
doctitle="${Name-Long}"
bottom="<small>Copyright &copy; 2001 Apache Software
Foundation. Documenation generated ${TODAY}</small>."
1.2 +4 -3
jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/DefaultMessenger.java
Index: DefaultMessenger.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/DefaultMessenger.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultMessenger.java 2001/08/28 22:38:28 1.1
+++ DefaultMessenger.java 2001/08/29 10:31:55 1.2
@@ -5,10 +5,11 @@
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*
- * $Id: DefaultMessenger.java,v 1.1 2001/08/28 22:38:28 jstrachan Exp $
+ * $Id: DefaultMessenger.java,v 1.2 2001/08/29 10:31:55 jstrachan Exp $
*/
package org.apache.commons.messenger;
+import java.lang.ThreadLocal; // for javadoc
import java.io.Serializable;
import javax.jms.Connection;
@@ -17,11 +18,11 @@
import javax.jms.Session;
/** <p><code>DefaultMessenger</code> is the default implementation of
- * Messenger which uses a {@link java.lang.ThreadLocal} variable
+ * Messenger which uses a {@link ThreadLocal} variable
* to keep the JMS Session that should be used for a given calling thread.</p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class DefaultMessenger extends MessengerSupport {
1.3 +4 -30
jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/JNDISessionFactory.java
Index: JNDISessionFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/JNDISessionFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JNDISessionFactory.java 2001/08/28 22:38:28 1.2
+++ JNDISessionFactory.java 2001/08/29 10:31:55 1.3
@@ -5,7 +5,7 @@
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*
- * $Id: JNDISessionFactory.java,v 1.2 2001/08/28 22:38:28 jstrachan Exp $
+ * $Id: JNDISessionFactory.java,v 1.3 2001/08/29 10:31:55 jstrachan Exp $
*/
package org.apache.commons.messenger;
@@ -24,16 +24,13 @@
* which looks up the ConnectionFactory object from JNDI.</p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class JNDISessionFactory extends SessionFactory {
/** the initial JNDI context used to lookup ConnectionFactory objects */
private Context context;
- /** the properties used to create the initial context */
- private Properties contextProperties;
-
/** the name used to lookup the ConnectionFactory */
private String lookupName = "TopicConnectionFactory";
@@ -64,22 +61,6 @@
this.context = context;
}
- /** Returns the Properties used to create the initial JNDI Context */
- public Properties getContextProperties() {
- if ( contextProperties == null ) {
- contextProperties = createContextProperties();
- }
- return contextProperties;
- }
-
- public void setContextProperties(Properties contextProperties) {
- this.contextProperties = contextProperties;
- }
-
- public void setContextProperty(String name, String value) {
- getContextProperties().setProperty(name, value);
- }
-
// Implementation methods
//-------------------------------------------------------------------------
@@ -101,19 +82,12 @@
* Derived classes may wish to use JNDI to load the ConnectionFactory
*/
protected Context createContext() throws NamingException {
- if ( contextProperties != null ) {
- return new InitialContext( contextProperties );
+ if ( properties != null ) {
+ return new InitialContext( properties );
}
else {
return new InitialContext();
}
- }
-
- /** Factory method used to create the initial JNDI context properties.
- * Derived classes may wish to overload this method to provide different
properties
- */
- protected Properties createContextProperties() {
- return System.getProperties();
}
}
1.2 +7 -32
jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerDigester.java
Index: MessengerDigester.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerDigester.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MessengerDigester.java 2001/08/28 22:38:28 1.1
+++ MessengerDigester.java 2001/08/29 10:31:55 1.2
@@ -5,7 +5,7 @@
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*
- * $Id: MessengerDigester.java,v 1.1 2001/08/28 22:38:28 jstrachan Exp $
+ * $Id: MessengerDigester.java,v 1.2 2001/08/29 10:31:55 jstrachan Exp $
*/
package org.apache.commons.messenger;
@@ -14,7 +14,7 @@
* that JMS Messengers can be created from an XML config file.</p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class MessengerDigester extends DigesterSupport {
@@ -49,6 +49,10 @@
addSetNext( "manager/messenger/factory", "setSessionFactory",
"org.apache.commons.messenger.SessionFactory"
);
+ addCallMethod( "manager/messenger/factory/property", "addProperty", 2);
+ addCallParam( "manager/messenger/factory/property/name", 0 );
+ addCallParam( "manager/messenger/factory/property/value", 1 );
+
addObjectCreate( "manager/messenger/jndi", jndiSessionFactory, "className"
);
addSetProperties( "manager/messenger/jndi" );
@@ -57,37 +61,8 @@
"org.apache.commons.messenger.SessionFactory"
);
- addCallMethod( "manager/messenger/jndi/property", "setContextProperty", 2);
+ addCallMethod( "manager/messenger/jndi/property", "addProperty", 2);
addCallParam( "manager/messenger/jndi/property/name", 0 );
addCallParam( "manager/messenger/jndi/property/value", 1 );
-
-
-/*
- addObjectCreate( "manager/messenger/exceptionStategy",
exceptionStrategyClass, "className" );
- addSetNext( "manager/messenger/exceptionStategy", "setExceptionStrategry",
- "com.spirit.cache.spi.ExceptionStrategy"
- );
-
- addObjectCreate( "manager/messenger/keyPolicy", cacheEntryFactoryClass,
"className" );
- addSetNext( "manager/messenger/keyPolicy", "setCacheEntryFactory",
- "com.spirit.cache.spi.CacheEntryFactory"
- );
-
- addObjectCreate( "manager/messenger/store", storeClass, "className" );
- addCallMethod( "manager/messenger/store/maximumSize", "setMaximumSize", 0,
new Class[] { Integer.TYPE } );
- addCallMethod( "manager/messenger/store/evictionPolicy",
"setEvictionPolicyType", 0 );
-
- addSetNext( "manager/messenger/store", "setStore",
- "com.spirit.cache.spi.Store"
- );
-
- addObjectCreate( "manager/messenger/connector", connectorClass, "className"
);
- addCallMethod( "manager/messenger/connector/connectionFactory",
"setConnectionFactory", 0 );
- addCallMethod( "manager/messenger/connector/subject", "setSubject", 0 );
-
- addSetNext( "manager/messenger/connector", "addConnector",
- "com.spirit.cache.connector.Connector"
- );
-*/
}
}
1.4 +28 -2
jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/SessionFactory.java
Index: SessionFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/SessionFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SessionFactory.java 2001/08/28 22:38:28 1.3
+++ SessionFactory.java 2001/08/29 10:31:55 1.4
@@ -5,11 +5,12 @@
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*
- * $Id: SessionFactory.java,v 1.3 2001/08/28 22:38:28 jstrachan Exp $
+ * $Id: SessionFactory.java,v 1.4 2001/08/29 10:31:55 jstrachan Exp $
*/
package org.apache.commons.messenger;
import java.io.Serializable;
+import java.util.Properties;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
@@ -26,7 +27,7 @@
* a JMS ConnectionFactory instance to create the JMS Connection lazily</p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class SessionFactory {
@@ -42,6 +43,8 @@
private String username;
/** the optional password used when creating a new JMS connection via a JMS
ConnectionFactory */
private String password;
+ /** the properties used to create the connection */
+ protected Properties properties;
@@ -124,6 +127,22 @@
this.password = password;
}
+ /** Returns the Properties that can be used to configure the connection
creation */
+ public Properties getProperties() {
+ if ( properties == null ) {
+ properties = createProperties();
+ }
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+ public void addProperty(String name, String value) {
+ getProperties().setProperty(name, value);
+ }
+
// Implementation methods
//-------------------------------------------------------------------------
@@ -176,6 +195,13 @@
*/
protected ConnectionFactory createConnectionFactory() throws JMSException {
return null;
+ }
+
+ /** Factory method used to create the initial JNDI context properties.
+ * Derived classes may wish to overload this method to provide different
properties
+ */
+ protected Properties createProperties() {
+ return System.getProperties();
}
}