axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r372978 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2: description/AxisService.java util/PolicyUtil.java
Date Fri, 27 Jan 2006 20:45:23 GMT
Author: deepal
Date: Fri Jan 27 12:45:13 2006
New Revision: 372978

URL: http://svn.apache.org/viewcvs?rev=372978&view=rev
Log:
-added a way to get policy from AxisService and AxisOperation

Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java?rev=372978&r1=372977&r2=372978&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
Fri Jan 27 12:45:13 2006
@@ -307,6 +307,19 @@
         schema.write(out);
     }
 
+    public void printPolicy(OutputStream out) throws AxisFault {
+        PolicyUtil.writePolicy(getPolicyInclude(), out);
+        schema.write(out);
+    }
+
+    public void printPolicy(OutputStream out, String operationName) throws AxisFault {
+        AxisOperation axisOperation = getOperation(new QName(operationName));
+        if (axisOperation == null) {
+            throw new AxisFault("invalid operation : " + operationName);
+        }
+        PolicyUtil.writePolicy(axisOperation.getPolicyInclude(), out);
+    }
+
     public void printWSDL(OutputStream out, String serviceURL) throws AxisFault {
         if (getWSDLDefinition() != null) {
             printUsingWSDLDefinition(out, serviceURL);

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java?rev=372978&r1=372977&r2=372978&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java Fri
Jan 27 12:45:13 2006
@@ -16,39 +16,27 @@
 
 package org.apache.axis2.util;
 
-import org.apache.axis2.description.AxisDescWSDLComponentFactory;
-import org.apache.axis2.description.AxisMessage;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.AxisServiceGroup;
-import org.apache.axis2.description.PolicyInclude;
+import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.wsdl.builder.wsdl4j.WSDLPump;
+import org.apache.ws.policy.Policy;
 import org.apache.ws.policy.PolicyConstants;
 import org.apache.ws.policy.PolicyReference;
-import org.apache.wsdl.Component;
-import org.apache.wsdl.WSDLBinding;
-import org.apache.wsdl.WSDLBindingOperation;
-import org.apache.wsdl.WSDLConstants;
-import org.apache.wsdl.WSDLDescription;
-import org.apache.wsdl.WSDLEndpoint;
-import org.apache.wsdl.WSDLExtensibilityAttribute;
-import org.apache.wsdl.WSDLInterface;
-import org.apache.wsdl.WSDLOperation;
-import org.apache.wsdl.WSDLService;
+import org.apache.ws.policy.util.PolicyFactory;
+import org.apache.ws.policy.util.PolicyWriter;
+import org.apache.wsdl.*;
 import org.apache.wsdl.extensions.ExtensionConstants;
 import org.apache.wsdl.extensions.PolicyExtensibilityElement;
 import org.apache.wsdl.extensions.impl.ExtensionFactoryImpl;
-import org.apache.wsdl.impl.WSDLDescriptionImpl;
 import org.apache.wsdl.impl.WSDLProcessingException;
 
-import javax.wsdl.Definition;
 import javax.xml.namespace.QName;
+import java.io.OutputStream;
+import java.io.PrintWriter;
 import java.util.Iterator;
 import java.util.List;
 
 public class PolicyUtil {
-	
+
     public static void populatePolicy(WSDLDescription description,
                                       AxisService axisService) {
         WSDLService wsdlService = description.getService(new QName(axisService
@@ -61,9 +49,9 @@
 
         AxisServiceGroup axisServiceGroup = null;
         AxisConfiguration axisConfiguration = null;
-        
+
         axisServiceGroup = (AxisServiceGroup) axisService.getParent();
-        
+
         if (axisServiceGroup != null) {
             axisConfiguration = (AxisConfiguration) axisServiceGroup.getParent();
         }
@@ -74,10 +62,10 @@
 
         // Policies defined in Axis2.xml
         if (axisConfiguration != null) {
-        policyList = axisConfiguration.getPolicyInclude().getPolicyElements(
-                PolicyInclude.AXIS_POLICY);
-        addPolicyAsExtElements(description, policyList, wsdlService,
-                servicePolicyInclude);
+            policyList = axisConfiguration.getPolicyInclude().getPolicyElements(
+                    PolicyInclude.AXIS_POLICY);
+            addPolicyAsExtElements(description, policyList, wsdlService,
+                    servicePolicyInclude);
         }
 
         // Policies defined in wsdl:Service
@@ -339,6 +327,17 @@
                                 .getPolicy(policyURIString)));
 
             }
+        }
+    }
+
+    public static void writePolicy(PolicyInclude policy, OutputStream out) {
+        if (policy != null) {
+            Policy pl = policy.getEffectivePolicy();
+            PolicyWriter write = PolicyFactory.getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
+            write.writePolicy(pl, out);
+        } else {
+            PrintWriter write = new PrintWriter(out);
+            write.println("no policy found");
         }
     }
 }



Mime
View raw message