commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/messenger/src/webapp/conf web.xml
Date Tue, 26 Feb 2002 04:12:53 GMT
jstrachan    02/02/25 20:12:53

  Modified:    messenger PROPOSAL.html STATUS.html TODO.txt
                        build.properties.sample build.xml
               messenger/src/conf Messenger.xml test-connections.xml
               messenger/src/java/org/apache/commons/messagelet
                        ManagerServlet.java
               messenger/src/java/org/apache/commons/messenger
                        DefaultMessenger.java InitMessengerServlet.java
                        JNDISessionFactory.java Messenger.java
                        MessengerManager.java MessengerSupport.java
                        SessionFactory.java
               messenger/src/webapp/conf web.xml
  Added:       messenger RELEASE-NOTES.txt
               messenger/src/conf sampleMessage.txt
  Log:
  Updated to use commons-logging. Added release notes and upgraded the build.xml to the current commons template. Added Anil's patches for new methods. Also added new Ant targets for testing Messenger and messagelets
  
  Revision  Changes    Path
  1.8       +2 -3      jakarta-commons-sandbox/messenger/PROPOSAL.html
  
  Index: PROPOSAL.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/PROPOSAL.html,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PROPOSAL.html	15 Feb 2002 11:50:18 -0000	1.7
  +++ PROPOSAL.html	26 Feb 2002 04:12:52 -0000	1.8
  @@ -39,8 +39,8 @@
   production deployment along with the JMS API, JNDI API and the Servlet API.
   </p>
   
  -<p><em>Messenger</em> also uses the Jakarta Digester package, 
  -which is also dependent on the Jakarta Collections and BeanUtils packages.
  +<p><em>Messenger</em> also uses the Jakarta Digester package, which is also 
  +dependent on the Jakarta Collections, BeanUtils and Logging packages.
   </p>
   
   <p>Messsenger utilizes the JUnit unit testing framework for
  @@ -87,7 +87,6 @@
   
   <h3>(4) Initial Committers</h3>
   <ul>
  -   <li>Colin Crist</li>
      <li>James Strachan</li>
      <li>Saimon Moore</li>
   </ul>
  
  
  
  1.9       +14 -7     jakarta-commons-sandbox/messenger/STATUS.html
  
  Index: STATUS.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/STATUS.html,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- STATUS.html	15 Feb 2002 11:50:18 -0000	1.8
  +++ STATUS.html	26 Feb 2002 04:12:52 -0000	1.9
  @@ -7,7 +7,7 @@
   
   <div align="center">
   <h1>The Jakarta Commons <em>Messenger</em> Package</h1>
  -$Id: STATUS.html,v 1.8 2002/02/15 11:50:18 jstrachan Exp $<br>
  +$Id: STATUS.html,v 1.9 2002/02/26 04:12:52 jstrachan Exp $<br>
   <a href="#Introduction">[Introduction]</a>
   <a href="#Dependencies">[Dependencies]</a>
   <a href="#Release Info">[Release Info]</a>
  @@ -48,13 +48,14 @@
   <ul>
   <li><a href="http://java.sun.com/j2se">Java Development Kit</a>
       (Version 1.2 or later)</li>
  -<li><a href="http://jakarta.apache.org/commons/digester.html">
  -  Jakarta Commons Digester (version 1.1.1 or later)</a></li>
   <li><a href="http://jakarta.apache.org/commons/beanutils.html">
     Jakarta Commons BeanUtils</a></li>
  -<li><a href="http://jakarta.apache.org/commons/collections.html">
  -  Jakarta Commons Collections</a>
  +<li><a href="http://jakarta.apache.org/commons/collections.html">Jakarta Commons Collections</a>
       (Version 1.1 or later)</li>
  +<li><a href="http://jakarta.apache.org/commons/digester.html">
  +  Jakarta Commons Digester (version 1.1.1 or later)</a></li>
  +<li><a href="http://jakarta.apache.org/commons/logging.html">Jakarta Commons 
  +Logging</a></li>
   <li><a href="http://java.sun.com/products/jms">JMS</a>
       (Version 1.0.2b or later)</li>
   <li><a href="http://java.sun.com/products/servlet">Servlet</a>
  @@ -94,7 +95,6 @@
   projects are encouraged to collaborate on the future development of this
   component to ensure that it continues to meet a variety of needs.</p>
   <ul>
  -   <li><a href="mailto:ccrist@apache.org">Colin Crist</a></li>
      <li><a href="mailto:jstrachan@apache.org">James Strachan</a></li>
      <li>Saimon Moore</li>
   </ul>
  @@ -111,7 +111,14 @@
     </tr>
   
     <tr>
  -    <td><strong>Improved configuration</strong>.  Support more flexible configuration support.</td>
  +    <td><strong>More config files</strong>.  More configuration files for common 
  +    JMS providers would be great.</td>
  +    <td align="center">&nbsp;</td>
  +  </tr>
  +
  +  <tr>
  +    <td><b>More examples</b>. More examples might be good - maybe a chat 
  +    application or whatever.</td>
       <td align="center">&nbsp;</td>
     </tr>
   
  
  
  
  1.7       +7 -7      jakarta-commons-sandbox/messenger/TODO.txt
  
  Index: TODO.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/TODO.txt,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TODO.txt	19 Dec 2001 18:16:25 -0000	1.6
  +++ TODO.txt	26 Feb 2002 04:12:52 -0000	1.7
  @@ -13,6 +13,13 @@
     </subscribe>
   
   * Maybe Ant tasks to generate messages from <fileSets> or something?
  +	- would require some XML based notation for specifying messages?
  +	- maybe using the Jelly scripting engine might be better, where a Jelly
  +		script creates the message, maybe in a loop from some XML data file?
  +
  +* file based JMS test harness for testing JMS networks? Firing in batches of
  +  messages to certain JMS connections, via a test agent, then outputtting messages
  +  to some directory, allowing JUnit style testing.
   
   * write JMSServlet such that
     HTTP GET -> Messenger.receive();
  @@ -20,12 +27,5 @@
   
   * consider Messenger based appender for log4j.
   
  -* file based JMS test harness for testing JMS networks? Firing in batches of
  -  messages to certain JMS connections, via a test agent, then outputtting messages
  -  to some directory, allowing JUnit style testing.
  -
  -* Messenger taglib, allowing JMS messages to be sent & received from JSP.
  -
   * a Messenger based JAXM provider, allowing SOAP messages to be sent over JMS.
  -
   
  
  
  
  1.14      +3 -0      jakarta-commons-sandbox/messenger/build.properties.sample
  
  Index: build.properties.sample
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/build.properties.sample,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- build.properties.sample	13 Feb 2002 13:56:34 -0000	1.13
  +++ build.properties.sample	26 Feb 2002 04:12:52 -0000	1.14
  @@ -15,6 +15,9 @@
   # jakarta commons-beanutils.jar
   commons-beanutils.jar=../../jakarta-commons/beanutils/dist/commons-beanutils.jar
   
  +# jakarta commons-logging.jar
  +commons-logging.jar=../../jakarta-commons/logging/dist/commons-logging.jar
  +
   
   
   #
  
  
  
  1.24      +399 -261  jakarta-commons-sandbox/messenger/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/build.xml,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- build.xml	19 Dec 2001 18:16:25 -0000	1.23
  +++ build.xml	26 Feb 2002 04:12:52 -0000	1.24
  @@ -1,236 +1,344 @@
  -<!-- $Id: build.xml,v 1.23 2001/12/19 18:16:25 jstrachan Exp $ -->
  -<project name="messenger" default="test" basedir=".">
  +<project name="messenger" default="compile" basedir=".">
   
  -   <!-- patternset describing files to be copied from the doc directory -->
  -   <patternset id="patternset-doc"/>
   
  -   <!-- patternset describing test classes -->
  -   <patternset id="patternset-test-classes">
  -      <include name="**/Test*.class"/>
  -   </patternset>
  +<!--
  +        "messenger" component of the Jakarta Commons Subproject
  +        $Id: build.xml,v 1.24 2002/02/26 04:12:52 jstrachan Exp $
  +-->
   
  -   <!-- patternset describing non test classes -->
  -   <patternset id="patternset-non-test-classes">
  -      <include name="**/*.class"/>
  -      <exclude name="**/Test*.class"/>
  -   </patternset>
   
  -   <!-- patternset describing non test source files (*.java, *html, etc.) -->
  -   <patternset id="patternset-javadocable-sources">
  -      <include name="**/*"/>
  -      <exclude name="**/Test*.java"/>
  -   </patternset>
  +<!-- ========== Initialize Properties ===================================== -->
   
  -   <!-- patternset describing config files -->
  -   <patternset id="patternset-config-files">
  -      <include name="**/*.xml"/>
  -   </patternset>
   
  -   <!-- ######################################################### -->
  +  <property file="build.properties"/>                <!-- Component local   -->
  +  <property file="../build.properties"/>             <!-- Commons local     -->
  +  <property file="${user.home}/build.properties"/>   <!-- User local        -->
   
  -   <target name="init">
  -      <tstamp/>
   
  -      <!-- read properties from the build.properties, if any -->
  -      <property name="component-propfile" value="${basedir}/build.properties"/>
  -      <property file="${component-propfile}"/>
  +<!-- ========== External Dependencies ===================================== -->
   
  -      <!-- read properties from the commons build.properties, if any -->
  -      <property name="commons-propfile" value="${basedir}/../build.properties"/>
  -      <property file="${commons-propfile}"/>
   
  -      <!-- read properties from the ${user.home}/propfile, if any -->
  -      <property name="user-propfile" value="${user.home}/build.properties"/>
  -      <property file="${user-propfile}"/>
  +  <!-- The directory containing your binary distribution of JUnit,
  +       version 3.7 or later -->
  +  <property name="junit.home"              value="/usr/local/junit3.7"/>
   
  +  <!-- The directories corresponding to your necessary dependencies -->
  +  <property name="jaxp.home"               value="/usr/local/jaxp1.1"/>
  +  <property name="jdk.home"                value="/usr/local/jdk1.3"/>
  +  <property name="commons.home"            value="../../jakarta-commons"/>
  +  <property name="beanutils.home"          value="${commons.home}/beanutils"/>
  +  <property name="collections.home"        value="${commons.home}/collections"/>
  +  <property name="logging.home"            value="${commons.home}/logging"/>
  +  <property name="digester.home"           value="${commons.home}/digester"/>
   
  -      <!-- command line classpath, if any -->
  -      <property name="cp" value=""/>
  +  <property name="j2sdkee"                 value="/j2sdkee1.3"/>
   
  -      <property name="j2ee.jar" value="${j2sdkee}/lib/j2ee.jar"/>
  +  <property name="messenger.xml"           value="src/conf/Messenger.xml"/>
  +  <property name="jms.classes.dir"         value="jms/classes"/>
  +  <property name="jms.lib.dir"             value="jms/lib"/>
   
  -      <property name="name" value="messenger"/>
  -      <property name="Name" value="Commons Messenger"/>
  -      <property name="Name-Long" value="Jakarta Commons Messenger Package"/>
   
  -      <!-- The current version number of this component -->
  -      <property name="component.version"       value="1.0-dev"/>
  +<!-- ========== Derived Values ============================================ -->
   
  -      <property name="test.entry" value="org.apache.commons.messenger.TestAll"/>
  -      <property name="test.failonerror" value="true" />
  -      <property name="test.runner" value="junit.textui.TestRunner" />
   
  -      <property name="workdir" value="${java.io.tmpdir}/buildtemp_${DSTAMP}${TSTAMP}"/>
  +  <!-- The locations of necessary jar files -->
  +  <property name="junit.jar"               value="${junit.home}/junit.jar"/>
  +  <property name="jdk.api"                 value="${jdk.home}/docs/api"/>
  +  <property name="j2ee.api"                value="${j2sdkee}/lib/j2ee.jar"/>
  +  <property name="j2ee.jar"                value="${j2sdkee}/doc/api"/>
  +  <property name="jaxp.jaxp.jar"           value="${jaxp.home}/jaxp.jar"/>
  +  <property name="jaxp.parser.jar"         value="${jaxp.home}/crimson.jar"/>
  +  <property name="jaxp.api"                value="${jaxp.home}/docs/api"/>
  +  <property name="commons-beanutils.api"   value="${beanutils.home}/dist/docs/api"/>
  +  <property name="commons-beanutils.jar"   value="${beanutils.home}/dist/commons-beanutils.jar"/>
  +  <property name="commons-collections.api" value="${collections.home}/dist/docs/api"/>
  +  <property name="commons-collections.jar" value="${collections.home}/dist/commons-collections.jar"/>
  +  <property name="commons-logging.api"     value="${logging.home}/dist/docs/api"/>
  +  <property name="commons-logging.jar"     value="${logging.home}/dist/commons-logging.jar"/>
  +  <property name="commons-digester.api"    value="${digester.home}/dist/docs/api"/>
  +  <property name="commons-digester.jar"    value="${digester.home}/dist/commons-digester.jar"/>
   
  -      <property name="source" value="${basedir}"/>
  -      <property name="source.src" value="${basedir}/src"/>
  -      <property name="source.src.conf" value="${source.src}/conf"/>
  -      <property name="source.src.java" value="${source.src}/java"/>
  -      <property name="source.src.test" value="${source.src}/test"/>
  -      <property name="source.doc" value="${basedir}/doc"/>
  -      <property name="webapp.dir" value="${source.src}/webapp"/>
  -      <property name="dest" value="${basedir}/dist"/>
  -      <property name="dest.classes" value="${dest}/classes"/>
  -      <property name="dest.doc" value="${dest}/doc"/>
  -      <property name="dest.doc.api" value="${dest.doc}/api"/>
  -      <property name="dest.jardir" value="${dest}"/>
  -      <property name="dest.jardir.jar" value="${dest.jardir}/commons-${name}.jar"/>
  -      <property name="dest.jmsri.jardir" value="../../lib"/>
  -      <property name="dest.jmsri.jardir.jar" value="${dest.jmsri.jardir}/jms-ri.jar"/>
  -      <property name="javadoc-website-dir" value="../../jakarta-commons/docs/${name}/api"/>
  -      <property name="build.webapp" value="${webapp.dir}/web/WEB-INF"/>
  +<!-- ========== Component Declarations ==================================== -->
   
  -      <available property="available-doc" file="${source.doc}"/> <!-- does this module have docs? -->
  -      <available property="available-src-java" file="${source.src.java}"/> <!-- does this module have java src? -->
  -      <available property="available-src-test" file="${source.src.test}"/> <!-- does this module have test src? -->
   
  +  <!-- The name of this component -->
  +  <property name="component.name"          value="messenger"/>
   
  -      <!-- default properties which can be overridden -->
  -      <property name="messenger.xml" value="${source.src.conf}/Messenger.xml"/>
  -      <property name="jms.classes.dir" value="${workdir}/jms/classes"/>
  -      <property name="jms.lib.dir" value="${workdir}/jms/lib"/>
  +  <!-- The primary package name of this component -->
  +  <property name="component.package"       value="org.apache.commons.messenger"/>
   
  -      <!-- now combine the classpaths -->
  -      <property name="classpath" value="${cp}:${jms.jar}:${servlet.jar}:${commons-digester.jar}:${commons-collections.jar}:${commons-beanutils.jar}"/>
  +  <!-- The title of this component -->
  +  <property name="component.title"         value="Messenger: JMS Framework"/>
   
  -      <!-- classpath for unit tests -->
  -      <property name="test.classpath" value="${cp}:${j2ee.jar}:${j2sdkee}/lib/local}:${junit.jar}:${commons-digester.jar}:${commons-collections.jar}:${commons-beanutils.jar}"/>
  +  <!-- The current version number of this component -->
  +  <property name="component.version"       value="1.0-dev"/>
   
  -   </target>
  +  <!-- The base directory for compilation targets -->
  +  <property name="build.home"              value="target"/>
   
  -   <!-- ######################################################### -->
  +  <!-- The base directory for component configuration files -->
  +  <property name="conf.home"               value="src/conf"/>
   
  -   <target name="clean" depends="clean-dist,clean-build,clean-doc" description="removes generated files">
  -      <delete dir="${dest}"/>
  -   </target>
  +  <!-- The base directory for distribution targets -->
  +  <property name="dist.home"               value="dist"/>
   
  -   <target name="clean-doc" depends="init,clean-javadoc">
  -      <delete dir="${dest.doc}"/>
  -   </target>
  +  <!-- The base directory for component sources -->
  +  <property name="source.home"             value="src/java"/>
   
  -   <target name="clean-javadoc" depends="init">
  -      <delete dir="${dest.doc.api}"/>
  -   </target>
  +  <!-- The base directory for unit test sources -->
  +  <property name="test.home"               value="src/test"/>
   
  -   <target name="clean-build" depends="init">
  -      <delete dir="${dest.classes}"/>
  -      <delete dir="${build.webapp}"/>
  -   </target>
  +  <!-- The base directory for the example web app -->
  +  <property name="webapp.dir"              value="src/webapp"/>
   
  -   <target name="clean-dist" depends="init">
  -      <delete file="${dest.jardir.jar}"/>
  -   </target>
  +  <!-- The build directory for the web app -->
  +  <property name="build.webapp"            value="${webapp.dir}/web/WEB-INF"/>
   
  -   <!-- ######################################################### -->
  +<!-- ========== Compiler Defaults ========================================= -->
   
  -   <target name="doc" depends="init,doc-top,doc-copy,doc-javadoc" description="generates javadocs and other documentation">
  -   </target>
   
  -   <target name="doc-top" depends="init">
  -      <mkdir  dir="${dest}"/>
  -      <copy todir="${dest}" file="../LICENSE"/>
  -   </target>
  +  <!-- Should Java compilations set the 'debug' compiler option? -->
  +  <property name="compile.debug"           value="true"/>
   
  -   <target name="doc-copy" depends="init" if="available-doc">
  -<!--
  -      <mkdir dir="${dest.xdocs}"/>
  -      <copy todir="${dest.xdocs}">
  -        <fileset dir="${source.xdocs}">
  -          <patternset refid="patternset-doc"/>
  -        </fileset>
  -      </copy>
  --->
  -      <copy todir="${dest.doc}">
  -        <fileset dir="${source.doc}">
  -          <patternset refid="patternset-doc"/>
  -        </fileset>
  -      </copy>
  -   </target>
  +  <!-- Should Java compilations set the 'deprecation' compiler option? -->
  +  <property name="compile.deprecation"     value="false"/>
   
  -<!--
  -   <target name="doc-html" depends="init" if="available-doc">
  -    <style    
  -      basedir="${source.xdocs}" 
  -      destdir="${source.doc}" 
  -      style="site.xsl"
  -      includes="**/*.xml"
  -      excludes="project.xml"/>
  -   </target>
  --->
  +  <!-- Should Java compilations set the 'optimize' compiler option? -->
  +  <property name="compile.optimize"        value="true"/>
  +
  +  <!-- Construct compile classpath -->
  +  <path id="compile.classpath">
  +    <pathelement location="${build.home}/classes"/>
  +    <pathelement location="${jaxp.jaxp.jar}"/>
  +    <pathelement location="${jaxp.parser.jar}"/>
  +    <pathelement location="${servlet.jar}"/>
  +    <pathelement location="${jms.jar}"/>
  +    <pathelement location="${commons-beanutils.jar}"/>
  +    <pathelement location="${commons-collections.jar}"/>
  +    <pathelement location="${commons-logging.jar}"/>
  +    <pathelement location="${commons-digester.jar}"/>
  +  </path>
  +
  +
  +<!-- ========== Test Execution Defaults =================================== -->
  +
  +
  +  <!-- Construct unit test classpath -->
  +  <path id="test.classpath">
  +    <pathelement location="${build.home}/classes"/>
  +    <pathelement location="${build.home}/tests"/>
  +    <pathelement location="${servlet.jar}"/>
  +    <pathelement location="${jms.jar}"/>
  +    <pathelement location="${jaxp.jaxp.jar}"/>
  +    <pathelement location="${jaxp.parser.jar}"/>
  +    <pathelement location="${commons-beanutils.jar}"/>
  +    <pathelement location="${commons-collections.jar}"/>
  +    <pathelement location="${commons-logging.jar}"/>
  +    <pathelement location="${commons-digester.jar}"/>
  +    <pathelement location="${junit.jar}"/>
  +    <pathelement location="${j2ee.jar}"/>
  +    <pathelement location="${j2sdkee}/lib/local"/>
  +
  +    <!-- not sure why this is needed - something to do with JNDI I think -->
  +    <!-- if this is missing then the JNDI initial context fails for some reason -->
  +    <pathelement path="${java.class.path}"/>
  +  </path>
  +
  +  <!-- Running sample programs against the configured JMS provider -->
  +  <path id="jms.classpath">
  +    <pathelement location="${build.home}/classes"/>
  +    <pathelement location="${build.home}/tests"/>
  +    <pathelement location="${servlet.jar}"/>
  +    <pathelement location="${jms.jar}"/>
  +    <pathelement location="${jaxp.jaxp.jar}"/>
  +    <pathelement location="${jaxp.parser.jar}"/>
  +    <pathelement location="${commons-beanutils.jar}"/>
  +    <pathelement location="${commons-collections.jar}"/>
  +    <pathelement location="${commons-logging.jar}"/>
  +    <pathelement location="${commons-digester.jar}"/>
  +
  +    <!-- add the JARs required for a pluggable JMS provider -->
  +    <pathelement path="${jms.classes.dir}"/>
  +    <fileset dir="${jms.lib.dir}">
  +      <include name="**/*.jar"/>
  +    </fileset>
  +  </path>
  +
  +  <!-- Should all tests fail if one does? -->
  +  <property name="test.failonerror"        value="true"/>
  +
  +  <!-- The test runner to execute -->
  +  <property name="test.runner"             value="junit.textui.TestRunner"/>
  +
  +
  +<!-- ========== Executable Targets ======================================== -->
  +
  +
  +  <target name="init"
  +   description="Initialize and evaluate conditionals">
  +    <echo message="-------- ${component.name} ${component.version} --------"/>
  +    <filter  token="name"                  value="${component.name}"/>
  +    <filter  token="package"               value="${component.package}"/>
  +    <filter  token="version"               value="${component.version}"/>
  +  </target>
  +
  +
  +  <target name="prepare" depends="init"
  +   description="Prepare build directory">
  +    <mkdir dir="${build.home}"/>
  +    <mkdir dir="${build.home}/classes"/>
  +    <mkdir dir="${build.home}/conf"/>
  +    <mkdir dir="${build.home}/tests"/>
  +  </target>
  +
  +
  +  <target name="static" depends="prepare"
  +   description="Copy static files to build directory">
  +    <tstamp/>
  +    <copy  todir="${build.home}/conf" filtering="on">
  +      <fileset dir="${conf.home}" includes="*.MF"/>
  +    </copy>
  +  </target>
  +
  +
  +  <target name="compile" depends="static"
  +   description="Compile shareable components">
  +    <javac  srcdir="${source.home}"
  +           destdir="${build.home}/classes"
  +             debug="${compile.debug}"
  +       deprecation="${compile.deprecation}"
  +          optimize="${compile.optimize}">
  +      <classpath refid="compile.classpath"/>
  +    </javac>
  +    <copy    todir="${build.home}/classes" filtering="on">
  +      <fileset dir="${source.home}" excludes="**/*.java"/>
  +    </copy>
  +  </target>
  +
  +
  +  <target name="compile.tests" depends="compile"
  +   description="Compile unit test cases">
  +    <javac  srcdir="${test.home}"
  +           destdir="${build.home}/tests"
  +             debug="${compile.debug}"
  +       deprecation="${compile.deprecation}"
  +          optimize="${compile.optimize}">
  +      <classpath refid="test.classpath"/>
  +    </javac>
  +    <copy    todir="${build.home}/tests" filtering="on">
  +      <fileset dir="${test.home}" excludes="**/*.java"/>
  +    </copy>
  +  </target>
  +
  +
  +  <target name="clean"
  +   description="Clean build and distribution directories">
  +    <delete    dir="${build.home}"/>
  +    <delete    dir="${dist.home}"/>
  +    <delete    dir="${build.webapp}"/>
  +  </target>
  +
  +
  +  <target name="all" depends="clean,compile"
  +   description="Clean and compile all components"/>
   
  -   <target name="doc-javadoc" depends="init" if="available-src-java">
  -      <!-- copy all the non-test sources out to the work directory and javadoc that -->
  -      <mkdir dir="${workdir}"/>
  -      <copy todir="${workdir}">
  -        <fileset dir="${source.src.java}">
  -          <patternset refid="patternset-javadocable-sources"/>
  -        </fileset>
  -      </copy>
  -      <mkdir dir="${dest.doc.api}"/>
  -      <javadoc packagenames="org.*"
  -               sourcepath="${workdir}"
  -               destdir="${dest.doc.api}"
  -               classpath="${classpath}"
  -               windowtitle="${Name-Long}"
  -               doctitle="${Name-Long}"
  -               bottom="&lt;small&gt;Copyright &amp;copy; 2001 Apache Software Foundation. Documenation generated ${TODAY}&lt;/small&gt;."
  -               protected="true"
  -               version="true"
  -               author="true"
  -               splitindex="false"
  -               nodeprecated="true"
  -               nodeprecatedlist="true"
  -               notree="true"
  -               noindex="false"
  -               nohelp="true"
  -               nonavbar="false"
  -               serialwarn="false">
  -          <link href="http://java.sun.com/j2ee/j2sdkee/techdocs/api"/>
  -          <link href="http://java.sun.com/j2se/1.4/docs/api"/>
  -      </javadoc>
  -      <delete dir="${workdir}"/>
  -   </target>
  -
  -   <!-- Updates the JavaDoc in the jakarta-commons/docs area -->
  -   <target name="website" depends="doc-javadoc" if="available-src-java">
  -      <copy todir="${javadoc-website-dir}" filtering="no">
  -         <fileset dir="${dest.doc.api}"/>
  -      </copy>
  -   </target>
  -
  -   <!-- ######################################################### -->
  -
  -   <target name="build" depends="init,build-java" description="compiles source files"/>
  -
  -   <target name="build-java" depends="init" if="available-src-java">
  -      <mkdir dir="${dest.classes}"/>
  -      <javac destdir="${dest.classes}"
  -             srcdir="${source.src.java}"
  -             classpath="${classpath}"
  -             debug="false"
  -             deprecation="false"
  -             optimize="true"/>
  -   </target>
  -
  -   <target name="build-test" depends="init,build-java" if="available-src-test">
  -      <mkdir dir="${dest.classes}"/>
  -      <javac destdir="${dest.classes}"
  -             srcdir="${source.src.test}"
  -             classpath="${test.classpath}"
  -             debug="false"
  -             deprecation="true"
  -             optimize="true"/>
  -
  -      <copy todir="${dest.classes}" filtering="no">
  -         <fileset dir="${source.src.conf}">
  -            <patternset refid="patternset-config-files"/>
  -         </fileset>
  -      </copy>
  -   </target>
   
  -   <!-- ######################################################### -->
  +  <target name="javadoc" depends="compile"
  +   description="Create component Javadoc documentation">
  +    <mkdir      dir="${dist.home}"/>
  +    <mkdir      dir="${dist.home}/docs"/>
  +    <mkdir      dir="${dist.home}/docs/api"/>
  +    <javadoc sourcepath="${source.home}"
  +                destdir="${dist.home}/docs/api"
  +           packagenames="org.apache.commons.*"
  +                 author="true"
  +                private="true"
  +                version="true"
  +               doctitle="&lt;h1&gt;${component.title}&lt;/h1&gt;"
  +            windowtitle="${component.title} (Version ${component.version})"
  +                 bottom="Copyright (c) 2001-2002 - Apache Software Foundation">
  +      <classpath refid="compile.classpath"/>
  +      <link     offline="true" packagelistLoc="${commons-beanutils.api}"
  +                   href="http://jakarta.apache.org/commons/beanutils/api/"/>
  +      <link     offline="true" packagelistLoc="${commons-collections.api}"
  +                   href="http://jakarta.apache.org/commons/collections/api/"/>
  +      <link     offline="true" packagelistLoc="${commons-logging.api}"
  +                   href="http://jakarta.apache.org/commons/logging/api/"/>
  +      <link     offline="true" packagelistLoc="${commons-digester.api}"
  +                   href="http://jakarta.apache.org/commons/digester/api/"/>
  +      <link     offline="true"  packagelistLoc="${jdk.api}"
  +                   href="http://java.sun.com/products/jdk/1.3/docs/api"/>
  +      <link     offline="true"  packagelistLoc="${j2ee.api}"
  +                   href="http://java.sun.com/products/j2ee/docs/api"/>
  +      <link     offline="true"  packagelistLoc="${jaxp.api}"
  +                   href="http://java.sun.com/xml/jaxp-docs-1.1/docs/api"/>
  +    </javadoc>
  +  </target>
  +
  +
  +  <target name="dist" depends="compile,javadoc"
  +   description="Create binary distribution">
  +    <mkdir      dir="${dist.home}"/>
  +    <copy      file="../LICENSE"
  +              todir="${dist.home}"/>
  +    <copy      file="RELEASE-NOTES.txt"
  +              todir="${dist.home}"/>
  +    <antcall target="jar"/>
  +  </target>
  +
  +
  +  <target name="jar" depends="compile"
  +   description="Create jar">
  +    <mkdir      dir="${dist.home}"/>
  +    <mkdir      dir="${build.home}/classes/META-INF"/>
  +    <copy      file="../LICENSE"
  +             tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
  +    <jar    jarfile="${dist.home}/commons-${component.name}.jar"
  +            basedir="${build.home}/classes"
  +           manifest="${build.home}/conf/MANIFEST.MF"/>
  +  </target>
  +
  +
  +  <target name="install-jar" depends="jar"
  +   description="--> Installs jar file in ${lib.repo}">
  +    <copy todir="${lib.repo}" filtering="no">
  +      <fileset dir="${dist.home}">
  +        <include name="commons-${component.name}.jar"/>
  +      </fileset>
  +    </copy>
  +  </target>
   
  -  <target name="webapp" depends="dist-jar">
  +
  +<!-- ========== Unit Test Targets ========================================= -->
  +
  +
  +  <target name="test"  depends="compile.tests,
  +                                test.messenger"
  +   description="Run all unit test cases">
  +  </target>
  +
  +
  +  <target name="test.messenger" depends="compile.tests">
  +    <echo message="Running messenger tests ..."/>
  +    <java classname="${test.runner}" fork="yes"
  +        failonerror="${test.failonerror}">
  +      <classpath refid="test.classpath"/>
  +
  +      <arg value="org.apache.commons.messenger.TestAll"/>
  +
  +      <!-- J2EE SDK properties -->
  +      <sysproperty key="jms.properties" value="${j2sdkee}/config/jms_client.properties"/>
  +      <sysproperty key="java.security.policy" value="${j2sdkee}/lib/security/client.policy"/>
  +      <sysproperty key="java.security.auth.login.config" value="${j2sdkee}/lib/security/login.config"/>
  +      <sysproperty key="com.sun.enterprise.home" value="${j2sdkee}"/>
  +      <sysproperty key="org.apache.commons.messenger" value="${conf.home}/test-connections.xml"/>
  +    </java>
  +  </target>
  +
  +<!-- ========== Example Web App =========================================== -->
  +
  +  <target name="webapp" depends="jar"
  +    description="Builds the sample web application">
       <mkdir dir="${build.webapp}"/>
       <mkdir dir="${build.webapp}/classes"/>
       <mkdir dir="${build.webapp}/lib"/>
  @@ -241,11 +349,12 @@
   
       <javac destdir="${build.webapp}/classes"
              srcdir="${webapp.dir}/src"
  -           classpath="${classpath};${dest.jardir.jar}"
              debug="false"
              deprecation="true"
              optimize="true"
  -           fork="true"/>
  +           fork="true">
  +      <classpath refid="compile.classpath"/>
  +    </javac>
   
       <copy toDir="${build.webapp}">
         <fileset dir="${webapp.dir}/conf" includes="*.tld, *.xml"/>
  @@ -254,10 +363,11 @@
       <copy tofile="${build.webapp}/Messenger.xml" file="${messenger.xml}"/>
   
       <!-- commons jars... -->
  -    <copy todir="${build.webapp}/lib" file="${dest.jardir.jar}"/>
  +    <copy todir="${build.webapp}/lib" file="${dist.home}/commons-${component.name}.jar"/>
       <copy todir="${build.webapp}/lib" file="${commons-digester.jar}"/>
       <copy todir="${build.webapp}/lib" file="${commons-collections.jar}"/>
       <copy todir="${build.webapp}/lib" file="${commons-beanutils.jar}"/>
  +    <copy todir="${build.webapp}/lib" file="${commons-logging.jar}"/>
   
       <copy toDir="${build.webapp}/classes">
         <fileset dir="${jms.classes.dir}"/>
  @@ -268,69 +378,97 @@
       </copy>
     </target>
   
  -   <!-- ######################################################### -->
  +<!-- ========== Demos using Messagelets =================================== -->
  +
  +<!--   
  +  the following require the webapp target to have been built and then
  +  the j2ee server to be running this webapp. To do this you need to edit
  +  the ${j2eesdk}/conf/web.properties to point to the src/webapp/web directory
  +-->
  +
  +  <target name="demo.j2eesdk.call" depends="compile.tests"
  +    description="Sends a message to a Messagelet engine and displays the result">
  +    <echo message="Sending a message to the Messagelet engine using the J2EE SDK JMS..."/>
  +    <java classname="org.apache.commons.messenger.tool.Caller" fork="yes">
  +      <classpath refid="test.classpath"/>
  +
  +      <arg value="queue"/>
  +      <arg value="jms/Queue"/>
  +      <arg value="src/conf/sampleMessage.txt"/>
  +
  +      <!-- J2EE SDK properties -->
  +      <sysproperty key="jms.properties" value="${j2sdkee}/config/jms_client.properties"/>
  +      <sysproperty key="java.security.policy" value="${j2sdkee}/lib/security/client.policy"/>
  +      <sysproperty key="java.security.auth.login.config" value="${j2sdkee}/lib/security/login.config"/>
  +      <sysproperty key="com.sun.enterprise.home" value="${j2sdkee}"/>
  +      <sysproperty key="org.apache.commons.messenger" value="${conf.home}/test-connections.xml"/>
  +    </java>
  +  </target>
  +  
  +<!--   
  +    the following demos assume that some JMS provider is being used
  +    and that the messenger.xml variable points to the config file to use and
  +    jms.classpath points to the required JARs & config files etc.
  +-->
  +
  +  <target name="demo.jms.call.mdo" depends="compile.tests"
  +    description="Sends a message to a Messagelet engine for processing by a MDO and displays the result">
  +    <echo message="Sending a message to the Messagelet engine using the configured JMS provider..."/>
  +    <java classname="org.apache.commons.messenger.tool.Caller" fork="yes">
  +      <classpath refid="jms.classpath"/>
  +
  +      <arg value="queue"/>
  +      <arg value="jms/Queue"/>
  +      <arg value="src/conf/sampleMessage.txt"/>
  +
  +      <sysproperty key="org.apache.commons.messenger" value="${messenger.xml}"/>
  +    </java>
  +  </target>
  +
  +  <target name="demo.jms.call.servlet" depends="compile.tests"
  +    description="Sends a message to a Messagelet engine for processing by a Servlet and displays the result">
  +    <echo message="Sending a message to the Messagelet engine using the configured JMS provider..."/>
  +    <java classname="org.apache.commons.messenger.tool.Caller" fork="yes">
  +      <classpath refid="jms.classpath"/>
  +
  +      <arg value="queue"/>
  +      <arg value="echo.servlet"/>
  +      <arg value="src/conf/sampleMessage.txt"/>
  +
  +      <sysproperty key="org.apache.commons.messenger" value="${messenger.xml}"/>
  +    </java>
  +  </target>
  +  
  +
  +  <target name="demo.jms.call.messagelet" depends="compile.tests"
  +    description="Sends a message to a Messagelet engine for processing by a Messagelet and displays the result">
  +    <echo message="Sending a message to the Messagelet engine using the configured JMS provider..."/>
  +    <java classname="org.apache.commons.messenger.tool.Caller" fork="yes">
  +      <classpath refid="jms.classpath"/>
  +
  +      <arg value="queue"/>
  +      <arg value="echo.messagelet"/>
  +      <arg value="src/conf/sampleMessage.txt"/>
  +
  +      <sysproperty key="org.apache.commons.messenger" value="${messenger.xml}"/>
  +    </java>
  +  </target>
     
  -  <target name="jms-ri" depends="init">
  -    <property name="jms.ri.tmp" value="${java.io.tmpdir}/buildtemp_jmsri_${DSTAMP}${TSTAMP}"/>
  -    <!-- lets unjar the monster J2EE JAR and delete the non-JMS bits -->
  -    <unjar src="${j2ee.jar}" dest="${jms.ri.tmp}" />
  -    <delete>
  -      <fileset dir="${jms.ri.tmp}" includes="**, **/*" excludes="COM/sun/jms/**, COM/sun/enterprise/**, javax/jms/**"/>
  -    </delete>
  -    <jar jarfile="${dest.jmsri.jardir.jar}" basedir="${jms.ri.tmp}" filesonly="true"/>
  -  </target>
  -
  -   <!-- ######################################################### -->
  -
  -   <target name="test" depends="build-test" if="test.entry" description="runs (junit) unit tests">
  -      <!--
  -      <junit printsummary="yes" fork="on" haltonfailure="yes">
  -      	<formatter type="plain" usefile="false"/>
  -      	<test name="${test.entry}"/>
  -      	<classpath>
  -          <pathelement location="${dest.classes}" />
  -          <pathelement path="${classpath}" />
  -          <pathelement path="${java.class.path}" />
  -      	</classpath>
  -      </junit>
  -      -->
  -
  -      <java classname="${test.runner}" fork="yes" failonerror="${test.failonerror}">
  -        <classpath>
  -          <pathelement location="${dest.classes}" />
  -          <pathelement path="${test.classpath}"/>
  -          <pathelement path="${java.class.path}" />
  -        </classpath>
  -
  -        <arg value="${test.entry}"/>
  -
  -        <!-- J2EE SDK properties -->
  -        <sysproperty key="jms.properties" value="${j2sdkee}/config/jms_client.properties"/>
  -        <sysproperty key="java.security.policy" value="${j2sdkee}/lib/security/client.policy"/>
  -        <sysproperty key="java.security.auth.login.config" value="${j2sdkee}/lib/security/login.config"/>
  -        <sysproperty key="com.sun.enterprise.home" value="${j2sdkee}"/>
  -        <sysproperty key="org.apache.commons.messenger" value="${source.src.conf}/test-connections.xml"/>
  -      </java>
  -   </target>
  -
  -   <!-- ######################################################### -->
  -
  -   <target name="dist" depends="dist-jar,doc" description="builds binary distribution"/>
  -
  -   <target name="dist-jar" depends="build">
  -      <mkdir dir="${dest.jardir}"/>
  -      <mkdir dir="${workdir}"/>
  -      <copy todir="${workdir}">
  -         <fileset dir="${dest.classes}">
  -            <patternset refid="patternset-non-test-classes"/>
  -         </fileset>
  -      </copy>
  -      <jar jarfile="${dest.jardir.jar}" manifest="${source.src}/conf/MANIFEST.MF">
  -         <fileset dir="${workdir}"/>
  -      </jar>
  -      <delete dir="${workdir}"/>
  -      <delete dir="${dest.classes}"/>
  -   </target>
   
  -   <!-- ######################################################### -->
  +  <target name="demo.jms.call.jsp" depends="compile.tests"
  +    description="Sends a message to a Messagelet engine for processing by a JSP page and displays the result">
  +    <echo message="Sending a message to the Messagelet engine using the configured JMS provider..."/>
  +    <java classname="org.apache.commons.messenger.tool.Caller" fork="yes">
  +      <classpath refid="jms.classpath"/>
  +
  +      <arg value="queue"/>
  +      <arg value="echo.jsp"/>
  +      <arg value="src/conf/sampleMessage.txt"/>
  +
  +      <sysproperty key="org.apache.commons.messenger" value="${messenger.xml}"/>
  +    </java>
  +  </target>
  +  
  +
  +
   </project>
  
  
  
  1.1                  jakarta-commons-sandbox/messenger/RELEASE-NOTES.txt
  
  Index: RELEASE-NOTES.txt
  ===================================================================
  $Id: RELEASE-NOTES.txt,v 1.1 2002/02/26 04:12:52 jstrachan Exp $
  
  			 Commons Messenger Package
  			   Version 1.0-dev
  			    Release Notes
  
  
  INTRODUCTION:
  
  This document contains the release notes for this version of the Commons
  Messenger package, and highlights changes since the previous version.  The
  current release adds new features and bug fixes, and is being done now to
  follow the release early/release often mentality.
  
  
  NEW FEATURES:
  
  * 
  
  
  BUG FIXES:
  
  
  
  
  
  1.5       +10 -0     jakarta-commons-sandbox/messenger/src/conf/Messenger.xml
  
  Index: Messenger.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/conf/Messenger.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Messenger.xml	15 Feb 2002 15:54:08 -0000	1.4
  +++ Messenger.xml	26 Feb 2002 04:12:52 -0000	1.5
  @@ -5,7 +5,12 @@
     <!-- when running inside of a J2EE container                          -->
   
     <messenger name="topic" jndiDestinations="false">
  +    <jndi lookupName="TopicConnectionFactory" topic="true">
  +<!--
  +    for some reason these don't work too well with J2EE SDK
  +
       <jndi lookupName="java:comp/env/TopicConnectionFactory" topic="true">
  +-->
         <property>
           <name>com.sun.jms.internal.java.naming.factory.initial</name>
           <value>com.sun.enterprise.naming.SerialInitContextFactory</value>
  @@ -14,7 +19,12 @@
     </messenger>
   
     <messenger name="queue" jndiDestinations="false">
  +    <jndi lookupName="QueueConnectionFactory" topic="false">
  +<!--
  +    for some reason these don't work too well with J2EE SDK
  +
       <jndi lookupName="java:comp/env/QueueConnectionFactory" topic="false">
  +-->
         <property>
           <name>com.sun.jms.internal.java.naming.factory.initial</name>
           <value>com.sun.enterprise.naming.SerialInitContextFactory</value>
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/messenger/src/conf/test-connections.xml
  
  Index: test-connections.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/conf/test-connections.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- test-connections.xml	30 Oct 2001 08:30:09 -0000	1.1
  +++ test-connections.xml	26 Feb 2002 04:12:52 -0000	1.2
  @@ -5,7 +5,7 @@
     <!-- when running outside of a J2EE container                         -->
   
     <messenger name="topic">
  -    <jndi lookupName="TopicConnectionFactory">
  +    <jndi lookupName="TopicConnectionFactory" topic="true">
         <property>
           <name>com.sun.jms.internal.java.naming.factory.initial</name>
           <value>com.sun.enterprise.naming.SerialInitContextFactory</value>
  @@ -14,7 +14,7 @@
     </messenger>
   
     <messenger name="queue">
  -    <jndi lookupName="QueueConnectionFactory">
  +    <jndi lookupName="QueueConnectionFactory" topic="false">
         <property>
           <name>com.sun.jms.internal.java.naming.factory.initial</name>
           <value>com.sun.enterprise.naming.SerialInitContextFactory</value>
  
  
  
  1.1                  jakarta-commons-sandbox/messenger/src/conf/sampleMessage.txt
  
  Index: sampleMessage.txt
  ===================================================================
  This is a sample message!
  
  
  1.10      +15 -2     jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet/ManagerServlet.java
  
  Index: ManagerServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messagelet/ManagerServlet.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ManagerServlet.java	13 Nov 2001 09:42:27 -0000	1.9
  +++ ManagerServlet.java	26 Feb 2002 04:12:53 -0000	1.10
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: ManagerServlet.java,v 1.9 2001/11/13 09:42:27 jstrachan Exp $
  + * $Id: ManagerServlet.java,v 1.10 2002/02/26 04:12:53 jstrachan Exp $
    */
   package org.apache.commons.messagelet;
   
  @@ -14,6 +14,7 @@
   
   import javax.jms.Destination;
   import javax.jms.Message;
  +import javax.jms.MessageConsumer;
   import javax.jms.MessageListener;
   import javax.jms.JMSException;
   import javax.servlet.GenericServlet;
  @@ -35,7 +36,7 @@
     * and use of MessageListener beans for a given ServletContext.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.9 $
  +  * @version $Revision: 1.10 $
     */
   public class ManagerServlet extends GenericServlet {
   
  @@ -98,6 +99,18 @@
               SubscriptionList list = createSubscriptionList();
               subscribe( list );
               setSubscriptionList( list );
  +            
  +            // now lets start all the connections...
  +            for (Iterator iter = manager.getMessengerNames(); iter.hasNext(); ) {
  +                String name = (String) iter.next();
  +                Messenger messenger = manager.getMessenger( name );
  +                try {
  +                    messenger.getConnection().start();
  +                }
  +                catch (JMSException e) {
  +                    log( "Caught exception trying to start messenger: " + name + ". Exception: " + e, e );
  +                }
  +            }
           }
       }
       
  
  
  
  1.8       +32 -8     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultMessenger.java	15 Feb 2002 11:50:18 -0000	1.7
  +++ DefaultMessenger.java	26 Feb 2002 04:12:53 -0000	1.8
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    *
  - * $Id: DefaultMessenger.java,v 1.7 2002/02/15 11:50:18 jstrachan Exp $
  + * $Id: DefaultMessenger.java,v 1.8 2002/02/26 04:12:53 jstrachan Exp $
    */
   package org.apache.commons.messenger;
   
  @@ -13,9 +13,12 @@
   import java.io.Serializable;
   
   import javax.jms.Connection;
  +import javax.jms.ConnectionFactory;
   import javax.jms.JMSException;
   import javax.jms.Message;
  +import javax.jms.MessageConsumer;
   import javax.jms.MessageListener;
  +import javax.jms.MessageProducer;
   import javax.jms.ServerSessionPool;
   import javax.jms.Session;
   import javax.jms.Queue;
  @@ -25,18 +28,22 @@
   import javax.naming.NamingException;
   import javax.naming.Context;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
   /** <p><code>DefaultMessenger</code> is the default implementation of
     * 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:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.7 $
  +  * @version $Revision: 1.8 $
     */
   public class DefaultMessenger extends MessengerSupport {
   
       private static final boolean SHARE_CONNECTION = true;
   
  -
  +    /** Logger */
  +    private static final Log log = LogFactory.getLog( DefaultMessenger.class );
   
   
       /** the session object for each thread */
  @@ -72,14 +79,15 @@
               return getSessionFactory().getConnection();
           }
           else {
  -
               Connection answer = (Connection) connectionPool.get();
               if ( answer == null ) {
   
                   answer = getSessionFactory().createConnection();
   
  -                System.out.println( "Created connection: " + answer + " for thread: " + Thread.currentThread() );
  -
  +                if ( log.isInfoEnabled() ) {
  +                    log.info( "Created connection: " + answer + " for thread: " + Thread.currentThread() );
  +                }
  +                
                   connectionPool.set( answer );
               }
               return answer;
  @@ -100,6 +108,22 @@
   
       // Implementation methods
       //-------------------------------------------------------------------------
  +    protected boolean isTopic(Connection connection) throws JMSException {
  +        return sessionFactory.isTopic();
  +    }
  +    
  +    protected boolean isTopic(ConnectionFactory factory) throws JMSException {
  +        return sessionFactory.isTopic();
  +    }
  +    
  +    protected boolean isTopic(Session session) throws JMSException {
  +        return sessionFactory.isTopic();
  +    }
  +    
  +    protected boolean isTopic(MessageProducer producer) throws JMSException {
  +        return sessionFactory.isTopic();
  +    }
  +    
       protected Session borrowSession() throws JMSException {
           Session answer = (Session) sessionPool.get();
           if ( answer == null ) {
  @@ -157,7 +181,7 @@
               }
   
               catch (Exception e) {
  -                System.out.println("Unable to lookup subject:" + subject);
  +                log.error( "Unable to lookup subject: " + subject + ". Exception: " + e, e );
               }
           }
   
  @@ -187,7 +211,7 @@
               }
   
               catch (Exception e) {
  -                System.out.println("Unable to lookup subject:" + subject);
  +                log.error( "Unable to lookup subject: " + subject + ". Exception: " + e, e );
               }
           }
   
  
  
  
  1.2       +3 -3      jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/InitMessengerServlet.java
  
  Index: InitMessengerServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/InitMessengerServlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InitMessengerServlet.java	1 Feb 2002 14:32:33 -0000	1.1
  +++ InitMessengerServlet.java	26 Feb 2002 04:12:53 -0000	1.2
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    *
  - * $Id: InitMessengerServlet.java,v 1.1 2002/02/01 14:32:33 jstrachan Exp $
  + * $Id: InitMessengerServlet.java,v 1.2 2002/02/26 04:12:53 jstrachan Exp $
    */
   package org.apache.commons.messenger;
   
  @@ -20,7 +20,7 @@
    * web.xml deployment descriptor.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class InitMessengerServlet extends HttpServlet {
   
  @@ -32,7 +32,7 @@
       public void init() throws ServletException {
           if ( ! initialized ) {
               initialized = true;
  -            //System.out.println( "About to initialize MessengerManager" );
  +            
               getServletContext().log( "About to initialize MessengerManager" );
               
               String config = getRequiredInitParmeter( "config", "The URL of the Messenger XML deployment document" );
  
  
  
  1.5       +23 -33    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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JNDISessionFactory.java	15 Feb 2002 15:54:08 -0000	1.4
  +++ JNDISessionFactory.java	26 Feb 2002 04:12:53 -0000	1.5
  @@ -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.4 2002/02/15 15:54:08 jstrachan Exp $
  + * $Id: JNDISessionFactory.java,v 1.5 2002/02/26 04:12:53 jstrachan Exp $
    */
   package org.apache.commons.messenger;
   
  @@ -26,23 +26,27 @@
   import javax.naming.NamingException;
   import javax.naming.NamingEnumeration;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
   
   /** <p><code>JNDISessionFactory</code> is a Factory of JMS Session objects
     * which looks up the ConnectionFactory object from JNDI.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.4 $
  +  * @version $Revision: 1.5 $
     */
   public class JNDISessionFactory extends SessionFactory {
   
  +    /** Logger */
  +    private static final Log log = LogFactory.getLog( JNDISessionFactory.class );
  +    
       /** the initial JNDI context used to lookup ConnectionFactory objects */
       public Context context;
   
       /** the name used to lookup the ConnectionFactory */
       private String lookupName = "TopicConnectionFactory";
   
  -    /** Wether Topics or Queue Connections should be forced */
  -    private boolean topic = false;
   
       // Properties
       //-------------------------------------------------------------------------
  @@ -57,16 +61,6 @@
           this.lookupName = lookupName;
       }
   
  -    /** To force Topic or Queue Connections */
  -    public void setTopic(boolean topic) {
  -    this.topic = topic;
  -    }
  -
  -    /** To force Topic or Queue Connections */
  -    public boolean isTopic() {
  -        return topic;
  -    }
  -
       /** Returns the JNDI Context used to lookup JMS ConnectionFactory objects */
       public Context getContext() throws NamingException {
           if ( context == null ) {
  @@ -87,14 +81,10 @@
         */
       protected ConnectionFactory createConnectionFactory() throws JMSException {
           try {
  -            System.out.println( "Looking up: " + getLookupName() + " in JNDI" );
  -
  -            if (!topic) {
  -                return (QueueConnectionFactory) getContext().lookup(getLookupName());
  +            if ( log.isInfoEnabled() ) {
  +                log.info( "Looking up: " + getLookupName() + " in JNDI" );
               }
  -
  -            else return (TopicConnectionFactory) getContext().lookup(getLookupName());
  -
  +            return (ConnectionFactory) getContext().lookup(getLookupName());
           }
           catch (NamingException e) {
               JMSException jmsException = new JMSException( "Failed to lookup: " + getLookupName() + " using JNDI. " + e );
  @@ -111,25 +101,25 @@
               throw new JMSException( "No ConnectionFactory configured. Cannot create a JMS Session" );
           }
   
  -        if (!topic) {
  +        if ( isTopic() ) {
  +            return createTopicConnection((TopicConnectionFactory) factory);
  +        }
  +        else {
               return createQueueConnection((QueueConnectionFactory) factory);
           }
  -
  -        else return createTopicConnection((TopicConnectionFactory) factory);
       }
   
       /** Re-implemented from SessionFactory. Creates a new Session instance */
       public Session createSession(Connection connection) throws JMSException {
   
  -         if (!topic) {
  -                QueueConnection queueConnection = (QueueConnection) connection;
  -                return queueConnection.createQueueSession( isTransacted(), getAcknowledgeMode() );
  -            }
  -
  -           else {
  -                TopicConnection topicConnection = (TopicConnection) connection;
  -                return topicConnection.createTopicSession( isTransacted(), getAcknowledgeMode() );
  -            }
  +        if ( isTopic() ) {
  +            TopicConnection topicConnection = (TopicConnection) connection;
  +            return topicConnection.createTopicSession( isTransacted(), getAcknowledgeMode() );
  +        }
  +        else {
  +            QueueConnection queueConnection = (QueueConnection) connection;
  +            return queueConnection.createQueueSession( isTransacted(), getAcknowledgeMode() );
  +        }
       }
   
       /** Factory method used to create a connection factory.
  
  
  
  1.10      +16 -2     jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/Messenger.java
  
  Index: Messenger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/Messenger.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Messenger.java	25 Oct 2001 21:07:12 -0000	1.9
  +++ Messenger.java	26 Feb 2002 04:12:53 -0000	1.10
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: Messenger.java,v 1.9 2001/10/25 21:07:12 jstrachan Exp $
  + * $Id: Messenger.java,v 1.10 2002/02/26 04:12:53 jstrachan Exp $
    */
   package org.apache.commons.messenger;
   
  @@ -33,7 +33,7 @@
     * taglib) will use the same JMS Session.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.9 $
  +  * @version $Revision: 1.10 $
     */
   public interface Messenger {
   
  @@ -144,5 +144,19 @@
       
       /** Closes the underlying JMS connection */
       public void close() throws JMSException;
  +    
  +    
  +    // Extra configuration methods available in JMS
  +    //-------------------------------------------------------------------------        
  +    public int getDeliveryMode(Destination destination) throws JMSException;
  +    public boolean getDisableMessageID(Destination destination) throws JMSException;
  +    public boolean getDisableMessageTimestamp(Destination destination) throws JMSException;
  +    public int getPriority(Destination destination) throws JMSException;
  +    public long getTimeToLive(Destination destination) throws JMSException;
  +    public void setDeliveryMode(Destination destination,int deliveryMode) throws JMSException;
  +    public void setDisableMessageID(Destination destination, boolean value) throws JMSException;
  +    public void setDisableMessageTimestamp(Destination destination,boolean value) throws JMSException;
  +    public void setPriority(Destination destination,int defaultPriority) throws JMSException;
  +    public void setTimeToLive(Destination destination,long timeToLive) throws JMSException;
   }
   
  
  
  
  1.7       +11 -4     jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerManager.java
  
  Index: MessengerManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MessengerManager.java	13 Feb 2002 13:56:34 -0000	1.6
  +++ MessengerManager.java	26 Feb 2002 04:12:53 -0000	1.7
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: MessengerManager.java,v 1.6 2002/02/13 13:56:34 jstrachan Exp $
  + * $Id: MessengerManager.java,v 1.7 2002/02/26 04:12:53 jstrachan Exp $
    */
   package org.apache.commons.messenger;
   
  @@ -16,13 +16,19 @@
   
   import javax.jms.JMSException;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
   /** <p><code>MessengerManager</code> is a manager of {@link Messenger} instances.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.6 $
  +  * @version $Revision: 1.7 $
     */
   public class MessengerManager {
       
  +    /** Logger */
  +    private static final Log log = LogFactory.getLog( MessengerManager.class );
  +    
       /** The singleton MessengerManager used by the static get() method */
       private static MessengerManager singleton;
       
  @@ -104,9 +110,10 @@
                       messenger.close();
                   }
                   catch (Exception e) {
  -                    System.out.println( 
  +                    log.error( 
                           "Caught exception trying to close messenger: " + name 
  -                        + " Exception: " + e 
  +                        + " Exception: " + e,
  +                        e
                       );
                       // continue to close all connections even if an error occurs
                   }
  
  
  
  1.19      +193 -14   jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerSupport.java
  
  Index: MessengerSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerSupport.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- MessengerSupport.java	15 Feb 2002 11:52:52 -0000	1.18
  +++ MessengerSupport.java	26 Feb 2002 04:12:53 -0000	1.19
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    *
  - * $Id: MessengerSupport.java,v 1.18 2002/02/15 11:52:52 jstrachan Exp $
  + * $Id: MessengerSupport.java,v 1.19 2002/02/26 04:12:53 jstrachan Exp $
    */
   package org.apache.commons.messenger;
   
  @@ -16,6 +16,7 @@
   import javax.jms.BytesMessage;
   import javax.jms.Connection;
   import javax.jms.ConnectionConsumer;
  +import javax.jms.ConnectionFactory;
   import javax.jms.Destination;
   import javax.jms.JMSException;
   import javax.jms.MapMessage;
  @@ -45,7 +46,7 @@
     * connection and session creation and the pooling strategy.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.18 $
  +  * @version $Revision: 1.19 $
     */
   public abstract class MessengerSupport implements Messenger {
   
  @@ -55,7 +56,7 @@
       /** The name of the Messenger */
       private String name;
   
  -    /** Wether Queue's and Topic's are looked up using JNDI (true)
  +    /** Whether Queue's and Topic's are looked up using JNDI (true)
       * or wether they should be created on the fly */
       private boolean jndiDestinations;
   
  @@ -89,7 +90,6 @@
       /** The inbox which is used for the call() methods */
       private Destination replyToDestination;
   
  -
       public MessengerSupport() {
       }
   
  @@ -108,7 +108,7 @@
       public Destination getDestination(String subject) throws JMSException {
           Session session = borrowSession();
           try {
  -            if ( session instanceof TopicSession ) {
  +            if ( isTopic( session ) ) {
                   return getTopic( (TopicSession) session, subject );
               }
               else {
  @@ -123,7 +123,7 @@
       public Destination createTemporaryDestination() throws JMSException {
           Session session = borrowSession();
           try {
  -            if ( session instanceof TopicSession ) {
  +            if ( isTopic( session ) ) {
                   TopicSession topicSession = (TopicSession) session;
                   return topicSession.createTemporaryTopic();
               }
  @@ -142,7 +142,7 @@
           MessageProducer producer = null;
           try {
               producer = getMessageProducer( session, destination );
  -            if ( producer instanceof TopicPublisher ) {
  +            if ( isTopic( producer ) ) {
                   ((TopicPublisher) producer).publish( message );
               }
               else {
  @@ -158,7 +158,7 @@
       public Message call( Destination destination, Message message ) throws JMSException {
           Session session = borrowSession();
           try {
  -            if ( session instanceof TopicSession ) {
  +            if ( isTopic( session ) ) {
                   TopicRequestor requestor = getTopicRequestor( (TopicSession) session, (Topic) destination );
                   return requestor.request( message );
               }
  @@ -182,7 +182,7 @@
               MessageProducer producer = getMessageProducer( session, destination );
               MessageConsumer consumer = getMessageConsumer( session, replyTo );
   
  -            if ( session instanceof TopicSession ) {
  +            if ( isTopic( session ) ) {
                   ((TopicPublisher) producer).publish( message );
               }
               else {
  @@ -207,7 +207,7 @@
               producer = getMessageProducer( session, destination );
               consumer = getMessageConsumer( session, replyTo );
   
  -            if ( session instanceof TopicSession ) {
  +            if ( isTopic( session ) ) {
                   ((TopicPublisher) producer).publish( message );
               }
               else {
  @@ -325,7 +325,7 @@
   
       public ConnectionConsumer createConnectionConsumer(Destination destination, String selector, ServerSessionPool sessionPool, int maxMessages) throws JMSException {
           Connection connection = getConnection();
  -        if ( connection instanceof TopicConnection ) {
  +        if ( isTopic( connection ) ) {
               TopicConnection topicConnection = (TopicConnection) connection;
               if ( isDurable() ) {
                   return topicConnection.createDurableConnectionConsumer( (Topic) destination, getDurableName(), selector, sessionPool, maxMessages );
  @@ -508,6 +508,177 @@
           getConnection().close();
       }
   
  +    /** Get the producer's default delivery mode. */
  +    public int getDeliveryMode(Destination destination)  throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +        int deliveryMode = 0;
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            deliveryMode = producer.getDeliveryMode( );
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +        return deliveryMode;
  +    }
  +
  +    /** Set the producer's default delivery mode. */
  +    public void setDeliveryMode(Destination destination, int deliveryMode)  throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            producer.setDeliveryMode( deliveryMode );
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +    }
  +    /**  Get the producer's default priority. */
  +    public int getPriority(Destination destination ) throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +        int priority = 0;
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            priority = producer.getPriority( );
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +        return priority;
  +    }
  +
  +    /**   Set the producer's default priority. */
  +    public void setPriority(Destination destination, int priority ) throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            producer.setPriority( priority );
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +    }
  +
  +    /**  Get the producer's default delivery mode. */
  +    public long getTimeToLive(Destination destination ) throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +        long timeToLive = 0;
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            timeToLive = producer.getTimeToLive( );
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +        return timeToLive;
  +    }
  +
  +    /**  <p>Set the default length of time in milliseconds from its dispatch time that
  +     *   a produced message should be retained by the message system.</p>
  +     */
  +    public void setTimeToLive(Destination destination, long timeToLive) throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            producer.setTimeToLive( timeToLive );
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +    }
  +
  +    /** Get an indication of whether message timestamps are disabled. */
  +    public boolean getDisableMessageTimestamp(Destination destination)  throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +        boolean value = false;
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            value = producer.getDisableMessageTimestamp( );
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +        return value;
  +    }
  +
  +    /** Set whether message timestamps are disabled. */
  +    public void setDisableMessageTimestamp(Destination destination, boolean value) throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            producer.setDisableMessageTimestamp( value );
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +    }
  +
  +    /** Extends the send capability to send by specifying additional options. */
  +    public void send( Destination destination, Message message , int deliveryMode, int priority, long timeToLive) throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            if ( isTopic(producer) ) {
  +                ((TopicPublisher) producer).publish( message, deliveryMode, priority, timeToLive );
  +            }
  +            else {
  +                ((QueueSender) producer).send( message, deliveryMode, priority, timeToLive);
  +            }
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +    }
  +
  +    /**  Get an indication of whether message IDs are disabled. */
  +    public boolean getDisableMessageID(Destination destination)  throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +        boolean value = false;
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            value = producer.getDisableMessageID( );
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +        return value;
  +    }
  +
  +    /** Set whether message IDs are disabled. */
  +    public void setDisableMessageID(Destination destination, boolean value) throws JMSException {
  +        Session session = borrowSession();
  +        MessageProducer producer = null;
  +        try {
  +            producer = getMessageProducer( session, destination );
  +            producer.setDisableMessageID( value );
  +        }
  +        finally {
  +            producer.close();
  +            returnSession( session );
  +        }
  +    }
  +    
       // Properties
       //-------------------------------------------------------------------------
   
  @@ -582,6 +753,14 @@
       /** Returns a session instance back to the pool */
       protected abstract void returnListenerSession(Session session) throws JMSException;
   
  +    protected abstract boolean isTopic(Connection connection) throws JMSException;
  +    
  +    protected abstract boolean isTopic(ConnectionFactory factory) throws JMSException;
  +    
  +    protected abstract boolean isTopic(Session session) throws JMSException;
  +    
  +    protected abstract boolean isTopic(MessageProducer producer) throws JMSException;
  +    
       /** Returns a message producer for the given session and destination */
       protected MessageProducer getMessageProducer( Session session, Destination destination ) throws JMSException {
           return createMessageProducer( session, destination );
  @@ -596,7 +775,7 @@
   
       /** Returns a newly created message producer for the given session and destination */
       protected MessageProducer createMessageProducer( Session session, Destination destination ) throws JMSException {
  -        if ( session instanceof TopicSession ) {
  +        if ( isTopic( session ) ) {
               TopicSession topicSession = (TopicSession) session;
               return topicSession.createPublisher( (Topic) destination );
           }
  @@ -626,7 +805,7 @@
   
       /** Returns a new MessageConsumer for the given session and destination */
       protected MessageConsumer createMessageConsumer( Session session, Destination destination ) throws JMSException {
  -        if ( session instanceof TopicSession ) {
  +        if ( isTopic( session ) ) {
               TopicSession topicSession = (TopicSession) session;
               if ( isDurable() ) {
                   return topicSession.createDurableSubscriber(
  @@ -648,7 +827,7 @@
   
       /** Returns a new MessageConsumer for the given session, destination and selector */
       protected MessageConsumer createMessageConsumer( Session session, Destination destination, String selector ) throws JMSException {
  -        if ( session instanceof TopicSession ) {
  +        if ( isTopic( session ) ) {
               TopicSession topicSession = (TopicSession) session;
               if ( isDurable() ) {
                   return topicSession.createDurableSubscriber(
  
  
  
  1.10      +56 -18    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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SessionFactory.java	25 Oct 2001 21:07:12 -0000	1.9
  +++ SessionFactory.java	26 Feb 2002 04:12:53 -0000	1.10
  @@ -5,7 +5,7 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    * 
  - * $Id: SessionFactory.java,v 1.9 2001/10/25 21:07:12 jstrachan Exp $
  + * $Id: SessionFactory.java,v 1.10 2002/02/26 04:12:53 jstrachan Exp $
    */
   package org.apache.commons.messenger;
   
  @@ -23,16 +23,22 @@
   import javax.jms.TopicConnection;
   import javax.jms.TopicConnectionFactory;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
   
   /** <p><code>SessionFactory</code> is a Factory of JMS Session objects.
     * It can be configured with a JMS Connection object to use or can use 
     * a JMS ConnectionFactory instance to create the JMS Connection lazily</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.9 $
  +  * @version $Revision: 1.10 $
     */
   public class SessionFactory {
   
  +    /** Logger */
  +    private static final Log log = LogFactory.getLog( SessionFactory.class );
  +    
       /** The JMS connection used to create JMS sessions */
       private Connection connection;
       /** The JMS ConnectionFactory used to create JMS Connection instances */
  @@ -47,12 +53,14 @@
       private String password;
       /** the properties used to create the connection */
       protected Properties properties;
  -    
  +    /** Whether to use a Topic or Queue connection/session */
  +    private boolean topic = true;
  +
       
       
       /** Creates a new Session instance */
       public Session createSession(Connection connection) throws JMSException {
  -        if ( connection instanceof TopicConnection ) {
  +        if ( topic ) {
               TopicConnection topicConnection = (TopicConnection) connection;
               return topicConnection.createTopicSession( isTransacted(), getAcknowledgeMode() );
           }
  @@ -65,7 +73,7 @@
       /** Creates a new Session instance */
       public Session createSession() throws JMSException {
           Connection connection = getConnection();
  -        if ( connection instanceof TopicConnection ) {
  +        if ( topic ) {
               TopicConnection topicConnection = (TopicConnection) connection;
               return topicConnection.createTopicSession( isTransacted(), getAcknowledgeMode() );
           }
  @@ -85,18 +93,13 @@
           if ( factory == null ) {
               throw new JMSException( "No ConnectionFactory configured. Cannot create a JMS Session" );
           }
  -        //System.out.println( "About to create a connection from: " + factory );
           
  -        if ( factory instanceof TopicConnectionFactory ) {
  -            try {
  -                return createTopicConnection((TopicConnectionFactory) factory);
  -            }
  -            catch (ClassCastException e) {
  -                // XXXX: for some reason in J2EE SDK QueueConnectionFactory 
  -                // objects appear to be  TopicConnectionFactory objects 
  -                // for some wierd reason
  -                return createQueueConnection((QueueConnectionFactory) factory);
  -            }
  +        if ( log.isDebugEnabled() ) {
  +            log.debug( "About to create a connection from: " + factory );
  +        }
  +        
  +        if ( topic ) {
  +            return createTopicConnection((TopicConnectionFactory) factory);
           }
           else {
               return createQueueConnection((QueueConnectionFactory) factory);
  @@ -117,7 +120,8 @@
       /** Returns the JMS connection used to create new sessions */
       public Connection getConnection() throws JMSException {
           if ( connection == null ) {
  -            connection = createConnection();
  +            setConnection( createConnection() );
  +            
               connection.start();
           }
           return connection;
  @@ -125,18 +129,42 @@
       
       public void setConnection(Connection connection) {
           this.connection = connection;
  +        
  +        // change the topic flag if the wrong topic/queue type
  +        if ( topic ) {
  +            if ( ! ( connection instanceof TopicConnection ) ) {
  +                setTopic( false );
  +            }
  +        }
  +        else {
  +            if ( ! ( connection instanceof QueueConnection ) ) {
  +                setTopic( true );
  +            }
  +        }
       }
       
       /** Returns the JMS ConnectionFactory used to create a new connection */
       public ConnectionFactory getConnectionFactory() throws JMSException {
           if ( connectionFactory == null ) {
  -            connectionFactory = createConnectionFactory();
  +            setConnectionFactory( createConnectionFactory() );
           }
           return connectionFactory;
       }
       
       public void setConnectionFactory(ConnectionFactory connectionFactory) {
           this.connectionFactory = connectionFactory;
  +        
  +        // change the topic flag if the wrong topic/queue type
  +        if ( topic ) {
  +            if ( ! ( connectionFactory instanceof TopicConnectionFactory ) ) {
  +                setTopic( false );
  +            }
  +        }
  +        else {
  +            if ( ! ( connectionFactory instanceof QueueConnectionFactory ) ) {
  +                setTopic( true );
  +            }
  +        }
       }
       
       /** Returns true if sessions created by this factory should be transacted */
  @@ -191,6 +219,16 @@
   
       public void addProperty(String name, String value) {
           getProperties().setProperty(name, value);
  +    }
  +    
  +    /** @return whether to use a Topic or Queue connection/session */
  +    public boolean isTopic() {
  +        return topic;
  +    }
  +    
  +    /** Sets whether to use a Topic or Queue connection/session */
  +    public void setTopic(boolean topic) {
  +        this.topic = topic;
       }
       
       
  
  
  
  1.4       +0 -1      jakarta-commons-sandbox/messenger/src/webapp/conf/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/webapp/conf/web.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- web.xml	26 Oct 2001 14:27:26 -0000	1.3
  +++ web.xml	26 Feb 2002 04:12:53 -0000	1.4
  @@ -46,7 +46,6 @@
       <url-pattern>/jms/echoServlet</url-pattern>
     </servlet-mapping>
   
  -
     <welcome-file-list>
       <welcome-file>index.jsp</welcome-file>
     </welcome-file-list>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message