Return-Path: Delivered-To: apmail-ws-wsrf-commits-archive@www.apache.org Received: (qmail 39543 invoked from network); 26 Aug 2005 22:09:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Aug 2005 22:09:30 -0000 Received: (qmail 5861 invoked by uid 500); 26 Aug 2005 22:09:30 -0000 Delivered-To: apmail-ws-wsrf-commits-archive@ws.apache.org Received: (qmail 5837 invoked by uid 500); 26 Aug 2005 22:09:29 -0000 Mailing-List: contact wsrf-commits-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: wsrf-dev@ws.apache.org Delivered-To: mailing list wsrf-commits@ws.apache.org Received: (qmail 5824 invoked by uid 500); 26 Aug 2005 22:09:29 -0000 Delivered-To: apmail-ws-wsrf-cvs@ws.apache.org Received: (qmail 5821 invoked by uid 99); 26 Aug 2005 22:09:29 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 26 Aug 2005 15:09:28 -0700 Received: (qmail 39536 invoked by uid 65534); 26 Aug 2005 22:09:28 -0000 Message-ID: <20050826220928.39535.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r240353 - in /webservices/wsrf/trunk/src/java/org/apache/ws: resource/handler/axis/ util/j2ee/ util/jsr109/ util/platform/axis/tool/ Date: Fri, 26 Aug 2005 22:09:27 -0000 To: wsrf-cvs@ws.apache.org From: ips@apache.org X-Mailer: svnmailer-1.0.3 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: ips Date: Fri Aug 26 15:09:22 2005 New Revision: 240353 URL: http://svn.apache.org/viewcvs?rev=240353&view=rev Log: Ant tasks for merging web.xml and webservices.xml DDs Added: webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/ webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/WebDDMergeTask.java webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/WebservicesDDMergeTask.java Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/axis/ResourceProvider.java webservices/wsrf/trunk/src/java/org/apache/ws/util/jsr109/DummyEndpoint.java webservices/wsrf/trunk/src/java/org/apache/ws/util/jsr109/DummyEndpointImpl.java webservices/wsrf/trunk/src/java/org/apache/ws/util/platform/axis/tool/WsddUpdater.java Modified: webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/axis/ResourceProvider.java URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/axis/ResourceProvider.java?rev=240353&r1=240352&r2=240353&view=diff ============================================================================== --- webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/axis/ResourceProvider.java (original) +++ webservices/wsrf/trunk/src/java/org/apache/ws/resource/handler/axis/ResourceProvider.java Fri Aug 26 15:09:22 2005 @@ -46,7 +46,7 @@ import java.util.List; /** - * LOG-DONE Axis provider that dispatches requests to WS-Resources. + * An Axis provider that dispatches requests to WS-Resources. * * @author Ian Springer, Sal Campana */ Added: webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/WebDDMergeTask.java URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/WebDDMergeTask.java?rev=240353&view=auto ============================================================================== --- webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/WebDDMergeTask.java (added) +++ webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/WebDDMergeTask.java Fri Aug 26 15:09:22 2005 @@ -0,0 +1,211 @@ +/*=============================================================================* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *=============================================================================*/ +package org.apache.ws.util.j2ee; + +import noNamespace.ServletMappingType; +import noNamespace.ServletType; +import noNamespace.WebAppDocument; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.types.FileSet; +import org.apache.xmlbeans.XmlOptions; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * An Ant task that merges one or more source J2EE web.xml's into a target web.xml. + */ +public class WebDDMergeTask extends Task +{ + + private List m_sourceFiles = new ArrayList(); + private File m_targetFile; + + public WebDDMergeTask() + { + initContextClassLoader(); + } + + /** + * Adds the specified file to the list of source web.xml's. + * + * @param srcFile + */ + public void setSourceFile( File srcFile ) + { + m_sourceFiles.add( srcFile ); + } + + /** + * Adds the files in the specified fileset to the list of source web.xml's. + * + * @param fileSet DOCUMENT_ME + */ + public void addConfiguredSourceFiles( FileSet fileSet ) + { + File baseDir = fileSet.getDir( getProject() ); + DirectoryScanner dirScanner = fileSet.getDirectoryScanner( getProject() ); + String[] includedFiles = dirScanner.getIncludedFiles(); + for ( int i = 0; i < includedFiles.length; i++ ) + { + m_sourceFiles.add( new File( baseDir, includedFiles[i] ) ); + } + } + + /** + * Sets the target web.xml (i.e. the web.xml to be merged into). + * + * @param targetFile + */ + public void setTargetFile( File targetFile ) + { + m_targetFile = targetFile; + } + + /** + * DOCUMENT_ME + * + * @throws org.apache.tools.ant.BuildException + * DOCUMENT_ME + */ + public void execute() + throws BuildException + { + if ( m_sourceFiles.isEmpty() ) + { + throw new BuildException( "No source web.xml files were specified!" ); + } + try + { + System.out.println( "Loading target web-app document from " + m_targetFile + " ..." ); + WebAppDocument targetWebAppDoc = parseWebXmlFile( m_targetFile ); + WebAppDocument.WebApp targetWebApp = targetWebAppDoc.getWebApp(); + for ( int i = 0; i < m_sourceFiles.size(); i++ ) + { + mergeWebXml( (File) m_sourceFiles.get( i ), targetWebApp ); + } + saveTargetDocToFile( targetWebAppDoc ); + } + catch ( Exception e ) + { + throw new BuildException( e ); + } + } + + private WebAppDocument parseWebXmlFile( File ddFile ) + throws Exception + { + XmlOptions loadOptions = new XmlOptions().setLoadStripWhitespace(); + return WebAppDocument.Factory.parse( ddFile, loadOptions ); + } + + private void saveTargetDocToFile( WebAppDocument doc ) + throws IOException + { + System.out.println( "Saving updated target web-app document to " + m_targetFile + " ..." ); + XmlOptions saveOptions = new XmlOptions().setSavePrettyPrint(); + doc.save( m_targetFile, saveOptions ); + } + + private void mergeWebXml( File srcFile, WebAppDocument.WebApp targetWebApp ) throws Exception + { + System.out.println( "Merging " + srcFile + " into target web-app document ..." ); + WebAppDocument webAppDoc = parseWebXmlFile( srcFile ); + WebAppDocument.WebApp webApp = webAppDoc.getWebApp(); + mergeServletElements( webApp, targetWebApp ); + mergeServletMappingElements( webApp, targetWebApp ); + } + + private void mergeServletElements( WebAppDocument.WebApp webApp, WebAppDocument.WebApp targetWebApp ) + { + ServletType[] servletArray = webApp.getServletArray(); + ServletType[] targetServletArray = targetWebApp.getServletArray(); + for ( int i = 0; i < servletArray.length; i++ ) + { + ServletType servlet = servletArray[i]; + String servletName = servlet.getServletName().getStringValue(); + ServletType targetServlet = getServlet( targetServletArray, servletName ); + if ( targetServlet == null ) + { + targetServlet = targetWebApp.addNewServlet(); + } + targetServlet.set( servlet ); + } + } + + private void mergeServletMappingElements( WebAppDocument.WebApp webApp, WebAppDocument.WebApp targetWebApp ) + { + ServletMappingType[] servletMappingArray = webApp.getServletMappingArray(); + ServletMappingType[] targetServletMappingArray = targetWebApp.getServletMappingArray(); + for ( int i = 0; i < servletMappingArray.length; i++ ) + { + ServletMappingType servletMapping = servletMappingArray[i]; + String servletName = servletMapping.getServletName().getStringValue(); + String urlPattern = servletMapping.getUrlPattern().getStringValue(); + ServletMappingType targetServletMapping = getServletMapping( targetServletMappingArray, servletName, + urlPattern ); + if ( targetServletMapping == null ) + { + targetServletMapping = targetWebApp.addNewServletMapping(); + } + targetServletMapping.set( servletMapping ); + } + } + + private ServletType getServlet( ServletType[] servletArray, + String servletName ) + { + ServletType servlet = null; + for ( int j = 0; j < servletArray.length; j++ ) + { + if ( servletArray[j].getServletName().getStringValue().equals( servletName ) ) + { + servlet = servletArray[j]; + break; + } + } + return servlet; + } + + private ServletMappingType getServletMapping( ServletMappingType[] servletMappingArray, String servletName, + String urlPattern ) + { + ServletMappingType servletMapping = null; + for ( int j = 0; j < servletMappingArray.length; j++ ) + { + if ( servletMappingArray[j].getServletName().getStringValue().equals( servletName ) && + servletMappingArray[j].getUrlPattern().getStringValue().equals( urlPattern ) ) + { + servletMapping = servletMappingArray[j]; + break; + } + } + return servletMapping; + } + + private void initContextClassLoader() + { + if ( Thread.currentThread().getContextClassLoader() == null ) + { + Thread.currentThread().setContextClassLoader( Task.class.getClassLoader() ); + } + } + +} Added: webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/WebservicesDDMergeTask.java URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/WebservicesDDMergeTask.java?rev=240353&view=auto ============================================================================== --- webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/WebservicesDDMergeTask.java (added) +++ webservices/wsrf/trunk/src/java/org/apache/ws/util/j2ee/WebservicesDDMergeTask.java Fri Aug 26 15:09:22 2005 @@ -0,0 +1,175 @@ +/*=============================================================================* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *=============================================================================*/ +package org.apache.ws.util.j2ee; + +import com.sun.java.xml.ns.j2Ee.WebserviceDescriptionType; +import com.sun.java.xml.ns.j2Ee.WebservicesDocument; +import com.sun.java.xml.ns.j2Ee.WebservicesType; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.types.FileSet; +import org.apache.xmlbeans.XmlOptions; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * An Ant task that merges one or more source J2EE webservices.xml's into a target webservices.xml. + */ +public class WebservicesDDMergeTask extends Task +{ + + private List m_sourceFiles = new ArrayList(); + private File m_targetFile; + + public WebservicesDDMergeTask() + { + initContextClassLoader(); + } + + /** + * Adds the specified file to the list of source web.xml's. + * + * @param srcFile + */ + public void setSourceFile( File srcFile ) + { + m_sourceFiles.add( srcFile ); + } + + /** + * Adds the files in the specified fileset to the list of source web.xml's. + * + * @param fileSet DOCUMENT_ME + */ + public void addConfiguredSourceFiles( FileSet fileSet ) + { + File baseDir = fileSet.getDir( getProject() ); + DirectoryScanner dirScanner = fileSet.getDirectoryScanner( getProject() ); + String[] includedFiles = dirScanner.getIncludedFiles(); + for ( int i = 0; i < includedFiles.length; i++ ) + { + m_sourceFiles.add( new File( baseDir, includedFiles[i] ) ); + } + } + + /** + * Sets the target web.xml (i.e. the web.xml to be merged into). + * + * @param targetFile + */ + public void setTargetFile( File targetFile ) + { + m_targetFile = targetFile; + } + + /** + * DOCUMENT_ME + * + * @throws org.apache.tools.ant.BuildException + * DOCUMENT_ME + */ + public void execute() + throws BuildException + { + if ( m_sourceFiles.isEmpty() ) + { + throw new BuildException( "No source webservices.xml files were specified!" ); + } + try + { + System.out.println( "Loading target webservices document from " + m_targetFile + " ..." ); + WebservicesDocument targetDdDoc = parseWebservicesXmlFile( m_targetFile ); + WebservicesType targetDd = targetDdDoc.getWebservices(); + for ( int i = 0; i < m_sourceFiles.size(); i++ ) + { + mergeWebservicesDD( (File) m_sourceFiles.get( i ), targetDd ); + } + saveTargetDocToFile( targetDdDoc ); + } + catch ( Exception e ) + { + throw new BuildException( e ); + } + } + + private WebservicesDocument parseWebservicesXmlFile( File ddFile ) + throws Exception + { + XmlOptions loadOptions = new XmlOptions().setLoadStripWhitespace(); + return WebservicesDocument.Factory.parse( ddFile, loadOptions ); + } + + private void saveTargetDocToFile( WebservicesDocument doc ) + throws IOException + { + System.out.println( "Saving updated target webservices document to " + m_targetFile + " ..." ); + XmlOptions saveOptions = new XmlOptions().setSavePrettyPrint(); + doc.save( m_targetFile, saveOptions ); + } + + private void mergeWebservicesDD( File srcFile, WebservicesType targetWebservices ) throws Exception + { + System.out.println( "Merging " + srcFile + " into target webservices document ..." ); + WebservicesDocument ddDoc = parseWebservicesXmlFile( srcFile ); + WebservicesType dd = ddDoc.getWebservices(); + mergeWebserviceDescriptionElements( dd, targetWebservices ); + } + + private void mergeWebserviceDescriptionElements( WebservicesType webservices, WebservicesType targetWebservices ) + { + WebserviceDescriptionType[] wsDescArray = webservices.getWebserviceDescriptionArray(); + WebserviceDescriptionType[] targetWsDescArray = targetWebservices.getWebserviceDescriptionArray(); + for ( int i = 0; i < wsDescArray.length; i++ ) + { + WebserviceDescriptionType wsDesc = wsDescArray[i]; + String wsDescName = wsDesc.getWebserviceDescriptionName().getStringValue(); + WebserviceDescriptionType targetWsDesc = getWebserviceDescription( targetWsDescArray, wsDescName ); + if ( targetWsDesc == null ) + { + targetWsDesc = targetWebservices.addNewWebserviceDescription(); + } + targetWsDesc.set( wsDesc ); + } + } + + private WebserviceDescriptionType getWebserviceDescription( WebserviceDescriptionType[] wsDescArray, + String wsDescName ) + { + WebserviceDescriptionType wsDesc = null; + for ( int i = 0; i < wsDescArray.length; i++ ) + { + if ( wsDescArray[i].getWebserviceDescriptionName().getStringValue().equals( wsDescName ) ) + { + wsDesc = wsDescArray[i]; + break; + } + } + return wsDesc; + } + + private void initContextClassLoader() + { + if ( Thread.currentThread().getContextClassLoader() == null ) + { + Thread.currentThread().setContextClassLoader( Task.class.getClassLoader() ); + } + } + +} Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jsr109/DummyEndpoint.java URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jsr109/DummyEndpoint.java?rev=240353&r1=240352&r2=240353&view=diff ============================================================================== --- webservices/wsrf/trunk/src/java/org/apache/ws/util/jsr109/DummyEndpoint.java (original) +++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jsr109/DummyEndpoint.java Fri Aug 26 15:09:22 2005 @@ -1,24 +1,19 @@ package org.apache.ws.util.jsr109; import java.rmi.Remote; +import java.rmi.RemoteException; /** - * A JSR109 Service Endpoint Interface used for providing a dummy endpoint - * which is mapped in the JSR109 config files for mapping all service requests - * to a single method. - *
- * This interface is used as the service-endpoint-interface entry in the webservices.xml - * and the jaxrpc-mapping.xml files for a JSR109 deployment. - *
- * The implementation may either be a real implementation or simply a dummy - * implementation in the case of using the JAX-RPC handler as the actual endpoint. - *
- * When using the JAX-RPC handler as the endpoint, the JSR109 config files should - * contain an entry for the handler. + * A JSR109 Service Endpoint Interface used for providing a dummy endpoint which is mapped in the JSR109 config files + * for mapping all service requests to a single method.
This interface is used as the service-endpoint-interface + * entry in the webservices.xml and the jaxrpc-mapping.xml files for a JSR109 deployment.
The implementation may + * either be a real implementation or simply a dummy implementation in the case of using the JAX-RPC handler as the + * actual endpoint.
When using the JAX-RPC handler as the endpoint, the JSR109 config files should contain an + * entry for the handler. * * @author Sal Campana */ public interface DummyEndpoint extends Remote { - public javax.xml.soap.SOAPElement processRequest( javax.xml.soap.SOAPElement requestDoc ) throws org.apache.ws.resource.example.filesystem.MountDeviceBusyFaultException, java.rmi.RemoteException ; + public javax.xml.soap.SOAPElement processRequest( javax.xml.soap.SOAPElement requestDoc ) throws RemoteException; } Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/jsr109/DummyEndpointImpl.java URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/jsr109/DummyEndpointImpl.java?rev=240353&r1=240352&r2=240353&view=diff ============================================================================== --- webservices/wsrf/trunk/src/java/org/apache/ws/util/jsr109/DummyEndpointImpl.java (original) +++ webservices/wsrf/trunk/src/java/org/apache/ws/util/jsr109/DummyEndpointImpl.java Fri Aug 26 15:09:22 2005 @@ -1,16 +1,11 @@ package org.apache.ws.util.jsr109; -import org.apache.ws.resource.example.filesystem.MountDeviceBusyFaultException; - import javax.xml.soap.SOAPElement; import java.rmi.RemoteException; - /** - * A dummy Service Endpoint to be configured as the servlet-class in web.xml for a JSR109 deployment - * of the JAX-RPC handler. - *
- * An entry must be made in webservices.xml for the JAX-RPC handler to be registered. The handler will + * A dummy Service Endpoint to be configured as the servlet-class in web.xml for a JSR109 deployment of the JAX-RPC + * handler.
An entry must be made in webservices.xml for the JAX-RPC handler to be registered. The handler will * act as the endpoint for the requests and will always return false, thus never entering this code. * * @author Sal Campana @@ -18,16 +13,18 @@ public class DummyEndpointImpl implements DummyEndpoint { /** - * This method should never be directly invoked and will always throw a RemoteException. - * It is merely a placeholder for the JSR109 configuration. + * This method should never be directly invoked and will always throw a RemoteException. It is merely a placeholder + * for the JSR109 configuration. * * @param requestDoc - * @return null. - * @throws MountDeviceBusyFaultException - * @throws RemoteException + * + * @return nothing; always throws a RemoteException + * + * @throws RemoteException whenever called */ - public SOAPElement processRequest(SOAPElement requestDoc) throws MountDeviceBusyFaultException, RemoteException + public SOAPElement processRequest( SOAPElement requestDoc ) throws RemoteException { - throw new RemoteException("The processRequest method was invoked, you should check webservices.xml and make sure the JAX-RPC handler is configured."); + throw new RemoteException( + "The processRequest method was invoked, you should check webservices.xml and make sure the WSRF JAX-RPC handler is configured." ); } } Modified: webservices/wsrf/trunk/src/java/org/apache/ws/util/platform/axis/tool/WsddUpdater.java URL: http://svn.apache.org/viewcvs/webservices/wsrf/trunk/src/java/org/apache/ws/util/platform/axis/tool/WsddUpdater.java?rev=240353&r1=240352&r2=240353&view=diff ============================================================================== --- webservices/wsrf/trunk/src/java/org/apache/ws/util/platform/axis/tool/WsddUpdater.java (original) +++ webservices/wsrf/trunk/src/java/org/apache/ws/util/platform/axis/tool/WsddUpdater.java Fri Aug 26 15:09:22 2005 @@ -153,6 +153,7 @@ */ public void execute( ) throws BuildException + { if ( m_wsddFiles.isEmpty( ) ) {