[jboss-cvs] JBossAS SVN: r60523 - in projects/jaxr/trunk: src/main/org/jboss/jaxr/juddi and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 13 17:16:57 EST 2007
Author: thomas.diesler at jboss.com
Date: 2007-02-13 17:16:56 -0500 (Tue, 13 Feb 2007)
New Revision: 60523
Removed:
projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/WS4EEJUDDIServlet.java
projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/transport/WS4EESaajTransport.java
Modified:
projects/jaxr/trunk/pom.xml
projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/JUDDIService.java
projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/transport/SaajTransport.java
Log:
Remove ws4ee stuff
Modified: projects/jaxr/trunk/pom.xml
===================================================================
--- projects/jaxr/trunk/pom.xml 2007-02-13 22:05:59 UTC (rev 60522)
+++ projects/jaxr/trunk/pom.xml 2007-02-13 22:16:56 UTC (rev 60523)
@@ -1,196 +1,198 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>jboss</groupId>
- <artifactId>jboss-jaxr</artifactId>
- <packaging>jar</packaging>
- <version>1.0.0</version>
- <name>JBoss Registry</name>
- <url>http://labs.jboss.org/portal/jbossws/</url>
- <description>JBoss JAXR</description>
- <licenses>
- <license>
- <name>lgpl</name>
- <url>http://repository.jboss.com/licenses/lgpl.txt</url>
- </license>
- </licenses>
- <organization>
- <name>JBoss Inc.</name>
- <url>http://www.jboss.org</url>
- </organization>
- <repositories>
- <repository>
- <id>jboss</id>
- <name>JBoss Inc. Repository</name>
- <layout>default</layout>
- <url>http://repository.jboss.com/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>jbosspluginrepo</id>
- <name>jboss plugin repository</name>
- <url>http://repository.jboss.com/maven2</url>
- <layout>default</layout>
- <snapshots>
- <enabled>false</enabled>
- <updatePolicy>never</updatePolicy>
- </snapshots>
- </pluginRepository>
- <pluginRepository>
- <id>Maven Snapshots</id>
- <url>http://snapshots.maven.codehaus.org/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- </pluginRepository>
- <pluginRepository>
- <id>LSU ibiblio</id>
- <url>http://ibiblio.lsu.edu/main/pub/packages/maven2/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- </pluginRepository>
- </pluginRepositories>
- <build>
- <sourceDirectory>src/main</sourceDirectory>
- <finalName>${artifactId}</finalName>
- <outputDirectory>output/classes</outputDirectory>
- <plugins>
- <!-- define how we want compilation to take place
- here, we accept most of the defaults but say that we want the
- optimization flag set, and define the source and target to be 1.4,
- these setting will be inherited by child projects -->
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <optimize>true</optimize>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <!-- define that we wish to create src jars -->
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <version>2.0</version>
- <inherited>true</inherited>
- <executions>
- <execution>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <!-- handle the retrieval and unpacking of dependencies
- required for the sar -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>dependency-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack-jboss</id>
- <phase>process-classes</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>jboss</groupId>
- <artifactId>jboss</artifactId>
- <version>5.0-SNAPSHOT</version>
- <type>jar</type>
- <outputDirectory>
- ${project.build.directory}/dependencies</outputDirectory>
- </artifactItem>
- </artifactItems>
- <outputDirectory>
- ${project.build.directory}</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <jarName>jboss-jaxr</jarName>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.1</version>
- <configuration>
- <archive>
- <addMavenDescriptor>false</addMavenDescriptor>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <inherited>true</inherited>
- <executions>
- <execution>
- <id>buildjar</id>
- <phase>package</phase>
- <configuration>
- <tasks>
- <mkdir dir="${basedir}/output/lib"/>
-
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <version>2.0.2.GA</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <version>2.0.2.GA</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>juddi</groupId>
- <artifactId>juddi</artifactId>
- <version>0.9RC4</version>
- </dependency>
- <dependency>
- <groupId>scout</groupId>
- <artifactId>scout</artifactId>
- <version>0.7rc2</version>
- </dependency>
- </dependencies>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jaxr</artifactId>
+ <packaging>jar</packaging>
+ <version>1.0.0</version>
+ <name>JBoss Registry</name>
+ <url>http://labs.jboss.org/portal/jbossws/</url>
+ <description>JBoss JAXR</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+ <repositories>
+ <repository>
+ <id>jboss</id>
+ <name>JBoss Inc. Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.com/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>jbosspluginrepo</id>
+ <name>jboss plugin repository</name>
+ <url>http://repository.jboss.com/maven2</url>
+ <layout>default</layout>
+ <snapshots>
+ <enabled>false</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </pluginRepository>
+ <pluginRepository>
+ <id>Maven Snapshots</id>
+ <url>http://snapshots.maven.codehaus.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </pluginRepository>
+ <pluginRepository>
+ <id>LSU ibiblio</id>
+ <url>http://ibiblio.lsu.edu/main/pub/packages/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+ <build>
+ <sourceDirectory>src/main</sourceDirectory>
+ <finalName>${artifactId}</finalName>
+ <outputDirectory>output/classes</outputDirectory>
+ <plugins>
+ <!-- define how we want compilation to take place
+ here, we accept most of the defaults but say that we want the
+ optimization flag set, and define the source and target to be 1.4,
+ these setting will be inherited by child projects -->
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <optimize>true</optimize>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ <!-- define that we wish to create src jars -->
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.0</version>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <!-- handle the retrieval and unpacking of dependencies
+ required for the sar -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>dependency-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack-jboss</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>jboss</groupId>
+ <artifactId>jboss</artifactId>
+ <version>5.0-SNAPSHOT</version>
+ <type>jar</type>
+ <outputDirectory> ${project.build.directory}/dependencies</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory> ${project.build.directory}</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <jarName>jboss-jaxr</jarName>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.1</version>
+ <configuration>
+ <archive>
+ <addMavenDescriptor>false</addMavenDescriptor>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <id>buildjar</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${basedir}/output/lib"/>
+
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>apache-scout</groupId>
+ <artifactId>scout</artifactId>
+ <version>0.7rc2</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>2.0.2.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <version>2.0.2.GA</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>juddi</groupId>
+ <artifactId>juddi</artifactId>
+ <version>0.9RC4</version>
+ </dependency>
+ <dependency>
+ <groupId>sun-servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
Modified: projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/JUDDIService.java
===================================================================
--- projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/JUDDIService.java 2007-02-13 22:05:59 UTC (rev 60522)
+++ projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/JUDDIService.java 2007-02-13 22:16:56 UTC (rev 60523)
@@ -36,417 +36,376 @@
import java.sql.SQLException;
import java.sql.Statement;
-
/**
- * A JBoss MBean for the JUDDI Service
- * MBean for the JUDDI open source project integrated as part of the JAXR requirements
- * for J2EE 1.4 compliance
- *
+ * A JBoss MBean for the JUDDI Service MBean for the JUDDI open source project
+ * integrated as part of the JAXR requirements for J2EE 1.4 compliance
+ *
* @author <mailto:Anil.Saldhana at jboss.org>Anil Saldhana
* extends="org.jboss.system.ServiceMBean"
* @since Nov 8, 2004
*/
-public class JUDDIService extends ServiceMBeanSupport
- implements JUDDIServiceMBean
-{
- protected boolean dropOnStart = false;
- protected boolean createOnStart = false;
- protected boolean dropOnStop = false;
- protected boolean loadNAICS = false;
- protected boolean loadUNSPSC = false;
+public class JUDDIService extends ServiceMBeanSupport implements
+ JUDDIServiceMBean {
+ protected boolean dropOnStart = false;
- protected DataSource datasource = null;
+ protected boolean createOnStart = false;
- protected String datasourceurl = null;
+ protected boolean dropOnStop = false;
- protected String registryOperator = null;
+ protected boolean loadNAICS = false;
- protected String bindJaxr = null;
- protected boolean shouldBindJaxr = true;
- protected boolean dropDB = false;
+ protected boolean loadUNSPSC = false;
- private boolean jndiAlreadyBound = false;
+ protected DataSource datasource = null;
- protected Connection getConnection()
- throws SQLException, NamingException
- {
- try
- {
- if (datasource == null)
- {
- InitialContext ctx = new InitialContext();
- Object obj = ctx.lookup(datasourceurl);
- log.debug(obj.getClass().getName());
- datasource = (DataSource) obj;
- }//end if
- } catch (Exception e)
- {
- e.printStackTrace();
- log.error(e);
- }
- return datasource.getConnection();
- }
+ protected String datasourceurl = null;
- protected void runDrop()
- throws SQLException, IOException
- {
- log.debug("JUDDIService: Inside runDrop");
+ protected String registryOperator = null;
- locateAndRunScript("juddi_drop_db.ddl");
- log.debug("JUDDIService: Exit runDrop");
- }
+ protected String bindJaxr = null;
- protected void runCreate()
- throws SQLException, IOException
- {
- log.debug("JUDDIService: Inside runCreate");
- locateAndRunScript("juddi_create_db.ddl");
- locateAndRunScript("juddi_data.ddl");
- }
+ protected boolean shouldBindJaxr = true;
- private void locateAndRunScript(String name)
- throws SQLException, IOException
- {
- log.debug("JUDDIService: Inside locateScript");
- InputStream input =
- getClass().getClassLoader().getResourceAsStream("META-INF/ddl/" + name);
- if (input != null)
- {
- try
- {
- runScript(input);
- } finally
- {
- input.close();
- }
- }
- }
+ protected boolean dropDB = false;
- protected void runScript(InputStream stream)
- throws SQLException, IOException
- {
- boolean firstError = true;
- BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+ private boolean jndiAlreadyBound = false;
- Connection connection = null;
- try
- {
- connection = this.getConnection();
- if (connection != null)
- log.debug("Obtained the Connection");
- Statement statement = connection.createStatement();
- try
- {
- String nextStatement = "";
- String nextLine;
- while ((nextLine = reader.readLine()) != null)
- {
- log.debug("Statement Obtained=" + nextLine);
- nextLine = nextLine.trim();
- if (nextLine.indexOf("--") != -1) continue;
- int semicolon = nextLine.indexOf(";");
- if (semicolon != -1)
- {
- nextStatement += nextLine.substring(0, semicolon);
- try
- {
- log.debug("Statement to execute:" + nextStatement);
- statement.execute(nextStatement);
- } catch (SQLException e)
- {
- String err = "Could not execute a statement of juddi script::";
+ protected Connection getConnection() throws SQLException, NamingException {
+ try {
+ if (datasource == null) {
+ InitialContext ctx = new InitialContext();
+ Object obj = ctx.lookup(datasourceurl);
+ log.debug(obj.getClass().getName());
+ datasource = (DataSource) obj;
+ }// end if
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error(e);
+ }
+ return datasource.getConnection();
+ }
- if (firstError)
- {
- log.debug(err + e.getLocalizedMessage() + " " + nextStatement);
- log.debug("Your settings are:dropOnStart =" + dropOnStart + ";createOnStart =" + createOnStart);
- log.debug("dropOnStop = " + dropOnStop);
+ protected void runDrop() throws SQLException, IOException {
+ log.debug("JUDDIService: Inside runDrop");
- firstError = false;
- }
- }
- nextStatement = nextLine.substring(semicolon + 1);
- } else
- {
- nextStatement += nextLine;
- }
- }
- if (!nextStatement.equals(""))
- {
- try
- {
- log.debug("Statement to execute:" + nextStatement);
- statement.execute(nextStatement);
- } catch (SQLException e)
- {
- log.debug("Could not execute last statement of a juddi init script: " + e.getLocalizedMessage());
- log.debug("Your settings are:dropOnStart =" + dropOnStart + ";createOnStart =" + createOnStart);
- log.debug("dropOnStop = " + dropOnStop);
- }
- }
- } finally
- {
- if (statement != null) statement.close();
- }
- } catch (NamingException nm)
- {
- log.error("Looks like DataSource was tried with the wrong JNDI name");
- log.error(nm);
- } finally
- {
- if (connection != null) connection.close();
- }
- }
+ locateAndRunScript("juddi_drop_db.ddl");
+ log.debug("JUDDIService: Exit runDrop");
+ }
- /**
- * starts the jUDDI service
- */
- public void startService() throws Exception
- {
- log.debug("JUDDIService: Inside startService with dropOnStart="
- + dropOnStart + " createOnStart=" + createOnStart);
- if (shouldBindJaxr && !jndiAlreadyBound)
- {
- bindJAXRConnectionFactory();
- }
+ protected void runCreate() throws SQLException, IOException {
+ log.debug("JUDDIService: Inside runCreate");
+ locateAndRunScript("juddi_create_db.ddl");
+ locateAndRunScript("juddi_data.ddl");
+ }
- if (dropOnStart)
- {
- runDrop();
- }
- if (createOnStart)
- {
- runCreate();
- }
- }
+ private void locateAndRunScript(String name) throws SQLException,
+ IOException {
+ log.debug("JUDDIService: Inside locateScript");
+ InputStream input = getClass().getClassLoader().getResourceAsStream(
+ "META-INF/ddl/" + name);
+ if (input != null) {
+ try {
+ runScript(input);
+ } finally {
+ input.close();
+ }
+ }
+ }
- /**
- * stop the service
- */
- public void stopService()
- throws Exception
- {
- log.debug("JUDDIService: Inside stopService with dropOnStop=" + dropOnStop);
- if (dropOnStop)
- {
- runDrop();
- }
- unBindJAXRConnectionFactory();
- }
+ protected void runScript(InputStream stream) throws SQLException,
+ IOException {
+ boolean firstError = true;
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(stream));
+ Connection connection = null;
+ try {
+ connection = this.getConnection();
+ if (connection != null)
+ log.debug("Obtained the Connection");
+ Statement statement = connection.createStatement();
+ try {
+ String nextStatement = "";
+ String nextLine;
+ while ((nextLine = reader.readLine()) != null) {
+ log.debug("Statement Obtained=" + nextLine);
+ nextLine = nextLine.trim();
+ if (nextLine.indexOf("--") != -1)
+ continue;
+ int semicolon = nextLine.indexOf(";");
+ if (semicolon != -1) {
+ nextStatement += nextLine.substring(0, semicolon);
+ try {
+ log.debug("Statement to execute:" + nextStatement);
+ statement.execute(nextStatement);
+ } catch (SQLException e) {
+ String err = "Could not execute a statement of juddi script::";
- /**
- * @return boolean
- */
- public boolean isDropOnStart()
- {
- return dropOnStart;
- }
+ if (firstError) {
+ log.debug(err + e.getLocalizedMessage() + " "
+ + nextStatement);
+ log.debug("Your settings are:dropOnStart ="
+ + dropOnStart + ";createOnStart ="
+ + createOnStart);
+ log.debug("dropOnStop = " + dropOnStop);
- /**
- * Sets the dropOnStart.
- *
- * @param dropOnStart The dropOnStart to set
- */
- public void setDropOnStart(boolean dropOnStart)
- {
- this.dropOnStart = dropOnStart;
- }
+ firstError = false;
+ }
+ }
+ nextStatement = nextLine.substring(semicolon + 1);
+ } else {
+ nextStatement += nextLine;
+ }
+ }
+ if (!nextStatement.equals("")) {
+ try {
+ log.debug("Statement to execute:" + nextStatement);
+ statement.execute(nextStatement);
+ } catch (SQLException e) {
+ log
+ .debug("Could not execute last statement of a juddi init script: "
+ + e.getLocalizedMessage());
+ log.debug("Your settings are:dropOnStart ="
+ + dropOnStart + ";createOnStart ="
+ + createOnStart);
+ log.debug("dropOnStop = " + dropOnStop);
+ }
+ }
+ } finally {
+ if (statement != null)
+ statement.close();
+ }
+ } catch (NamingException nm) {
+ log
+ .error("Looks like DataSource was tried with the wrong JNDI name");
+ log.error(nm);
+ } finally {
+ if (connection != null)
+ connection.close();
+ }
+ }
- /**
- * @return boolean
- */
- public boolean isDropOnStop()
- {
- return dropOnStop;
- }
+ /**
+ * starts the jUDDI service
+ */
+ public void startService() throws Exception {
+ log.debug("JUDDIService: Inside startService with dropOnStart="
+ + dropOnStart + " createOnStart=" + createOnStart);
+ if (shouldBindJaxr && !jndiAlreadyBound) {
+ bindJAXRConnectionFactory();
+ }
- /**
- * Sets the dropOnStop.
- *
- * @param dropOnStop The dropOnStop to set
- */
- public void setDropOnStop(boolean dropOnStop)
- {
- this.dropOnStop = dropOnStop;
- }
+ if (dropOnStart) {
+ runDrop();
+ }
+ if (createOnStart) {
+ runCreate();
+ }
+ }
- /**
- * @return boolean
- */
- public boolean isCreateOnStart()
- {
- return createOnStart;
- }
+ /**
+ * stop the service
+ */
+ public void stopService() throws Exception {
+ log.debug("JUDDIService: Inside stopService with dropOnStop="
+ + dropOnStop);
+ if (dropOnStop) {
+ runDrop();
+ }
+ unBindJAXRConnectionFactory();
+ }
- /**
- * Sets the createOnStart.
- *
- * @param createOnStart The createOnStart to set
- */
- public void setCreateOnStart(boolean createOnStart)
- {
- this.createOnStart = createOnStart;
- }
+ /**
+ * @return boolean
+ */
+ public boolean isDropOnStart() {
+ return dropOnStart;
+ }
- /**
- * @return String
- */
- public String getDataSource()
- {
- return datasourceurl;
- }
+ /**
+ * Sets the dropOnStart.
+ *
+ * @param dropOnStart
+ * The dropOnStart to set
+ */
+ public void setDropOnStart(boolean dropOnStart) {
+ this.dropOnStart = dropOnStart;
+ }
- /**
- * Sets the Datasource Url.
- *
- * @param ds The datasourceurl to set
- */
- public void setDataSourceUrl(String ds)
- {
- this.datasourceurl = ds;
- }
+ /**
+ * @return boolean
+ */
+ public boolean isDropOnStop() {
+ return dropOnStop;
+ }
- /**
- * @return String
- */
- public String getRegistryOperator()
- {
- return registryOperator;
- }
+ /**
+ * Sets the dropOnStop.
+ *
+ * @param dropOnStop
+ * The dropOnStop to set
+ */
+ public void setDropOnStop(boolean dropOnStop) {
+ this.dropOnStop = dropOnStop;
+ }
- /**
- * Sets the RegistryOperator.
- *
- * @param ro The datasourceurl to set
- */
- public void setRegistryOperator(String ro)
- {
- this.registryOperator = ro;
- }
+ /**
+ * @return boolean
+ */
+ public boolean isCreateOnStart() {
+ return createOnStart;
+ }
- /**
- * gets the JAXR ConnectionFactory.
- */
- public String getBindJaxr()
- {
- return bindJaxr;
- }
+ /**
+ * Sets the createOnStart.
+ *
+ * @param createOnStart
+ * The createOnStart to set
+ */
+ public void setCreateOnStart(boolean createOnStart) {
+ this.createOnStart = createOnStart;
+ }
+ /**
+ * @return String
+ */
+ public String getDataSource() {
+ return datasourceurl;
+ }
- /**
- * Sets the JAXR ConnectionFactory.
- *
- * @param str The context to bind the Jaxr factory to set
- */
- public void setBindJaxr(String str)
- {
- this.bindJaxr = str;
+ /**
+ * Sets the Datasource Url.
+ *
+ * @param ds
+ * The datasourceurl to set
+ */
+ public void setDataSourceUrl(String ds) {
+ this.datasourceurl = ds;
+ }
- if(this.shouldBindJaxr)
- {
- bindJAXRConnectionFactory();
- }
- }
+ /**
+ * @return String
+ */
+ public String getRegistryOperator() {
+ return registryOperator;
+ }
+ /**
+ * Sets the RegistryOperator.
+ *
+ * @param ro
+ * The datasourceurl to set
+ */
+ public void setRegistryOperator(String ro) {
+ this.registryOperator = ro;
+ }
- /**
- * gets the JAXR ConnectionFactory.
- */
- public boolean getShouldBindJaxr()
- {
- return shouldBindJaxr;
- }
+ /**
+ * gets the JAXR ConnectionFactory.
+ */
+ public String getBindJaxr() {
+ return bindJaxr;
+ }
- /**
- * Sets the JAXR ConnectionFactory.
- *
- * @param str Should a Jaxr Connection Factory bound
- */
- public void setShouldBindJaxr(boolean str)
- {
- this.shouldBindJaxr = str;
- if (shouldBindJaxr)
- {
- bindJAXRConnectionFactory();
- }
- }
+ /**
+ * Sets the JAXR ConnectionFactory.
+ *
+ * @param str
+ * The context to bind the Jaxr factory to set
+ */
+ public void setBindJaxr(String str) {
+ this.bindJaxr = str;
- /**
- * gets the JAXR ConnectionFactory.
- */
- public boolean getDropDB()
- {
- return dropDB;
- }
+ if (this.shouldBindJaxr) {
+ bindJAXRConnectionFactory();
+ }
+ }
- /**
- * Sets the JAXR ConnectionFactory.
- *
- * @param b Should a Jaxr Connection Factory bound
- */
- public void setDropDB(boolean b)
- {
- this.dropDB = b;
- try
- {
- if (datasource != null) this.runDrop();
- } catch (Exception e)
- {
- log.error(e.toString());
- }
- }
+ /**
+ * gets the JAXR ConnectionFactory.
+ */
+ public boolean getShouldBindJaxr() {
+ return shouldBindJaxr;
+ }
- private void bindJAXRConnectionFactory()
- {
- if( this.bindJaxr == null || jndiAlreadyBound ) return;//We will wait for it to be set
+ /**
+ * Sets the JAXR ConnectionFactory.
+ *
+ * @param str
+ * Should a Jaxr Connection Factory bound
+ */
+ public void setShouldBindJaxr(boolean str) {
+ this.shouldBindJaxr = str;
+ if (shouldBindJaxr) {
+ bindJAXRConnectionFactory();
+ }
+ }
- //Bind a ConnectionFactory object to JNDI
- InitialContext ctx = null;
- try
- {
- ctx = new InitialContext();
- } catch (NamingException e)
- {
- log.error("JNDI InitialContext Failed");
- e.printStackTrace();
- }
- ConnectionFactory factory = (ConnectionFactory) ConnectionFactoryImpl.newInstance();
+ /**
+ * gets the JAXR ConnectionFactory.
+ */
+ public boolean getDropDB() {
+ return dropDB;
+ }
- try
- {
- ctx.rebind(bindJaxr, factory);
- jndiAlreadyBound = true;
- } catch (NamingException e)
- {
- log.error("JNDI Bind Failed:" + bindJaxr);
- e.printStackTrace();
- }
+ /**
+ * Sets the JAXR ConnectionFactory.
+ *
+ * @param b
+ * Should a Jaxr Connection Factory bound
+ */
+ public void setDropDB(boolean b) {
+ this.dropDB = b;
+ try {
+ if (datasource != null)
+ this.runDrop();
+ } catch (Exception e) {
+ log.error(e.toString());
+ }
+ }
- }
+ private void bindJAXRConnectionFactory() {
+ if (this.bindJaxr == null || jndiAlreadyBound)
+ return;// We will wait for it to be set
- private void unBindJAXRConnectionFactory()
- {
- if( this.bindJaxr == null || jndiAlreadyBound ) return;//We will wait for it to be set
+ // Bind a ConnectionFactory object to JNDI
+ InitialContext ctx = null;
+ try {
+ ctx = new InitialContext();
+ } catch (NamingException e) {
+ log.error("JNDI InitialContext Failed");
+ e.printStackTrace();
+ }
+ ConnectionFactory factory = (ConnectionFactory) ConnectionFactoryImpl
+ .newInstance();
- //Bind a ConnectionFactory object to JNDI
- InitialContext ctx = null;
- try
- {
- ctx = new InitialContext();
- } catch (NamingException e)
- {
- log.error("JNDI InitialContext Failed");
- e.printStackTrace();
- }
- try
- {
- ctx.unbind(bindJaxr);
- } catch (NamingException e)
- {
- //Ignore
- }
+ try {
+ ctx.rebind(bindJaxr, factory);
+ jndiAlreadyBound = true;
+ } catch (NamingException e) {
+ log.error("JNDI Bind Failed:" + bindJaxr);
+ e.printStackTrace();
+ }
- }
-}
+ }
+ private void unBindJAXRConnectionFactory() {
+ if (this.bindJaxr == null || jndiAlreadyBound)
+ return;// We will wait for it to be set
+
+ // Bind a ConnectionFactory object to JNDI
+ InitialContext ctx = null;
+ try {
+ ctx = new InitialContext();
+ } catch (NamingException e) {
+ log.error("JNDI InitialContext Failed");
+ e.printStackTrace();
+ }
+ try {
+ ctx.unbind(bindJaxr);
+ } catch (NamingException e) {
+ // Ignore
+ }
+
+ }
+}
Deleted: projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/WS4EEJUDDIServlet.java
===================================================================
--- projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/WS4EEJUDDIServlet.java 2007-02-13 22:05:59 UTC (rev 60522)
+++ projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/WS4EEJUDDIServlet.java 2007-02-13 22:16:56 UTC (rev 60523)
@@ -1,368 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jaxr.juddi;
-
-import org.apache.juddi.IRegistry;
-import org.apache.juddi.datatype.RegistryObject;
-import org.apache.juddi.datatype.response.DispositionReport;
-import org.apache.juddi.datatype.response.ErrInfo;
-import org.apache.juddi.datatype.response.Result;
-import org.apache.juddi.error.BusyException;
-import org.apache.juddi.error.FatalErrorException;
-import org.apache.juddi.error.RegistryException;
-import org.apache.juddi.error.UnsupportedException;
-import org.apache.juddi.handler.HandlerMaker;
-import org.apache.juddi.handler.IHandler;
-import org.apache.juddi.registry.RegistryEngine;
-import org.apache.juddi.registry.RegistryServlet;
-import org.apache.juddi.util.Config;
-import org.apache.juddi.util.xml.XMLUtils;
-import org.jboss.logging.Logger;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.soap.Detail;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFactory;
-import javax.xml.soap.SOAPFault;
-import javax.xml.soap.SOAPMessage;
-import java.io.IOException;
-import java.util.Vector;
-
-/**
- * Servlet that represents the JUDDI Registry
- * Used with the Axis based stack in JBoss
- * @author <mailto:Anil.Saldhana at jboss.org>Anil Saldhana
- * @since May 18, 2005
- */
-public class WS4EEJUDDIServlet extends HttpServlet
-{
- // XML Document Builder
- private static DocumentBuilder docBuilder = null;
-
- // jUDDI XML Handler maker
- private static HandlerMaker maker = HandlerMaker.getInstance();
-
- private static Logger log = Logger.getLogger(WS4EEJUDDIServlet.class);
-
- /**
- *
- */
- public void doGet(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException
- {
- res.setHeader("Allow", "POST");
- res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The request " +
- "method 'GET' is not allowed by UDDI API.");
- }
-
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException
- {
- res.setContentType("text/xml; charset=utf-8");
-
- SOAPMessage soapReq = null;
- SOAPMessage soapRes = null;
-
- try
- {
-
- MessageFactory msgFactory = MessageFactory.newInstance();
- soapReq = msgFactory.createMessage(null, req.getInputStream());
- soapRes = msgFactory.createMessage();
-
- SOAPBody soapReqBody = soapReq.getSOAPBody();
- Element uddiReq = (Element) soapReqBody.getFirstChild();
- if (uddiReq == null)
- throw new FatalErrorException("A UDDI request was not " +
- "found in the SOAP message.");
-
- String function = uddiReq.getLocalName();
- if ((function == null) || (function.trim().length() == 0))
- throw new FatalErrorException("The name of the UDDI request " +
- "could not be identified.");
- IHandler requestHandler = maker.lookup(function);
- if (requestHandler == null)
- throw new UnsupportedException("The UDDI request " +
- "type specified is unknown: " + function);
-
- String generic = uddiReq.getAttribute("generic");
- if (generic == null)
- throw new FatalErrorException("A UDDI generic attribute " +
- "value was not found for UDDI request: " + function + " (The " +
- "'generic' attribute must be present)");
- else if (!generic.equals(IRegistry.UDDI_V2_GENERIC))
- throw new UnsupportedException("Currently only UDDI v2 " +
- "requests are supported. The generic attribute value " +
- "received was: " + generic);
-
- // Unmarshal the raw xml into the appropriate jUDDI
- // request object.
-
- RegistryObject uddiReqObj = requestHandler.unmarshal(uddiReq);
-
- // Grab a reference to the shared jUDDI registry
- // instance (make sure it's running) and execute the
- // requested UDDI function.
-
- RegistryObject uddiResObj = null;
- RegistryEngine registry = RegistryServlet.getRegistry();
- if ((registry != null) && (registry.isAvailable()))
- uddiResObj = registry.execute(uddiReqObj);
- else
- throw new BusyException("The Registry is currently unavailable.");
-
- // Lookup the appropriate response handler which will
- // be used to marshal the UDDI object into the appropriate
- // xml format.
-
- IHandler responseHandler = maker.lookup(uddiResObj.getClass().getName());
- if (responseHandler == null)
- throw new FatalErrorException("The response object " +
- "type is unknown: " + uddiResObj.getClass().getName());
-
- // Create a new 'temp' XML element to use as a container
- // in which to marshal the UDDI response data into.
-
- DocumentBuilder docBuilder = getDocumentBuilder();
- Document document = docBuilder.newDocument();
- Element element = document.createElement("temp");
-
- // Lookup the appropriate response handler and marshal
- // the juddi object into the appropriate xml format (we
- // only support UDDI v2.0 at this time). Attach the
- // results to the body of the SOAP response.
-
- responseHandler.marshal(uddiResObj, element);
- log.debug(XMLUtils.toString((Element) element.getFirstChild()));
-
- // Grab a reference to the 'temp' element's
- // only child here (this has the effect of
- // discarding the temp element) and append
- // this child to the soap response body
-
- /*document.appendChild(element.getFirstChild());
- soapRes.getSOAPBody().addDocument(document);*/
- SOAPBody soapBody = soapRes.getSOAPBody();
- Element el = (Element) element.getFirstChild();
- soapBody.addChildElement(this.getSOAPElement(soapBody, el));
- } catch (Exception ex) // Catch ALL exceptions
- {
- // SOAP Fault values
- String faultCode = null;
- String faultString = null;
- String faultActor = null;
-
- // UDDI DispositionReport values
- String errno = null;
- String errCode = null;
- String errMsg = null;
-
- if (ex instanceof RegistryException)
- {
-
- log.error(ex.getMessage());
-
- RegistryException rex = (RegistryException) ex;
-
- faultCode = rex.getFaultCode(); // SOAP Fault faultCode
- faultString = rex.getFaultString(); // SOAP Fault faultString
- faultActor = rex.getFaultActor(); // SOAP Fault faultActor
-
- DispositionReport dispRpt = rex.getDispositionReport();
- if (dispRpt != null)
- {
- Result result = null;
- ErrInfo errInfo = null;
-
- Vector results = dispRpt.getResultVector();
- if ((results != null) && (!results.isEmpty()))
- result = (Result) results.elementAt(0);
-
- if (result != null)
- {
- errno = String.valueOf(result.getErrno()); // UDDI Result errno
- errInfo = result.getErrInfo();
-
- if (errInfo != null)
- {
- errCode = errInfo.getErrCode(); // UDDI ErrInfo errCode
- errMsg = errInfo.getErrMsg(); // UDDI ErrInfo errMsg
- }
- }
- }
- } else
- {
-
- log.error(ex.getMessage(), ex);
-
- faultCode = "Server";
- faultString = ex.getMessage();
- faultActor = null;
-
-
- errno = String.valueOf(Result.E_FATAL_ERROR);
- errCode = Result.lookupErrCode(Result.E_FATAL_ERROR);
- errMsg = Result.lookupErrText(Result.E_FATAL_ERROR);
- }
-
- try
- {
- SOAPBody soapResBody = soapRes.getSOAPBody();
- SOAPFault soapFault = soapResBody.addFault();
- soapFault.setFaultCode(faultCode);
- soapFault.setFaultString(faultString);
- soapFault.setFaultActor(faultActor);
-
- Detail faultDetail = soapFault.addDetail();
-
- SOAPElement dispRpt = faultDetail.addChildElement("dispositionReport", "", IRegistry.UDDI_V2_NAMESPACE);
- dispRpt.setAttribute("generic", IRegistry.UDDI_V2_GENERIC);
- dispRpt.setAttribute("operator", Config.getOperator());
-
- SOAPElement result = dispRpt.addChildElement("result");
- result.setAttribute("errno", errno);
-
- SOAPElement errInfo = result.addChildElement("errInfo");
- errInfo.setAttribute("errCode", errCode);
- errInfo.setValue(errMsg);
- } catch (Exception e)
- { // if we end up in here it's just NOT good.
- log.error("A serious error has occured while assembling the SOAP Fault.", e);
- }
- } finally
- {
- try
- {
- soapRes.writeTo(res.getOutputStream());
- } catch (SOAPException sex)
- {
- log.error(sex);
- }
- }
- }
-
- /**
- *
- */
- private DocumentBuilder getDocumentBuilder()
- {
- if (docBuilder == null)
- docBuilder = createDocumentBuilder();
- return docBuilder;
- }
-
- /**
- *
- */
- private synchronized DocumentBuilder createDocumentBuilder()
- {
- if (docBuilder != null)
- return docBuilder;
-
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- //factory.setValidating(true);
-
- docBuilder = factory.newDocumentBuilder();
- } catch (ParserConfigurationException pcex)
- {
- pcex.printStackTrace();
- }
-
- return docBuilder;
- }
-
-
- private SOAPElement getSOAPElement(SOAPBody soapBody, Element elem)
- {
- if (elem == null)
- throw new IllegalArgumentException("Element passed is null");
-
- String xmlns = IRegistry.UDDI_V2_NAMESPACE;
- SOAPElement soapElement = null;
- SOAPFactory factory = null;
- try
- {
- factory = SOAPFactory.newInstance();
- //Go through the element
- String name = elem.getNodeName();
- String nsuri = elem.getNamespaceURI();
- if (nsuri == null)
- nsuri = xmlns;
- soapElement = factory.createElement(name, "ns1", nsuri);
- //Get Attributes
- if (elem.hasAttributes())
- {
- NamedNodeMap nnm = elem.getAttributes();
- int len = nnm != null ? nnm.getLength() : 0;
- for (int i = 0; i < len; i++)
- {
- Node n = nnm.item(i);
- String nodename = n.getNodeName();
- String nodevalue = n.getNodeValue();
- soapElement.addAttribute(factory.createName(nodename), nodevalue);
- }
- } else
- {
- soapElement.addAttribute(factory.createName("xmlns:ns1"), nsuri);
- }
-
- NodeList nlist = elem.getChildNodes();
- int len = nlist != null ? nlist.getLength() : 0;
-
- for (int i = 0; i < len; i++)
- {
- Node node = nlist.item(i);
- short nodeType = node != null ? node.getNodeType() : -100;
- if (Node.ELEMENT_NODE == nodeType)
- {
- soapElement.addChildElement(getSOAPElement(soapBody, (Element) node));
- } else if (nodeType == Node.TEXT_NODE)
- {
- soapElement.addTextNode(node.getNodeValue());
- }
-
- }
- } catch (SOAPException e)
- {
- e.printStackTrace();
- }
- return soapElement;
- }
-
-}
Modified: projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/transport/SaajTransport.java
===================================================================
--- projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/transport/SaajTransport.java 2007-02-13 22:05:59 UTC (rev 60522)
+++ projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/transport/SaajTransport.java 2007-02-13 22:16:56 UTC (rev 60523)
@@ -39,12 +39,11 @@
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.juddi.IRegistry;
import org.apache.juddi.error.RegistryException;
import org.apache.juddi.proxy.Transport;
import org.apache.juddi.util.xml.XMLUtils;
+import org.jboss.logging.Logger;
import org.jboss.util.xml.DOMWriter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -61,7 +60,7 @@
public class SaajTransport implements Transport
{
// private reference to the jUDDI logger
- private static Log log = LogFactory.getLog(SaajTransport.class);
+ private static Logger log = Logger.getLogger(SaajTransport.class);
/**
* @see Transport#send(org.w3c.dom.Element, java.net.URL)
Deleted: projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/transport/WS4EESaajTransport.java
===================================================================
--- projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/transport/WS4EESaajTransport.java 2007-02-13 22:05:59 UTC (rev 60522)
+++ projects/jaxr/trunk/src/main/org/jboss/jaxr/juddi/transport/WS4EESaajTransport.java 2007-02-13 22:16:56 UTC (rev 60523)
@@ -1,241 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jaxr.juddi.transport;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.juddi.IRegistry;
-import org.apache.juddi.error.RegistryException;
-import org.apache.juddi.proxy.Transport;
-import org.apache.juddi.util.xml.XMLUtils;
-import org.jboss.util.xml.DOMWriter;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPBody;
-import javax.xml.soap.SOAPConnection;
-import javax.xml.soap.SOAPConnectionFactory;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFactory;
-import javax.xml.soap.SOAPFault;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.soap.SOAPPart;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.ByteArrayOutputStream;
-import java.net.URL;
-
-/**
- * Transport based on SAAJ
- * Used for the Axis based stack
- *
- * @author Anil Saldhana (anil at apache.org)
- */
-public class WS4EESaajTransport implements Transport
-{
- // private reference to the jUDDI logger
- private static Log log = LogFactory.getLog(WS4EESaajTransport.class);
-
- private String debugProp = System.getProperty("jaxr.debug","false");
-
- public Element send(Element request, URL endpointURL)
- throws RegistryException
- {
- log.debug("Request message:" + XMLUtils.toString(request));
- if("true".equalsIgnoreCase(debugProp))
- System.out.println("Request Element:" + XMLUtils.toString(request));
-
- Element response = null;
- try
- {
- MessageFactory msgFactory = MessageFactory.newInstance();
- SOAPMessage message = msgFactory.createMessage();
- message.getSOAPHeader().detachNode();
- SOAPPart soapPart = message.getSOAPPart();
- SOAPBody soapBody = soapPart.getEnvelope().getBody();
- soapBody.addChildElement(getSOAPElement(soapBody, request));
- //There seems to be a bug in the Saaj/Axis implementation that requires
- //message to be written to an output stream
- ByteArrayOutputStream by = new ByteArrayOutputStream();
- message.writeTo(by); //Does not do anything
- by.close();
- if("true".equalsIgnoreCase(debugProp))
- message.writeTo(System.out);
-
- //Make the SAAJ Call now
- SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
- SOAPConnection connection = soapConnectionFactory.createConnection();
- SOAPMessage soapResponse = connection.call(message, endpointURL);
- if("true".equalsIgnoreCase(debugProp))
- {
- System.out.println("Response is:");
- soapResponse.writeTo(System.out);
- }
-
- soapBody = soapResponse.getSOAPBody();
- boolean hasFault = soapBody.hasFault();
- if(hasFault)
- {
- SOAPFault soapFault = soapBody.getFault();
- String faultStr = soapFault.getFaultCode() + "::" + soapFault.getFaultString();
- throw new RegistryException(faultStr);
- }
- response = getFirstChildElement(soapBody);
- } catch (Exception ex)
- {
- ex.printStackTrace();
- log.error(ex);
- throw new RegistryException(ex);
- }
-
- log.debug("Response message:" + XMLUtils.getText(response));
-
-
- return response;
- }
-
- public String send(String request, URL endpointURL)
- throws RegistryException
- {
- Element reqEl = getElement(request);
- Element respEl = this.send(reqEl, endpointURL);
- StringWriter sw = new StringWriter();
-
- DOMWriter dw = new DOMWriter(sw);
- dw.print(respEl);
- return sw.toString();
- //return XMLUtils.toString(respEl);
- }
-
- private SOAPElement getSOAPElement(SOAPBody soapBody, Element elem)
- {
- String xmlns = IRegistry.UDDI_V2_NAMESPACE;
- SOAPElement soapElement = null;
- SOAPFactory factory = null;
- try
- {
- factory = SOAPFactory.newInstance();
- //Go through the element
- String name = elem.getNodeName();
- String nsuri = elem.getNamespaceURI();
- if (nsuri == null)
- nsuri = xmlns;
- soapElement = factory.createElement(name, "ns1", nsuri);
- //Get Attributes
- if (elem.hasAttributes())
- {
- NamedNodeMap nnm = elem.getAttributes();
- int len = nnm != null ? nnm.getLength() : 0;
- for (int i = 0; i < len; i++)
- {
- Node n = nnm.item(i);
- String nodename = n.getNodeName();
- String nodevalue = n.getNodeValue();
- soapElement.addAttribute(factory.createName(nodename), nodevalue);
- }
- } else
- {
- soapElement.addAttribute(factory.createName("xmlns:ns1"), nsuri);
- }
-
- NodeList nlist = elem.getChildNodes();
- int len = nlist != null ? nlist.getLength() : 0;
-
- for (int i = 0; i < len; i++)
- {
- Node node = nlist.item(i);
- short nodeType = node != null ? node.getNodeType() : -100;
- if (Node.ELEMENT_NODE == nodeType)
- {
- soapElement.addChildElement(getSOAPElement(soapBody, (Element) node));
- } else if (nodeType == Node.TEXT_NODE)
- {
- soapElement.addTextNode(node.getNodeValue());
- }
-
- }
- } catch (SOAPException e)
- {
- e.printStackTrace();
- }
- return soapElement;
- }
-
- public static Element getElement(String xmlFrag)
- {
- Document doc = null;
- Element reqElement = null;
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(xmlFrag)));
- reqElement = doc.getDocumentElement();
- } catch (SAXException e)
- {
- e.printStackTrace();
- } catch (IOException e)
- {
- e.printStackTrace();
- } catch (ParserConfigurationException e)
- {
- e.printStackTrace();
- }
-
- return reqElement;
-
- }
-
- public Element getFirstChildElement(Element el)
- {
- return getFirstChildElement(el, null);
- }
-
- /**
- * Return the first child element for a givenname
- */
- public Element getFirstChildElement(Element el, String tagName)
- {
- Element childEl = null;
- NodeList nlist = el != null ? el.getChildNodes() : null;
- int len = nlist != null ? nlist.getLength() : 0;
- for (int i = 0; childEl == null && i < len; i++)
- {
- Node node = nlist.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- if (tagName == null || tagName.equals(node.getLocalName()))
- childEl = (Element) node;
- }
- }
- return childEl;
- }
-}
More information about the jboss-cvs-commits
mailing list