[jboss-cvs] JBossAS SVN: r104683 - in trunk/testsuite: src/main/org/jboss/test/invokers/ejb and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 11 10:28:22 EDT 2010
Author: bstansberry at jboss.com
Date: 2010-05-11 10:28:21 -0400 (Tue, 11 May 2010)
New Revision: 104683
Added:
trunk/testsuite/src/main/org/jboss/test/invokers/ejb/CompressingInvocationMarshaller.java
trunk/testsuite/src/main/org/jboss/test/invokers/ejb/CompressingInvocationUnMarshaller.java
trunk/testsuite/src/resources/invokers/service-inf/compressing-invoker-jboss-beans.xml
Removed:
trunk/testsuite/src/resources/invokers/service-inf/jboss-service.xml
Modified:
trunk/testsuite/imports/sections/invokers.xml
trunk/testsuite/src/resources/invokers/META-INF/jboss.xml
Log:
[JBAS-7563] Use a unified invoker variant for the compression invoker
Modified: trunk/testsuite/imports/sections/invokers.xml
===================================================================
--- trunk/testsuite/imports/sections/invokers.xml 2010-05-11 13:42:02 UTC (rev 104682)
+++ trunk/testsuite/imports/sections/invokers.xml 2010-05-11 14:28:21 UTC (rev 104683)
@@ -16,6 +16,7 @@
<metainf dir="${build.resources}/invokers/service-inf"/>
<fileset dir="${build.classes}">
<include name="org/jboss/test/invokers/ejb/Compression*.class"/>
+ <include name="org/jboss/test/invokers/ejb/Compressing*.class"/>
</fileset>
</jar>
<jar destfile="${build.lib}/invokers.jar">
Added: trunk/testsuite/src/main/org/jboss/test/invokers/ejb/CompressingInvocationMarshaller.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/invokers/ejb/CompressingInvocationMarshaller.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/invokers/ejb/CompressingInvocationMarshaller.java 2010-05-11 14:28:21 UTC (rev 104683)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.invokers.ejb;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.transaction.SystemException;
+
+import org.jboss.invocation.Invocation;
+import org.jboss.invocation.MarshalledInvocation;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.MarshallerDecorator;
+import org.jboss.remoting.marshal.compress.CompressingMarshaller;
+import org.jboss.tm.TransactionPropagationContextFactory;
+import org.jboss.tm.TransactionPropagationContextUtil;
+
+/**
+ * This marshaller is to be used in conjunction with the UnifiedInvoker and will
+ * look for an InvocationRequest to be passed to it, which is specific to EJB
+ * invocations.
+ *
+ * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
+ */
+public class CompressingInvocationMarshaller extends CompressingMarshaller implements MarshallerDecorator
+{
+ /** @since 4.2.0 */
+ static final long serialVersionUID = -2109634245396128775L;
+
+ public final static String DATATYPE = "invocation";
+
+ private static final Logger log = Logger.getLogger(CompressingInvocationMarshaller.class);
+
+ /**
+ * Marshaller will need to take the dataObject and convert
+ * into primitive java data types and write to the
+ * given output. Will check to see if dataObject being passed is
+ * an InvocationRequest, and if is, process it (including handling propagation of
+ * transaction). If is not an instance of InvocationRequest, will default back to
+ * SerializableMarshaller for processing.
+ *
+ * @param dataObject Object to be writen to output
+ * @param output The data output to write the object
+ * data to.
+ */
+ public void write(Object dataObject, OutputStream output) throws IOException
+ {
+
+ super.write(addDecoration(dataObject), output);
+ }
+
+ public void write(Object dataObject, OutputStream output, int version) throws IOException
+ {
+
+ super.write(addDecoration(dataObject), output, version);
+ }
+
+ public Object addDecoration(Object dataObject) throws IOException {
+ if(dataObject instanceof InvocationRequest)
+ {
+ InvocationRequest remoteInv = (InvocationRequest) dataObject;
+
+ if(remoteInv.getParameter() instanceof Invocation)
+ {
+ Invocation inv = (Invocation) remoteInv.getParameter();
+
+ MarshalledInvocation marshInv = new MarshalledInvocation(inv);
+
+ if(inv != null)
+ {
+ // now that have invocation object related to ejb invocations,
+ // need to get the possible known payload objects and make sure
+ // they get serialized.
+
+ try
+ {
+ marshInv.setTransactionPropagationContext(getTransactionPropagationContext());
+ }
+ catch(SystemException e)
+ {
+ log.error("Error setting transaction propagation context.", e);
+ throw new IOException("Error setting transaction context. Message: " + e.getMessage());
+ }
+
+ // reset the invocation parameter within remote invocation
+ remoteInv.setParameter(marshInv);
+ }
+ else
+ {
+ //Should never get here, but will check anyways
+ log.error("Attempting to marshall Invocation but is null. Can not proceed.");
+ throw new IOException("Can not process data object due to the InvocationRequest's parameter being null.");
+ }
+
+ }
+ }
+ return dataObject;
+ }
+
+ public Object getTransactionPropagationContext()
+ throws SystemException
+ {
+ TransactionPropagationContextFactory tpcFactory = TransactionPropagationContextUtil.getTPCFactoryClientSide();
+ return (tpcFactory == null) ? null : tpcFactory.getTransactionPropagationContext();
+ }
+
+ public Marshaller cloneMarshaller() throws CloneNotSupportedException
+ {
+ return new CompressingInvocationMarshaller();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/testsuite/src/main/org/jboss/test/invokers/ejb/CompressingInvocationMarshaller.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Added: trunk/testsuite/src/main/org/jboss/test/invokers/ejb/CompressingInvocationUnMarshaller.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/invokers/ejb/CompressingInvocationUnMarshaller.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/invokers/ejb/CompressingInvocationUnMarshaller.java 2010-05-11 14:28:21 UTC (rev 104683)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.invokers.ejb;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.jboss.invocation.MarshalledInvocation;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.remoting.marshal.UnMarshallerDecorator;
+import org.jboss.remoting.marshal.compress.CompressingUnMarshaller;
+import org.jboss.tm.TransactionPropagationContextImporter;
+import org.jboss.tm.TransactionPropagationContextUtil;
+
+/**
+ * This is a hollow implementation in that it only over rides the DATATYPE
+ * value. All behavior is that of SerializableUnMarshaller.
+ *
+ * @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
+ */
+public class CompressingInvocationUnMarshaller extends CompressingUnMarshaller implements UnMarshallerDecorator
+{
+ /** @since 4.2.0 */
+ static final long serialVersionUID = -7323800106085276090L;
+
+ public final static String DATATYPE = "invocation";
+
+ public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException
+ {
+ Object ret = super.read(inputStream, metadata);
+
+
+ return removeDecoration(ret);
+ }
+
+ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
+ {
+ Object ret = super.read(inputStream, metadata, version);
+
+
+ return removeDecoration(ret);
+ }
+
+ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
+ {
+ CompressingInvocationUnMarshaller unmarshaller = new CompressingInvocationUnMarshaller();
+ unmarshaller.setClassLoader(this.customClassLoader);
+ return unmarshaller;
+ }
+
+ public Object removeDecoration(Object obj) throws IOException
+ {
+ if(obj instanceof InvocationRequest)
+ {
+ InvocationRequest remoteInv = (InvocationRequest) obj;
+ Object param = remoteInv.getParameter();
+
+ if(param instanceof MarshalledInvocation)
+ {
+ MarshalledInvocation mi = (MarshalledInvocation) param;
+ Object txCxt = mi.getTransactionPropagationContext();
+ if(txCxt != null)
+ {
+ TransactionPropagationContextImporter tpcImporter = TransactionPropagationContextUtil.getTPCImporter();
+ mi.setTransaction(tpcImporter.importTransactionPropagationContext(txCxt));
+ }
+ }
+ }
+ return obj;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/testsuite/src/main/org/jboss/test/invokers/ejb/CompressingInvocationUnMarshaller.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: trunk/testsuite/src/resources/invokers/META-INF/jboss.xml
===================================================================
--- trunk/testsuite/src/resources/invokers/META-INF/jboss.xml 2010-05-11 13:42:02 UTC (rev 104682)
+++ trunk/testsuite/src/resources/invokers/META-INF/jboss.xml 2010-05-11 14:28:21 UTC (rev 104683)
@@ -17,7 +17,7 @@
<jndi-name>SimpleBMP</jndi-name>
</invoker>
</invoker-bindings>
- <depends>jboss:service=invoker,type=jrmp,socketType=CompressionSocketFactory</depends>
+ <depends>jboss:service=invoker,type=compression</depends>
</entity>
<session>
<ejb-name>StatelessSession</ejb-name>
@@ -39,7 +39,7 @@
</ejb-ref>
</invoker>
</invoker-bindings>
- <depends>jboss:service=invoker,type=jrmp,socketType=CompressionSocketFactory</depends>
+ <depends>jboss:service=invoker,type=compression</depends>
</session>
<session>
<ejb-name>BusinessSession</ejb-name>
@@ -58,7 +58,7 @@
<invoker-proxy-bindings>
<invoker-proxy-binding>
<name>entity-compression-invoker</name>
- <invoker-mbean>jboss:service=invoker,type=jrmp,socketType=CompressionSocketFactory</invoker-mbean>
+ <invoker-mbean>jboss:service=invoker,type=compression</invoker-mbean>
<proxy-factory>org.jboss.proxy.ejb.ProxyFactory</proxy-factory>
<proxy-factory-config>
<client-interceptors exposeContainer="true">
@@ -81,7 +81,7 @@
</invoker-proxy-binding>
<invoker-proxy-binding>
<name>stateless-compression-invoker</name>
- <invoker-mbean>jboss:service=invoker,type=jrmp,socketType=CompressionSocketFactory</invoker-mbean>
+ <invoker-mbean>jboss:service=invoker,type=compression</invoker-mbean>
<proxy-factory>org.jboss.proxy.ejb.ProxyFactory</proxy-factory>
<proxy-factory-config>
<client-interceptors exposeContainer="true">
Added: trunk/testsuite/src/resources/invokers/service-inf/compressing-invoker-jboss-beans.xml
===================================================================
--- trunk/testsuite/src/resources/invokers/service-inf/compressing-invoker-jboss-beans.xml (rev 0)
+++ trunk/testsuite/src/resources/invokers/service-inf/compressing-invoker-jboss-beans.xml 2010-05-11 14:28:21 UTC (rev 104683)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+
+ <!-- ==================================================================== -->
+ <!-- UnifiedInvoker variant that uses compression -->
+ <!-- ==================================================================== -->
+
+ <!-- Unified invoker. Registers itself as an invocation handler with UnifiedInvokerConnector. -->
+ <!-- Can find more details on unified invoker configuration at -->
+ <!-- http://docs.jboss.org/jbossas/unified_invoker/UnifiedInvoker_guide.html. -->
+ <bean name="CompressingInvoker" class="org.jboss.invocation.unified.server.UnifiedInvoker">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:service=invoker,type=compression",exposedInterface=org.jboss.invocation.unified.server.UnifiedInvokerMBean.class,registerDirectly=true)</annotation>
+ <property name="connector"><inject bean="ComrpressionInvokerConnector"/></property>
+ <depends>TransactionManager</depends>
+ </bean>
+
+
+ <bean name="ComrpressionInvokerConnector" class="org.jboss.remoting.transport.Connector">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.remoting:service=Connector,transport=socket,compression=true",exposedInterface=org.jboss.remoting.transport.ConnectorMBean.class,registerDirectly=true)</annotation>
+ <property name="serverConfiguration"><inject bean="CompressionInvokerConfiguration"/></property>
+ </bean>
+
+
+ <!-- Remoting server configuration -->
+ <bean name="CompressionInvokerConfiguration" class="org.jboss.remoting.ServerConfiguration">
+ <constructor>
+ <!-- transport: Others include sslsocket, bisocket, sslbisocket, http, https, rmi, sslrmi, servlet, sslservlet. -->
+ <parameter>socket</parameter>
+ </constructor>
+
+ <!-- Parameters visible to both client and server -->
+ <property name="invokerLocatorParameters">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>serverBindAddress</key>
+ <value>${jboss.bind.address}</value>
+ </entry>
+ <entry>
+ <key>serverBindPort</key>
+ <value>24446</value>
+ </entry>
+
+ <entry><key>dataType</key> <value>invocation</value></entry>
+ <entry><key>marshaller</key> <value>org.jboss.test.invokers.ejb.CompressingInvocationMarshaller</value></entry>
+ <entry><key>unmarshaller</key> <value>org.jboss.test.invokers.ejb.CompressingInvocationUnMarshaller</value></entry>
+
+ <!-- A socket transport parameter -->
+ <entry><key>enableTcpNoDelay</key> <value>true</value></entry>
+ </map>
+ </property>
+
+ <!-- Parameters visible only to server -->
+ <property name="serverParameters">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+
+ <!-- Selected optional parameters: -->
+
+ <!-- Maximum number of worker threads on the -->
+ <!-- server (socket transport). Defaults to 300. -->
+ <!--entry><key>maxPoolSize</key> <value>500</value></entry-->
+
+ <!-- Number of seconds after which an idle worker thread will be -->
+ <!-- purged (socket transport). By default purging is not enabled. -->
+ <!--entry><key>idleTimeout</key> <value>60</value></entry-->
+ </map>
+ </property>
+
+ <property name="invocationHandlers">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <!-- The JSR88 deployment service StreamingTarget handler -->
+ <entry><key>JSR88</key> <value>org.jboss.deployment.remoting.DeployHandler</value></entry>
+ </map>
+ </property>
+ </bean>
+
+</deployment>
Property changes on: trunk/testsuite/src/resources/invokers/service-inf/compressing-invoker-jboss-beans.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Deleted: trunk/testsuite/src/resources/invokers/service-inf/jboss-service.xml
===================================================================
--- trunk/testsuite/src/resources/invokers/service-inf/jboss-service.xml 2010-05-11 13:42:02 UTC (rev 104682)
+++ trunk/testsuite/src/resources/invokers/service-inf/jboss-service.xml 2010-05-11 14:28:21 UTC (rev 104683)
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<server>
-
- <mbean code="org.jboss.invocation.jrmp.server.JRMPInvoker"
- name="jboss:service=invoker,type=jrmp,socketType=CompressionSocketFactory">
- <attribute name="RMIObjectPort">0</attribute>
- <attribute name="RMIClientSocketFactory">org.jboss.test.invokers.ejb.CompressionClientSocketFactory</attribute>
- <attribute name="RMIServerSocketFactory">org.jboss.test.invokers.ejb.CompressionServerSocketFactory</attribute>
- </mbean>
-
-</server>
More information about the jboss-cvs-commits
mailing list