You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Davanum Srinivas <da...@gmail.com> on 2008/10/20 16:34:15 UTC

[Axis2] bad import (Re: svn commit: r706306 - in /webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy: MTOMPolicy.java Utils.java)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nandana,

Please review before commit :)

"import com.sun.corba.se.impl.javax.rmi.CORBA.Util;"

- -- dims

nandana@apache.org wrote:
> Author: nandana
> Date: Mon Oct 20 07:28:04 2008
> New Revision: 706306
> 
> URL: http://svn.apache.org/viewvc?rev=706306&view=rev
> Log:
> mtompolicy module improvements 
> 
> Modified:
>     webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java
>     webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java
> 
> Modified: webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java?rev=706306&r1=706305&r2=706306&view=diff
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java (original)
> +++ webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java Mon Oct 20 07:28:04 2008
> @@ -5,6 +5,8 @@
>  import org.apache.axis2.context.ConfigurationContext;
>  import org.apache.axis2.description.AxisDescription;
>  import org.apache.axis2.description.AxisModule;
> +import org.apache.axis2.description.AxisService;
> +import org.apache.axis2.description.Parameter;
>  import org.apache.axis2.modules.Module;
>  import org.apache.axis2.policy.model.MTOMAssertion;
>  import org.apache.commons.logging.Log;
> @@ -12,6 +14,8 @@
>  import org.apache.neethi.Assertion;
>  import org.apache.neethi.Policy;
>  
> +import com.sun.corba.se.impl.javax.rmi.CORBA.Util;
> +
>  public class MTOMPolicy implements Module {
>  
>      /*
> @@ -48,22 +52,21 @@
>                      + axisDescription.getClass().getName());
>          }
>  
> -        boolean isOptional = false;
> -
> -        MTOMAssertion mtomAssertion = Utils.getMTOMAssertion(axisDescription);
> -
> -        if (mtomAssertion == null) {
> +        AxisService axisService = Utils.locateAxisService(axisDescription);
> +        
> +        if (axisService == null) {
> +            if (log.isDebugEnabled()) {
> +                log.debug("MTOMPolicy module couldn't find the Axis Service ");
> +            }
>              return;
>          }
>          
> -        isOptional = mtomAssertion.isOptional();
> -
> -        if (isOptional) {
> -            axisDescription.addParameter(Constants.Configuration.ENABLE_MTOM,
> -                    Constants.VALUE_OPTIONAL);
> -        } else {
> -            axisDescription.addParameter(Constants.Configuration.ENABLE_MTOM,
> -                    Constants.VALUE_TRUE);
> +        Parameter param = axisService.getParameter(Constants.Configuration.ENABLE_MTOM);
> +        
> +        Policy mtomPolicy = Utils.getMTOMPolicy(param);
> +        
> +        if (mtomPolicy != null) {
> +            Utils.applyPolicyToSOAPBindings(axisService, mtomPolicy);
>          }
>  
>      }
> 
> Modified: webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java?rev=706306&r1=706305&r2=706306&view=diff
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java (original)
> +++ webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java Mon Oct 20 07:28:04 2008
> @@ -3,40 +3,110 @@
>  import java.util.ArrayList;
>  import java.util.List;
>  
> +import org.apache.axis2.AxisFault;
> +import org.apache.axis2.Constants;
> +import org.apache.axis2.description.AxisBinding;
>  import org.apache.axis2.description.AxisDescription;
> +import org.apache.axis2.description.AxisEndpoint;
>  import org.apache.axis2.description.AxisService;
> +import org.apache.axis2.description.Parameter;
> +import org.apache.axis2.description.WSDL2Constants;
> +import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
> +import org.apache.axis2.policy.model.MTOM10Assertion;
>  import org.apache.axis2.policy.model.MTOMAssertion;
>  import org.apache.axis2.util.PolicyUtil;
>  import org.apache.neethi.Assertion;
>  import org.apache.neethi.Policy;
>  
>  public class Utils {
> -    
> -    public static MTOMAssertion getMTOMAssertion (AxisDescription axisDescription) {
> -        
> +
> +    private static final String MTOM_ASSERTION_APPLIED = "MTOM_ASSERTION_APPLIED";
> +
> +    public static MTOMAssertion getMTOMAssertion(AxisDescription axisDescription) {
> +
>          if (axisDescription == null) {
>              return null;
>          }
> -        
> +
>          ArrayList policyList = new ArrayList();
> -        policyList.addAll(axisDescription.getPolicySubject().getAttachedPolicyComponents());
> -            
> +        policyList.addAll(axisDescription.getPolicySubject()
> +                .getAttachedPolicyComponents());
> +
>          Policy policy = PolicyUtil.getMergedPolicy(policyList, axisDescription);
> -        
> +
>          if (policy == null) {
>              return null;
>          }
> -            
> -        List<Assertion> list = (List<Assertion>)policy.getAlternatives().next();
> -            
> +
> +        List<Assertion> list = (List<Assertion>) policy.getAlternatives()
> +                .next();
> +
>          for (Assertion assertion : list) {
>              if (assertion instanceof MTOMAssertion) {
> -               return (MTOMAssertion)assertion;
> +                return (MTOMAssertion) assertion;
>              }
>          }
> -        
> +
>          return null;
> +
> +    }
> +
> +    public static AxisService locateAxisService(AxisDescription axisDescription) {
> +
> +        if (axisDescription == null || axisDescription instanceof AxisService) {
> +            return (AxisService) axisDescription;
> +        } else {
> +            return locateAxisService(axisDescription.getParent());
> +        }
> +    }
> +
> +    public static Policy getMTOMPolicy(Parameter param) {
> +
> +        if (param == null) {
> +            return null;
> +        }
> +
> +        MTOMAssertion mtom10;
> +
> +        if (Constants.VALUE_TRUE.equals(param.getValue())) {
> +            mtom10 = new MTOM10Assertion();
> +        } else if (Constants.VALUE_OPTIONAL.equals(param.getValue())) {
> +            mtom10 = new MTOM10Assertion();
> +            mtom10.setOptional(true);
> +        } else {
> +            return null;
> +        }
> +
> +        Policy policy = new Policy();
> +        policy.addAssertion(mtom10);
> +
> +        return policy;
> +
> +    }
> +
> +    public static void applyPolicyToSOAPBindings(AxisService axisService,
> +            Policy policy) throws AxisFault {
>          
> +        Parameter param = axisService.getParameter(MTOM_ASSERTION_APPLIED);
> +
> +        if ( policy == null || (param != null && Constants.VALUE_TRUE.equals(param.getValue()))) {
> +            return;
> +        }
> +
> +        for (Object obj : axisService.getEndpoints().values()) {
> +
> +            AxisEndpoint endpoint = (AxisEndpoint) obj;
> +            AxisBinding binding = endpoint.getBinding();
> +
> +            if (Java2WSDLConstants.TRANSPORT_URI.equals(binding.getType())
> +                    || WSDL2Constants.URI_WSDL2_SOAP.equals(binding.getType())) {
> +                binding.getPolicySubject().attachPolicy(policy);
> +            }
> +        }
> +
> +        axisService
> +                .addParameter("MTOM_ASSERTION_APPLIED", Constants.VALUE_TRUE);
> +
>      }
>  
>  }
> 
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFI/JbmgNg6eWEDv1kRAtwmAJwJ0PwPSYLfSy/1V8kkZdyDkVP4IQCfbCel
j2f7YcHirsOJi/Zk8jRF2xE=
=jfsr
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] bad import (Re: svn commit: r706306 - in /webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy: MTOMPolicy.java Utils.java)

Posted by Nandana Mihindukulasooriya <na...@gmail.com>.
Dims,
    My bad and thank for pointing out. Fixed.

thanks,
nandana

On Mon, Oct 20, 2008 at 8:34 PM, Davanum Srinivas <da...@gmail.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Nandana,
>
> Please review before commit :)
>
> "import com.sun.corba.se.impl.javax.rmi.CORBA.Util;"
>
> - -- dims
>
> nandana@apache.org wrote:
> > Author: nandana
> > Date: Mon Oct 20 07:28:04 2008
> > New Revision: 706306
> >
> > URL: http://svn.apache.org/viewvc?rev=706306&view=rev
> > Log:
> > mtompolicy module improvements
> >
> > Modified:
> >
> webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java
> >
> webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java
> >
> > Modified:
> webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java
> > URL:
> http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java?rev=706306&r1=706305&r2=706306&view=diff
> >
> ==============================================================================
> > ---
> webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java
> (original)
> > +++
> webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java
> Mon Oct 20 07:28:04 2008
> > @@ -5,6 +5,8 @@
> >  import org.apache.axis2.context.ConfigurationContext;
> >  import org.apache.axis2.description.AxisDescription;
> >  import org.apache.axis2.description.AxisModule;
> > +import org.apache.axis2.description.AxisService;
> > +import org.apache.axis2.description.Parameter;
> >  import org.apache.axis2.modules.Module;
> >  import org.apache.axis2.policy.model.MTOMAssertion;
> >  import org.apache.commons.logging.Log;
> > @@ -12,6 +14,8 @@
> >  import org.apache.neethi.Assertion;
> >  import org.apache.neethi.Policy;
> >
> > +import com.sun.corba.se.impl.javax.rmi.CORBA.Util;
> > +
> >  public class MTOMPolicy implements Module {
> >
> >      /*
> > @@ -48,22 +52,21 @@
> >                      + axisDescription.getClass().getName());
> >          }
> >
> > -        boolean isOptional = false;
> > -
> > -        MTOMAssertion mtomAssertion =
> Utils.getMTOMAssertion(axisDescription);
> > -
> > -        if (mtomAssertion == null) {
> > +        AxisService axisService =
> Utils.locateAxisService(axisDescription);
> > +
> > +        if (axisService == null) {
> > +            if (log.isDebugEnabled()) {
> > +                log.debug("MTOMPolicy module couldn't find the Axis
> Service ");
> > +            }
> >              return;
> >          }
> >
> > -        isOptional = mtomAssertion.isOptional();
> > -
> > -        if (isOptional) {
> > -
>  axisDescription.addParameter(Constants.Configuration.ENABLE_MTOM,
> > -                    Constants.VALUE_OPTIONAL);
> > -        } else {
> > -
>  axisDescription.addParameter(Constants.Configuration.ENABLE_MTOM,
> > -                    Constants.VALUE_TRUE);
> > +        Parameter param =
> axisService.getParameter(Constants.Configuration.ENABLE_MTOM);
> > +
> > +        Policy mtomPolicy = Utils.getMTOMPolicy(param);
> > +
> > +        if (mtomPolicy != null) {
> > +            Utils.applyPolicyToSOAPBindings(axisService, mtomPolicy);
> >          }
> >
> >      }
> >
> > Modified:
> webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java
> > URL:
> http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java?rev=706306&r1=706305&r2=706306&view=diff
> >
> ==============================================================================
> > ---
> webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java
> (original)
> > +++
> webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java
> Mon Oct 20 07:28:04 2008
> > @@ -3,40 +3,110 @@
> >  import java.util.ArrayList;
> >  import java.util.List;
> >
> > +import org.apache.axis2.AxisFault;
> > +import org.apache.axis2.Constants;
> > +import org.apache.axis2.description.AxisBinding;
> >  import org.apache.axis2.description.AxisDescription;
> > +import org.apache.axis2.description.AxisEndpoint;
> >  import org.apache.axis2.description.AxisService;
> > +import org.apache.axis2.description.Parameter;
> > +import org.apache.axis2.description.WSDL2Constants;
> > +import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
> > +import org.apache.axis2.policy.model.MTOM10Assertion;
> >  import org.apache.axis2.policy.model.MTOMAssertion;
> >  import org.apache.axis2.util.PolicyUtil;
> >  import org.apache.neethi.Assertion;
> >  import org.apache.neethi.Policy;
> >
> >  public class Utils {
> > -
> > -    public static MTOMAssertion getMTOMAssertion (AxisDescription
> axisDescription) {
> > -
> > +
> > +    private static final String MTOM_ASSERTION_APPLIED =
> "MTOM_ASSERTION_APPLIED";
> > +
> > +    public static MTOMAssertion getMTOMAssertion(AxisDescription
> axisDescription) {
> > +
> >          if (axisDescription == null) {
> >              return null;
> >          }
> > -
> > +
> >          ArrayList policyList = new ArrayList();
> > -
>  policyList.addAll(axisDescription.getPolicySubject().getAttachedPolicyComponents());
> > -
> > +        policyList.addAll(axisDescription.getPolicySubject()
> > +                .getAttachedPolicyComponents());
> > +
> >          Policy policy = PolicyUtil.getMergedPolicy(policyList,
> axisDescription);
> > -
> > +
> >          if (policy == null) {
> >              return null;
> >          }
> > -
> > -        List<Assertion> list =
> (List<Assertion>)policy.getAlternatives().next();
> > -
> > +
> > +        List<Assertion> list = (List<Assertion>)
> policy.getAlternatives()
> > +                .next();
> > +
> >          for (Assertion assertion : list) {
> >              if (assertion instanceof MTOMAssertion) {
> > -               return (MTOMAssertion)assertion;
> > +                return (MTOMAssertion) assertion;
> >              }
> >          }
> > -
> > +
> >          return null;
> > +
> > +    }
> > +
> > +    public static AxisService locateAxisService(AxisDescription
> axisDescription) {
> > +
> > +        if (axisDescription == null || axisDescription instanceof
> AxisService) {
> > +            return (AxisService) axisDescription;
> > +        } else {
> > +            return locateAxisService(axisDescription.getParent());
> > +        }
> > +    }
> > +
> > +    public static Policy getMTOMPolicy(Parameter param) {
> > +
> > +        if (param == null) {
> > +            return null;
> > +        }
> > +
> > +        MTOMAssertion mtom10;
> > +
> > +        if (Constants.VALUE_TRUE.equals(param.getValue())) {
> > +            mtom10 = new MTOM10Assertion();
> > +        } else if (Constants.VALUE_OPTIONAL.equals(param.getValue())) {
> > +            mtom10 = new MTOM10Assertion();
> > +            mtom10.setOptional(true);
> > +        } else {
> > +            return null;
> > +        }
> > +
> > +        Policy policy = new Policy();
> > +        policy.addAssertion(mtom10);
> > +
> > +        return policy;
> > +
> > +    }
> > +
> > +    public static void applyPolicyToSOAPBindings(AxisService
> axisService,
> > +            Policy policy) throws AxisFault {
> >
> > +        Parameter param =
> axisService.getParameter(MTOM_ASSERTION_APPLIED);
> > +
> > +        if ( policy == null || (param != null &&
> Constants.VALUE_TRUE.equals(param.getValue()))) {
> > +            return;
> > +        }
> > +
> > +        for (Object obj : axisService.getEndpoints().values()) {
> > +
> > +            AxisEndpoint endpoint = (AxisEndpoint) obj;
> > +            AxisBinding binding = endpoint.getBinding();
> > +
> > +            if
> (Java2WSDLConstants.TRANSPORT_URI.equals(binding.getType())
> > +                    ||
> WSDL2Constants.URI_WSDL2_SOAP.equals(binding.getType())) {
> > +                binding.getPolicySubject().attachPolicy(policy);
> > +            }
> > +        }
> > +
> > +        axisService
> > +                .addParameter("MTOM_ASSERTION_APPLIED",
> Constants.VALUE_TRUE);
> > +
> >      }
> >
> >  }
> >
> >
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFI/JbmgNg6eWEDv1kRAtwmAJwJ0PwPSYLfSy/1V8kkZdyDkVP4IQCfbCel
> j2f7YcHirsOJi/Zk8jRF2xE=
> =jfsr
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>