axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r392246 - /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java
Date Fri, 07 Apr 2006 11:01:13 GMT
Author: sanka
Date: Fri Apr  7 04:01:06 2006
New Revision: 392246

URL: http://svn.apache.org/viewcvs?rev=392246&view=rev
Log:
Modified: PolicyEvaluator to work using AxisService instead of WOM description

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java?rev=392246&r1=392245&r2=392246&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java
Fri Apr  7 04:01:06 2006
@@ -19,6 +19,9 @@
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.PolicyInclude;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.modules.Module;
 import org.apache.axis2.modules.ModulePolicyExtension;
@@ -45,6 +48,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  *
@@ -54,12 +58,14 @@
 public class PolicyEvaluator implements CodeGenExtension {
 
 	CodeGenConfiguration configuration;
+    
+    AxisService axisService;
 
 //HashMap ns2modules = new HashMap();
 	
 	HashMap ns2Exts = new HashMap();
 
-	PolicyAttachmentUtil util;
+//	PolicyAttachmentUtil util;
 
 	Element rootElement;
 
@@ -68,7 +74,7 @@
 
 	public void init(CodeGenConfiguration configuration) {
 		this.configuration = configuration;
-		util = new PolicyAttachmentUtil(configuration.getWom());
+        this.axisService = configuration.getAxisService();
         
        // adding default PolicyExtensions
        ns2Exts.put("http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization",
new MTOMPolicyExtension());
@@ -80,14 +86,11 @@
        
 		String repository = configuration.getRepositoryPath();
         
-		if (repository == null) {
-			return;
-		}
+		if (repository == null) {    return;    }
 
 
 		try {
             
-           
 			ConfigurationContext configurationCtx = ConfigurationContextFactory
 					.createConfigurationContextFromFileSystem(repository, null);
 			AxisConfiguration axisConfiguration = configurationCtx
@@ -124,87 +127,32 @@
 
 	public void engage() {
         
-        // TODO XSLTConstants.BASE_64_PROPERTY_KEY
-        
-        
-		WSDLDescription womDescription = configuration.getWom();
-		String serviceName = configuration.getServiceName();
-
 		Document document = getEmptyDocument();
 		Element rootElement = document.createElement("stubMethods");
-
-		WSDLService wsdlService = null;
-		WSDLInterface wsdlInterface = null;
-
-		if (serviceName != null) {
-			wsdlService = womDescription.getService(new QName(serviceName));
-		} else {
-			for (Iterator iterator = womDescription.getServices().values()
-					.iterator(); iterator.hasNext();) {
-				wsdlService = (WSDLService) iterator.next();
-				serviceName = wsdlService.getName().getLocalPart();
-				configuration.setServiceName(serviceName);
-				break;
-			}
-		}
-
-		if (wsdlService != null) {
-
-			String port = configuration.getPortName();
-			WSDLEndpoint wsdlEndpoint = null;
-
-			if (port == null) {
-				for (Iterator iterator = wsdlService.getEndpoints().values()
-						.iterator(); iterator.hasNext();) {
-					wsdlEndpoint = (WSDLEndpoint) iterator.next();
-					port = wsdlEndpoint.getName().getLocalPart();
-					configuration.setPortName(port);
-					break;
-
-				}
-			} else {
-				wsdlEndpoint = wsdlService.getEndpoint(new QName(port));
-			}
-			if (wsdlEndpoint == null) {
-				System.err.println("no wsdl:port found for the service");
-				return;
-			}
-
-			WSDLBinding wsdlBinding = wsdlEndpoint.getBinding();
-			wsdlInterface = wsdlBinding.getBoundInterface();
-
-			for (Iterator iterator = wsdlInterface.getOperations().values()
-					.iterator(); iterator.hasNext();) {
-				WSDLOperation wsdlOperation = (WSDLOperation) iterator.next();
-				Policy policy = util.getPolicyForOperation(wsdlEndpoint.getName(),
-						wsdlOperation.getName());
-
-				if (policy != null) {
-					processPolicies(document, rootElement, policy,
-							wsdlEndpoint, wsdlOperation);
-				}
-			}
-
-		}
-
-		for (Iterator iterator = womDescription.getWsdlInterfaces().values()
-				.iterator(); iterator.hasNext();) {
-			wsdlInterface = (WSDLInterface) iterator.next();
-			break;
-		}
-
-		if (wsdlInterface == null) {
-			System.err.println("cannot find a wsdl:Service or a wsdl:portType");
-			// TODO exception ?
-			return;
-		}
-
-		// TODO wsdl:portType processing..
-
+        
+        AxisOperation axisOperation;
+        QName opName;
+        PolicyInclude policyInclude;
+        Policy policy;
+        Iterator a = axisService.getOperations();
+        
+        for (Iterator iterator = axisService.getOperations(); iterator.hasNext(); ) {
+            axisOperation = (AxisOperation) iterator.next();
+            opName = axisOperation.getName();
+            
+            policyInclude = axisOperation.getPolicyInclude();
+            policy = policyInclude.getEffectivePolicy();
+            
+            if (policy != null) {
+            	processPolicies(document, rootElement, policy, opName);
+            }
+        }
+        
+        configuration.putProperty("stubMethods", rootElement);
 	}
 
 	private void processPolicies(Document document, Element rootElement,
-			Policy policy, WSDLEndpoint wsdlEndpoint, WSDLOperation operation) {
+			Policy policy, QName opName) {
         
 		if (!policy.isNormalized()) {
 			policy = (Policy) policy.normalize();
@@ -258,12 +206,9 @@
 			AndCompositeAssertion nAND = (AndCompositeAssertion) map
 					.get(namespace);
 			nXOR.addTerm(nAND);
-
-            QName operationName = operation.getName();
-			policyExtension.addMethodsToStub(document, rootElement, operationName, nPolicy);
+            
+			policyExtension.addMethodsToStub(document, rootElement, opName, nPolicy);
 		}
-
-		configuration.putProperty("stubMethods", rootElement);
 	}
 
 	private Document getEmptyDocument() {



Mime
View raw message