riftsaw SVN: r649 - branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws.
by riftsaw-commits@lists.jboss.org
Author: objectiser
Date: 2010-05-11 06:39:55 -0400 (Tue, 11 May 2010)
New Revision: 649
Modified:
branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DeploymentBuilder.java
branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java
branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java
Log:
Initial mechanism for configuring jaxws handlers and WS-Security (for username authentication) on a web service provided by a BPEL process.
Modified: branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DeploymentBuilder.java
===================================================================
--- branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DeploymentBuilder.java 2010-05-10 15:36:59 UTC (rev 648)
+++ branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/DeploymentBuilder.java 2010-05-11 10:39:55 UTC (rev 649)
@@ -75,6 +75,12 @@
return (
f.getName().endsWith(".wsdl")
|| f.getName().endsWith(".xsd")
+ || f.getName().endsWith(".xml")
+ || f.getName().endsWith(".properties")
+ || f.getName().endsWith(".jks")
+ || f.getName().endsWith(".keystore")
+ || f.getName().endsWith(".pem")
+ || f.getName().endsWith(".chain")
|| f.isDirectory()
);
}
@@ -83,10 +89,69 @@
for(File f : parent.listFiles(filter))
{
if(f.equals(wsdl)) continue;
- copy(f, new File(this.wsdlDir, f.getName()));
+
+ if (f.getName().endsWith(".wsdl") ||
+ f.getName().endsWith(".xsd")) {
+ copy(f, new File(this.wsdlDir, f.getName()));
+ } else {
+ copy(f, new File(this.webInf, f.getName()));
+ }
}
return this;
}
+
+ public DeploymentBuilder setProvider(javax.xml.ws.Provider<?> provider) {
+
+ // Check if jbossws-cxf.xml is present, and if so, updated the provider implementation class attribute
+ File f=new File(this.webInf, "jbossws-cxf.xml");
+
+ if (f.exists()) {
+ FileInputStream fis=null;
+ FileOutputStream fos=null;
+
+ try {
+ fis=new FileInputStream(f);
+
+ byte[] b=new byte[fis.available()];
+ fis.read(b);
+
+ String str=new String(b);
+
+ fis.close();
+ fis = null;
+
+ if (str.indexOf("@provider@") != -1) {
+ fos=new FileOutputStream(f);
+
+ str = str.replaceAll("@provider@", provider.getClass().getName());
+
+ fos.write(str.getBytes());
+
+ fos.flush();
+ fos.close();
+
+ fos = null;
+ } else {
+ // Report error
+ System.err.println("jbossws-cxf.xml file does not contain @provider@ field");
+ }
+
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to copy files", e);
+ } finally {
+ try {
+ if (fis != null) fis.close();
+ } catch (IOException e) {
+ }
+ try {
+ if (fos != null) fos.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ return this;
+ }
public File build()
{
Modified: branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java
===================================================================
--- branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java 2010-05-10 15:36:59 UTC (rev 648)
+++ branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/EndpointManager.java 2010-05-11 10:39:55 UTC (rev 649)
@@ -93,16 +93,16 @@
{
try
{
+
+ // Check if a handler file has been specified
+ File wsdlFile=new File(wsdlRef.getWsdlURL().toURI());
+
+ File handlerFile=new File(wsdlFile.getParentFile(), "jws_handlers.xml");
+
+ if (handlerFile.exists() == false) {
+ handlerFile = null;
+ }
- // create deployment structure (maybe replaced by shrinkwrap)
- File warArchive = new DeploymentBuilder(serverConfig)
- .setEndpoint(metaData.getEndpointId())
- .setWSDL(new File(wsdlRef.getWsdlURL().toURI()))
- .build();
-
- //Deployment deployment = createInMemoryDeployment(endpointId);
- Deployment deployment = createVFSDeployment(warArchive);
-
// generate provider impl
WebServiceProviderFactory providerFactory = new WebServiceProviderFactory();
@@ -112,11 +112,22 @@
metaData.getPortName(),
metaData.getEndpointId(),
wsdlRef,
- classLoader
+ classLoader,
+ handlerFile
);
log.debug("Created dynamic endpoint class " + providerImpl.getClass().getName());
+ // create deployment structure (maybe replaced by shrinkwrap)
+ File warArchive = new DeploymentBuilder(serverConfig)
+ .setEndpoint(metaData.getEndpointId())
+ .setWSDL(wsdlFile)
+ .setProvider(providerImpl)
+ .build();
+
+ //Deployment deployment = createInMemoryDeployment(endpointId);
+ Deployment deployment = createVFSDeployment(warArchive);
+
// Classloading
ClassLoaderFactory clf = new DelegatingClassLoaderFactory(classLoader);
Modified: branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java
===================================================================
--- branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java 2010-05-10 15:36:59 UTC (rev 648)
+++ branches/gbrown/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/ws/WebServiceProviderFactory.java 2010-05-11 10:39:55 UTC (rev 649)
@@ -47,7 +47,8 @@
QName service, String port,
String endpointId,
WSDLReference wsdlRef,
- ClassLoader loader
+ ClassLoader loader,
+ java.io.File handlerFile
)
throws Exception
{
@@ -57,6 +58,7 @@
// Imports
pool.importPackage("java.lang");
pool.importPackage("javax.xml.ws");
+ pool.importPackage("javax.jws");
CtClass stringType = pool.get("java.lang.String");
@@ -141,6 +143,18 @@
attr.addAnnotation(annotation2);
classFile.addAttribute(attr);
+
+
+ // Check if handler chain should be established
+ if (handlerFile != null) {
+ Annotation handlerChain = new Annotation("javax.jws.HandlerChain", constantPool);
+
+ handlerChain.addMemberValue("file",
+ new StringMemberValue("/"+handlerFile.getName(), constantPool));
+
+ attr.addAnnotation(handlerChain);
+ }
+
createStringGetter(impl, stringType, "endpointId", "getEndpointId");
createStringGetter(impl, stringType, "serviceName", "getServiceName");