You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2008/03/31 16:51:42 UTC
svn commit: r643008 [3/4] - in /webservices/axis2/trunk/java/modules:
integration/test-resources/ integration/test-resources/ComplexDataTypes/
integration/test/org/apache/axis2/deployment/ kernel/src/org/apache/axis2/
kernel/src/org/apache/axis2/contex...
Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/WSDL11ToAxisServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/WSDL11ToAxisServiceBuilderTest.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/WSDL11ToAxisServiceBuilderTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/deployment/WSDL11ToAxisServiceBuilderTest.java Mon Mar 31 07:51:35 2008
@@ -19,8 +19,11 @@
package org.apache.axis2.deployment;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder;
+import org.apache.axis2.engine.AxisConfiguration;
import org.custommonkey.xmlunit.XMLTestCase;
import org.custommonkey.xmlunit.XMLUnit;
@@ -44,13 +47,15 @@
WSDL11ToAllAxisServicesBuilder builder = new WSDL11ToAllAxisServicesBuilder(
new FileInputStream(testResourceFile));
AxisService axisService = builder.populateService();
+ ConfigurationContext configContext = ConfigurationContextFactory.createDefaultConfigurationContext();
+ AxisConfiguration axisConfig = configContext.getAxisConfiguration();
+ axisConfig.addService(axisService);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
axisService.printWSDL(baos);
assertXMLEqual(new FileReader(testResourceFile), new StringReader(new String(baos.toByteArray())));
} catch (Exception e) {
System.out.println("Error in WSDL : " + testResourceFile.getName());
System.out.println("Exception: " + e.toString());
- e.printStackTrace();
fail("Caught exception " + e.toString());
} finally {
XMLUnit.setIgnoreWhitespace(false);
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java Mon Mar 31 07:51:35 2008
@@ -71,6 +71,9 @@
public static final String MESSAGE_SCOPE = "message";
public static final String AXIS_BINDING_OPERATION = "AxisBindingOperation";
+
+ public static final String AXIS_BINDING_MESSAGE = "AxisBindingMessage";
+
/**
* To chenge the conetext path from axis2/service to something else
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java Mon Mar 31 07:51:35 2008
@@ -26,6 +26,7 @@
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
import org.apache.axis2.Constants.Configuration;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.addressing.RelatesTo;
@@ -36,6 +37,7 @@
import org.apache.axis2.context.externalize.SafeObjectInputStream;
import org.apache.axis2.context.externalize.SafeObjectOutputStream;
import org.apache.axis2.context.externalize.SafeSerializable;
+import org.apache.axis2.description.AxisBindingMessage;
import org.apache.axis2.description.AxisMessage;
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.description.AxisOperation;
@@ -1539,16 +1541,19 @@
if (LoggingControl.debugLoggingAllowed) {
checkActivateWarning("getEffectivePolicy");
}
- if (axisMessage != null) {
- return axisMessage.getPolicyInclude().getEffectivePolicy();
- }
- if (axisOperation != null) {
- return axisOperation.getPolicyInclude().getEffectivePolicy();
- }
- if (axisService != null) {
- return axisService.getPolicyInclude().getEffectivePolicy();
+
+ AxisBindingMessage bindingMessage =
+ (AxisBindingMessage) getProperty(Constants.AXIS_BINDING_MESSAGE);
+
+ if (bindingMessage != null) {
+ return bindingMessage.getEffectivePolicy();
+ } else {
+ if (axisMessage != null) {
+ return axisMessage.getEffectivePolicy();
+ } else {
+ return null;
+ }
}
- return configurationContext.getAxisConfiguration().getPolicyInclude().getEffectivePolicy();
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java Mon Mar 31 07:51:35 2008
@@ -154,8 +154,8 @@
TAG_POLICY));
if (policyElements != null && policyElements.hasNext()) {
- processPolicyElements(PolicyInclude.AXIS_POLICY, policyElements,
- axisConfig.getPolicyInclude());
+ processPolicyElements(policyElements,
+ axisConfig.getPolicySubject());
}
// processing <wsp:PolicyReference> .. </..> elements
@@ -163,8 +163,8 @@
TAG_POLICY_REF));
if (policyRefElements != null && policyRefElements.hasNext()) {
- processPolicyRefElements(PolicyInclude.AXIS_POLICY, policyElements,
- axisConfig.getPolicyInclude());
+ processPolicyRefElements(policyElements,
+ axisConfig.getPolicySubject());
}
//to process default module versions
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java Mon Mar 31 07:51:35 2008
@@ -158,5 +158,7 @@
String POLICY_NS_URI = Constants.URI_POLICY;
String TAG_POLICY = "Policy";
String TAG_POLICY_REF = "PolicyReference";
-
+
+ String TAG_POLICY_ATTACHMENT = "PolicyAttachment";
+ String TAG_APPLIES_TO = "AppliesTo";
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java Mon Mar 31 07:51:35 2008
@@ -33,6 +33,7 @@
import org.apache.axis2.description.ParameterInclude;
import org.apache.axis2.description.PhaseRule;
import org.apache.axis2.description.PolicyInclude;
+import org.apache.axis2.description.PolicySubject;
import org.apache.axis2.description.WSDL2Constants;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.MessageReceiver;
@@ -631,23 +632,21 @@
}
}
- protected void processPolicyElements(int type, Iterator policyElements,
- PolicyInclude policyInclude) {
+ protected void processPolicyElements(Iterator policyElements,
+ PolicySubject policySubject) {
while (policyElements.hasNext()) {
Policy p = PolicyEngine
.getPolicy((OMElement) policyElements.next());
- policyInclude.addPolicyElement(type, p);
+ policySubject.attachPolicy(p);
}
}
- protected void processPolicyRefElements(int type,
- Iterator policyRefElements,
- PolicyInclude policyInclude) {
-
+ protected void processPolicyRefElements(Iterator policyRefElements,
+ PolicySubject policySubject) {
while (policyRefElements.hasNext()) {
PolicyReference policyReference = PolicyEngine
.getPolicyReference((OMElement) policyRefElements.next());
- policyInclude.addPolicyRefElement(type, policyReference);
+ policySubject.attachPolicyReference(policyReference);
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java Mon Mar 31 07:51:35 2008
@@ -147,8 +147,7 @@
moduleElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
if (policyElements != null && policyElements.hasNext()) {
- processPolicyElements(PolicyInclude.AXIS_MODULE_POLICY, policyElements,
- module.getPolicyInclude());
+ processPolicyElements(policyElements, module.getPolicySubject());
}
// processing <wsp:PolicyReference> .. </..> elements
@@ -156,8 +155,7 @@
moduleElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
if (policyRefElements != null && policyElements.hasNext()) {
- processPolicyRefElements(PolicyInclude.AXIS_MODULE_POLICY, policyRefElements,
- module.getPolicyInclude());
+ processPolicyRefElements(policyRefElements, module.getPolicySubject());
}
// process INFLOW
@@ -297,14 +295,14 @@
Iterator policyElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
if (policyElements != null && policyElements.hasNext()) {
- processPolicyElements(PolicyInclude.AXIS_MODULE_OPERATION_POLICY, policyElements, op_descrip.getPolicyInclude());
+ processPolicyElements(policyElements, op_descrip.getPolicySubject());
}
// processing <wsp:PolicyReference> .. </..> elements
Iterator policyRefElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
if (policyRefElements != null && policyRefElements.hasNext()) {
- processPolicyRefElements(PolicyInclude.AXIS_MODULE_OPERATION_POLICY, policyRefElements, module.getPolicyInclude());
+ processPolicyRefElements(policyRefElements, module.getPolicySubject());
}
// setting Operation phase
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java Mon Mar 31 07:51:35 2008
@@ -48,6 +48,9 @@
import org.apache.commons.logging.LogFactory;
import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
@@ -298,8 +301,7 @@
.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
if (policyElements != null && policyElements.hasNext()) {
- processPolicyElements(PolicyInclude.AXIS_SERVICE_POLICY,
- policyElements, service.getPolicyInclude());
+ processPolicyElements(policyElements, service.getPolicySubject());
}
// processing <wsp:PolicyReference> .. </..> elements
@@ -308,8 +310,7 @@
TAG_POLICY_REF));
if (policyRefElements != null && policyRefElements.hasNext()) {
- processPolicyRefElements(PolicyInclude.AXIS_SERVICE_POLICY,
- policyRefElements, service.getPolicyInclude());
+ processPolicyRefElements(policyRefElements, service.getPolicySubject());
}
// processing service scope
@@ -423,6 +424,8 @@
}
processEndpoints(service);
+ processPolicyAttachments(service_element, service);
+
} catch (AxisFault axisFault) {
throw new DeploymentException(axisFault);
@@ -627,8 +630,7 @@
.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
if (policyElements != null) {
- processPolicyElements(PolicyInclude.AXIS_MESSAGE_POLICY,
- policyElements, message.getPolicyInclude());
+ processPolicyElements(policyElements, message.getPolicySubject());
}
// processing <wsp:PolicyReference> .. </..> elements
@@ -637,8 +639,7 @@
TAG_POLICY_REF));
if (policyRefElements != null) {
- processPolicyRefElements(PolicyInclude.AXIS_MESSAGE_POLICY,
- policyRefElements, message.getPolicyInclude());
+ processPolicyRefElements(policyRefElements, message.getPolicySubject());
}
processParameters(parameters, message, operation);
@@ -789,8 +790,7 @@
POLICY_NS_URI, TAG_POLICY));
if (policyElements != null && policyElements.hasNext()) {
- processPolicyElements(PolicyInclude.AXIS_OPERATION_POLICY,
- policyElements, op_descrip.getPolicyInclude());
+ processPolicyElements(policyElements, op_descrip.getPolicySubject());
}
// processing <wsp:PolicyReference> .. </..> elements
@@ -799,8 +799,7 @@
TAG_POLICY_REF));
if (policyRefElements != null && policyRefElements.hasNext()) {
- processPolicyRefElements(PolicyInclude.AXIS_OPERATION_POLICY,
- policyRefElements, op_descrip.getPolicyInclude());
+ processPolicyRefElements(policyRefElements, op_descrip.getPolicySubject());
}
// Operation Parameters
@@ -913,7 +912,16 @@
private void processEndpoints(AxisService axisService) throws AxisFault {
String endpointName = axisService.getEndpointName();
if (endpointName == null || endpointName.length() == 0) {
- Utils.addEndpointsToService(axisService);
+ Utils.addEndpointsToService(axisService, service.getAxisConfiguration());
+ }
+ }
+
+ private void processPolicyAttachments(OMElement serviceElement, AxisService service) throws DeploymentException {
+ Iterator attachmentElements = serviceElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_ATTACHMENT));
+ try {
+ Utils.processPolicyAttachments(attachmentElements, service);
+ } catch (Exception e) {
+ throw new DeploymentException(e);
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Mon Mar 31 07:51:35 2008
@@ -19,6 +19,44 @@
package org.apache.axis2.deployment.util;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLDecoder;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+import java.util.StringTokenizer;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
+
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
@@ -56,51 +94,18 @@
import org.apache.axis2.engine.Handler;
import org.apache.axis2.engine.MessageReceiver;
import org.apache.axis2.util.Loader;
+import org.apache.axis2.util.PolicyUtil;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.axis2.wsdl.WSDLUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.PolicyComponent;
import org.apache.ws.commons.schema.utils.NamespaceMap;
import org.codehaus.jam.JAnnotation;
import org.codehaus.jam.JMethod;
-import javax.xml.namespace.QName;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.FileNotFoundException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLDecoder;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedExceptionAction;
-import java.security.PrivilegedActionException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Stack;
-import java.util.StringTokenizer;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
public class Utils {
-
public static String defaultEncoding = new OutputStreamWriter(System.out)
.getEncoding();
@@ -114,39 +119,39 @@
HandlerDescription handlermd = flow.getHandler(j);
Handler handler;
- final Class handlerClass = getHandlerClass(handlermd.getClassName(), clsLoader);
+ final Class handlerClass = getHandlerClass(
+ handlermd.getClassName(), clsLoader);
- try {
- handler = (Handler) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run() throws InstantiationException, IllegalAccessException {
- return handlerClass.newInstance();
- }
- }
- );
- handler.init(handlermd);
- handlermd.setHandler(handler);
- } catch (PrivilegedActionException e) {
- throw AxisFault.makeFault(e);
- }
- }
- }
+ try {
+ handler = (Handler) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws InstantiationException,
+ IllegalAccessException {
+ return handlerClass.newInstance();
+ }
+ });
+ handler.init(handlermd);
+ handlermd.setHandler(handler);
+ } catch (PrivilegedActionException e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
+ }
- public static boolean loadHandler(ClassLoader loader1, HandlerDescription desc)
- throws DeploymentException {
+ public static boolean loadHandler(ClassLoader loader1,
+ HandlerDescription desc) throws DeploymentException {
String handlername = desc.getClassName();
Handler handler;
try {
final Class handlerClass = Loader.loadClass(loader1, handlername);
- Package aPackage = (Package) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return handlerClass.getPackage();
- }
- }
- );
- if (aPackage != null && aPackage.getName().equals(
- "org.apache.axis2.engine")) {
+ Package aPackage = (Package) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return handlerClass.getPackage();
+ }
+ });
+ if (aPackage != null
+ && aPackage.getName().equals("org.apache.axis2.engine")) {
String name = handlerClass.getName();
log.warn("Dispatcher " + name + " is now deprecated.");
if (name.indexOf("InstanceDispatcher") != -1) {
@@ -158,257 +163,259 @@
+ "and replace with the same class in org.apache.axis2.dispatchers package");
}
}
- handler = (Handler) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run() throws InstantiationException, IllegalAccessException {
- return handlerClass.newInstance();
- }
- }
- );
+ handler = (Handler) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws InstantiationException,
+ IllegalAccessException {
+ return handlerClass.newInstance();
+ }
+ });
handler.init(desc);
desc.setHandler(handler);
} catch (ClassNotFoundException e) {
- if(handlername.indexOf("jaxws")>0){
- log.warn("[JAXWS] - unable to load " + handlername);
- return false;
- }
- throw new DeploymentException(e);
- } catch (Exception e) {
+ if (handlername.indexOf("jaxws") > 0) {
+ log.warn("[JAXWS] - unable to load " + handlername);
+ return false;
+ }
+ throw new DeploymentException(e);
+ } catch (Exception e) {
throw new DeploymentException(e);
}
- return true;
- }
-
+ return true;
+ }
+
public static URL[] getURLsForAllJars(URL url, File tmpDir) {
- FileInputStream fin = null;
- InputStream in = null;
- ZipInputStream zin = null;
- try {
- ArrayList array = new ArrayList();
- in = url.openStream();
- String fileName = url.getFile();
- int index = fileName.lastIndexOf('/');
- if (index != -1) {
- fileName = fileName.substring(index + 1);
- }
- final File f = createTempFile(fileName, in, tmpDir);
-
- fin = (FileInputStream) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run() throws FileNotFoundException {
- return new FileInputStream(f);
- }
- }
- );
- array.add(f.toURL());
- zin = new ZipInputStream(fin);
-
- ZipEntry entry;
- String entryName;
- while ((entry = zin.getNextEntry()) != null) {
- entryName = entry.getName();
- /**
- * id the entry name start with /lib and end with .jar
- * then those entry name will be added to the arraylist
- */
- if ((entryName != null) && entryName.toLowerCase().startsWith("lib/")
- && entryName.toLowerCase().endsWith(".jar")) {
- String suffix = entryName.substring(4);
- File f2 = createTempFile(suffix, zin, tmpDir);
- array.add(f2.toURL());
- }
- }
- return (URL[]) array.toArray(new URL[array.size()]);
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- if (fin != null) {
- try {
- fin.close();
- } catch (IOException e) {
- //
- }
- }
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- //
- }
- }
- if (zin != null) {
- try {
- zin.close();
- } catch (IOException e) {
- //
- }
- }
- }
- }
-
- public static File createTempFile(final String suffix, InputStream in, final File tmpDir) throws IOException {
- byte data[] = new byte[2048];
- int count;
- File f;
- if (tmpDir == null) {
- String directory = (String) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return System.getProperty("java.io.tmpdir");
- }
- }
- );
- final File tempFile = new File(directory, "_axis2");
- Boolean exists = (Boolean) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return new Boolean(tempFile.exists());
- }
- }
- );
- if (!exists.booleanValue()) {
- Boolean mkdirs = (Boolean) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return new Boolean(tempFile.mkdirs());
- }
- }
- );
- if (!mkdirs.booleanValue()) {
- throw new IOException("Unable to create the directory");
- }
- }
- try {
- f = (File) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run() throws IOException {
- return File.createTempFile("axis2", suffix, tempFile);
- }
- }
- );
- } catch (PrivilegedActionException e) {
- throw (IOException) e.getException();
- }
- } else {
- try {
- f = (File) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run() throws IOException {
- return File.createTempFile("axis2", suffix, tmpDir);
- }
- }
- );
- } catch (PrivilegedActionException e) {
- throw (IOException) e.getException();
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("Created temporary file : " + f.getAbsolutePath());//$NON-SEC-4
- }
- final File f2 = f;
- org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- f2.deleteOnExit();
- return null;
- }
- }
- );
- FileOutputStream out = null;
- try {
- out = (FileOutputStream) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run() throws FileNotFoundException {
- return new FileOutputStream(f2);
- }
- }
- );
- } catch (PrivilegedActionException e) {
- throw (FileNotFoundException) e.getException();
- }
- while ((count = in.read(data, 0, 2048)) != -1) {
- out.write(data, 0, count);
- }
- out.close();
- return f;
- }
-
+ FileInputStream fin = null;
+ InputStream in = null;
+ ZipInputStream zin = null;
+ try {
+ ArrayList array = new ArrayList();
+ in = url.openStream();
+ String fileName = url.getFile();
+ int index = fileName.lastIndexOf('/');
+ if (index != -1) {
+ fileName = fileName.substring(index + 1);
+ }
+ final File f = createTempFile(fileName, in, tmpDir);
+
+ fin = (FileInputStream) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws FileNotFoundException {
+ return new FileInputStream(f);
+ }
+ });
+ array.add(f.toURL());
+ zin = new ZipInputStream(fin);
+
+ ZipEntry entry;
+ String entryName;
+ while ((entry = zin.getNextEntry()) != null) {
+ entryName = entry.getName();
+ /**
+ * id the entry name start with /lib and end with .jar then
+ * those entry name will be added to the arraylist
+ */
+ if ((entryName != null)
+ && entryName.toLowerCase().startsWith("lib/")
+ && entryName.toLowerCase().endsWith(".jar")) {
+ String suffix = entryName.substring(4);
+ File f2 = createTempFile(suffix, zin, tmpDir);
+ array.add(f2.toURL());
+ }
+ }
+ return (URL[]) array.toArray(new URL[array.size()]);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (fin != null) {
+ try {
+ fin.close();
+ } catch (IOException e) {
+ //
+ }
+ }
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ //
+ }
+ }
+ if (zin != null) {
+ try {
+ zin.close();
+ } catch (IOException e) {
+ //
+ }
+ }
+ }
+ }
+
+ public static File createTempFile(final String suffix, InputStream in,
+ final File tmpDir) throws IOException {
+ byte data[] = new byte[2048];
+ int count;
+ File f;
+ if (tmpDir == null) {
+ String directory = (String) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty("java.io.tmpdir");
+ }
+ });
+ final File tempFile = new File(directory, "_axis2");
+ Boolean exists = (Boolean) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new Boolean(tempFile.exists());
+ }
+ });
+ if (!exists.booleanValue()) {
+ Boolean mkdirs = (Boolean) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new Boolean(tempFile.mkdirs());
+ }
+ });
+ if (!mkdirs.booleanValue()) {
+ throw new IOException("Unable to create the directory");
+ }
+ }
+ try {
+ f = (File) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws IOException {
+ return File.createTempFile("axis2", suffix,
+ tempFile);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (IOException) e.getException();
+ }
+ } else {
+ try {
+ f = (File) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws IOException {
+ return File.createTempFile("axis2", suffix,
+ tmpDir);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (IOException) e.getException();
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Created temporary file : " + f.getAbsolutePath());// $NON-SEC-4
+ }
+ final File f2 = f;
+ org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ f2.deleteOnExit();
+ return null;
+ }
+ });
+ FileOutputStream out = null;
+ try {
+ out = (FileOutputStream) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws FileNotFoundException {
+ return new FileOutputStream(f2);
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (FileNotFoundException) e.getException();
+ }
+ while ((count = in.read(data, 0, 2048)) != -1) {
+ out.write(data, 0, count);
+ }
+ out.close();
+ return f;
+ }
+
public static ClassLoader getClassLoader(ClassLoader parent, String path)
throws DeploymentException {
return getClassLoader(parent, new File(path));
}
-
+
/**
- * Get a ClassLoader which contains a classpath of a) the passed directory and b) any jar
- * files inside the "lib/" or "Lib/" subdirectory of the passed directory.
- *
- * @param parent parent ClassLoader which will be the parent of the result of this method
- * @param file a File which must be a directory for this to be useful
- * @return a new ClassLoader pointing to both the passed dir and jar files under lib/
- * @throws DeploymentException if problems occur
- */
- public static ClassLoader getClassLoader(final ClassLoader parent, File file)
- throws DeploymentException {
- URLClassLoader classLoader;
-
- if (file == null) return null; // Shouldn't this just return the parent?
-
- try {
- ArrayList urls = new ArrayList();
- urls.add(file.toURL());
-
- // lower case directory name
- File libfiles = new File(file, "lib");
- if (!addFiles(urls, libfiles)) {
- // upper case directory name
- libfiles = new File(file, "Lib");
- addFiles(urls, libfiles);
- }
-
- final URL urllist[] = new URL[urls.size()];
- for (int i = 0; i < urls.size(); i++) {
- urllist[i] = (URL) urls.get(i);
- }
- classLoader =
- (URLClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new URLClassLoader(urllist, parent);
- }
- });
- return classLoader;
- } catch (MalformedURLException e) {
- throw new DeploymentException(e);
- }
- }
-
- private static boolean addFiles(ArrayList urls, final File libfiles) throws MalformedURLException {
- Boolean exists = (Boolean) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return new Boolean(libfiles.exists());
- }
- }
- );
- if (exists.booleanValue()) {
- urls.add(libfiles.toURL());
- File jarfiles[] = (File[]) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return libfiles.listFiles();
- }
- }
- );
- for (int i = 0; i < jarfiles.length; i++) {
- File jarfile = jarfiles[i];
- if (jarfile.getName().endsWith(".jar")) {
- urls.add(jarfile.toURL());
- }
- }
- }
- return exists.booleanValue();
- }
+ * Get a ClassLoader which contains a classpath of a) the passed directory
+ * and b) any jar files inside the "lib/" or "Lib/" subdirectory of the
+ * passed directory.
+ *
+ * @param parent
+ * parent ClassLoader which will be the parent of the result of
+ * this method
+ * @param file
+ * a File which must be a directory for this to be useful
+ * @return a new ClassLoader pointing to both the passed dir and jar files
+ * under lib/
+ * @throws DeploymentException
+ * if problems occur
+ */
+ public static ClassLoader getClassLoader(final ClassLoader parent, File file)
+ throws DeploymentException {
+ URLClassLoader classLoader;
+
+ if (file == null)
+ return null; // Shouldn't this just return the parent?
+
+ try {
+ ArrayList urls = new ArrayList();
+ urls.add(file.toURL());
+
+ // lower case directory name
+ File libfiles = new File(file, "lib");
+ if (!addFiles(urls, libfiles)) {
+ // upper case directory name
+ libfiles = new File(file, "Lib");
+ addFiles(urls, libfiles);
+ }
- private static Class getHandlerClass(String className, ClassLoader loader1)
+ final URL urllist[] = new URL[urls.size()];
+ for (int i = 0; i < urls.size(); i++) {
+ urllist[i] = (URL) urls.get(i);
+ }
+ classLoader = (URLClassLoader) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new URLClassLoader(urllist, parent);
+ }
+ });
+ return classLoader;
+ } catch (MalformedURLException e) {
+ throw new DeploymentException(e);
+ }
+ }
+
+ private static boolean addFiles(ArrayList urls, final File libfiles)
+ throws MalformedURLException {
+ Boolean exists = (Boolean) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new Boolean(libfiles.exists());
+ }
+ });
+ if (exists.booleanValue()) {
+ urls.add(libfiles.toURL());
+ File jarfiles[] = (File[]) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return libfiles.listFiles();
+ }
+ });
+ for (int i = 0; i < jarfiles.length; i++) {
+ File jarfile = jarfiles[i];
+ if (jarfile.getName().endsWith(".jar")) {
+ urls.add(jarfile.toURL());
+ }
+ }
+ }
+ return exists.booleanValue();
+ }
+
+ private static Class getHandlerClass(String className, ClassLoader loader1)
throws AxisFault {
Class handlerClass;
@@ -455,33 +462,36 @@
.getParameter(Constants.SERVICE_OBJECT_SUPPLIER);
if (implInfoParam != null) {
String className = ((String) implInfoParam.getValue()).trim();
- final Class serviceObjectMaker = Loader.loadClass(serviceClassLoader,
- className);
+ final Class serviceObjectMaker = Loader.loadClass(
+ serviceClassLoader, className);
if (serviceObjectMaker.getModifiers() != Modifier.PUBLIC) {
throw new AxisFault("Service class " + className
+ " must have public as access Modifier");
}
- // Find static getServiceObject() method, call it if there
- final Method method = (Method) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run() throws NoSuchMethodException {
- return serviceObjectMaker.getMethod(
- "getServiceObject", new Class[]{AxisService.class});
- }
- }
- );
- Object obj = null;
+ // Find static getServiceObject() method, call it if there
+ final Method method = (Method) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws NoSuchMethodException {
+ return serviceObjectMaker.getMethod(
+ "getServiceObject",
+ new Class[] { AxisService.class });
+ }
+ });
+ Object obj = null;
if (method != null) {
- obj = org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run() throws InstantiationException, IllegalAccessException, InvocationTargetException {
- return method.invoke(serviceObjectMaker.newInstance(),
- new Object[]{axisService});
- }
- }
- );
- }
+ obj = org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run()
+ throws InstantiationException,
+ IllegalAccessException,
+ InvocationTargetException {
+ return method.invoke(serviceObjectMaker
+ .newInstance(),
+ new Object[] { axisService });
+ }
+ });
+ }
if (obj == null) {
log.warn("ServiceObjectSupplier implmentation Object could not be found");
throw new DeploymentException(
@@ -563,32 +573,35 @@
}
}
}
-
- public static AxisOperation getAxisOperationForJmethod(JMethod jmethod) throws AxisFault {
- AxisOperation operation;
- if (jmethod.getReturnType().isVoidType()) {
- if (jmethod.getExceptionTypes().length > 0) {
- operation = AxisOperationFactory.getAxisOperation(
- WSDLConstants.MEP_CONSTANT_ROBUST_IN_ONLY);
- } else {
- operation = AxisOperationFactory.getAxisOperation(
- WSDLConstants.MEP_CONSTANT_IN_ONLY);
- }
- } else {
- operation = AxisOperationFactory.getAxisOperation(
- WSDLConstants.MEP_CONSTANT_IN_OUT);
- }
- String opName = getSimpleName(jmethod);
- operation.setName(new QName(opName));
- JAnnotation methodAnnon = jmethod.getAnnotation(AnnotationConstants.WEB_METHOD);
- if (methodAnnon != null) {
- String action = methodAnnon.getValue(AnnotationConstants.ACTION).asString();
- if (action != null && !"".equals(action)) {
- operation.setSoapAction(action);
- }
- }
- return operation;
- }
+
+ public static AxisOperation getAxisOperationForJmethod(JMethod jmethod)
+ throws AxisFault {
+ AxisOperation operation;
+ if (jmethod.getReturnType().isVoidType()) {
+ if (jmethod.getExceptionTypes().length > 0) {
+ operation = AxisOperationFactory
+ .getAxisOperation(WSDLConstants.MEP_CONSTANT_ROBUST_IN_ONLY);
+ } else {
+ operation = AxisOperationFactory
+ .getAxisOperation(WSDLConstants.MEP_CONSTANT_IN_ONLY);
+ }
+ } else {
+ operation = AxisOperationFactory
+ .getAxisOperation(WSDLConstants.MEP_CONSTANT_IN_OUT);
+ }
+ String opName = getSimpleName(jmethod);
+ operation.setName(new QName(opName));
+ JAnnotation methodAnnon = jmethod
+ .getAnnotation(AnnotationConstants.WEB_METHOD);
+ if (methodAnnon != null) {
+ String action = methodAnnon.getValue(AnnotationConstants.ACTION)
+ .asString();
+ if (action != null && !"".equals(action)) {
+ operation.setSoapAction(action);
+ }
+ }
+ return operation;
+ }
public static String getSimpleName(JMethod method) {
JAnnotation methodAnnon = method
@@ -634,25 +647,24 @@
PhasesInfo phasesInfo = axisConfig.getPhasesInfo();
final ClassLoader moduleClassLoader = module.getModuleClassLoader();
ArrayList services = new ArrayList();
- final InputStream in = (InputStream) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return moduleClassLoader.getResourceAsStream("aars/aars.list");
- }
- }
- );
+ final InputStream in = (InputStream) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return moduleClassLoader
+ .getResourceAsStream("aars/aars.list");
+ }
+ });
if (in != null) {
BufferedReader input;
try {
- input = new BufferedReader((InputStreamReader) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return new InputStreamReader(in);
- }
- }
- )
- );
- String line;
+ input = new BufferedReader(
+ (InputStreamReader) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new InputStreamReader(in);
+ }
+ }));
+ String line;
while ((line = input.readLine()) != null) {
line = line.trim();
if (line.length() > 0 && line.charAt(0) != '#') {
@@ -670,15 +682,15 @@
if (servicename == null || "".equals(servicename)) {
continue;
}
- InputStream fin = (InputStream) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return moduleClassLoader
- .getResourceAsStream("aars/" + servicename);
- }
- }
- );
- if (fin == null) {
+ InputStream fin = (InputStream) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return moduleClassLoader
+ .getResourceAsStream("aars/"
+ + servicename);
+ }
+ });
+ if (fin == null) {
throw new AxisFault("No service archive found : "
+ servicename);
}
@@ -735,56 +747,57 @@
throw AxisFault.makeFault(e);
}
}
-
+
/**
- * Normalize a uri containing ../ and ./ paths.
- *
- * @param uri The uri path to normalize
- * @return The normalized uri
- */
- public static String normalize(String uri) {
- if ("".equals(uri)) {
- return uri;
- }
- int leadingSlashes = 0;
- for (leadingSlashes = 0; leadingSlashes < uri.length()
- && uri.charAt(leadingSlashes) == '/'; ++leadingSlashes) {
- //FIXME: this block is empty!!
- }
- boolean isDir = (uri.charAt(uri.length() - 1) == '/');
- StringTokenizer st = new StringTokenizer(uri, "/");
- LinkedList clean = new LinkedList();
- while (st.hasMoreTokens()) {
- String token = st.nextToken();
- if ("..".equals(token)) {
- if (!clean.isEmpty() && !"..".equals(clean.getLast())) {
- clean.removeLast();
- if (!st.hasMoreTokens()) {
- isDir = true;
- }
- } else {
- clean.add("..");
- }
- } else if (!".".equals(token) && !"".equals(token)) {
- clean.add(token);
- }
- }
- StringBuffer sb = new StringBuffer();
- while (leadingSlashes-- > 0) {
- sb.append('/');
- }
- for (Iterator it = clean.iterator(); it.hasNext();) {
- sb.append(it.next());
- if (it.hasNext()) {
- sb.append('/');
- }
- }
- if (isDir && sb.length() > 0 && sb.charAt(sb.length() - 1) != '/') {
- sb.append('/');
- }
- return sb.toString();
- }
-
+ * Normalize a uri containing ../ and ./ paths.
+ *
+ * @param uri
+ * The uri path to normalize
+ * @return The normalized uri
+ */
+ public static String normalize(String uri) {
+ if ("".equals(uri)) {
+ return uri;
+ }
+ int leadingSlashes = 0;
+ for (leadingSlashes = 0; leadingSlashes < uri.length()
+ && uri.charAt(leadingSlashes) == '/'; ++leadingSlashes) {
+ // FIXME: this block is empty!!
+ }
+ boolean isDir = (uri.charAt(uri.length() - 1) == '/');
+ StringTokenizer st = new StringTokenizer(uri, "/");
+ LinkedList clean = new LinkedList();
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken();
+ if ("..".equals(token)) {
+ if (!clean.isEmpty() && !"..".equals(clean.getLast())) {
+ clean.removeLast();
+ if (!st.hasMoreTokens()) {
+ isDir = true;
+ }
+ } else {
+ clean.add("..");
+ }
+ } else if (!".".equals(token) && !"".equals(token)) {
+ clean.add(token);
+ }
+ }
+ StringBuffer sb = new StringBuffer();
+ while (leadingSlashes-- > 0) {
+ sb.append('/');
+ }
+ for (Iterator it = clean.iterator(); it.hasNext();) {
+ sb.append(it.next());
+ if (it.hasNext()) {
+ sb.append('/');
+ }
+ }
+ if (isDir && sb.length() > 0 && sb.charAt(sb.length() - 1) != '/') {
+ sb.append('/');
+ }
+ return sb.toString();
+ }
+
public static String getPath(String parent, String childPath) {
Stack parentStack = new Stack();
Stack childStack = new Stack();
@@ -825,62 +838,62 @@
}
return filepath;
}
-
+
/**
- * Searches for jar files inside /lib dirctory. If there are any, the
- * names of those jar files will be added to the array list
- */
- public static List findLibJars(URL url) {
- ArrayList embedded_jars = new ArrayList();
- try {
- ZipInputStream zin = new ZipInputStream(url.openStream());
- ZipEntry entry;
- String entryName = "";
- while ((entry = zin.getNextEntry()) != null) {
- entryName = entry.getName();
- /**
- * if the entry name start with /lib and ends with .jar
- * add it to the the arraylist
- */
- if (entryName != null && (entryName.startsWith("lib/") ||
- entryName.startsWith("Lib/")) &&
- entryName.endsWith(".jar")) {
- embedded_jars.add(entryName);
- }
- }
- zin.close();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return embedded_jars;
- }
-
- /**
- * To add the exclude method when generating schemas , here the exclude methods
- * will be session releated axis2 methods
- */
- public static void addExcludeMethods(ArrayList excludeList) {
- excludeList.add("init");
- excludeList.add("setOperationContext");
- excludeList.add("startUp");
- excludeList.add("destroy");
- excludeList.add("shutDown");
- }
-
- public static DeploymentClassLoader createClassLoader(File serviceFile) throws MalformedURLException {
- ClassLoader contextClassLoader = (ClassLoader) org.apache.axis2.java.security.AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return Thread.currentThread().getContextClassLoader();
- }
- }
- );
- return createDeploymentClassLoader(new URL[]{serviceFile.toURL()},
- contextClassLoader,
- new ArrayList());
- }
+ * Searches for jar files inside /lib dirctory. If there are any, the names
+ * of those jar files will be added to the array list
+ */
+ public static List findLibJars(URL url) {
+ ArrayList embedded_jars = new ArrayList();
+ try {
+ ZipInputStream zin = new ZipInputStream(url.openStream());
+ ZipEntry entry;
+ String entryName = "";
+ while ((entry = zin.getNextEntry()) != null) {
+ entryName = entry.getName();
+ /**
+ * if the entry name start with /lib and ends with .jar add it
+ * to the the arraylist
+ */
+ if (entryName != null
+ && (entryName.startsWith("lib/") || entryName
+ .startsWith("Lib/"))
+ && entryName.endsWith(".jar")) {
+ embedded_jars.add(entryName);
+ }
+ }
+ zin.close();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return embedded_jars;
+ }
+
+ /**
+ * To add the exclude method when generating schemas , here the exclude
+ * methods will be session releated axis2 methods
+ */
+ public static void addExcludeMethods(ArrayList excludeList) {
+ excludeList.add("init");
+ excludeList.add("setOperationContext");
+ excludeList.add("startUp");
+ excludeList.add("destroy");
+ excludeList.add("shutDown");
+ }
- public static ClassLoader createClassLoader(ArrayList urls,
+ public static DeploymentClassLoader createClassLoader(File serviceFile)
+ throws MalformedURLException {
+ ClassLoader contextClassLoader = (ClassLoader) org.apache.axis2.java.security.AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ return createDeploymentClassLoader(new URL[] { serviceFile.toURL() },
+ contextClassLoader, new ArrayList());
+ }
+
+ public static ClassLoader createClassLoader(ArrayList urls,
ClassLoader serviceClassLoader, boolean extractJars, File tmpDir) {
URL url = (URL) urls.get(0);
if (extractJars) {
@@ -889,8 +902,9 @@
urls.remove(0);
urls.addAll(0, Arrays.asList(urls1));
URL[] urls2 = (URL[]) urls.toArray(new URL[urls.size()]);
- return createDeploymentClassLoader(urls2, serviceClassLoader, null);
- } catch (Exception e) {
+ return createDeploymentClassLoader(urls2, serviceClassLoader,
+ null);
+ } catch (Exception e) {
log
.warn("Exception extracting jars into temporary directory : "
+ e.getMessage()
@@ -900,39 +914,48 @@
}
List embedded_jars = Utils.findLibJars(url);
URL[] urls2 = (URL[]) urls.toArray(new URL[urls.size()]);
- return createDeploymentClassLoader(urls2, serviceClassLoader, embedded_jars);
- }
+ return createDeploymentClassLoader(urls2, serviceClassLoader,
+ embedded_jars);
+ }
public static File toFile(URL url) throws UnsupportedEncodingException {
- String path = URLDecoder.decode(url.getPath(), defaultEncoding);
- File file =
- new File(path.replace('/', File.separatorChar).replace('|', ':'));
- return file;
- }
-
- public static ClassLoader createClassLoader(URL[] urls, ClassLoader serviceClassLoader,
- boolean extractJars, File tmpDir) {
- if (extractJars) {
- try {
- URL[] urls1 = Utils.getURLsForAllJars(urls[0], tmpDir);
- return createDeploymentClassLoader(urls1, serviceClassLoader, null);
- } catch (Exception e){
- log.warn("Exception extracting jars into temporary directory : " + e.getMessage() + " : switching to alternate class loading mechanism");
- log.debug(e.getMessage(), e);
- }
- }
- List embedded_jars = Utils.findLibJars(urls[0]);
- return createDeploymentClassLoader(urls, serviceClassLoader, embedded_jars);
- }
-
-
- private static DeploymentClassLoader createDeploymentClassLoader(final URL[] urls, final ClassLoader serviceClassLoader, final List embeddedJars) {
- return (DeploymentClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new DeploymentClassLoader(urls, embeddedJars, serviceClassLoader);
- }
- });
- }
+ String path = URLDecoder.decode(url.getPath(), defaultEncoding);
+ File file = new File(path.replace('/', File.separatorChar).replace('|',
+ ':'));
+ return file;
+ }
+
+ public static ClassLoader createClassLoader(URL[] urls,
+ ClassLoader serviceClassLoader, boolean extractJars, File tmpDir) {
+ if (extractJars) {
+ try {
+ URL[] urls1 = Utils.getURLsForAllJars(urls[0], tmpDir);
+ return createDeploymentClassLoader(urls1, serviceClassLoader,
+ null);
+ } catch (Exception e) {
+ log
+ .warn("Exception extracting jars into temporary directory : "
+ + e.getMessage()
+ + " : switching to alternate class loading mechanism");
+ log.debug(e.getMessage(), e);
+ }
+ }
+ List embedded_jars = Utils.findLibJars(urls[0]);
+ return createDeploymentClassLoader(urls, serviceClassLoader,
+ embedded_jars);
+ }
+
+ private static DeploymentClassLoader createDeploymentClassLoader(
+ final URL[] urls, final ClassLoader serviceClassLoader,
+ final List embeddedJars) {
+ return (DeploymentClassLoader) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return new DeploymentClassLoader(urls, embeddedJars,
+ serviceClassLoader);
+ }
+ });
+ }
/**
* This method is to process bean exclude parameter and the XML format of
@@ -1026,18 +1049,22 @@
.getAxisConfiguration();
if (axisConfiguration != null) {
ArrayList transports = new ArrayList();
- for (Iterator iterator = axisConfiguration.getTransportsIn().values().iterator(); iterator.hasNext(); ){
- TransportInDescription transportInDescription = (TransportInDescription) iterator.next();
+ for (Iterator iterator = axisConfiguration.getTransportsIn()
+ .values().iterator(); iterator.hasNext();) {
+ TransportInDescription transportInDescription = (TransportInDescription) iterator
+ .next();
transports.add(transportInDescription.getName());
}
- transportInValues = transports.iterator();
+ transportInValues = transports.iterator();
}
} else {
transportInValues = axisService.getExposedTransports().iterator();
}
+ HashMap bindingCache = new HashMap();
+
if (transportInValues != null) {
- for (; transportInValues.hasNext();) {
+ for (; transportInValues.hasNext();) {
String transportName = (String) transportInValues.next();
String protocol = transportName.substring(0, 1).toUpperCase()
+ transportName.substring(1, transportName.length())
@@ -1052,7 +1079,8 @@
httpSoap11Endpoint.setName(soap11EndpointName);
httpSoap11Endpoint.setParent(axisService);
httpSoap11Endpoint.setTransportInDescription(transportName);
- populateSoap11Endpoint(axisService, httpSoap11Endpoint);
+ populateSoap11Endpoint(axisService, httpSoap11Endpoint,
+ bindingCache);
axisService.addEndpoint(httpSoap11Endpoint.getName(),
httpSoap11Endpoint);
// setting soap11 endpoint as the default endpoint
@@ -1067,7 +1095,8 @@
httpSoap12Endpoint.setName(soap12EndpointName);
httpSoap12Endpoint.setParent(axisService);
httpSoap12Endpoint.setTransportInDescription(transportName);
- populateSoap12Endpoint(axisService, httpSoap12Endpoint);
+ populateSoap12Endpoint(axisService, httpSoap12Endpoint,
+ bindingCache);
axisService.addEndpoint(httpSoap12Endpoint.getName(),
httpSoap12Endpoint);
@@ -1081,7 +1110,81 @@
httpEndpoint.setName(httpEndpointName);
httpEndpoint.setParent(axisService);
httpEndpoint.setTransportInDescription(transportName);
- populateHttpEndpoint(axisService, httpEndpoint);
+ populateHttpEndpoint(axisService, httpEndpoint, bindingCache);
+ axisService.addEndpoint(httpEndpoint.getName(),
+ httpEndpoint);
+ }
+ }
+ }
+ }
+
+ public static void addEndpointsToService(AxisService axisService,
+ AxisConfiguration axisConfiguration) throws AxisFault {
+
+ String serviceName = axisService.getName();
+ Iterator transportInValues = null;
+
+ if (axisConfiguration != null) {
+ ArrayList transports = new ArrayList();
+ for (Iterator iterator = axisConfiguration.getTransportsIn()
+ .values().iterator(); iterator.hasNext();) {
+ TransportInDescription transportInDescription = (TransportInDescription) iterator
+ .next();
+ transports.add(transportInDescription.getName());
+ }
+ transportInValues = transports.iterator();
+ }
+
+ HashMap bindingCache = new HashMap();
+ if (transportInValues != null) {
+ for (; transportInValues.hasNext();) {
+ String transportName = (String) transportInValues.next();
+ String protocol = transportName.substring(0, 1).toUpperCase()
+ + transportName.substring(1, transportName.length())
+ .toLowerCase();
+ /*
+ * populates soap11 endpoint
+ */
+ String soap11EndpointName = serviceName + protocol
+ + "Soap11Endpoint";
+
+ AxisEndpoint httpSoap11Endpoint = new AxisEndpoint();
+ httpSoap11Endpoint.setName(soap11EndpointName);
+ httpSoap11Endpoint.setParent(axisService);
+ httpSoap11Endpoint.setTransportInDescription(transportName);
+ populateSoap11Endpoint(axisService, httpSoap11Endpoint,
+ bindingCache);
+ axisService.addEndpoint(httpSoap11Endpoint.getName(),
+ httpSoap11Endpoint);
+ // setting soap11 endpoint as the default endpoint
+ axisService.setEndpointName(soap11EndpointName);
+
+ /*
+ * generating Soap12 endpoint
+ */
+ String soap12EndpointName = serviceName + protocol
+ + "Soap12Endpoint";
+ AxisEndpoint httpSoap12Endpoint = new AxisEndpoint();
+ httpSoap12Endpoint.setName(soap12EndpointName);
+ httpSoap12Endpoint.setParent(axisService);
+ httpSoap12Endpoint.setTransportInDescription(transportName);
+ populateSoap12Endpoint(axisService, httpSoap12Endpoint,
+ bindingCache);
+ axisService.addEndpoint(httpSoap12Endpoint.getName(),
+ httpSoap12Endpoint);
+
+ /*
+ * generating Http endpoint
+ */
+ if ("http".equals(transportName)
+ || "https".equals(transportName)) {
+ String httpEndpointName = serviceName + protocol
+ + "Endpoint";
+ AxisEndpoint httpEndpoint = new AxisEndpoint();
+ httpEndpoint.setName(httpEndpointName);
+ httpEndpoint.setParent(axisService);
+ httpEndpoint.setTransportInDescription(transportName);
+ populateHttpEndpoint(axisService, httpEndpoint, bindingCache);
axisService.addEndpoint(httpEndpoint.getName(),
httpEndpoint);
}
@@ -1102,8 +1205,9 @@
httpSoap11Endpoint.setName(soap11EndpointName);
httpSoap11Endpoint.setParent(axisService);
httpSoap11Endpoint.setEndpointURL(url.toString());
+ httpSoap11Endpoint.setTransportInDescription(url.getProtocol());
- populateSoap11Endpoint(axisService, httpSoap11Endpoint);
+ populateSoap11Endpoint(axisService, httpSoap11Endpoint, null);
axisService.addEndpoint(httpSoap11Endpoint.getName(),
httpSoap11Endpoint);
// setting soap11 endpoint as the default endpoint
@@ -1123,8 +1227,9 @@
httpSoap12Endpoint.setName(soap12EndpointName);
httpSoap12Endpoint.setParent(axisService);
httpSoap12Endpoint.setEndpointURL(url.toString());
+ httpSoap12Endpoint.setTransportInDescription(url.getProtocol());
- populateSoap12Endpoint(axisService, httpSoap12Endpoint);
+ populateSoap12Endpoint(axisService, httpSoap12Endpoint, null);
axisService.addEndpoint(httpSoap12Endpoint.getName(),
httpSoap12Endpoint);
}
@@ -1140,121 +1245,204 @@
httpEndpoint.setName(httpEndpointName);
httpEndpoint.setParent(axisService);
httpEndpoint.setEndpointURL(url.toString());
- populateHttpEndpoint(axisService, httpEndpoint);
+ httpEndpoint.setTransportInDescription(url.getProtocol());
+ populateHttpEndpoint(axisService, httpEndpoint, null);
axisService.addEndpoint(httpEndpoint.getName(), httpEndpoint);
}
- private static void populateSoap11Endpoint(AxisService axisService,
- AxisEndpoint axisEndpoint) {
- String endpointName = axisEndpoint.getName();
- String name = endpointName.substring(0, endpointName
- .indexOf("Endpoint"))
- + "Binding";
-
- QName bindingName = new QName(name);
+ public static void processPolicyAttachments(Iterator attachmentElements,
+ AxisService service) throws XMLStreamException,
+ FactoryConfigurationError {
+ OMElement attachmentElement;
+ HashMap attachmentsMap = new HashMap();
+
+ for (; attachmentElements.hasNext();) {
+ attachmentElement = (OMElement) attachmentElements.next();
+ OMElement appliesToElem = attachmentElement
+ .getFirstChildWithName(new QName(
+ DeploymentConstants.POLICY_NS_URI,
+ DeploymentConstants.TAG_APPLIES_TO));
+ ArrayList policyComponents = new ArrayList();
+
+ // process <wsp:Policy> elements ..
+ for (Iterator policyElements = attachmentElement
+ .getChildrenWithName(new QName(
+ DeploymentConstants.POLICY_NS_URI,
+ DeploymentConstants.TAG_POLICY)); policyElements
+ .hasNext();) {
+ PolicyComponent policy = PolicyUtil
+ .getPolicyFromOMElement((OMElement) policyElements
+ .next());
+ policyComponents.add(policy);
+ }
- AxisBinding axisBinding = new AxisBinding();
- axisBinding.setName(bindingName);
+ // process <wsp:PolicyReference> elements ..
+ for (Iterator policyRefElements = attachmentElement
+ .getChildrenWithName(new QName(
+ DeploymentConstants.POLICY_NS_URI,
+ DeploymentConstants.TAG_POLICY_REF)); policyRefElements
+ .hasNext();) {
+ PolicyComponent policyRef = PolicyUtil
+ .getPolicyReferenceFromOMElement((OMElement) policyRefElements
+ .next());
+ policyComponents.add(policyRef);
+ }
- axisBinding.setType(Java2WSDLConstants.TRANSPORT_URI);
- axisBinding.setProperty(WSDLConstants.WSDL_1_1_STYLE,
- WSDLConstants.STYLE_DOC);
+ for (Iterator policySubjects = appliesToElem
+ .getChildrenWithName(new QName("policy-subject")); policySubjects
+ .hasNext();) {
+ OMElement policySubject = (OMElement) policySubjects.next();
+ String identifier = policySubject.getAttributeValue(new QName(
+ "identifier"));
+
+ ArrayList values = (ArrayList) attachmentsMap.get(identifier);
+ if (values == null) {
+ values = new ArrayList();
+ attachmentsMap.put(identifier, values);
+ }
+ values.addAll(policyComponents);
+ }
+ }
- axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
- SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+ for (Iterator keys = attachmentsMap.keySet().iterator(); keys.hasNext();) {
+ String identifier = (String) keys.next();
+ if (identifier.startsWith("binding:soap")) {
+ processSoapAttachments(identifier, (List) attachmentsMap
+ .get(identifier), service);
+ }
+ }
+ }
- for (Iterator iterator = axisService.getChildren(); iterator.hasNext();) {
- AxisOperation operation = (AxisOperation) iterator.next();
- AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
+ private static void populateSoap11Endpoint(AxisService axisService,
+ AxisEndpoint axisEndpoint, HashMap bindingCache) {
+ String serviceName = axisService.getName();
+ String name = serviceName + "Soap11Binding";
- axisBindingOperation.setName(operation.getName());
- axisBindingOperation.setAxisOperation(operation);
+ QName bindingName = new QName(name);
- String soapAction = operation.getSoapAction();
- if (soapAction != null) {
- axisBindingOperation.setProperty(
- WSDL2Constants.ATTR_WSOAP_ACTION, soapAction);
+ AxisBinding axisBinding = (bindingCache != null) ? (AxisBinding) bindingCache
+ .get(bindingName)
+ : null;
+ if (axisBinding == null) {
+ axisBinding = new AxisBinding();
+ axisBinding.setName(bindingName);
+
+ axisBinding.setType(Java2WSDLConstants.TRANSPORT_URI);
+ axisBinding.setProperty(WSDLConstants.WSDL_1_1_STYLE,
+ WSDLConstants.STYLE_DOC);
+
+ axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
+ SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ for (Iterator iterator = axisService.getChildren(); iterator
+ .hasNext();) {
+ AxisOperation operation = (AxisOperation) iterator.next();
+ AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
+
+ axisBindingOperation.setName(operation.getName());
+ axisBindingOperation.setAxisOperation(operation);
+
+ String soapAction = operation.getSoapAction();
+ if (soapAction != null) {
+ axisBindingOperation.setProperty(
+ WSDL2Constants.ATTR_WSOAP_ACTION, soapAction);
+ }
+ axisBinding.addChild(axisBindingOperation.getName(),
+ axisBindingOperation);
+ populateBindingOperation(axisService, axisBinding,
+ axisBindingOperation);
+ }
+ if (bindingCache != null) {
+ bindingCache.put(name, axisBinding);
}
- axisBinding.addChild(axisBindingOperation.getName(),
- axisBindingOperation);
- populateBindingOperation(axisService, axisBinding,
- axisBindingOperation);
}
-
- axisBinding.setParent(axisEndpoint);
+ // axisBinding.setParent(axisEndpoint);
axisEndpoint.setBinding(axisBinding);
}
private static void populateSoap12Endpoint(AxisService axisService,
- AxisEndpoint axisEndpoint) {
- String endpointName = axisEndpoint.getName();
- String name = endpointName.substring(0, endpointName
- .indexOf("Endpoint"))
- + "Binding";
+ AxisEndpoint axisEndpoint, HashMap bindingCache) {
+ String serviceName = axisService.getName();
+ String name = serviceName + "Soap12Binding";
QName bindingName = new QName(name);
- AxisBinding axisBinding = new AxisBinding();
- axisBinding.setName(bindingName);
-
- axisBinding.setType(Java2WSDLConstants.TRANSPORT_URI);
- axisBinding.setProperty(WSDLConstants.WSDL_1_1_STYLE,
- WSDLConstants.STYLE_DOC);
- axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
- SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-
- for (Iterator iterator = axisService.getChildren(); iterator.hasNext();) {
- AxisOperation operation = (AxisOperation) iterator.next();
- AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
-
- axisBindingOperation.setName(operation.getName());
- axisBindingOperation.setAxisOperation(operation);
+ AxisBinding axisBinding = (bindingCache != null) ? (AxisBinding) bindingCache
+ .get(bindingName)
+ : null;
+ if (axisBinding == null) {
+ axisBinding = new AxisBinding();
+ axisBinding.setName(bindingName);
+
+ axisBinding.setType(Java2WSDLConstants.TRANSPORT_URI);
+ axisBinding.setProperty(WSDLConstants.WSDL_1_1_STYLE,
+ WSDLConstants.STYLE_DOC);
+
+ axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
+ SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+
+ for (Iterator iterator = axisService.getChildren(); iterator
+ .hasNext();) {
+ AxisOperation operation = (AxisOperation) iterator.next();
+ AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
+
+ axisBindingOperation.setName(operation.getName());
+ axisBindingOperation.setAxisOperation(operation);
+
+ String soapAction = operation.getSoapAction();
+ if (soapAction != null) {
+ axisBindingOperation.setProperty(
+ WSDL2Constants.ATTR_WSOAP_ACTION, soapAction);
+ }
+ axisBinding.addChild(axisBindingOperation.getName(),
+ axisBindingOperation);
- String soapAction = operation.getSoapAction();
- if (soapAction != null) {
- axisBindingOperation.setProperty(
- WSDL2Constants.ATTR_WSOAP_ACTION, soapAction);
+ populateBindingOperation(axisService, axisBinding,
+ axisBindingOperation);
+ }
+ if (bindingCache != null) {
+ bindingCache.put(name, axisBinding);
}
- axisBinding.addChild(axisBindingOperation.getName(),
- axisBindingOperation);
-
- populateBindingOperation(axisService, axisBinding,
- axisBindingOperation);
}
-
- axisBinding.setParent(axisEndpoint);
axisEndpoint.setBinding(axisBinding);
}
private static void populateHttpEndpoint(AxisService axisService,
- AxisEndpoint axisEndpoint) {
- String endpointName = axisEndpoint.getName();
- String name = endpointName.substring(0, endpointName
- .indexOf("Endpoint"))
- + "Binding";
+ AxisEndpoint axisEndpoint, HashMap bindingCache) {
+ String serviceName = axisService.getName();
+ String name = serviceName + "HttpBinding";
QName bindingName = new QName(name);
- AxisBinding axisBinding = new AxisBinding();
- axisBinding.setName(bindingName);
- axisBinding.setType(WSDL2Constants.URI_WSDL2_HTTP);
- axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, "POST");
+ AxisBinding axisBinding = (bindingCache != null) ? (AxisBinding) bindingCache
+ .get(bindingName)
+ : null;
+
+ if (axisBinding == null) {
+ axisBinding = new AxisBinding();
+ axisBinding.setName(bindingName);
+
+ axisBinding.setType(WSDL2Constants.URI_WSDL2_HTTP);
+ axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, "POST");
+
+ for (Iterator iterator = axisService.getChildren(); iterator
+ .hasNext();) {
+ AxisOperation operation = (AxisOperation) iterator.next();
+ AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
- for (Iterator iterator = axisService.getChildren(); iterator.hasNext();) {
- AxisOperation operation = (AxisOperation) iterator.next();
- AxisBindingOperation axisBindingOperation = new AxisBindingOperation();
+ axisBindingOperation.setName(operation.getName());
+ axisBindingOperation.setAxisOperation(operation);
- axisBindingOperation.setName(operation.getName());
- axisBindingOperation.setAxisOperation(operation);
+ axisBinding.addChild(axisBindingOperation.getName(),
+ axisBindingOperation);
- axisBinding.addChild(axisBindingOperation.getName(),
- axisBindingOperation);
-
- populateBindingOperation(axisService, axisBinding,
- axisBindingOperation);
+ populateBindingOperation(axisService, axisBinding,
+ axisBindingOperation);
+ }
+ if (bindingCache != null) {
+ bindingCache.put(name, axisBinding);
+ }
}
-
- axisBinding.setParent(axisEndpoint);
axisEndpoint.setBinding(axisBinding);
}
@@ -1307,5 +1495,66 @@
axisBindingOperation.setAxisOperation(axisOperation);
axisBindingOperation.setParent(axisBinding);
+ }
+
+ private static void processSoapAttachments(String identifier,
+ List policyComponents, AxisService service) {
+ Map map = service.getEndpoints();
+ String soapVersion = (identifier.indexOf("soap12") > -1) ? SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI
+ : SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+
+ for (Iterator iterator = map.values().iterator(); iterator.hasNext();) {
+ AxisEndpoint axisEndpoint = (AxisEndpoint) iterator.next();
+ AxisBinding axisBinding = axisEndpoint.getBinding();
+ String wsoap = (String) axisBinding
+ .getProperty(WSDL2Constants.ATTR_WSOAP_VERSION);
+ if (soapVersion.equals(wsoap)) {
+ String[] identifiers = identifier.split("/");
+ int key = identifiers.length;
+ if (key == 1) {
+ axisBinding.getPolicySubject().attachPolicyComponents(
+ policyComponents);
+ } else if (key == 2 || key == 3) {
+ String opName = identifiers[1];
+ opName = opName.substring(opName.indexOf(":") + 1, opName
+ .length());
+ AxisBindingOperation bindingOperation = null;
+ boolean found = false;
+ for (Iterator i = axisBinding.getChildren(); i.hasNext();) {
+ bindingOperation = (AxisBindingOperation) i.next();
+ if (opName.equals(bindingOperation.getName()
+ .getLocalPart())) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ throw new IllegalArgumentException(
+ "Invalid binding operation " + opName);
+ }
+
+ if (key == 2) {
+ bindingOperation.getPolicySubject()
+ .attachPolicyComponents(policyComponents);
+ } else {
+ if ("in".equals(identifiers[2])) {
+ AxisBindingMessage bindingInMessage = (AxisBindingMessage) bindingOperation
+ .getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ bindingInMessage.getPolicySubject()
+ .attachPolicyComponents(policyComponents);
+
+ } else if ("out".equals(identifiers[2])) {
+ AxisBindingMessage bindingOutMessage = (AxisBindingMessage) bindingOperation
+ .getChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ bindingOutMessage.getPolicySubject()
+ .attachPolicyComponents(policyComponents);
+ } else {
+ // FIXME faults
+ }
+ }
+ }
+ break;
+ }
+ }
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java Mon Mar 31 07:51:35 2008
@@ -103,7 +103,7 @@
}
public Object getKey() {
- return null;
+ return name;
}
public void engageModule(AxisModule axisModule) throws AxisFault {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java Mon Mar 31 07:51:35 2008
@@ -181,20 +181,40 @@
.getTransportIn(transportInDescName);
TransportListener listener = in.getReceiver();
String ip = HttpUtils.getIpAddress(axisConfiguration);
+ // we should pass [serviceName].[endpointName] instead of
+ // [endpointName]
+ String sDOTe = serviceName + "." + name;
EndpointReference[] eprsForService = listener
- .getEPRsForService(serviceName, ip);
+ .getEPRsForService(sDOTe, ip);
// we consider only the first address return by the listener
if (eprsForService != null && eprsForService.length > 0) {
return eprsForService[0].getAddress();
}
} catch (SocketException e) {
- logger.warn("", e);
+ logger.warn(e.getMessage(), e);
} catch (AxisFault e) {
- logger.warn("", e);
+ logger.warn(e.getMessage(), e);
}
}
}
-
+
return null;
+ }
+
+ public boolean isActive() {
+ if (transportInDescName != null && parent != null) {
+ AxisConfiguration axisConfiguration = getAxisConfiguration();
+ if (axisConfiguration != null) {
+ AxisService service = (AxisService) parent;
+ if (service.isEnableAllTransports()) {
+ return axisConfiguration.getTransportsIn().containsKey(
+ transportInDescName);
+ } else {
+ return service.getExposedTransports().contains(
+ transportInDescName);
+ }
+ }
+ }
+ return false;
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java Mon Mar 31 07:51:35 2008
@@ -21,8 +21,11 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
+import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.phaseresolver.PhaseResolver;
+import org.apache.axis2.util.PolicyUtil;
import org.apache.axis2.wsdl.SOAPHeaderMessage;
+import org.apache.neethi.Policy;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaImport;
@@ -59,6 +62,10 @@
//To chcek whether the message is wrapped or unwrapped
private boolean wrapped = true;
+
+ private Policy effectivePolicy = null;
+
+ private boolean policyCalculated = false;
public String getMessagePartName() {
return messagePartName;
@@ -231,4 +238,46 @@
public void setWrapped(boolean wrapped) {
this.wrapped = wrapped;
}
+
+ public Policy getEffectivePolicy() {
+ if (effectivePolicy == null && !policyCalculated) {
+ effectivePolicy = calculateEffectivePolicy();
+ policyCalculated = true;
+ }
+ return effectivePolicy;
+ }
+
+ public Policy calculateEffectivePolicy() {
+ PolicySubject policySubject = null;
+ ArrayList policyList = new ArrayList();
+
+ // AxisMessage
+ policySubject = getPolicySubject();
+ policyList.addAll(policySubject.getAttachPolicyComponents());
+
+ // AxisOperation
+ AxisOperation axisOperation = getAxisOperation();
+ if (axisOperation != null) {
+ policyList.addAll(axisOperation.getPolicySubject()
+ .getAttachPolicyComponents());
+ }
+
+ // AxisService
+ AxisService axisService = (axisOperation == null) ? null
+ : axisOperation.getAxisService();
+ if (axisService != null) {
+ policyList.addAll(axisService.getPolicySubject()
+ .getAttachPolicyComponents());
+ }
+
+ // AxisConfiguration
+ AxisConfiguration axisConfiguration = (axisService == null) ? null
+ : axisService.getAxisConfiguration();
+ if (axisConfiguration != null) {
+ policyList.addAll(axisConfiguration.getPolicySubject()
+ .getAttachPolicyComponents());
+ }
+
+ return PolicyUtil.getMergedPolicy(policyList, axisService);
+ }
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisModule.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisModule.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisModule.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisModule.java Mon Mar 31 07:51:35 2008
@@ -83,6 +83,7 @@
public static final String VERSION_SNAPSHOT = "SNAPSHOT";
public static final String MODULE_SERVICE = "moduleService";
+ private PolicySubject policySubject = new PolicySubject();
/**
* Constructor ModuleDescription.
@@ -261,6 +262,10 @@
policyInclude = new PolicyInclude();
}
return policyInclude;
+ }
+
+ public PolicySubject getPolicySubject() {
+ return policySubject;
}
public String getModuleDescription() {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?rev=643008&r1=643007&r2=643008&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java Mon Mar 31 07:51:35 2008
@@ -2239,7 +2239,7 @@
String endpointName = axisService.getEndpointName();
if ((endpointName == null || endpointName.length() == 0)
&& axisService.getAxisConfiguration() != null) {
- Utils.addEndpointsToService(axisService);
+ Utils.addEndpointsToService(axisService, axisService.getAxisConfiguration());
}
return axisService;
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org