[jboss-svn-commits] JBL Code SVN: r34523 - in labs/jbossesb/workspace/platform/soa_tags: JBESB_4_4_SOA_4_3_CP4_1059293/product and 10 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 4 13:33:45 EDT 2010
Author: kevin.conner at jboss.com
Date: 2010-08-04 13:33:42 -0400 (Wed, 04 Aug 2010)
New Revision: 34523
Added:
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/build-distr.xml
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/apache/
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/ScoutAspect.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/resources/META-INF/jboss-aop.xml
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/build.xml
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionExceptionHandler.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/JBossMessagingConnectionExceptionHandler.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/WMQConnectionExceptionHandler.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolUnitTest.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java
Removed:
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/build-distr.xml
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/resources/META-INF/jboss-aop.xml
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/build.xml
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolUnitTest.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java
Modified:
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/build.xml
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java
labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/soa/esb/common/Environment.java
Log:
tag for 1059293
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293 (from rev 32778, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA)
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/build-distr.xml
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/build-distr.xml 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/build-distr.xml 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,151 +0,0 @@
-<project name="JBESB Distribution Build" default="dist" basedir=".">
- <!-- Set default properties filename -->
- <property name="org.jboss.esb.properties" location="product.properties"/>
-
- <property file="skip.properties"/>
-
- <!-- Load Build Properties File -->
- <property file="${org.jboss.esb.properties}"/>
-
- <property name="build.dir" value="build"/>
- <property name="lib.dir" value="build/lib"/>
- <property name="aoplib.dir" value="build/aoplib"/>
- <property name="lib.ext.dir" value="lib/ext"/>
- <property name="services.dir" value="services"/>
- <property name="build.lib.dir" value="${build.dir}/jbossesb/lib"/>
- <property name="version" value="4.2.MR1"/>
- <property name="esbserver.dist.dir" value="${build.dir}/soa-server-${version}"/>
- <property name="installation.files.dir" value="install"/>
-
- <target name="dist" depends="server.dist, copy.esbserver.files" />
-
- <target name="copy.esbserver.files" unless="skip.server.esb">
- <copy todir="${esbserver.dist.dir}/docs" failonerror="false">
- <fileset dir="${build.dir}/jbossesb/docs">
- <include name="**/*"/>
- </fileset>
- </copy>
- <copy todir="${esbserver.dist.dir}" failonerror="false">
- <fileset dir="${build.dir}/jbossesb">
- <include name="javadocs/**/*"/>
- </fileset>
- </copy>
- <copy todir="${esbserver.dist.dir}" failonerror="false">
- <fileset dir="${build.dir}/jbossesb">
- <include name="samples/**/*"/>
- </fileset>
- </copy>
- <copy todir="${esbserver.dist.dir}" failonerror="false">
- <fileset dir="${build.dir}/jbossesb">
- <include name="tools/**/*"/>
- </fileset>
- </copy>
- <copy file="${build.dir}/jbossesb/xml/jbossesb-1.0.1.xsd"
- todir="${esbserver.dist.dir}/docs/schema"/>
- <copy todir="${esbserver.dist.dir}">
- <fileset dir="${build.dir}/jbossesb">
- <include name="*.txt"/>
- </fileset>
- </copy>
- </target>
-
- <target name="ftp-server" unless="skip.ftp.server">
- <ant antfile="build.xml" dir="ftp"/>
- </target>
-
- <target name="server.dist" depends="build.sar, unpack.server.zip, ftp-server" unless="skip.server.esb">
- <ant antfile="build.xml" dir="${esb.install.location}" target="deploy"
- inheritall="false">
- <property name="org.jboss.esb.server.home" value="${esbserver.dist.dir}"/>
- <property name="org.jboss.esb.server.config" value="default"/>
- </ant>
- </target>
-
- <target name="unpack.server.zip" unless="skip.server.esb">
- <delete dir="${esbserver.dist.dir}"/>
- <unzip src="${installation.files.dir}/standalone/jbossesb-server-base.zip" dest="${build.dir}"/>
- <chmod dir="${build.dir}/jbossesb-server/bin" perm="ugo+rx" includes="*.sh"/>
- <move file="${build.dir}/jbossesb-server" tofile="${esbserver.dist.dir}"/>
- </target>
-
- <target name="build.sar">
- <echo message="Building JBoss ESB sar files"/>
- <delete dir="${build.dir}/jbossesb.sar"/>
- <mkdir dir="${build.dir}/jbossesb.sar"/>
- <mkdir dir="${build.dir}/jbossesb.sar/META-INF"/>
- <copy file="${installation.files.dir}/jboss-service.xml"
- todir="${build.dir}/jbossesb.sar/META-INF"/>
- <copy todir="${build.dir}/jbossesb.sar">
- <fileset dir="${installation.files.dir}/conf">
- <include name="jbossesb-properties.xml"/>
- <include name="esb.juddi.xml"/>
- <include name="actionArtifactMap.properties"/>
- <include name="privateKeyStore"/>
- <include name="publicKeyStore"/>
- </fileset>
- <fileset dir="${installation.files.dir}/jUDDI-registry">
- <include name="juddi-ds.xml"/>
- </fileset>
- <!-- We use AOP on scout to get around an issue -->
- <fileset dir="${build.dir}" includes="rosetta.aop"/>
- <!-- We use AOP on smooks to get around an issue -->
- <fileset dir="${build.dir}" includes="jboss-smooks-1.0.aop"/>
- </copy>
-
- <mkdir dir="${build.dir}/jbossesb.sar/juddi-sql"/>
- <copy todir="${build.dir}/jbossesb.sar/juddi-sql">
- <fileset dir="${installation.files.dir}/jUDDI-registry/sql">
- <include name="**/import.sql"/>
- <include name="**/create_database.sql"/>
- </fileset>
- </copy>
-
- <mkdir dir="${build.dir}/jbossesb.sar/lib"/>
- <copy todir="${build.dir}/jbossesb.sar/lib">
- <fileset dir="${lib.ext.dir}" includes="jbossts-common.jar"/>
- <fileset dir="${build.lib.dir}" includes="jbossesb*.jar"/>
- <!-- scout -->
- <fileset dir="${lib.dir}" includes="scout-*.jar"/>
- <!-- xbean for reading/marchalling xml for configuration, and scout -->
- <fileset dir="${lib.dir}" includes="xbean*.jar"/>
- <fileset dir="${lib.dir}" includes="stax-api-*.jar"/>
- <!-- jUDDI Registry, we're one -->
- <!-- We use AOP on juddi to get around an issue, use the modified jar for now
- <fileset dir="${lib.dir}" includes="juddi-*.jar"/>
- -->
- <fileset dir="${aoplib.dir}" includes="juddi-*.jar"/>
- <fileset dir="${lib.dir}" includes="juddi-client*.jar"/>
- <!-- ftp -->
- <fileset dir="${lib.ext.dir}" includes="commons-net-*.jar"/>
- <fileset dir="${lib.dir}" includes="commons-io-*.jar,jsch-*.jar"/>
- <!-- Commons lang... -->
- <fileset dir="${lib.dir}" includes="commons-lang-*.jar"/>
- <!-- XStream jars -->
- <fileset dir="${lib.dir}" includes="xstream-*.jar"/>
- <!-- woodstox for the StaxDriver -->
- <fileset dir="${lib.dir}" includes="wstx-*.jar"/>
- <!-- MVEL -->
- <fileset dir="${lib.dir}" includes="mvel*.jar"/>
- <!-- Quartz -->
- <fileset dir="${lib.ext.dir}" includes="quartz*.jar"/>
- <!-- Commons SSL -->
- <fileset dir="${lib.ext.dir}" includes="commons-ssl-*.jar"/>
- <!-- groovy -->
- <fileset dir="${lib.dir}" includes="groovy-*.jar"/>
- <!-- smooks -->
- <fileset dir="${lib.dir}" includes="milyn-*.jar,freemarker-*.jar,ognl-*.jar,stringtemplate-*.jar,xpp3_min-*.jar"
- excludes="milyn-smooks-core-*.jar"/>
- <fileset dir="${lib.ext.dir}" includes="opencsv-*.jar"/>
- <fileset dir="${aoplib.dir}" includes="milyn-*.jar"/>
- </copy>
- <copy todir="${build.dir}/jbossesb.sar">
- <fileset dir="${installation.files.dir}/jUDDI-registry" includes="juddi.war"/>
- </copy>
- <copy todir="${build.lib.dir}">
- <fileset dir="build" includes="jbossesb.sar/**"/>
- </copy>
-
- </target>
-
-
-</project>
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/build-distr.xml (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/build-distr.xml)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/build-distr.xml (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/build-distr.xml 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,154 @@
+<project name="JBESB Distribution Build" default="dist" basedir=".">
+ <!-- Set default properties filename -->
+ <property name="org.jboss.esb.properties" location="product.properties"/>
+
+ <property file="skip.properties"/>
+
+ <!-- Load Build Properties File -->
+ <property file="${org.jboss.esb.properties}"/>
+
+ <property name="build.dir" value="build"/>
+ <property name="lib.dir" value="build/lib"/>
+ <property name="aoplib.dir" value="build/aoplib"/>
+ <property name="lib.ext.dir" value="lib/ext"/>
+ <property name="services.dir" value="services"/>
+ <property name="build.lib.dir" value="${build.dir}/jbossesb/lib"/>
+ <property name="version" value="4.2.MR1"/>
+ <property name="esbserver.dist.dir" value="${build.dir}/soa-server-${version}"/>
+ <property name="installation.files.dir" value="install"/>
+
+ <target name="dist" depends="server.dist, copy.esbserver.files" />
+
+ <target name="copy.esbserver.files" unless="skip.server.esb">
+ <copy todir="${esbserver.dist.dir}/docs" failonerror="false">
+ <fileset dir="${build.dir}/jbossesb/docs">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+ <copy todir="${esbserver.dist.dir}" failonerror="false">
+ <fileset dir="${build.dir}/jbossesb">
+ <include name="javadocs/**/*"/>
+ </fileset>
+ </copy>
+ <copy todir="${esbserver.dist.dir}" failonerror="false">
+ <fileset dir="${build.dir}/jbossesb">
+ <include name="samples/**/*"/>
+ </fileset>
+ </copy>
+ <copy todir="${esbserver.dist.dir}" failonerror="false">
+ <fileset dir="${build.dir}/jbossesb">
+ <include name="tools/**/*"/>
+ </fileset>
+ </copy>
+ <copy file="${build.dir}/jbossesb/xml/jbossesb-1.0.1.xsd"
+ todir="${esbserver.dist.dir}/docs/schema"/>
+ <copy todir="${esbserver.dist.dir}">
+ <fileset dir="${build.dir}/jbossesb">
+ <include name="*.txt"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="ftp-server" unless="skip.ftp.server">
+ <ant antfile="build.xml" dir="ftp"/>
+ </target>
+
+ <target name="server.dist" depends="build.sar, unpack.server.zip, ftp-server" unless="skip.server.esb">
+ <ant antfile="build.xml" dir="${esb.install.location}" target="deploy"
+ inheritall="false">
+ <property name="org.jboss.esb.server.home" value="${esbserver.dist.dir}"/>
+ <property name="org.jboss.esb.server.config" value="default"/>
+ </ant>
+ </target>
+
+ <target name="unpack.server.zip" unless="skip.server.esb">
+ <delete dir="${esbserver.dist.dir}"/>
+ <unzip src="${installation.files.dir}/standalone/jbossesb-server-base.zip" dest="${build.dir}"/>
+ <chmod dir="${build.dir}/jbossesb-server/bin" perm="ugo+rx" includes="*.sh"/>
+ <move file="${build.dir}/jbossesb-server" tofile="${esbserver.dist.dir}"/>
+ </target>
+
+ <target name="build.sar">
+ <echo message="Building JBoss ESB sar files"/>
+ <delete dir="${build.dir}/jbossesb.sar"/>
+ <mkdir dir="${build.dir}/jbossesb.sar"/>
+ <mkdir dir="${build.dir}/jbossesb.sar/META-INF"/>
+ <copy file="${installation.files.dir}/jboss-service.xml"
+ todir="${build.dir}/jbossesb.sar/META-INF"/>
+ <copy todir="${build.dir}/jbossesb.sar">
+ <fileset dir="${installation.files.dir}/conf">
+ <include name="jbossesb-properties.xml"/>
+ <include name="esb.juddi.xml"/>
+ <include name="actionArtifactMap.properties"/>
+ <include name="privateKeyStore"/>
+ <include name="publicKeyStore"/>
+ </fileset>
+ <fileset dir="${installation.files.dir}/jUDDI-registry">
+ <include name="juddi-ds.xml"/>
+ </fileset>
+ <!-- We use AOP on scout to get around an issue -->
+ <fileset dir="${build.dir}" includes="rosetta.aop"/>
+ <!-- We use AOP on smooks to get around an issue -->
+ <fileset dir="${build.dir}" includes="jboss-smooks-1.0.aop"/>
+ </copy>
+
+ <mkdir dir="${build.dir}/jbossesb.sar/juddi-sql"/>
+ <copy todir="${build.dir}/jbossesb.sar/juddi-sql">
+ <fileset dir="${installation.files.dir}/jUDDI-registry/sql">
+ <include name="**/import.sql"/>
+ <include name="**/create_database.sql"/>
+ </fileset>
+ </copy>
+
+ <mkdir dir="${build.dir}/jbossesb.sar/lib"/>
+ <copy todir="${build.dir}/jbossesb.sar/lib">
+ <fileset dir="${lib.ext.dir}" includes="jbossts-common.jar"/>
+ <fileset dir="${build.lib.dir}" includes="jbossesb*.jar"/>
+ <!-- We use AOP on scout to get around an issue, use the modified jar for now
+ <fileset dir="${lib.dir}" includes="scout-*.jar"/>
+ -->
+ <!-- scout -->
+ <fileset dir="${aoplib.dir}" includes="scout-*.jar"/>
+ <!-- xbean for reading/marchalling xml for configuration, and scout -->
+ <fileset dir="${lib.dir}" includes="xbean*.jar"/>
+ <fileset dir="${lib.dir}" includes="stax-api-*.jar"/>
+ <!-- jUDDI Registry, we're one -->
+ <!-- We use AOP on juddi to get around an issue, use the modified jar for now
+ <fileset dir="${lib.dir}" includes="juddi-*.jar"/>
+ -->
+ <fileset dir="${aoplib.dir}" includes="juddi-*.jar"/>
+ <fileset dir="${lib.dir}" includes="juddi-client*.jar"/>
+ <!-- ftp -->
+ <fileset dir="${lib.ext.dir}" includes="commons-net-*.jar"/>
+ <fileset dir="${lib.dir}" includes="commons-io-*.jar,jsch-*.jar"/>
+ <!-- Commons lang... -->
+ <fileset dir="${lib.dir}" includes="commons-lang-*.jar"/>
+ <!-- XStream jars -->
+ <fileset dir="${lib.dir}" includes="xstream-*.jar"/>
+ <!-- woodstox for the StaxDriver -->
+ <fileset dir="${lib.dir}" includes="wstx-*.jar"/>
+ <!-- MVEL -->
+ <fileset dir="${lib.dir}" includes="mvel*.jar"/>
+ <!-- Quartz -->
+ <fileset dir="${lib.ext.dir}" includes="quartz*.jar"/>
+ <!-- Commons SSL -->
+ <fileset dir="${lib.ext.dir}" includes="commons-ssl-*.jar"/>
+ <!-- groovy -->
+ <fileset dir="${lib.dir}" includes="groovy-*.jar"/>
+ <!-- smooks -->
+ <fileset dir="${lib.dir}" includes="milyn-*.jar,freemarker-*.jar,ognl-*.jar,stringtemplate-*.jar,xpp3_min-*.jar"
+ excludes="milyn-smooks-core-*.jar"/>
+ <fileset dir="${lib.ext.dir}" includes="opencsv-*.jar"/>
+ <fileset dir="${aoplib.dir}" includes="milyn-*.jar"/>
+ </copy>
+ <copy todir="${build.dir}/jbossesb.sar">
+ <fileset dir="${installation.files.dir}/jUDDI-registry" includes="juddi.war"/>
+ </copy>
+ <copy todir="${build.lib.dir}">
+ <fileset dir="build" includes="jbossesb.sar/**"/>
+ </copy>
+
+ </target>
+
+
+</project>
Modified: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/build.xml
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/build.xml 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/build.xml 2010-08-04 17:33:42 UTC (rev 34523)
@@ -37,7 +37,7 @@
<property name="org.jboss.esb.internal.jar.dest" location="build/jbossesb/lib"/>
<!-- JBoss ESB version -->
- <property name="version" value="4.3.0"/>
+ <property name="version" value="4.3.0_1059293"/>
<property name="esb.server.name" value="soa-server-${version}"/>
<property name="esbserver.dist.dir" value="${org.jboss.esb.internal.dest}/${esb.server.name}"/>
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/apache (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/aop/java/org/apache)
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,92 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.internal.soa.esb.services.registry.aspect;
-
-import java.util.Vector;
-
-import org.apache.juddi.util.Config;
-import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Aspect used to support CDATA sections from within jUDDI.
- *
- * Also intercepts calls for services when constructing the organizational information.
- *
- * @author <a href='mailto:Kevin.Conner at jboss.com'>Kevin Conner</a>
- */
-public class JUDDIAspect
-{
- public Object getText(final MethodInvocation invocation)
- throws Throwable
- {
- final Object[] args = invocation.getArguments() ;
- final Element element = (Element)args[0] ;
- final StringBuffer sb = new StringBuffer();
-
- final NodeList nodeList = element.getChildNodes() ;
- final int numNodes = nodeList.getLength() ;
- for(int count = 0 ; count < numNodes ; count++)
- {
- final Node node = nodeList.item(count) ;
- final short type = node.getNodeType() ;
- if ((type == Element.TEXT_NODE) || (type == Element.CDATA_SECTION_NODE))
- {
- sb.append(node.getNodeValue()) ;
- }
- }
-
- return sb.toString().trim();
- }
-
- public Object fetchServiceByBusinessKey(final MethodCalledByMethodInvocation invocation)
- throws Throwable
- {
- return new Vector<Object>() ;
- }
-
- public Object getStringProperty(final MethodCalledByMethodInvocation invocation)
- throws Throwable
- {
- final Object[] args = invocation.getArguments() ;
- final String key = (String)args[0] ;
- return Config.getStringProperty(key) ;
- }
-
- public Object setProperty(final MethodCalledByMethodInvocation invocation)
- throws Throwable
- {
- final Object[] args = invocation.getArguments() ;
- final Object value = args[1] ;
- if (value != null)
- {
- return invocation.invokeNext() ;
- }
- else
- {
- return null ;
- }
- }
-}
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/JUDDIAspect.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.internal.soa.esb.services.registry.aspect;
+
+import java.sql.Connection;
+import java.util.Vector;
+
+import org.apache.juddi.datastore.jdbc.JBossESBDataStore;
+import org.apache.juddi.datastore.jdbc.JDBCDataStore;
+import org.apache.juddi.datatype.binding.BindingTemplate;
+import org.apache.juddi.datatype.binding.TModelInstanceDetails;
+import org.apache.juddi.util.Config;
+import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Aspect used to support CDATA sections from within jUDDI.
+ *
+ * Also intercepts calls for services when constructing the organizational information.
+ *
+ * @author <a href='mailto:Kevin.Conner at jboss.com'>Kevin Conner</a>
+ */
+public class JUDDIAspect
+{
+ public Object getText(final MethodInvocation invocation)
+ throws Throwable
+ {
+ final Object[] args = invocation.getArguments() ;
+ final Element element = (Element)args[0] ;
+ final StringBuffer sb = new StringBuffer();
+
+ final NodeList nodeList = element.getChildNodes() ;
+ final int numNodes = nodeList.getLength() ;
+ for(int count = 0 ; count < numNodes ; count++)
+ {
+ final Node node = nodeList.item(count) ;
+ final short type = node.getNodeType() ;
+ if ((type == Element.TEXT_NODE) || (type == Element.CDATA_SECTION_NODE))
+ {
+ sb.append(node.getNodeValue()) ;
+ }
+ }
+
+ return sb.toString().trim();
+ }
+
+ public Object fetchServiceByBusinessKey(final MethodCalledByMethodInvocation invocation)
+ throws Throwable
+ {
+ return new Vector<Object>() ;
+ }
+
+ public Object fetchBindingByServiceKey(final MethodCalledByMethodInvocation invocation)
+ throws Throwable
+ {
+ final JDBCDataStore jdbcDataStore = (JDBCDataStore)invocation.getTargetObject() ;
+ final Object[] args = invocation.getArguments() ;
+ final String serviceKey = (String)args[0] ;
+ final Connection connection = jdbcDataStore.getConnection() ;
+ if (connection != null)
+ {
+ final Vector<BindingTemplate> result = JBossESBDataStore.selectByServiceKey(serviceKey,connection);
+ if (result.size() > 0)
+ {
+ final TModelInstanceDetails dummyDetails = new TModelInstanceDetails() ;
+ for (BindingTemplate bindingTemplate: result)
+ {
+ bindingTemplate.setTModelInstanceDetails(dummyDetails) ;
+ }
+ }
+ return result ;
+ }
+ else
+ {
+ return new Vector(0) ;
+ }
+ }
+
+ public Object getStringProperty(final MethodCalledByMethodInvocation invocation)
+ throws Throwable
+ {
+ final Object[] args = invocation.getArguments() ;
+ final String key = (String)args[0] ;
+ return Config.getStringProperty(key) ;
+ }
+
+ public Object setProperty(final MethodCalledByMethodInvocation invocation)
+ throws Throwable
+ {
+ final Object[] args = invocation.getArguments() ;
+ final Object value = args[1] ;
+ if (value != null)
+ {
+ return invocation.invokeNext() ;
+ }
+ else
+ {
+ return null ;
+ }
+ }
+}
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/ScoutAspect.java (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/ScoutAspect.java)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/ScoutAspect.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/ScoutAspect.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.internal.soa.esb.services.registry.aspect;
+
+import javax.xml.registry.LifeCycleManager;
+import javax.xml.registry.infomodel.Service;
+
+import org.apache.ws.scout.registry.BusinessQueryManagerImpl;
+import org.apache.ws.scout.registry.infomodel.ServiceImpl;
+import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
+
+/**
+ * Aspect used to prevent scout from loading the complete service
+ * graph for the registry just to return a binding.
+ *
+ * Updated to intercept calls for the organizational information when
+ * querying a specific service.
+ *
+ * @author <a href='mailto:Kevin.Conner at jboss.com'>Kevin Conner</a>
+ */
+public class ScoutAspect
+{
+ public Object getRegistryObject(final MethodCalledByMethodInvocation invocation)
+ throws Throwable
+ {
+ final BusinessQueryManagerImpl bqmImpl = (BusinessQueryManagerImpl)invocation.getCallingObject() ;
+ final Object[] args = invocation.getArguments() ;
+ final String id = (String)args[0] ;
+ final String objectType = (String)args[1] ;
+
+ if (LifeCycleManager.SERVICE.equals(objectType))
+ {
+ final LifeCycleManager lcm = bqmImpl.getRegistryService().getBusinessLifeCycleManager() ;
+ final Service service = new ServiceImpl(lcm);
+ service.setKey(lcm.createKey(id));
+ return service ;
+ }
+ else
+ {
+ return invocation.invokeNext() ;
+ }
+ }
+}
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/resources/META-INF/jboss-aop.xml
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/aop/resources/META-INF/jboss-aop.xml 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/resources/META-INF/jboss-aop.xml 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE aop PUBLIC
- "-//JBoss//DTD JBOSS AOP 1.0//EN"
- "http://labs.jboss.com/portal/jbossaop/dtd/jboss-aop_1_0.dtd">
-
-<aop>
- <aspect class="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect" scope="PER_VM"/>
-
- <bind pointcut="execution(* org.apache.juddi.util.xml.XMLUtils->getText(..))">
- <advice name="getText" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
- </bind>
-
- <bind pointcut="withincode(* org.apache.juddi.datastore.jdbc.JDBCDataStore->fetchBusiness(..)) AND call(* org.apache.juddi.datastore.jdbc.JDBCDataStore->fetchServiceByBusinessKey(..))">
- <advice name="fetchServiceByBusinessKey" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
- </bind>
-
- <bind pointcut="withincode(* org.apache.juddi.registry.rmi.JNDIRegistration->register()) AND call(* org.apache.juddi.util.Config->getStringProperty(..))">
- <advice name="getStringProperty" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
- </bind>
-
- <bind pointcut="withincode(* org.apache.juddi.registry.rmi.JNDIRegistration->register()) AND call(* java.util.Properties->setProperty(..))">
- <advice name="setProperty" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
- </bind>
-</aop>
-
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/resources/META-INF/jboss-aop.xml (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/aop/resources/META-INF/jboss-aop.xml)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/resources/META-INF/jboss-aop.xml (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/aop/resources/META-INF/jboss-aop.xml 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE aop PUBLIC
+ "-//JBoss//DTD JBOSS AOP 1.0//EN"
+ "http://labs.jboss.com/portal/jbossaop/dtd/jboss-aop_1_0.dtd">
+
+<aop>
+ <aspect class="org.jboss.internal.soa.esb.services.registry.aspect.ScoutAspect" scope="PER_VM"/>
+ <aspect class="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect" scope="PER_VM"/>
+
+ <bind pointcut="withincode(* org.apache.ws.scout.registry.BusinessQueryManagerImpl->findServiceBindings(..)) AND call(* org.apache.ws.scout.registry.BusinessQueryManagerImpl->getRegistryObject(..))">
+ <advice name="getRegistryObject" aspect="org.jboss.internal.soa.esb.services.registry.aspect.ScoutAspect"/>
+ </bind>
+
+ <bind pointcut="execution(* org.apache.juddi.util.xml.XMLUtils->getText(..))">
+ <advice name="getText" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
+ </bind>
+
+ <bind pointcut="withincode(* org.apache.juddi.datastore.jdbc.JDBCDataStore->fetchBusiness(..)) AND call(* org.apache.juddi.datastore.jdbc.JDBCDataStore->fetchServiceByBusinessKey(..))">
+ <advice name="fetchServiceByBusinessKey" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
+ </bind>
+
+ <bind pointcut="withincode(* org.apache.juddi.datastore.jdbc.JDBCDataStore->fetchService(..)) AND call(* org.apache.juddi.datastore.jdbc.JDBCDataStore->fetchBindingByServiceKey(..))">
+ <advice name="fetchBindingByServiceKey" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
+ </bind>
+
+ <bind pointcut="withincode(* org.apache.juddi.registry.rmi.JNDIRegistration->register()) AND call(* org.apache.juddi.util.Config->getStringProperty(..))">
+ <advice name="getStringProperty" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
+ </bind>
+
+ <bind pointcut="withincode(* org.apache.juddi.registry.rmi.JNDIRegistration->register()) AND call(* java.util.Properties->setProperty(..))">
+ <advice name="setProperty" aspect="org.jboss.internal.soa.esb.services.registry.aspect.JUDDIAspect"/>
+ </bind>
+</aop>
+
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/build.xml
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/build.xml 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/build.xml 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,210 +0,0 @@
-<?xml version="1.0"?>
-<project name="BuildJbossEsbRosetta" default="org.jboss.esb.rosetta.compile" basedir=".">
-
- <property name="org.jboss.esb.rosetta.jar.name" value="jbossesb-rosetta"/>
- <property name="org.jboss.esb.rosetta.distrib.dir" location="${org.jboss.esb.internal.dest}/jbossesb"/>
- <property name="org.jboss.esb.rosetta.classes.dir" location="${org.jboss.esb.internal.dest}/classes/rosetta"/>
- <property name="org.jboss.esb.rosetta.aop.classes.dir" location="${org.jboss.esb.rosetta.classes.dir}-aop"/>
- <property name="org.jboss.esb.rosetta.aopc.juddi.classes.dir" location="${org.jboss.esb.rosetta.classes.dir}-juddi-aopc"/>
- <property name="org.jboss.esb.rosetta.src.dir" location="src"/>
- <property name="org.jboss.esb.root.dir" location="../"/>
- <property name="gendir" location="${org.jboss.esb.internal.dest}/schema-model" />
- <property environment="env"/>
-
- <property name="org.jboss.esb.lib.dir" location="${org.jboss.esb.internal.dest}/lib"/>
- <property name="org.jboss.esb.aoplib.dir" location="${org.jboss.esb.internal.dest}/aoplib"/>
- <property name="org.jboss.esb.ext.lib.dir" location="${org.jboss.esb.root.dir}/lib/ext"/>
-
- <path id="org.jboss.esb.rosetta.base.classpath">
- <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="*.jar"/>
- <fileset dir="${org.jboss.esb.lib.dir}" includes="*.jar"/>
- <fileset dir="../../testlib" includes="emma*.jar"/>
- <fileset dir="${org.jboss.esb.ext.lib.dir}/standalone" includes="*.jar"/>
- <pathelement location="${gendir}/classes"/>
- </path>
-
- <target name="org.jboss.esb.rosetta.init">
- <tstamp>
- <format property="TODAY" pattern="dd-MM-yy"/>
- </tstamp>
- </target>
-
- <target name="org.jboss.esb.rosetta.prepare" depends="org.jboss.esb.rosetta.init">
- <mkdir dir="${org.jboss.esb.rosetta.classes.dir}"/>
- <mkdir dir="${org.jboss.esb.rosetta.distrib.dir}"/>
- <mkdir dir="${org.jboss.esb.rosetta.distrib.dir}/lib"/>
- <!-- aop dirs -->
- <mkdir dir="${org.jboss.esb.rosetta.aop.classes.dir}"/>
- <mkdir dir="${org.jboss.esb.aoplib.dir}"/>
- </target>
-
- <target name="clean" description="Remove classes directory">
- <ant dir="tests" target="clean"/>
- <delete dir="${org.jboss.esb.rosetta.classes.dir}"/>
- </target>
-
- <target name="org.jboss.esb.rosetta.compile" depends="generate-config-model, org.jboss.esb.rosetta.internal.compile, aop">
- <ant inheritAll="true" dir="tests" target="org.jboss.esb.rosetta.tests.compile"/>
- </target>
-
- <target name="org.jboss.esb.rosetta.internal.compile" depends="org.jboss.esb.rosetta.prepare"
- description="Compile all classes">
-
- <javac
- destdir="${org.jboss.esb.rosetta.classes.dir}"
- classpathref="org.jboss.esb.rosetta.base.classpath"
- debug="${org.jboss.esb.debug}"
- optimize="${org.jboss.esb.optimize}"
- >
- <src path="${org.jboss.esb.rosetta.src.dir}"/>
- </javac>
-
- </target>
-
- <target name="recompile" depends="clean,org.jboss.esb.rosetta.compile"
- description="Clean and compile"/>
-
- <target name="jar" depends="org.jboss.esb.rosetta.compile" description="Assemble jar files">
- <delete file="${org.jboss.esb.rosetta.distrib.dir}/lib/${org.jboss.esb.rosetta.jar.name}.jar" />
-
- <delete file="${org.jboss.esb.rosetta.classes.dir}/VERSION"/>
- <propertyfile file="${org.jboss.esb.rosetta.classes.dir}/VERSION" comment="JBoss ESB Product Information">
- <entry key="Version" value="${version}"/>
- </propertyfile>
-
- <manifest file="${org.jboss.esb.rosetta.classes.dir}/MANIFEST.MF">
- <attribute name="Built-By" value="${user.name}"/>
- <attribute name="Main-Class" value="org.jboss.soa.esb.Version"/>
- <section name="JBoss ESB">
- <attribute name="Specification-Title" value="${esb.server.name}"/>
- <attribute name="Specification-Version" value="${version}"/>
- <attribute name="Specification-Vendor" value="JBoss"/>
- <attribute name="Implementation-Version" value="${version} ${TODAY}"/>
- </section>
- </manifest>
-
- <jar destfile="${org.jboss.esb.rosetta.distrib.dir}/lib/${org.jboss.esb.rosetta.jar.name}.jar"
- basedir="${org.jboss.esb.rosetta.classes.dir}"
- includes="**/*.class,VERSION"
- manifest="${org.jboss.esb.rosetta.classes.dir}/MANIFEST.MF"
- excludes="test/**"
- >
- <fileset dir="${org.jboss.esb.rosetta.src.dir}" includes="**/*.groovy"/>
- <fileset dir="${org.jboss.esb.rosetta.src.dir}" includes="**/*.properties"/>
- <fileset dir="${org.jboss.esb.rosetta.src.dir}" includes="**/*.ftl"/>
- <fileset dir="${org.jboss.esb.rosetta.src.dir}" includes="org/jboss/soa/esb/services/security/auth/ws/smooks-ws-security.xml"/>
- </jar>
-
- <jar destfile="${org.jboss.esb.rosetta.distrib.dir}/lib/test-util.jar" manifest="${org.jboss.esb.rosetta.classes.dir}/MANIFEST.MF">
- <fileset dir="${org.jboss.esb.rosetta.classes.dir}"
- includes="VERSION org/jboss/soa/**/Version.class"/>
- <fileset dir="${org.jboss.esb.internal.dest}/tests/"
- includes="org/jboss/soa/esb/testutils/**/*.class"/>
- <fileset dir="tests/src" includes="org/jboss/soa/esb/testutils/*.properties"/>
- <fileset dir="tests/src" includes="org/jboss/soa/esb/testutils/*.xml"/>
- <fileset dir="${org.jboss.esb.internal.dest}/tests/"
- includes="org/jboss/soa/esb/common/tests/*.class"/>
- <fileset dir="${org.jboss.esb.internal.dest}/tests/"
- includes="org/jboss/**/Mock*.class"/>
- </jar>
- </target>
-
- <target name="org.jboss.esb.rosetta.test" depends="org.jboss.esb.rosetta.compile" description="Run tests for this module">
- <!-- Compile rosetta tests -->
- <ant dir="tests" target="org.jboss.esb.rosetta.internal.test"/>
- </target>
-
- <target name="org.jboss.esb.rosetta.integration.test" description="Run integration tests for this module">
- <!-- Compile rosetta integration tests -->
- <ant dir="tests" target="org.jboss.esb.rosetta.internal.integration.test"/>
- </target>
-
- <target name="all" depends="recompile,jar" />
-
- <target name="generate-config-model" depends="org.jboss.esb.rosetta.prepare">
-
- <delete file="${org.jboss.esb.rosetta.classes.dir}/VERSION"/>
- <propertyfile file="${org.jboss.esb.rosetta.classes.dir}/VERSION" comment="JBoss ESB Product Information">
- <entry key="Version" value="${version}"/>
- </propertyfile>
-
- <manifest file="${org.jboss.esb.rosetta.classes.dir}/MANIFEST.MF">
- <attribute name="Built-By" value="${user.name}"/>
- <attribute name="Main-Class" value="org.jboss.soa.esb.Version"/>
- <section name="JBoss ESB">
- <attribute name="Specification-Title" value="${esb.server.name}"/>
- <attribute name="Specification-Version" value="${version}"/>
- <attribute name="Specification-Vendor" value="JBoss"/>
- <attribute name="Implementation-Version" value="${version} ${TODAY}"/>
- </section>
- </manifest>
-
- <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean" classpathref="xbeans-classpath" />
- <delete dir="${gendir}" /><mkdir dir="${gendir}" />
-
- <xmlbean
- classgendir="${gendir}/classes"
- javasource="1.5"
- debug="${org.jboss.esb.debug}"
- srcgendir="${gendir}/src"
- destfile="${org.jboss.esb.rosetta.distrib.dir}/lib/jbossesb-config-model-1.0.1.jar"
- classpathref="xbeans-classpath">
- <fileset dir="${org.jboss.esb.root.dir}/etc/schemas/xml/" includes="jbossesb-1.0.1.xsd,jbossesb-1.0.1.xsdconfig"/>
- </xmlbean>
- <!-- now add the xsd to it -->
- <jar destfile="${org.jboss.esb.rosetta.distrib.dir}/lib/jbossesb-config-model-1.0.1.jar" update="true" manifest="${org.jboss.esb.rosetta.classes.dir}/MANIFEST.MF"
- basedir="${org.jboss.esb.root.dir}/etc/schemas/xml/"
- includes="jbossesb-1.0.1.xsd">
- <fileset dir="${org.jboss.esb.rosetta.classes.dir}"
- includes="VERSION org/jboss/soa/**/Version.class"/>
- </jar>
- </target>
-
- <path id="xbeans-classpath">
- <fileset dir="${org.jboss.esb.lib.dir}" includes="*.jar"/>
- <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="*.jar"/>
- </path>
-
- <property name="coverage.dir" location="${org.jboss.esb.internal.dest}/tests/coverage"/>
-
- <path id="aop-classpath">
- <fileset dir="${org.jboss.esb.lib.dir}" includes="jboss-aop-*.jar, javassist-*.jar, jbossall-client-*.jar, xbean-*.jar"/>
- <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="trove.jar"/>
- </path>
-
- <target name="aop" depends="aop-jar">
- <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="aop-classpath"/>
-
- <delete dir="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}" quiet="true"/>
- <mkdir dir="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
-
- <unzip src="${org.jboss.esb.lib.dir}/juddi-2.0rc5.jar" dest="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
-
- <aopc compilerclasspathref="aop-classpath">
- <classpath>
- <pathelement path="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
- <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="commons-logging*.jar"/>
- </classpath>
- <src path="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
- <include name="org/apache/juddi/util/xml/XMLUtils.class"/>
- <include name="org/apache/juddi/datastore/jdbc/JDBCDataStore.class"/>
- <include name="org/apache/juddi/registry/rmi/JNDIRegistration.class"/>
- <aoppath path="aop/resources/META-INF/jboss-aop.xml"/>
- <aopclasspath path="${org.jboss.esb.rosetta.aop.classes.dir}"/>
- </aopc>
- <zip destfile="${org.jboss.esb.aoplib.dir}/juddi-2.0rc5.aop.jar" basedir="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
- </target>
-
- <target name="aop-jar" depends="aop-compile">
- <jar destfile="${org.jboss.esb.internal.dest}/rosetta.aop">
- <fileset dir="${org.jboss.esb.rosetta.aop.classes.dir}"/>
- <fileset dir="aop/resources"/>
- </jar>
- </target>
-
- <target name="aop-compile">
- <javac srcdir="aop/java" destdir="${org.jboss.esb.rosetta.aop.classes.dir}"
- debug="${org.jboss.esb.debug}" optimize="${org.jboss.esb.optimize}"
- classpathref="org.jboss.esb.rosetta.base.classpath"/>
- </target>
-</project>
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/build.xml (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/build.xml)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/build.xml (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/build.xml 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,221 @@
+<?xml version="1.0"?>
+<project name="BuildJbossEsbRosetta" default="org.jboss.esb.rosetta.compile" basedir=".">
+
+ <property name="org.jboss.esb.rosetta.jar.name" value="jbossesb-rosetta"/>
+ <property name="org.jboss.esb.rosetta.distrib.dir" location="${org.jboss.esb.internal.dest}/jbossesb"/>
+ <property name="org.jboss.esb.rosetta.classes.dir" location="${org.jboss.esb.internal.dest}/classes/rosetta"/>
+ <property name="org.jboss.esb.rosetta.aop.classes.dir" location="${org.jboss.esb.rosetta.classes.dir}-aop"/>
+ <property name="org.jboss.esb.rosetta.aopc.scout.classes.dir" location="${org.jboss.esb.rosetta.classes.dir}-scout-aopc"/>
+ <property name="org.jboss.esb.rosetta.aopc.juddi.classes.dir" location="${org.jboss.esb.rosetta.classes.dir}-juddi-aopc"/>
+ <property name="org.jboss.esb.rosetta.src.dir" location="src"/>
+ <property name="org.jboss.esb.root.dir" location="../"/>
+ <property name="gendir" location="${org.jboss.esb.internal.dest}/schema-model" />
+ <property environment="env"/>
+
+ <property name="org.jboss.esb.lib.dir" location="${org.jboss.esb.internal.dest}/lib"/>
+ <property name="org.jboss.esb.aoplib.dir" location="${org.jboss.esb.internal.dest}/aoplib"/>
+ <property name="org.jboss.esb.ext.lib.dir" location="${org.jboss.esb.root.dir}/lib/ext"/>
+
+ <path id="org.jboss.esb.rosetta.base.classpath">
+ <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="*.jar"/>
+ <fileset dir="${org.jboss.esb.lib.dir}" includes="*.jar"/>
+ <fileset dir="../../testlib" includes="emma*.jar"/>
+ <fileset dir="${org.jboss.esb.ext.lib.dir}/standalone" includes="*.jar"/>
+ <pathelement location="${gendir}/classes"/>
+ </path>
+
+ <target name="org.jboss.esb.rosetta.init">
+ <tstamp>
+ <format property="TODAY" pattern="dd-MM-yy"/>
+ </tstamp>
+ </target>
+
+ <target name="org.jboss.esb.rosetta.prepare" depends="org.jboss.esb.rosetta.init">
+ <mkdir dir="${org.jboss.esb.rosetta.classes.dir}"/>
+ <mkdir dir="${org.jboss.esb.rosetta.distrib.dir}"/>
+ <mkdir dir="${org.jboss.esb.rosetta.distrib.dir}/lib"/>
+ <!-- aop dirs -->
+ <mkdir dir="${org.jboss.esb.rosetta.aop.classes.dir}"/>
+ <mkdir dir="${org.jboss.esb.aoplib.dir}"/>
+ </target>
+
+ <target name="clean" description="Remove classes directory">
+ <ant dir="tests" target="clean"/>
+ <delete dir="${org.jboss.esb.rosetta.classes.dir}"/>
+ </target>
+
+ <target name="org.jboss.esb.rosetta.compile" depends="generate-config-model, org.jboss.esb.rosetta.internal.compile, aop">
+ <ant inheritAll="true" dir="tests" target="org.jboss.esb.rosetta.tests.compile"/>
+ </target>
+
+ <target name="org.jboss.esb.rosetta.internal.compile" depends="org.jboss.esb.rosetta.prepare"
+ description="Compile all classes">
+
+ <javac
+ destdir="${org.jboss.esb.rosetta.classes.dir}"
+ classpathref="org.jboss.esb.rosetta.base.classpath"
+ debug="${org.jboss.esb.debug}"
+ optimize="${org.jboss.esb.optimize}"
+ >
+ <src path="${org.jboss.esb.rosetta.src.dir}"/>
+ </javac>
+
+ </target>
+
+ <target name="recompile" depends="clean,org.jboss.esb.rosetta.compile"
+ description="Clean and compile"/>
+
+ <target name="jar" depends="org.jboss.esb.rosetta.compile" description="Assemble jar files">
+ <delete file="${org.jboss.esb.rosetta.distrib.dir}/lib/${org.jboss.esb.rosetta.jar.name}.jar" />
+
+ <delete file="${org.jboss.esb.rosetta.classes.dir}/VERSION"/>
+ <propertyfile file="${org.jboss.esb.rosetta.classes.dir}/VERSION" comment="JBoss ESB Product Information">
+ <entry key="Version" value="${version}"/>
+ </propertyfile>
+
+ <manifest file="${org.jboss.esb.rosetta.classes.dir}/MANIFEST.MF">
+ <attribute name="Built-By" value="${user.name}"/>
+ <attribute name="Main-Class" value="org.jboss.soa.esb.Version"/>
+ <section name="JBoss ESB">
+ <attribute name="Specification-Title" value="${esb.server.name}"/>
+ <attribute name="Specification-Version" value="${version}"/>
+ <attribute name="Specification-Vendor" value="JBoss"/>
+ <attribute name="Implementation-Version" value="${version} ${TODAY}"/>
+ </section>
+ </manifest>
+
+ <jar destfile="${org.jboss.esb.rosetta.distrib.dir}/lib/${org.jboss.esb.rosetta.jar.name}.jar"
+ basedir="${org.jboss.esb.rosetta.classes.dir}"
+ includes="**/*.class,VERSION"
+ manifest="${org.jboss.esb.rosetta.classes.dir}/MANIFEST.MF"
+ excludes="test/**"
+ >
+ <fileset dir="${org.jboss.esb.rosetta.src.dir}" includes="**/*.groovy"/>
+ <fileset dir="${org.jboss.esb.rosetta.src.dir}" includes="**/*.properties"/>
+ <fileset dir="${org.jboss.esb.rosetta.src.dir}" includes="**/*.ftl"/>
+ <fileset dir="${org.jboss.esb.rosetta.src.dir}" includes="org/jboss/soa/esb/services/security/auth/ws/smooks-ws-security.xml"/>
+ </jar>
+
+ <jar destfile="${org.jboss.esb.rosetta.distrib.dir}/lib/test-util.jar" manifest="${org.jboss.esb.rosetta.classes.dir}/MANIFEST.MF">
+ <fileset dir="${org.jboss.esb.rosetta.classes.dir}"
+ includes="VERSION org/jboss/soa/**/Version.class"/>
+ <fileset dir="${org.jboss.esb.internal.dest}/tests/"
+ includes="org/jboss/soa/esb/testutils/**/*.class"/>
+ <fileset dir="tests/src" includes="org/jboss/soa/esb/testutils/*.properties"/>
+ <fileset dir="tests/src" includes="org/jboss/soa/esb/testutils/*.xml"/>
+ <fileset dir="${org.jboss.esb.internal.dest}/tests/"
+ includes="org/jboss/soa/esb/common/tests/*.class"/>
+ <fileset dir="${org.jboss.esb.internal.dest}/tests/"
+ includes="org/jboss/**/Mock*.class"/>
+ </jar>
+ </target>
+
+ <target name="org.jboss.esb.rosetta.test" depends="org.jboss.esb.rosetta.compile" description="Run tests for this module">
+ <!-- Compile rosetta tests -->
+ <ant dir="tests" target="org.jboss.esb.rosetta.internal.test"/>
+ </target>
+
+ <target name="org.jboss.esb.rosetta.integration.test" description="Run integration tests for this module">
+ <!-- Compile rosetta integration tests -->
+ <ant dir="tests" target="org.jboss.esb.rosetta.internal.integration.test"/>
+ </target>
+
+ <target name="all" depends="recompile,jar" />
+
+ <target name="generate-config-model" depends="org.jboss.esb.rosetta.prepare">
+
+ <delete file="${org.jboss.esb.rosetta.classes.dir}/VERSION"/>
+ <propertyfile file="${org.jboss.esb.rosetta.classes.dir}/VERSION" comment="JBoss ESB Product Information">
+ <entry key="Version" value="${version}"/>
+ </propertyfile>
+
+ <manifest file="${org.jboss.esb.rosetta.classes.dir}/MANIFEST.MF">
+ <attribute name="Built-By" value="${user.name}"/>
+ <attribute name="Main-Class" value="org.jboss.soa.esb.Version"/>
+ <section name="JBoss ESB">
+ <attribute name="Specification-Title" value="${esb.server.name}"/>
+ <attribute name="Specification-Version" value="${version}"/>
+ <attribute name="Specification-Vendor" value="JBoss"/>
+ <attribute name="Implementation-Version" value="${version} ${TODAY}"/>
+ </section>
+ </manifest>
+
+ <taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean" classpathref="xbeans-classpath" />
+ <delete dir="${gendir}" /><mkdir dir="${gendir}" />
+
+ <xmlbean
+ classgendir="${gendir}/classes"
+ javasource="1.5"
+ debug="${org.jboss.esb.debug}"
+ srcgendir="${gendir}/src"
+ destfile="${org.jboss.esb.rosetta.distrib.dir}/lib/jbossesb-config-model-1.0.1.jar"
+ classpathref="xbeans-classpath">
+ <fileset dir="${org.jboss.esb.root.dir}/etc/schemas/xml/" includes="jbossesb-1.0.1.xsd,jbossesb-1.0.1.xsdconfig"/>
+ </xmlbean>
+ <!-- now add the xsd to it -->
+ <jar destfile="${org.jboss.esb.rosetta.distrib.dir}/lib/jbossesb-config-model-1.0.1.jar" update="true" manifest="${org.jboss.esb.rosetta.classes.dir}/MANIFEST.MF"
+ basedir="${org.jboss.esb.root.dir}/etc/schemas/xml/"
+ includes="jbossesb-1.0.1.xsd">
+ <fileset dir="${org.jboss.esb.rosetta.classes.dir}"
+ includes="VERSION org/jboss/soa/**/Version.class"/>
+ </jar>
+ </target>
+
+ <path id="xbeans-classpath">
+ <fileset dir="${org.jboss.esb.lib.dir}" includes="*.jar"/>
+ <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="*.jar"/>
+ </path>
+
+ <property name="coverage.dir" location="${org.jboss.esb.internal.dest}/tests/coverage"/>
+
+ <path id="aop-classpath">
+ <fileset dir="${org.jboss.esb.lib.dir}" includes="jboss-aop-*.jar, javassist-*.jar, jbossall-client-*.jar, xbean-*.jar"/>
+ <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="trove.jar"/>
+ </path>
+
+ <target name="aop" depends="aop-jar">
+ <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="aop-classpath"/>
+
+ <delete dir="${org.jboss.esb.rosetta.aopc.scout.classes.dir}" quiet="true"/>
+ <delete dir="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}" quiet="true"/>
+ <mkdir dir="${org.jboss.esb.rosetta.aopc.scout.classes.dir}"/>
+ <mkdir dir="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
+
+ <unzip src="${org.jboss.esb.lib.dir}/scout-1.0.jar" dest="${org.jboss.esb.rosetta.aopc.scout.classes.dir}"/>
+ <unzip src="${org.jboss.esb.lib.dir}/juddi-2.0rc5.jar" dest="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
+
+ <aopc compilerclasspathref="aop-classpath">
+ <classpath path="${org.jboss.esb.rosetta.aopc.scout.classes.dir}"/>
+ <src path="${org.jboss.esb.rosetta.aopc.scout.classes.dir}"/>
+ <aoppath path="aop/resources/META-INF/jboss-aop.xml"/>
+ <aopclasspath path="${org.jboss.esb.rosetta.aop.classes.dir}"/>
+ </aopc>
+ <aopc compilerclasspathref="aop-classpath">
+ <classpath>
+ <pathelement path="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
+ <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="commons-logging*.jar"/>
+ </classpath>
+ <src path="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
+ <include name="org/apache/juddi/util/xml/XMLUtils.class"/>
+ <include name="org/apache/juddi/datastore/jdbc/JDBCDataStore.class"/>
+ <include name="org/apache/juddi/registry/rmi/JNDIRegistration.class"/>
+ <aoppath path="aop/resources/META-INF/jboss-aop.xml"/>
+ <aopclasspath path="${org.jboss.esb.rosetta.aop.classes.dir}"/>
+ </aopc>
+ <zip destfile="${org.jboss.esb.aoplib.dir}/scout-1.0.aop.jar" basedir="${org.jboss.esb.rosetta.aopc.scout.classes.dir}"/>
+ <zip destfile="${org.jboss.esb.aoplib.dir}/juddi-2.0rc5.aop.jar" basedir="${org.jboss.esb.rosetta.aopc.juddi.classes.dir}"/>
+ </target>
+
+ <target name="aop-jar" depends="aop-compile">
+ <jar destfile="${org.jboss.esb.internal.dest}/rosetta.aop">
+ <fileset dir="${org.jboss.esb.rosetta.aop.classes.dir}"/>
+ <fileset dir="aop/resources"/>
+ </jar>
+ </target>
+
+ <target name="aop-compile">
+ <javac srcdir="aop/java" destdir="${org.jboss.esb.rosetta.aop.classes.dir}"
+ debug="${org.jboss.esb.debug}" optimize="${org.jboss.esb.optimize}"
+ classpathref="org.jboss.esb.rosetta.base.classpath"/>
+ </target>
+</project>
Added: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionExceptionHandler.java
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionExceptionHandler.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionExceptionHandler.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.rosetta.pooling;
+
+import javax.jms.JMSException;
+
+/**
+ * Interface to enable testing of exceptions for connection errors.
+ *
+ * @author <a href="mailto:Kevin.Conner at jboss.com">Kevin Conner</a>
+ */
+public interface JmsConnectionExceptionHandler
+{
+ /**
+ * Check the exception to see whether it indicates a connection failure
+ * @param jmse The current JMS Exception
+ * @return null if no connection failure, TRUE if the connection should be closed, FALSE if just cleaned up.
+ */
+ public Boolean isConnectionFailure(final JMSException jmse) ;
+}
Property changes on: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionExceptionHandler.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,1066 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.internal.soa.esb.rosetta.pooling;
-
-import java.sql.SQLException;
-import java.util.*;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ThreadFactory;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.Session;
-import javax.jms.XAConnection;
-import javax.jms.XAConnectionFactory;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.common.Environment;
-import org.jboss.soa.esb.common.ModulePropertyManager;
-import org.jboss.soa.esb.common.TransactionStrategy;
-import org.jboss.soa.esb.common.TransactionStrategyException;
-import org.jboss.soa.esb.helpers.NamingContextException;
-import org.jboss.soa.esb.helpers.NamingContextPool;
-
-import com.arjuna.common.util.propertyservice.PropertyManager;
-
-/**
- * JmsConnectionPool.
- *
- * @author kstam
- * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
- * Date: March 10, 2007
- */
-public class JmsConnectionPool
-{
- private static final int DEFAULT_POOL_SIZE = 20;
- private static final int DEFAULT_SLEEP = 30;
-
- private static int CONFIGURED_POOL_SIZE = DEFAULT_POOL_SIZE;
- private static int CONFIGURED_SLEEP = DEFAULT_SLEEP;
-
- /**
- * The executor used to create sessions.
- */
- private static final Executor SESSION_EXECUTOR = Executors.newSingleThreadExecutor(new DaemonThreadFactory()) ;
- /**
- * The completion service.
- */
- private static final CompletionService<JmsSession> COMPLETION_SERVICE = new ExecutorCompletionService<JmsSession>(SESSION_EXECUTOR) ;
-
- /** Maximum number of Sessions that will be created in this pool */
- private int maxSessions = DEFAULT_POOL_SIZE; //TODO Make this manageable
-
- /**
- * The max number of sessions per connection. Defaults to "maxSessions".
- */
- private int maxSessionsPerConnection;
-
- /**
- * The max number of XA sessions per connection. Defaults to "maxSessionsPerConnection".
- */
- private int maxXASessionsPerConnection;
-
- /** Time to sleep when trying to get a session. */
- private int sleepTime = DEFAULT_SLEEP;
-
- /** The Indentifier of the pool */
- private Map<String, String> poolKey;
- /** Logger */
- private Logger logger = Logger.getLogger(this.getClass());
-
- /**
- * JMS Session Pools.
- */
- private List<JmsSessionPool> sessionPools = new ArrayList<JmsSessionPool>();
- /**
- * The flag representing XA aware connections.
- */
- private boolean isXAAware ;
- /**
- * Flag signifying that the pool has been terminated.
- */
- private boolean terminated ;
- /**
- * The pool instance id.
- */
- private long id ;
-
- /**
- * Contructor of the pool.
- *
- */
- public JmsConnectionPool(Map<String, String> poolKey) throws ConnectionException {
- this(poolKey, JmsConnectionPool.CONFIGURED_POOL_SIZE, JmsConnectionPool.CONFIGURED_SLEEP);
- }
-
- public JmsConnectionPool(Map<String, String> poolKey, int poolSize, int sleepTime) throws ConnectionException {
- this.poolKey = poolKey;
-
- maxSessions = poolSize;
- this.sleepTime = sleepTime;
-
- maxSessionsPerConnection = getIntPoolConfig(poolKey, JMSEpr.MAX_SESSIONS_PER_CONNECTION, maxSessions);
- if(maxSessionsPerConnection < 1) {
- throw new ConnectionException("Invalid '" + JMSEpr.MAX_SESSIONS_PER_CONNECTION + "' configuration value '" + maxSessionsPerConnection + "'. Must be greater than 0.");
- }
- maxXASessionsPerConnection = getIntPoolConfig(poolKey, JMSEpr.MAX_XA_SESSIONS_PER_CONNECTION, maxSessionsPerConnection);
- if(maxXASessionsPerConnection < 1) {
- throw new ConnectionException("Invalid '" + JMSEpr.MAX_XA_SESSIONS_PER_CONNECTION + "' configuration value '" + maxXASessionsPerConnection + "'. Must be greater than 0.");
- } else if(maxXASessionsPerConnection > maxSessionsPerConnection) {
- throw new ConnectionException("Invalid '" + JMSEpr.MAX_XA_SESSIONS_PER_CONNECTION + "' configuration value '" + maxXASessionsPerConnection + "'. Cannot be greater than the configured value for '" + JMSEpr.MAX_SESSIONS_PER_CONNECTION + "', which is " + maxSessionsPerConnection + ".");
- }
- }
-
- private int getIntPoolConfig(Map<String, String> poolKey, String configKey, int defaultVal) throws ConnectionException {
- String configValueString = poolKey.get(configKey);
- int configValue = defaultVal;
-
- if(configValueString != null) {
- try {
- configValue = Integer.parseInt(configValueString.trim());
- } catch(NumberFormatException e) {
- throw new ConnectionException("Invalid '" + configKey + "' configuration value '" + configValueString.trim() + "'. Must be a valid Integer.");
- }
- }
-
- return configValue;
- }
-
- protected int getMaxSessions() {
- return maxSessions;
- }
-
- protected int getMaxSessionsPerConnection() {
- return maxSessionsPerConnection;
- }
-
- public int getMaxXASessionsPerConnection() {
- return maxXASessionsPerConnection;
- }
-
- protected List<JmsSessionPool> getSessionPools() {
- return sessionPools;
- }
-
- /**
- * This method can be called whenever a connection is needed from the pool.
- *
- * @return Connection to be used
- * @throws ConnectionException
- */
- public synchronized JmsSession getSession(final int acknowledgeMode) throws NamingException, JMSException, ConnectionException
- {
- if (terminated)
- {
- throw new ConnectionException("Connection pool has been terminated") ;
- }
-
- try
- {
- return internalGetSession(acknowledgeMode) ;
- }
- catch (final JMSException jmse)
- {
- /*
- * JBoss Messaging may drop the connection from the server side.
- * We check for IllegalStateException as this appears to be the indicator
- * exception used by JBoss Messaging when the connection has disappeared.
- */
- if (messagingConnectionFailure(jmse))
- {
- return internalGetSession(acknowledgeMode) ;
- }
- throw jmse ;
- }
- }
-
- private synchronized JmsSession internalGetSession(final int acknowledgeMode)
- throws NamingException, JMSException, ConnectionException
- {
- if(sessionPools.isEmpty()) {
- // Create the first pool entry...
- addSessionPool();
- }
-
- final Object factoryConnection ;
- try
- {
- factoryConnection = getFactoryConnection() ;
- }
- catch (final NamingContextException nce)
- {
- throw new ConnectionException("Unexpected exception accessing Naming Context", nce) ;
- }
- isXAAware = (factoryConnection instanceof XAConnectionFactory) ;
-
- final boolean transacted ;
- try {
- transacted = (isXAAware && TransactionStrategy.getTransactionStrategy(true).isActive()) ;
- } catch (final TransactionStrategyException tse) {
- throw new ConnectionException("Failed to determine current transaction context", tse) ;
- }
-
- if (transacted)
- {
- final JmsXASession currentSession = getXASession() ;
- if (currentSession != null)
- {
- return currentSession ;
- }
- }
-
- final int mode = (transacted ? Session.SESSION_TRANSACTED : acknowledgeMode) ;
- final long end = System.currentTimeMillis() + (sleepTime * 1000) ;
- boolean emitExpiry = logger.isDebugEnabled() ;
-
- while(true) {
- // Cycle through all the existing session pools and try getting a
- // free session. Will JmsSessionPool.getSession will add a session
- // to a pool that is not "full"...
- for (JmsSessionPool sessionPool : sessionPools) {
- try {
- JmsSession session = sessionPool.getSession(mode, transacted);
-
- if(session != null) {
- return session;
- }
- } catch (final JMSException jmse) {
- if (messagingConnectionFailure(jmse)) {
- sessionPool.cleanSessionPool() ;
- }
- throw jmse ;
- }
- }
-
- // OK... all the existing session pools are full and have no free sessions. If we can add
- // another session pool, add it and then start this loop again...
- if(getSessionsInPool() < maxSessions) {
- addSessionPool();
- continue;
- }
-
- // We've reached our max permitted number of connections and the sessions
- // associated with these connections are all in use. Drop into the
- // delay below and wait for a session to be freed...
- if (emitExpiry)
- {
- logger.debug("The connection pool was exhausted, waiting for a session to be released.") ;
- emitExpiry = false ;
- }
-
- // Wait and loop again...
- final long now = System.currentTimeMillis() ;
- final long delay = (end - now) ;
- if (delay <= 0)
- {
- throw new ConnectionException("Could not obtain a JMS connection from the pool after "+ sleepTime +"s.");
- }
- else
- {
- try
- {
- wait(delay) ;
- }
- catch (final InterruptedException ie) {} // ignore
- }
- }
- }
-
- private Object getFactoryConnection()
- throws NamingContextException, NamingException
- {
- String connectionFactoryString = poolKey.get(JMSEpr.CONNECTION_FACTORY_TAG);
- Object factoryConnection=null;
-
- Properties jndiEnvironment = JmsConnectionPoolContainer.getJndiEnvironment(poolKey);
- Context jndiContext = NamingContextPool.getNamingContext(jndiEnvironment);
- try
- {
- factoryConnection = jndiContext.lookup(connectionFactoryString);
- }
- catch (NamingException ne)
- {
- logger.info("Received NamingException, refreshing context.");
- jndiContext = NamingContextPool.replaceNamingContext(jndiContext, JmsConnectionPoolContainer.getJndiEnvironment(poolKey));
- factoryConnection = jndiContext.lookup(connectionFactoryString);
- }
- finally
- {
- NamingContextPool.releaseNamingContext(jndiContext) ;
- }
- return factoryConnection ;
- }
-
- private JmsSessionPool addSessionPool() throws NamingException, JMSException, ConnectionException {
- final JmsSessionPool sessionPool = new JmsSessionPool();
-
- // And add it to the pool...
- sessionPools.add(sessionPool);
-
- return sessionPool;
- }
-
- /**
- * This method can be called whenever a Session is needed from the pool.
- * @return
- * @throws NamingException
- * @throws JMSException
- * @throws ConnectionException
- */
- public JmsSession getSession() throws NamingException, JMSException, ConnectionException
- {
- return getSession(Session.AUTO_ACKNOWLEDGE);
- }
-
- /**
- * This method closes an open connection and returns the connection to the pool.
- * @param session The connection to be returned to the pool.
- * @throws SQLException
- * @deprecated
- */
- public void closeSession(Session session){
- if (session instanceof JmsSession) {
- closeSession((JmsSession)session) ;
- } else {
- logger.error("Invalid JMS Session type in closeSession: " + session);
- }
- }
-
- /**
- * This method closes an open connection and returns the connection to the pool.
- * @param session The connection to be returned to the pool.
- * @throws SQLException
- */
- public void closeSession(JmsSession session){
- session.handleCloseSession(this) ;
- }
-
- /**
- * Handle the real work of closing the connection.
- * @param session The session to close.
- */
- synchronized void handleCloseSession(final JmsSession session)
- {
- JmsSessionPool sessionPool = findOwnerPool(session);
-
- if(sessionPool != null) {
- sessionPool.handleCloseSession(session);
- }
- }
-
- /**
- * Handle the real work of releasing the connection.
- * @param session The session to release.
- */
- synchronized void handleReleaseSession(final JmsSession session)
- {
- session.releaseResources();
- try
- {
- session.close() ;
- }
- catch (final Throwable th) {} // ignore
- releaseInUseSession(session) ;
- }
-
- /**
- * Handle exceptions that occur in the session or its child objects.
- * @param jmsSession The jmsSession associated with the call.
- * @param jmse The JMSException to check.
- * @throws JMSException if the exception is to be overridden.
- */
- void handleException(final JmsSession jmsSession, final JMSException jmse)
- throws JMSException
- {
- if (messagingConnectionFailure(jmse))
- {
- final JmsSessionPool sessionPool = findOwnerPool(jmsSession);
-
- if(sessionPool != null) {
- sessionPool.cleanSessionPool() ;
- }
- throw new JmsConnectionFailureException("The underlying exception appears to have failed", jmse) ;
- }
- }
-
- /**
- * Check the exception to see whether it indicates a connection failure in JBM
- * @param jmse The current JMS Exception
- * @return true if it suggests a failure, false otherwise.
- */
- private boolean messagingConnectionFailure(final JMSException jmse)
- {
- /*
- * JBoss Messaging can drop the connection from the server side
- * without calling back on the exception listener. We check for
- * IllegalStateException as this appears to be the indicator
- * exception used by JBoss Messaging when the connection has disappeared.
- */
- Throwable cause = jmse ;
- while(cause.getCause() != null)
- {
- cause = cause.getCause() ;
- }
- return (cause instanceof IllegalStateException) ;
- }
-
- /**
- * Release a session from the in use mapping.
- * @param session The session to release.
- */
- private void releaseInUseSession(final JmsSession session)
- {
- JmsSessionPool sessionPool = findOwnerPool(session);
-
- if(sessionPool != null) {
- sessionPool.releaseInUseSession(session);
- }
-
- notifyAll() ;
- }
-
- /**
- * This method closes an open session without returning it to the pool.
- * @param session The session to be returned to the pool.
- * @throws SQLException
- */
- public synchronized void releaseSession(final JmsSession session) {
- session.handleReleaseSession(this) ;
- }
-
- /**
- * This method closes an open session without returning it to the pool.
- * @param session The session to be returned to the pool.
- * @throws SQLException
- * @deprecated
- */
- public synchronized void releaseSession(final Session session) {
- if (session instanceof JmsSession) {
- releaseSession((JmsSession)session) ;
- } else {
- logger.error("Invalid JMS Session type in releaseSession: " + session);
- }
- }
-
- /**
- * This method is called when the pool needs to destroyed. It closes all open sessions
- * and the connection and removes it from the container's poolMap.
- */
- public synchronized void removeSessionPool()
- {
- for(JmsSessionPool sessionPool : sessionPools) {
- try {
- sessionPool.removeSessionPool();
- } catch(Exception e) {
- logger.error("Exception while removing JmsSessionPool.", e);
- }
- }
-
- sessionPools.clear();
- terminated = true ;
- JmsConnectionPoolContainer.removePool(poolKey);
- }
- /**
- * Gets the total number of sessions in the pool regardless of the acknowlede mode
- * used when creating the sessions.
- * @return the session pool size
- */
- public int getSessionsInPool() {
- return getSessionsInPool(Session.AUTO_ACKNOWLEDGE) +
- getSessionsInPool(Session.CLIENT_ACKNOWLEDGE) +
- getSessionsInPool(Session.DUPS_OK_ACKNOWLEDGE) +
- getSessionsInPool(Session.SESSION_TRANSACTED) ;
- }
-
- /**
- * Returns the total nr of sessions for the specifed acknowledge mode
- *
- * @param acknowledgeMode the acknowledge mode of sessions
- * @return
- */
- public synchronized int getSessionsInPool(final int acknowledgeMode) {
- return getFreeSessionsInPool(acknowledgeMode) + getInUseSessionsInPool(acknowledgeMode) ;
- }
-
- /**
- * Get the number of free sessions created with the specified acknowledge mode
- * @param acknowledgeMode the acknowledge mode of sessions
- * @return int the number of in use sessions
- */
- public synchronized int getFreeSessionsInPool(final int acknowledgeMode) {
- int count = 0;
-
- for(JmsSessionPool sessionPool : sessionPools) {
- count += sessionPool.getFreeSessionsInPool(acknowledgeMode);
- }
-
- return count;
- }
-
- /**
- * Get the number of sessions that are in use and that were
- * created with the specified acknowledge mode
- * @param acknowledgeMode the acknowledge mode of sessions
- * @return int the number of in use sessions
- */
- public synchronized int getInUseSessionsInPool(final int acknowledgeMode) {
- int count = 0;
-
- for(JmsSessionPool sessionPool : sessionPools) {
- count += sessionPool.getInUseSessionsInPool(acknowledgeMode);
- }
-
- return count;
- }
-
- /**
- * Get the current transaction.
- * @return The transaction or null if none present.
- * @throws ConnectionException if the transaction context cannot be obtained.
- */
- private Object getTransaction()
- throws ConnectionException
- {
- try {
- return TransactionStrategy.getTransactionStrategy(true).getTransaction() ;
- } catch (final TransactionStrategyException tse) {
- throw new ConnectionException("Failed to determine current transaction context", tse) ;
- }
- }
-
- /**
- * Get a JMS session associated with the current transaction.
- * @return The JMS session or null if not associated.
- * @throws ConnectionException For accessint the current transaction context
- */
- private synchronized JmsXASession getXASession()
- throws ConnectionException
- {
- final Object tx = getTransaction() ;
-
- for(JmsSessionPool sessionPool : sessionPools) {
- JmsXASession session = sessionPool.transactionsToSessions.get(tx);
- if(session != null) {
- return session;
- }
- }
-
- return null;
- }
-
- /**
- * Associate the JMS XA Session with the current transaction.
- * @param session The XA session.
- * @throws ConnectionException if there is no transaction active.
- */
- synchronized void associateTransaction(final JmsXASession session)
- throws ConnectionException
- {
- JmsSessionPool sessionPool = findOwnerPool(session);
-
- if(sessionPool != null) {
- sessionPool.associateTransaction(session);
- }
- }
-
- /**
- * Disassociate the JMS XA Session from a transaction.
- * @param session The XA session.
- */
- synchronized void disassociateTransaction(final JmsXASession session)
- {
- JmsSessionPool sessionPool = findOwnerPool(session);
-
- if(sessionPool != null) {
- sessionPool.disassociateTransaction(session);
- }
- }
-
- synchronized JmsSessionPool findOwnerPool(final JmsSession session) {
- for(JmsSessionPool sessionPool : sessionPools) {
- if(sessionPool.isOwnerPool(session)) {
- return sessionPool;
- }
- }
-
- return null;
- }
-
- static
- {
- PropertyManager prop = ModulePropertyManager.getPropertyManager(ModulePropertyManager.TRANSPORTS_MODULE);
- String value = prop.getProperty(Environment.JMS_CONNECTION_POOL_SIZE);
-
- if (value != null)
- {
- try
- {
- CONFIGURED_POOL_SIZE = Integer.parseInt(value);
- }
- catch (NumberFormatException ex)
- {
- ex.printStackTrace();
- }
- }
-
- value = prop.getProperty(Environment.JMS_SESSION_SLEEP);
-
- if (value != null)
- {
- try
- {
- CONFIGURED_SLEEP = Integer.parseInt(value);
- }
- catch (NumberFormatException ex)
- {
- ex.printStackTrace();
- }
- }
- }
-
- class JmsSessionPool {
-
- /** Reference to a Queue or Topic Connection, we only need one per pool */
- protected Connection jmsConnection ;
-
- /** Number of free sessions in the pool that can be given out. Indexed by session key */
- private Map<Integer,ArrayList<JmsSession>> freeSessionsMap = new HashMap<Integer,ArrayList<JmsSession>>();
-
- /** Number of session that are currently in use. Indexed by session key mode */
- private Map<Integer,ArrayList<JmsSession>> inUseSessionsMap = new HashMap<Integer,ArrayList<JmsSession>>();
-
- /**
- * Mapping from transactions to sessions.
- */
- private Map<Object, JmsXASession> transactionsToSessions = new HashMap<Object, JmsXASession>() ;
-
- /**
- * Mapping from sessions to transactions.
- */
- private Map<JmsXASession, Object> sessionsToTransactions = new HashMap<JmsXASession, Object>() ;
-
- private JmsSessionPool() {
- freeSessionsMap.put(Session.AUTO_ACKNOWLEDGE, new ArrayList<JmsSession>() );
- freeSessionsMap.put(Session.CLIENT_ACKNOWLEDGE, new ArrayList<JmsSession>() );
- freeSessionsMap.put(Session.DUPS_OK_ACKNOWLEDGE, new ArrayList<JmsSession>() );
-
- inUseSessionsMap.put(Session.AUTO_ACKNOWLEDGE, new ArrayList<JmsSession>() );
- inUseSessionsMap.put(Session.CLIENT_ACKNOWLEDGE, new ArrayList<JmsSession>() );
- inUseSessionsMap.put(Session.DUPS_OK_ACKNOWLEDGE, new ArrayList<JmsSession>() );
- }
-
- private boolean isOwnerPool(JmsSession session) {
- if (isInList(session, freeSessionsMap.values())) {
- return true;
- } else if (isInList(session, inUseSessionsMap.values())) {
- return true;
- }
-
- return false;
- }
-
- private boolean isInList(JmsSession session, Collection<ArrayList<JmsSession>> sessionLists) {
- for(ArrayList<JmsSession> sessionList : sessionLists) {
- if(sessionList.contains(session)) {
- return true;
- }
- }
- return false;
- }
-
- public synchronized void removeSessionPool() {
- freeSessionsMap = null ;
- inUseSessionsMap = null ;
- transactionsToSessions = null ;
- sessionsToTransactions = null ;
-
- logger.debug("Emptied the session pool now closing the connection to the factory.");
- if (jmsConnection!=null) {
- try {
- jmsConnection.close();
- } catch (final Exception ex) {} // ignore
- jmsConnection=null;
- }
- }
-
- public synchronized JmsSession getSession(int acknowledgeMode, boolean transacted) throws ConnectionException, NamingException, JMSException {
-
- initConnection() ;
-
- ArrayList<JmsSession> freeSessions = freeSessionsMap.get(acknowledgeMode );
- ArrayList<JmsSession> inUseSessions = inUseSessionsMap.get(acknowledgeMode);
-
- if (freeSessions.size() > 0)
- {
- final JmsSession session = freeSessions.remove(freeSessions.size()-1);
- inUseSessions.add(session);
- return session ;
- } else if (getSessionsInPool() < maxSessionsPerConnection) {
- JmsSession session = null;
-
- if(transacted) {
- if(getXASessionsInPool() < maxXASessionsPerConnection) {
- session = addAnotherSession(poolKey, transacted, acknowledgeMode);
- }
- } else {
- session = addAnotherSession(poolKey, transacted, acknowledgeMode);
- }
-
- if(session != null) {
- inUseSessions.add(session);
- return session ;
- }
- }
-
- return null;
- }
-
- private synchronized void initConnection()
- throws ConnectionException, NamingException, JMSException
- {
- if (terminated)
- {
- throw new ConnectionException("Connection pool has been terminated") ;
- }
-
- if (jmsConnection == null)
- {
- try {
- logger.debug("Creating a JMS Connection for poolKey : " + poolKey);
- final Object factoryConnection = getFactoryConnection() ;
- final String username = poolKey.get( JMSEpr.JMS_SECURITY_PRINCIPAL_TAG );
- final String password = poolKey.get( JMSEpr.JMS_SECURITY_CREDENTIAL_TAG );
- boolean useJMSSecurity = (username != null && password != null);
- logger.debug( "JMS Security principal [" + username + "] using JMS Security : " + useJMSSecurity );
-
- if (isXAAware)
- {
- final XAConnectionFactory factory = (XAConnectionFactory)factoryConnection ;
- jmsConnection = useJMSSecurity ? factory.createXAConnection(username,password): factory.createXAConnection();
- freeSessionsMap.put(Session.SESSION_TRANSACTED, new ArrayList<JmsSession>() );
- inUseSessionsMap.put(Session.SESSION_TRANSACTED, new ArrayList<JmsSession>() );
- }
- else if (factoryConnection instanceof ConnectionFactory)
- {
- final ConnectionFactory factory = (ConnectionFactory)factoryConnection ;
- jmsConnection = useJMSSecurity ? factory.createConnection(username,password): factory.createConnection();
- }
-
- jmsConnection.setExceptionListener(new ExceptionListener() {
- public void onException(JMSException arg0)
- {
- // This will result in all connections (and their sessions) on this pool
- // being closed...
- cleanSessionPool() ;
- }
- }) ;
- jmsConnection.start();
- } catch (final NamingContextException nce) {
- throw new ConnectionException("Unexpected exception accessing Naming Context", nce) ;
- }
- }
- }
-
- /**
- * This is where we create the sessions.
- *
- * @param poolKey
- * @param transacted
- * @throws JMSException
- */
- private synchronized JmsSession addAnotherSession(Map<String, String> poolKey, final boolean transacted, final int acknowledgeMode)
- throws JMSException
- {
- // Sessions need to be created in this way because of an issue with JBM.
- // See https://jira.jboss.org/jira/browse/JBESB-1799
- final long currentID = id ;
- final Connection currentConnection = jmsConnection ;
- final Future<JmsSession> future = COMPLETION_SERVICE.submit(new Callable<JmsSession>() {
- public JmsSession call()
- throws JMSException
- {
- final JmsSession session ;
-
- if (transacted) {
- session = new JmsXASession(JmsConnectionPool.this, ((XAConnection)currentConnection).createXASession(), currentID);
- } else {
- session = new JmsSession(JmsConnectionPool.this, currentConnection.createSession(transacted, acknowledgeMode), currentID);
- }
-
- return session ;
- }
- }) ;
-
- //Create a new Session
- ArrayList<JmsSession> freeSessions = freeSessionsMap.get(acknowledgeMode);
- // For now we only support JTA transacted sessions
- try
- {
- JmsSession session = future.get();
- logger.debug("Number of Sessions in the pool with acknowledgeMode: " + acknowledgeMode + " is now " + getSessionsInPool(acknowledgeMode));
- return session;
- }
- catch (final InterruptedException ie) {} // ignore
- catch (final ExecutionException ee)
- {
- final Throwable th = ee.getCause() ;
- if (th instanceof JMSException)
- {
- throw (JMSException)th ;
- }
- if (th instanceof Error)
- {
- throw (Error)th ;
- }
- if (th instanceof RuntimeException)
- {
- throw (RuntimeException)th ;
- }
- }
-
- return null;
- }
-
- public void cleanSessionPool() {
- final Connection connection ;
- synchronized(this)
- {
- if (terminated)
- {
- return ;
- }
- id++ ;
- for (List<JmsSession> list : freeSessionsMap.values())
- {
- list.clear() ;
- }
- for (List<JmsSession> list : inUseSessionsMap.values())
- {
- list.clear() ;
- }
- transactionsToSessions.clear() ;
- sessionsToTransactions.clear() ;
-
- logger.debug("Cleared the session pool now closing the connection to the factory.");
- connection = jmsConnection ;
- jmsConnection = null ;
- }
- if (connection!=null) {
- try {
- connection.close();
- } catch (final Exception ex) {} // ignore
- }
- }
-
- /**
- * Returns the total number of sessions in the pool.
- * @return The total number of sessions in the pool.
- */
- private synchronized int getSessionsInPool() {
- // Get a count of all sessions (of any type) in the pool...
- return getSessionsInPool(JmsSession.class);
- }
-
- /**
- * Returns the total number of XA sessions in the pool.
- * @return The total number of XA sessions in the pool.
- */
- private synchronized int getXASessionsInPool() {
- // Get a count of XA sessions in the pool...
- return getSessionsInPool(JmsXASession.class);
- }
-
- /**
- * Returns the total number of XA sessions in the pool.
- * @return The total number of XA sessions in the pool.
- */
- private synchronized int getSessionsInPool(Class<? extends JmsSession> jmsSessionType) {
- int total = 0;
-
- total += getSessionsInMap(freeSessionsMap, jmsSessionType);
- total += getSessionsInMap(inUseSessionsMap, jmsSessionType);
-
- return total;
- }
-
- private synchronized int getSessionsInMap(Map<Integer, ArrayList<JmsSession>> sessionsMap, Class<? extends JmsSession> jmsSessionType) {
- Collection<ArrayList<JmsSession>> sessionLists = sessionsMap.values();
- int total = 0;
-
- for(ArrayList<JmsSession> sessionList : sessionLists) {
- for(JmsSession session : sessionList) {
- if(jmsSessionType.isAssignableFrom(session.getClass())) {
- total++;
- }
- }
- }
-
- return total;
- }
-
- /**
- * Returns the total nr of sessions for the specifed acknowledge mode
- *
- * @param acknowledgeMode the acknowledge mode of sessions
- * @return
- */
- public synchronized int getSessionsInPool(final int acknowledgeMode) {
- return getFreeSessionsInPool(acknowledgeMode) + getInUseSessionsInPool(acknowledgeMode) ;
- }
-
- /**
- * Get the number of free sessions created with the specified acknowledge mode
- * @param acknowledgeMode the acknowledge mode of sessions
- * @return int the number of in use sessions
- */
- public synchronized int getFreeSessionsInPool(final int acknowledgeMode) {
- final ArrayList<JmsSession> freeSessionMap = (freeSessionsMap == null ? null : freeSessionsMap.get(acknowledgeMode)) ;
- final int numFreeSessions = (freeSessionMap == null ? 0 : freeSessionMap.size()) ;
- return numFreeSessions;
- }
-
- /**
- * Get the number of sessions that are in use and that were
- * created with the specified acknowledge mode
- * @param acknowledgeMode the acknowledge mode of sessions
- * @return int the number of in use sessions
- */
- public synchronized int getInUseSessionsInPool(final int acknowledgeMode) {
- final ArrayList<JmsSession> inUseSessionMap = (inUseSessionsMap == null ? null : inUseSessionsMap.get(acknowledgeMode)) ;
- final int numInUseSessions = (inUseSessionMap == null ? 0 : inUseSessionMap.size()) ;
- return numInUseSessions;
- }
-
- /**
- * Associate the JMS XA Session with the current transaction.
- * @param session The XA session.
- * @throws ConnectionException if there is no transaction active.
- */
- synchronized void associateTransaction(final JmsXASession session)
- throws ConnectionException
- {
- final Object tx = getTransaction() ;
- if (tx == null)
- {
- throw new ConnectionException("No active transaction") ;
- }
- transactionsToSessions.put(tx, session) ;
- sessionsToTransactions.put(session, tx) ;
- }
-
- /**
- * Disassociate the JMS XA Session from a transaction.
- * @param session The XA session.
- */
- synchronized void disassociateTransaction(final JmsXASession session)
- {
- final Object tx = sessionsToTransactions.remove(session) ;
- transactionsToSessions.remove(tx) ;
- }
-
- public void releaseInUseSession(JmsSession session) {
- final int mode ;
- try {
- mode = session.getAcknowledgeMode() ;
- } catch (final JMSException jmse) {
- logger.warn("JMSException while calling getAcknowledgeMode") ;
- logger.debug("JMSException while calling getAcknowledgeMode", jmse) ;
- return ;
- }
-
- final ArrayList<JmsSession> sessions = (inUseSessionsMap == null ? null : inUseSessionsMap.get(mode));
- if (sessions != null) {
- sessions.remove(session) ;
- }
- }
-
- public void handleCloseSession(JmsSession session) {
- if (session.isSuspect())
- {
- logger.debug("Session is suspect, dropping") ;
- handleReleaseSession(session) ;
- }
- else
- {
- if (session.getId() != id)
- {
- logger.debug("Session is from a previous incarnation, dropping") ;
- }
- else
- {
- final int mode ;
- try {
- mode = session.getAcknowledgeMode() ;
- } catch (final JMSException jmse) {
- logger.warn("JMSException while calling getAcknowledgeMode") ;
- logger.debug("JMSException while calling getAcknowledgeMode", jmse) ;
- return ;
- }
-
- final ArrayList<JmsSession> sessions = (freeSessionsMap == null ? null : freeSessionsMap.get(mode));
- if (sessions != null) {
- sessions.add(session) ;
- }
- }
- session.releaseResources() ;
- releaseInUseSession(session) ;
- }
- }
- }
-
- /**
- * Thread factory returning daemon threads.
- * <p/>
- * Required as part of the fix for https://jira.jboss.org/jira/browse/JBESB-1799
- *
- * @author kevin
- */
- private static final class DaemonThreadFactory implements ThreadFactory
- {
- /**
- * The default executor factory.
- */
- private final ThreadFactory defaultFactory = Executors.defaultThreadFactory() ;
-
- /**
- * Return a new daemon thread.
- * @param runnable The runnable associated with the thread.
- */
- public Thread newThread(final Runnable runnable)
- {
- final Thread thread = defaultFactory.newThread(runnable) ;
- thread.setDaemon(true) ;
- return thread ;
- }
- }
-}
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,1091 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.internal.soa.esb.rosetta.pooling;
+
+import java.sql.SQLException;
+import java.util.*;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ThreadFactory;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.ModulePropertyManager;
+import org.jboss.soa.esb.common.TransactionStrategy;
+import org.jboss.soa.esb.common.TransactionStrategyException;
+import org.jboss.soa.esb.helpers.NamingContextException;
+import org.jboss.soa.esb.helpers.NamingContextPool;
+import org.jboss.soa.esb.util.ClassUtil;
+
+import com.arjuna.common.util.propertyservice.PropertyManager;
+
+/**
+ * JmsConnectionPool.
+ *
+ * @author kstam
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ * Date: March 10, 2007
+ */
+public class JmsConnectionPool
+{
+ private static final int DEFAULT_POOL_SIZE = 20;
+ private static final int DEFAULT_SLEEP = 30;
+
+ private static int CONFIGURED_POOL_SIZE = DEFAULT_POOL_SIZE;
+ private static int CONFIGURED_SLEEP = DEFAULT_SLEEP;
+
+ /**
+ * The executor used to create sessions.
+ */
+ private static final Executor SESSION_EXECUTOR = Executors.newSingleThreadExecutor(new DaemonThreadFactory()) ;
+ /**
+ * The completion service.
+ */
+ private static final CompletionService<JmsSession> COMPLETION_SERVICE = new ExecutorCompletionService<JmsSession>(SESSION_EXECUTOR) ;
+ /** Logger */
+ private static final Logger LOGGER = Logger.getLogger(JmsConnectionPool.class);
+
+ /**
+ * The JMS COnnection Exception Handlers.
+ */
+ private static final JmsConnectionExceptionHandler[] CONNECTION_EXCEPTION_HANDLERS ;
+
+ /** Maximum number of Sessions that will be created in this pool */
+ private int maxSessions = DEFAULT_POOL_SIZE; //TODO Make this manageable
+
+ /**
+ * The max number of sessions per connection. Defaults to "maxSessions".
+ */
+ private int maxSessionsPerConnection;
+
+ /**
+ * The max number of XA sessions per connection. Defaults to "maxSessionsPerConnection".
+ */
+ private int maxXASessionsPerConnection;
+
+ /** Time to sleep when trying to get a session. */
+ private int sleepTime = DEFAULT_SLEEP;
+
+ /** The Indentifier of the pool */
+ private Map<String, String> poolKey;
+
+ /**
+ * JMS Session Pools.
+ */
+ private List<JmsSessionPool> sessionPools = new ArrayList<JmsSessionPool>();
+ /**
+ * The flag representing XA aware connections.
+ */
+ private boolean isXAAware ;
+ /**
+ * Flag signifying that the pool has been terminated.
+ */
+ private boolean terminated ;
+ /**
+ * The pool instance id.
+ */
+ private long id ;
+
+ /**
+ * Contructor of the pool.
+ *
+ */
+ public JmsConnectionPool(Map<String, String> poolKey) throws ConnectionException {
+ this(poolKey, JmsConnectionPool.CONFIGURED_POOL_SIZE, JmsConnectionPool.CONFIGURED_SLEEP);
+ }
+
+ public JmsConnectionPool(Map<String, String> poolKey, int poolSize, int sleepTime) throws ConnectionException {
+ this.poolKey = poolKey;
+
+ maxSessions = poolSize;
+ this.sleepTime = sleepTime;
+
+ maxSessionsPerConnection = getIntPoolConfig(poolKey, JMSEpr.MAX_SESSIONS_PER_CONNECTION, maxSessions);
+ if(maxSessionsPerConnection < 1) {
+ throw new ConnectionException("Invalid '" + JMSEpr.MAX_SESSIONS_PER_CONNECTION + "' configuration value '" + maxSessionsPerConnection + "'. Must be greater than 0.");
+ }
+ maxXASessionsPerConnection = getIntPoolConfig(poolKey, JMSEpr.MAX_XA_SESSIONS_PER_CONNECTION, maxSessionsPerConnection);
+ if(maxXASessionsPerConnection < 1) {
+ throw new ConnectionException("Invalid '" + JMSEpr.MAX_XA_SESSIONS_PER_CONNECTION + "' configuration value '" + maxXASessionsPerConnection + "'. Must be greater than 0.");
+ } else if(maxXASessionsPerConnection > maxSessionsPerConnection) {
+ throw new ConnectionException("Invalid '" + JMSEpr.MAX_XA_SESSIONS_PER_CONNECTION + "' configuration value '" + maxXASessionsPerConnection + "'. Cannot be greater than the configured value for '" + JMSEpr.MAX_SESSIONS_PER_CONNECTION + "', which is " + maxSessionsPerConnection + ".");
+ }
+ }
+
+ private int getIntPoolConfig(Map<String, String> poolKey, String configKey, int defaultVal) throws ConnectionException {
+ String configValueString = poolKey.get(configKey);
+ int configValue = defaultVal;
+
+ if(configValueString != null) {
+ try {
+ configValue = Integer.parseInt(configValueString.trim());
+ } catch(NumberFormatException e) {
+ throw new ConnectionException("Invalid '" + configKey + "' configuration value '" + configValueString.trim() + "'. Must be a valid Integer.");
+ }
+ }
+
+ return configValue;
+ }
+
+ protected int getMaxSessions() {
+ return maxSessions;
+ }
+
+ protected int getMaxSessionsPerConnection() {
+ return maxSessionsPerConnection;
+ }
+
+ public int getMaxXASessionsPerConnection() {
+ return maxXASessionsPerConnection;
+ }
+
+ protected List<JmsSessionPool> getSessionPools() {
+ return sessionPools;
+ }
+
+ /**
+ * This method can be called whenever a connection is needed from the pool.
+ *
+ * @return Connection to be used
+ * @throws ConnectionException
+ */
+ public synchronized JmsSession getSession(final int acknowledgeMode) throws NamingException, JMSException, ConnectionException
+ {
+ if (terminated)
+ {
+ throw new ConnectionException("Connection pool has been terminated") ;
+ }
+
+ try
+ {
+ return internalGetSession(acknowledgeMode) ;
+ }
+ catch (final JMSException jmse)
+ {
+ if (isConnectionFailure(jmse) != null)
+ {
+ return internalGetSession(acknowledgeMode) ;
+ }
+ throw jmse ;
+ }
+ }
+
+ private synchronized JmsSession internalGetSession(final int acknowledgeMode)
+ throws NamingException, JMSException, ConnectionException
+ {
+ if(sessionPools.isEmpty()) {
+ // Create the first pool entry...
+ addSessionPool();
+ }
+
+ final Object factoryConnection ;
+ try
+ {
+ factoryConnection = getFactoryConnection() ;
+ }
+ catch (final NamingContextException nce)
+ {
+ throw new ConnectionException("Unexpected exception accessing Naming Context", nce) ;
+ }
+ isXAAware = (factoryConnection instanceof XAConnectionFactory) ;
+
+ final boolean transacted ;
+ try {
+ transacted = (isXAAware && TransactionStrategy.getTransactionStrategy(true).isActive()) ;
+ } catch (final TransactionStrategyException tse) {
+ throw new ConnectionException("Failed to determine current transaction context", tse) ;
+ }
+
+ if (transacted)
+ {
+ final JmsXASession currentSession = getXASession() ;
+ if (currentSession != null)
+ {
+ return currentSession ;
+ }
+ }
+
+ final int mode = (transacted ? Session.SESSION_TRANSACTED : acknowledgeMode) ;
+ final long end = System.currentTimeMillis() + (sleepTime * 1000) ;
+ boolean emitExpiry = LOGGER.isDebugEnabled() ;
+
+ while(true) {
+ // Cycle through all the existing session pools and try getting a
+ // free session. Will JmsSessionPool.getSession will add a session
+ // to a pool that is not "full"...
+ for (JmsSessionPool sessionPool : sessionPools) {
+ try {
+ JmsSession session = sessionPool.getSession(mode, transacted);
+
+ if(session != null) {
+ return session;
+ }
+ } catch (final JMSException jmse) {
+ final Boolean failure = isConnectionFailure(jmse) ;
+ if (failure != null) {
+ sessionPool.cleanSessionPool(failure.booleanValue()) ;
+ }
+ throw jmse ;
+ }
+ }
+
+ // OK... all the existing session pools are full and have no free sessions. If we can add
+ // another session pool, add it and then start this loop again...
+ if(getSessionsInPool() < maxSessions) {
+ addSessionPool();
+ continue;
+ }
+
+ // We've reached our max permitted number of connections and the sessions
+ // associated with these connections are all in use. Drop into the
+ // delay below and wait for a session to be freed...
+ if (emitExpiry)
+ {
+ LOGGER.debug("The connection pool was exhausted, waiting for a session to be released.") ;
+ emitExpiry = false ;
+ }
+
+ // Wait and loop again...
+ final long now = System.currentTimeMillis() ;
+ final long delay = (end - now) ;
+ if (delay <= 0)
+ {
+ throw new ConnectionException("Could not obtain a JMS connection from the pool after "+ sleepTime +"s.");
+ }
+ else
+ {
+ try
+ {
+ wait(delay) ;
+ }
+ catch (final InterruptedException ie) {} // ignore
+ }
+ }
+ }
+
+ private Object getFactoryConnection()
+ throws NamingContextException, NamingException
+ {
+ String connectionFactoryString = poolKey.get(JMSEpr.CONNECTION_FACTORY_TAG);
+ Object factoryConnection=null;
+
+ Properties jndiEnvironment = JmsConnectionPoolContainer.getJndiEnvironment(poolKey);
+ Context jndiContext = NamingContextPool.getNamingContext(jndiEnvironment);
+ try
+ {
+ factoryConnection = jndiContext.lookup(connectionFactoryString);
+ }
+ catch (NamingException ne)
+ {
+ LOGGER.info("Received NamingException, refreshing context.");
+ jndiContext = NamingContextPool.replaceNamingContext(jndiContext, JmsConnectionPoolContainer.getJndiEnvironment(poolKey));
+ factoryConnection = jndiContext.lookup(connectionFactoryString);
+ }
+ finally
+ {
+ NamingContextPool.releaseNamingContext(jndiContext) ;
+ }
+ return factoryConnection ;
+ }
+
+ private JmsSessionPool addSessionPool() throws NamingException, JMSException, ConnectionException {
+ final JmsSessionPool sessionPool = new JmsSessionPool();
+
+ // And add it to the pool...
+ sessionPools.add(sessionPool);
+
+ return sessionPool;
+ }
+
+ /**
+ * This method can be called whenever a Session is needed from the pool.
+ * @return
+ * @throws NamingException
+ * @throws JMSException
+ * @throws ConnectionException
+ */
+ public JmsSession getSession() throws NamingException, JMSException, ConnectionException
+ {
+ return getSession(Session.AUTO_ACKNOWLEDGE);
+ }
+
+ /**
+ * This method closes an open connection and returns the connection to the pool.
+ * @param session The connection to be returned to the pool.
+ * @throws SQLException
+ * @deprecated
+ */
+ public void closeSession(Session session){
+ if (session instanceof JmsSession) {
+ closeSession((JmsSession)session) ;
+ } else {
+ LOGGER.error("Invalid JMS Session type in closeSession: " + session);
+ }
+ }
+
+ /**
+ * This method closes an open connection and returns the connection to the pool.
+ * @param session The connection to be returned to the pool.
+ * @throws SQLException
+ */
+ public void closeSession(JmsSession session){
+ session.handleCloseSession(this) ;
+ }
+
+ /**
+ * Handle the real work of closing the connection.
+ * @param session The session to close.
+ */
+ synchronized void handleCloseSession(final JmsSession session)
+ {
+ JmsSessionPool sessionPool = findOwnerPool(session);
+
+ if(sessionPool != null) {
+ sessionPool.handleCloseSession(session);
+ }
+ }
+
+ /**
+ * Handle the real work of releasing the connection.
+ * @param session The session to release.
+ */
+ synchronized void handleReleaseSession(final JmsSession session)
+ {
+ session.releaseResources();
+ try
+ {
+ session.close() ;
+ }
+ catch (final Throwable th) {} // ignore
+ releaseInUseSession(session) ;
+ }
+
+ /**
+ * Handle exceptions that occur in the session or its child objects.
+ * @param jmsSession The jmsSession associated with the call.
+ * @param jmse The JMSException to check.
+ * @throws JMSException if the exception is to be overridden.
+ */
+ void handleException(final JmsSession jmsSession, final JMSException jmse)
+ throws JMSException
+ {
+ final Boolean failure = isConnectionFailure(jmse) ;
+ if (failure != null) {
+ final JmsSessionPool sessionPool = findOwnerPool(jmsSession);
+
+ if(sessionPool != null) {
+ sessionPool.cleanSessionPool(failure.booleanValue()) ;
+ }
+ throw new JmsConnectionFailureException("The underlying exception appears to have failed", jmse) ;
+ }
+ }
+
+ /**
+ * Check the exception to see whether it indicates a connection failure
+ * @param jmse The current JMS Exception
+ * @return null if no connection failure, TRUE if the connection should be closed, FALSE if just cleaned up.
+ */
+ private Boolean isConnectionFailure(final JMSException jmse)
+ {
+ for(JmsConnectionExceptionHandler connectionExceptionHandler: CONNECTION_EXCEPTION_HANDLERS)
+ {
+ final Boolean isConnectionFailure = connectionExceptionHandler.isConnectionFailure(jmse) ;
+ if (isConnectionFailure != null)
+ {
+ LOGGER.debug("Connection failure detected by handler: " + connectionExceptionHandler.getClass().getName(), jmse) ;
+ LOGGER.debug("Linked exception", jmse.getLinkedException()) ;
+ return isConnectionFailure ;
+ }
+ }
+ return null ;
+ }
+
+ /**
+ * Release a session from the in use mapping.
+ * @param session The session to release.
+ */
+ private void releaseInUseSession(final JmsSession session)
+ {
+ JmsSessionPool sessionPool = findOwnerPool(session);
+
+ if(sessionPool != null) {
+ sessionPool.releaseInUseSession(session);
+ }
+
+ notifyAll() ;
+ }
+
+ /**
+ * This method closes an open session without returning it to the pool.
+ * @param session The session to be returned to the pool.
+ * @throws SQLException
+ */
+ public synchronized void releaseSession(final JmsSession session) {
+ session.handleReleaseSession(this) ;
+ }
+
+ /**
+ * This method closes an open session without returning it to the pool.
+ * @param session The session to be returned to the pool.
+ * @throws SQLException
+ * @deprecated
+ */
+ public synchronized void releaseSession(final Session session) {
+ if (session instanceof JmsSession) {
+ releaseSession((JmsSession)session) ;
+ } else {
+ LOGGER.error("Invalid JMS Session type in releaseSession: " + session);
+ }
+ }
+
+ /**
+ * This method is called when the pool needs to destroyed. It closes all open sessions
+ * and the connection and removes it from the container's poolMap.
+ */
+ public synchronized void removeSessionPool()
+ {
+ for(JmsSessionPool sessionPool : sessionPools) {
+ try {
+ sessionPool.removeSessionPool();
+ } catch(Exception e) {
+ LOGGER.error("Exception while removing JmsSessionPool.", e);
+ }
+ }
+
+ sessionPools.clear();
+ terminated = true ;
+ JmsConnectionPoolContainer.removePool(poolKey);
+ }
+ /**
+ * Gets the total number of sessions in the pool regardless of the acknowlede mode
+ * used when creating the sessions.
+ * @return the session pool size
+ */
+ public int getSessionsInPool() {
+ return getSessionsInPool(Session.AUTO_ACKNOWLEDGE) +
+ getSessionsInPool(Session.CLIENT_ACKNOWLEDGE) +
+ getSessionsInPool(Session.DUPS_OK_ACKNOWLEDGE) +
+ getSessionsInPool(Session.SESSION_TRANSACTED) ;
+ }
+
+ /**
+ * Returns the total nr of sessions for the specifed acknowledge mode
+ *
+ * @param acknowledgeMode the acknowledge mode of sessions
+ * @return
+ */
+ public synchronized int getSessionsInPool(final int acknowledgeMode) {
+ return getFreeSessionsInPool(acknowledgeMode) + getInUseSessionsInPool(acknowledgeMode) ;
+ }
+
+ /**
+ * Get the number of free sessions created with the specified acknowledge mode
+ * @param acknowledgeMode the acknowledge mode of sessions
+ * @return int the number of in use sessions
+ */
+ public synchronized int getFreeSessionsInPool(final int acknowledgeMode) {
+ int count = 0;
+
+ for(JmsSessionPool sessionPool : sessionPools) {
+ count += sessionPool.getFreeSessionsInPool(acknowledgeMode);
+ }
+
+ return count;
+ }
+
+ /**
+ * Get the number of sessions that are in use and that were
+ * created with the specified acknowledge mode
+ * @param acknowledgeMode the acknowledge mode of sessions
+ * @return int the number of in use sessions
+ */
+ public synchronized int getInUseSessionsInPool(final int acknowledgeMode) {
+ int count = 0;
+
+ for(JmsSessionPool sessionPool : sessionPools) {
+ count += sessionPool.getInUseSessionsInPool(acknowledgeMode);
+ }
+
+ return count;
+ }
+
+ /**
+ * Get the current transaction.
+ * @return The transaction or null if none present.
+ * @throws ConnectionException if the transaction context cannot be obtained.
+ */
+ private Object getTransaction()
+ throws ConnectionException
+ {
+ try {
+ return TransactionStrategy.getTransactionStrategy(true).getTransaction() ;
+ } catch (final TransactionStrategyException tse) {
+ throw new ConnectionException("Failed to determine current transaction context", tse) ;
+ }
+ }
+
+ /**
+ * Get a JMS session associated with the current transaction.
+ * @return The JMS session or null if not associated.
+ * @throws ConnectionException For accessint the current transaction context
+ */
+ private synchronized JmsXASession getXASession()
+ throws ConnectionException
+ {
+ final Object tx = getTransaction() ;
+
+ for(JmsSessionPool sessionPool : sessionPools) {
+ JmsXASession session = sessionPool.transactionsToSessions.get(tx);
+ if(session != null) {
+ return session;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Associate the JMS XA Session with the current transaction.
+ * @param session The XA session.
+ * @throws ConnectionException if there is no transaction active.
+ */
+ synchronized void associateTransaction(final JmsXASession session)
+ throws ConnectionException
+ {
+ JmsSessionPool sessionPool = findOwnerPool(session);
+
+ if(sessionPool != null) {
+ sessionPool.associateTransaction(session);
+ }
+ }
+
+ /**
+ * Disassociate the JMS XA Session from a transaction.
+ * @param session The XA session.
+ */
+ synchronized void disassociateTransaction(final JmsXASession session)
+ {
+ JmsSessionPool sessionPool = findOwnerPool(session);
+
+ if(sessionPool != null) {
+ sessionPool.disassociateTransaction(session);
+ }
+ }
+
+ synchronized JmsSessionPool findOwnerPool(final JmsSession session) {
+ for(JmsSessionPool sessionPool : sessionPools) {
+ if(sessionPool.isOwnerPool(session)) {
+ return sessionPool;
+ }
+ }
+
+ return null;
+ }
+
+ static
+ {
+ PropertyManager prop = ModulePropertyManager.getPropertyManager(ModulePropertyManager.TRANSPORTS_MODULE);
+ String value = prop.getProperty(Environment.JMS_CONNECTION_POOL_SIZE);
+
+ if (value != null)
+ {
+ try
+ {
+ CONFIGURED_POOL_SIZE = Integer.parseInt(value);
+ }
+ catch (NumberFormatException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ value = prop.getProperty(Environment.JMS_SESSION_SLEEP);
+
+ if (value != null)
+ {
+ try
+ {
+ CONFIGURED_SLEEP = Integer.parseInt(value);
+ }
+ catch (NumberFormatException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ value = Configuration.getJMSConnectionExceptionHandlers() ;
+ final String[] handlerNames = (value == null ? null : value.split(",")) ;
+
+ final ArrayList<JmsConnectionExceptionHandler> handlers = new ArrayList<JmsConnectionExceptionHandler>() ;
+ for(String handler: handlerNames)
+ {
+ final Class<?> handlerClass ;
+ try
+ {
+ handlerClass = ClassUtil.forName(handler.trim(), JmsConnectionPool.class) ;
+ }
+ catch (final ClassNotFoundException cnfe)
+ {
+ LOGGER.error("Failed to instantiate connection exception handler, ignoring", cnfe) ;
+ continue ;
+ }
+ if (!JmsConnectionExceptionHandler.class.isAssignableFrom(handlerClass))
+ {
+ LOGGER.error("Handler does not implement JmsConnectionExceptionHandler interface, ignoring: " + handlerClass.getName()) ;
+ continue ;
+ }
+ final Object instance ;
+ try
+ {
+ instance = handlerClass.newInstance() ;
+ }
+ catch (final Throwable th)
+ {
+ LOGGER.error("Failed to instantiate handler, ignoring", th) ;
+ continue ;
+ }
+ handlers.add((JmsConnectionExceptionHandler)instance) ;
+ }
+ CONNECTION_EXCEPTION_HANDLERS = handlers.toArray(new JmsConnectionExceptionHandler[handlers.size()]) ;
+ }
+
+ class JmsSessionPool {
+
+ /** Reference to a Queue or Topic Connection, we only need one per pool */
+ protected Connection jmsConnection ;
+
+ /** Number of free sessions in the pool that can be given out. Indexed by session key */
+ private Map<Integer,ArrayList<JmsSession>> freeSessionsMap = new HashMap<Integer,ArrayList<JmsSession>>();
+
+ /** Number of session that are currently in use. Indexed by session key mode */
+ private Map<Integer,ArrayList<JmsSession>> inUseSessionsMap = new HashMap<Integer,ArrayList<JmsSession>>();
+
+ /**
+ * Mapping from transactions to sessions.
+ */
+ private Map<Object, JmsXASession> transactionsToSessions = new HashMap<Object, JmsXASession>() ;
+
+ /**
+ * Mapping from sessions to transactions.
+ */
+ private Map<JmsXASession, Object> sessionsToTransactions = new HashMap<JmsXASession, Object>() ;
+
+ private JmsSessionPool() {
+ freeSessionsMap.put(Session.AUTO_ACKNOWLEDGE, new ArrayList<JmsSession>() );
+ freeSessionsMap.put(Session.CLIENT_ACKNOWLEDGE, new ArrayList<JmsSession>() );
+ freeSessionsMap.put(Session.DUPS_OK_ACKNOWLEDGE, new ArrayList<JmsSession>() );
+
+ inUseSessionsMap.put(Session.AUTO_ACKNOWLEDGE, new ArrayList<JmsSession>() );
+ inUseSessionsMap.put(Session.CLIENT_ACKNOWLEDGE, new ArrayList<JmsSession>() );
+ inUseSessionsMap.put(Session.DUPS_OK_ACKNOWLEDGE, new ArrayList<JmsSession>() );
+ }
+
+ private boolean isOwnerPool(JmsSession session) {
+ if (isInList(session, freeSessionsMap.values())) {
+ return true;
+ } else if (isInList(session, inUseSessionsMap.values())) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private boolean isInList(JmsSession session, Collection<ArrayList<JmsSession>> sessionLists) {
+ for(ArrayList<JmsSession> sessionList : sessionLists) {
+ if(sessionList.contains(session)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public synchronized void removeSessionPool() {
+ freeSessionsMap = null ;
+ inUseSessionsMap = null ;
+ transactionsToSessions = null ;
+ sessionsToTransactions = null ;
+
+ LOGGER.debug("Emptied the session pool now closing the connection to the factory.");
+ if (jmsConnection!=null) {
+ try {
+ jmsConnection.close();
+ } catch (final Exception ex) {} // ignore
+ jmsConnection=null;
+ }
+ }
+
+ public synchronized JmsSession getSession(int acknowledgeMode, boolean transacted) throws ConnectionException, NamingException, JMSException {
+
+ initConnection() ;
+
+ ArrayList<JmsSession> freeSessions = freeSessionsMap.get(acknowledgeMode );
+ ArrayList<JmsSession> inUseSessions = inUseSessionsMap.get(acknowledgeMode);
+
+ if (freeSessions.size() > 0)
+ {
+ final JmsSession session = freeSessions.remove(freeSessions.size()-1);
+ inUseSessions.add(session);
+ return session ;
+ } else if (getSessionsInPool() < maxSessionsPerConnection) {
+ JmsSession session = null;
+
+ if(transacted) {
+ if(getXASessionsInPool() < maxXASessionsPerConnection) {
+ session = addAnotherSession(poolKey, transacted, acknowledgeMode);
+ }
+ } else {
+ session = addAnotherSession(poolKey, transacted, acknowledgeMode);
+ }
+
+ if(session != null) {
+ inUseSessions.add(session);
+ return session ;
+ }
+ }
+
+ return null;
+ }
+
+ private synchronized void initConnection()
+ throws ConnectionException, NamingException, JMSException
+ {
+ if (terminated)
+ {
+ throw new ConnectionException("Connection pool has been terminated") ;
+ }
+
+ if (jmsConnection == null)
+ {
+ try {
+ LOGGER.debug("Creating a JMS Connection for poolKey : " + poolKey);
+ final Object factoryConnection = getFactoryConnection() ;
+ final String username = poolKey.get( JMSEpr.JMS_SECURITY_PRINCIPAL_TAG );
+ final String password = poolKey.get( JMSEpr.JMS_SECURITY_CREDENTIAL_TAG );
+ boolean useJMSSecurity = (username != null && password != null);
+ LOGGER.debug( "JMS Security principal [" + username + "] using JMS Security : " + useJMSSecurity );
+
+ if (isXAAware)
+ {
+ final XAConnectionFactory factory = (XAConnectionFactory)factoryConnection ;
+ jmsConnection = useJMSSecurity ? factory.createXAConnection(username,password): factory.createXAConnection();
+ freeSessionsMap.put(Session.SESSION_TRANSACTED, new ArrayList<JmsSession>() );
+ inUseSessionsMap.put(Session.SESSION_TRANSACTED, new ArrayList<JmsSession>() );
+ }
+ else if (factoryConnection instanceof ConnectionFactory)
+ {
+ final ConnectionFactory factory = (ConnectionFactory)factoryConnection ;
+ jmsConnection = useJMSSecurity ? factory.createConnection(username,password): factory.createConnection();
+ }
+
+ jmsConnection.setExceptionListener(new ExceptionListener() {
+ public void onException(JMSException arg0)
+ {
+ // This will result in all connections (and their sessions) on this pool
+ // being closed...
+ cleanSessionPool() ;
+ }
+ }) ;
+ jmsConnection.start();
+ } catch (final NamingContextException nce) {
+ throw new ConnectionException("Unexpected exception accessing Naming Context", nce) ;
+ }
+ }
+ }
+
+ /**
+ * This is where we create the sessions.
+ *
+ * @param poolKey
+ * @param transacted
+ * @throws JMSException
+ */
+ private synchronized JmsSession addAnotherSession(Map<String, String> poolKey, final boolean transacted, final int acknowledgeMode)
+ throws JMSException
+ {
+ // Sessions need to be created in this way because of an issue with JBM.
+ // See https://jira.jboss.org/jira/browse/JBESB-1799
+ final long currentID = id ;
+ final Connection currentConnection = jmsConnection ;
+ final Future<JmsSession> future = COMPLETION_SERVICE.submit(new Callable<JmsSession>() {
+ public JmsSession call()
+ throws JMSException
+ {
+ final JmsSession session ;
+
+ if (transacted) {
+ session = new JmsXASession(JmsConnectionPool.this, ((XAConnection)currentConnection).createXASession(), currentID, acknowledgeMode);
+ } else {
+ session = new JmsSession(JmsConnectionPool.this, currentConnection.createSession(transacted, acknowledgeMode), currentID, acknowledgeMode);
+ }
+
+ return session ;
+ }
+ }) ;
+
+ // For now we only support JTA transacted sessions
+ try
+ {
+ JmsSession session = future.get();
+ LOGGER.debug("Number of Sessions in the pool with acknowledgeMode: " + acknowledgeMode + " is now " + getSessionsInPool(acknowledgeMode));
+ return session;
+ }
+ catch (final InterruptedException ie) {} // ignore
+ catch (final ExecutionException ee)
+ {
+ final Throwable th = ee.getCause() ;
+ if (th instanceof JMSException)
+ {
+ throw (JMSException)th ;
+ }
+ if (th instanceof Error)
+ {
+ throw (Error)th ;
+ }
+ if (th instanceof RuntimeException)
+ {
+ throw (RuntimeException)th ;
+ }
+ }
+
+ return null;
+ }
+
+ public void cleanSessionPool() {
+ cleanSessionPool(true) ;
+ }
+
+ public void cleanSessionPool(final boolean closeConnection) {
+ final Connection connection ;
+ synchronized(this)
+ {
+ if (terminated)
+ {
+ return ;
+ }
+ id++ ;
+ for (List<JmsSession> list : freeSessionsMap.values())
+ {
+ list.clear() ;
+ }
+ for (List<JmsSession> list : inUseSessionsMap.values())
+ {
+ list.clear() ;
+ }
+ transactionsToSessions.clear() ;
+ sessionsToTransactions.clear() ;
+
+ LOGGER.debug("Cleared the session pool now closing the connection to the factory.");
+ connection = jmsConnection ;
+ jmsConnection = null ;
+ }
+ if (closeConnection && (connection!=null)) {
+ try {
+ connection.close();
+ } catch (final Exception ex) {} // ignore
+ }
+ }
+
+ /**
+ * Returns the total number of sessions in the pool.
+ * @return The total number of sessions in the pool.
+ */
+ private synchronized int getSessionsInPool() {
+ // Get a count of all sessions (of any type) in the pool...
+ return getSessionsInPool(JmsSession.class);
+ }
+
+ /**
+ * Returns the total number of XA sessions in the pool.
+ * @return The total number of XA sessions in the pool.
+ */
+ private synchronized int getXASessionsInPool() {
+ // Get a count of XA sessions in the pool...
+ return getSessionsInPool(JmsXASession.class);
+ }
+
+ /**
+ * Returns the total number of XA sessions in the pool.
+ * @return The total number of XA sessions in the pool.
+ */
+ private synchronized int getSessionsInPool(Class<? extends JmsSession> jmsSessionType) {
+ int total = 0;
+
+ total += getSessionsInMap(freeSessionsMap, jmsSessionType);
+ total += getSessionsInMap(inUseSessionsMap, jmsSessionType);
+
+ return total;
+ }
+
+ private synchronized int getSessionsInMap(Map<Integer, ArrayList<JmsSession>> sessionsMap, Class<? extends JmsSession> jmsSessionType) {
+ Collection<ArrayList<JmsSession>> sessionLists = sessionsMap.values();
+ int total = 0;
+
+ for(ArrayList<JmsSession> sessionList : sessionLists) {
+ for(JmsSession session : sessionList) {
+ if(jmsSessionType.isAssignableFrom(session.getClass())) {
+ total++;
+ }
+ }
+ }
+
+ return total;
+ }
+
+ /**
+ * Returns the total nr of sessions for the specifed acknowledge mode
+ *
+ * @param acknowledgeMode the acknowledge mode of sessions
+ * @return
+ */
+ public synchronized int getSessionsInPool(final int acknowledgeMode) {
+ return getFreeSessionsInPool(acknowledgeMode) + getInUseSessionsInPool(acknowledgeMode) ;
+ }
+
+ /**
+ * Get the number of free sessions created with the specified acknowledge mode
+ * @param acknowledgeMode the acknowledge mode of sessions
+ * @return int the number of in use sessions
+ */
+ public synchronized int getFreeSessionsInPool(final int acknowledgeMode) {
+ final ArrayList<JmsSession> freeSessionMap = (freeSessionsMap == null ? null : freeSessionsMap.get(acknowledgeMode)) ;
+ final int numFreeSessions = (freeSessionMap == null ? 0 : freeSessionMap.size()) ;
+ return numFreeSessions;
+ }
+
+ /**
+ * Get the number of sessions that are in use and that were
+ * created with the specified acknowledge mode
+ * @param acknowledgeMode the acknowledge mode of sessions
+ * @return int the number of in use sessions
+ */
+ public synchronized int getInUseSessionsInPool(final int acknowledgeMode) {
+ final ArrayList<JmsSession> inUseSessionMap = (inUseSessionsMap == null ? null : inUseSessionsMap.get(acknowledgeMode)) ;
+ final int numInUseSessions = (inUseSessionMap == null ? 0 : inUseSessionMap.size()) ;
+ return numInUseSessions;
+ }
+
+ /**
+ * Associate the JMS XA Session with the current transaction.
+ * @param session The XA session.
+ * @throws ConnectionException if there is no transaction active.
+ */
+ synchronized void associateTransaction(final JmsXASession session)
+ throws ConnectionException
+ {
+ final Object tx = getTransaction() ;
+ if (tx == null)
+ {
+ throw new ConnectionException("No active transaction") ;
+ }
+ transactionsToSessions.put(tx, session) ;
+ sessionsToTransactions.put(session, tx) ;
+ }
+
+ /**
+ * Disassociate the JMS XA Session from a transaction.
+ * @param session The XA session.
+ */
+ synchronized void disassociateTransaction(final JmsXASession session)
+ {
+ final Object tx = sessionsToTransactions.remove(session) ;
+ transactionsToSessions.remove(tx) ;
+ }
+
+ public void releaseInUseSession(JmsSession session) {
+ final int mode = session.getRequestedAcknowledgeMode() ;
+
+ final ArrayList<JmsSession> sessions = (inUseSessionsMap == null ? null : inUseSessionsMap.get(mode));
+ if (sessions != null) {
+ sessions.remove(session) ;
+ }
+ }
+
+ public void handleCloseSession(JmsSession session) {
+ if (session.isSuspect())
+ {
+ LOGGER.debug("Session is suspect, dropping") ;
+ handleReleaseSession(session) ;
+ }
+ else
+ {
+ if (session.getId() != id)
+ {
+ LOGGER.debug("Session is from a previous incarnation, dropping") ;
+ }
+ else
+ {
+ final int mode = session.getRequestedAcknowledgeMode() ;
+
+ final ArrayList<JmsSession> sessions = (freeSessionsMap == null ? null : freeSessionsMap.get(mode));
+ if (sessions != null) {
+ sessions.add(session) ;
+ }
+ }
+ session.releaseResources() ;
+ releaseInUseSession(session) ;
+ }
+ }
+ }
+
+ /**
+ * Thread factory returning daemon threads.
+ * <p/>
+ * Required as part of the fix for https://jira.jboss.org/jira/browse/JBESB-1799
+ *
+ * @author kevin
+ */
+ private static final class DaemonThreadFactory implements ThreadFactory
+ {
+ /**
+ * The default executor factory.
+ */
+ private final ThreadFactory defaultFactory = Executors.defaultThreadFactory() ;
+
+ /**
+ * Return a new daemon thread.
+ * @param runnable The runnable associated with the thread.
+ */
+ public Thread newThread(final Runnable runnable)
+ {
+ final Thread thread = defaultFactory.newThread(runnable) ;
+ thread.setDaemon(true) ;
+ return thread ;
+ }
+ }
+}
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,481 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.internal.soa.esb.rosetta.pooling;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashSet;
-
-import javax.jms.BytesMessage;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TemporaryQueue;
-import javax.jms.TemporaryTopic;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.TopicSubscriber;
-
-/**
- * Wrapper for JMS session class, responsible for tracking resources and the pooling.
- */
-public class JmsSession implements Session
-{
- /**
- * The connection pool.
- */
- private final JmsConnectionPool pool ;
- /**
- * The session delegate.
- */
- private final Session session ;
- /**
- * The pool instance id.
- */
- private final long id ;
- /**
- * The session acknowledge mode.
- */
- private final int acknowledgeMode ;
- /**
- * Flag indicating whether this session is suspect or not.
- */
- private boolean suspect ;
-
- /**
- * The set of active queue browsers.
- */
- private HashSet<QueueBrowser> queueBrowserSet ;
- /**
- * The set of active message consumers.
- */
- private HashSet<MessageConsumer> messageConsumerSet ;
- /**
- * The set of active message producers.
- */
- private HashSet<MessageProducer> messageProducerSet ;
-
- /**
- * Create the session wrapper.
- * @param pool The pool associated with this session.
- * @param session The session delegate.
- * @param id The pool instance id.
- * @param isJTA True if this tales part in a JTA transaction
- * @throws JMSException
- */
- JmsSession(final JmsConnectionPool pool, final Session session, final long id)
- throws JMSException
- {
- this.pool = pool ;
- this.id = id ;
- this.session = (Session)getExceptionHandler(pool, Session.class, session) ;
- acknowledgeMode = session.getAcknowledgeMode() ;
- // Workaround for JBESB-1873
- if ("org.jboss.jms.client.JBossSession".equals(session.getClass().getName()))
- {
- SessionExecutorInit.initExecutor(session) ;
- }
- }
-
- public long getId()
- {
- return id ;
- }
-
- public void close() throws JMSException
- {
- session.close();
- }
-
- public void commit() throws JMSException
- {
- setSuspect(true) ;
- session.commit();
- setSuspect(false) ;
- }
-
- public QueueBrowser createBrowser(Queue arg0, String arg1)
- throws JMSException
- {
- return trackQueueBrowser(session.createBrowser(arg0, arg1));
- }
-
- public QueueBrowser createBrowser(Queue arg0) throws JMSException
- {
- return trackQueueBrowser(session.createBrowser(arg0));
- }
-
- public BytesMessage createBytesMessage() throws JMSException
- {
- associate() ;
- return session.createBytesMessage();
- }
-
- public MessageConsumer createConsumer(Destination arg0, String arg1,
- boolean arg2) throws JMSException
- {
- return trackMessageConsumer(session.createConsumer(arg0, arg1, arg2));
- }
-
- public MessageConsumer createConsumer(Destination arg0, String arg1)
- throws JMSException
- {
- return trackMessageConsumer(session.createConsumer(arg0, arg1));
- }
-
- public MessageConsumer createConsumer(Destination arg0) throws JMSException
- {
- return trackMessageConsumer(session.createConsumer(arg0));
- }
-
- public TopicSubscriber createDurableSubscriber(Topic arg0, String arg1,
- String arg2, boolean arg3) throws JMSException
- {
- return trackTopicSubscriber(session.createDurableSubscriber(arg0, arg1, arg2, arg3));
- }
-
- public TopicSubscriber createDurableSubscriber(Topic arg0, String arg1)
- throws JMSException
- {
- return trackTopicSubscriber(session.createDurableSubscriber(arg0, arg1));
- }
-
- public MapMessage createMapMessage() throws JMSException
- {
- associate() ;
- return session.createMapMessage();
- }
-
- public Message createMessage() throws JMSException
- {
- associate() ;
- return session.createMessage();
- }
-
- public ObjectMessage createObjectMessage() throws JMSException
- {
- associate() ;
- return session.createObjectMessage();
- }
-
- public ObjectMessage createObjectMessage(Serializable arg0)
- throws JMSException
- {
- associate() ;
- return session.createObjectMessage(arg0);
- }
-
- public MessageProducer createProducer(Destination arg0) throws JMSException
- {
- return trackMessageProducer(session.createProducer(arg0));
- }
-
- public Queue createQueue(String arg0) throws JMSException
- {
- associate() ;
- return session.createQueue(arg0);
- }
-
- public StreamMessage createStreamMessage() throws JMSException
- {
- associate() ;
- return session.createStreamMessage();
- }
-
- public TemporaryQueue createTemporaryQueue() throws JMSException
- {
- associate() ;
- return session.createTemporaryQueue();
- }
-
- public TemporaryTopic createTemporaryTopic() throws JMSException
- {
- associate() ;
- return session.createTemporaryTopic();
- }
-
- public TextMessage createTextMessage() throws JMSException
- {
- associate() ;
- return session.createTextMessage();
- }
-
- public TextMessage createTextMessage(String arg0) throws JMSException
- {
- associate() ;
- return session.createTextMessage(arg0);
- }
-
- public Topic createTopic(String arg0) throws JMSException
- {
- associate() ;
- return session.createTopic(arg0);
- }
-
- public int getAcknowledgeMode() throws JMSException
- {
- return acknowledgeMode;
- }
-
- public MessageListener getMessageListener() throws JMSException
- {
- associate() ;
- return session.getMessageListener();
- }
-
- public boolean getTransacted() throws JMSException
- {
- associate() ;
- return session.getTransacted();
- }
-
- public void recover() throws JMSException
- {
- associate() ;
- session.recover();
- }
-
- public void rollback() throws JMSException
- {
- setSuspect(true) ;
- session.rollback();
- setSuspect(false) ;
- }
-
- public void run()
- {
- session.run();
- }
-
- public void setMessageListener(MessageListener arg0) throws JMSException
- {
- associate() ;
- session.setMessageListener(arg0);
- }
-
- public void unsubscribe(String arg0) throws JMSException
- {
- associate() ;
- session.unsubscribe(arg0);
- }
-
- private synchronized QueueBrowser trackQueueBrowser(QueueBrowser queueBrowser)
- throws JMSException
- {
- associate() ;
- if (queueBrowserSet == null)
- {
- queueBrowserSet = new HashSet<QueueBrowser>() ;
- }
- final QueueBrowser result = getQueueBrowser(queueBrowser) ;
- queueBrowserSet.add(result) ;
- return (QueueBrowser)getExceptionHandler(pool, QueueBrowser.class, result) ;
- }
-
- private synchronized MessageConsumer trackMessageConsumer(MessageConsumer messageConsumer)
- throws JMSException
- {
- associate() ;
- if (messageConsumerSet == null)
- {
- messageConsumerSet = new HashSet<MessageConsumer>() ;
- }
- final MessageConsumer result = getMessageConsumer(messageConsumer) ;
- messageConsumerSet.add(result) ;
- return (MessageConsumer)getExceptionHandler(pool, MessageConsumer.class, result) ;
- }
-
- private synchronized TopicSubscriber trackTopicSubscriber(TopicSubscriber topicSubscriber)
- throws JMSException
- {
- associate() ;
- if (messageConsumerSet == null)
- {
- messageConsumerSet = new HashSet<MessageConsumer>() ;
- }
- final TopicSubscriber result = getTopicSubscriber(topicSubscriber) ;
- messageConsumerSet.add(result) ;
- return (TopicSubscriber)getExceptionHandler(pool, TopicSubscriber.class, result) ;
- }
-
- private synchronized MessageProducer trackMessageProducer(MessageProducer messageProducer)
- throws JMSException
- {
- associate() ;
- if (messageProducerSet == null)
- {
- messageProducerSet = new HashSet<MessageProducer>() ;
- }
- final MessageProducer result = getMessageProducer(messageProducer) ;
- messageProducerSet.add(result) ;
- return (MessageProducer)getExceptionHandler(pool, MessageProducer.class, result) ;
- }
-
- synchronized void releaseResources()
- {
- if (queueBrowserSet != null)
- {
- for(QueueBrowser queueBrowser: queueBrowserSet)
- {
- try {
- queueBrowser.close() ;
- } catch (final Exception jmse) {} // ignore
- }
- queueBrowserSet = null ;
- }
- if (messageConsumerSet != null)
- {
- for(MessageConsumer messageConsumer: messageConsumerSet)
- {
- try {
- messageConsumer.close() ;
- } catch (final Exception jmse) {} // ignore
- }
- messageConsumerSet = null ;
- }
- if (messageProducerSet != null)
- {
- for(MessageProducer messageProducer: messageProducerSet)
- {
- try {
- messageProducer.close() ;
- } catch (final Exception jmse) {} // ignore
- }
- messageProducerSet = null ;
- }
- }
-
- protected QueueBrowser getQueueBrowser(QueueBrowser queueBrowser)
- {
- return queueBrowser ;
- }
-
- protected MessageConsumer getMessageConsumer(MessageConsumer messageConsumer)
- {
- return messageConsumer ;
- }
-
- protected TopicSubscriber getTopicSubscriber(TopicSubscriber topicSubscriber)
- {
- return topicSubscriber ;
- }
-
- protected MessageProducer getMessageProducer(MessageProducer messageProducer)
- {
- return messageProducer ;
- }
-
- protected void handleCloseSession(final JmsConnectionPool jmsConnectionPool)
- {
- jmsConnectionPool.handleCloseSession(this) ;
- }
-
- protected void handleReleaseSession(JmsConnectionPool jmsConnectionPool)
- {
- jmsConnectionPool.handleReleaseSession(this) ;
- }
-
- protected void associate()
- throws JMSException
- {
- }
-
- protected void setSuspect(final boolean suspect)
- {
- this.suspect = suspect ;
- }
-
- public boolean isSuspect()
- {
- return suspect ;
- }
-
- /**
- * Wrap the object in an exception handler.
- * @param pool The pool associated with this session.
- * @param instanceClass The interface type of the instance.
- * @param instance The instance
- * @return
- */
- protected Object getExceptionHandler(final JmsConnectionPool pool,
- final Class<?> instanceClass, final Object instance)
- {
- final InvocationHandler handler = new ExceptionHandler(pool, instance) ;
- return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {instanceClass}, handler);
- }
-
- /**
- * Handler responsible for intercepting JMS exceptions and checking for unreported closure.
- * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
- */
- private final class ExceptionHandler implements InvocationHandler
- {
- /**
- * The connection pool.
- */
- private final JmsConnectionPool pool ;
- /**
- * The target instance.
- */
- private final Object target ;
-
- /**
- * Construct the handler using the specified target.
- * @param pool The associated connection pool.
- * @param target The target instance.
- */
- public ExceptionHandler(final JmsConnectionPool pool, final Object target)
- {
- this.pool = pool ;
- this.target = target ;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- {
- try
- {
- return method.invoke(target, args);
- }
- catch (final InvocationTargetException ite)
- {
- final Throwable th = ite.getCause() ;
- if (th instanceof JMSException)
- {
- pool.handleException(JmsSession.this, (JMSException)th) ;
- }
- throw th ;
- }
- }
- }
-}
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,492 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.internal.soa.esb.rosetta.pooling;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashSet;
+
+import javax.jms.BytesMessage;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TemporaryQueue;
+import javax.jms.TemporaryTopic;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.jms.TopicSubscriber;
+
+/**
+ * Wrapper for JMS session class, responsible for tracking resources and the pooling.
+ */
+public class JmsSession implements Session
+{
+ /**
+ * The connection pool.
+ */
+ private final JmsConnectionPool pool ;
+ /**
+ * The session delegate.
+ */
+ private final Session session ;
+ /**
+ * The pool instance id.
+ */
+ private final long id ;
+ /**
+ * The session acknowledge mode.
+ */
+ private final int acknowledgeMode ;
+ /**
+ * The requested acknowledge mode for this session.
+ */
+ private final int requestedAcknowledgeMode ;
+
+ /**
+ * Flag indicating whether this session is suspect or not.
+ */
+ private boolean suspect ;
+
+ /**
+ * The set of active queue browsers.
+ */
+ private HashSet<QueueBrowser> queueBrowserSet ;
+ /**
+ * The set of active message consumers.
+ */
+ private HashSet<MessageConsumer> messageConsumerSet ;
+ /**
+ * The set of active message producers.
+ */
+ private HashSet<MessageProducer> messageProducerSet ;
+
+ /**
+ * Create the session wrapper.
+ * @param pool The pool associated with this session.
+ * @param session The session delegate.
+ * @param id The pool instance id.
+ * @param requestedAcknowledgeMode The requested acknowledge mode for this session.
+ * @throws JMSException
+ */
+ JmsSession(final JmsConnectionPool pool, final Session session, final long id, final int requestedAcknowledgeMode)
+ throws JMSException
+ {
+ this.pool = pool ;
+ this.id = id ;
+ this.session = (Session)getExceptionHandler(pool, Session.class, session) ;
+ this.requestedAcknowledgeMode = requestedAcknowledgeMode ;
+ acknowledgeMode = session.getAcknowledgeMode() ;
+ // Workaround for JBESB-1873
+ if ("org.jboss.jms.client.JBossSession".equals(session.getClass().getName()))
+ {
+ SessionExecutorInit.initExecutor(session) ;
+ }
+ }
+
+ public long getId()
+ {
+ return id ;
+ }
+
+ public void close() throws JMSException
+ {
+ session.close();
+ }
+
+ public void commit() throws JMSException
+ {
+ setSuspect(true) ;
+ session.commit();
+ setSuspect(false) ;
+ }
+
+ public QueueBrowser createBrowser(Queue arg0, String arg1)
+ throws JMSException
+ {
+ return trackQueueBrowser(session.createBrowser(arg0, arg1));
+ }
+
+ public QueueBrowser createBrowser(Queue arg0) throws JMSException
+ {
+ return trackQueueBrowser(session.createBrowser(arg0));
+ }
+
+ public BytesMessage createBytesMessage() throws JMSException
+ {
+ associate() ;
+ return session.createBytesMessage();
+ }
+
+ public MessageConsumer createConsumer(Destination arg0, String arg1,
+ boolean arg2) throws JMSException
+ {
+ return trackMessageConsumer(session.createConsumer(arg0, arg1, arg2));
+ }
+
+ public MessageConsumer createConsumer(Destination arg0, String arg1)
+ throws JMSException
+ {
+ return trackMessageConsumer(session.createConsumer(arg0, arg1));
+ }
+
+ public MessageConsumer createConsumer(Destination arg0) throws JMSException
+ {
+ return trackMessageConsumer(session.createConsumer(arg0));
+ }
+
+ public TopicSubscriber createDurableSubscriber(Topic arg0, String arg1,
+ String arg2, boolean arg3) throws JMSException
+ {
+ return trackTopicSubscriber(session.createDurableSubscriber(arg0, arg1, arg2, arg3));
+ }
+
+ public TopicSubscriber createDurableSubscriber(Topic arg0, String arg1)
+ throws JMSException
+ {
+ return trackTopicSubscriber(session.createDurableSubscriber(arg0, arg1));
+ }
+
+ public MapMessage createMapMessage() throws JMSException
+ {
+ associate() ;
+ return session.createMapMessage();
+ }
+
+ public Message createMessage() throws JMSException
+ {
+ associate() ;
+ return session.createMessage();
+ }
+
+ public ObjectMessage createObjectMessage() throws JMSException
+ {
+ associate() ;
+ return session.createObjectMessage();
+ }
+
+ public ObjectMessage createObjectMessage(Serializable arg0)
+ throws JMSException
+ {
+ associate() ;
+ return session.createObjectMessage(arg0);
+ }
+
+ public MessageProducer createProducer(Destination arg0) throws JMSException
+ {
+ return trackMessageProducer(session.createProducer(arg0));
+ }
+
+ public Queue createQueue(String arg0) throws JMSException
+ {
+ associate() ;
+ return session.createQueue(arg0);
+ }
+
+ public StreamMessage createStreamMessage() throws JMSException
+ {
+ associate() ;
+ return session.createStreamMessage();
+ }
+
+ public TemporaryQueue createTemporaryQueue() throws JMSException
+ {
+ associate() ;
+ return session.createTemporaryQueue();
+ }
+
+ public TemporaryTopic createTemporaryTopic() throws JMSException
+ {
+ associate() ;
+ return session.createTemporaryTopic();
+ }
+
+ public TextMessage createTextMessage() throws JMSException
+ {
+ associate() ;
+ return session.createTextMessage();
+ }
+
+ public TextMessage createTextMessage(String arg0) throws JMSException
+ {
+ associate() ;
+ return session.createTextMessage(arg0);
+ }
+
+ public Topic createTopic(String arg0) throws JMSException
+ {
+ associate() ;
+ return session.createTopic(arg0);
+ }
+
+ public int getAcknowledgeMode() throws JMSException
+ {
+ return acknowledgeMode;
+ }
+
+ public MessageListener getMessageListener() throws JMSException
+ {
+ associate() ;
+ return session.getMessageListener();
+ }
+
+ public boolean getTransacted() throws JMSException
+ {
+ associate() ;
+ return session.getTransacted();
+ }
+
+ public void recover() throws JMSException
+ {
+ associate() ;
+ session.recover();
+ }
+
+ public void rollback() throws JMSException
+ {
+ setSuspect(true) ;
+ session.rollback();
+ setSuspect(false) ;
+ }
+
+ public void run()
+ {
+ session.run();
+ }
+
+ public void setMessageListener(MessageListener arg0) throws JMSException
+ {
+ associate() ;
+ session.setMessageListener(arg0);
+ }
+
+ public void unsubscribe(String arg0) throws JMSException
+ {
+ associate() ;
+ session.unsubscribe(arg0);
+ }
+
+ private synchronized QueueBrowser trackQueueBrowser(QueueBrowser queueBrowser)
+ throws JMSException
+ {
+ associate() ;
+ if (queueBrowserSet == null)
+ {
+ queueBrowserSet = new HashSet<QueueBrowser>() ;
+ }
+ final QueueBrowser result = getQueueBrowser(queueBrowser) ;
+ queueBrowserSet.add(result) ;
+ return (QueueBrowser)getExceptionHandler(pool, QueueBrowser.class, result) ;
+ }
+
+ private synchronized MessageConsumer trackMessageConsumer(MessageConsumer messageConsumer)
+ throws JMSException
+ {
+ associate() ;
+ if (messageConsumerSet == null)
+ {
+ messageConsumerSet = new HashSet<MessageConsumer>() ;
+ }
+ final MessageConsumer result = getMessageConsumer(messageConsumer) ;
+ messageConsumerSet.add(result) ;
+ return (MessageConsumer)getExceptionHandler(pool, MessageConsumer.class, result) ;
+ }
+
+ private synchronized TopicSubscriber trackTopicSubscriber(TopicSubscriber topicSubscriber)
+ throws JMSException
+ {
+ associate() ;
+ if (messageConsumerSet == null)
+ {
+ messageConsumerSet = new HashSet<MessageConsumer>() ;
+ }
+ final TopicSubscriber result = getTopicSubscriber(topicSubscriber) ;
+ messageConsumerSet.add(result) ;
+ return (TopicSubscriber)getExceptionHandler(pool, TopicSubscriber.class, result) ;
+ }
+
+ private synchronized MessageProducer trackMessageProducer(MessageProducer messageProducer)
+ throws JMSException
+ {
+ associate() ;
+ if (messageProducerSet == null)
+ {
+ messageProducerSet = new HashSet<MessageProducer>() ;
+ }
+ final MessageProducer result = getMessageProducer(messageProducer) ;
+ messageProducerSet.add(result) ;
+ return (MessageProducer)getExceptionHandler(pool, MessageProducer.class, result) ;
+ }
+
+ synchronized void releaseResources()
+ {
+ if (queueBrowserSet != null)
+ {
+ for(QueueBrowser queueBrowser: queueBrowserSet)
+ {
+ try {
+ queueBrowser.close() ;
+ } catch (final Exception jmse) {} // ignore
+ }
+ queueBrowserSet = null ;
+ }
+ if (messageConsumerSet != null)
+ {
+ for(MessageConsumer messageConsumer: messageConsumerSet)
+ {
+ try {
+ messageConsumer.close() ;
+ } catch (final Exception jmse) {} // ignore
+ }
+ messageConsumerSet = null ;
+ }
+ if (messageProducerSet != null)
+ {
+ for(MessageProducer messageProducer: messageProducerSet)
+ {
+ try {
+ messageProducer.close() ;
+ } catch (final Exception jmse) {} // ignore
+ }
+ messageProducerSet = null ;
+ }
+ }
+
+ protected QueueBrowser getQueueBrowser(QueueBrowser queueBrowser)
+ {
+ return queueBrowser ;
+ }
+
+ protected MessageConsumer getMessageConsumer(MessageConsumer messageConsumer)
+ {
+ return messageConsumer ;
+ }
+
+ protected TopicSubscriber getTopicSubscriber(TopicSubscriber topicSubscriber)
+ {
+ return topicSubscriber ;
+ }
+
+ protected MessageProducer getMessageProducer(MessageProducer messageProducer)
+ {
+ return messageProducer ;
+ }
+
+ protected void handleCloseSession(final JmsConnectionPool jmsConnectionPool)
+ {
+ jmsConnectionPool.handleCloseSession(this) ;
+ }
+
+ protected void handleReleaseSession(JmsConnectionPool jmsConnectionPool)
+ {
+ jmsConnectionPool.handleReleaseSession(this) ;
+ }
+
+ protected void associate()
+ throws JMSException
+ {
+ }
+
+ protected void setSuspect(final boolean suspect)
+ {
+ this.suspect = suspect ;
+ }
+
+ public boolean isSuspect()
+ {
+ return suspect ;
+ }
+
+ public int getRequestedAcknowledgeMode()
+ {
+ return requestedAcknowledgeMode ;
+ }
+
+ /**
+ * Wrap the object in an exception handler.
+ * @param pool The pool associated with this session.
+ * @param instanceClass The interface type of the instance.
+ * @param instance The instance
+ * @return
+ */
+ protected Object getExceptionHandler(final JmsConnectionPool pool,
+ final Class<?> instanceClass, final Object instance)
+ {
+ final InvocationHandler handler = new ExceptionHandler(pool, instance) ;
+ return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {instanceClass}, handler);
+ }
+
+ /**
+ * Handler responsible for intercepting JMS exceptions and checking for unreported closure.
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+ private final class ExceptionHandler implements InvocationHandler
+ {
+ /**
+ * The connection pool.
+ */
+ private final JmsConnectionPool pool ;
+ /**
+ * The target instance.
+ */
+ private final Object target ;
+
+ /**
+ * Construct the handler using the specified target.
+ * @param pool The associated connection pool.
+ * @param target The target instance.
+ */
+ public ExceptionHandler(final JmsConnectionPool pool, final Object target)
+ {
+ this.pool = pool ;
+ this.target = target ;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ try
+ {
+ return method.invoke(target, args);
+ }
+ catch (final InvocationTargetException ite)
+ {
+ final Throwable th = ite.getCause() ;
+ if (th instanceof JMSException)
+ {
+ pool.handleException(JmsSession.this, (JMSException)th) ;
+ }
+ throw th ;
+ }
+ }
+ }
+}
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,254 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.internal.soa.esb.rosetta.pooling;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.QueueBrowser;
-import javax.jms.TopicSubscriber;
-import javax.jms.XASession;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.xa.XAResource;
-
-import org.jboss.soa.esb.common.TransactionStrategy;
-import org.jboss.soa.esb.common.TransactionStrategyException;
-
-/**
- * Wrapper for JMS XA session class, responsible for tracking resources and the pooling.
- */
-class JmsXASession extends JmsSession implements Synchronization
-{
- /**
- * The connection pool.
- */
- private final JmsConnectionPool pool ;
-
- /**
- * The session delegate.
- */
- private final XASession session ;
-
- /**
- * Flag indicating whether this session is associated with a transaction.
- */
- private boolean associated ;
-
- /**
- * Cleanup actions
- */
- private enum Cleanup { close, release, none }
-
- /**
- * The cleanup action for the synchronization.
- */
- private Cleanup cleanupAction = Cleanup.none ;
-
- /**
- * Create the session wrapper.
- * @param pool The current connection pool
- * @param session The session delegate.
- * @param id The pool instance id.
- * @throws JMSException
- */
- JmsXASession(final JmsConnectionPool pool, final XASession session, final long id)
- throws JMSException
- {
- super(pool, session, id) ;
- this.pool = pool ;
- this.session = (XASession)getExceptionHandler(pool, XASession.class, session) ;
- }
-
- @Override
- public void commit() throws JMSException
- {
- // Handled by the transaction
- }
-
- @Override
- public void rollback() throws JMSException
- {
- try
- {
- TransactionStrategy.getTransactionStrategy(true).rollbackOnly() ;
- }
- catch (final TransactionStrategyException tse)
- {
- final JMSException ex = new JMSException("Failed to rollback transaction") ;
- ex.initCause(tse) ;
- throw ex ;
- }
- }
-
- @Override
- protected MessageProducer getMessageProducer(MessageProducer messageProducer)
- {
- final InvocationHandler handler = new AssociationHandler(messageProducer) ;
- return (MessageProducer)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {MessageProducer.class}, handler );
- }
-
- @Override
- protected MessageConsumer getMessageConsumer(MessageConsumer messageConsumer)
- {
- final InvocationHandler handler = new AssociationHandler(messageConsumer) ;
- return (MessageConsumer)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {MessageConsumer.class}, handler);
- }
-
- @Override
- protected QueueBrowser getQueueBrowser(QueueBrowser queueBrowser)
- {
- final InvocationHandler handler = new AssociationHandler(queueBrowser) ;
- return (QueueBrowser)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {QueueBrowser.class}, handler);
- }
-
- @Override
- protected TopicSubscriber getTopicSubscriber(TopicSubscriber topicSubscriber)
- {
- final InvocationHandler handler = new AssociationHandler(topicSubscriber) ;
- return (TopicSubscriber)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {TopicSubscriber.class}, handler);
- }
-
- protected synchronized void handleCloseSession(final JmsConnectionPool jmsConnectionPool)
- {
- if (associated)
- {
- cleanupAction = Cleanup.close ;
- }
- else
- {
- pool.handleCloseSession(this) ;
- }
- }
-
- protected synchronized void handleReleaseSession(JmsConnectionPool jmsConnectionPool)
- {
- if (associated)
- {
- cleanupAction = Cleanup.release ;
- }
- else
- {
- pool.handleReleaseSession(this) ;
- }
- }
-
- protected synchronized void associate()
- throws JMSException
- {
- if (!associated)
- {
- cleanupAction = Cleanup.none ;
- final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
- try
- {
- transactionStrategy.registerSynchronization(this) ;
- setSuspect(true) ;
- final XAResource resource = session.getXAResource() ;
- transactionStrategy.enlistResource(resource) ;
- }
- catch (final TransactionStrategyException tse)
- {
- final JMSException ex = new JMSException("Failed to initialise transaction resources") ;
- ex.initCause(tse) ;
- throw ex ;
- }
- try
- {
- pool.associateTransaction(this) ;
- }
- catch (final ConnectionException ce)
- {
- final JMSException ex = new JMSException("Failed to associate session with the current transaction") ;
- ex.initCause(ce) ;
- throw ex ;
- }
-
- setSuspect(false) ;
- associated = true ;
- }
- }
-
- public void beforeCompletion()
- {
- }
-
- public synchronized void afterCompletion(final int result)
- {
- pool.disassociateTransaction(this) ;
- switch (cleanupAction)
- {
- case close:
- if (result == Status.STATUS_COMMITTED)
- {
- pool.handleCloseSession(this) ;
- break ;
- }
- // fall through
- case release:
- pool.handleReleaseSession(this) ;
- break ;
- case none:
- // Reference held by caller
- }
- associated = false ;
- }
-
- /**
- * Handler responsible for associating XA resources.
- * @author kevin
- */
- private final class AssociationHandler implements InvocationHandler
- {
- /**
- * The target instance.
- */
- private final Object target ;
-
- /**
- * Construct the handler using the specified target.
- * @param target The target instance.
- */
- public AssociationHandler(final Object target)
- {
- this.target = target ;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
- {
- associate() ;
- try
- {
- return method.invoke(target, args);
- }
- catch (final InvocationTargetException ite)
- {
- throw ite.getCause() ;
- }
- }
- }
-}
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,255 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.internal.soa.esb.rosetta.pooling;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.QueueBrowser;
+import javax.jms.TopicSubscriber;
+import javax.jms.XASession;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.xa.XAResource;
+
+import org.jboss.soa.esb.common.TransactionStrategy;
+import org.jboss.soa.esb.common.TransactionStrategyException;
+
+/**
+ * Wrapper for JMS XA session class, responsible for tracking resources and the pooling.
+ */
+class JmsXASession extends JmsSession implements Synchronization
+{
+ /**
+ * The connection pool.
+ */
+ private final JmsConnectionPool pool ;
+
+ /**
+ * The session delegate.
+ */
+ private final XASession session ;
+
+ /**
+ * Flag indicating whether this session is associated with a transaction.
+ */
+ private boolean associated ;
+
+ /**
+ * Cleanup actions
+ */
+ private enum Cleanup { close, release, none }
+
+ /**
+ * The cleanup action for the synchronization.
+ */
+ private Cleanup cleanupAction = Cleanup.none ;
+
+ /**
+ * Create the session wrapper.
+ * @param pool The current connection pool
+ * @param session The session delegate.
+ * @param id The pool instance id.
+ * @param requestedAcknowledgeMode The requested acknowledge mode for this session.
+ * @throws JMSException
+ */
+ JmsXASession(final JmsConnectionPool pool, final XASession session, final long id, final int requestedAcknowledgeMode)
+ throws JMSException
+ {
+ super(pool, session, id, requestedAcknowledgeMode) ;
+ this.pool = pool ;
+ this.session = (XASession)getExceptionHandler(pool, XASession.class, session) ;
+ }
+
+ @Override
+ public void commit() throws JMSException
+ {
+ // Handled by the transaction
+ }
+
+ @Override
+ public void rollback() throws JMSException
+ {
+ try
+ {
+ TransactionStrategy.getTransactionStrategy(true).rollbackOnly() ;
+ }
+ catch (final TransactionStrategyException tse)
+ {
+ final JMSException ex = new JMSException("Failed to rollback transaction") ;
+ ex.initCause(tse) ;
+ throw ex ;
+ }
+ }
+
+ @Override
+ protected MessageProducer getMessageProducer(MessageProducer messageProducer)
+ {
+ final InvocationHandler handler = new AssociationHandler(messageProducer) ;
+ return (MessageProducer)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {MessageProducer.class}, handler );
+ }
+
+ @Override
+ protected MessageConsumer getMessageConsumer(MessageConsumer messageConsumer)
+ {
+ final InvocationHandler handler = new AssociationHandler(messageConsumer) ;
+ return (MessageConsumer)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {MessageConsumer.class}, handler);
+ }
+
+ @Override
+ protected QueueBrowser getQueueBrowser(QueueBrowser queueBrowser)
+ {
+ final InvocationHandler handler = new AssociationHandler(queueBrowser) ;
+ return (QueueBrowser)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {QueueBrowser.class}, handler);
+ }
+
+ @Override
+ protected TopicSubscriber getTopicSubscriber(TopicSubscriber topicSubscriber)
+ {
+ final InvocationHandler handler = new AssociationHandler(topicSubscriber) ;
+ return (TopicSubscriber)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {TopicSubscriber.class}, handler);
+ }
+
+ protected synchronized void handleCloseSession(final JmsConnectionPool jmsConnectionPool)
+ {
+ if (associated)
+ {
+ cleanupAction = Cleanup.close ;
+ }
+ else
+ {
+ pool.handleCloseSession(this) ;
+ }
+ }
+
+ protected synchronized void handleReleaseSession(JmsConnectionPool jmsConnectionPool)
+ {
+ if (associated)
+ {
+ cleanupAction = Cleanup.release ;
+ }
+ else
+ {
+ pool.handleReleaseSession(this) ;
+ }
+ }
+
+ protected synchronized void associate()
+ throws JMSException
+ {
+ if (!associated)
+ {
+ cleanupAction = Cleanup.none ;
+ final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
+ try
+ {
+ transactionStrategy.registerSynchronization(this) ;
+ setSuspect(true) ;
+ final XAResource resource = session.getXAResource() ;
+ transactionStrategy.enlistResource(resource) ;
+ }
+ catch (final TransactionStrategyException tse)
+ {
+ final JMSException ex = new JMSException("Failed to initialise transaction resources") ;
+ ex.initCause(tse) ;
+ throw ex ;
+ }
+ try
+ {
+ pool.associateTransaction(this) ;
+ }
+ catch (final ConnectionException ce)
+ {
+ final JMSException ex = new JMSException("Failed to associate session with the current transaction") ;
+ ex.initCause(ce) ;
+ throw ex ;
+ }
+
+ setSuspect(false) ;
+ associated = true ;
+ }
+ }
+
+ public void beforeCompletion()
+ {
+ }
+
+ public synchronized void afterCompletion(final int result)
+ {
+ pool.disassociateTransaction(this) ;
+ switch (cleanupAction)
+ {
+ case close:
+ if (result == Status.STATUS_COMMITTED)
+ {
+ pool.handleCloseSession(this) ;
+ break ;
+ }
+ // fall through
+ case release:
+ pool.handleReleaseSession(this) ;
+ break ;
+ case none:
+ // Reference held by caller
+ }
+ associated = false ;
+ }
+
+ /**
+ * Handler responsible for associating XA resources.
+ * @author kevin
+ */
+ private final class AssociationHandler implements InvocationHandler
+ {
+ /**
+ * The target instance.
+ */
+ private final Object target ;
+
+ /**
+ * Construct the handler using the specified target.
+ * @param target The target instance.
+ */
+ public AssociationHandler(final Object target)
+ {
+ this.target = target ;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ associate() ;
+ try
+ {
+ return method.invoke(target, args);
+ }
+ catch (final InvocationTargetException ite)
+ {
+ throw ite.getCause() ;
+ }
+ }
+ }
+}
Added: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/JBossMessagingConnectionExceptionHandler.java
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/JBossMessagingConnectionExceptionHandler.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/JBossMessagingConnectionExceptionHandler.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.rosetta.pooling.handlers;
+
+import javax.jms.JMSException;
+
+import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionExceptionHandler;
+
+/**
+ * JBoss Messaging connection exception handler.
+ *
+ * @author <a href="mailto:Kevin.Conner at jboss.com">Kevin Conner</a>
+ */
+public class JBossMessagingConnectionExceptionHandler implements JmsConnectionExceptionHandler
+{
+ /**
+ * Check the exception to see whether it indicates a connection failure
+ * @param jmse The current JMS Exception
+ * @return null if no connection failure, TRUE if the connection should be closed, FALSE if just cleaned up.
+ */
+ public Boolean isConnectionFailure(final JMSException jmse)
+ {
+ /*
+ * JBoss Messaging can drop the connection from the server side
+ * without calling back on the exception listener. We check for
+ * IllegalStateException as this appears to be the indicator
+ * exception used by JBoss Messaging when the connection has disappeared.
+ *
+ * We return TRUE as the connection should be closed.
+ */
+ Throwable cause = jmse ;
+ while(cause.getCause() != null)
+ {
+ cause = cause.getCause() ;
+ }
+ return (cause instanceof IllegalStateException ? Boolean.TRUE : null) ;
+ }
+}
Property changes on: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/JBossMessagingConnectionExceptionHandler.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/WMQConnectionExceptionHandler.java
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/WMQConnectionExceptionHandler.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/WMQConnectionExceptionHandler.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.jboss.internal.soa.esb.rosetta.pooling.handlers;
+
+import javax.jms.JMSException;
+
+import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionExceptionHandler;
+
+/**
+ * JBoss Messaging connection exception handler.
+ *
+ * @author <a href="mailto:Kevin.Conner at jboss.com">Kevin Conner</a>
+ */
+public class WMQConnectionExceptionHandler implements JmsConnectionExceptionHandler
+{
+ /**
+ * WMQ error code.
+ */
+ public static final String WMQ_ERROR_CODE_CONNECTION_FAILURE = "MQJMS2008";
+ /**
+ * WMQ connection failure message.
+ */
+ public static final String WMQ_LINKED_EXCEPTION_CONNECTION_FAILURE = "MQJE001: Completion Code 2, Reason 2009";
+
+ /**
+ * Check the exception to see whether it indicates a connection failure
+ * @param jmse The current JMS Exception
+ * @return null if no connection failure, TRUE if the connection should be closed, FALSE if just cleaned up.
+ */
+ public Boolean isConnectionFailure(final JMSException jmse)
+ {
+ /*
+ * Websphere MQ can drop the connection from the server side
+ * without calling back on the exception listener. We check for
+ * the exception errorcode MQJMS2008 used by Websphere MQ when the connection has disappeared.
+ *
+ * We return FALSE as we should not try to close the connection.
+ */
+ boolean iswmqMessagingConnectionFailure = false;
+
+ if (WMQ_ERROR_CODE_CONNECTION_FAILURE.equals(jmse.getErrorCode())) {
+ Exception linkedException = jmse.getLinkedException();
+ if ((linkedException != null)
+ && (WMQ_LINKED_EXCEPTION_CONNECTION_FAILURE.equals(linkedException.getMessage()))) {
+ iswmqMessagingConnectionFailure = true;
+ }
+ }
+ return (iswmqMessagingConnectionFailure ? Boolean.FALSE : null) ;
+ }
+}
Property changes on: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/handlers/WMQConnectionExceptionHandler.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,820 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.internal.soa.esb.services.registry;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.registry.BulkResponse;
-import javax.xml.registry.BusinessLifeCycleManager;
-import javax.xml.registry.BusinessQueryManager;
-import javax.xml.registry.Connection;
-import javax.xml.registry.FindQualifier;
-import javax.xml.registry.JAXRException;
-import javax.xml.registry.JAXRResponse;
-import javax.xml.registry.RegistryService;
-import javax.xml.registry.infomodel.Classification;
-import javax.xml.registry.infomodel.ClassificationScheme;
-import javax.xml.registry.infomodel.Concept;
-import javax.xml.registry.infomodel.EmailAddress;
-import javax.xml.registry.infomodel.Key;
-import javax.xml.registry.infomodel.Organization;
-import javax.xml.registry.infomodel.PersonName;
-import javax.xml.registry.infomodel.PostalAddress;
-import javax.xml.registry.infomodel.RegistryObject;
-import javax.xml.registry.infomodel.Service;
-import javax.xml.registry.infomodel.ServiceBinding;
-import javax.xml.registry.infomodel.SpecificationLink;
-import javax.xml.registry.infomodel.TelephoneNumber;
-import javax.xml.registry.infomodel.User;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.ws.scout.registry.infomodel.KeyImpl;
-import org.apache.ws.scout.registry.infomodel.SpecificationLinkImpl;
-import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.services.registry.Registry;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
-/**
- * Utility class for the Registry.
- * If need be we can extract the interface from here, add a factory and have JAXR as a plugin, allowing
- * for other RegistryAPIs.
- *
- * @author Kurt Stam
- */
-public class JAXRRegistryImpl implements Registry
-{
- private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
- private JAXRConnectionFactory jaxrConnectionFactory;
- private Organization jbossESBOrganization;
- private static Concept jbossTModel;
- public static final String JBOSS_ESB_CATEGORY = "org.jboss.soa.esb.:category";
-
- public JAXRRegistryImpl() throws ConfigurationException {
- jaxrConnectionFactory = new JAXRConnectionFactory();
- }
-
- /**
- * Publish an EPR to the Registry
- */
- protected Service registerService(String category, String serviceName, String serviceDescription) throws JAXRException
- {
- Service service =null;
- Organization organization = getJBossESBOrganization();
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- //Adding the category as prefix for the name
- service = blm.createService(blm.createInternationalString(serviceName));
- service.setDescription(blm.createInternationalString(serviceDescription));
- Collection<String> findQualifiers = new ArrayList<String>();
- findQualifiers.add(FindQualifier.AND_ALL_KEYS);
- findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
- ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
- Classification classification = blm.createClassification(cScheme, "category", category);
- service.addClassification(classification);
- service.setProvidingOrganization(organization);
- saveRegistryObject(service, jaxrConnectionFactory);
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- return service;
- }
- /**
- * Remove an EPR from the Registry
- */
- @SuppressWarnings("unchecked")
- public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException{
- // first find the ServiceBindings for this service
- Connection connection = jaxrConnectionFactory.getConnection();
- Service service = null;
- try {
- service = findService(category, serviceName);
- if (service==null) {
- throw new ServiceNotFoundException("No such EPR found for service with name = " + serviceName);
- }
- RegistryService rs = connection.getRegistryService();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- Collection<Key> serviceKeys = new ArrayList<Key>();
- serviceKeys.add(service.getKey());
- blm.deleteServices(serviceKeys);
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
- /**
- * Publish an EPR to the Registry
- */
- public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription)
- throws RegistryException
- {
- Connection connection = jaxrConnectionFactory.getConnection();
- if (jbossTModel == null) {
- try {
- jbossTModel = getJBossESBTModel(jaxrConnectionFactory);
- } catch (JAXRException je) {
- throw new RegistryException();
- }
- }
-
- try {
- //Find the service
- Service service = findService(category,serviceName);
- if (service==null) {
- logger.log(Level.DEBUG, "Service " + serviceName + " does not yet exist, creating now..");
- service = registerService(category, serviceName, serviceDescription);
- }
-
- RegistryService rs = connection.getRegistryService();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- ServiceBinding serviceBinding = blm.createServiceBinding();
- String xml = EPRHelper.toXMLString(epr);
- serviceBinding.setAccessURI(xml);
-
- ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
- SpecificationLink sl = new SpecificationLinkImpl(blm);
- sl.setSpecificationObject(jbossTModel);
- serviceBinding.getSpecificationLinks().add(sl);
- serviceBinding.setDescription(blm.createInternationalString(eprDescription));
- serviceBindings.add(serviceBinding);
-
- service.addServiceBindings(serviceBindings);
- Collection<String> findQualifiers = new ArrayList<String>();
- findQualifiers.add(FindQualifier.AND_ALL_KEYS);
- findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
- ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
- Classification classification = blm.createClassification(cScheme, "category", category);
- service.addClassification(classification);
-
- saveRegistryObject(serviceBinding, jaxrConnectionFactory);
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- } catch (MarshalException me) {
- throw new RegistryException(me.getLocalizedMessage(), me);
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
- /**
- * Remove an EPR from the Registry
- */
- public void unRegisterEPR(String category, String serviceName, EPR toBeDeletedEPR) throws RegistryException, ServiceNotFoundException{
- //first find the ServiceBindings for this service
- Connection connection = jaxrConnectionFactory.getConnection();
- Service service = null;
- try {
- service = findService(category, serviceName);
- if (service==null) {
- throw new ServiceNotFoundException("No such Service found for service with category= "
- + category + " and name = " + serviceName);
- }
- Collection serviceBindings = findServiceBindings(service);
- service.addServiceBindings(serviceBindings);
- for (Iterator i=serviceBindings.iterator();i.hasNext();){
- ServiceBinding serviceBinding = (ServiceBinding) i.next();
- String eprXML = serviceBinding.getAccessURI().trim();
- // for backwards compatibility still have the decoder if
- // unmarchalling fails
- try {
- EPR epr = EPRHelper.fromXMLString(eprXML);
- } catch (UnmarshalException unme) {
- try {
- eprXML = URLDecoder.decode(eprXML, "UTF-8").trim();
- } catch (UnsupportedEncodingException ue) {
- logger.error(unme.getMessage(), unme);
- logger.error(ue.getMessage(), ue);
- }
- }
- String toBeDeletedEPRXml = EPRHelper.toXMLString(toBeDeletedEPR).trim();
- if (eprXML.equals(toBeDeletedEPRXml)) {
- RegistryService rs = connection.getRegistryService();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- Collection<Key> serviceBindingKeys = new ArrayList<Key>();
- serviceBindingKeys.add(serviceBinding.getKey());
- blm.deleteServiceBindings(serviceBindingKeys);
- return;
- }
- }
- throw new RegistryException("No such EPR found for service with name = "
- + serviceName + " and EPR=" + toBeDeletedEPR);
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- } catch (MarshalException me) {
- throw new RegistryException(me.getLocalizedMessage(), me);
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
-
- /**
- * {@inheritDoc}
- * @return collection services
- */
- public List<String> findAllServices() throws RegistryException
- {
- List<String> serviceNames = new ArrayList<String>();
- try {
- Collection<Service> services = findServices();
- for (Service service: services) {
- String serviceName = service.getName().getValue();
- serviceNames.add(serviceName);
- }
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- }
- return serviceNames;
- }
- /**
- * Find Services based on a category ("transformation").
- *
- * @return collection services
- */
- public List<String> findServices(String category) throws RegistryException
- {
- List<String>serviceNames = new ArrayList<String>();
-
- try {
- Collection<Service>services = findServicesForCategory(category);
- for (Iterator<Service> i=services.iterator();i.hasNext();) {
- String serviceName = i.next().getName().getValue();
- serviceNames.add(serviceName);
- }
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- }
- return serviceNames;
- }
- /**
- *
- * @return
- */
- public List<EPR> findEPRs(String category, String serviceName) throws RegistryException, ServiceNotFoundException
- {
- List<EPR> eprs = new ArrayList<EPR>();
-
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-
- Service service = findService(category, serviceName);
- if (service==null){
- throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
- }
- // Get registry service and business query manager
- Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
- //Converting them to EPRs
- for (Iterator i=serviceBindings.iterator();i.hasNext();) {
- ServiceBinding serviceBinding = (ServiceBinding) i.next();
-
- Collection<String> findQualifiers = new ArrayList<String>();
- findQualifiers.add(FindQualifier.AND_ALL_KEYS);
- findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
- ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
- Classification classification = blm.createClassification(cScheme, "category", category);
-
- SpecificationLink sl = new SpecificationLinkImpl(blm);
- sl.setSpecificationObject(jbossTModel);
- serviceBinding.getSpecificationLinks().add(sl);
-
- @SuppressWarnings("unused")
- String eprXML = serviceBinding.getAccessURI();
- EPR epr = null;
- //for backwards compatibility still have the decoder if
- //unmarchalling fails
- try {
- epr = EPRHelper.fromXMLString(eprXML);
- eprs.add(epr);
- } catch (UnmarshalException unme) {
- try {
- eprXML = URLDecoder.decode(eprXML, "UTF-8");
- epr = EPRHelper.fromXMLString(eprXML);
- eprs.add(epr);
- } catch (UnsupportedEncodingException ue) {
- logger.error(ue.getMessage(), ue);
- throw new UnmarshalException(ue.getMessage(), ue);
- }
- }
- }
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- } catch (UnmarshalException me) {
- throw new RegistryException(me.getLocalizedMessage(), me);
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- return eprs;
- }
- /**
- *
- * @return
- */
- public EPR findEPR(String category, String serviceName) throws RegistryException, ServiceNotFoundException
- {
- EPR epr = null ;
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-
- Service service = findService(category, serviceName);
- if (service==null){
- throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
- }
- // Get registry service and business query manager
- Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
- if (serviceBindings.iterator().hasNext()) {
- ServiceBinding serviceBinding = (ServiceBinding) serviceBindings.iterator().next();
- SpecificationLink sl = new SpecificationLinkImpl(blm);
- sl.setSpecificationObject(jbossTModel);
- serviceBinding.getSpecificationLinks().add(sl);
-
- String eprXML = serviceBinding.getAccessURI();
- // for backwards compatibility still have the decoder if
- // unmarchalling fails
- try {
- epr = EPRHelper.fromXMLString(eprXML);
- } catch (UnmarshalException unme) {
- try {
- eprXML = URLDecoder.decode(eprXML, "UTF-8");
- epr = EPRHelper.fromXMLString(eprXML);
- } catch (UnsupportedEncodingException ue) {
- logger.error(ue.getMessage(), ue);
- throw new UnmarshalException(ue.getMessage(), ue);
- }
- }
- }
- } catch (JAXRException je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- } catch (UnmarshalException me) {
- throw new RegistryException(me.getLocalizedMessage(), me);
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
-
- return epr;
- }
-
- /**
- * Find all Organizations with a name mathing the queryString parameter.
- *
- * @param organizationName used to match with the name of the organization.
- * @return the Organization.
- */
- public static Organization findOrganization(String organizationName, JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException {
- if (organizationName==null) {
- organizationName="";
- }
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- // Get registry service and business query manager
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- // Define find qualifiers and name patterns
- Collection<String> findQualifiers = new ArrayList<String>();
- findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
- Collection<String> namePatterns = new ArrayList<String>();
- namePatterns.add("%" + organizationName + "%");
- //Find based upon qualifier type and values
- logger.log(Level.DEBUG,"Going to query the registry for name pattern " + namePatterns);
- BulkResponse response = bqm.findOrganizations(findQualifiers,
- namePatterns, null, null, null, null);
- if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
- for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();)
- {
- Organization org = (Organization) orgIter.next();
- logger.log(Level.DEBUG, "Organization name: " + org.getName().getValue());
- logger.log(Level.DEBUG, "Description: " + org.getDescription().getValue());
- logger.log(Level.DEBUG, "Key id: " + org.getKey().getId());
- User primaryContact = org.getPrimaryContact();
- logger.log(Level.DEBUG, "Primary Contact: " + primaryContact.getPersonName().getFullName());
- if (orgIter.hasNext()) {
- logger.log(Level.ERROR, "Found " + response.getCollection().size()
- + " Organization, while expecting only one of name " + organizationName);
- }
- return org;
- }
- }
- return null;
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
-
- /**
- *
- * @param category
- * @param serviceName
- * @return Service
- */
- protected Service findService(String category, String serviceName) throws JAXRException
- {
- if (category==null) {
- category="";
- }
- if (serviceName==null) {
- serviceName="";
- }
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- // Get registry service and business query manager
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- // Define find qualifiers and name patterns
- Collection<String> findQualifiers = new ArrayList<String>();
- findQualifiers.add(FindQualifier.AND_ALL_KEYS);
- findQualifiers.add(FindQualifier.EXACT_NAME_MATCH);
- findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
- ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
- Collection<Classification> classifications = new ArrayList<Classification>();
- // If the scheme returned null, then we have to create a org.jboss.soa.esb.:category scheme to use
- if (cScheme == null) {
- try {
- ClassificationScheme scheme = blm.createClassificationScheme(JBOSS_ESB_CATEGORY, JBOSS_ESB_CATEGORY);
- ArrayList<ClassificationScheme> cSchemes = new ArrayList<ClassificationScheme>();
- cSchemes.add(scheme);
- BulkResponse br = blm.saveClassificationSchemes(cSchemes);
- } catch (Exception e) {
- throw new JAXRException(e);
- }
- cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
- }
- Classification classification =
- blm.createClassification(
- cScheme,
- "category", category );
- classifications.add(classification);
- Collection<String> namePatterns = new ArrayList<String>();
- namePatterns.add(serviceName);
- //Find based upon qualifier type and values
- logger.log(Level.DEBUG, "Going to query the registry for name pattern " + namePatterns);
- BulkResponse response = bqm.findServices(null, findQualifiers,
- namePatterns, classifications, null);
- if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
- for (Iterator servIter = response.getCollection().iterator(); servIter.hasNext();)
- {
- Service service = (Service) servIter.next();
- logger.log(Level.DEBUG, "Service name: " + service.getName().getValue());
- if (service.getDescription()!=null) {
- logger.log(Level.DEBUG, "Description: " + service.getDescription().getValue());
- }
- logger.log(Level.DEBUG, "Key id: " + service.getKey().getId());
- if (servIter.hasNext()) {
- logger.log(Level.ERROR, "Found " + response.getCollection().size()
- + " Services, while expecting only one by the name of "
- + serviceName + " in category " + category);
- }
- return service;
- }
- }
- return null;
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
-
- /**
- * Finds all services for a given category.
- * @param category
- * @return Service
- */
- @SuppressWarnings("unchecked")
- protected Collection<Service> findServicesForCategory(String category) throws JAXRException
- {
- Collection<Service> services = new ArrayList<Service>();
- if (category==null) {
- category="";
- }
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- // Get registry service and business query manager
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- Collection<String> findQualifiers = new ArrayList<String>();
- findQualifiers.add(FindQualifier.AND_ALL_KEYS);
- findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
- ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
- //Create classification
- Classification classification =
- blm.createClassification(
- cScheme,
- "category", category );
-
- // Define find qualifiers and name patterns
- //Collection<String> findQualifiers = new ArrayList<String>();
- //findQualifiers.add(FindQualifier.AND_ALL_KEYS);
- findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
- Collection<Classification> classifications = new ArrayList<Classification>();
- classifications.add(classification);
- //Find based upon qualifier type and values
- logger.log(Level.DEBUG, "Going to query the registry for classification " + classifications);
- BulkResponse response = bqm.findServices(null, findQualifiers,
- null, classifications, null);
- if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
- services = (Collection<Service>) response.getCollection();
- }
- return services;
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
-
- /**
- * Finds all services for the organization.
- */
- @SuppressWarnings("unchecked")
- protected Collection<Service> findServices() throws JAXRException
- {
- Collection<Service> services = new ArrayList<Service>();
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- // Get registry service and business query manager
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- //Find based upon qualifier type and values
- logger.log(Level.DEBUG, "Going to query the registry for services");
- BulkResponse response = bqm.findServices(getJBossESBOrganization().getKey(),
- null, null, null, null);
- if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
- services = (Collection<Service>) response.getCollection();
- }
- return services;
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
-
- /**
- * Create a jbossesb organization under which we will register all our services.
- *
- * @return
- * @throws JAXRException
- */
- protected static Organization createJBossESBOrganization(JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException
- {
-// Getting the connection to the Registry (reading config)
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- //Logging in
- RegistryService rs = connection.getRegistryService();
- //Building organization
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- Organization organization = blm.createOrganization(blm.createInternationalString("Red Hat/JBossESB"));
- organization.setDescription(blm.createInternationalString("Red Hat/JBoss Professional Open Source, Services for the JBossESB"));
-
- User user = blm.createUser();
- organization.setPrimaryContact(user);
- PersonName personName = blm.createPersonName("JBossESB");
- TelephoneNumber telephoneNumber = blm.createTelephoneNumber();
- telephoneNumber.setNumber("404 467-8555");
- telephoneNumber.setType(null);
- PostalAddress address = blm.createPostalAddress("3340",
- "Peachtree Road, NE, Suite 1200", "Atlanta", "GA", "USA",
- "30326", "");
- Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>();
- postalAddresses.add(address);
- Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
- EmailAddress emailAddress = blm
- .createEmailAddress("jbossesb at jboss.com");
- emailAddresses.add(emailAddress);
-
- Collection<TelephoneNumber> numbers = new ArrayList<TelephoneNumber>();
- numbers.add(telephoneNumber);
- user.setPersonName(personName);
- user.setPostalAddresses(postalAddresses);
- user.setEmailAddresses(emailAddresses);
- user.setTelephoneNumbers(numbers);
-
- // Scout does not support this (yet), so leaving it out for now.
- // ClassificationScheme cScheme = getClassificationScheme(blm,
- // blm.createInternationalString("uddi-org:general_keywords"), blm.createInternationalString(""));
- // Classification classification = blm.createClassification(cScheme,
- // blm.createInternationalString("JBoss ESB"), blm.createInternationalString("JBESB"));
- // org.addClassification(classification);
-
- saveRegistryObject(organization, jaxrConnectionFactory);
- return organization;
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
-
- /**
- * Create a jbossesb organization under which we will register all our services.
- *
- * @return
- * @throws JAXRException
- */
- protected static Concept getJBossESBTModel(JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException
- {
- Connection connection = jaxrConnectionFactory.getConnection();
- Concept tmodel = null;
- try {
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-
- Collection<String> findQualifiers = new ArrayList<String>();
- findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
- Collection<String> namePatterns = new ArrayList<String>();
- namePatterns.add("%" + JBOSS_ESB_CATEGORY + "%");
-
- BulkResponse response = bqm.findConcepts(findQualifiers, namePatterns, null, null, null);
- if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
- Collection<RegistryObject> regs = (Collection<RegistryObject>) response.getCollection();
- for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();)
- {
- tmodel = (Concept) orgIter.next();
- }
- }
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- return tmodel;
- }
-
-
- /**
- * Save Registry Object
- */
- private static void saveRegistryObject(RegistryObject registryObject, JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException
- {
-// Getting the connection to the Registry (reading config)
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
-
- BulkResponse br = null;
- //Logging in
- RegistryService rs = connection.getRegistryService();
- //Building organization
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-
- Class[] interfaces = registryObject.getClass().getInterfaces();
- String interfaceName ="";
- for (int i=0; i<interfaces.length; i++) {
- interfaceName = interfaces[i].getName();
- if (interfaceName.equals("javax.xml.registry.infomodel.Organization")) {
- Collection<Organization> orginations = new ArrayList<Organization>();
- orginations.add((Organization) registryObject);
- br = blm.saveOrganizations(orginations);
- break;
- } else if (interfaceName.equals("javax.xml.registry.infomodel.Service")) {
- Collection<Service> services = new ArrayList<Service>();
- services.add((Service) registryObject);
- br = blm.saveServices(services);
- break;
- } else if (interfaceName.equals("javax.xml.registry.infomodel.ServiceBinding")) {
- Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
- serviceBindings.add((ServiceBinding) registryObject);
- br = blm.saveServiceBindings(serviceBindings);
- break;
- } else {
- logger.log(Level.ERROR, "Trying to save an unsupported RegistryObject");
- throw new JAXRException("Trying to save an unsupported RegistryObject");
- }
- }
- //Verify the return
- if (br!=null && br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
- logger.log(Level.DEBUG, interfaceName + " successfully saved");
- Collection coll = br.getCollection();
- Iterator iter = coll.iterator();
- while (iter.hasNext()) {
- Key key = (Key) iter.next();
- registryObject.setKey(key);
- logger.log(Level.DEBUG, "Saved Key=" + key.getId());
- }
- } else {
- logger.log(Level.ERROR, "Errors occurred during save.");
- if (br!=null) {
- Collection exceptions = br.getExceptions();
- Iterator iter = exceptions.iterator();
- String errors = "";
- JAXRException je = new JAXRException("JAXRExceptions occurred during save");
- while (iter.hasNext()) {
- Exception e = (Exception) iter.next();
- errors += e.getLocalizedMessage() + "\n";
- je.setStackTrace(e.getStackTrace());
- logger.log(Level.ERROR, e.getLocalizedMessage(), e);
- //if it's the last error, throw it now and set the current stacktrace
- if (!iter.hasNext()) {
- throw new JAXRException(errors, e);
- }
- }
- throw new JAXRException("Errors occurred during save. Response status=" + br.getStatus());
- }
- throw new JAXRException("Errors occurred during save");
- }
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
-
- /**
- * finds the JBossESB Organizationa and creates one if it is not there.
- * Note, there are no services associated with this information.
- *
- * @return JBossESB Organization
- * @throws JAXRException
- */
- private synchronized Organization getJBossESBOrganization() throws JAXRException
- {
-
- if (jbossESBOrganization==null) {
- jbossESBOrganization = findOrganization("Red Hat/JBossESB", jaxrConnectionFactory);
- if (jbossESBOrganization==null) {
- jbossESBOrganization = createJBossESBOrganization(jaxrConnectionFactory);
- }
- }
-
- return jbossESBOrganization;
- }
-
- /**
- * Find the ServiceBindings for a given Service
- * @param service
- * @return
- * @throws RegistryException
- */
- @SuppressWarnings("unchecked")
- private Collection<ServiceBinding> findServiceBindings(Service service) throws RegistryException
- {
- if (jbossTModel == null) {
- try {
- jbossTModel = getJBossESBTModel(jaxrConnectionFactory);
- } catch (JAXRException je) {
- throw new RegistryException();
- }
- }
-
- Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
- Connection connection = jaxrConnectionFactory.getConnection();
- try {
- RegistryService rs = connection.getRegistryService();
- BusinessQueryManager bqm = rs.getBusinessQueryManager();
- BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
- Collection<String> findQualifiers = null;
- //Collection<String> findQualifiers = new ArrayList<String>();
- //findQualifiers.add(FindQualifier.SORT_BY_DATE_ASC);
- ArrayList<SpecificationLink> specs = new ArrayList<SpecificationLink>();
- SpecificationLink sl = new SpecificationLinkImpl(blm);
- sl.setSpecificationObject(jbossTModel);
-
- specs.add(sl);
- BulkResponse bulkResponse = bqm.findServiceBindings(service.getKey(),findQualifiers,null,specs);
- if (bulkResponse.getStatus()==JAXRResponse.STATUS_SUCCESS){
- serviceBindings = (Collection<ServiceBinding>)bulkResponse.getCollection();
- for (Iterator bindIter = serviceBindings.iterator(); bindIter.hasNext();)
- {
- ServiceBinding binding = (ServiceBinding) bindIter.next();
- SpecificationLink speclink = new SpecificationLinkImpl(blm);
- speclink.setSpecificationObject(jbossTModel);
- binding.getSpecificationLinks().add(speclink);
- }
- }
- return serviceBindings;
- } catch (Exception je) {
- throw new RegistryException(je.getLocalizedMessage(), je);
- } finally {
- jaxrConnectionFactory.closeConnection(connection);
- }
- }
-}
-
-
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,825 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.internal.soa.esb.services.registry;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.registry.BulkResponse;
+import javax.xml.registry.BusinessLifeCycleManager;
+import javax.xml.registry.BusinessQueryManager;
+import javax.xml.registry.Connection;
+import javax.xml.registry.FindQualifier;
+import javax.xml.registry.JAXRException;
+import javax.xml.registry.JAXRResponse;
+import javax.xml.registry.RegistryService;
+import javax.xml.registry.infomodel.Classification;
+import javax.xml.registry.infomodel.ClassificationScheme;
+import javax.xml.registry.infomodel.Concept;
+import javax.xml.registry.infomodel.EmailAddress;
+import javax.xml.registry.infomodel.Key;
+import javax.xml.registry.infomodel.Organization;
+import javax.xml.registry.infomodel.PersonName;
+import javax.xml.registry.infomodel.PostalAddress;
+import javax.xml.registry.infomodel.RegistryObject;
+import javax.xml.registry.infomodel.Service;
+import javax.xml.registry.infomodel.ServiceBinding;
+import javax.xml.registry.infomodel.SpecificationLink;
+import javax.xml.registry.infomodel.TelephoneNumber;
+import javax.xml.registry.infomodel.User;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.ws.scout.registry.infomodel.KeyImpl;
+import org.apache.ws.scout.registry.infomodel.SpecificationLinkImpl;
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.services.registry.Registry;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
+/**
+ * Utility class for the Registry.
+ * If need be we can extract the interface from here, add a factory and have JAXR as a plugin, allowing
+ * for other RegistryAPIs.
+ *
+ * @author Kurt Stam
+ */
+public class JAXRRegistryImpl implements Registry
+{
+ private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
+ private JAXRConnectionFactory jaxrConnectionFactory;
+ private Organization jbossESBOrganization;
+ private ClassificationScheme jbossESBScheme;
+ private static Concept jbossTModel;
+ public static final String JBOSS_ESB_CATEGORY = "org.jboss.soa.esb.:category";
+
+ public JAXRRegistryImpl() throws ConfigurationException {
+ jaxrConnectionFactory = new JAXRConnectionFactory();
+ }
+
+ /**
+ * Publish an EPR to the Registry
+ */
+ protected Service registerService(String category, String serviceName, String serviceDescription) throws JAXRException
+ {
+ Service service =null;
+ Organization organization = getJBossESBOrganization();
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ //Adding the category as prefix for the name
+ service = blm.createService(blm.createInternationalString(serviceName));
+ service.setDescription(blm.createInternationalString(serviceDescription));
+ ClassificationScheme cScheme = getClassificationScheme(bqm, blm);
+ Classification classification = blm.createClassification(cScheme, "category", category);
+ service.addClassification(classification);
+ service.setProvidingOrganization(organization);
+ saveRegistryObject(service, jaxrConnectionFactory);
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ return service;
+ }
+ /**
+ * Remove an EPR from the Registry
+ */
+ @SuppressWarnings("unchecked")
+ public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException{
+ // first find the ServiceBindings for this service
+ Connection connection = jaxrConnectionFactory.getConnection();
+ Service service = null;
+ try {
+ service = findService(category, serviceName);
+ if (service==null) {
+ throw new ServiceNotFoundException("No such EPR found for service with name = " + serviceName);
+ }
+ RegistryService rs = connection.getRegistryService();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ Collection<Key> serviceKeys = new ArrayList<Key>();
+ serviceKeys.add(service.getKey());
+ blm.deleteServices(serviceKeys);
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
+ /**
+ * Publish an EPR to the Registry
+ */
+ public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription)
+ throws RegistryException
+ {
+ Connection connection = jaxrConnectionFactory.getConnection();
+ if (jbossTModel == null) {
+ try {
+ jbossTModel = getJBossESBTModel(jaxrConnectionFactory);
+ } catch (JAXRException je) {
+ throw new RegistryException();
+ }
+ }
+
+ try {
+ //Find the service
+ Service service = findService(category,serviceName);
+ if (service==null) {
+ logger.log(Level.DEBUG, "Service " + serviceName + " does not yet exist, creating now..");
+ service = registerService(category, serviceName, serviceDescription);
+ }
+
+ RegistryService rs = connection.getRegistryService();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ ServiceBinding serviceBinding = blm.createServiceBinding();
+ String xml = EPRHelper.toXMLString(epr);
+ serviceBinding.setAccessURI(xml);
+
+ ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
+ SpecificationLink sl = new SpecificationLinkImpl(blm);
+ sl.setSpecificationObject(jbossTModel);
+ serviceBinding.getSpecificationLinks().add(sl);
+ serviceBinding.setDescription(blm.createInternationalString(eprDescription));
+ serviceBindings.add(serviceBinding);
+
+ service.addServiceBindings(serviceBindings);
+ ClassificationScheme cScheme = getClassificationScheme(bqm, blm);
+ Classification classification = blm.createClassification(cScheme, "category", category);
+ service.addClassification(classification);
+
+ saveRegistryObject(serviceBinding, jaxrConnectionFactory);
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ } catch (MarshalException me) {
+ throw new RegistryException(me.getLocalizedMessage(), me);
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
+ /**
+ * Remove an EPR from the Registry
+ */
+ public void unRegisterEPR(String category, String serviceName, EPR toBeDeletedEPR) throws RegistryException, ServiceNotFoundException{
+ //first find the ServiceBindings for this service
+ Connection connection = jaxrConnectionFactory.getConnection();
+ Service service = null;
+ try {
+ service = findService(category, serviceName);
+ if (service==null) {
+ throw new ServiceNotFoundException("No such Service found for service with category= "
+ + category + " and name = " + serviceName);
+ }
+ Collection serviceBindings = findServiceBindings(service);
+ String toBeDeletedEPRXml = EPRHelper.toXMLString(toBeDeletedEPR).trim();
+ for (Iterator i=serviceBindings.iterator();i.hasNext();){
+ ServiceBinding serviceBinding = (ServiceBinding) i.next();
+ String eprXML = serviceBinding.getAccessURI().trim();
+ // for backwards compatibility still have the decoder if
+ // unmarchalling fails
+ try {
+ EPR epr = EPRHelper.fromXMLString(eprXML);
+ } catch (UnmarshalException unme) {
+ try {
+ eprXML = URLDecoder.decode(eprXML, "UTF-8").trim();
+ } catch (UnsupportedEncodingException ue) {
+ logger.error(unme.getMessage(), unme);
+ logger.error(ue.getMessage(), ue);
+ }
+ }
+ if (eprXML.equals(toBeDeletedEPRXml)) {
+ RegistryService rs = connection.getRegistryService();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ Collection<Key> serviceBindingKeys = new ArrayList<Key>();
+ serviceBindingKeys.add(serviceBinding.getKey());
+ blm.deleteServiceBindings(serviceBindingKeys);
+ return;
+ }
+ }
+ throw new RegistryException("No such EPR found for service with name = "
+ + serviceName + " and EPR=" + toBeDeletedEPR);
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ } catch (MarshalException me) {
+ throw new RegistryException(me.getLocalizedMessage(), me);
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @return collection services
+ */
+ public List<String> findAllServices() throws RegistryException
+ {
+ List<String> serviceNames = new ArrayList<String>();
+ try {
+ Collection<Service> services = findServices();
+ for (Service service: services) {
+ String serviceName = service.getName().getValue();
+ serviceNames.add(serviceName);
+ }
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ }
+ return serviceNames;
+ }
+ /**
+ * Find Services based on a category ("transformation").
+ *
+ * @return collection services
+ */
+ public List<String> findServices(String category) throws RegistryException
+ {
+ List<String>serviceNames = new ArrayList<String>();
+
+ try {
+ Collection<Service>services = findServicesForCategory(category);
+ for (Iterator<Service> i=services.iterator();i.hasNext();) {
+ String serviceName = i.next().getName().getValue();
+ serviceNames.add(serviceName);
+ }
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ }
+ return serviceNames;
+ }
+ /**
+ *
+ * @return
+ */
+ public List<EPR> findEPRs(String category, String serviceName) throws RegistryException, ServiceNotFoundException
+ {
+ List<EPR> eprs = new ArrayList<EPR>();
+
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+
+ Service service = findService(category, serviceName);
+ if (service==null){
+ throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
+ }
+ // Get registry service and business query manager
+ Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
+ //Converting them to EPRs
+ for (Iterator i=serviceBindings.iterator();i.hasNext();) {
+ ServiceBinding serviceBinding = (ServiceBinding) i.next();
+
+ String eprXML = serviceBinding.getAccessURI();
+ EPR epr = null;
+ //for backwards compatibility still have the decoder if
+ //unmarchalling fails
+ try {
+ epr = EPRHelper.fromXMLString(eprXML);
+ eprs.add(epr);
+ } catch (UnmarshalException unme) {
+ try {
+ eprXML = URLDecoder.decode(eprXML, "UTF-8");
+ epr = EPRHelper.fromXMLString(eprXML);
+ eprs.add(epr);
+ } catch (UnsupportedEncodingException ue) {
+ logger.error(ue.getMessage(), ue);
+ throw new UnmarshalException(ue.getMessage(), ue);
+ }
+ }
+ }
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ } catch (UnmarshalException me) {
+ throw new RegistryException(me.getLocalizedMessage(), me);
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ return eprs;
+ }
+ /**
+ *
+ * @return
+ */
+ public EPR findEPR(String category, String serviceName) throws RegistryException, ServiceNotFoundException
+ {
+ EPR epr = null ;
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+
+ Service service = findService(category, serviceName);
+ if (service==null){
+ throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
+ }
+ // Get registry service and business query manager
+ Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
+ if (serviceBindings.iterator().hasNext()) {
+ ServiceBinding serviceBinding = (ServiceBinding) serviceBindings.iterator().next();
+
+ String eprXML = serviceBinding.getAccessURI();
+ // for backwards compatibility still have the decoder if
+ // unmarchalling fails
+ try {
+ epr = EPRHelper.fromXMLString(eprXML);
+ } catch (UnmarshalException unme) {
+ try {
+ eprXML = URLDecoder.decode(eprXML, "UTF-8");
+ epr = EPRHelper.fromXMLString(eprXML);
+ } catch (UnsupportedEncodingException ue) {
+ logger.error(ue.getMessage(), ue);
+ throw new UnmarshalException(ue.getMessage(), ue);
+ }
+ }
+ }
+ } catch (JAXRException je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ } catch (UnmarshalException me) {
+ throw new RegistryException(me.getLocalizedMessage(), me);
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+
+ return epr;
+ }
+
+ /**
+ * Find all Organizations with a name mathing the queryString parameter.
+ *
+ * @param organizationName used to match with the name of the organization.
+ * @return the Organization.
+ */
+ public static Organization findOrganization(String organizationName, JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException {
+ if (organizationName==null) {
+ organizationName="";
+ }
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ // Get registry service and business query manager
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ // Define find qualifiers and name patterns
+ Collection<String> findQualifiers = new ArrayList<String>();
+ findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
+ Collection<String> namePatterns = new ArrayList<String>();
+ namePatterns.add("%" + organizationName + "%");
+ //Find based upon qualifier type and values
+ logger.log(Level.DEBUG,"Going to query the registry for name pattern " + namePatterns);
+ BulkResponse response = bqm.findOrganizations(findQualifiers,
+ namePatterns, null, null, null, null);
+ if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+ for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();)
+ {
+ Organization org = (Organization) orgIter.next();
+ logger.log(Level.DEBUG, "Organization name: " + org.getName().getValue());
+ logger.log(Level.DEBUG, "Description: " + org.getDescription().getValue());
+ logger.log(Level.DEBUG, "Key id: " + org.getKey().getId());
+ User primaryContact = org.getPrimaryContact();
+ logger.log(Level.DEBUG, "Primary Contact: " + primaryContact.getPersonName().getFullName());
+ if (orgIter.hasNext()) {
+ logger.log(Level.ERROR, "Found " + response.getCollection().size()
+ + " Organization, while expecting only one of name " + organizationName);
+ }
+ return org;
+ }
+ }
+ return null;
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
+
+ /**
+ *
+ * @param category
+ * @param serviceName
+ * @return Service
+ */
+ protected Service findService(String category, String serviceName) throws JAXRException
+ {
+ if (category==null) {
+ category="";
+ }
+ if (serviceName==null) {
+ serviceName="";
+ }
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ // Get registry service and business query manager
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ final ClassificationScheme cScheme = getClassificationScheme(bqm, blm) ;
+ Collection<Classification> classifications = new ArrayList<Classification>();
+ Classification classification =
+ blm.createClassification(
+ cScheme,
+ "category", category );
+ classifications.add(classification);
+ Collection<String> namePatterns = new ArrayList<String>();
+ namePatterns.add(serviceName);
+ //Find based upon qualifier type and values
+ Collection<String> findQualifiers = new ArrayList<String>();
+ findQualifiers.add(FindQualifier.AND_ALL_KEYS);
+ findQualifiers.add(FindQualifier.EXACT_NAME_MATCH);
+ findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
+ logger.log(Level.DEBUG, "Going to query the registry for name pattern " + namePatterns);
+ BulkResponse response = bqm.findServices(null, findQualifiers,
+ namePatterns, classifications, null);
+ if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+ for (Iterator servIter = response.getCollection().iterator(); servIter.hasNext();)
+ {
+ Service service = (Service) servIter.next();
+ logger.log(Level.DEBUG, "Service name: " + service.getName().getValue());
+ if (service.getDescription()!=null) {
+ logger.log(Level.DEBUG, "Description: " + service.getDescription().getValue());
+ }
+ logger.log(Level.DEBUG, "Key id: " + service.getKey().getId());
+ if (servIter.hasNext()) {
+ logger.log(Level.ERROR, "Found " + response.getCollection().size()
+ + " Services, while expecting only one by the name of "
+ + serviceName + " in category " + category);
+ }
+ return service;
+ }
+ }
+ return null;
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
+
+ /**
+ * Finds all services for a given category.
+ * @param category
+ * @return Service
+ */
+ @SuppressWarnings("unchecked")
+ protected Collection<Service> findServicesForCategory(String category) throws JAXRException
+ {
+ Collection<Service> services = new ArrayList<Service>();
+ if (category==null) {
+ category="";
+ }
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ // Get registry service and business query manager
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ ClassificationScheme cScheme = getClassificationScheme(bqm, blm);
+ //Create classification
+ Classification classification =
+ blm.createClassification(
+ cScheme,
+ "category", category );
+
+ // Define find qualifiers and name patterns
+ Collection<String> findQualifiers = new ArrayList<String>();
+ findQualifiers.add(FindQualifier.AND_ALL_KEYS);
+ findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
+ Collection<Classification> classifications = new ArrayList<Classification>();
+ classifications.add(classification);
+ //Find based upon qualifier type and values
+ logger.log(Level.DEBUG, "Going to query the registry for classification " + classifications);
+ BulkResponse response = bqm.findServices(null, findQualifiers,
+ null, classifications, null);
+ if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+ services = (Collection<Service>) response.getCollection();
+ }
+ return services;
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
+
+ /**
+ * Finds all services for the organization.
+ */
+ @SuppressWarnings("unchecked")
+ protected Collection<Service> findServices() throws JAXRException
+ {
+ Collection<Service> services = new ArrayList<Service>();
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ // Get registry service and business query manager
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ //Find based upon qualifier type and values
+ logger.log(Level.DEBUG, "Going to query the registry for services");
+ BulkResponse response = bqm.findServices(getJBossESBOrganization().getKey(),
+ null, null, null, null);
+ if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+ services = (Collection<Service>) response.getCollection();
+ }
+ return services;
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
+
+ /**
+ * Create a jbossesb organization under which we will register all our services.
+ *
+ * @return
+ * @throws JAXRException
+ */
+ protected static Organization createJBossESBOrganization(JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException
+ {
+// Getting the connection to the Registry (reading config)
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ //Logging in
+ RegistryService rs = connection.getRegistryService();
+ //Building organization
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ Organization organization = blm.createOrganization(blm.createInternationalString("Red Hat/JBossESB"));
+ organization.setDescription(blm.createInternationalString("Red Hat/JBoss Professional Open Source, Services for the JBossESB"));
+
+ User user = blm.createUser();
+ organization.setPrimaryContact(user);
+ PersonName personName = blm.createPersonName("JBossESB");
+ TelephoneNumber telephoneNumber = blm.createTelephoneNumber();
+ telephoneNumber.setNumber("404 467-8555");
+ telephoneNumber.setType(null);
+ PostalAddress address = blm.createPostalAddress("3340",
+ "Peachtree Road, NE, Suite 1200", "Atlanta", "GA", "USA",
+ "30326", "");
+ Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>();
+ postalAddresses.add(address);
+ Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
+ EmailAddress emailAddress = blm
+ .createEmailAddress("jbossesb at jboss.com");
+ emailAddresses.add(emailAddress);
+
+ Collection<TelephoneNumber> numbers = new ArrayList<TelephoneNumber>();
+ numbers.add(telephoneNumber);
+ user.setPersonName(personName);
+ user.setPostalAddresses(postalAddresses);
+ user.setEmailAddresses(emailAddresses);
+ user.setTelephoneNumbers(numbers);
+
+ // Scout does not support this (yet), so leaving it out for now.
+ // ClassificationScheme cScheme = getClassificationScheme(blm,
+ // blm.createInternationalString("uddi-org:general_keywords"), blm.createInternationalString(""));
+ // Classification classification = blm.createClassification(cScheme,
+ // blm.createInternationalString("JBoss ESB"), blm.createInternationalString("JBESB"));
+ // org.addClassification(classification);
+
+ saveRegistryObject(organization, jaxrConnectionFactory);
+ return organization;
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
+
+ /**
+ * Create a jbossesb organization under which we will register all our services.
+ *
+ * @return
+ * @throws JAXRException
+ */
+ protected static Concept getJBossESBTModel(JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException
+ {
+ Connection connection = jaxrConnectionFactory.getConnection();
+ Concept tmodel = null;
+ try {
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+
+ Collection<String> findQualifiers = new ArrayList<String>();
+ findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
+ Collection<String> namePatterns = new ArrayList<String>();
+ namePatterns.add("%" + JBOSS_ESB_CATEGORY + "%");
+
+ BulkResponse response = bqm.findConcepts(findQualifiers, namePatterns, null, null, null);
+ if (response.getStatus()==JAXRResponse.STATUS_SUCCESS) {
+ Collection<RegistryObject> regs = (Collection<RegistryObject>) response.getCollection();
+ for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();)
+ {
+ tmodel = (Concept) orgIter.next();
+ }
+ }
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ return tmodel;
+ }
+
+
+ /**
+ * Save Registry Object
+ */
+ private static void saveRegistryObject(RegistryObject registryObject, JAXRConnectionFactory jaxrConnectionFactory) throws JAXRException
+ {
+// Getting the connection to the Registry (reading config)
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+
+ BulkResponse br = null;
+ //Logging in
+ RegistryService rs = connection.getRegistryService();
+ //Building organization
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+
+ Class[] interfaces = registryObject.getClass().getInterfaces();
+ String interfaceName ="";
+ for (int i=0; i<interfaces.length; i++) {
+ interfaceName = interfaces[i].getName();
+ if (interfaceName.equals("javax.xml.registry.infomodel.Organization")) {
+ Collection<Organization> orginations = new ArrayList<Organization>();
+ orginations.add((Organization) registryObject);
+ br = blm.saveOrganizations(orginations);
+ break;
+ } else if (interfaceName.equals("javax.xml.registry.infomodel.Service")) {
+ Collection<Service> services = new ArrayList<Service>();
+ services.add((Service) registryObject);
+ br = blm.saveServices(services);
+ break;
+ } else if (interfaceName.equals("javax.xml.registry.infomodel.ServiceBinding")) {
+ Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
+ serviceBindings.add((ServiceBinding) registryObject);
+ br = blm.saveServiceBindings(serviceBindings);
+ break;
+ } else {
+ logger.log(Level.ERROR, "Trying to save an unsupported RegistryObject");
+ throw new JAXRException("Trying to save an unsupported RegistryObject");
+ }
+ }
+ //Verify the return
+ if (br!=null && br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
+ logger.log(Level.DEBUG, interfaceName + " successfully saved");
+ Collection coll = br.getCollection();
+ Iterator iter = coll.iterator();
+ while (iter.hasNext()) {
+ Key key = (Key) iter.next();
+ registryObject.setKey(key);
+ logger.log(Level.DEBUG, "Saved Key=" + key.getId());
+ }
+ } else {
+ logger.log(Level.ERROR, "Errors occurred during save.");
+ if (br!=null) {
+ Collection exceptions = br.getExceptions();
+ Iterator iter = exceptions.iterator();
+ String errors = "";
+ JAXRException je = new JAXRException("JAXRExceptions occurred during save");
+ while (iter.hasNext()) {
+ Exception e = (Exception) iter.next();
+ errors += e.getLocalizedMessage() + "\n";
+ je.setStackTrace(e.getStackTrace());
+ logger.log(Level.ERROR, e.getLocalizedMessage(), e);
+ //if it's the last error, throw it now and set the current stacktrace
+ if (!iter.hasNext()) {
+ throw new JAXRException(errors, e);
+ }
+ }
+ throw new JAXRException("Errors occurred during save. Response status=" + br.getStatus());
+ }
+ throw new JAXRException("Errors occurred during save");
+ }
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
+
+ /**
+ * finds the JBossESB Organizationa and creates one if it is not there.
+ * Note, there are no services associated with this information.
+ *
+ * @return JBossESB Organization
+ * @throws JAXRException
+ */
+ private synchronized Organization getJBossESBOrganization() throws JAXRException
+ {
+
+ if (jbossESBOrganization==null) {
+ jbossESBOrganization = findOrganization("Red Hat/JBossESB", jaxrConnectionFactory);
+ if (jbossESBOrganization==null) {
+ jbossESBOrganization = createJBossESBOrganization(jaxrConnectionFactory);
+ }
+ }
+
+ return jbossESBOrganization;
+ }
+
+ /**
+ * finds the JBossESB category classification scheme and creates one if it is not there.
+ *
+ * @return JBossESB category classification scheme
+ * @throws JAXRException For errors during querying/creating.
+ */
+ private synchronized ClassificationScheme getClassificationScheme(final BusinessQueryManager bqm, final BusinessLifeCycleManager blm) throws JAXRException
+ {
+ if (jbossESBScheme == null) {
+ // Define find qualifiers and name patterns
+ Collection<String> findQualifiers = new ArrayList<String>();
+ findQualifiers.add(FindQualifier.AND_ALL_KEYS);
+ findQualifiers.add(FindQualifier.EXACT_NAME_MATCH);
+ findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
+ ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
+ // If the scheme returned null, then we have to create a org.jboss.soa.esb.:category scheme to use
+ if (cScheme == null) {
+ try {
+ ClassificationScheme scheme = blm.createClassificationScheme(JBOSS_ESB_CATEGORY, JBOSS_ESB_CATEGORY);
+ ArrayList<ClassificationScheme> cSchemes = new ArrayList<ClassificationScheme>();
+ cSchemes.add(scheme);
+ BulkResponse br = blm.saveClassificationSchemes(cSchemes);
+ } catch (Exception e) {
+ throw new JAXRException(e);
+ }
+ cScheme = bqm.findClassificationSchemeByName(findQualifiers, JBOSS_ESB_CATEGORY);
+ }
+ jbossESBScheme = cScheme ;
+ }
+ return jbossESBScheme ;
+ }
+
+ /**
+ * Find the ServiceBindings for a given Service
+ * @param service
+ * @return
+ * @throws RegistryException
+ */
+ @SuppressWarnings("unchecked")
+ private Collection<ServiceBinding> findServiceBindings(Service service) throws RegistryException
+ {
+ final Collection currentBindings ;
+ try {
+ currentBindings = service.getServiceBindings() ;
+ } catch (final JAXRException jaxre) {
+ throw new RegistryException(jaxre.getLocalizedMessage(), jaxre);
+ }
+ if ((currentBindings != null) && (currentBindings.size() > 0)) {
+ return currentBindings;
+ }
+ if (jbossTModel == null) {
+ try {
+ jbossTModel = getJBossESBTModel(jaxrConnectionFactory);
+ } catch (JAXRException je) {
+ throw new RegistryException();
+ }
+ }
+
+ Collection<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
+ Connection connection = jaxrConnectionFactory.getConnection();
+ try {
+ RegistryService rs = connection.getRegistryService();
+ BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+ Collection<String> findQualifiers = null;
+ //Collection<String> findQualifiers = new ArrayList<String>();
+ //findQualifiers.add(FindQualifier.SORT_BY_DATE_ASC);
+ ArrayList<SpecificationLink> specs = new ArrayList<SpecificationLink>();
+ SpecificationLink sl = new SpecificationLinkImpl(blm);
+ sl.setSpecificationObject(jbossTModel);
+
+ specs.add(sl);
+ BulkResponse bulkResponse = bqm.findServiceBindings(service.getKey(),findQualifiers,null,specs);
+ if (bulkResponse.getStatus()==JAXRResponse.STATUS_SUCCESS){
+ serviceBindings = (Collection<ServiceBinding>)bulkResponse.getCollection();
+ for (Iterator bindIter = serviceBindings.iterator(); bindIter.hasNext();)
+ {
+ ServiceBinding binding = (ServiceBinding) bindIter.next();
+ SpecificationLink speclink = new SpecificationLinkImpl(blm);
+ speclink.setSpecificationObject(jbossTModel);
+ binding.getSpecificationLinks().add(speclink);
+ }
+ }
+ return serviceBindings;
+ } catch (Exception je) {
+ throw new RegistryException(je.getLocalizedMessage(), je);
+ } finally {
+ jaxrConnectionFactory.closeConnection(connection);
+ }
+ }
+}
+
+
Modified: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -30,6 +30,8 @@
import javax.naming.NamingException;
import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.rosetta.pooling.handlers.JBossMessagingConnectionExceptionHandler;
+import org.jboss.internal.soa.esb.rosetta.pooling.handlers.WMQConnectionExceptionHandler;
import org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.helpers.KeyValuePair;
@@ -450,6 +452,17 @@
}
}
+ /**
+ * Get the JMS Connection Exception Handler class names
+ * @return JMS Connection Exception Handler class names.
+ */
+ public static String getJMSConnectionExceptionHandlers()
+ {
+ // If nothing is specified then we default to the InVM interceptor
+ return ModulePropertyManager.getPropertyManager(ModulePropertyManager.TRANSPORTS_MODULE).getProperty(Environment.JMS_CONNECTION_EXCEPTION_HANDLERS,
+ JBossMessagingConnectionExceptionHandler.class.getName() + ", " + WMQConnectionExceptionHandler.class.getName());
+ }
+
/**
* The SecurityService Implememtation Class
*
Modified: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/soa/esb/common/Environment.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/src/org/jboss/soa/esb/common/Environment.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/src/org/jboss/soa/esb/common/Environment.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -56,6 +56,7 @@
public static final String JMS_CONNECTION_POOL_SIZE = "org.jboss.soa.esb.jms.connectionPool";
public static final String JMS_SESSION_SLEEP = "org.jboss.soa.esb.jms.sessionSleep";
+ public static final String JMS_CONNECTION_EXCEPTION_HANDLERS = "org.jboss.soa.esb.jms.connectionExceptionHandlers";
public static final String WS_RETURN_STACK_TRACE = "org.jboss.soa.esb.ws.returnStackTrace";
public static final String WS_TIMEOUT = "org.jboss.soa.esb.ws.timeout" ;
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolUnitTest.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolUnitTest.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolUnitTest.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,664 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.internal.soa.esb.rosetta.pooling;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicSubscriber;
-import javax.jms.XAConnection;
-import javax.jms.XAConnectionFactory;
-import javax.jms.XASession;
-import javax.naming.Context;
-import javax.transaction.Synchronization;
-import javax.transaction.xa.XAResource;
-
-import junit.framework.Assert;
-import junit.framework.JUnit4TestAdapter;
-
-import org.jboss.soa.esb.addressing.eprs.JMSEpr;
-import org.jboss.soa.esb.common.Environment;
-import org.jboss.soa.esb.common.TransactionStrategy;
-import org.jboss.soa.esb.common.TransactionStrategyException;
-import org.jboss.soa.esb.common.TransactionStrategy.NullTransactionStrategy;
-import org.jboss.soa.esb.helpers.NamingContextPool;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockejb.jms.MockQueue;
-import org.mockejb.jms.MockTopic;
-import org.mockejb.jndi.MockContextFactory;
-
-/**
- * Unit tests for handling JBM specific error conditions in JmsConnectionPool
- *
- * @author <a href='kevin.conner at jboss.com'>Kevin Conner</a>
- */
-public class JmsConnectionPoolUnitTest
-{
- private static final String CONNECTION_FACTORY = "ConnectionFactory" ;
- private static final String QUEUE_NAME = "testQueue" ;
- private static final String TOPIC_NAME = "testTopic" ;
-
- @Before
- public void setUp()
- throws Exception
- {
- MockContextFactory.setAsInitial();
-
- final Context ctx = NamingContextPool.getNamingContext(null);
- try
- {
- ctx.rebind(CONNECTION_FACTORY, new MockXAConnectionFactory());
- }
- finally
- {
- NamingContextPool.releaseNamingContext(ctx) ;
- }
- System.setProperty(Environment.JNDI_SERVER_CONTEXT_FACTORY, System.getProperty(Context.INITIAL_CONTEXT_FACTORY)) ;
- }
-
- @After
- public void tearDown()
- throws Exception
- {
- MockContextFactory.revertSetAsInitial();
- }
-
- @Test
- public void testSessionRepeatableAcquire()
- throws Exception
- {
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- final JmsSession session = pool.getSession() ;
- Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
- pool.closeSession(session) ;
-
- final JmsSession session2 = pool.getSession() ;
- Assert.assertEquals("Session class", JmsSession.class, session2.getClass()) ;
- Assert.assertSame("Same session returned", session, session2) ;
- }
-
- @Test
- public void testSessionRetry()
- throws Exception
- {
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- MockConnectionInvocationHandler.throwFault = true ;
- final JmsSession session ;
- try
- {
- session = pool.getSession() ;
- Assert.assertFalse("fault should have been thrown", MockConnectionInvocationHandler.throwFault) ;
- }
- finally
- {
- MockConnectionInvocationHandler.throwFault = false ;
- }
-
- Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
- pool.closeSession(session) ;
- }
-
- @Test
- public void testSessionQueueBrowserRetry()
- throws Exception
- {
- final Queue queue = new MockQueue(QUEUE_NAME) ;
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- final JmsSession session = pool.getSession() ;
- Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
-
- final QueueBrowser queueBrowser = session.createBrowser(queue) ;
- queueBrowser.close() ;
-
- MockSessionInvocationHandler.throwFault = true ;
- try
- {
- session.createBrowser(queue) ;
- Assert.fail("Expected JmsConnectionFailureException") ;
- }
- catch (final JmsConnectionFailureException jmse) {} // expected
- finally
- {
- MockSessionInvocationHandler.throwFault = false ;
- }
-
- pool.closeSession(session) ;
-
- final JmsSession session2 = pool.getSession() ;
- Assert.assertEquals("Session class", JmsSession.class, session2.getClass()) ;
- Assert.assertNotSame("Session class", session, session2) ;
- }
-
- @Test
- public void testSessionMessageConsumerRetry()
- throws Exception
- {
- final Queue queue = new MockQueue(QUEUE_NAME) ;
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- final JmsSession session = pool.getSession() ;
- Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
-
- final MessageConsumer messageConsumer = session.createConsumer(queue) ;
- messageConsumer.close() ;
-
- MockSessionInvocationHandler.throwFault = true ;
- try
- {
- session.createConsumer(queue) ;
- Assert.fail("Expected JmsConnectionFailureException") ;
- }
- catch (final JmsConnectionFailureException jmse) {} // expected
- finally
- {
- MockSessionInvocationHandler.throwFault = false ;
- }
-
- pool.closeSession(session) ;
-
- final JmsSession session2 = pool.getSession() ;
- Assert.assertEquals("Session class", JmsSession.class, session2.getClass()) ;
- Assert.assertNotSame("Session class", session, session2) ;
- }
-
- @Test
- public void testSessionTopicSubscriberRetry()
- throws Exception
- {
- final Topic topic = new MockTopic(TOPIC_NAME) ;
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- final JmsSession session = pool.getSession() ;
- Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
-
- final TopicSubscriber topicSubscriber = session.createDurableSubscriber(topic, "testSessionTopicSubscriberRetry") ;
- topicSubscriber.close() ;
-
- MockSessionInvocationHandler.throwFault = true ;
- try
- {
- session.createDurableSubscriber(topic, "testSessionTopicSubscriberRetry") ;
- Assert.fail("Expected JmsConnectionFailureException") ;
- }
- catch (final JmsConnectionFailureException jmse) {} // expected
- finally
- {
- MockSessionInvocationHandler.throwFault = false ;
- }
-
- pool.closeSession(session) ;
-
- final JmsSession session2 = pool.getSession() ;
- Assert.assertEquals("Session class", JmsSession.class, session2.getClass()) ;
- Assert.assertNotSame("Session class", session, session2) ;
- }
-
- @Test
- public void testSessionMessageProducerRetry()
- throws Exception
- {
- final Queue queue = new MockQueue(QUEUE_NAME) ;
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- final JmsSession session = pool.getSession() ;
- Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
-
- final MessageProducer messageProducer = session.createProducer(queue) ;
- messageProducer.close() ;
-
- MockSessionInvocationHandler.throwFault = true ;
- try
- {
- session.createProducer(queue) ;
- Assert.fail("Expected JmsConnectionFailureException") ;
- }
- catch (final JmsConnectionFailureException jmse) {} // expected
- finally
- {
- MockSessionInvocationHandler.throwFault = false ;
- }
-
- pool.closeSession(session) ;
-
- final JmsSession session2 = pool.getSession() ;
- Assert.assertEquals("Session class", JmsSession.class, session2.getClass()) ;
- Assert.assertNotSame("Session class", session, session2) ;
- }
-
- @Test
- public void testXASessionRetry()
- throws Exception
- {
- final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
- TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
- try
- {
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- MockConnectionInvocationHandler.throwFault = true ;
- final JmsSession session ;
- try
- {
- session = pool.getSession() ;
- Assert.assertFalse("fault should have been thrown", MockConnectionInvocationHandler.throwFault) ;
- }
- finally
- {
- MockConnectionInvocationHandler.throwFault = false ;
- }
-
- Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
- pool.closeSession(session) ;
- }
- finally
- {
- TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
- }
- }
-
- @Test
- public void testXASessionQueueBrowserRetry()
- throws Exception
- {
- final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
- TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
- try
- {
- final Queue queue = new MockQueue(QUEUE_NAME) ;
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- final JmsSession session = pool.getSession() ;
- Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
-
- final QueueBrowser queueBrowser = session.createBrowser(queue) ;
- queueBrowser.close() ;
-
- MockSessionInvocationHandler.throwFault = true ;
- try
- {
- session.createBrowser(queue) ;
- Assert.fail("Expected JmsConnectionFailureException") ;
- }
- catch (final JmsConnectionFailureException jmse) {} // expected
- finally
- {
- MockSessionInvocationHandler.throwFault = false ;
- }
-
- pool.closeSession(session) ;
-
- final JmsSession session2 = pool.getSession() ;
- Assert.assertEquals("Session class", JmsXASession.class, session2.getClass()) ;
- Assert.assertNotSame("Session class", session, session2) ;
- }
- finally
- {
- TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
- }
- }
-
- @Test
- public void testXASessionMessageConsumerRetry()
- throws Exception
- {
- final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
- TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
- try
- {
- final Queue queue = new MockQueue(QUEUE_NAME) ;
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- final JmsSession session = pool.getSession() ;
- Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
-
- final MessageConsumer messageConsumer = session.createConsumer(queue) ;
- messageConsumer.close() ;
-
- MockSessionInvocationHandler.throwFault = true ;
- try
- {
- session.createConsumer(queue) ;
- Assert.fail("Expected JmsConnectionFailureException") ;
- }
- catch (final JmsConnectionFailureException jmse) {} // expected
- finally
- {
- MockSessionInvocationHandler.throwFault = false ;
- }
-
- pool.closeSession(session) ;
-
- final JmsSession session2 = pool.getSession() ;
- Assert.assertEquals("Session class", JmsXASession.class, session2.getClass()) ;
- Assert.assertNotSame("Session class", session, session2) ;
- }
- finally
- {
- TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
- }
- }
-
- @Test
- public void testXASessionTopicSubscriberRetry()
- throws Exception
- {
- final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
- TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
- try
- {
- final Topic topic = new MockTopic(TOPIC_NAME) ;
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- final JmsSession session = pool.getSession() ;
- Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
-
- final TopicSubscriber topicSubscriber = session.createDurableSubscriber(topic, "testSessionTopicSubscriberRetry") ;
- topicSubscriber.close() ;
-
- MockSessionInvocationHandler.throwFault = true ;
- try
- {
- session.createDurableSubscriber(topic, "testSessionTopicSubscriberRetry") ;
- Assert.fail("Expected JmsConnectionFailureException") ;
- }
- catch (final JmsConnectionFailureException jmse) {} // expected
- finally
- {
- MockSessionInvocationHandler.throwFault = false ;
- }
-
- pool.closeSession(session) ;
-
- final JmsSession session2 = pool.getSession() ;
- Assert.assertEquals("Session class", JmsXASession.class, session2.getClass()) ;
- Assert.assertNotSame("Session class", session, session2) ;
- }
- finally
- {
- TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
- }
- }
-
- @Test
- public void testXASessionMessageProducerRetry()
- throws Exception
- {
- final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
- TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
- try
- {
- final Queue queue = new MockQueue(QUEUE_NAME) ;
- final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
- final JmsSession session = pool.getSession() ;
- Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
-
- final MessageProducer messageProducer = session.createProducer(queue) ;
- messageProducer.close() ;
-
- MockSessionInvocationHandler.throwFault = true ;
- try
- {
- session.createProducer(queue) ;
- Assert.fail("Expected JmsConnectionFailureException") ;
- }
- catch (final JmsConnectionFailureException jmse) {} // expected
- finally
- {
- MockSessionInvocationHandler.throwFault = false ;
- }
-
- pool.closeSession(session) ;
-
- final JmsSession session2 = pool.getSession() ;
- Assert.assertEquals("Session class", JmsXASession.class, session2.getClass()) ;
- Assert.assertNotSame("Session class", session, session2) ;
- }
- finally
- {
- TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
- }
- }
-
- private Map<String, String> getPoolEnv()
- {
- final Map<String, String> env = new HashMap<String, String>() ;
- env.put(JMSEpr.CONNECTION_FACTORY_TAG, CONNECTION_FACTORY);
- return env ;
- }
-
- static class MockXAConnectionFactory implements XAConnectionFactory, ConnectionFactory
- {
- public XAConnection createXAConnection()
- throws JMSException
- {
- return (XAConnection)Proxy.newProxyInstance(MockXAConnectionFactory.class.getClassLoader(), new Class[] {XAConnection.class},
- new MockConnectionInvocationHandler()) ;
- }
-
- public XAConnection createXAConnection(final String user, final String password)
- throws JMSException
- {
- return createXAConnection() ;
- }
-
- public Connection createConnection()
- throws JMSException
- {
- return (Connection)Proxy.newProxyInstance(MockXAConnectionFactory.class.getClassLoader(), new Class[] {Connection.class},
- new MockConnectionInvocationHandler()) ;
- }
-
- public Connection createConnection(final String user, final String password)
- throws JMSException
- {
- return createConnection() ;
- }
- }
-
- static final class MockConnectionInvocationHandler implements InvocationHandler
- {
- private ExceptionListener exceptionListener ;
- static boolean throwFault ;
-
- MockConnectionInvocationHandler()
- {
- }
-
- public Object invoke(final Object proxy, final Method method, final Object[] args)
- throws Throwable
- {
- final String methodName = method.getName() ;
- if ("setExceptionListener".equals(methodName))
- {
- exceptionListener = (ExceptionListener)args[0] ;
- return null ;
- }
- else if ("getExceptionListener".equals(methodName))
- {
- return exceptionListener ;
- }
- else if ("createSession".equals(methodName))
- {
- checkFault() ;
- final Integer acknowledgeMode = (Integer)args[1] ;
- return Proxy.newProxyInstance(MockConnectionInvocationHandler.class.getClassLoader(), new Class[] {Session.class},
- new MockSessionInvocationHandler(acknowledgeMode)) ;
- }
- else if ("createXASession".equals(methodName))
- {
- checkFault() ;
- return Proxy.newProxyInstance(MockConnectionInvocationHandler.class.getClassLoader(), new Class[] {XASession.class},
- new MockSessionInvocationHandler(Session.SESSION_TRANSACTED)) ;
- }
- else
- {
- System.out.println("Connection method " + method.getName() + " called") ;
- return null ;
- }
- }
-
- void fireExceptionListener(final JMSException exception)
- {
- if (exceptionListener != null)
- {
- exceptionListener.onException(exception) ;
- }
- }
-
- private void checkFault()
- throws JMSException
- {
- if (throwFault)
- {
- final JMSException exception = new JMSException("Test exception") ;
- exception.initCause(new IllegalStateException("JMS IllegalStateException")) ;
- // clear it down to allow retry
- throwFault = false ;
- throw exception ;
- }
- }
- }
-
- static final class MockSessionInvocationHandler implements InvocationHandler
- {
- private final Integer acknowledgeMode ;
- static boolean throwFault ;
-
- MockSessionInvocationHandler(final Integer acknowledgeMode)
- {
- this.acknowledgeMode = acknowledgeMode ;
- }
-
- public Object invoke(final Object proxy, final Method method, final Object[] args)
- throws Throwable
- {
- final String methodName = method.getName() ;
- if ("getAcknowledgeMode".equals(methodName))
- {
- return acknowledgeMode ;
- }
- else if ("createBrowser".equals(methodName))
- {
- checkFault() ;
- return Proxy.newProxyInstance(MockSessionInvocationHandler.class.getClassLoader(), new Class[] {QueueBrowser.class},
- new MockNullInvocationHandler()) ;
- }
- else if ("createConsumer".equals(methodName))
- {
- checkFault() ;
- return Proxy.newProxyInstance(MockSessionInvocationHandler.class.getClassLoader(), new Class[] {MessageConsumer.class},
- new MockNullInvocationHandler()) ;
- }
- else if ("createDurableSubscriber".equals(methodName))
- {
- checkFault() ;
- return Proxy.newProxyInstance(MockSessionInvocationHandler.class.getClassLoader(), new Class[] {TopicSubscriber.class},
- new MockNullInvocationHandler()) ;
- }
- else if ("createProducer".equals(methodName))
- {
- checkFault() ;
- return Proxy.newProxyInstance(MockSessionInvocationHandler.class.getClassLoader(), new Class[] {MessageProducer.class},
- new MockNullInvocationHandler()) ;
- }
- else
- {
- System.out.println("Session method " + method.getName() + " called") ;
- return null ;
- }
- }
-
- private void checkFault()
- throws JMSException
- {
- if (throwFault)
- {
- final JMSException exception = new JMSException("Test exception") ;
- exception.initCause(new IllegalStateException("JMS IllegalStateException")) ;
- throw exception ;
- }
- }
- }
-
- static final class MockNullInvocationHandler implements InvocationHandler
- {
- public Object invoke(final Object proxy, final Method method, final Object[] args)
- throws Throwable
- {
- final String methodName = method.getName() ;
- if ("hashCode".equals(methodName))
- {
- return System.identityHashCode(proxy) ;
- }
- else if ("equals".equals(methodName))
- {
- return proxy == args[0] ;
- }
- else
- {
- return null ;
- }
- }
- }
-
- private static final class MockActiveTransactionStrategy extends NullTransactionStrategy
- {
- @Override
- public boolean isActive()
- throws TransactionStrategyException
- {
- return true ;
- }
-
- @Override
- public void registerSynchronization(final Synchronization sync)
- throws TransactionStrategyException
- {
- }
-
- @Override
- public void enlistResource(final XAResource resource)
- throws TransactionStrategyException
- {
- }
-
- @Override
- public Object getTransaction()
- throws TransactionStrategyException
- {
- return this ;
- }
- }
-
- public static junit.framework.Test suite()
- {
- return new JUnit4TestAdapter(JmsConnectionPoolUnitTest.class);
- }
-}
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolUnitTest.java (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolUnitTest.java)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolUnitTest.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/product/rosetta/tests/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPoolUnitTest.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,866 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.internal.soa.esb.rosetta.pooling;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.ExceptionListener;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+import javax.jms.Session;
+import javax.jms.Topic;
+import javax.jms.TopicSubscriber;
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
+import javax.jms.XASession;
+import javax.naming.Context;
+import javax.transaction.Synchronization;
+import javax.transaction.xa.XAResource;
+
+import junit.framework.Assert;
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.internal.soa.esb.rosetta.pooling.handlers.WMQConnectionExceptionHandler;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.common.Environment;
+import org.jboss.soa.esb.common.TransactionStrategy;
+import org.jboss.soa.esb.common.TransactionStrategyException;
+import org.jboss.soa.esb.common.TransactionStrategy.NullTransactionStrategy;
+import org.jboss.soa.esb.helpers.NamingContextPool;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockejb.jms.MockQueue;
+import org.mockejb.jms.MockTopic;
+import org.mockejb.jndi.MockContextFactory;
+
+/**
+ * Unit tests for handling specific error conditions in JmsConnectionPool
+ * and JBMQ acknowledge behaviour.
+ *
+ * @author <a href='kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public class JmsConnectionPoolUnitTest
+{
+ private static final String CONNECTION_FACTORY = "ConnectionFactory" ;
+ private static final String QUEUE_NAME = "testQueue" ;
+ private static final String TOPIC_NAME = "testTopic" ;
+
+ @Before
+ public void setUp()
+ throws Exception
+ {
+ MockContextFactory.setAsInitial();
+
+ final Context ctx = NamingContextPool.getNamingContext(null);
+ try
+ {
+ ctx.rebind(CONNECTION_FACTORY, new MockXAConnectionFactory());
+ }
+ finally
+ {
+ NamingContextPool.releaseNamingContext(ctx) ;
+ }
+ System.setProperty(Environment.JNDI_SERVER_CONTEXT_FACTORY, System.getProperty(Context.INITIAL_CONTEXT_FACTORY)) ;
+ }
+
+ @After
+ public void tearDown()
+ throws Exception
+ {
+ MockContextFactory.revertSetAsInitial();
+ }
+
+ @Test
+ public void testSessionAcknowledgeBehaviour()
+ throws Exception
+ {
+ MockSessionInvocationHandler.changeAcknowledgeMode = true ;
+ try
+ {
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ final int acknowledgeMode = Session.CLIENT_ACKNOWLEDGE ;
+ Assert.assertEquals("current pool free count", 0, pool.getFreeSessionsInPool(acknowledgeMode)) ;
+ Assert.assertEquals("current pool in use count", 0, pool.getInUseSessionsInPool(acknowledgeMode)) ;
+ final JmsSession session = pool.getSession(acknowledgeMode) ;
+ Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
+ Assert.assertEquals("current pool free count", 0, pool.getFreeSessionsInPool(acknowledgeMode)) ;
+ Assert.assertEquals("current pool in use count", 1, pool.getInUseSessionsInPool(acknowledgeMode)) ;
+ Assert.assertTrue("Different acknowledge mode", acknowledgeMode != session.getAcknowledgeMode()) ;
+ pool.closeSession(session) ;
+ Assert.assertEquals("current pool free count", 1, pool.getFreeSessionsInPool(acknowledgeMode)) ;
+ Assert.assertEquals("current pool in use count", 0, pool.getInUseSessionsInPool(acknowledgeMode)) ;
+ }
+ finally
+ {
+ MockSessionInvocationHandler.changeAcknowledgeMode = false ;
+ }
+ }
+
+ @Test
+ public void testSessionRepeatableAcquire()
+ throws Exception
+ {
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ final JmsSession session = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
+ pool.closeSession(session) ;
+
+ final JmsSession session2 = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsSession.class, session2.getClass()) ;
+ Assert.assertSame("Same session returned", session, session2) ;
+ }
+
+ @Test
+ public void testSessionRetry()
+ throws Exception
+ {
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ MockConnectionInvocationHandler.throwFault = true ;
+ final JmsSession session ;
+ try
+ {
+ session = pool.getSession() ;
+ Assert.assertFalse("fault should have been thrown", MockConnectionInvocationHandler.throwFault) ;
+ }
+ finally
+ {
+ MockConnectionInvocationHandler.throwFault = false ;
+ }
+
+ Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
+ pool.closeSession(session) ;
+ }
+
+ @Test
+ public void testSessionQueueBrowserRetry()
+ throws Exception
+ {
+ executeSessionQueueBrowserRetry(false) ;
+ }
+
+ @Test
+ public void testWSMQSessionQueueBrowserRetry()
+ throws Exception
+ {
+ executeSessionQueueBrowserRetry(true) ;
+ }
+
+ public void executeSessionQueueBrowserRetry(final boolean wsmq)
+ throws Exception
+ {
+ final Queue queue = new MockQueue(QUEUE_NAME) ;
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ final JmsSession session = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
+
+ final QueueBrowser queueBrowser = session.createBrowser(queue) ;
+ queueBrowser.close() ;
+
+ setFault(wsmq, true) ;
+ try
+ {
+ session.createBrowser(queue) ;
+ Assert.fail("Expected JmsConnectionFailureException") ;
+ }
+ catch (final JmsConnectionFailureException jmse) {} // expected
+ finally
+ {
+ setFault(wsmq, false) ;
+ }
+
+ pool.closeSession(session) ;
+
+ final JmsSession session2 = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsSession.class, session2.getClass()) ;
+ Assert.assertNotSame("Session class", session, session2) ;
+ }
+
+ @Test
+ public void testSessionMessageConsumerRetry()
+ throws Exception
+ {
+ executeSessionMessageConsumerRetry(false) ;
+ }
+
+ @Test
+ public void testWSMQSessionMessageConsumerRetry()
+ throws Exception
+ {
+ executeSessionMessageConsumerRetry(true) ;
+ }
+
+ public void executeSessionMessageConsumerRetry(final boolean wsmq)
+ throws Exception
+ {
+ final Queue queue = new MockQueue(QUEUE_NAME) ;
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ final JmsSession session = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
+
+ final MessageConsumer messageConsumer = session.createConsumer(queue) ;
+ messageConsumer.close() ;
+
+ setFault(wsmq, true) ;
+ try
+ {
+ session.createConsumer(queue) ;
+ Assert.fail("Expected JmsConnectionFailureException") ;
+ }
+ catch (final JmsConnectionFailureException jmse) {} // expected
+ finally
+ {
+ setFault(wsmq, false) ;
+ }
+
+ pool.closeSession(session) ;
+
+ final JmsSession session2 = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsSession.class, session2.getClass()) ;
+ Assert.assertNotSame("Session class", session, session2) ;
+ }
+
+ @Test
+ public void testSessionTopicSubscriberRetry()
+ throws Exception
+ {
+ executeSessionTopicSubscriberRetry(false) ;
+ }
+
+ @Test
+ public void testWSMQSessionTopicSubscriberRetry()
+ throws Exception
+ {
+ executeSessionTopicSubscriberRetry(true) ;
+ }
+
+ public void executeSessionTopicSubscriberRetry(final boolean wsmq)
+ throws Exception
+ {
+ final Topic topic = new MockTopic(TOPIC_NAME) ;
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ final JmsSession session = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
+
+ final TopicSubscriber topicSubscriber = session.createDurableSubscriber(topic, "testSessionTopicSubscriberRetry") ;
+ topicSubscriber.close() ;
+
+ setFault(wsmq, true) ;
+ try
+ {
+ session.createDurableSubscriber(topic, "testSessionTopicSubscriberRetry") ;
+ Assert.fail("Expected JmsConnectionFailureException") ;
+ }
+ catch (final JmsConnectionFailureException jmse) {} // expected
+ finally
+ {
+ setFault(wsmq, false) ;
+ }
+
+ pool.closeSession(session) ;
+
+ final JmsSession session2 = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsSession.class, session2.getClass()) ;
+ Assert.assertNotSame("Session class", session, session2) ;
+ }
+
+ @Test
+ public void testSessionMessageProducerRetry()
+ throws Exception
+ {
+ executeSessionMessageProducerRetry(false) ;
+ }
+
+ @Test
+ public void testWSMQSessionMessageProducerRetry()
+ throws Exception
+ {
+ executeSessionMessageProducerRetry(true) ;
+ }
+
+ public void executeSessionMessageProducerRetry(final boolean wsmq)
+ throws Exception
+ {
+ final Queue queue = new MockQueue(QUEUE_NAME) ;
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ final JmsSession session = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsSession.class, session.getClass()) ;
+
+ final MessageProducer messageProducer = session.createProducer(queue) ;
+ messageProducer.close() ;
+
+ setFault(wsmq, true) ;
+ try
+ {
+ session.createProducer(queue) ;
+ Assert.fail("Expected JmsConnectionFailureException") ;
+ }
+ catch (final JmsConnectionFailureException jmse) {} // expected
+ finally
+ {
+ setFault(wsmq, false) ;
+ }
+
+ pool.closeSession(session) ;
+
+ final JmsSession session2 = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsSession.class, session2.getClass()) ;
+ Assert.assertNotSame("Session class", session, session2) ;
+ }
+
+ @Test
+ public void testXASessionAcknowledgeBehaviour()
+ throws Exception
+ {
+ executeXASessionAcknowledgeBehaviour(false) ;
+ }
+
+ @Test
+ public void testWSMQXASessionAcknowledgeBehaviour()
+ throws Exception
+ {
+ executeXASessionAcknowledgeBehaviour(true) ;
+ }
+
+ public void executeXASessionAcknowledgeBehaviour(final boolean wsmq)
+ throws Exception
+ {
+ final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
+ TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
+ MockSessionInvocationHandler.changeAcknowledgeMode = true ;
+ try
+ {
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ // transactional sessions are requested with transacted acknowledge mode
+ final int acknowledgeMode = Session.SESSION_TRANSACTED ;
+ Assert.assertEquals("current pool free count", 0, pool.getFreeSessionsInPool(acknowledgeMode)) ;
+ Assert.assertEquals("current pool in use count", 0, pool.getInUseSessionsInPool(acknowledgeMode)) ;
+ final JmsSession session = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
+ Assert.assertEquals("current pool free count", 0, pool.getFreeSessionsInPool(acknowledgeMode)) ;
+ Assert.assertEquals("current pool in use count", 1, pool.getInUseSessionsInPool(acknowledgeMode)) ;
+ Assert.assertTrue("Different acknowledge mode", acknowledgeMode != session.getAcknowledgeMode()) ;
+ pool.closeSession(session) ;
+ Assert.assertEquals("current pool free count", 1, pool.getFreeSessionsInPool(acknowledgeMode)) ;
+ Assert.assertEquals("current pool in use count", 0, pool.getInUseSessionsInPool(acknowledgeMode)) ;
+ }
+ finally
+ {
+ MockSessionInvocationHandler.changeAcknowledgeMode = false ;
+ TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
+ }
+ }
+
+ @Test
+ public void testXASessionRetry()
+ throws Exception
+ {
+ final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
+ TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
+ try
+ {
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ MockConnectionInvocationHandler.throwFault = true ;
+ final JmsSession session ;
+ try
+ {
+ session = pool.getSession() ;
+ Assert.assertFalse("fault should have been thrown", MockConnectionInvocationHandler.throwFault) ;
+ }
+ finally
+ {
+ MockConnectionInvocationHandler.throwFault = false ;
+ }
+
+ Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
+ pool.closeSession(session) ;
+ }
+ finally
+ {
+ TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
+ }
+ }
+
+ @Test
+ public void testXASessionQueueBrowserRetry()
+ throws Exception
+ {
+ executeXASessionQueueBrowserRetry(false) ;
+ }
+
+ @Test
+ public void testWSMQXASessionQueueBrowserRetry()
+ throws Exception
+ {
+ executeXASessionQueueBrowserRetry(true) ;
+ }
+
+ public void executeXASessionQueueBrowserRetry(final boolean wsmq)
+ throws Exception
+ {
+ final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
+ TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
+ try
+ {
+ final Queue queue = new MockQueue(QUEUE_NAME) ;
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ final JmsSession session = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
+
+ final QueueBrowser queueBrowser = session.createBrowser(queue) ;
+ queueBrowser.close() ;
+
+ setFault(wsmq, true) ;
+ try
+ {
+ session.createBrowser(queue) ;
+ Assert.fail("Expected JmsConnectionFailureException") ;
+ }
+ catch (final JmsConnectionFailureException jmse) {} // expected
+ finally
+ {
+ setFault(wsmq, false) ;
+ }
+
+ pool.closeSession(session) ;
+
+ final JmsSession session2 = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsXASession.class, session2.getClass()) ;
+ Assert.assertNotSame("Session class", session, session2) ;
+ }
+ finally
+ {
+ TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
+ }
+ }
+
+ @Test
+ public void testXASessionMessageConsumerRetry()
+ throws Exception
+ {
+ executeXASessionMessageConsumerRetry(false) ;
+ }
+
+ @Test
+ public void testWSMQXASessionMessageConsumerRetry()
+ throws Exception
+ {
+ executeXASessionMessageConsumerRetry(true) ;
+ }
+
+ public void executeXASessionMessageConsumerRetry(final boolean wsmq)
+ throws Exception
+ {
+ final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
+ TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
+ try
+ {
+ final Queue queue = new MockQueue(QUEUE_NAME) ;
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ final JmsSession session = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
+
+ final MessageConsumer messageConsumer = session.createConsumer(queue) ;
+ messageConsumer.close() ;
+
+ setFault(wsmq, true) ;
+ try
+ {
+ session.createConsumer(queue) ;
+ Assert.fail("Expected JmsConnectionFailureException") ;
+ }
+ catch (final JmsConnectionFailureException jmse) {} // expected
+ finally
+ {
+ setFault(wsmq, false) ;
+ }
+
+ pool.closeSession(session) ;
+
+ final JmsSession session2 = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsXASession.class, session2.getClass()) ;
+ Assert.assertNotSame("Session class", session, session2) ;
+ }
+ finally
+ {
+ TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
+ }
+ }
+
+ @Test
+ public void testXASessionTopicSubscriberRetry()
+ throws Exception
+ {
+ executeXASessionTopicSubscriberRetry(false) ;
+ }
+
+ @Test
+ public void testWSMQXASessionTopicSubscriberRetry()
+ throws Exception
+ {
+ executeXASessionTopicSubscriberRetry(true) ;
+ }
+
+ public void executeXASessionTopicSubscriberRetry(final boolean wsmq)
+ throws Exception
+ {
+ final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
+ TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
+ try
+ {
+ final Topic topic = new MockTopic(TOPIC_NAME) ;
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ final JmsSession session = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
+
+ final TopicSubscriber topicSubscriber = session.createDurableSubscriber(topic, "testSessionTopicSubscriberRetry") ;
+ topicSubscriber.close() ;
+
+ setFault(wsmq, true) ;
+ try
+ {
+ session.createDurableSubscriber(topic, "testSessionTopicSubscriberRetry") ;
+ Assert.fail("Expected JmsConnectionFailureException") ;
+ }
+ catch (final JmsConnectionFailureException jmse) {} // expected
+ finally
+ {
+ setFault(wsmq, false) ;
+ }
+
+ pool.closeSession(session) ;
+
+ final JmsSession session2 = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsXASession.class, session2.getClass()) ;
+ Assert.assertNotSame("Session class", session, session2) ;
+ }
+ finally
+ {
+ TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
+ }
+ }
+
+ @Test
+ public void testXASessionMessageProducerRetry()
+ throws Exception
+ {
+ executeXASessionMessageProducerRetry(false) ;
+ }
+
+ @Test
+ public void testWSMQXASessionMessageProducerRetry()
+ throws Exception
+ {
+ executeXASessionMessageProducerRetry(true) ;
+ }
+
+ public void executeXASessionMessageProducerRetry(final boolean wsmq)
+ throws Exception
+ {
+ final TransactionStrategy transactionStrategy = TransactionStrategy.getTransactionStrategy(true) ;
+ TransactionStrategy.setTransactionStrategy(new MockActiveTransactionStrategy()) ;
+ try
+ {
+ final Queue queue = new MockQueue(QUEUE_NAME) ;
+ final JmsConnectionPool pool = new JmsConnectionPool(getPoolEnv()) ;
+ final JmsSession session = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsXASession.class, session.getClass()) ;
+
+ final MessageProducer messageProducer = session.createProducer(queue) ;
+ messageProducer.close() ;
+
+ setFault(wsmq, true) ;
+ try
+ {
+ session.createProducer(queue) ;
+ Assert.fail("Expected JmsConnectionFailureException") ;
+ }
+ catch (final JmsConnectionFailureException jmse) {} // expected
+ finally
+ {
+ setFault(wsmq, false) ;
+ }
+
+ pool.closeSession(session) ;
+
+ final JmsSession session2 = pool.getSession() ;
+ Assert.assertEquals("Session class", JmsXASession.class, session2.getClass()) ;
+ Assert.assertNotSame("Session class", session, session2) ;
+ }
+ finally
+ {
+ TransactionStrategy.setTransactionStrategy(transactionStrategy) ;
+ }
+ }
+
+ private Map<String, String> getPoolEnv()
+ {
+ final Map<String, String> env = new HashMap<String, String>() ;
+ env.put(JMSEpr.CONNECTION_FACTORY_TAG, CONNECTION_FACTORY);
+ return env ;
+ }
+
+ private void setFault(final boolean wsmq, final boolean value)
+ {
+ if (wsmq)
+ {
+ MockSessionInvocationHandler.throwWSMQFault = value ;
+ }
+ else
+ {
+ MockSessionInvocationHandler.throwFault = value ;
+ }
+ }
+
+ static class MockXAConnectionFactory implements XAConnectionFactory, ConnectionFactory
+ {
+ public XAConnection createXAConnection()
+ throws JMSException
+ {
+ return (XAConnection)Proxy.newProxyInstance(MockXAConnectionFactory.class.getClassLoader(), new Class[] {XAConnection.class},
+ new MockConnectionInvocationHandler()) ;
+ }
+
+ public XAConnection createXAConnection(final String user, final String password)
+ throws JMSException
+ {
+ return createXAConnection() ;
+ }
+
+ public Connection createConnection()
+ throws JMSException
+ {
+ return (Connection)Proxy.newProxyInstance(MockXAConnectionFactory.class.getClassLoader(), new Class[] {Connection.class},
+ new MockConnectionInvocationHandler()) ;
+ }
+
+ public Connection createConnection(final String user, final String password)
+ throws JMSException
+ {
+ return createConnection() ;
+ }
+ }
+
+ static final class MockConnectionInvocationHandler implements InvocationHandler
+ {
+ private ExceptionListener exceptionListener ;
+ static boolean throwFault ;
+
+ MockConnectionInvocationHandler()
+ {
+ }
+
+ public Object invoke(final Object proxy, final Method method, final Object[] args)
+ throws Throwable
+ {
+ final String methodName = method.getName() ;
+ if ("setExceptionListener".equals(methodName))
+ {
+ exceptionListener = (ExceptionListener)args[0] ;
+ return null ;
+ }
+ else if ("getExceptionListener".equals(methodName))
+ {
+ return exceptionListener ;
+ }
+ else if ("createSession".equals(methodName))
+ {
+ checkFault() ;
+ final Integer acknowledgeMode = (Integer)args[1] ;
+ return Proxy.newProxyInstance(MockConnectionInvocationHandler.class.getClassLoader(), new Class[] {Session.class},
+ new MockSessionInvocationHandler(acknowledgeMode)) ;
+ }
+ else if ("createXASession".equals(methodName))
+ {
+ checkFault() ;
+ return Proxy.newProxyInstance(MockConnectionInvocationHandler.class.getClassLoader(), new Class[] {XASession.class},
+ new MockSessionInvocationHandler(Session.SESSION_TRANSACTED)) ;
+ }
+ else
+ {
+ System.out.println("Connection method " + method.getName() + " called") ;
+ return null ;
+ }
+ }
+
+ void fireExceptionListener(final JMSException exception)
+ {
+ if (exceptionListener != null)
+ {
+ exceptionListener.onException(exception) ;
+ }
+ }
+
+ private void checkFault()
+ throws JMSException
+ {
+ if (throwFault)
+ {
+ final JMSException exception = new JMSException("Test exception") ;
+ exception.initCause(new IllegalStateException("JMS IllegalStateException")) ;
+ // clear it down to allow retry
+ throwFault = false ;
+ throw exception ;
+ }
+ }
+ }
+
+ static final class MockSessionInvocationHandler implements InvocationHandler
+ {
+ private final Integer acknowledgeMode ;
+ static boolean throwFault ;
+ static boolean throwWSMQFault ;
+ static boolean changeAcknowledgeMode ;
+
+ MockSessionInvocationHandler(final Integer acknowledgeMode)
+ {
+ this.acknowledgeMode = acknowledgeMode ;
+ }
+
+ public Object invoke(final Object proxy, final Method method, final Object[] args)
+ throws Throwable
+ {
+ final String methodName = method.getName() ;
+ if ("getAcknowledgeMode".equals(methodName))
+ {
+ if (changeAcknowledgeMode)
+ {
+ return (acknowledgeMode + 1) & 3 ;
+ }
+ else
+ {
+ return acknowledgeMode ;
+ }
+ }
+ else if ("createBrowser".equals(methodName))
+ {
+ checkFault() ;
+ return Proxy.newProxyInstance(MockSessionInvocationHandler.class.getClassLoader(), new Class[] {QueueBrowser.class},
+ new MockNullInvocationHandler()) ;
+ }
+ else if ("createConsumer".equals(methodName))
+ {
+ checkFault() ;
+ return Proxy.newProxyInstance(MockSessionInvocationHandler.class.getClassLoader(), new Class[] {MessageConsumer.class},
+ new MockNullInvocationHandler()) ;
+ }
+ else if ("createDurableSubscriber".equals(methodName))
+ {
+ checkFault() ;
+ return Proxy.newProxyInstance(MockSessionInvocationHandler.class.getClassLoader(), new Class[] {TopicSubscriber.class},
+ new MockNullInvocationHandler()) ;
+ }
+ else if ("createProducer".equals(methodName))
+ {
+ checkFault() ;
+ return Proxy.newProxyInstance(MockSessionInvocationHandler.class.getClassLoader(), new Class[] {MessageProducer.class},
+ new MockNullInvocationHandler()) ;
+ }
+ else
+ {
+ System.out.println("Session method " + method.getName() + " called") ;
+ return null ;
+ }
+ }
+
+ private void checkFault()
+ throws JMSException
+ {
+ if (throwFault)
+ {
+ final JMSException exception = new JMSException("Test exception") ;
+ exception.initCause(new IllegalStateException("JMS IllegalStateException")) ;
+ throw exception ;
+ }
+ else if (throwWSMQFault)
+ {
+ final JMSException exception = new JMSException("Test exception", WMQConnectionExceptionHandler.WMQ_ERROR_CODE_CONNECTION_FAILURE) ;
+ exception.setLinkedException(new Exception(WMQConnectionExceptionHandler.WMQ_LINKED_EXCEPTION_CONNECTION_FAILURE)) ;
+ throw exception ;
+ }
+ }
+ }
+
+ static final class MockNullInvocationHandler implements InvocationHandler
+ {
+ public Object invoke(final Object proxy, final Method method, final Object[] args)
+ throws Throwable
+ {
+ final String methodName = method.getName() ;
+ if ("hashCode".equals(methodName))
+ {
+ return System.identityHashCode(proxy) ;
+ }
+ else if ("equals".equals(methodName))
+ {
+ return proxy == args[0] ;
+ }
+ else
+ {
+ return null ;
+ }
+ }
+ }
+
+ private static final class MockActiveTransactionStrategy extends NullTransactionStrategy
+ {
+ @Override
+ public boolean isActive()
+ throws TransactionStrategyException
+ {
+ return true ;
+ }
+
+ @Override
+ public void registerSynchronization(final Synchronization sync)
+ throws TransactionStrategyException
+ {
+ }
+
+ @Override
+ public void enlistResource(final XAResource resource)
+ throws TransactionStrategyException
+ {
+ }
+
+ @Override
+ public Object getTransaction()
+ throws TransactionStrategyException
+ {
+ return this ;
+ }
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(JmsConnectionPoolUnitTest.class);
+ }
+}
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,352 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.server.aop;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Field;
-import java.util.Collection;
-import java.util.List;
-
-import javax.xml.registry.BulkResponse;
-import javax.xml.registry.BusinessQueryManager;
-import javax.xml.registry.Connection;
-import javax.xml.registry.JAXRException;
-import javax.xml.registry.JAXRResponse;
-import javax.xml.registry.LifeCycleManager;
-import javax.xml.registry.RegistryService;
-import javax.xml.registry.infomodel.InternationalString;
-import javax.xml.registry.infomodel.Organization;
-import javax.xml.registry.infomodel.Service;
-import javax.xml.registry.infomodel.ServiceBinding;
-
-import org.apache.ws.scout.registry.infomodel.ServiceImpl;
-import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
-import org.jboss.internal.soa.esb.services.registry.JAXRConnectionFactory;
-import org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
-import org.jboss.soa.esb.services.registry.Registry;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.RegistryFactory;
-import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
-
-
-/**
- * MBean to manage AOP tests.
- *
- * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
- */
-public class AOPServer implements AOPServerMBean
-{
- public AOPServer()
- {
- System.out.println("AOP test MBean deployed") ;
- }
-
- public String verifyScoutPerformanceIssue()
- throws JAXRException, ConfigurationException
- {
- return new TestScoutRegistryImpl().checkService() ;
- }
-
- public String verifyScoutPerformanceIssue2()
- throws JAXRException, ConfigurationException
- {
- return new TestScoutRegistryImpl().checkServiceFromBusinessService() ;
- }
-
- public String verifyJUDDICDataIssue()
- throws RegistryException, MarshalException, ServiceNotFoundException
- {
- final Registry registry = RegistryFactory.getRegistry() ;
- final String category = "DummyAOPCategory" ;
- final String serviceName = "DummyAOPServiceName" ;
- final String serviceDescription = "Dummy AOP Service Description" ;
- final LogicalEPR epr = new LogicalEPR(category, serviceName) ;
- for (char name = 'a' ; name <= 'z' ; name++)
- {
- final String val = new String(new char[] {name}) ;
- epr.getAddr().addExtension(val, val) ;
- }
- final String eprAsXML = EPRHelper.toXMLString(epr) ;
- final String heuristic = verifyHeuristic(eprAsXML) ;
- if (heuristic != null)
- {
- return null ;
- }
-
- final String eprDescription = "Dummy AOP EPR Description" ;
-
- registry.registerEPR(category, serviceName, serviceDescription, epr, eprDescription) ;
- try
- {
- registry.findEPR(category, serviceName) ;
- }
- catch (final Throwable th)
- {
- final StringWriter sw = new StringWriter() ;
- final PrintWriter pw = new PrintWriter(sw) ;
- th.printStackTrace(pw) ;
- pw.flush() ;
- return sw.toString() ;
- }
-
- return null ;
- }
-
- public String verifyServiceRetrieval()
- throws RegistryException
- {
- final Registry registry = RegistryFactory.getRegistry() ;
- final List<String> services = registry.findAllServices() ;
- if ((services == null) || (services.size() == 0))
- {
- return "No services returned from query" ;
- }
- return null ;
- }
-
- public String verifyOrganizationalStructure()
- throws RegistryException, JAXRException, ConfigurationException
- {
- final Organization jbossESBOrganization = JAXRRegistryImpl.findOrganization("Red Hat/JBossESB", new JAXRConnectionFactory());
- final Collection<Service> services = jbossESBOrganization.getServices() ;
- if ((services != null) & (services.size() > 0))
- {
- return "Services returned in organization information" ;
- }
- return null ;
- }
-
- private String verifyHeuristic(final String value)
- {
- final char[] contents = value.toCharArray() ;
- final int numChars = contents.length ;
- int counter = 0 ;
- for(int index = 0 ; index < numChars ; index++)
- {
- final char ch = contents[index] ;
- if ((ch == '<') || (ch == '&'))
- {
- counter++;
- }
- }
- if ((numChars > 32) && (counter > 5) &&
- (((counter * 100) / numChars) > 1))
- {
- return null ;
- }
- else
- {
- return "Heuristic failure" ;
- }
- }
-
- private static final class TestScoutRegistryImpl extends JAXRRegistryImpl
- {
- public TestScoutRegistryImpl()
- throws ConfigurationException
- {
- }
-
- public String checkService()
- throws JAXRException, ConfigurationException
- {
- final Service service = findService("JBossESB-Internal", "DeadLetterService") ;
-
- if (service == null)
- {
- return "Service not found" ;
- }
-
- final ScoutConnectionFactory scoutConnectionFactory = new ScoutConnectionFactory() ;
- final Connection connection = scoutConnectionFactory.getConnection();
- try
- {
- final RegistryService rs = connection.getRegistryService();
- final BusinessQueryManager bqm = rs.getBusinessQueryManager();
- final BulkResponse bulkResponse = bqm.findServiceBindings(service.getKey(),null,null,null);
- if (bulkResponse.getStatus()!=JAXRResponse.STATUS_SUCCESS)
- {
- return "findServiceBindings failed" ;
- }
- final Collection<ServiceBinding> serviceBindings = (Collection<ServiceBinding>)bulkResponse.getCollection();
- if ((serviceBindings == null) || (serviceBindings.size() == 0))
- {
- return "could not find service bindings for DeadLetterService" ;
- }
-
- final Class<ServiceImpl> serviceImplClass = ServiceImpl.class ;
- final Field field ;
- try
- {
- field = serviceImplClass.getDeclaredField("org") ;
- }
- catch (final NoSuchFieldException nsfe)
- {
- return "Could not locate org field" ;
- }
- field.setAccessible(true) ;
- try
- {
- for(ServiceBinding serviceBinding: serviceBindings)
- {
- final Service bindingService = serviceBinding.getService() ;
- if (bindingService == null)
- {
- return "Could not find service associated with binding" ;
- }
- if (bindingService.getSubmittingOrganization() != null)
- {
- return "FAILED: Submitting organization is present in service binding" ;
- }
- if (!(bindingService instanceof ServiceImpl))
- {
- return "Binding service is not a ServiceImpl, need to change the test" ;
- }
- final ServiceImpl serviceImpl = (ServiceImpl)bindingService ;
- if (serviceImpl.getSubmittingOrganizationKey() == null)
- {
- return "FAILED: Submitting organization key is not present in service binding" ;
- }
- try
- {
- if (field.get(serviceImpl) != null)
- {
- return "FAILED: Organization is present in service binding" ;
- }
- }
- catch (final IllegalAccessException iae)
- {
- return "FAILED: Could not access org field in current service" ;
- }
- }
- }
- finally
- {
- field.setAccessible(false) ;
- }
-
- return null ;
- }
- finally
- {
- scoutConnectionFactory.closeConnection(connection) ;
- }
- }
-
- public String checkServiceFromBusinessService()
- throws JAXRException, ConfigurationException
- {
- final String serviceKey ;
- {
- final Service service = findService("JBossESB-Internal", "DeadLetterService") ;
-
- if (service == null)
- {
- return "Service not found" ;
- }
- serviceKey = service.getKey().getId() ;
- }
-
- final ScoutConnectionFactory scoutConnectionFactory = new ScoutConnectionFactory() ;
- final Connection connection = scoutConnectionFactory.getConnection();
- try
- {
- final RegistryService rs = connection.getRegistryService();
- final BusinessQueryManager bqm = rs.getBusinessQueryManager();
- final Service registryService = (Service)bqm.getRegistryObject(serviceKey, LifeCycleManager.SERVICE) ;
- if (registryService == null)
- {
- return "Failed to obtain service as registry object" ;
- }
-
- if (registryService.getSubmittingOrganization() != null)
- {
- return "FAILED: Submitting organization is present in service binding" ;
- }
- if (!(registryService instanceof ServiceImpl))
- {
- return "Binding service is not a ServiceImpl, need to change the test" ;
- }
- final ServiceImpl serviceImpl = (ServiceImpl)registryService ;
- if (serviceImpl.getSubmittingOrganizationKey() == null)
- {
- return "FAILED: Submitting organization key is not present in service binding" ;
- }
-
- final Field field ;
- try
- {
- field = serviceImpl.getClass().getDeclaredField("org") ;
- }
- catch (final NoSuchFieldException nsfe)
- {
- return "Could not locate org field" ;
- }
- field.setAccessible(true) ;
- try
- {
- try
- {
- if (field.get(serviceImpl) != null)
- {
- return "FAILED: Organization is present in service binding" ;
- }
- }
- catch (final IllegalAccessException iae)
- {
- return "FAILED: Could not access org field in current service" ;
- }
- }
- finally
- {
- field.setAccessible(false) ;
- }
-
- return null ;
- }
- finally
- {
- scoutConnectionFactory.closeConnection(connection) ;
- }
- }
- }
-
- private static class ScoutConnectionFactory extends JAXRConnectionFactory
- {
- public ScoutConnectionFactory()
- throws ConfigurationException
- {
- }
-
- public Connection getConnection()
- {
- return super.getConnection() ;
- }
-
- public void closeConnection(Connection connection)
- {
- super.closeConnection(connection) ;
- }
- }
-}
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServer.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,414 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.server.aop;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Field;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.registry.BulkResponse;
+import javax.xml.registry.BusinessQueryManager;
+import javax.xml.registry.Connection;
+import javax.xml.registry.JAXRException;
+import javax.xml.registry.JAXRResponse;
+import javax.xml.registry.LifeCycleManager;
+import javax.xml.registry.RegistryService;
+import javax.xml.registry.infomodel.Organization;
+import javax.xml.registry.infomodel.Service;
+import javax.xml.registry.infomodel.ServiceBinding;
+
+import org.apache.ws.scout.registry.IRegistry;
+import org.apache.ws.scout.registry.infomodel.ServiceImpl;
+import org.apache.ws.scout.uddi.BindingTemplate;
+import org.apache.ws.scout.uddi.BindingTemplates;
+import org.apache.ws.scout.uddi.BusinessService;
+import org.apache.ws.scout.uddi.ServiceDetail;
+import org.apache.ws.scout.uddi.TModelInstanceDetails;
+import org.apache.ws.scout.uddi.TModelInstanceInfo;
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
+import org.jboss.internal.soa.esb.services.registry.JAXRConnectionFactory;
+import org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.addressing.eprs.LogicalEPR;
+import org.jboss.soa.esb.services.registry.Registry;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.RegistryFactory;
+import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
+
+
+/**
+ * MBean to manage AOP tests.
+ *
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public class AOPServer implements AOPServerMBean
+{
+ public AOPServer()
+ {
+ System.out.println("AOP test MBean deployed") ;
+ }
+
+ public String verifyScoutPerformanceIssue()
+ throws JAXRException, ConfigurationException
+ {
+ return new TestScoutRegistryImpl().checkService() ;
+ }
+
+ public String verifyScoutPerformanceIssue2()
+ throws JAXRException, ConfigurationException
+ {
+ return new TestScoutRegistryImpl().checkServiceFromBusinessService() ;
+ }
+
+ public String verifyJUDDICDataIssue()
+ throws RegistryException, MarshalException, ServiceNotFoundException
+ {
+ final Registry registry = RegistryFactory.getRegistry() ;
+ final String category = "DummyAOPCategory" ;
+ final String serviceName = "DummyAOPServiceName" ;
+ final String serviceDescription = "Dummy AOP Service Description" ;
+ final LogicalEPR epr = new LogicalEPR(category, serviceName) ;
+ for (char name = 'a' ; name <= 'z' ; name++)
+ {
+ final String val = new String(new char[] {name}) ;
+ epr.getAddr().addExtension(val, val) ;
+ }
+ final String eprAsXML = EPRHelper.toXMLString(epr) ;
+ final String heuristic = verifyHeuristic(eprAsXML) ;
+ if (heuristic != null)
+ {
+ return null ;
+ }
+
+ final String eprDescription = "Dummy AOP EPR Description" ;
+
+ registry.registerEPR(category, serviceName, serviceDescription, epr, eprDescription) ;
+ try
+ {
+ registry.findEPR(category, serviceName) ;
+ }
+ catch (final Throwable th)
+ {
+ final StringWriter sw = new StringWriter() ;
+ final PrintWriter pw = new PrintWriter(sw) ;
+ th.printStackTrace(pw) ;
+ pw.flush() ;
+ return sw.toString() ;
+ }
+
+ return null ;
+ }
+
+ public String verifyServiceRetrieval()
+ throws RegistryException
+ {
+ final Registry registry = RegistryFactory.getRegistry() ;
+ final List<String> services = registry.findAllServices() ;
+ if ((services == null) || (services.size() == 0))
+ {
+ return "No services returned from query" ;
+ }
+ return null ;
+ }
+
+ public String verifyOrganizationalStructure()
+ throws RegistryException, JAXRException, ConfigurationException
+ {
+ final Organization jbossESBOrganization = JAXRRegistryImpl.findOrganization("Red Hat/JBossESB", new JAXRConnectionFactory());
+ final Collection<Service> services = jbossESBOrganization.getServices() ;
+ if ((services != null) & (services.size() > 0))
+ {
+ return "Services returned in organization information" ;
+ }
+ return null ;
+ }
+
+ public String verifyJuddiPerformanceIssue()
+ throws JAXRException, ConfigurationException, org.apache.ws.scout.registry.RegistryException
+ {
+ return new TestScoutRegistryImpl().checkServiceNestedBindings() ;
+ }
+
+ private String verifyHeuristic(final String value)
+ {
+ final char[] contents = value.toCharArray() ;
+ final int numChars = contents.length ;
+ int counter = 0 ;
+ for(int index = 0 ; index < numChars ; index++)
+ {
+ final char ch = contents[index] ;
+ if ((ch == '<') || (ch == '&'))
+ {
+ counter++;
+ }
+ }
+ if ((numChars > 32) && (counter > 5) &&
+ (((counter * 100) / numChars) > 1))
+ {
+ return null ;
+ }
+ else
+ {
+ return "Heuristic failure" ;
+ }
+ }
+
+ private static final class TestScoutRegistryImpl extends JAXRRegistryImpl
+ {
+ public TestScoutRegistryImpl()
+ throws ConfigurationException
+ {
+ }
+
+ public String checkService()
+ throws JAXRException, ConfigurationException
+ {
+ final Service service = findService("JBossESB-Internal", "DeadLetterService") ;
+
+ if (service == null)
+ {
+ return "Service not found" ;
+ }
+
+ final ScoutConnectionFactory scoutConnectionFactory = new ScoutConnectionFactory() ;
+ final Connection connection = scoutConnectionFactory.getConnection();
+ try
+ {
+ final RegistryService rs = connection.getRegistryService();
+ final BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ final BulkResponse bulkResponse = bqm.findServiceBindings(service.getKey(),null,null,null);
+ if (bulkResponse.getStatus()!=JAXRResponse.STATUS_SUCCESS)
+ {
+ return "findServiceBindings failed" ;
+ }
+ final Collection<ServiceBinding> serviceBindings = (Collection<ServiceBinding>)bulkResponse.getCollection();
+ if ((serviceBindings == null) || (serviceBindings.size() == 0))
+ {
+ return "could not find service bindings for DeadLetterService" ;
+ }
+
+ for(ServiceBinding serviceBinding: serviceBindings)
+ {
+ final Service bindingService = serviceBinding.getService() ;
+ if (bindingService == null)
+ {
+ return "Could not find service associated with binding" ;
+ }
+ final Collection<ServiceBinding> nestedServiceBindings = (Collection<ServiceBinding>)bindingService.getServiceBindings();
+ if ((nestedServiceBindings != null) && (nestedServiceBindings.size() > 0))
+ {
+ return "Nested service contains service bindings for DeadLetterService" ;
+ }
+ }
+
+ return null ;
+ }
+ finally
+ {
+ scoutConnectionFactory.closeConnection(connection) ;
+ }
+ }
+
+ public String checkServiceFromBusinessService()
+ throws JAXRException, ConfigurationException
+ {
+ final String serviceKey ;
+ {
+ final Service service = findService("JBossESB-Internal", "DeadLetterService") ;
+
+ if (service == null)
+ {
+ return "Service not found" ;
+ }
+ serviceKey = service.getKey().getId() ;
+ }
+
+ final ScoutConnectionFactory scoutConnectionFactory = new ScoutConnectionFactory() ;
+ final Connection connection = scoutConnectionFactory.getConnection();
+ try
+ {
+ final RegistryService rs = connection.getRegistryService();
+ final BusinessQueryManager bqm = rs.getBusinessQueryManager();
+ final Service registryService = (Service)bqm.getRegistryObject(serviceKey, LifeCycleManager.SERVICE) ;
+ if (registryService == null)
+ {
+ return "Failed to obtain service as registry object" ;
+ }
+
+ if (registryService.getSubmittingOrganization() != null)
+ {
+ return "FAILED: Submitting organization is present in service binding" ;
+ }
+ if (!(registryService instanceof ServiceImpl))
+ {
+ return "Binding service is not a ServiceImpl, need to change the test" ;
+ }
+ final ServiceImpl serviceImpl = (ServiceImpl)registryService ;
+ if (serviceImpl.getSubmittingOrganizationKey() == null)
+ {
+ return "FAILED: Submitting organization key is not present in service binding" ;
+ }
+
+ final Field field ;
+ try
+ {
+ field = serviceImpl.getClass().getDeclaredField("org") ;
+ }
+ catch (final NoSuchFieldException nsfe)
+ {
+ return "Could not locate org field" ;
+ }
+ field.setAccessible(true) ;
+ try
+ {
+ try
+ {
+ if (field.get(serviceImpl) != null)
+ {
+ return "FAILED: Organization is present in service binding" ;
+ }
+ }
+ catch (final IllegalAccessException iae)
+ {
+ return "FAILED: Could not access org field in current service" ;
+ }
+ }
+ finally
+ {
+ field.setAccessible(false) ;
+ }
+
+ return null ;
+ }
+ finally
+ {
+ scoutConnectionFactory.closeConnection(connection) ;
+ }
+ }
+
+ public String checkServiceNestedBindings()
+ throws JAXRException, ConfigurationException, org.apache.ws.scout.registry.RegistryException
+ {
+ final String serviceKey ;
+ {
+ final Service service = findService("JBossESB-Internal", "DeadLetterService") ;
+
+ if (service == null)
+ {
+ return "Service not found" ;
+ }
+ serviceKey = service.getKey().getId() ;
+ }
+
+ final IRegistry registry ;
+ final ScoutConnectionFactory scoutConnectionFactory = new ScoutConnectionFactory() ;
+ final Connection connection = scoutConnectionFactory.getConnection();
+ try
+ {
+ final Field field ;
+ try
+ {
+ field = connection.getClass().getDeclaredField("registry") ;
+ }
+ catch (final NoSuchFieldException nsfe)
+ {
+ return "Could not locate org field" ;
+ }
+ field.setAccessible(true) ;
+ try
+ {
+ final Object registryImpl ;
+ try
+ {
+ registryImpl = field.get(connection) ;
+ }
+ catch (final IllegalAccessException iae)
+ {
+ return "FAILED: Could not access org field in current service" ;
+ }
+ if (registryImpl == null)
+ {
+ return "FAILED: Registry implementation is null" ;
+ }
+ if (!(registryImpl instanceof IRegistry))
+ {
+ return "FAILED: Registry implementation is not of correct type";
+ }
+ registry = (IRegistry)registryImpl ;
+ }
+ finally
+ {
+ field.setAccessible(false) ;
+ }
+
+ final ServiceDetail serviceDetail = registry.getServiceDetail(serviceKey) ;
+ final BusinessService[] businessServiceArray = serviceDetail.getBusinessServiceArray() ;
+ if (businessServiceArray == null)
+ {
+ return "FAILED: no business services returned from registry" ;
+ }
+ for (BusinessService businessService: businessServiceArray)
+ {
+ final BindingTemplates bindingTemplates = businessService.getBindingTemplates() ;
+ final BindingTemplate[] bindingTemplateArray = bindingTemplates.getBindingTemplateArray() ;
+ for (BindingTemplate bindingTemplate: bindingTemplateArray)
+ {
+ final TModelInstanceDetails tModelInstanceDetails = bindingTemplate.getTModelInstanceDetails() ;
+ if (tModelInstanceDetails == null)
+ {
+ return "FAILED: Missing tModelInstanceDetails returned from registry" ;
+ }
+ final TModelInstanceInfo[] tModelInstanceInfoArray = tModelInstanceDetails.getTModelInstanceInfoArray() ;
+ if ((tModelInstanceInfoArray != null) && (tModelInstanceInfoArray.length > 0))
+ {
+ return "FAILED: tModelInstanceInfo set, must have come from the database. Should be hidden by AOP" ;
+ }
+ }
+ }
+ }
+ finally
+ {
+ scoutConnectionFactory.closeConnection(connection) ;
+ }
+ return null ;
+ }
+ }
+
+ private static class ScoutConnectionFactory extends JAXRConnectionFactory
+ {
+ public ScoutConnectionFactory()
+ throws ConfigurationException
+ {
+ }
+
+ public Connection getConnection()
+ {
+ return super.getConnection() ;
+ }
+
+ public void closeConnection(Connection connection)
+ {
+ super.closeConnection(connection) ;
+ }
+ }
+}
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.server.aop;
-
-import javax.xml.registry.JAXRException;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
-
-/**
- * MBean to manage AOP tests.
- *
- * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
- */
-public interface AOPServerMBean
-{
- public static final String OBJECT_NAME="jboss.esb:test=AOPServer" ;
-
- public String verifyScoutPerformanceIssue()
- throws JAXRException, ConfigurationException ;
-
- public String verifyScoutPerformanceIssue2()
- throws JAXRException, ConfigurationException ;
-
- public String verifyJUDDICDataIssue()
- throws RegistryException, MarshalException, ServiceNotFoundException ;
-
- public String verifyServiceRetrieval()
- throws RegistryException ;
-
- public String verifyOrganizationalStructure()
- throws RegistryException, JAXRException, ConfigurationException ;
-}
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPServerMBean.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.server.aop;
+
+import javax.xml.registry.JAXRException;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
+
+/**
+ * MBean to manage AOP tests.
+ *
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public interface AOPServerMBean
+{
+ public static final String OBJECT_NAME="jboss.esb:test=AOPServer" ;
+
+ public String verifyScoutPerformanceIssue()
+ throws JAXRException, ConfigurationException ;
+
+ public String verifyScoutPerformanceIssue2()
+ throws JAXRException, ConfigurationException ;
+
+ public String verifyJUDDICDataIssue()
+ throws RegistryException, MarshalException, ServiceNotFoundException ;
+
+ public String verifyServiceRetrieval()
+ throws RegistryException ;
+
+ public String verifyOrganizationalStructure()
+ throws RegistryException, JAXRException, ConfigurationException ;
+
+ public String verifyJuddiPerformanceIssue()
+ throws JAXRException, ConfigurationException, org.apache.ws.scout.registry.RegistryException ;
+}
Deleted: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java
===================================================================
--- labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java 2010-05-07 12:04:17 UTC (rev 32778)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -1,142 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.server.aop;
-
-import javax.management.ObjectName;
-
-import junit.framework.Test;
-
-import org.jboss.test.JBossTestCase;
-
-/**
- * Test asynchronous callbacks for jBPM processes.
- *
- * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
- */
-public class AOPUnitTest extends JBossTestCase
-{
- /**
- * The name of the deployment archive.
- */
- private static final String SAR_ARCHIVE = "aop-test.sar" ;
-
- /**
- * Construct the test case with the specified name.
- * @param name The name of the test case.
- */
- public AOPUnitTest(final String name)
- {
- super(name) ;
- }
-
- /**
- * Test for scout performance issue.
- * @throws Exception For any failures.
- */
- public void testScoutPerformanceIssue()
- throws Exception
- {
- final String result = (String)execute("verifyScoutPerformanceIssue", null, null) ;
- if (result != null)
- {
- fail(result) ;
- }
- }
-
- /**
- * Test for second scout performance issue.
- * @throws Exception For any failures.
- */
- public void testScoutPerformanceIssue2()
- throws Exception
- {
- final String result = (String)execute("verifyScoutPerformanceIssue2", null, null) ;
- if (result != null)
- {
- fail(result) ;
- }
- }
-
- /**
- * Test for juddi CDATA issue..
- * @throws Exception For any failures.
- */
- public void testJUDDICDataIssue()
- throws Exception
- {
- final String result = (String)execute("verifyJUDDICDataIssue", null, null) ;
- if (result != null)
- {
- fail(result) ;
- }
- }
-
- /**
- * Test service retrieval.
- * @throws Exception For any failures.
- */
- public void testServiceRetrievalIssue()
- throws Exception
- {
- final String result = (String)execute("verifyServiceRetrieval", null, null) ;
- if (result != null)
- {
- fail(result) ;
- }
- }
-
- /**
- * Test for scout performance issue.
- * @throws Exception For any failures.
- */
- public void testOrganizationalStructureIssue()
- throws Exception
- {
- final String result = (String)execute("verifyOrganizationalStructure", null, null) ;
- if (result != null)
- {
- fail(result) ;
- }
- }
-
- /**
- * Execute the specified method on the mbean.
- * @param method The method name.
- * @param values The parmeter values.
- * @param types The parameter types.
- * @return The method return value.
- * @throws Exception For errors during invocation.
- */
- private Object execute(final String method, final Object[] values, final String[] types)
- throws Exception
- {
- return getServer().invoke(new ObjectName(AOPServerMBean.OBJECT_NAME), method, values, types) ;
- }
-
- /**
- * Create the test suite.
- * @return The suite representing this test case.
- */
- public static Test suite()
- throws Exception
- {
- return getDeploySetup(AOPUnitTest.class, SAR_ARCHIVE);
- }
-}
Copied: labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java (from rev 32779, labs/jbossesb/workspace/platform/JBESB_4_4_SOA_4_3_GA/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java)
===================================================================
--- labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java (rev 0)
+++ labs/jbossesb/workspace/platform/soa_tags/JBESB_4_4_SOA_4_3_CP4_1059293/qa/junit/src/org/jboss/soa/esb/server/aop/AOPUnitTest.java 2010-08-04 17:33:42 UTC (rev 34523)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.server.aop;
+
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test asynchronous callbacks for jBPM processes.
+ *
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public class AOPUnitTest extends JBossTestCase
+{
+ /**
+ * The name of the deployment archive.
+ */
+ private static final String SAR_ARCHIVE = "aop-test.sar" ;
+
+ /**
+ * Construct the test case with the specified name.
+ * @param name The name of the test case.
+ */
+ public AOPUnitTest(final String name)
+ {
+ super(name) ;
+ }
+
+ /**
+ * Test for scout performance issue.
+ * @throws Exception For any failures.
+ */
+ public void testScoutPerformanceIssue()
+ throws Exception
+ {
+ final String result = (String)execute("verifyScoutPerformanceIssue", null, null) ;
+ if (result != null)
+ {
+ fail(result) ;
+ }
+ }
+
+ /**
+ * Test for second scout performance issue.
+ * @throws Exception For any failures.
+ */
+ public void testScoutPerformanceIssue2()
+ throws Exception
+ {
+ final String result = (String)execute("verifyScoutPerformanceIssue2", null, null) ;
+ if (result != null)
+ {
+ fail(result) ;
+ }
+ }
+
+ /**
+ * Test for juddi performance issue, retrieving details bindings while acquiring service.
+ * @throws Exception For any failures.
+ */
+ public void testJuddiPerformanceIssue()
+ throws Exception
+ {
+ final String result = (String)execute("verifyJuddiPerformanceIssue", null, null) ;
+ if (result != null)
+ {
+ fail(result) ;
+ }
+ }
+
+ /**
+ * Test for juddi CDATA issue..
+ * @throws Exception For any failures.
+ */
+ public void testJUDDICDataIssue()
+ throws Exception
+ {
+ final String result = (String)execute("verifyJUDDICDataIssue", null, null) ;
+ if (result != null)
+ {
+ fail(result) ;
+ }
+ }
+
+ /**
+ * Test service retrieval.
+ * @throws Exception For any failures.
+ */
+ public void testServiceRetrievalIssue()
+ throws Exception
+ {
+ final String result = (String)execute("verifyServiceRetrieval", null, null) ;
+ if (result != null)
+ {
+ fail(result) ;
+ }
+ }
+
+ /**
+ * Test for scout performance issue.
+ * @throws Exception For any failures.
+ */
+ public void testOrganizationalStructureIssue()
+ throws Exception
+ {
+ final String result = (String)execute("verifyOrganizationalStructure", null, null) ;
+ if (result != null)
+ {
+ fail(result) ;
+ }
+ }
+
+ /**
+ * Execute the specified method on the mbean.
+ * @param method The method name.
+ * @param values The parmeter values.
+ * @param types The parameter types.
+ * @return The method return value.
+ * @throws Exception For errors during invocation.
+ */
+ private Object execute(final String method, final Object[] values, final String[] types)
+ throws Exception
+ {
+ return getServer().invoke(new ObjectName(AOPServerMBean.OBJECT_NAME), method, values, types) ;
+ }
+
+ /**
+ * Create the test suite.
+ * @return The suite representing this test case.
+ */
+ public static Test suite()
+ throws Exception
+ {
+ return getDeploySetup(AOPUnitTest.class, SAR_ARCHIVE);
+ }
+}
More information about the jboss-svn-commits
mailing list