You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2012/06/22 11:04:41 UTC

svn commit: r1352812 - in /axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2: context/ description/ util/

Author: sagara
Date: Fri Jun 22 09:04:38 2012
New Revision: 1352812

URL: http://svn.apache.org/viewvc?rev=1352812&view=rev
Log:
AXIS2-5334 - Removed some deprecated method on PolicyInclude.

Modified:
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/MessageContext.java
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBinding.java
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/PolicyInclude.java
    axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/MessageContext.java?rev=1352812&r1=1352811&r2=1352812&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/MessageContext.java Fri Jun 22 09:04:38 2012
@@ -76,6 +76,7 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -1627,7 +1628,7 @@ public class MessageContext extends Abst
         		return axisMessage.getEffectivePolicy();
         } else {
             if (axisService != null){
-                List<PolicyComponent> policyList = new ArrayList<PolicyComponent>();
+                Collection<PolicyComponent> policyList = new ArrayList<PolicyComponent>();
                 policyList.addAll(axisService.getPolicySubject().getAttachedPolicyComponents());
                 AxisConfiguration axisConfiguration = axisService.getAxisConfiguration();
                 policyList.addAll(axisConfiguration.getPolicySubject().getAttachedPolicyComponents());

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBinding.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBinding.java?rev=1352812&r1=1352811&r2=1352812&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBinding.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBinding.java Fri Jun 22 09:04:38 2012
@@ -20,6 +20,7 @@
 package org.apache.axis2.description;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -242,7 +243,7 @@ public class AxisBinding extends AxisDes
     }
     
     public Policy getEffectivePolicy() {
-        ArrayList<PolicyComponent> policyList = new ArrayList<PolicyComponent>();
+        Collection<PolicyComponent> policyList = new ArrayList<PolicyComponent>();
         policyList.addAll(getPolicySubject().getAttachedPolicyComponents());
      
         // AxisEndpoint

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java?rev=1352812&r1=1352811&r2=1352812&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java Fri Jun 22 09:04:38 2012
@@ -30,8 +30,10 @@ import org.apache.axis2.util.WSDL20Util;
 import org.apache.axis2.util.WSDLSerializationUtil;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -232,7 +234,7 @@ public class AxisBindingMessage extends 
 
 	public Policy calculateEffectivePolicy() {
 		PolicySubject policySubject = null;
-		ArrayList policyList = new ArrayList();
+		Collection<PolicyComponent> policyList = new ArrayList<PolicyComponent>();
 
 		// AxisBindingMessage
 		policySubject = getPolicySubject();

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java?rev=1352812&r1=1352811&r2=1352812&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisBindingOperation.java Fri Jun 22 09:04:38 2012
@@ -266,19 +266,15 @@ public class AxisBindingOperation extend
 	}
 
 	public Policy getEffectivePolicy() {
-		ArrayList<PolicyComponent> policyList = new ArrayList<PolicyComponent>();
-
-		PolicyInclude policyInclude;
-
-		// AxisBindingOperation policies
-		policyInclude = getPolicyInclude();
-		policyList.addAll(policyInclude.getAttachedPolicies());
+	    
+        Collection<PolicyComponent> policyList = new ArrayList<PolicyComponent>();
 
+        policyList.addAll(getPolicySubject().getAttachedPolicyComponents());
+		
 		// AxisBinding
 		AxisBinding axisBinding = getAxisBinding();
 		if (axisBinding != null) {
-			policyList.addAll(axisBinding.getPolicyInclude()
-					.getAttachedPolicies());
+            policyList.addAll(axisBinding.getPolicySubject().getAttachedPolicyComponents());
 		}
 
 		// AxisEndpoint
@@ -288,16 +284,12 @@ public class AxisBindingOperation extend
 		}
 
 		if (axisEndpoint != null) {
-			policyList.addAll(axisEndpoint.getPolicyInclude()
-					.getAttachedPolicies());
+            policyList.addAll(axisEndpoint.getPolicySubject().getAttachedPolicyComponents());
 		}
 
-		// AxisOperation
-		Policy axisOperationPolicy = axisOperation.getPolicyInclude()
-				.getEffectivePolicy();
-
-		if (axisOperationPolicy != null) {
-			policyList.add(axisOperationPolicy);
+		
+		if (axisOperation != null) {
+            policyList.addAll(axisOperation.getPolicySubject().getAttachedPolicyComponents());
 		}
 
 		return PolicyUtil.getMergedPolicy(policyList, this);

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisMessage.java?rev=1352812&r1=1352811&r2=1352812&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisMessage.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisMessage.java Fri Jun 22 09:04:38 2012
@@ -32,6 +32,7 @@ import org.apache.ws.commons.schema.*;
 
 import javax.xml.namespace.QName;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
@@ -252,7 +253,7 @@ public class AxisMessage extends AxisDes
 
 	public Policy calculateEffectivePolicy() {
 		PolicySubject policySubject;
-		ArrayList<PolicyComponent> policyList = new ArrayList<PolicyComponent>();
+		Collection<PolicyComponent> policyList = new ArrayList<PolicyComponent>();
 
 		// AxisMessage
 		policySubject = getPolicySubject();

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java?rev=1352812&r1=1352811&r2=1352812&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java Fri Jun 22 09:04:38 2012
@@ -36,6 +36,7 @@ import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyComponent;
 import org.apache.neethi.PolicyReference;
 import org.apache.neethi.PolicyRegistry;
+import org.apache.neethi.PolicyRegistryImpl;
 import org.apache.ws.commons.schema.XmlSchema;
 
 import javax.xml.namespace.QName;
@@ -530,7 +531,7 @@ public class AxisService2WSDL11 implemen
 		}
 
 
-        addPolicyAsExtElement(PolicyInclude.SERVICE_POLICY, axisService.getPolicyInclude(),
+        addPolicyAsExtElement(PolicyInclude.SERVICE_POLICY, axisService.getPolicySubject(),
                               service);
 		// addPolicyAsExtElement(PolicyInclude.AXIS_SERVICE_POLICY, axisService.
 		// getPolicyInclude(), service);
@@ -588,9 +589,9 @@ public class AxisService2WSDL11 implemen
 		}
 	}
 
-	private void addPolicyAsExtElement(int type, PolicyInclude policyInclude,
+	private void addPolicyAsExtElement(int type, PolicySubject policySubject,
 			OMElement parentElement) throws Exception {
-		ArrayList elementList = policyInclude.getPolicyElements(type);
+	    Collection<PolicyComponent> elementList = policySubject.getAttachedPolicyComponents();
 
         for (Object policyElement : elementList) {
             if (policyElement instanceof Policy) {
@@ -624,7 +625,7 @@ public class AxisService2WSDL11 implemen
                     firstChildElem.insertSiblingBefore(child);
                 }
 
-                PolicyRegistry reg = policyInclude.getPolicyRegistry();
+                PolicyRegistry reg = new PolicyRegistryImpl();
                 String key = ((PolicyReference)policyElement).getURI();
 
                 if (key.startsWith("#")) {

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/PolicyInclude.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/PolicyInclude.java?rev=1352812&r1=1352811&r2=1352812&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/PolicyInclude.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/description/PolicyInclude.java Fri Jun 22 09:04:38 2012
@@ -135,26 +135,6 @@ public class PolicyInclude {
     }
 
     /**
-	 * @deprecated As of 1.4 release, replaced by
-	 *             {@link PolicySubject #updatePolicy(Policy)}.
-	 */
-    public void updatePolicy(Policy policy) {
-        String key;
-
-        if ((key = policy.getName()) == null && (key = policy.getId()) == null) {
-            // TODO throw more meaningful exception ..
-            throw new RuntimeException("policy doesn't have a name or an id ");
-        }
-
-        Wrapper wrapper = (Wrapper) wrapperElements.get(key);
-        wrapper.value = policy;
-        
-        if (description != null) {
-			description.getPolicySubject().updatePolicy(policy);
-		}
-    }
-
-    /**
 	 * @deprecated As of 1.4 release. You can't override a policies that
 	 *             applicable for the current policy scope via
 	 *             {@link PolicyInclude #setEffectivePolicy(Policy)}. In case
@@ -279,26 +259,6 @@ public class PolicyInclude {
     }
 
     /**
-	 * @deprecated As of 1.4 release, replaced by
-	 *             {@link PolicySubject #getAttachedPolicyComponents()}
-	 */
-    public ArrayList getPolicyElements() {
-    	if (description != null) {
-			return new ArrayList<PolicyComponent>(description.getPolicySubject()
-					.getAttachedPolicyComponents());
-		}
-    	
-        ArrayList policyElementsList = new ArrayList();
-        Iterator<Wrapper> policyElementIterator = wrapperElements.values().iterator();
-
-        while (policyElementIterator.hasNext()) {
-            policyElementsList
-                    .add(policyElementIterator.next().getValue());
-        }
-        return policyElementsList;
-    }
-
-    /**
 	 * @deprecated As of 1.4 release. The policy element type is no longer
 	 *             required since we maintain a complete binding description
 	 *             hierarchy for the static description the service. Hence use
@@ -320,67 +280,6 @@ public class PolicyInclude {
         return policyElementList;
     }
 
-    /**
-	 * @deprecated As of 1.4 release. Use ServiceData.xml or Axis2 DataLocators
-	 *             to configure policies that are stored separately.
-	 */
-    public void registerPolicy(String key, Policy policy) {
-        reg.register(key, policy);
-    }
-
-    /**
-	 * @deprecated As of 1.4 release, replaced by
-	 *             {@link PolicySubject #getAttachedPolicyComponent(String)}
-	 */
-    public Policy getPolicy(String key) {
-    	if (description != null) {
-			PolicyComponent result = description.getPolicySubject()
-					.getAttachedPolicyComponent(key);
-			if (result != null && result instanceof Policy) {
-				return (Policy) result;
-			}
-		}
-    	
-        return reg.lookup(key);
-    }
-
-    /**
-	 * @deprecated As of 1.4 release, replaced by
-	 *             {@link PolicySubject #attachPolicy(Policy)}
-	 */
-    public void addPolicyElement(int type, Policy policy) {
-
-        String key;
-
-        if ((key = policy.getName()) == null && (key = policy.getId()) == null) {
-            policy.setId(UIDGenerator.generateUID());
-        }
-
-        key = (policy.getName() != null) ? policy.getName() : policy.getId();
-
-        Wrapper wrapper = new Wrapper(type, policy);
-        wrapperElements.put(key, wrapper);
-        reg.register(key, policy);
-        
-        if (description != null) {
-			description.getPolicySubject().attachPolicy(policy);
-		}
-    }
-
-    /**
-	 * @deprecated As of 1.4 release, replaced by
-	 *             {@link PolicySubject #attachPolicyReference(PolicyReference)}
-	 */
-    public void addPolicyRefElement(int type, PolicyReference policyReference) {
-        Wrapper wrapper = new Wrapper(type, policyReference);
-        wrapperElements.put(policyReference.getURI(), wrapper);
-        
-        if (description != null) {
-			description.getPolicySubject().attachPolicyReference(
-					policyReference);
-		}
-    }
-
     class Wrapper {
         private int type;
         private Object value;
@@ -406,47 +305,4 @@ public class PolicyInclude {
             return value;
         }
     }
-
-    /**
-	 * @deprecated As of 1.4 release, replaced by
-	 *             {@link PolicySubject #detachPolicyComponent(String)}
-	 */
-    public void removePolicyElement(String policyURI) {
-        wrapperElements.remove(policyURI);
-        reg.remove(policyURI);
-        
-        if (description != null) {
-			description.getPolicySubject().detachPolicyComponent(policyURI);
-		}
-    }
-
-    /**
-	 * @deprecated As of 1.4 release, replaced by {@link PolicySubject #clear()}
-	 */
-    public void removeAllPolicyElements() {
-        wrapperElements.clear();
-        
-        if (description != null) {
-			description.getPolicySubject().clear();
-		}
-    }
-    
-    /**
-	 * @deprecated As of 1.4 release, replaced by
-	 *             {@link PolicySubject #getAttachedPolicyComponents()}
-	 */
-    public List getAttachedPolicies() {
-    	if (description != null) {
-			return new ArrayList(description.getPolicySubject()
-					.getAttachedPolicyComponents());
-		}
-    	
-        ArrayList  arrayList = new ArrayList();
-        
-        for (Iterator iterator = wrapperElements.values().iterator(); iterator.hasNext();) {
-            arrayList.add(((Wrapper) iterator.next()).value);
-        }
-        
-        return arrayList;
-    }
 }

Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java?rev=1352812&r1=1352811&r2=1352812&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java Fri Jun 22 09:04:38 2012
@@ -22,6 +22,7 @@ package org.apache.axis2.util;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
@@ -40,6 +41,7 @@ import org.apache.axis2.description.Axis
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.PolicyInclude;
+import org.apache.axis2.description.PolicySubject;
 import org.apache.neethi.Constants;
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyComponent;
@@ -193,7 +195,7 @@ public class PolicyUtil {
 	}
 
 	public static String generateId(AxisDescription description) {
-		PolicyInclude policyInclude = description.getPolicyInclude();
+		PolicySubject policySubject = description.getPolicySubject();
 		String identifier = "-policy-1";
 
 		if (description instanceof AxisMessage) {
@@ -217,19 +219,19 @@ public class PolicyUtil {
 		 * Int 49 is the value of the Character '1'. Here we want to change '1'
 		 * to '2' or '2' to '3' .. etc. to construct a unique identifier.
 		 */
-		for (int index = 49; policyInclude.getPolicy(identifier) != null; index++) {
+		for (int index = 49; policySubject.getAttachedPolicyComponent(identifier) != null; index++) {
 			identifier = identifier.replace((char) index, (char) (index + 1));
 		}
 
 		return identifier;
 	}
 
-	public static Policy getMergedPolicy(List policies,
+	public static Policy getMergedPolicy(Collection<PolicyComponent> policies,
 			AxisDescription description) {
 
 		Policy policy = null;
 
-		for (Iterator iterator = policies.iterator(); iterator.hasNext();) {
+		for (Iterator<PolicyComponent> iterator = policies.iterator(); iterator.hasNext();) {
 			Object policyElement = iterator.next();
 			if (policyElement instanceof Policy) {
 				policy = (policy == null) ? (Policy) policyElement