Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jbossws/jbossws-cxf
Browse files Browse the repository at this point in the history
  • Loading branch information
asoldano committed Nov 10, 2017
2 parents da65991 + 3a3107d commit b3e1a8f
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
*/
public class WSDLFilePublisher extends AbstractWSDLFilePublisher
{
private static final Object lock= new Object();
private static final String[] wsdlLocationPrefixes = {"vfsfile:", "file:", "jar:", "vfszip:"};

public WSDLFilePublisher(ArchiveDeployment dep)
Expand Down Expand Up @@ -118,24 +119,58 @@ public void publishWsdlFiles(QName serviceName, String wsdlLocation, Bus bus, Li

public void unpublishWsdlFiles()
{
try
String deploymentName = dep.getCanonicalName();

if (deploymentName.startsWith("http://"))
{
File parentDir = new File(serverConfig.getServerDataDir().getCanonicalPath() + "/wsdl");
ArchiveDeployment deployment = dep;
while (deployment.getParent() != null)
{
deployment = deployment.getParent();
}
String deploymentName = deployment.getCanonicalName();
if (deploymentName.startsWith("http://"))
{
deploymentName = deploymentName.replace("http://", "http-");
}
File targetDir = new File(parentDir, deploymentName);
FileUtils.removeDir(targetDir);
deploymentName = deploymentName.replace("http://", "http-");
}
catch (IOException e)
{

try {

File publishDir = new File(serverConfig.getServerDataDir().getCanonicalPath()
+ "/wsdl/" + deploymentName);

File wsdlRoot = new File(serverConfig.getServerDataDir().getCanonicalPath()
+ "/wsdl/");
String wsdlRootDirStr = wsdlRoot.getCanonicalPath();

if (publishDir.exists()) {

List<File> dirList = new ArrayList<>();
getWsdlDirList(publishDir, dirList);
dirList.add(publishDir); // clean up contents in the parent

for (File dir : dirList) {
File[] wsdlFileList = dir.listFiles();
if (wsdlFileList != null) {
for (int i = 0; i < wsdlFileList.length; i++) {
File f = wsdlFileList[i];
FileUtils.delete(f);
if (f.exists()) {
Loggers.DEPLOYMENT_LOGGER.couldNotDeleteWsdlFile(f.getAbsolutePath());
} else {
Loggers.DEPLOYMENT_LOGGER.deletedWsdlFile(f.getAbsolutePath());
}
}
}
}

synchronized(lock) {
File parent = publishDir;
while (!wsdlRootDirStr.equals(parent.getCanonicalPath())) {
if (parent.exists()) {
File[] files = parent.listFiles();
if (files == null || files.length == 0) {
FileUtils.delete(parent);
}
}
parent = parent.getParentFile();
}
}
}

} catch (IOException e) {
Loggers.DEPLOYMENT_LOGGER.couldNotCreateWsdlDataPath();
}
}
Expand Down Expand Up @@ -240,4 +275,21 @@ private String getExpLocation(String wsdlLocation) {
return wsdlLocation.startsWith("vfs:") && wsdlLocation.contains("/") ? wsdlLocation.substring(0, wsdlLocation.lastIndexOf("/") + 1) : "";
}
}

/**
* Depth-first list of directories
* @param dir
* @param dirList
*/
private void getWsdlDirList(File dir, List<File> dirList) {
File[] files = dir.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
getWsdlDirList(files[i], dirList);
dirList.add(files[i]);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ public void cleanup() throws Exception {
}
@Deployment(testable = false, name=EAR_DEPLOYMENT,managed=false)
public static JavaArchive createDeployment3() {

JavaArchive archive1 = ShrinkWrap.create(JavaArchive.class, "jaxws-cxf-jbws3655-ejb.jar");
archive1.addManifest().addClass(org.jboss.test.ws.jaxws.cxf.jbws3655.HelloWSEJBImpl.class);
writeToDisk(archive1);

JavaArchive archive2 = ShrinkWrap.create(JavaArchive.class, "jaxws-cxf-jbws3655-jaxws.jar");
archive2.addManifest()
.addClass(org.jboss.test.ws.jaxws.cxf.jbws3655.HelloRequest.class)
Expand All @@ -82,12 +83,29 @@ public static JavaArchive createDeployment3() {
.addAsManifestResource(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/cxf/jbws3655/META-INF/wsdl/Hello.wsdl"), "wsdl/Hello.wsdl")
.addAsManifestResource(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/cxf/jbws3655/META-INF/wsdl/Hello_schema1.xsd"), "wsdl/Hello_schema1.xsd");
writeToDisk(archive2);


JavaArchive archive3 = ShrinkWrap.create(JavaArchive.class, "jaxws-cxf-jbws3655-goodBy-jaxws.jar");
archive3.addManifest()
.addClass(org.jboss.test.ws.jaxws.cxf.jbws3655.GoodByRequest.class)
.addClass(org.jboss.test.ws.jaxws.cxf.jbws3655.GoodByResponse.class)
.addClass(org.jboss.test.ws.jaxws.cxf.jbws3655.GoodByWs.class)
.addClass(org.jboss.test.ws.jaxws.cxf.jbws3655.GoodByWsImpl.class)
.addAsManifestResource(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/cxf/jbws3655/META-INF/wsdl/GoodBy.wsdl"), "wsdl/GoodBy.wsdl")
.addAsManifestResource(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/cxf/jbws3655/META-INF/wsdl/GoodBy_schema1.xsd"), "wsdl/GoodBy_schema1.xsd");
writeToDisk(archive3);

JavaArchive archive4 = ShrinkWrap.create(JavaArchive.class, "jaxws-cxf-jbws3655-ejb-goodBy.jar");
archive4.addManifest().addClass(org.jboss.test.ws.jaxws.cxf.jbws3655.GoodByWSEJBImpl.class);
writeToDisk(archive4);

JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "jaxws-cxf-jbws3655.ear");
archive.addManifest()
.addAsManifestResource(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/cxf/jbws3655/META-INF/application.xml"))
.addAsResource(new File(JBossWSTestHelper.getTestArchiveDir(), "jaxws-cxf-jbws3655-jaxws.jar"), "lib/jaxws-cxf-jbws3655-jaxws.jar")
.addAsResource(new File(JBossWSTestHelper.getTestArchiveDir(), "jaxws-cxf-jbws3655-ejb.jar"));
.addAsResource(new File(JBossWSTestHelper.getTestArchiveDir(), "jaxws-cxf-jbws3655-goodBy-jaxws.jar"), "lib/jaxws-cxf-jbws3655-goodBy-jaxws.jar")
.addAsResource(new File(JBossWSTestHelper.getTestArchiveDir(), "jaxws-cxf-jbws3655-ejb.jar"))
.addAsResource(new File(JBossWSTestHelper.getTestArchiveDir(), "jaxws-cxf-jbws3655-ejb-goodBy.jar"))
;
return archive;
}

Expand Down Expand Up @@ -115,4 +133,5 @@ private HelloWs getPort(String publishURL) throws Exception
Service service = Service.create(wsdlURL, qname);
return (HelloWs)service.getPort(HelloWs.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jboss.test.ws.jaxws.cxf.jbws3655;

public class GoodByRequest
{
private String input;

public String getInput()
{
return input;
}

public void setInput(String input)
{
this.input = input;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.jboss.test.ws.jaxws.cxf.jbws3655;

import java.util.ArrayList;
import java.util.List;

public class GoodByResponse
{
private List<String> multiGoodBy = new ArrayList<String>();

public List<String> getMultiGoodBy()
{
return multiGoodBy;
}

public void setMultiGoodBy(List<String> multiGoodBy)
{
this.multiGoodBy = multiGoodBy;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.jboss.test.ws.jaxws.cxf.jbws3655;

import org.jboss.ws.api.annotation.WebContext;

import javax.ejb.Stateless;
import javax.jws.WebService;

@Stateless
@WebService(wsdlLocation = "META-INF/wsdl/GoodBy.wsdl",
name = GoodByWs.NAME,
serviceName = GoodByWs.NAME,
targetNamespace = GoodByWs.TARGET_NAMESPACE,
endpointInterface = "org.jboss.test.ws.jaxws.cxf.jbws3655.GoodByWs")
@WebContext(contextRoot = "/jaxws-cxf-jbws3655-goodby", urlPattern = GoodByWs.NAME)
public class GoodByWSEJBImpl implements GoodByWs
{

public GoodByResponse doGoodBy(GoodByRequest request)
{
GoodByResponse response = new GoodByResponse();
response.getMultiGoodBy().add(request.getInput());
response.getMultiGoodBy().add("world");
return response;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.jboss.test.ws.jaxws.cxf.jbws3655;

import javax.jws.WebService;

@WebService(name = GoodByWs.NAME, targetNamespace = GoodByWs.TARGET_NAMESPACE)
public interface GoodByWs
{
public final static String NAME = "GoodByService";

public final static String TARGET_NAMESPACE = "http://goodby/test";

public GoodByResponse doGoodBy(GoodByRequest request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.jboss.test.ws.jaxws.cxf.jbws3655;

import javax.jws.WebService;
@WebService(wsdlLocation = "META-INF/wsdl/GoodBy.wsdl",
name = GoodByWs.NAME,
serviceName = GoodByWs.NAME,
targetNamespace = GoodByWs.TARGET_NAMESPACE,
endpointInterface = "org.jboss.test.ws.jaxws.cxf.jbws3655.GoodByWs")
public class GoodByWsImpl implements GoodByWs
{
public GoodByResponse doGoodBy(GoodByRequest request)
{
GoodByResponse response = new GoodByResponse();
response.getMultiGoodBy().add(request.getInput());
response.getMultiGoodBy().add("world");
return response;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="6" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
<application-name>jbws3655</application-name>
<module>
<ejb>jaxws-cxf-jbws3655-ejb-goodBy.jar</ejb>
</module>
<module>
<ejb>jaxws-cxf-jbws3655-ejb.jar</ejb>
</module>

<library-directory>lib</library-directory>
</application>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="GoodByService"
targetNamespace="http://goodby/test"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://goodby/test"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://goodby/test" schemaLocation="GoodBy_schema1.xsd"/>
</schema>
</wsdl:types>
<wsdl:message name="doGoodBy">
<wsdl:part name="parameters" element="tns:doGoodBy">
</wsdl:part>
</wsdl:message>
<wsdl:message name="doGoodByResponse">
<wsdl:part name="parameters" element="tns:doGoodByResponse">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="GoodByService">
<wsdl:operation name="doGoodBy">
<wsdl:input name="doGoodBy" message="tns:doGoodBy">
</wsdl:input>
<wsdl:output name="doGoodByResponse" message="tns:doGoodByResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="GoodByServiceSoapBinding" type="tns:GoodByService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="doGoodBy">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="doGoodBy">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="doGoodByResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="GoodByService">
<wsdl:port name="GoodByServicePort" binding="tns:GoodByServiceSoapBinding">
<soap:address location="http://localhost:9090/GoodByServicePort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://goodby/test"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified"
targetNamespace="http://goodby/test" version="1.0">
<xs:element name="doGoodBy" type="tns:doGoodBy"/>
<xs:element name="doGoodByResponse" type="tns:doGoodByResponse"/>
<xs:complexType name="doGoodBy">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:goodByRequest"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="goodByRequest">
<xs:sequence>
<xs:element minOccurs="0" name="goodBy" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="doGoodByResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:goodByResponse"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="goodByResponse">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="multiGoodBy" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

0 comments on commit b3e1a8f

Please sign in to comment.