You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by sa...@apache.org on 2006/02/15 08:11:37 UTC
svn commit: r377953 [4/9] - in
/incubator/synapse/trunk/scratch/synase-multimodules: ./ bin/ etc/ modules/
modules/core/ modules/core/conf/ modules/core/src/ modules/core/src/org/
modules/core/src/org/apache/ modules/core/src/org/apache/synapse/ module...
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/RefProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/RefProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/RefProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/RefProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+
+/**
+ *
+ *
+ * Calls another processor which is referred to by the Ref property.
+ *
+ */
+public class RefProcessor extends AbstractProcessor {
+ private Log log = LogFactory.getLog(getClass());
+ private String ref = null;
+
+ public boolean process(SynapseEnvironment se, SynapseMessage sm) {
+ log.debug("process");
+ Processor p = se.lookupProcessor(getRef());
+ if (p==null) log.debug("processor with name "+this.getRef()+" not found");
+ else return p.process(se, sm);
+ return true;
+ }
+
+ public void setRef(String ref) {
+ this.ref = ref;
+ }
+
+ public String getRef() {
+ return ref;
+ }
+
+
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/StageProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/StageProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/StageProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/StageProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors;
+
+
+/**
+ *
+ *
+ *
+ */
+public class StageProcessor extends ListProcessor {
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/SynapseProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/SynapseProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/SynapseProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/SynapseProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors;
+
+/**
+ *
+ *
+ * This implements the main processor. Delegates to ListProcessor
+ * Here in case we need the main <synapse> to do anything special
+ *
+ */
+public class SynapseProcessor extends ListProcessor {
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/DropProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/DropProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/DropProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/DropProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors.builtin;
+
+import org.apache.synapse.processors.AbstractProcessor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+
+/**
+ * Implementaion of <drop/>
+ */
+public class DropProcessor extends AbstractProcessor {
+
+ public boolean process(SynapseEnvironment se, SynapseMessage sm) {
+ if (sm.getTo() == null) {
+ return false;
+ }else{
+ sm.setTo(null);
+ return false;
+ }
+ }
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/HeaderProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/HeaderProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/HeaderProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/HeaderProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+
+package org.apache.synapse.processors.builtin;
+
+import org.apache.synapse.HeaderType;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.processors.AbstractProcessor;
+
+/**
+ *
+ * @see org.apache.synapse.HeaderType
+ * <p> Sets aspects of the header to new values.
+ * Uses HeaderType to set header values
+ *
+ */
+public class HeaderProcessor extends AbstractProcessor {
+
+ private HeaderType headerType = new HeaderType();
+
+ private String value = null;
+
+ public void setHeaderType(String ht) {
+ headerType.setHeaderType(ht);
+ }
+
+ public String getHeaderType() {
+ return headerType.getHeaderType();
+ }
+
+ public boolean process(SynapseEnvironment se, SynapseMessage sm) {
+
+ headerType.setHeader(sm, getValue());
+ return true;
+ }
+
+
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/LogProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/LogProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/LogProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/LogProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors.builtin;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.processors.AbstractProcessor;
+
+/**
+ *
+ * <p>
+ * Logs the message using commons logging
+ *
+ * <p>
+ * TODO make configurable - short or detailed logs
+ *
+ */
+public class LogProcessor extends AbstractProcessor {
+
+ private Log log = LogFactory.getLog(getClass());
+
+ public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+ log.info("---------------------------------------");
+ if (smc.getTo() != null)
+ log.info("To: " + smc.getTo().getAddress());
+ if (smc.getFrom() != null)
+ log.info("From: " + smc.getFrom().getAddress());
+ if (smc.getReplyTo() != null)
+ log.info("ReplyTo: " + smc.getReplyTo().getAddress());
+ if (smc.getEnvelope() != null)
+ log.info("Envelope: " + smc.getEnvelope().toString());
+ log.info("---------------------------------------");
+ return true;
+ }
+
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/SendNowProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/SendNowProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/SendNowProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/SendNowProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors.builtin;
+
+import org.apache.synapse.processors.AbstractProcessor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.synapse.axis2.Axis2FlexibleMEPClient;
+import org.apache.synapse.axis2.DynamicAxisOperation;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.util.UUIDGenerator;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.deployment.util.PhasesInfo;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.wsdl.WSDLConstants;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Implementaion of <sendnow/>
+ */
+public class SendNowProcessor extends AbstractProcessor {
+ public boolean process(SynapseEnvironment se, SynapseMessage sm) {
+ MessageContext mc = ((Axis2SynapseMessage)sm).getMessageContext();
+
+ try {
+ MessageContext response = send(mc);
+ if (response.getProperty(MessageContext.TRANSPORT_IN) !=null) {
+ SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(
+ response, mc.getEnvelope().getNamespace()
+ .getName());
+
+ response.setEnvelope(resenvelope);
+ outMessageSerialization(response,mc,sm);
+ }
+
+
+ } catch (AxisFault axisFault) {
+ throw new SynapseException(axisFault);
+ }
+ // this will stop processing message and what User
+ return false;
+ }
+
+ public MessageContext send(MessageContext smc) throws AxisFault {
+ ConfigurationContext cc = smc.getConfigurationContext();
+ AxisConfiguration ac = cc.getAxisConfiguration();
+ PhasesInfo phasesInfo = ac.getPhasesInfo();
+
+ // setting operation default chains
+ if (ac.getService("__ANONYMOUS_SERVICE__") == null) {
+ DynamicAxisOperation operation = new DynamicAxisOperation(new QName(
+ "__DYNAMIC_OPERATION__"));
+ AxisService axisAnonymousService =
+ new AxisService("__ANONYMOUS_SERVICE__");
+ axisAnonymousService.addOperation(operation);
+ ac.addService(axisAnonymousService);
+ phasesInfo.setOperationPhases(operation);
+ }
+ ServiceGroupContext sgc = new ServiceGroupContext(cc,
+ ac.getService("__ANONYMOUS_SERVICE__").getParent());
+ ServiceContext sc =
+ sgc.getServiceContext(new AxisService("__ANONYMOUS_SERVICE__"));
+
+ MessageContext mc = new MessageContext();
+ mc.setConfigurationContext(sc.getConfigurationContext());
+ ///////////////////////////////////////////////////////////////////////
+ // filtering properties
+ if (smc.getSoapAction() != null)
+ mc.setSoapAction(smc.getSoapAction());
+ if (smc.getWSAAction() != null)
+ mc.setWSAAction(smc.getWSAAction());
+ if (smc.getFrom() != null)
+ mc.setFrom(smc.getFrom());
+ if (smc.getMessageID() != null)
+ mc.setMessageID(smc.getMessageID());
+ else
+ mc.setMessageID(String.valueOf("uuid:"
+ + UUIDGenerator.getUUID()));
+ if (smc.getReplyTo() != null)
+ mc.setReplyTo(smc.getReplyTo());
+ if (smc.getRelatesTo() != null)
+ mc.setRelatesTo(smc.getRelatesTo());
+ if (smc.getTo() != null) {
+ mc.setTo(smc.getTo());
+ } else {
+ throw new AxisFault(
+ "To canno't be null, if null Synapse can't infer the transport");
+ }
+ if (smc.isDoingREST()) {
+ mc.setDoingREST(true);
+ }
+ mc.setEnvelope(Axis2FlexibleMEPClient.outEnvelopeConfiguration(smc));
+
+ AxisOperation axisAnonymousOperation =
+ ac.getService("__ANONYMOUS_SERVICE__")
+ .getOperation(new QName("__DYNAMIC_OPERATION__"));
+
+ Options options = new Options();
+ OperationClient mepClient =
+ axisAnonymousOperation.createClient(sc,options);
+
+ mepClient.addMessageContext(mc);
+ mepClient.execute(true);
+ MessageContext response = mepClient
+ .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+
+
+ response.setProperty(MessageContext.TRANSPORT_OUT,
+ smc.getProperty(MessageContext.TRANSPORT_OUT));
+ response.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
+ smc.getProperty(
+ org.apache.axis2.Constants.OUT_TRANSPORT_INFO));
+
+ // If request is REST we assume the response is REST, so set the
+ // variable
+ response.setDoingREST(smc.isDoingREST());
+
+ return response;
+ }
+
+ private void outMessageSerialization(MessageContext mcn,MessageContext mco,SynapseMessage sm) throws AxisFault {
+
+ // copying important configuration stuff
+ sm.setResponse(true);
+ // as agreed upone
+ mcn.setTo(null);
+ Object os = mco
+ .getProperty(MessageContext.TRANSPORT_OUT);
+ mcn.setProperty(MessageContext.TRANSPORT_OUT, os);
+ TransportInDescription ti = mco.getTransportIn();
+ mcn.setTransportIn(ti);
+ mcn.setServerSide(true);
+
+ AxisEngine ae = new AxisEngine(mco.getConfigurationContext());
+ ae.send(mcn);
+
+
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/SendProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/SendProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/SendProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/SendProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors.builtin;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.processors.AbstractProcessor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+
+/**
+ *
+ * <p>
+ *
+ * This sends the message on (or back)
+ *
+ */
+public class SendProcessor extends AbstractProcessor {
+
+
+ private Log log = LogFactory.getLog(getClass());
+
+
+ public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+ log.debug("process");
+ se.send(smc, se);
+ return false;
+
+ }
+
+
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/AddressingInProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/AddressingInProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/AddressingInProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/AddressingInProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors.builtin.axis2;
+
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.*;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+
+
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+
+import org.apache.axis2.util.Utils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+
+
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+
+
+import org.apache.synapse.processors.AbstractProcessor;
+
+
+/**
+ * <p/>
+ * This class turns on the addressing module and then calls an empty
+ * service There's probably a better way but this should work!
+ */
+public class AddressingInProcessor extends AbstractProcessor {
+ private Log log = LogFactory.getLog(getClass());
+
+
+ public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+ log.debug("Processing __AddressingInHandler__");
+ try {
+ MessageContext mc = ((Axis2SynapseMessage)smc).getMessageContext();
+ se.setProperty(Constants.ADDRESSING_PROCESSED,Boolean.TRUE);
+ // default configuration_contex and axis_configuration
+ ConfigurationContext cc = mc.getConfigurationContext();
+ AxisConfiguration ac = cc.getAxisConfiguration();
+ AxisService as = ac.getService(Constants.EMPTYMEDIATOR);
+ if (as == null)
+ throw new SynapseException("cannot locate service "
+ + Constants.EMPTYMEDIATOR);
+
+ AxisEngine ae = new AxisEngine(cc);
+ AxisOperation ao = as
+ .getOperation(Constants.MEDIATE_OPERATION_NAME);
+ OperationContext oc = OperationContextFactory
+ .createOperationContext(ao.getAxisSpecifMEPConstant(), ao);
+ ao.registerOperationContext(mc,oc);
+ ServiceContext sc = Utils.fillContextInformation(ao, as, cc);
+ oc.setParent(sc);
+ mc.setAxisOperation(ao);
+ mc.setAxisService(as);
+ ae.receive(mc);
+
+ } catch (AxisFault axisFault) {
+ throw new SynapseException(
+ "__AddresingInHandler__ caught an Exception" +
+ axisFault.getMessage());
+ }
+ return true;
+ }
+
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/FaultProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/FaultProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/FaultProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/FaultProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors.builtin.axis2;
+
+
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMDocument;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.soap.SOAP12Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.processors.AbstractProcessor;
+
+
+/**
+ * <p/>
+ * This returns a fault in response to this message
+ */
+public class FaultProcessor extends AbstractProcessor {
+
+ private Log log = LogFactory.getLog(getClass());
+
+ public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+ log.debug("process");
+
+ SOAPEnvelope envelop = smc.getEnvelope();
+ SOAPFactory factory;
+ if (envelop != null) {
+ if (envelop.getNamespace().getName()
+ .equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
+ factory = OMAbstractFactory.getSOAP12Factory();
+ } else {
+ factory = OMAbstractFactory.getSOAP11Factory();
+ }
+
+ } else {
+ factory = OMAbstractFactory.getSOAP11Factory();
+ }
+ try {
+ OMDocument soapFaultDocument = factory.createOMDocument();
+ SOAPEnvelope faultEnvelope = factory.getDefaultFaultEnvelope();
+ soapFaultDocument.addChild(faultEnvelope);
+ smc.setEnvelope(faultEnvelope);
+ } catch (Exception e) {
+ throw new SynapseException(e);
+ }
+ smc.setResponse(true);
+
+ //Flipping the headers
+ EndpointReference tempEPR = smc.getTo();
+ smc.setTo(smc.getReplyTo());
+ smc.setReplyTo(tempEPR);
+
+ se.injectMessage(smc);
+
+
+ return false;
+ }
+
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/SecurityProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/SecurityProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/SecurityProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/axis2/SecurityProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,75 @@
+package org.apache.synapse.processors.builtin.axis2;
+
+import org.apache.synapse.processors.AbstractProcessor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.axis2.context.*;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.util.Utils;
+import org.apache.axis2.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.
+*
+*/
+
+public class SecurityProcessor extends AbstractProcessor {
+ private Log log = LogFactory.getLog(getClass());
+
+ public boolean process(SynapseEnvironment se, SynapseMessage sm) {
+ log.debug("process");
+ try {
+ MessageContext mc = ((Axis2SynapseMessage) sm)
+ .getMessageContext();
+ ConfigurationContext cc = mc.getConfigurationContext();
+ AxisConfiguration ac = cc.getAxisConfiguration();
+ AxisEngine ae = new AxisEngine(cc);
+ AxisService as = ac.getService(Constants.SECURITY_QOS);
+ if (as == null)
+ throw new SynapseException("cannot locate service "
+ + Constants.SECURITY_QOS);
+ ac.engageModule(new QName("security"));
+ AxisOperation ao = as
+ .getOperation(Constants.MEDIATE_OPERATION_NAME);
+ OperationContext oc = OperationContextFactory
+ .createOperationContext(ao.getAxisSpecifMEPConstant(), ao);
+ ao.registerOperationContext(mc, oc);
+
+ ServiceContext sc = Utils.fillContextInformation(ao, as, cc);
+ oc.setParent(sc);
+
+ mc.setOperationContext(oc);
+ mc.setServiceContext(sc);
+
+ mc.setAxisOperation(ao);
+ mc.setAxisService(as);
+
+ ae.receive(mc);
+
+ } catch (AxisFault e) {
+ throw new SynapseException(e);
+ }
+ return true;
+ }
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/xslt/XSLTProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/xslt/XSLTProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/xslt/XSLTProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/xslt/XSLTProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,92 @@
+package org.apache.synapse.processors.builtin.xslt;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.processors.AbstractProcessor;
+
+/**
+ *
+ * @see org.apache.synapse.processors.builtin.xslt.XSLTProcessorConfigurator
+ * <p> This class is the class that transforms messages using XSLT.
+ *
+
+ *
+ */
+public class XSLTProcessor extends AbstractProcessor {
+
+ private Transformer tran = null;
+
+ private boolean isBody = false;
+
+ public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ XMLStreamWriter xsw;
+ try {
+ xsw = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
+
+ if (isBody) smc.getEnvelope().getBody().serialize(xsw);
+ else smc.getEnvelope().serialize(xsw);
+
+ Source src = new StreamSource(new ByteArrayInputStream(baos.toByteArray()));
+ ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
+ StreamResult result = new StreamResult(baos2);
+ tran.transform(src, result);
+ StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(baos2.toByteArray()));
+ OMElement nw = builder.getDocumentElement();
+ if (isBody) smc.getEnvelope().setFirstChild(nw);
+ //TODO don't assume SOAP 1.1
+ else smc.setEnvelope(OMAbstractFactory.getSOAP11Factory().createSOAPEnvelope(builder));
+
+ } catch (Exception e) {
+ throw new SynapseException(e);
+ }
+ return true;
+ }
+
+ /**
+ * @param b
+ * <p> If isBody is true then the XSLT is applied to the Body of the SOAP message, otherwise to the whole env
+ */
+ public void setIsBody(boolean b) {
+ isBody = b;
+ }
+
+
+ /**
+ * @param is
+ * <p>
+ * This sets the correct XSL transform
+ */
+ public void setXSLInputStream(InputStream is) {
+ try {
+ Source src = new StreamSource(is);
+ tran = TransformerFactory.newInstance().newTransformer(src);
+ } catch (Exception e) {
+ throw new SynapseException(e);
+
+ }
+ }
+
+}
+
+
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/xslt/XSLTProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/xslt/XSLTProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/xslt/XSLTProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/builtin/xslt/XSLTProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,57 @@
+package org.apache.synapse.processors.builtin.xslt;
+
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+
+
+
+import org.apache.synapse.xml.AbstractProcessorConfigurator;
+
+
+
+/**
+ *
+ * @see org.apache.synapse.processors.builtin.xslt.XSLTProcessor
+ * <p> This class configures the XSLT transformer
+ * <p> The tag looks like this
+ * <xmp><xslt name="x" xsl="file.xsl" type="body|envelope"/></xmp>
+ * Perform the given XSLT on the SOAP-Envelope or Body
+ * <p>If type is not present, assumed to be body
+ */
+public class XSLTProcessorConfigurator extends AbstractProcessorConfigurator {
+ private static final QName tagName = new QName(Constants.SYNAPSE_NAMESPACE, "xslt");
+
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ XSLTProcessor xp = new XSLTProcessor();
+ super.setNameOnProcessor(se,el,xp);
+
+ OMAttribute type = el.getAttribute(new QName("type"));
+ if (type != null && type.getAttributeValue().trim().toLowerCase().equals("envelope")) xp.setIsBody(false);
+ else xp.setIsBody(true);
+
+ OMAttribute xsl = el.getAttribute(new QName("xsl"));
+ if (xsl == null) throw new SynapseException("no xsl attribute on: "+el.toString());
+
+ InputStream xslStream = se.getClassLoader().getResourceAsStream(xsl.getAttributeValue());
+ xp.setXSLInputStream(xslStream);
+
+ return xp;
+
+
+
+ }
+
+ public QName getTagQName() {
+
+ return tagName;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/mediatortypes/ClassMediatorProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/mediatortypes/ClassMediatorProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/mediatortypes/ClassMediatorProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/mediatortypes/ClassMediatorProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors.mediatortypes;
+
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.api.EnvironmentAware;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.processors.AbstractProcessor;
+
+/**
+ *
+ *
+ * This executes the "mediate" operation on a new instance of the specified class
+ *
+ * TODO add support for simple properties to be set
+ *
+ */
+public class ClassMediatorProcessor extends AbstractProcessor {
+
+ private Class clazz = null;
+
+
+
+ public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+ Mediator m = null;
+
+ try {
+ m = (Mediator) getClazz().newInstance();
+ } catch (Exception e) {
+ throw new SynapseException(e);
+ }
+ if (EnvironmentAware.class.isAssignableFrom(m.getClass())) {
+ ((EnvironmentAware) m).setSynapseEnvironment(se);
+ }
+ return m.mediate(smc);
+
+ }
+
+
+ public void setClazz(Class clazz) {
+ this.clazz = clazz;
+ }
+
+ public Class getClazz() {
+ return clazz;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/mediatortypes/axis2/ServiceMediatorProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/mediatortypes/axis2/ServiceMediatorProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/mediatortypes/axis2/ServiceMediatorProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/mediatortypes/axis2/ServiceMediatorProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors.mediatortypes.axis2;
+
+
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.context.OperationContextFactory;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.util.Utils;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.synapse.processors.AbstractProcessor;
+
+/**
+ *
+ * <p>
+ * This class executes a service in the "owning" axis2 engine.
+ * The service operation will be "mediate" and the service name is set as the ServiceName property
+ *
+ *
+ */
+public class ServiceMediatorProcessor extends AbstractProcessor {
+
+
+ private String serviceName = null;
+
+ public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+ MessageContext messageContext = null;
+ try {
+ messageContext = ((Axis2SynapseMessage) smc)
+ .getMessageContext();
+ } catch (ClassCastException cce) {
+ throw new SynapseException(
+ "A non-Axis2 MC SOAPMessageContext has been passed to the Axis2 MediationExecutor",
+ cce);
+ }
+
+
+
+ try {
+ ConfigurationContext cc = messageContext.getConfigurationContext();
+ AxisConfiguration ac = cc.getAxisConfiguration();
+ AxisEngine ae = new AxisEngine(cc);
+
+ AxisService as = null;
+ AxisOperation ao = null;
+
+ as = ac.getService(getServiceName());
+ if (as == null)
+ throw new SynapseException("cannot locate service "
+ + getServiceName());
+
+ ao = as.getOperation(Constants.MEDIATE_OPERATION_NAME);
+ OperationContext oc = OperationContextFactory
+ .createOperationContext(ao.getAxisSpecifMEPConstant(), ao);
+ ao.registerOperationContext(messageContext, oc);
+
+ ServiceContext sc = Utils.fillContextInformation(ao, as, cc);
+ oc.setParent(sc);
+
+ messageContext.setOperationContext(oc);
+ messageContext.setServiceContext(sc);
+
+ messageContext.setAxisOperation(ao);
+ messageContext.setAxisService(as);
+
+ ae.receive(messageContext);
+
+ } catch (AxisFault e) {
+ throw new SynapseException(e);
+
+ }
+
+ return ((Boolean) messageContext
+ .getProperty(Constants.MEDIATOR_RESPONSE_PROPERTY))
+ .booleanValue();
+
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/rules/RegexProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/rules/RegexProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/rules/RegexProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/rules/RegexProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors.rules;
+
+import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.synapse.HeaderType;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+
+import org.apache.synapse.processors.ListProcessor;
+
+/**
+ *
+ * <p>
+ * This checks the pattern against a property and if true processes the message with its child or children
+ * <p>
+ * TODO add to the set of properties you can search
+ *
+ *
+ */
+public class RegexProcessor extends ListProcessor {
+ private Pattern pattern = null;
+
+ private Log log = LogFactory.getLog(getClass());
+
+ private HeaderType headerType = new HeaderType();
+
+ private String property = null;
+
+ public void setHeaderType(String header) {
+ headerType.setHeaderType(header);
+ }
+
+ public String getHeaderType() {
+ return headerType.getHeaderType();
+ }
+
+ public void setPattern(String p) {
+ pattern = Pattern.compile(p);
+ }
+
+ public String getPattern() {
+ return pattern.toString();
+ }
+
+ public void setPropertyName(String p) {
+ this.property = p;
+ }
+
+ public String getPropertyName() {
+ return property;
+ }
+
+ public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+
+ if (pattern == null) {
+ log.debug("trying to process with empty pattern");
+ return true;
+ }
+ String toMatch = null;
+ if (property != null) {
+ toMatch = smc.getProperty(property).toString();
+ } else {
+ toMatch = headerType.getHeader(smc);
+ }
+
+ if (toMatch==null) return true;
+
+ if (pattern.matcher(toMatch).matches()) {
+ log.debug("Regex pattern " + pattern.toString() + " matched "
+ + toMatch);
+ return super.process(se, smc);
+ }
+ return true;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/rules/XPathProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/rules/XPathProcessor.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/rules/XPathProcessor.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/processors/rules/XPathProcessor.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.processors.rules;
+
+import org.apache.axis2.om.xpath.AXIOMXPath;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.processors.ListProcessor;
+import org.jaxen.JaxenException;
+
+/**
+ *
+ *
+ * <p>
+ * This class executes an XPath test against the message envelope and then processes all subsequent rules/mediations
+ * if the test is true
+ * <p>
+ * TODO add the context into the XPath matching space
+ *
+ */
+public class XPathProcessor extends ListProcessor {
+
+ private Log log = LogFactory.getLog(getClass());
+
+ private AXIOMXPath xp = null;
+
+
+ public boolean process(SynapseEnvironment se, SynapseMessage smc) {
+ if (xp == null) {
+ log.debug("trying to process xpath without being set");
+ return true;
+ }
+ try {
+ if (xp.booleanValueOf(smc.getEnvelope())) {
+ log.debug("matched xpath: " + xp.toString());
+ // now do "all"
+ return super.process(se, smc);
+ }
+
+ } catch (JaxenException je) {
+ throw new SynapseException("Problem evaluating " + xp.toString(),
+ je);
+ }
+ return true;
+ }
+
+ public void setXPathExpr(String expr) {
+ try {
+ xp = new AXIOMXPath(expr);
+ } catch (JaxenException je) {
+ throw new SynapseException(je);
+ }
+ }
+
+ public String getXPathExpr() {
+ return xp.toString();
+ }
+
+ public void addXPathNamespace(String prefix, String uri) {
+ try {
+ xp.addNamespace(prefix, uri);
+ } catch (JaxenException je) {
+ throw new SynapseException(je);
+ }
+
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AbstractListProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AbstractListProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AbstractListProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AbstractListProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.synapse.xml;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+
+
+import org.apache.axis2.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.processors.ListProcessor;
+
+/**
+ *
+ *
+ * <p> This is the abstract parent of any tag which is a "Node" - so <stage>, <in><out> and <never> all fit this model
+ * <p>It recursively creates a list of processors from the children.
+ *
+ */
+public abstract class AbstractListProcessorConfigurator extends AbstractProcessorConfigurator {
+
+ Log log = LogFactory.getLog(getClass());
+
+ public void addChildrenAndSetName(SynapseEnvironment se, OMElement el, ListProcessor p)
+ {
+ super.setNameOnProcessor(se, el, p);
+
+ Iterator it = el.getChildElements();
+ List processors = new LinkedList();
+ while (it.hasNext()) {
+ OMElement child = (OMElement) it.next();
+ Processor proc = ProcessorConfiguratorFinder.getProcessor(se, child);
+ if (proc != null)
+ processors.add(proc);
+ else
+ log.info("Unknown child of all" + child.getLocalName());
+ }
+ p.setList(processors);
+
+ }
+
+
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AbstractProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AbstractProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AbstractProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AbstractProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+
+/**
+ *
+ *
+ * <p> This is the abstract superclass of any tag that isn't a "node". I.e. mediators or builtin
+ * mediators like log
+ *
+ */
+public abstract class AbstractProcessorConfigurator implements ProcessorConfigurator {
+
+
+
+ private Log log = LogFactory.getLog(getClass());
+ public void setNameOnProcessor(SynapseEnvironment se, OMElement el, Processor p) {
+
+ OMAttribute nm = el.getAttribute(new QName("name"));
+ if (nm != null) {
+ String name = nm.getAttributeValue().trim();
+ p.setName(name);
+ se.addProcessor(p);
+ }
+ log.debug("compile "+el.getLocalName()+" with name '"+p.getName() +"' on "+p.getClass());
+
+ }
+
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AddressingProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AddressingProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AddressingProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/AddressingProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.processors.builtin.axis2.AddressingInProcessor;
+
+/**
+ *
+ *
+ * <xmp><synapse:addressing/></xmp>
+ * <p>
+ * This tag turns on the addressing module
+ *
+ */
+public class AddressingProcessorConfigurator extends AbstractProcessorConfigurator {
+ private static final QName ADD_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "engage-addressing-in");
+
+
+ public QName getTagQName() {
+ return ADD_Q;
+ }
+
+
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ AddressingInProcessor ap = new AddressingInProcessor();
+ super.setNameOnProcessor(se,el,ap);
+ return ap;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ClassMediatorProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ClassMediatorProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ClassMediatorProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ClassMediatorProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.processors.mediatortypes.ClassMediatorProcessor;
+
+/**
+ *
+ * <xmp><synapse:classmediator name="nm" class="org.fremantle.mediator"</synapse:classmediator></xmp>
+ * TODO add ability to configure properties with Strings/OMElements based on children.
+ */
+public class ClassMediatorProcessorConfigurator extends AbstractProcessorConfigurator {
+ private static final QName CLM_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "classmediator");
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ ClassMediatorProcessor cmp = new ClassMediatorProcessor();
+ super.setNameOnProcessor(se, el, cmp);
+
+ OMAttribute clsName = el.getAttribute(new QName("class"));
+ if (clsName == null)
+ throw new SynapseException("missing class attribute on element"
+ + el.toString());
+ try {
+ Class clazz = se.getClassLoader().loadClass(clsName.getAttributeValue());
+ cmp.setClazz(clazz);
+ } catch (ClassNotFoundException e) {
+ throw new SynapseException("class loading error", e);
+ }
+ return cmp;
+
+ }
+
+
+ public QName getTagQName() {
+ return CLM_Q;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/Constants.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/Constants.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/Constants.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.synapse.xml;
+
+/**
+ * <p/>
+ * Constants used in the XML processing
+ */
+public interface Constants {
+ String SYNAPSE_NAMESPACE = "http://ws.apache.org/ns/synapse";
+ String SYNAPSE = "synapse";
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/DefineProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/DefineProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/DefineProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/DefineProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.synapse.xml;
+
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.processors.DefineProcessor;
+import org.apache.axis2.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+
+public class DefineProcessorConfigurator extends AbstractListProcessorConfigurator{
+ private static final QName DEFINE_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "define");
+
+
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ DefineProcessor defineProcessor = new DefineProcessor();
+ super.addChildrenAndSetName(se,el,defineProcessor);
+ return defineProcessor;
+ }
+
+ public QName getTagQName() {
+ return DEFINE_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/DropProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/DropProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/DropProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/DropProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.xml;
+
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.processors.builtin.DropProcessor;
+import org.apache.axis2.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+/**
+ */
+public class DropProcessorConfigurator extends AbstractProcessorConfigurator{
+
+ private static final QName DROP_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "drop");
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ return new DropProcessor();
+ }
+
+ public QName getTagQName() {
+ return DROP_Q;
+ }
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/FaultProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/FaultProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/FaultProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/FaultProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.processors.builtin.axis2.FaultProcessor;
+
+/**
+ *
+ * <p>
+ * <xmp><synapse:fault name="optional"/> </xmp>
+ * TODO add the ability to configure the fault codes, etc
+ *
+ */
+public class FaultProcessorConfigurator extends AbstractProcessorConfigurator {
+ private static final QName HEADER_Q = new QName(
+ Constants.SYNAPSE_NAMESPACE, "fault");
+
+
+
+
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ FaultProcessor fp = new FaultProcessor();
+ super.setNameOnProcessor(se, el, fp);
+ return fp;
+ }
+
+ public QName getTagQName() {
+ return HEADER_Q;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/HeaderProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/HeaderProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/HeaderProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/HeaderProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+
+import org.apache.axis2.om.OMAttribute;
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.processors.builtin.HeaderProcessor;
+
+/**
+ *
+ * <p>
+ * <xmp><synapse:header name="optional" type="to|from|faultto|replyto|action"
+ * value="newvalue"/> </xmp>
+ *
+ *
+ */
+public class HeaderProcessorConfigurator extends AbstractProcessorConfigurator{
+ private static final QName HEADER_Q = new QName(
+ Constants.SYNAPSE_NAMESPACE, "header");
+
+
+
+ private static final QName TYPE_ATT_Q = new QName("type"),
+ VALUE_ATT_Q = new QName("value");
+
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ HeaderProcessor hp = new HeaderProcessor();
+ super.setNameOnProcessor(se, el, hp);
+ OMAttribute val = el.getAttribute(VALUE_ATT_Q);
+ OMAttribute type = el.getAttribute(TYPE_ATT_Q);
+ if (val == null || type == null) {
+ throw new SynapseException("<header> must have both " + VALUE_ATT_Q
+ + " and " + TYPE_ATT_Q + " attributes: " + el.toString());
+ }
+ hp.setHeaderType(type.getAttributeValue());
+ hp.setValue( val.getAttributeValue());
+ return hp;
+ }
+
+ public QName getTagQName() {
+ return HEADER_Q;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/InProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/InProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/InProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/InProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.Processor;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.processors.InProcessor;
+
+
+
+/**
+ *
+ *
+ * <p>
+ * <xmp><in name="optional">.... </in></xmp>
+ * Uses children if processing an request (i.e. if !response).
+ *
+ */
+public class InProcessorConfigurator extends
+ AbstractListProcessorConfigurator {
+ private static final QName IN_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "in");
+
+ public QName getTagQName() {
+ return IN_Q;
+ }
+
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ InProcessor sp = new InProcessor();
+ super.addChildrenAndSetName(se, el, sp);
+ return sp;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/LogProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/LogProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/LogProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/LogProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMElement;
+
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.processors.builtin.LogProcessor;
+
+/**
+ *
+ *
+ * <p>
+ * Logs messages using Commons-logging.
+ *
+ * <xmp><log name="optional"/></xmp>
+ * TODO add support for simple one-line log entry (doesn't cause body parsing)
+ *
+ */
+public class LogProcessorConfigurator extends AbstractProcessorConfigurator {
+ private static final QName LOG_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "log");
+
+
+ public QName getTagQName() {
+ return LOG_Q;
+ }
+
+
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ LogProcessor lp = new LogProcessor();
+ super.setNameOnProcessor(se,el,lp);
+ return lp;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/NeverProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/NeverProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/NeverProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/NeverProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.processors.NeverProcessor;
+
+
+/**
+ *
+ *
+ * <xmp><synapse:never name="optional"><more stuff in here></synapse:never></xmp>
+ * Stuff in here never gets processed
+ * You might think that a bit useless, but it lets you put things you want to refer to from elsewhere
+ *
+ *
+ */
+public class NeverProcessorConfigurator extends
+ AbstractListProcessorConfigurator {
+ private static final QName NEVER_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "never");
+
+ public QName getTagQName() {
+ return NEVER_Q;
+ }
+
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ NeverProcessor sp = new NeverProcessor();
+ super.addChildrenAndSetName(se, el, sp);
+ return sp;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/OutProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/OutProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/OutProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/OutProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.xml.Constants;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.processors.OutProcessor;
+
+
+public class OutProcessorConfigurator extends
+ AbstractListProcessorConfigurator {
+ private static final QName OUT_Q = new QName(Constants.SYNAPSE_NAMESPACE,
+ "out");
+
+ public QName getTagQName() {
+ return OUT_Q;
+ }
+
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ OutProcessor sp = new OutProcessor();
+ super.addChildrenAndSetName(se, el, sp);
+ return sp;
+ }
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ProcessorConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ProcessorConfigurator.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ProcessorConfigurator.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ProcessorConfigurator.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.synapse.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+
+public interface ProcessorConfigurator {
+ public Processor createProcessor(SynapseEnvironment se, OMElement el);
+ public QName getTagQName();
+
+}
Added: incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ProcessorConfiguratorFinder.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ProcessorConfiguratorFinder.java?rev=377953&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ProcessorConfiguratorFinder.java (added)
+++ incubator/synapse/trunk/scratch/synase-multimodules/modules/core/src/org/apache/synapse/xml/ProcessorConfiguratorFinder.java Tue Feb 14 23:11:24 2006
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+
+package org.apache.synapse.xml;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.OMNamespace;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.processors.builtin.xslt.XSLTProcessorConfigurator;
+
+import sun.misc.Service;
+
+/**
+ *
+ *
+ * This class is based on J2SE Service Provider model
+ * http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Service%20Provider
+ */
+
+public class ProcessorConfiguratorFinder {
+
+ private static Map lookup = null;
+
+ private static Log log = LogFactory
+ .getLog(ProcessorConfiguratorFinder.class);
+
+ private static Class[] processorConfigurators = {
+ SynapseProcessorConfigurator.class,
+ StageProcessorConfigurator.class, RegexProcessorConfigurator.class,
+ XPathProcessorConfigurator.class,
+ HeaderProcessorConfigurator.class,
+ ClassMediatorProcessorConfigurator.class,
+ ServiceMediatorProcessorConfigurator.class,
+ LogProcessorConfigurator.class, SendProcessorConfigurator.class,
+ FaultProcessorConfigurator.class,
+ AddressingProcessorConfigurator.class,
+ InProcessorConfigurator.class, OutProcessorConfigurator.class,
+ NeverProcessorConfigurator.class, RefProcessorConfigurator.class,
+ XSLTProcessorConfigurator.class,DefineProcessorConfigurator.class,
+ SendNowProcessorConfigurator.class,DropProcessorConfigurator.class,
+ RefDefineProcessorConfigurator.class};
+
+ private static void initialise() {
+
+ if (lookup != null)
+ return;
+ lookup = new HashMap();
+
+ for (int i = 0; i < processorConfigurators.length; i++) {
+ Class c = processorConfigurators[i];
+ try {
+ lookup.put(((ProcessorConfigurator) c.newInstance())
+ .getTagQName(), c);
+ } catch (Exception e) {
+ throw new SynapseException(e);
+ }
+ }
+ // now try additional processors
+ Iterator it = Service.providers(ProcessorConfigurator.class);
+ while (it.hasNext()) {
+ ProcessorConfigurator p = (ProcessorConfigurator) it.next();
+ QName tag = p.getTagQName();
+ lookup.put(tag, p.getClass());
+ log.debug("added Processor " + p.getClass() + " to handle " + tag);
+ }
+ }
+
+ /**
+ * @param qn
+ * @return the class which implements the Processor for the given QName
+ */
+ public static Class find(QName qn) {
+ initialise();
+ return (Class) lookup.get(qn);
+ }
+
+ /**
+ * This method returns a Processor given an OMElement. This will be used
+ * recursively by the elements which contain processor elements themselves
+ * (e.g. rules)
+ *
+ * @param synapseEnv
+ * @param element
+ * @return Processor
+ */
+ public static Processor getProcessor(SynapseEnvironment synapseEnv, OMElement element) {
+ OMNamespace n = element.getNamespace();
+
+ Class cls = find(new QName(n.getName(), element
+ .getLocalName()));
+ try {
+ ProcessorConfigurator pc = (ProcessorConfigurator) cls.newInstance();
+ Processor p = pc.createProcessor(synapseEnv, element);
+ return p;
+ } catch (InstantiationException e) {
+ throw new SynapseException(e);
+ } catch (IllegalAccessException e) {
+ throw new SynapseException(e);
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org