You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gd...@apache.org on 2004/07/20 02:06:13 UTC
cvs commit: incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/interceptors MsgTransformer.java
gdamour 2004/07/19 17:06:13
Modified: sandbox/messaging/src/java/org/apache/geronimo/messaging/proxy
EndPointProxyFactoryImpl.java EndPointProxy.java
EndPointCallback.java
Added: sandbox/messaging/src/java/org/apache/geronimo/messaging/interceptors
MsgTransformer.java
Log:
Provides a mean to intercept Msgs being sent by an EndPointProxy.
Revision Changes Path
1.3 +5 -1 incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/proxy/EndPointProxyFactoryImpl.java
Index: EndPointProxyFactoryImpl.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/proxy/EndPointProxyFactoryImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EndPointProxyFactoryImpl.java 10 Jun 2004 23:12:24 -0000 1.2
+++ EndPointProxyFactoryImpl.java 20 Jul 2004 00:06:13 -0000 1.3
@@ -30,6 +30,7 @@
import org.apache.geronimo.messaging.BaseEndPoint;
import org.apache.geronimo.messaging.Node;
import org.apache.geronimo.messaging.interceptors.MsgOutInterceptor;
+import org.apache.geronimo.messaging.interceptors.MsgTransformer;
/**
* EndPointProxyFactory implementation.
@@ -172,6 +173,9 @@
}
callbacks.remove(endPointCallback);
}
+ }
+ public void setTransformer(MsgTransformer aTransformer) {
+ endPointCallback.setTransformer(aTransformer);
}
}
1.3 +10 -1 incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/proxy/EndPointProxy.java
Index: EndPointProxy.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/proxy/EndPointProxy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EndPointProxy.java 10 Jun 2004 23:12:24 -0000 1.2
+++ EndPointProxy.java 20 Jul 2004 00:06:13 -0000 1.3
@@ -17,6 +17,8 @@
package org.apache.geronimo.messaging.proxy;
+import org.apache.geronimo.messaging.interceptors.MsgTransformer;
+
/**
* EndPointProxyFactory creates EndPoint proxies, which automatically implement
@@ -31,5 +33,12 @@
* Releases the EndPoint proxy resources.
*/
public void release();
+
+ /**
+ * Allows to transform Msgs being sent by this proxy.
+ *
+ * @param aTransformer Msg transformer.
+ */
+ public void setTransformer(MsgTransformer aTransformer);
}
1.3 +42 -2 incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/proxy/EndPointCallback.java
Index: EndPointCallback.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/proxy/EndPointCallback.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EndPointCallback.java 1 Jun 2004 13:37:14 -0000 1.2
+++ EndPointCallback.java 20 Jul 2004 00:06:13 -0000 1.3
@@ -22,10 +22,12 @@
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
+import org.apache.geronimo.messaging.Msg;
import org.apache.geronimo.messaging.NodeInfo;
import org.apache.geronimo.messaging.Request;
import org.apache.geronimo.messaging.RequestSender;
import org.apache.geronimo.messaging.interceptors.MsgOutInterceptor;
+import org.apache.geronimo.messaging.interceptors.MsgTransformer;
/**
* This Callback sends Request to an EndPoint hosted by a set of Nodes.
@@ -42,6 +44,11 @@
private final RequestSender sender;
/**
+ * Applies the MsgTransformer, if any.
+ */
+ private final Transformer transformer;
+
+ /**
* Transport bus.
*/
private MsgOutInterceptor out;
@@ -57,6 +64,11 @@
private Object id;
/**
+ * Msg transformer, if any.
+ */
+ private MsgTransformer msgTransformer;
+
+ /**
* @param aSender RequestSender to be used to send Request to the
* associated EndPoint.
*/
@@ -65,6 +77,8 @@
throw new IllegalArgumentException("Sender is required.");
}
sender = aSender;
+
+ transformer = new Transformer();
}
/**
@@ -113,6 +127,15 @@
}
/**
+ * Sets the transformer to be applied on Msgs sent by this instance.
+ *
+ * @param aTransformer
+ */
+ public void setTransformer(MsgTransformer aTransformer) {
+ msgTransformer = aTransformer;
+ }
+
+ /**
* Sets the Nodes hosting the target EndPoints.
*
* @param aTargets The targets to set.
@@ -133,7 +156,7 @@
try {
Object opaque = sender.sendSyncRequest(
new Request(arg1.getName(), arg1.getParameterTypes(), arg2),
- out, id, targets);
+ transformer, id, targets);
return opaque;
} catch (RuntimeException e) {
Throwable nested = e.getCause();
@@ -151,4 +174,21 @@
}
}
+ /**
+ * Applies the MsgTransformer, if any, on the sent Msgs.
+ */
+ private class Transformer implements MsgOutInterceptor {
+
+ public void push(Msg aMsg) {
+ if ( null != msgTransformer ) {
+ synchronized(msgTransformer) {
+ msgTransformer.push(aMsg);
+ aMsg = msgTransformer.pop();
+ }
+ }
+ out.push(aMsg);
+ }
+
+ }
+
}
1.1 incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/interceptors/MsgTransformer.java
Index: MsgTransformer.java
===================================================================
/**
*
* Copyright 2004 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.geronimo.messaging.interceptors;
/**
* An interface allowing various implementations to transform Msgs.
* <BR>
* In a first step, the Msg is pushed to this component, then the Msg is popped.
*
* @version $Revision: 1.1 $ $Date: 2004/07/20 00:06:13 $
*/
public interface MsgTransformer
extends MsgInInterceptor, MsgOutInterceptor
{
}