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 na...@apache.org on 2008/10/08 09:47:26 UTC

svn commit: r702747 - in /webservices/axis2/trunk/java/modules/mtompolicy-mar: ./ src/ src/META-INF/ src/org/ src/org/apache/ src/org/apache/axis2/ src/org/apache/axis2/mtompolicy/

Author: nandana
Date: Wed Oct  8 00:47:25 2008
New Revision: 702747

URL: http://svn.apache.org/viewvc?rev=702747&view=rev
Log:
mtompolicy-mar module as discussed in http://tinyurl.com/3nf4m2.

Added:
    webservices/axis2/trunk/java/modules/mtompolicy-mar/
    webservices/axis2/trunk/java/modules/mtompolicy-mar/pom.xml
    webservices/axis2/trunk/java/modules/mtompolicy-mar/src/
    webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/
    webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/module.xml
    webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/
    webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/
    webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/
    webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/
    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

Added: webservices/axis2/trunk/java/modules/mtompolicy-mar/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mtompolicy-mar/pom.xml?rev=702747&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/mtompolicy-mar/pom.xml (added)
+++ webservices/axis2/trunk/java/modules/mtompolicy-mar/pom.xml Wed Oct  8 00:47:25 2008
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.axis2</groupId>
+        <artifactId>axis2-parent</artifactId>
+        <version>SNAPSHOT</version>
+        <relativePath>../parent/pom.xml</relativePath>
+    </parent>
+    <artifactId>axis2-mtompolicy-mar</artifactId>
+    <name>Apache Axis2 - MTOM Policy module</name>
+    <description>Axis2 : MTOM Policy module</description>
+    <packaging>mar</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-kernel</artifactId>
+            <version>${version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.axis2</groupId>
+            <artifactId>axis2-mtompolicy</artifactId>
+            <version>${version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.neethi</groupId>
+            <artifactId>neethi</artifactId>
+        </dependency>
+    </dependencies>
+    <build>
+        <sourceDirectory>src</sourceDirectory>
+        <resources>
+            <resource>
+                <directory>../..</directory>
+                <includes>
+                    <include>NOTICE.txt</include>
+                    <include>LICENSE.txt</include>
+                </includes>
+                <filtering>false</filtering>
+            </resource>
+            <resource>
+                <directory>src</directory>
+                <excludes>
+                    <exclude>**/*.java</exclude>
+                </excludes>
+            </resource>
+        </resources>
+        <testSourceDirectory>test</testSourceDirectory>
+        <testResources>
+            <testResource>
+                <directory>test-resources</directory>
+            </testResource>
+        </testResources>
+        <plugins>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <inherited>true</inherited>
+                <configuration>
+                    <skip>false</skip>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.axis2</groupId>
+                <artifactId>axis2-mar-maven-plugin</artifactId>
+                <version>${version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <includeDependencies>false</includeDependencies>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/module.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/module.xml?rev=702747&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/module.xml (added)
+++ webservices/axis2/trunk/java/modules/mtompolicy-mar/src/META-INF/module.xml Wed Oct  8 00:47:25 2008
@@ -0,0 +1,6 @@
+<module name="mtompolicy" class="org.apache.axis2.mtompolicy.MTOMPolicy">
+    <Description>
+      fill in the description
+    </Description>
+</module>
+

Added: 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=702747&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java (added)
+++ webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/MTOMPolicy.java Wed Oct  8 00:47:25 2008
@@ -0,0 +1,61 @@
+package org.apache.axis2.mtompolicy;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisDescription;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.modules.Module;
+import org.apache.axis2.policy.model.MTOMAssertion;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+public class MTOMPolicy implements Module{
+
+    public void applyPolicy(Policy policy, AxisDescription axisDescription)
+            throws AxisFault {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public boolean canSupportAssertion(Assertion assertion) {
+        
+        if (assertion instanceof MTOMAssertion) {
+            return true;
+        }
+
+        return false;
+    }
+
+    public void engageNotify(AxisDescription axisDescription) throws AxisFault {
+        
+        boolean isOptional = false;
+            
+        MTOMAssertion mtomAssertion = Utils.getMTOMAssertion(axisDescription);
+
+        if (mtomAssertion == null) {
+            return;
+        }
+        
+        if ( isOptional) {
+            axisDescription.addParameter("enableMTOM", Constants.VALUE_OPTIONAL);
+        } else {
+            axisDescription.addParameter("enableMTOM", Constants.VALUE_TRUE);
+        }
+                
+                          
+    }
+
+    public void init(ConfigurationContext configContext, AxisModule module)
+            throws AxisFault {
+        // nothing to do here yet
+        
+    }
+
+    public void shutdown(ConfigurationContext configurationContext)
+            throws AxisFault {
+        // nothing to do here yet
+        
+    }
+
+}

Added: 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=702747&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java (added)
+++ webservices/axis2/trunk/java/modules/mtompolicy-mar/src/org/apache/axis2/mtompolicy/Utils.java Wed Oct  8 00:47:25 2008
@@ -0,0 +1,42 @@
+package org.apache.axis2.mtompolicy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.axis2.description.AxisDescription;
+import org.apache.axis2.description.AxisService;
+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) {
+        
+        if (axisDescription == null) {
+            return null;
+        }
+        
+        ArrayList policyList = new ArrayList();
+        policyList.addAll(axisDescription.getPolicySubject().getAttachedPolicyComponents());
+            
+        Policy policy = PolicyUtil.getMergedPolicy(policyList, axisDescription);
+        
+        if (policy == null) {
+            return null;
+        }
+            
+        List<Assertion> list = (List<Assertion>)policy.getAlternatives().next();
+            
+        for (Assertion assertion : list) {
+            if (assertion instanceof MTOMAssertion) {
+               return (MTOMAssertion)assertion;
+            }
+        }
+        
+        return null;
+        
+    }
+
+}