synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sami...@apache.org
Subject svn commit: r356068 - in /incubator/synapse/trunk/java: ./ config/ src/org/apache/synapse/axis2/ src/sampleMediators/deprecation/ src/sampleMediators/deprecation/META-INF/
Date Sun, 11 Dec 2005 23:45:37 GMT
Author: saminda
Date: Sun Dec 11 15:45:33 2005
New Revision: 356068

URL: http://svn.apache.org/viewcvs?rev=356068&view=rev
Log:
Remove the config folder. Added the resouces to its .aar rather. 

Added:
    incubator/synapse/trunk/java/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java
      - copied, changed from r355984, incubator/synapse/trunk/java/src/org/apache/synapse/axis2/MediatationMessageReceiver.java
    incubator/synapse/trunk/java/src/sampleMediators/deprecation/META-INF/deprecation.xml
Removed:
    incubator/synapse/trunk/java/config/
    incubator/synapse/trunk/java/src/org/apache/synapse/axis2/MediatationMessageReceiver.java
Modified:
    incubator/synapse/trunk/java/maven.xml
    incubator/synapse/trunk/java/src/sampleMediators/deprecation/DeprecationConfigurator.java
    incubator/synapse/trunk/java/src/sampleMediators/deprecation/DeprecationMediator.java
    incubator/synapse/trunk/java/src/sampleMediators/deprecation/META-INF/services.xml

Modified: incubator/synapse/trunk/java/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/maven.xml?rev=356068&r1=356067&r2=356068&view=diff
==============================================================================
--- incubator/synapse/trunk/java/maven.xml (original)
+++ incubator/synapse/trunk/java/maven.xml Sun Dec 11 15:45:33 2005
@@ -71,7 +71,7 @@
                  basedir="target/services/npe">
                 <include name="**"/>
             </jar>
-             <echo message="----------------Creating test-mediator aar----------------"/>
+            <echo message="----------------Creating test-mediator aar----------------"/>
             <mkdir dir="target/services/test-mediator/META-INF"/>
             <mkdir dir="target/services/test-mediator/org/apache/axis2/test"/>
             <copy file="test/org/apache/axis2/META-INF/service-mediator.xml"
@@ -115,6 +115,7 @@
 
             <ant:delete file="target/npe.aar"/>
             <ant:delete file="target/test-mediator.aar"/>
+            <ant:delete dir="target/test-mediator"/>
 
         </j:if>
 
@@ -157,16 +158,43 @@
         <copy file="synapse-test-resources/axis2/modules/addressing.mar"
               tofile="target/synapse-repository-send/modules/addressing.mar"/>
         <copy file="repo/axis2.xml"
-                  tofile="target/synapse-repository-sendonAxis2/axis2.xml"/>
+              tofile="target/synapse-repository-sendonAxis2/axis2.xml"/>
         <copy file="test/rules/synapse-send.xml"
               tofile="target/synapse-repository-send/synapse.xml"/>
 
+        <echo message="----------------Creating DeprecationMediator aar----------------"/>
+        <mkdir dir="target/sample-deprecation/META-INF"/>
+        <mkdir dir="target/sample-deprecation/sampleMediators/deprecation"/>
+        <copy file="src/sampleMediators/deprecation/META-INF/services.xml"
+              tofile="target/sample-deprecation/META-INF/services.xml"/>
+        <copy file="src/sampleMediators/deprecation/META-INF/deprecation.xml"
+              tofile="target/sample-deprecation/META-INF/deprecation.xml"/>
+
+        <ant:copy todir="target/sample-deprecation">
+            <ant:fileset dir="classes">
+                <ant:include name="sampleMediators/deprecation/**"/>
+                <ant:exclude name="sampleMediators/deprecation/**/*.xml"/>
+            </ant:fileset>
+        </ant:copy>
+
+        <mkdir dir="target/samples"/>
+        <jar jarfile="target/DeprecationMediator.aar"
+             basedir="target/sample-deprecation">
+            <include name="**"/>
+        </jar>
+
+        <copy file="target/DeprecationMediator.aar"
+              tofile="target/samples/DeprecationMediator.aar"/>
+
         <!-- Deleteing helper stuff-->
 
         <ant:delete dir="target/modules"/>
         <ant:delete dir="target/services"/>
         <ant:delete file="target/emptymediator.aar"/>
         <ant:delete file="target/synapse.aar"/>
+        <ant:delete dir="target/sample-deprecation"/>
+        <ant:delete file="target/DeprecationMediator.aar"/>
+
 
 
 

Copied: incubator/synapse/trunk/java/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java
(from r355984, incubator/synapse/trunk/java/src/org/apache/synapse/axis2/MediatationMessageReceiver.java)
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java?p2=incubator/synapse/trunk/java/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java&p1=incubator/synapse/trunk/java/src/org/apache/synapse/axis2/MediatationMessageReceiver.java&r1=355984&r2=356068&rev=356068&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/org/apache/synapse/axis2/MediatationMessageReceiver.java
(original)
+++ incubator/synapse/trunk/java/src/org/apache/synapse/axis2/ServiceMediatorMessageReceiver.java
Sun Dec 11 15:45:33 2005
@@ -1,6 +1,7 @@
 package org.apache.synapse.axis2;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.DependencyManager;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.receivers.AbstractMessageReceiver;
 import org.apache.synapse.Constants;
@@ -23,9 +24,15 @@
 *
 */
 
-public class MediatationMessageReceiver extends AbstractMessageReceiver {
+public class ServiceMediatorMessageReceiver extends AbstractMessageReceiver {
     public void receive(MessageContext messageContext) throws AxisFault {
-        Mediator mediator = (Mediator) makeNewServiceObject(messageContext);
+        Object obj = makeNewServiceObject(messageContext);
+        /**
+         * Dependency manager is used in inject MessageContext to the mediator object
+         * So some service related properties can be taken from META-INF folder
+         */
+        DependencyManager.configureBusinessLogicProvider(obj,messageContext,null);
+        Mediator mediator = (Mediator)obj;
         SynapseMessage smc = new Axis2SynapseMessage(messageContext);
         boolean returnValue = mediator.mediate(smc);
         messageContext.setProperty(Constants.MEDIATOR_STATUS, new Boolean(returnValue));

Modified: incubator/synapse/trunk/java/src/sampleMediators/deprecation/DeprecationConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/sampleMediators/deprecation/DeprecationConfigurator.java?rev=356068&r1=356067&r2=356068&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/sampleMediators/deprecation/DeprecationConfigurator.java
(original)
+++ incubator/synapse/trunk/java/src/sampleMediators/deprecation/DeprecationConfigurator.java
Sun Dec 11 15:45:33 2005
@@ -22,6 +22,7 @@
 
 import javax.xml.namespace.QName;
 import java.io.File;
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -69,6 +70,19 @@
             e.printStackTrace();
         }
     }
+    public DeprecationConfigurator(InputStream instream) {
+
+        /**
+         * This has been added to get the consistancy in getting input steams for
+         * Mediator configuraion.
+         */
+        try {
+            configMap = generateMap(instream);
+            setConfig(configMap);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 
     private Map generateMap() throws Exception {
 
@@ -85,6 +99,47 @@
         StAXOMBuilder staxOMBuilder;
 
         staxOMBuilder = new StAXOMBuilder(filePath);
+
+        OMElement config = staxOMBuilder.getDocumentElement();
+        config.build();
+        Iterator serviceItr = config.getChildrenWithName(new QName(DeprecationConstants.CFG_DEPRECATION_SERVICE));
+
+        while (serviceItr.hasNext()) {
+            OMElement serviceEle = (OMElement) serviceItr.next();
+            String serviceKey = serviceEle.getAttributeValue(new QName("Id"));
+            Iterator paramItr = serviceEle.getChildElements();
+            int counter = 0;
+            Map dataMap = new HashMap();
+
+            while (paramItr.hasNext()) {
+                OMElement paramEle = (OMElement) paramItr.next();
+                Iterator dataItr = paramEle.getChildElements();
+
+                while (dataItr.hasNext()) {
+                    OMElement dataEle = (OMElement) dataItr.next();
+                    String dataName = dataEle.getLocalName() + "[" + counter + "]";
+                    String dataValue = dataEle.getText();
+                    dataMap.put(dataName, dataValue);
+                }
+
+                //Will be of use if multiple services are facaded by a single serviceEPR
+                dataMap.put(DeprecationConstants.CFG_DEPRECATION_SERVICE + "[" + counter
+ "]", serviceKey);
+                counter++;
+
+            }
+            generatedMap.put(serviceKey, dataMap);
+        }
+        return generatedMap;
+    }
+
+    private Map generateMap(InputStream instream) throws Exception {
+
+        //Read the source and generate a map of the
+        Map generatedMap = new HashMap();
+
+        StAXOMBuilder staxOMBuilder;
+
+        staxOMBuilder = new StAXOMBuilder(instream);
 
         OMElement config = staxOMBuilder.getDocumentElement();
         config.build();

Modified: incubator/synapse/trunk/java/src/sampleMediators/deprecation/DeprecationMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/sampleMediators/deprecation/DeprecationMediator.java?rev=356068&r1=356067&r2=356068&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/sampleMediators/deprecation/DeprecationMediator.java
(original)
+++ incubator/synapse/trunk/java/src/sampleMediators/deprecation/DeprecationMediator.java
Sun Dec 11 15:45:33 2005
@@ -16,16 +16,26 @@
 
 package sampleMediators.deprecation;
 
+import org.apache.axis2.context.MessageContext;
 import org.apache.synapse.SynapseMessage;
 import org.apache.synapse.api.Mediator;
 
+import java.io.InputStream;
 import java.util.Map;
 
 public class DeprecationMediator implements Mediator {
 
-    private static final DeprecationConfigurator deprecationConfigurator = new DeprecationConfigurator();
-
     DeprecationConfiguration configuration;
+    private InputStream depricationInStream;
+
+    /**
+     * work around to get the deprication.xml into the mediator system
+     */
+    public void init(MessageContext messageContext) {
+        this.depricationInStream = messageContext.getServiceContext()
+                .getAxisService().getClassLoader()
+                .getResourceAsStream("META-INF/deprecation.xml");
+    }
 
     public DeprecationMediator() {
     }
@@ -33,8 +43,10 @@
     public boolean mediate(SynapseMessage synapseMessageContext) {
 
         try {
-
-            Map mediatorConfig = deprecationConfigurator.getConfig(synapseMessageContext.getTo());
+            final DeprecationConfigurator deprecationConfigurator =
+                    new DeprecationConfigurator(this.depricationInStream);
+            Map mediatorConfig = deprecationConfigurator
+                    .getConfig(synapseMessageContext.getTo());
             loadConfiguration(mediatorConfig);
             DeprecationRule rules[] = configuration.getRules();
             boolean deprecated = false;
@@ -47,7 +59,9 @@
 
             }
 
-            synapseMessageContext.setProperty(DeprecationConstants.CFG_DEPRECATION_RESULT,
Boolean.valueOf(deprecated));
+            synapseMessageContext.setProperty(
+                    DeprecationConstants.CFG_DEPRECATION_RESULT,
+                    Boolean.valueOf(deprecated));
 
             return !(deprecated);
 
@@ -62,10 +76,14 @@
 
         for (int i = 0; true; i++) {
 
-            String serviceKey = DeprecationConstants.CFG_DEPRECATION_SERVICE + "[" + i +
"]";
-            String fromDateKey = DeprecationConstants.CFG_DEPRECATION_FROM_DATE + "[" + i
+ "]";
-            String toDateKey = DeprecationConstants.CFG_DEPRECATION_TO_DATE + "[" + i + "]";
-            String enabledKey = DeprecationConstants.CFG_DEPRECATION_ENABLED + "[" + i +
"]";
+            String serviceKey = DeprecationConstants.CFG_DEPRECATION_SERVICE +
+                    "[" + i + "]";
+            String fromDateKey = DeprecationConstants
+                    .CFG_DEPRECATION_FROM_DATE + "[" + i + "]";
+            String toDateKey = DeprecationConstants.CFG_DEPRECATION_TO_DATE +
+                    "[" + i + "]";
+            String enabledKey = DeprecationConstants.CFG_DEPRECATION_ENABLED +
+                    "[" + i + "]";
 
             if (mediatorConfig.get(serviceKey) == null) {
                 break;

Added: incubator/synapse/trunk/java/src/sampleMediators/deprecation/META-INF/deprecation.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/sampleMediators/deprecation/META-INF/deprecation.xml?rev=356068&view=auto
==============================================================================
--- incubator/synapse/trunk/java/src/sampleMediators/deprecation/META-INF/deprecation.xml
(added)
+++ incubator/synapse/trunk/java/src/sampleMediators/deprecation/META-INF/deprecation.xml
Sun Dec 11 15:45:33 2005
@@ -0,0 +1,23 @@
+<!-- The time format is d/m/y:H:m and its with respect to UTC.
+TimeZone is that of the system, offset from UTC is calculated internally -->
+<deprecationConfig>
+    <deprecationService Id="http://localhost:8080/deprecatedService">
+        <parameterSet>
+            <deprecationFromdate>16/10/2005:00:00</deprecationFromdate>
+            <deprecationTodate>15/11/2005:00:00</deprecationTodate>
+            <deprecationEnabled>true</deprecationEnabled>
+        </parameterSet>
+        <parameterSet>
+            <deprecationFromdate>06/09/2005:00:00</deprecationFromdate>
+            <deprecationTodate>07/12/2006:00:00</deprecationTodate>
+            <deprecationEnabled>true</deprecationEnabled>
+        </parameterSet>
+    </deprecationService>
+    <deprecationService Id="http://localhost:8080/notDeprecated">
+        <parameterSet>
+            <deprecationFromdate>06/09/2005:00:00</deprecationFromdate>
+            <deprecationTodate>26/12/2005:00:00</deprecationTodate>
+            <deprecationEnabled>false</deprecationEnabled>
+        </parameterSet>
+    </deprecationService>
+</deprecationConfig>
\ No newline at end of file

Modified: incubator/synapse/trunk/java/src/sampleMediators/deprecation/META-INF/services.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/sampleMediators/deprecation/META-INF/services.xml?rev=356068&r1=356067&r2=356068&view=diff
==============================================================================
--- incubator/synapse/trunk/java/src/sampleMediators/deprecation/META-INF/services.xml (original)
+++ incubator/synapse/trunk/java/src/sampleMediators/deprecation/META-INF/services.xml Sun
Dec 11 15:45:33 2005
@@ -1,7 +1,10 @@
 <!-- Can be used if the mediator is to be provided as an axis2 service-->
 <service name="DeprecationMediator">
+    <parameter name="ServiceClass" locked="false">
+        sampleMediators.deprecation.DeprecationMediator</parameter>
     <operation name="mediate">
-        <messageReceiver class="sampleMediators.deprecation.DeprecationMediator"/>
+        <messageReceiver
+                class="org.apache.synapse.axis2.ServiceMediatorMessageReceiver"/>
     </operation>
 </service>
   



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


Mime
View raw message