[jboss-svn-commits] JBoss Common SVN: r4387 - in invokablecontainer/trunk: api/src/main/java/org/jboss/invokable and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed May 12 13:48:15 EDT 2010
Author: david.lloyd at jboss.com
Date: 2010-05-12 13:48:15 -0400 (Wed, 12 May 2010)
New Revision: 4387
Added:
invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/RemoteDispatcher.java
invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/RemoteInvocation.java
Modified:
invokablecontainer/trunk/api/pom.xml
invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/Invocation.java
invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/InvocationProcessorFactory.java
invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/ObjectInvocationDispatcher.java
invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/ProcessingInvocationDispatcher.java
invokablecontainer/trunk/build/pom.xml
Log:
Various fixes
Modified: invokablecontainer/trunk/api/pom.xml
===================================================================
--- invokablecontainer/trunk/api/pom.xml 2010-05-12 14:54:33 UTC (rev 4386)
+++ invokablecontainer/trunk/api/pom.xml 2010-05-12 17:48:15 UTC (rev 4387)
@@ -36,6 +36,13 @@
<!-- Dependencies -->
<dependencies>
-
+
+ <dependency>
+ <groupId>org.jboss.remoting</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
</project>
Modified: invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/Invocation.java
===================================================================
--- invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/Invocation.java 2010-05-12 14:54:33 UTC (rev 4386)
+++ invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/Invocation.java 2010-05-12 17:48:15 UTC (rev 4387)
@@ -232,9 +232,6 @@
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
- if (properties == null) {
- throw new InvalidObjectException("properties is null");
- }
if (args == null) {
throw new InvalidObjectException("args is null");
}
Modified: invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/InvocationProcessorFactory.java
===================================================================
--- invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/InvocationProcessorFactory.java 2010-05-12 14:54:33 UTC (rev 4386)
+++ invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/InvocationProcessorFactory.java 2010-05-12 17:48:15 UTC (rev 4387)
@@ -23,7 +23,7 @@
package org.jboss.invokable;
/**
- * A factory for invocation processors, used for assembling interceptor chains.
+ * A factory for invocation processors which delegate to other invocation processors, used for assembling interceptor chains.
*
* @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
*/
Modified: invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/ObjectInvocationDispatcher.java
===================================================================
--- invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/ObjectInvocationDispatcher.java 2010-05-12 14:54:33 UTC (rev 4386)
+++ invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/ObjectInvocationDispatcher.java 2010-05-12 17:48:15 UTC (rev 4387)
@@ -73,4 +73,8 @@
}
}
}
+
+ public String toString() {
+ return "dispatcher to " + target;
+ }
}
Modified: invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/ProcessingInvocationDispatcher.java
===================================================================
--- invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/ProcessingInvocationDispatcher.java 2010-05-12 14:54:33 UTC (rev 4386)
+++ invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/ProcessingInvocationDispatcher.java 2010-05-12 17:48:15 UTC (rev 4387)
@@ -95,4 +95,8 @@
}
}
}
+
+ public String toString() {
+ return String.format("processing dispatcher to %s via %s", dispatcher, processor);
+ }
}
Added: invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/RemoteDispatcher.java
===================================================================
--- invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/RemoteDispatcher.java (rev 0)
+++ invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/RemoteDispatcher.java 2010-05-12 17:48:15 UTC (rev 4387)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.invokable;
+
+import java.io.IOError;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.jboss.remoting3.Attachments;
+import org.jboss.remoting3.Client;
+import org.jboss.remoting3.Connection;
+import org.jboss.remoting3.RemoteExecutionException;
+import org.jboss.remoting3.RemotingContext;
+
+/**
+ * A dispatcher which sends an invocation to a specific remote dispatcher via a JBoss Remoting Client.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+public final class RemoteDispatcher implements InvocationDispatcher {
+ private final String remoteName;
+ private final Client<RemoteInvocation, InvocationReply> client;
+
+ /**
+ * Create a new instance.
+ *
+ * @param remoteName the name of the remote dispatcher
+ * @param client the client used to access the remote context
+ */
+ public RemoteDispatcher(final String remoteName, final Client<RemoteInvocation, InvocationReply> client) {
+ this.client = client;
+ this.remoteName = remoteName;
+ }
+
+ /** {@inheritDoc} */
+ public InvocationReply dispatch(final Invocation invocation) throws InvocationException {
+ try {
+ return client.invoke(new RemoteInvocation(remoteName, invocation));
+ } catch (RemoteExecutionException e) {
+ throw new InvocationException(e.getCause());
+ } catch (IOException e) {
+ throw new IOError(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public <I> void accept(final Visitor<InvocationDispatcher, I> visitor, final I param) {
+ visitor.visit(this, param);
+ }
+
+ protected Object writeReplace() {
+ if (client.getConnection() != RemotingContext.requireCurrent().getConnection()) {
+ throw new IllegalArgumentException("Remote dispatcher cannot be serialized over another connection");
+ }
+ return new SerializedLocalDispatcher(remoteName);
+ }
+
+ static final class SerializedLocalDispatcher implements Serializable {
+ private static final long serialVersionUID = 7094838872506833911L;
+
+ private final String remoteName;
+
+ SerializedLocalDispatcher(final String remoteName) {
+ this.remoteName = remoteName;
+ }
+
+ String getRemoteName() {
+ return remoteName;
+ }
+
+ protected Object readResolve() {
+ try {
+ final Connection c = RemotingContext.requireCurrent().getEndpoint().connect(new URI("local:///")).get();
+ // todo ...
+ final Attachments attachments = c.getAttachments();
+ throw new UnsupportedOperationException();
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ } catch (URISyntaxException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+}
Added: invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/RemoteInvocation.java
===================================================================
--- invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/RemoteInvocation.java (rev 0)
+++ invokablecontainer/trunk/api/src/main/java/org/jboss/invokable/RemoteInvocation.java 2010-05-12 17:48:15 UTC (rev 4387)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.invokable;
+
+import java.io.Serializable;
+
+/**
+ * An invocation bound for a specific remote dispatcher.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+public final class RemoteInvocation implements Serializable {
+
+ private static final long serialVersionUID = 8108865965008810909L;
+
+ private final String dispatcherName;
+ private final Invocation invocation;
+
+ /**
+ * Construct a new instance.
+ *
+ * @param dispatcherName the dispatcher identifier
+ * @param invocation the invocation
+ */
+ public RemoteInvocation(final String dispatcherName, final Invocation invocation) {
+ if (dispatcherName == null) {
+ throw new IllegalArgumentException("dispatcherIdentifier is null");
+ }
+ if (invocation == null) {
+ throw new IllegalArgumentException("invocation is null");
+ }
+ this.dispatcherName = dispatcherName;
+ this.invocation = invocation;
+ }
+
+ /**
+ * Get the dispatcher name.
+ *
+ * @return the dispatcher name
+ */
+ public String getDispatcherName() {
+ return dispatcherName;
+ }
+
+ /**
+ * Get the invocation.
+ *
+ * @return the invocation
+ */
+ public Invocation getInvocation() {
+ return invocation;
+ }
+}
Modified: invokablecontainer/trunk/build/pom.xml
===================================================================
--- invokablecontainer/trunk/build/pom.xml 2010-05-12 14:54:33 UTC (rev 4386)
+++ invokablecontainer/trunk/build/pom.xml 2010-05-12 17:48:15 UTC (rev 4387)
@@ -148,6 +148,13 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.remoting</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ <version>3.1.0.Beta1</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</dependencyManagement>
More information about the jboss-svn-commits
mailing list