JBoss Remoting SVN: r4798 - remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-01-09 15:50:24 -0500 (Fri, 09 Jan 2009)
New Revision: 4798
Modified:
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityClassResolver.java
Log:
javadoc
Modified: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityClassResolver.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityClassResolver.java 2009-01-09 20:44:27 UTC (rev 4797)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityClassResolver.java 2009-01-09 20:50:24 UTC (rev 4798)
@@ -29,7 +29,7 @@
import java.util.Collections;
/**
- *
+ * A base class resolver which maps Remoting 2 classes to their compatible placeholders.
*/
public abstract class CompatabilityClassResolver extends AbstractClassResolver {
15 years, 10 months
JBoss Remoting SVN: r4797 - in remoting3/trunk/compat/src/main/java: org and 3 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-01-09 15:44:27 -0500 (Fri, 09 Jan 2009)
New Revision: 4797
Added:
remoting3/trunk/compat/src/main/java/org/
remoting3/trunk/compat/src/main/java/org/jboss/
remoting3/trunk/compat/src/main/java/org/jboss/remoting/
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityClassResolver.java
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityInvocationRequest.java
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityInvocationResponse.java
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatibilityHome.java
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatibilityInvokerLocator.java
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/Request.java
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/UnwrappingReplyHandler.java
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/UnwrappingRequestHandler.java
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/WrappingReplyHandler.java
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/WrappingRequestHandler.java
remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/package-info.java
Log:
A start on the basic stuff for compatibility layer
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityClassResolver.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityClassResolver.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityClassResolver.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting.compat;
+
+import org.jboss.marshalling.AbstractClassResolver;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+
+/**
+ *
+ */
+public abstract class CompatabilityClassResolver extends AbstractClassResolver {
+
+ private static final Map<Class<?>, String> CLASS_WRITE_MAP;
+ private static final Map<String, Class<?>> CLASS_READ_MAP;
+
+ static {
+ final Map<Class<?>, String> classWriteMap = new HashMap<Class<?>, String>();
+ classWriteMap.put(CompatabilityInvocationRequest.class, "org.jboss.remoting.InvocationRequest");
+ classWriteMap.put(CompatabilityInvocationResponse.class, "org.jboss.remoting.InvocationReply");
+ classWriteMap.put(CompatibilityInvokerLocator.class, "org.jboss.remoting.InvokerLocator");
+ classWriteMap.put(CompatibilityHome.class, "org.jboss.remoting.Home");
+ CLASS_WRITE_MAP = Collections.unmodifiableMap(classWriteMap);
+ final Map<String, Class<?>> classReadMap = new HashMap<String, Class<?>>();
+ for (Map.Entry<Class<?>, String> entry : classWriteMap.entrySet()) {
+ classReadMap.put(entry.getValue(), entry.getKey());
+ }
+ CLASS_READ_MAP = Collections.unmodifiableMap(classReadMap);
+ }
+
+ public String getClassName(final Class<?> clazz) throws IOException {
+ final String name = CLASS_WRITE_MAP.get(clazz);
+ return name == null ? clazz.getName() : name;
+ }
+
+ protected Class<?> loadClass(final String name) throws ClassNotFoundException {
+ final Class<?> clazz = CLASS_READ_MAP.get(name);
+ return clazz == null ? super.loadClass(name) : clazz;
+ }
+}
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityInvocationRequest.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityInvocationRequest.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityInvocationRequest.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting.compat;
+
+import java.io.Serializable;
+import java.io.ObjectStreamField;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.Map;
+
+/**
+ *
+ */
+public final class CompatabilityInvocationRequest implements Serializable {
+ private static final long serialVersionUID = -6719842238864057289L;
+
+ private static final ObjectStreamField[] serialPersistentFields = {
+ new ObjectStreamField("sessionId", String.class),
+ new ObjectStreamField("subsystem", String.class),
+ new ObjectStreamField("arg", Object.class),
+ new ObjectStreamField("requestPayload", Map.class),
+ new ObjectStreamField("returnPayload", Map.class),
+ new ObjectStreamField("locator", CompatibilityInvokerLocator.class),
+ };
+
+ private String sessionId;
+ private String subsystem;
+ private Object arg;
+ private Map<Object, Object> requestPayload;
+ private Map<Object, Object> returnPayload;
+
+ public String getSessionId() {
+ return sessionId;
+ }
+
+ public void setSessionId(final String sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ public String getSubsystem() {
+ return subsystem;
+ }
+
+ public void setSubsystem(final String subsystem) {
+ this.subsystem = subsystem;
+ }
+
+ public Object getArg() {
+ return arg;
+ }
+
+ public void setArg(final Object arg) {
+ this.arg = arg;
+ }
+
+ public Map<Object, Object> getRequestPayload() {
+ return requestPayload;
+ }
+
+ public void setRequestPayload(final Map<Object, Object> requestPayload) {
+ this.requestPayload = requestPayload;
+ }
+
+ public Map<Object, Object> getReturnPayload() {
+ return returnPayload;
+ }
+
+ public void setReturnPayload(final Map<Object, Object> returnPayload) {
+ this.returnPayload = returnPayload;
+ }
+
+ @SuppressWarnings({ "unchecked" })
+ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ final ObjectInputStream.GetField fields = stream.readFields();
+ sessionId = (String) fields.get("sessionId", "");
+ subsystem = (String) fields.get("subsystem", "");
+ arg = fields.get("arg", "");
+ requestPayload = (Map<Object, Object>) fields.get("requestPayload", null);
+ returnPayload = (Map<Object, Object>) fields.get("returnPayload", null);
+ }
+
+ private void writeObject(ObjectOutputStream stream) throws IOException {
+ final ObjectOutputStream.PutField fields = stream.putFields();
+ fields.put("sessionId", sessionId);
+ fields.put("subsystem", subsystem);
+ fields.put("arg", arg);
+ fields.put("requestPayload", requestPayload);
+ fields.put("returnPayload", returnPayload);
+ stream.writeFields();
+ }
+}
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityInvocationResponse.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityInvocationResponse.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatabilityInvocationResponse.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting.compat;
+
+import java.io.Serializable;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.Map;
+
+/**
+ *
+ */
+public final class CompatabilityInvocationResponse<T> implements Serializable {
+ private static final long serialVersionUID = 1324503813652865685L;
+
+ private final String sessionId;
+ private final Object result;
+ private final boolean isException;
+ private Map<Object, Object> payload;
+
+ public CompatabilityInvocationResponse(final String sessionId, final Object result, final boolean isException, final Map<Object, Object> payload) {
+ this.sessionId = sessionId;
+ this.result = result;
+ this.isException = isException;
+ this.payload = payload;
+ }
+
+ public String getSessionId() {
+ return sessionId;
+ }
+
+ public Object getResult() {
+ return result;
+ }
+
+ public boolean isException() {
+ return isException;
+ }
+
+ public Map<Object, Object> getPayload() {
+ return payload;
+ }
+
+ public void setPayload(final Map<Object, Object> payload) {
+ this.payload = payload;
+ }
+
+ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ final ObjectInputStream.GetField fields = stream.readFields();
+ }
+
+ private void writeObject(ObjectOutputStream stream) throws IOException {
+ final ObjectOutputStream.PutField fields = stream.putFields();
+
+ stream.writeFields();
+ }
+}
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatibilityHome.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatibilityHome.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatibilityHome.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting.compat;
+
+import java.io.Serializable;
+
+/**
+ *
+ */
+public final class CompatibilityHome implements Serializable {
+
+ private static final long serialVersionUID = 8267821565540095027L;
+
+ public String host;
+ public int port;
+
+ public CompatibilityHome() {
+ }
+
+ public CompatibilityHome(final String host, final int port) {
+ this.host = host;
+ this.port = port;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(final String host) {
+ this.host = host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(final int port) {
+ this.port = port;
+ }
+}
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatibilityInvokerLocator.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatibilityInvokerLocator.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/CompatibilityInvokerLocator.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting.compat;
+
+import java.net.URI;
+import java.io.Serializable;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.util.ArrayList;
+import java.util.Map;
+
+/**
+ *
+ */
+public final class CompatibilityInvokerLocator implements Serializable {
+
+ private static final long serialVersionUID = -4977622166779282521L;
+
+ private static final ObjectStreamField[] serialPersistentFields = {
+ new ObjectStreamField("protocol", String.class),
+ new ObjectStreamField("host", String.class),
+ new ObjectStreamField("connectHomes", ArrayList.class),
+ new ObjectStreamField("homes", ArrayList.class),
+ new ObjectStreamField("port", int.class),
+ new ObjectStreamField("path", String.class),
+ new ObjectStreamField("query", String.class),
+ new ObjectStreamField("parameters", Map.class),
+ new ObjectStreamField("uri", String.class),
+ new ObjectStreamField("originalURL", String.class),
+ new ObjectStreamField("homeInUse", CompatibilityHome.class),
+ };
+
+ private transient URI uri;
+
+ public CompatibilityInvokerLocator() {
+ }
+
+ public CompatibilityInvokerLocator(final URI uri) {
+ this.uri = uri;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(final URI uri) {
+ this.uri = uri;
+ }
+
+ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ final ObjectInputStream.GetField fields = stream.readFields();
+
+ }
+
+ private void writeObject(ObjectOutputStream stream) throws IOException {
+ final ObjectOutputStream.PutField fields = stream.putFields();
+ fields.put("protocol", uri.getScheme());
+ fields.put("host", uri.getHost());
+ fields.put("port", uri.getPort());
+ fields.put("path", uri.getPath());
+ fields.put("query", uri.getQuery());
+ fields.put("uri", uri.toString());
+ fields.put("originalURL", uri.toString());
+
+ stream.writeFields();
+ }
+}
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/Request.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/Request.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/Request.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting.compat;
+
+import java.util.Map;
+
+/**
+ * A request wrapper object, used to issue a Remoting 2.x invocation with a metadata map.
+ */
+public final class Request<I> {
+ private I body;
+ private Map<Object, Object> metadata;
+
+ public Request() {
+ }
+
+ public Request(final I body, final Map<Object, Object> metadata) {
+ this.body = body;
+ this.metadata = metadata;
+ }
+
+ public I getBody() {
+ return body;
+ }
+
+ public void setBody(final I body) {
+ this.body = body;
+ }
+
+ public Map<Object, Object> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(final Map<Object, Object> metadata) {
+ this.metadata = metadata;
+ }
+}
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/UnwrappingReplyHandler.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/UnwrappingReplyHandler.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/UnwrappingReplyHandler.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting.compat;
+
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.RemoteExecutionException;
+import java.io.IOException;
+
+/**
+ * A reply handler which unwraps a Remoting 2-style invocation response to a Remoting 3-style plain object.
+ */
+public final class UnwrappingReplyHandler implements ReplyHandler {
+
+ private final ReplyHandler replyHandler;
+
+ public UnwrappingReplyHandler(final ReplyHandler replyHandler) {
+ this.replyHandler = replyHandler;
+ }
+
+ public void handleReply(final Object reply) throws IOException {
+ if (reply instanceof CompatabilityInvocationResponse) {
+ final CompatabilityInvocationResponse response = (CompatabilityInvocationResponse) reply;
+ if (response.isException()) {
+ final Object result = response.getResult();
+ if (result instanceof Throwable) {
+ replyHandler.handleException(new RemoteExecutionException("Remote execution failed", (Throwable) result));
+ } else {
+ replyHandler.handleException(new RemoteExecutionException("Remote execution failed: " + result));
+ }
+ } else {
+ replyHandler.handleReply(response.getPayload());
+ }
+ }
+ }
+
+ public void handleException(final IOException exception) throws IOException {
+ replyHandler.handleException(exception);
+ }
+
+ public void handleCancellation() throws IOException {
+ replyHandler.handleCancellation();
+ }
+}
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/UnwrappingRequestHandler.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/UnwrappingRequestHandler.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/UnwrappingRequestHandler.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting.compat;
+
+import org.jboss.remoting.spi.AbstractAutoCloseable;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RemoteRequestContext;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.SpiUtils;
+import org.jboss.remoting.RemoteRequestException;
+import org.jboss.xnio.log.Logger;
+import java.util.concurrent.Executor;
+import java.util.Map;
+import java.io.IOException;
+
+/**
+ * A request handler which unwraps a Remoting 2-style invocation request to a Remoting 3-style plain object
+ * or {@link org.jboss.remoting.compat.Request} instance.
+ */
+public final class UnwrappingRequestHandler extends AbstractAutoCloseable<RequestHandler> implements RequestHandler {
+
+ private static final Logger log = Logger.getLogger("org.jboss.remoting.compat");
+
+ private final RequestHandler next;
+
+ /**
+ * Basic constructor.
+ *
+ * @param executor the executor used to execute the close notification handlers
+ * @param next
+ */
+ protected UnwrappingRequestHandler(final Executor executor, final RequestHandler next) {
+ super(executor);
+ this.next = next;
+ }
+
+ public RemoteRequestContext receiveRequest(final Object request, final ReplyHandler replyHandler) {
+ if (request instanceof CompatabilityInvocationRequest) {
+ final CompatabilityInvocationRequest invocationRequest = (CompatabilityInvocationRequest) request;
+ final Map<Object,Object> map = invocationRequest.getRequestPayload();
+ if (map == null) {
+ return next.receiveRequest(invocationRequest.getArg(), new WrappingReplyHandler(replyHandler));
+ }
+ return null;
+ } else {
+ final RemoteRequestException nex = new RemoteRequestException("Expected a Remoting-2 InvocationRequest instance");
+ try {
+ replyHandler.handleException(nex);
+ } catch (IOException e) {
+ log.error(e, "Failed to forward an exception to the requesting party");
+ log.error(nex, "The original exception follows");
+ }
+ return SpiUtils.getBlankRemoteRequestContext();
+ }
+ }
+}
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/WrappingReplyHandler.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/WrappingReplyHandler.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/WrappingReplyHandler.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting.compat;
+
+import org.jboss.remoting.spi.ReplyHandler;
+import java.io.IOException;
+
+/**
+ * A request handler which wraps a Remoting 3-style reply with a Remoting 2-style invocation response.
+ */
+public final class WrappingReplyHandler implements ReplyHandler {
+
+ private final ReplyHandler replyHandler;
+
+ public WrappingReplyHandler(final ReplyHandler replyHandler) {
+ this.replyHandler = replyHandler;
+ }
+
+ public void handleReply(final Object reply) throws IOException {
+ replyHandler.handleReply(new CompatabilityInvocationResponse(null, reply, false, null));
+ }
+
+ public void handleException(final IOException exception) throws IOException {
+ replyHandler.handleReply(new CompatabilityInvocationResponse(null, exception, true, null));
+ }
+
+ public void handleCancellation() throws IOException {
+ replyHandler.handleCancellation();
+ }
+}
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/WrappingRequestHandler.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/WrappingRequestHandler.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/WrappingRequestHandler.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting.compat;
+
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RemoteRequestContext;
+import org.jboss.remoting.spi.ReplyHandler;
+import org.jboss.remoting.spi.AbstractAutoCloseable;
+import java.util.concurrent.Executor;
+
+/**
+ * A request handler which wraps a Remoting 3-style plain request (or an instance of {@link org.jboss.remoting.compat.Request Request}
+ * with a Remoting 2-style invocation request.
+ */
+public final class WrappingRequestHandler extends AbstractAutoCloseable<RequestHandler> implements RequestHandler {
+
+ private final RequestHandler next;
+
+ public WrappingRequestHandler(final RequestHandler next, final Executor executor) {
+ super(executor);
+ this.next = next;
+ }
+
+ public RemoteRequestContext receiveRequest(final Object obj, final ReplyHandler replyHandler) {
+ final CompatabilityInvocationRequest cir = new CompatabilityInvocationRequest();
+ if (obj instanceof Request) {
+ final Request request = (Request) obj;
+ cir.setArg(request.getBody());
+ // wtf?
+ //noinspection unchecked
+ cir.setRequestPayload(request.getMetadata());
+ } else {
+ cir.setArg(obj);
+ }
+ return next.receiveRequest(cir, new UnwrappingReplyHandler(replyHandler));
+ }
+}
Added: remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/package-info.java
===================================================================
--- remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/package-info.java (rev 0)
+++ remoting3/trunk/compat/src/main/java/org/jboss/remoting/compat/package-info.java 2009-01-09 20:44:27 UTC (rev 4797)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.
+ */
+
+/**
+ * Classes that represent the Remoting 3 end of a relationship with a legacy Remoting 2 service or client.
+ */
+package org.jboss.remoting.compat;
\ No newline at end of file
15 years, 10 months
JBoss Remoting SVN: r4796 - in remoting3/trunk: api/src/main/java/org/jboss/remoting and 2 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-01-08 23:32:38 -0500 (Thu, 08 Jan 2009)
New Revision: 4796
Added:
remoting3/trunk/api/src/main/java/org/jboss/remoting/Version.java
Removed:
remoting3/trunk/api/src/main/java/org/jboss/remoting/version/
Modified:
remoting3/trunk/build.xml
remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java
remoting3/trunk/testing-support/src/main/resources/testing.policy
Log:
Move version to main api package
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/Version.java (from rev 4793, remoting3/trunk/api/src/main/java/org/jboss/remoting/version/Version.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/Version.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/Version.java 2009-01-09 04:32:38 UTC (rev 4796)
@@ -0,0 +1,26 @@
+package org.jboss.remoting;
+
+/**
+ * The version of Remoting.
+ *
+ * @apiviz.exclude
+ */
+public final class Version {
+
+ private Version() {
+ }
+
+ /**
+ * The version.
+ */
+ public static final String VERSION = "3.0.0.CR1";
+
+ /**
+ * Print the version to {@code System.out}.
+ *
+ * @param args ignored
+ */
+ public static void main(String[] args) {
+ System.out.print(VERSION);
+ }
+}
Modified: remoting3/trunk/build.xml
===================================================================
--- remoting3/trunk/build.xml 2009-01-09 04:21:05 UTC (rev 4795)
+++ remoting3/trunk/build.xml 2009-01-09 04:32:38 UTC (rev 4796)
@@ -229,7 +229,7 @@
<path refid="lib.xnio-api.classpath"/>
<path refid="lib.marshalling-api.classpath"/>
</path>
- <java classpathref="api.classpath" classname="org.jboss.remoting.version.Version" outputproperty="version"/>
+ <java classpathref="api.classpath" classname="org.jboss.remoting.Version" outputproperty="version"/>
<property name="version" value="UNKNOWN"/>
</target>
Modified: remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java 2009-01-09 04:21:05 UTC (rev 4795)
+++ remoting3/trunk/core/src/main/java/org/jboss/remoting/core/EndpointImpl.java 2009-01-09 04:32:38 UTC (rev 4796)
@@ -27,7 +27,7 @@
import org.jboss.remoting.spi.RequestHandlerSource;
import org.jboss.remoting.spi.AbstractHandleableCloseable;
import org.jboss.remoting.spi.AbstractSimpleCloseable;
-import org.jboss.remoting.version.Version;
+import org.jboss.remoting.Version;
import org.jboss.xnio.FailedIoFuture;
import org.jboss.xnio.FinishedIoFuture;
import org.jboss.xnio.IoFuture;
Modified: remoting3/trunk/testing-support/src/main/resources/testing.policy
===================================================================
--- remoting3/trunk/testing-support/src/main/resources/testing.policy 2009-01-09 04:21:05 UTC (rev 4795)
+++ remoting3/trunk/testing-support/src/main/resources/testing.policy 2009-01-09 04:32:38 UTC (rev 4796)
@@ -37,6 +37,7 @@
grant codeBase "file:${build.home}/api/target/main/classes/-"
{
permission java.util.PropertyPermission "jboss.remoting.*", "read";
+ permission org.jboss.remoting.EndpointPermission "*";
};
grant codeBase "file:${build.home}/core/target/main/classes/-"
@@ -50,11 +51,6 @@
permission java.util.PropertyPermission "jboss.remoting.*", "read";
};
-grant codeBase "file:${build.home}/standalone/target/main/classes/-"
-{
- permission org.jboss.remoting.EndpointPermission "createEndpoint";
-};
-
// Support classes
grant codeBase "file:${build.home}/testing-support/target/main/classes/-"
15 years, 10 months
JBoss Remoting SVN: r4795 - remoting3/trunk.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-01-08 23:21:05 -0500 (Thu, 08 Jan 2009)
New Revision: 4795
Modified:
remoting3/trunk/build.xml
Log:
minor cleanup
Modified: remoting3/trunk/build.xml
===================================================================
--- remoting3/trunk/build.xml 2009-01-09 03:10:38 UTC (rev 4794)
+++ remoting3/trunk/build.xml 2009-01-09 04:21:05 UTC (rev 4795)
@@ -848,14 +848,10 @@
<target name="all-core" description="Build all core targets" depends="api,compat,core,protocol.basic,protocol.multiplex,samples,testing-support"/>
- <!-- JARs: These should be the third-to-last targets in the file -->
+ <!-- JARs: These should be the second-to-last targets in the file -->
<target name="all-jars" description="Build all the JARs" depends="api-jar,core-jar"/>
- <!-- fetch: These should be the second-to-last targets in the file -->
-
- <!--<target name="all-fetch" description="Pre-fetch all external libraries" depends="lib.jboss-common-core,lib.jboss-common-logging-spi,lib.jboss-deployers-core-spi,lib.jboss-deployers-spi,lib.jboss-deployers-structure-spi,lib.jbossmc-kernel,lib.jboss-managed,lib.jbossxb,lib.marshalling-api,lib.servlet"/>-->
-
<!-- all: These should be the last targets in the file -->
<target name="all" description="Build everything" depends="all-core,all-jars,api-javadoc"/>
15 years, 10 months
JBoss Remoting SVN: r4794 - remoting3/trunk.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-01-08 22:10:38 -0500 (Thu, 08 Jan 2009)
New Revision: 4794
Modified:
remoting3/trunk/build.xml
Log:
Remove mc-deployers from build file
Modified: remoting3/trunk/build.xml
===================================================================
--- remoting3/trunk/build.xml 2009-01-09 03:09:04 UTC (rev 4793)
+++ remoting3/trunk/build.xml 2009-01-09 03:10:38 UTC (rev 4794)
@@ -382,49 +382,6 @@
</path>
</target>
- <!-- mc-deployers module -->
-
- <target name="mc-deployers.compile.depcheck">
- <mkdir dir="mc-deployers/target/main"/>
- <uptodate property="mc-deployers.compile.uptodate" targetfile="mc-deployers/target/main/.lastcompile">
- <srcfiles dir="mc-deployers/src/main/java">
- <include name="**/"/>
- <include name="**/*.java"/>
- <exclude name="**/.*"/>
- </srcfiles>
- </uptodate>
- </target>
-
- <target name="mc-deployers.compile" depends="mc-deployers.compile.depcheck" unless="mc-deployers.compile.uptodate">
- <mkdir dir="mc-deployers/target/main/classes"/>
- <javac
- source="${javac.source}"
- target="${javac.target}"
- srcdir="mc-deployers/src/main/java"
- destdir="mc-deployers/target/main/classes"
- debug="true">
- <compilerarg value="-Xlint:unchecked"/>
- <classpath>
- <path refid="api.classpath"/>
- <path refid="core.classpath"/>
- <path refid="lib.jaxb-api.classpath"/>
- <path refid="lib.jbossmc-kernel.classpath"/>
- <path refid="lib.jbossxb.classpath"/>
- </classpath>
- </javac>
- <touch file="mc-deployers/target/main/.lastcompile" verbose="false"/>
- </target>
-
- <target name="mc-deployers.clean">
- <delete dir="mc-deployers/target"/>
- </target>
-
- <target name="mc-deployers" description="Build the mc-deployers module" depends="lib.jaxb-api,lib.jbossmc-kernel,lib.jbossxb,api,core,mc-deployers.compile">
- <path id="mc-deployers.classpath">
- <pathelement location="mc-deployers/target/main/classes"/>
- </path>
- </target>
-
<!-- protocol.multiplex module -->
<target name="protocol.multiplex.compile.depcheck">
@@ -889,7 +846,7 @@
<!-- core -->
- <target name="all-core" description="Build all core targets" depends="api,compat,core,mc-deployers,protocol.basic,protocol.multiplex,samples,testing-support"/>
+ <target name="all-core" description="Build all core targets" depends="api,compat,core,protocol.basic,protocol.multiplex,samples,testing-support"/>
<!-- JARs: These should be the third-to-last targets in the file -->
@@ -903,7 +860,7 @@
<target name="all" description="Build everything" depends="all-core,all-jars,api-javadoc"/>
- <target name="clean" description="Clean out all build files" depends="api.clean,compat.clean,core.clean,mc-deployers.clean,protocol.basic.clean,protocol.multiplex.clean,samples.clean,testing-support.clean"/>
+ <target name="clean" description="Clean out all build files" depends="api.clean,compat.clean,core.clean,protocol.basic.clean,protocol.multiplex.clean,samples.clean,testing-support.clean"/>
<target name="test" description="Run all tests" depends="api.test,core.test,protocol.basic.test,protocol.multiplex.test"/>
15 years, 10 months
JBoss Remoting SVN: r4793 - remoting-mc-int and 2 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-01-08 22:09:04 -0500 (Thu, 08 Jan 2009)
New Revision: 4793
Added:
remoting-mc-int/
remoting-mc-int/branches/
remoting-mc-int/tags/
remoting-mc-int/trunk/
remoting-mc-int/trunk/metadata/
Removed:
remoting3/trunk/mc-deployers/
Log:
Move mc-deployers to its own project
Copied: remoting-mc-int/trunk/metadata (from rev 4792, remoting3/trunk/mc-deployers)
15 years, 10 months
JBoss Remoting SVN: r4792 - in remoting3/trunk: api/src/main/java/org/jboss/remoting and 1 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-01-08 21:21:57 -0500 (Thu, 08 Jan 2009)
New Revision: 4792
Added:
remoting3/trunk/api/src/main/java/org/jboss/remoting/version/
remoting3/trunk/api/src/main/java/org/jboss/remoting/version/Version.java
Removed:
remoting3/trunk/transporter/
remoting3/trunk/version/
Modified:
remoting3/trunk/build.xml
Log:
Move transporter to its own project; consolidate version package
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/version/Version.java (from rev 4789, remoting3/trunk/version/src/main/java/org/jboss/remoting/version/Version.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/version/Version.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/version/Version.java 2009-01-09 02:21:57 UTC (rev 4792)
@@ -0,0 +1,24 @@
+package org.jboss.remoting.version;
+
+/**
+ * The version of Remoting.
+ */
+public final class Version {
+
+ private Version() {
+ }
+
+ /**
+ * The version.
+ */
+ public static final String VERSION = "3.0.0.CR1";
+
+ /**
+ * Print the version to {@code System.out}.
+ *
+ * @param args ignored
+ */
+ public static void main(String[] args) {
+ System.out.print(VERSION);
+ }
+}
Modified: remoting3/trunk/build.xml
===================================================================
--- remoting3/trunk/build.xml 2009-01-09 02:08:23 UTC (rev 4791)
+++ remoting3/trunk/build.xml 2009-01-09 02:21:57 UTC (rev 4792)
@@ -229,6 +229,8 @@
<path refid="lib.xnio-api.classpath"/>
<path refid="lib.marshalling-api.classpath"/>
</path>
+ <java classpathref="api.classpath" classname="org.jboss.remoting.version.Version" outputproperty="version"/>
+ <property name="version" value="UNKNOWN"/>
</target>
<!-- compat module -->
@@ -293,7 +295,6 @@
<compilerarg value="-Xlint:unchecked"/>
<classpath>
<path refid="api.classpath"/>
- <path refid="version.classpath"/>
</classpath>
</javac>
<touch file="core/target/main/.lastcompile" verbose="false"/>
@@ -375,7 +376,7 @@
<delete dir="core/target"/>
</target>
- <target name="core" description="Build the core module" depends="api,version,core.compile">
+ <target name="core" description="Build the core module" depends="api,core.compile">
<path id="core.classpath">
<pathelement location="core/target/main/classes"/>
</path>
@@ -745,88 +746,11 @@
</path>
</target>
- <!-- transporter module -->
-
- <target name="transporter.compile.depcheck">
- <mkdir dir="transporter/target/main"/>
- <uptodate property="transporter.compile.uptodate" targetfile="transporter/target/main/.lastcompile">
- <srcfiles dir="transporter/src/main/java">
- <include name="**/"/>
- <include name="**/*.java"/>
- <exclude name="**/.*"/>
- </srcfiles>
- </uptodate>
- </target>
-
- <target name="transporter.compile" depends="transporter.compile.depcheck" unless="transporter.compile.uptodate">
- <mkdir dir="transporter/target/main/classes"/>
- <javac
- source="${javac.source}"
- target="${javac.target}"
- srcdir="transporter/src/main/java"
- destdir="transporter/target/main/classes"
- debug="true">
- <compilerarg value="-Xlint:unchecked"/>
- <classpath>
- <path refid="api.classpath"/>
- </classpath>
- </javac>
- <touch file="transporter/target/main/.lastcompile" verbose="false"/>
- </target>
-
- <target name="transporter.clean">
- <delete dir="transporter/target"/>
- </target>
-
- <target name="transporter" description="Build the transporter module" depends="api,lib.xnio-api,transporter.compile">
- <path id="transporter.classpath">
- <pathelement location="transporter/target/main/classes"/>
- </path>
- </target>
-
- <!-- version module -->
-
- <target name="version.compile.depcheck">
- <mkdir dir="version/target/main"/>
- <uptodate property="version.compile.uptodate" targetfile="version/target/main/.lastcompile">
- <srcfiles dir="version/src/main/java">
- <include name="**/"/>
- <include name="**/*.java"/>
- <exclude name="**/.*"/>
- </srcfiles>
- </uptodate>
- </target>
-
- <target name="version.compile" depends="version.compile.depcheck" unless="version.compile.uptodate">
- <mkdir dir="version/target/main/classes"/>
- <javac
- source="${javac.source}"
- target="${javac.target}"
- srcdir="version/src/main/java"
- destdir="version/target/main/classes"
- debug="true">
- <compilerarg value="-Xlint:unchecked"/>
- </javac>
- <touch file="version/target/main/.lastcompile" verbose="false"/>
- </target>
-
- <target name="version.clean">
- <delete dir="version/target"/>
- </target>
-
- <target name="version" description="Build the version module" depends="version.compile">
- <path id="version.classpath">
- <pathelement location="version/target/main/classes"/>
- </path>
- <java classpathref="version.classpath" classname="org.jboss.remoting.version.Version" outputproperty="version"/>
- <property name="version" value="UNKNOWN"/>
- </target>
-
<!-- ============================================== -->
<!-- JARS - Keep in alpha order by jar name -->
<!-- ============================================== -->
- <target name="api-jar" description="Build the API JAR" depends="api,transporter,version">
+ <target name="api-jar" description="Build the API JAR" depends="api">
<delete file="jboss-remoting-api.jar"/>
<jar jarfile="jboss-remoting-api.jar">
<manifest>
@@ -843,16 +767,10 @@
<zipfileset dir="api/target/main/classes">
<include name="**/*.class"/>
</zipfileset>
- <zipfileset dir="transporter/target/main/classes">
- <include name="**/*.class"/>
- </zipfileset>
- <zipfileset dir="version/target/main/classes">
- <include name="**/*.class"/>
- </zipfileset>
</jar>
</target>
- <target name="api-source-jar" description="Build the API source JAR" depends="api,transporter,version">
+ <target name="api-source-jar" description="Build the API source JAR" depends="api">
<delete file="jboss-remoting-api-source.jar"/>
<jar jarfile="jboss-remoting-api-source.jar">
<manifest>
@@ -869,16 +787,10 @@
<zipfileset dir="api/src/main/java">
<include name="**/*.java"/>
</zipfileset>
- <zipfileset dir="transporter/src/main/java">
- <include name="**/*.java"/>
- </zipfileset>
- <zipfileset dir="version/src/main/java">
- <include name="**/*.java"/>
- </zipfileset>
</jar>
</target>
- <target name="core-jar" description="Build the Core JAR" depends="core,version">
+ <target name="core-jar" description="Build the Core JAR" depends="core">
<delete file="jboss-remoting-core.jar"/>
<jar jarfile="jboss-remoting-core.jar">
<manifest>
@@ -898,7 +810,7 @@
</jar>
</target>
- <target name="core-source-jar" description="Build the Core source JAR" depends="core,version">
+ <target name="core-source-jar" description="Build the Core source JAR" depends="core">
<delete file="jboss-remoting-core-source.jar"/>
<jar jarfile="jboss-remoting-core-source.jar">
<manifest>
@@ -922,13 +834,12 @@
<!-- JAVADOCS -->
<!-- ============================================== -->
- <target name="api-javadoc" description="Build the API JavaDoc" depends="api,core,transporter,lib.apiviz,lib.marshalling-api,lib.xnio-api">
+ <target name="api-javadoc" description="Build the API JavaDoc" depends="api,core,lib.apiviz,lib.marshalling-api,lib.xnio-api">
<delete dir="api/target/main/docs"/>
<mkdir dir="api/target/main/docs"/>
<javadoc destdir="api/target/main/docs" author="false" version="false" use="false" windowtitle="JBoss Remoting API">
<doclet name="${lib.apiviz.doclet}" pathref="lib.apiviz.classpath"/>
<packageset dir="api/src/main/java"/>
- <packageset dir="transporter/src/main/java"/>
<doctitle><![CDATA[<h1>JBoss Remoting, version ${version}</h1>]]></doctitle>
<header><![CDATA[JBoss Remoting ${version}]]></header>
<footer><![CDATA[JBoss Remoting ${version}]]></footer>
@@ -939,7 +850,6 @@
<classpath>
<path refid="core.classpath"/>
<path refid="api.classpath"/>
- <path refid="transporter.classpath"/>
</classpath>
</javadoc>
</target>
@@ -979,10 +889,8 @@
<!-- core -->
- <target name="all-core" description="Build all core targets" depends="api,compat,core,mc-deployers,protocol.basic,protocol.multiplex,samples,testing-support,transporter"/>
+ <target name="all-core" description="Build all core targets" depends="api,compat,core,mc-deployers,protocol.basic,protocol.multiplex,samples,testing-support"/>
- <target name="clean-core" description="Clean all core targets" depends="api.clean,compat.clean,core.clean,mc-deployers.clean,protocol.basic.clean,protocol.multiplex.clean,samples.clean,testing-support.clean,transporter.clean"/>
-
<!-- JARs: These should be the third-to-last targets in the file -->
<target name="all-jars" description="Build all the JARs" depends="api-jar,core-jar"/>
@@ -995,7 +903,7 @@
<target name="all" description="Build everything" depends="all-core,all-jars,api-javadoc"/>
- <target name="clean" description="Clean out all build files" depends="clean-core,version.clean"/>
+ <target name="clean" description="Clean out all build files" depends="api.clean,compat.clean,core.clean,mc-deployers.clean,protocol.basic.clean,protocol.multiplex.clean,samples.clean,testing-support.clean"/>
<target name="test" description="Run all tests" depends="api.test,core.test,protocol.basic.test,protocol.multiplex.test"/>
15 years, 10 months
JBoss Remoting SVN: r4791 - remoting3-transporter and 1 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-01-08 21:08:23 -0500 (Thu, 08 Jan 2009)
New Revision: 4791
Added:
remoting3-transporter/
remoting3-transporter/branches/
remoting3-transporter/tags/
remoting3-transporter/trunk/
remoting3-transporter/trunk/main/
Log:
Add seperate transporter project
Copied: remoting3-transporter/trunk/main (from rev 4790, remoting3/trunk/transporter)
15 years, 10 months
JBoss Remoting SVN: r4790 - in remoting3/trunk: api/src/main/java/org/jboss/remoting and 1 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-01-08 20:57:46 -0500 (Thu, 08 Jan 2009)
New Revision: 4790
Added:
remoting3/trunk/api/src/main/java/org/jboss/remoting/Remoting.java
Removed:
remoting3/trunk/standalone/
Modified:
remoting3/trunk/build.xml
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java
Log:
Get rid of the standalone module and JAR file - instead, standalone apps include the API, core, and protocol JARs
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/Remoting.java (from rev 4789, remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/Remoting.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/Remoting.java 2009-01-09 01:57:46 UTC (rev 4790)
@@ -0,0 +1,187 @@
+package org.jboss.remoting;
+
+import java.io.IOException;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.Executors;
+import org.jboss.remoting.spi.RequestHandler;
+import org.jboss.remoting.spi.RequestHandlerSource;
+import org.jboss.remoting.spi.Handle;
+import org.jboss.xnio.IoUtils;
+import org.jboss.xnio.CloseableExecutor;
+import org.jboss.xnio.log.Logger;
+
+/**
+ * The standalone interface into Remoting. This class contains static methods that are useful to standalone programs
+ * for managing endpoints and services in a simple fashion.
+ *
+ * @apiviz.landmark
+ */
+public final class Remoting {
+
+ private static final Logger log = Logger.getLogger("org.jboss.remoting");
+
+ /**
+ * Create an endpoint. The endpoint will create its own thread pool with a maximum of 10 threads.
+ *
+ * @param name the name of the endpoint
+ * @return the endpoint
+ */
+ public static Endpoint createEndpoint(final String name) throws IOException {
+ return createEndpoint(name, 10);
+ }
+
+ /**
+ * Create an endpoint. The endpoint will create its own thread pool with a maximum of {@code maxThreads} threads.
+ *
+ * You must have the {@link org.jboss.remoting.EndpointPermission createEndpoint EndpointPermission} to invoke this method.
+ *
+ * @param name the name of the endpoint
+ * @param maxThreads the maximum thread count
+ * @return the endpoint
+ */
+ public static Endpoint createEndpoint(final String name, final int maxThreads) throws IOException {
+ final CloseableExecutor executor = createExecutor(maxThreads);
+ final Endpoint endpoint = createEndpoint(executor, name);
+ endpoint.addCloseHandler(new CloseHandler<Endpoint>() {
+ public void handleClose(final Endpoint closed) {
+ IoUtils.safeClose(executor);
+ }
+ });
+ return endpoint;
+ }
+
+ private static final ThreadFactory OUR_THREAD_FACTORY = new ThreadFactory() {
+ private final ThreadFactory defaultThreadFactory = Executors.defaultThreadFactory();
+
+ public Thread newThread(final Runnable r) {
+ final Thread thread = defaultThreadFactory.newThread(r);
+ thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+ public void uncaughtException(final Thread t, final Throwable e) {
+ log.error(e, "Uncaught exception in thread %s", t);
+ }
+ });
+ return thread;
+ }
+ };
+
+ /**
+ * Create a simple thread pool that is compatible with Remoting. The thread pool will have a maximum of {@code maxThreads}
+ * threads.
+ *
+ * @param maxThreads the maximum thread count
+ * @return a closeable executor
+ */
+ public static CloseableExecutor createExecutor(final int maxThreads) {
+ return IoUtils.closeableExecutor(new ThreadPoolExecutor(1, maxThreads, 30L, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(50), OUR_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy()), 30L, TimeUnit.SECONDS);
+ }
+
+ /**
+ * Create an endpoint using the given {@code Executor} to execute tasks.
+ *
+ * @param executor the executor to use
+ * @param name the name of the endpoint
+ * @return the endpoint
+ */
+ public static Endpoint createEndpoint(final Executor executor, final String name) throws IOException {
+ try {
+ return (Endpoint) Class.forName("org.jboss.remoting.core.EndpointImpl").getConstructor(Executor.class, String.class).newInstance(executor, name);
+ } catch (Exception e) {
+ throw new EndpointException("Unable to create endpoint", e);
+ }
+ }
+
+ /**
+ * Create a local client from a request listener. The client will retain the sole reference to the request listener,
+ * so when the client is closed, the listener will also be closed (unless the client is sent to a remote endpoint).
+ *
+ * @param endpoint the endpoint to bind the request listener to
+ * @param requestListener the request listener
+ * @param requestClass the request class
+ * @param replyClass the reply class
+ * @param <I> the request type
+ * @param <O> the reply type
+ * @return a new client
+ * @throws IOException if an error occurs
+ */
+ public static <I, O> Client<I, O> createLocalClient(final Endpoint endpoint, final RequestListener<I, O> requestListener, final Class<I> requestClass, final Class<O> replyClass) throws IOException {
+ final Handle<RequestHandler> handle = endpoint.createRequestHandler(requestListener, requestClass, replyClass);
+ try {
+ return endpoint.createClient(handle.getResource(), requestClass, replyClass);
+ } finally {
+ IoUtils.safeClose(handle);
+ }
+ }
+
+ /**
+ * Create a local client source from a local service configuration. The client source will be registered on the endpoint.
+ *
+ * @param endpoint the endpoint to bind the service to
+ * @param config the service configuration
+ * @param <I> the request type
+ * @param <O> the reply type
+ * @return a new client source
+ * @throws IOException if an error occurs
+ */
+ public static <I, O> ClientSource<I, O> createLocalClientSource(final Endpoint endpoint, final LocalServiceConfiguration<I, O> config) throws IOException {
+ final Handle<RequestHandlerSource> handle = endpoint.registerService(config);
+ try {
+ return endpoint.createClientSource(handle.getResource(), config.getRequestClass(), config.getReplyClass());
+ } finally {
+ IoUtils.safeClose(handle);
+ }
+ }
+
+ /**
+ * An exception indicating that there was a problem creating an endpoint.
+ *
+ * @apiviz.exclude
+ */
+ public static final class EndpointException extends RemotingException {
+ private static final long serialVersionUID = -9157350594373125152L;
+
+ /**
+ * Constructs a <tt>EndpointException</tt> with no detail message. The cause is not initialized, and may
+ * subsequently be initialized by a call to {@link #initCause(Throwable) initCause}.
+ */
+ public EndpointException() {
+ }
+
+ /**
+ * Constructs a <tt>EndpointException</tt> with the specified detail message. The cause is not initialized, and
+ * may subsequently be initialized by a call to {@link #initCause(Throwable) initCause}.
+ *
+ * @param msg the detail message
+ */
+ public EndpointException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Constructs a <tt>EndpointException</tt> with the specified cause. The detail message is set to:
+ * <pre>
+ * (cause == null ? null : cause.toString())</pre>
+ * (which typically contains the class and detail message of <tt>cause</tt>).
+ *
+ * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method)
+ */
+ public EndpointException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructs a <tt>EndpointException</tt> with the specified detail message and cause.
+ *
+ * @param msg the detail message
+ * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method)
+ */
+ public EndpointException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+ }
+
+ private Remoting() { /* empty */ }
+}
Modified: remoting3/trunk/build.xml
===================================================================
--- remoting3/trunk/build.xml 2009-01-08 22:36:45 UTC (rev 4789)
+++ remoting3/trunk/build.xml 2009-01-09 01:57:46 UTC (rev 4790)
@@ -598,7 +598,6 @@
<path refid="api.classpath"/>
<path refid="core.classpath"/>
<path refid="protocol.basic.classpath"/>
- <path refid="standalone.classpath"/>
<path refid="testing-support.classpath"/>
<path refid="lib.junit.classpath"/>
<path refid="lib.river.classpath"/>
@@ -627,7 +626,6 @@
<path refid="api.classpath"/>
<path refid="core.classpath"/>
<path refid="protocol.basic.classpath"/>
- <path refid="standalone.classpath"/>
<path refid="testing-support.classpath"/>
<pathelement location="protocol/basic/target/test/classes"/>
<path refid="lib.junit.classpath"/>
@@ -643,7 +641,7 @@
</junit>
</target>
- <target name="protocol.basic.test" depends="lib.river,lib.xnio-nio,api,core,protocol.basic,standalone,testing-support,protocol.basic.test.compile">
+ <target name="protocol.basic.test" depends="lib.river,lib.xnio-nio,api,core,protocol.basic,testing-support,protocol.basic.test.compile">
<antcall inheritall="true" inheritrefs="true" target="protocol.basic.test.pseudotarget">
<param name="extension" value=".txt"/>
<param name="message" value="Running with no security manager"/>
@@ -691,7 +689,6 @@
<classpath>
<path refid="api.classpath"/>
<path refid="protocol.multiplex.classpath"/>
- <path refid="standalone.classpath"/>
<path refid="lib.river.classpath"/>
</classpath>
</javac>
@@ -702,52 +699,12 @@
<delete dir="samples/target"/>
</target>
- <target name="samples" description="Build the samples module" depends="lib.marshalling-api,lib.river,api,protocol.multiplex,standalone,samples.compile">
+ <target name="samples" description="Build the samples module" depends="lib.marshalling-api,lib.river,api,protocol.multiplex,samples.compile">
<path id="samples.classpath">
<pathelement location="samples/target/main/classes"/>
</path>
</target>
- <!-- standalone module -->
-
- <target name="standalone.compile.depcheck">
- <mkdir dir="standalone/target/main"/>
- <uptodate property="standalone.compile.uptodate" targetfile="standalone/target/main/.lastcompile">
- <srcfiles dir="standalone/src/main/java">
- <include name="**/"/>
- <include name="**/*.java"/>
- <exclude name="**/.*"/>
- </srcfiles>
- </uptodate>
- </target>
-
- <target name="standalone.compile" depends="standalone.compile.depcheck" unless="standalone.compile.uptodate">
- <mkdir dir="standalone/target/main/classes"/>
- <javac
- source="${javac.source}"
- target="${javac.target}"
- srcdir="standalone/src/main/java"
- destdir="standalone/target/main/classes"
- debug="true">
- <compilerarg value="-Xlint:unchecked"/>
- <classpath>
- <path refid="api.classpath"/>
- <path refid="core.classpath"/>
- </classpath>
- </javac>
- <touch file="standalone/target/main/.lastcompile" verbose="false"/>
- </target>
-
- <target name="standalone.clean">
- <delete dir="standalone/target"/>
- </target>
-
- <target name="standalone" description="Build the standalone module" depends="lib.xnio-api,api,core,standalone.compile">
- <path id="standalone.classpath">
- <pathelement location="standalone/target/main/classes"/>
- </path>
- </target>
-
<!-- testing-support module -->
<target name="testing-support.compile.depcheck">
@@ -961,81 +918,16 @@
</jar>
</target>
- <target name="standalone-jar" description="Build the standalone JAR" depends="api,core,standalone,transporter,version">
- <delete file="jboss-remoting-standalone.jar"/>
- <jar jarfile="jboss-remoting-standalone.jar">
- <manifest>
- <attribute name="Created-By" value="${java.vm.version} (${java.vm.vendor})"/>
- <attribute name="Specification-Title" value="JBoss Remoting"/>
- <attribute name="Specification-Version" value="${version}"/>
- <attribute name="Specification-Vendor" value="JBoss (http://www.jboss.org/)"/>
- <attribute name="Implementation-Title" value="JBoss Remoting - Standalone Version"/>
- <attribute name="Implementation-URL" value="http://labs.jboss.org/jbossremoting/"/>
- <attribute name="Implementation-Version" value="${version}"/>
- <attribute name="Implementation-Vendor" value="JBoss, a division of Red Hat, Inc."/>
- <attribute name="Implementation-Vendor-Id" value="http://www.jboss.org"/>
- </manifest>
- <zipfileset dir="api/target/main/classes">
- <include name="**/*.class"/>
- </zipfileset>
- <zipfileset dir="core/target/main/classes">
- <include name="**/*.class"/>
- </zipfileset>
- <zipfileset dir="standalone/target/main/classes">
- <include name="**/*.class"/>
- </zipfileset>
- <zipfileset dir="transporter/target/main/classes">
- <include name="**/*.class"/>
- </zipfileset>
- <zipfileset dir="version/target/main/classes">
- <include name="**/*.class"/>
- </zipfileset>
- </jar>
- </target>
-
- <target name="standalone-source-jar" description="Build the standalone source JAR" depends="api,core,standalone,transporter,version">
- <delete file="jboss-remoting-standalone-source.jar"/>
- <jar jarfile="jboss-remoting-standalone-source.jar">
- <manifest>
- <attribute name="Created-By" value="${java.vm.version} (${java.vm.vendor})"/>
- <attribute name="Specification-Title" value="JBoss Remoting Source"/>
- <attribute name="Specification-Version" value="${version}"/>
- <attribute name="Specification-Vendor" value="JBoss (http://www.jboss.org/)"/>
- <attribute name="Implementation-Title" value="JBoss Remoting Source - Standalone Version"/>
- <attribute name="Implementation-URL" value="http://labs.jboss.org/jbossremoting/"/>
- <attribute name="Implementation-Version" value="${version}"/>
- <attribute name="Implementation-Vendor" value="JBoss, a division of Red Hat, Inc."/>
- <attribute name="Implementation-Vendor-Id" value="http://www.jboss.org"/>
- </manifest>
- <zipfileset dir="api/src/main/java">
- <include name="**/*.java"/>
- </zipfileset>
- <zipfileset dir="core/src/main/java">
- <include name="**/*.java"/>
- </zipfileset>
- <zipfileset dir="standalone/src/main/java">
- <include name="**/*.java"/>
- </zipfileset>
- <zipfileset dir="transporter/src/main/java">
- <include name="**/*.java"/>
- </zipfileset>
- <zipfileset dir="version/src/main/java">
- <include name="**/*.java"/>
- </zipfileset>
- </jar>
- </target>
-
<!-- ============================================== -->
<!-- JAVADOCS -->
<!-- ============================================== -->
- <target name="api-javadoc" description="Build the API JavaDoc" depends="api,core,standalone,transporter,lib.apiviz,lib.marshalling-api,lib.xnio-api">
+ <target name="api-javadoc" description="Build the API JavaDoc" depends="api,core,transporter,lib.apiviz,lib.marshalling-api,lib.xnio-api">
<delete dir="api/target/main/docs"/>
<mkdir dir="api/target/main/docs"/>
<javadoc destdir="api/target/main/docs" author="false" version="false" use="false" windowtitle="JBoss Remoting API">
<doclet name="${lib.apiviz.doclet}" pathref="lib.apiviz.classpath"/>
<packageset dir="api/src/main/java"/>
- <packageset dir="standalone/src/main/java"/>
<packageset dir="transporter/src/main/java"/>
<doctitle><![CDATA[<h1>JBoss Remoting, version ${version}</h1>]]></doctitle>
<header><![CDATA[JBoss Remoting ${version}]]></header>
@@ -1047,7 +939,6 @@
<classpath>
<path refid="core.classpath"/>
<path refid="api.classpath"/>
- <path refid="standalone.classpath"/>
<path refid="transporter.classpath"/>
</classpath>
</javadoc>
@@ -1069,7 +960,7 @@
<!-- Distribution target -->
<!-- ============================================== -->
- <target name="dist" description="Build distribution zip file" depends="api-jar,api-source-jar,api-javadoc-zip,core-jar,core-source-jar,standalone-jar,standalone-source-jar">
+ <target name="dist" description="Build distribution zip file" depends="api-jar,api-source-jar,api-javadoc-zip,core-jar,core-source-jar">
<delete file="jboss-remoting.zip"/>
<zip zipfile="jboss-remoting.zip">
<zipfileset dir="${basedir}">
@@ -1078,8 +969,6 @@
<include name="jboss-remoting-api-source.jar"/>
<include name="jboss-remoting-core.jar"/>
<include name="jboss-remoting-core-source.jar"/>
- <include name="jboss-remoting-standalone.jar"/>
- <include name="jboss-remoting-standalone-source.jar"/>
<include name="jboss-remoting-javadoc.zip"/>
</zipfileset>
</zip>
@@ -1090,13 +979,13 @@
<!-- core -->
- <target name="all-core" description="Build all core targets" depends="api,compat,core,mc-deployers,protocol.basic,protocol.multiplex,samples,standalone,testing-support,transporter"/>
+ <target name="all-core" description="Build all core targets" depends="api,compat,core,mc-deployers,protocol.basic,protocol.multiplex,samples,testing-support,transporter"/>
- <target name="clean-core" description="Clean all core targets" depends="api.clean,compat.clean,core.clean,mc-deployers.clean,protocol.basic.clean,protocol.multiplex.clean,samples.clean,standalone.clean,testing-support.clean,transporter.clean"/>
+ <target name="clean-core" description="Clean all core targets" depends="api.clean,compat.clean,core.clean,mc-deployers.clean,protocol.basic.clean,protocol.multiplex.clean,samples.clean,testing-support.clean,transporter.clean"/>
<!-- JARs: These should be the third-to-last targets in the file -->
- <target name="all-jars" description="Build all the JARs" depends="api-jar,core-jar,standalone-jar"/>
+ <target name="all-jars" description="Build all the JARs" depends="api-jar,core-jar"/>
<!-- fetch: These should be the second-to-last targets in the file -->
Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java 2009-01-08 22:36:45 UTC (rev 4789)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java 2009-01-09 01:57:46 UTC (rev 4790)
@@ -67,61 +67,63 @@
}
public static void main(String[] args) {
- final Endpoint endpoint = Remoting.createEndpoint("example-client-endpoint");
try {
- // now create the client
- final NamedServiceRegistry serviceRegistry = new NamedServiceRegistry();
- final MultiplexConfiguration config = new MultiplexConfiguration();
- config.setNamedServiceRegistry(serviceRegistry);
- config.setAllocator(Buffers.createHeapByteBufferAllocator(1024));
- config.setMarshallerFactory(new RiverMarshallerFactory());
- config.setExecutor(IoUtils.directExecutor());
- config.setLinkMetric(100);
- config.setMarshallingConfiguration(new MarshallingConfiguration());
- final Xnio xnio = Xnio.create();
+ final Endpoint endpoint = Remoting.createEndpoint("example-client-endpoint");
try {
- final ConfigurableFactory<CloseableTcpConnector> tcpConnectorFactory = xnio.createTcpConnector();
- final CloseableTcpConnector closeableTcpConnector = tcpConnectorFactory.create();
+ // now create the client
+ final NamedServiceRegistry serviceRegistry = new NamedServiceRegistry();
+ final MultiplexConfiguration config = new MultiplexConfiguration();
+ config.setNamedServiceRegistry(serviceRegistry);
+ config.setAllocator(Buffers.createHeapByteBufferAllocator(1024));
+ config.setMarshallerFactory(new RiverMarshallerFactory());
+ config.setExecutor(IoUtils.directExecutor());
+ config.setLinkMetric(100);
+ config.setMarshallingConfiguration(new MarshallingConfiguration());
+ final Xnio xnio = Xnio.create();
try {
- final ChannelSource<AllocatedMessageChannel> channelSource = Channels.convertStreamToAllocatedMessage(closeableTcpConnector.createChannelSource(new InetSocketAddress("localhost", 10000)), 1024, 1024);
- final IoFuture<MultiplexConnection> futureConnection = MultiplexProtocol.connect(endpoint, config, channelSource);
- final MultiplexConnection connection = futureConnection.get();
+ final ConfigurableFactory<CloseableTcpConnector> tcpConnectorFactory = xnio.createTcpConnector();
+ final CloseableTcpConnector closeableTcpConnector = tcpConnectorFactory.create();
try {
- final Handle<RequestHandlerSource> handle = connection.openRemoteService(QualifiedName.parse("/jboss/example/string-rot-13"));
+ final ChannelSource<AllocatedMessageChannel> channelSource = Channels.convertStreamToAllocatedMessage(closeableTcpConnector.createChannelSource(new InetSocketAddress("localhost", 10000)), 1024, 1024);
+ final IoFuture<MultiplexConnection> futureConnection = MultiplexProtocol.connect(endpoint, config, channelSource);
+ final MultiplexConnection connection = futureConnection.get();
try {
- final ClientSource<String, String> clientSource = endpoint.createClientSource(handle.getResource(), String.class, String.class);
+ final Handle<RequestHandlerSource> handle = connection.openRemoteService(QualifiedName.parse("/jboss/example/string-rot-13"));
try {
- final Client<String, String> client = clientSource.createClient();
+ final ClientSource<String, String> clientSource = endpoint.createClientSource(handle.getResource(), String.class, String.class);
try {
- System.out.println("Enter text, send EOF to terminate");
- final BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));
- String line;
- while ((line = inputReader.readLine()) != null) {
- System.out.println("Response: " + client.invoke(line));
+ final Client<String, String> client = clientSource.createClient();
+ try {
+ System.out.println("Enter text, send EOF to terminate");
+ final BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));
+ String line;
+ while ((line = inputReader.readLine()) != null) {
+ System.out.println("Response: " + client.invoke(line));
+ }
+ System.out.println("Done!");
+ } finally {
+ IoUtils.safeClose(client);
}
- System.out.println("Done!");
} finally {
- IoUtils.safeClose(client);
+ IoUtils.safeClose(clientSource);
}
} finally {
- IoUtils.safeClose(clientSource);
+ IoUtils.safeClose(handle);
}
} finally {
- IoUtils.safeClose(handle);
+ IoUtils.safeClose(connection);
}
} finally {
- IoUtils.safeClose(connection);
+ IoUtils.safeClose(closeableTcpConnector);
}
} finally {
- IoUtils.safeClose(closeableTcpConnector);
+ IoUtils.safeClose(xnio);
}
} finally {
- IoUtils.safeClose(xnio);
+ IoUtils.safeClose(endpoint);
}
} catch (IOException e) {
e.printStackTrace();
- } finally {
- IoUtils.safeClose(endpoint);
}
}
}
Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java 2009-01-08 22:36:45 UTC (rev 4789)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java 2009-01-09 01:57:46 UTC (rev 4790)
@@ -110,11 +110,11 @@
} finally {
IoUtils.safeClose(handle);
}
- } catch (IOException e) {
- e.printStackTrace();
} finally {
IoUtils.safeClose(endpoint);
}
+ } catch (IOException e) {
+ e.printStackTrace();
} finally {
IoUtils.safeClose(executor);
}
15 years, 10 months
JBoss Remoting SVN: r4789 - in remoting3/trunk: api/src/main/java/org/jboss/remoting/spi and 5 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2009-01-08 17:36:45 -0500 (Thu, 08 Jan 2009)
New Revision: 4789
Added:
remoting3/trunk/api/src/main/java/org/jboss/remoting/QualifiedName.java
Removed:
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/QualifiedName.java
Modified:
remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientContext.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/CloseHandler.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/HandleableCloseable.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/LocalServiceConfiguration.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/RemoteServiceConfiguration.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestCancelHandler.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContext.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestListener.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceContext.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/package-info.java
remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/NamedServiceRegistry.java
remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/NameTestCase.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConnection.java
remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexReadHandler.java
remoting3/trunk/protocol/multiplex/src/test/java/org/jboss/remoting/protocol/multiplex/ConnectionTestCase.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java
remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java
remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java
Log:
Move QualifiedName to the main Remoting package
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/Client.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -11,6 +11,8 @@
*
* @param <I> the request type
* @param <O> the reply type
+ *
+ * @apiviz.landmark
*/
public interface Client<I, O> extends HandleableCloseable<Client<I, O>> {
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientContext.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientContext.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ClientContext.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -4,6 +4,8 @@
/**
* The server context for a single remote client instance.
+ *
+ * @apiviz.exclude
*/
public interface ClientContext extends HandleableCloseable<ClientContext> {
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/CloseHandler.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/CloseHandler.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/CloseHandler.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -4,6 +4,8 @@
* A handler which is notified of a resource close.
*
* @param <T> the type of resource
+ *
+ * @apiviz.exclude
*/
public interface CloseHandler<T> {
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/Endpoint.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -10,6 +10,8 @@
/**
* A potential participant in a JBoss Remoting communications relationship.
+ *
+ * @apiviz.landmark
*/
public interface Endpoint extends HandleableCloseable<Endpoint> {
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/HandleableCloseable.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/HandleableCloseable.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/HandleableCloseable.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -7,6 +7,8 @@
* A Remoting resource that can be closed.
*
* @param <T> the type that is passed to the close handler
+ *
+ * @apiviz.exclude
*/
public interface HandleableCloseable<T> extends Closeable {
@@ -28,6 +30,8 @@
/**
* A key which may be used to remove this handler.
+ *
+ * @apiviz.exclude
*/
interface Key {
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/LocalServiceConfiguration.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/LocalServiceConfiguration.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/LocalServiceConfiguration.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -24,6 +24,8 @@
/**
* A configuration for a service to be deployed into the endpoint.
+ *
+ * @apiviz.exclude
*/
public final class LocalServiceConfiguration<I, O> {
private final RequestListener<I, O> requestListener;
Copied: remoting3/trunk/api/src/main/java/org/jboss/remoting/QualifiedName.java (from rev 4761, remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/QualifiedName.java)
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/QualifiedName.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/QualifiedName.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -0,0 +1,222 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.remoting;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * A qualified name for service registration. A qualified name is a path-like structure comprised of a series of
+ * zero or more name segments. The string representation of a qualified name is a sequence of a forward slash
+ * ({@code /}) followed by a non-empty URL-encoded name segment.
+ */
+public final class QualifiedName implements Comparable<QualifiedName>, Iterable<String> {
+
+ /**
+ * The root name.
+ */
+ public static final QualifiedName ROOT_NAME = new QualifiedName(new String[0]);
+
+ private final String[] segments;
+
+ /**
+ * Create a new qualified name from the given name segments.
+ *
+ * @param nameSegments the name segments
+ * @throws NullPointerException if {@code nameSegments} is {@code null} or if any element of that array is {@code null}
+ * @throws IllegalArgumentException if an element of {@code nameSegments} is an empty string
+ */
+ public QualifiedName(final String[] nameSegments) throws NullPointerException, IllegalArgumentException {
+ if (nameSegments == null) {
+ throw new NullPointerException("segments is null");
+ }
+ String[] segments = nameSegments.clone();
+ for (String s : segments) {
+ if (s == null) {
+ throw new NullPointerException("Null segment");
+ }
+ if (s.length() == 0) {
+ throw new IllegalArgumentException("Empty segment");
+ }
+ }
+ this.segments = segments;
+ }
+
+ /**
+ * Compare this qualified name to another for equality. Returns {@code true} if both names have the same number of segments
+ * with the same content.
+ *
+ * @param o the object to compare to
+ * @return {@code true} if the given object is a qualified name which is equal to this name
+ */
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (! (o instanceof QualifiedName)) return false;
+ final QualifiedName name = (QualifiedName) o;
+ if (!Arrays.equals(segments, name.segments)) return false;
+ return true;
+ }
+
+ /**
+ * Get the hash code of this qualified name. Equal to the return value of {@link Arrays#hashCode(Object[]) Arrays.hashCode(segments)}
+ * where {@code segments} is the array of decoded segment strings.
+ *
+ * @return the hash code
+ */
+ public int hashCode() {
+ return Arrays.hashCode(segments);
+ }
+
+ /**
+ * Compare this qualified name to another. Each segment is compared in turn; if they are equal then the comparison
+ * carries on to the next segment. If all leading segments are equal but one qualified name has more segments,
+ * then the longer name is said to come after the shorter name.
+ *
+ * @param o the other name
+ * @return {@code 0} if the elements are equal, {@code -1} if this name comes before the given name, or {@code 1} if
+ * this name comes after the given name
+ */
+ public int compareTo(final QualifiedName o) {
+ if (this == o) return 0;
+ String[] a = segments;
+ String[] b = o.segments;
+ final int alen = a.length;
+ final int blen = b.length;
+ for (int i = 0; i < alen && i < blen; i ++) {
+ final int cmp = a[i].compareTo(b[i]);
+ if (cmp != 0) {
+ return cmp;
+ }
+ }
+ if (alen < blen) {
+ return -1;
+ } else if (alen > blen) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ /**
+ * Get the string representation of this qualified name. The root name is "{@code /}"; all other names are comprised
+ * of one or more consecutive character sequences of a forward slash followed by one or more URL-encoded characters.
+ *
+ * @return the string representation of this name
+ */
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ if (segments.length == 0) {
+ return "/";
+ } else for (String segment : segments) {
+ try {
+ builder.append('/');
+ builder.append(URLEncoder.encode(segment, "utf-8"));
+ } catch (UnsupportedEncodingException e) {
+ // cannot happen
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder.toString();
+ }
+
+ /**
+ * Parse a qualified name. A qualified name must consist of either a single forward slash ("{@code /}") or else
+ * a series of path components, each comprised of a single forward slash followed by a URL-encoded series of non-forward-slash
+ * characters.
+ *
+ * @param path the path
+ * @return the qualified name
+ */
+ public static QualifiedName parse(String path) {
+ List<String> decoded = new ArrayList<String>();
+ final int len = path.length();
+ if (len < 1) {
+ throw new IllegalArgumentException("Empty path");
+ }
+ if (path.charAt(0) != '/') {
+ throw new IllegalArgumentException("Relative paths are not allowed");
+ }
+ if (len == 1) {
+ return ROOT_NAME;
+ }
+ int segStart = 0;
+ int segEnd;
+ do {
+ segEnd = path.indexOf('/', segStart + 1);
+ String segment = segEnd == -1 ? path.substring(segStart + 1) : path.substring(segStart + 1, segEnd);
+ if (segment.length() == 0) {
+ throw new IllegalArgumentException(segEnd == -1 ? "Invalid trailing slash" : "Empty segment in path");
+ }
+ try {
+ decoded.add(URLDecoder.decode(segment, "utf-8"));
+ } catch (UnsupportedEncodingException e) {
+ // cannot happen
+ throw new IllegalStateException(e);
+ }
+ segStart = segEnd;
+ } while (segEnd != -1);
+ return new QualifiedName(decoded.toArray(new String[decoded.size()]));
+ }
+
+ /**
+ * Get an iterator over the sequence of strings.
+ *
+ * @return an iterator
+ */
+ public Iterator<String> iterator() {
+ return new Iterator<String>() {
+ int i;
+
+ public boolean hasNext() {
+ return i < segments.length;
+ }
+
+ public String next() {
+ try {
+ return segments[i++];
+ } catch (ArrayIndexOutOfBoundsException e) {
+ throw new NoSuchElementException("next() past end");
+ }
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove()");
+ }
+ };
+ }
+
+ /**
+ * Get the number of segments in this name.
+ *
+ * @return the number of segments
+ */
+ public int length() {
+ return segments.length;
+ }
+}
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/RemoteServiceConfiguration.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/RemoteServiceConfiguration.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/RemoteServiceConfiguration.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -26,6 +26,8 @@
/**
* A configuration for registering a remote service with an endpoint.
+ *
+ * @apiviz.exclude
*/
public final class RemoteServiceConfiguration {
private String serviceType;
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestCancelHandler.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestCancelHandler.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestCancelHandler.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -4,6 +4,8 @@
* A handler for request listeners to receive a notification when a request was cancelled.
*
* @param <O> the reply type
+ *
+ * @apiviz.exclude
*/
public interface RequestCancelHandler<O> {
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContext.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContext.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestContext.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -9,6 +9,8 @@
* specified in this interface.
*
* @param <O> the reply type
+ *
+ * @apiviz.exclude
*/
public interface RequestContext<O> extends Executor {
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestListener.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestListener.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/RequestListener.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -5,6 +5,8 @@
*
* @param <I> the request type
* @param <O> the reply type
+ *
+ * @apiviz.landmark
*/
public interface RequestListener<I, O> {
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceContext.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceContext.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceContext.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -5,6 +5,8 @@
/**
* The server-side context of a service. Used to hold state relating to a service (known as a {@code ContextSource} on
* the client side).
+ *
+ * @apiviz.exclude
*/
public interface ServiceContext extends HandleableCloseable<ServiceContext> {
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceListener.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -26,6 +26,8 @@
/**
* A listener for watching service registrations on an endpoint.
+ *
+ * @apiviz.landmark
*/
public interface ServiceListener {
@@ -39,6 +41,8 @@
/**
* Information about a registered service.
+ *
+ * @apiviz.exclude
*/
final class ServiceInfo {
private String endpointName;
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/ServiceURI.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -5,6 +5,8 @@
/**
* A parser for JBoss Remoting URI types.
+ *
+ * @apiviz.exclude
*/
public final class ServiceURI {
public static final String SCHEME = "jrs";
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/package-info.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/package-info.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/package-info.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -1,4 +1,6 @@
/**
* The base Remoting 3 API package.
+ *
+ * @apiviz.exclude org.jboss.remoting.transporter
*/
package org.jboss.remoting;
\ No newline at end of file
Modified: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/NamedServiceRegistry.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/NamedServiceRegistry.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/NamedServiceRegistry.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -30,6 +30,7 @@
import java.io.IOException;
import org.jboss.remoting.ServiceRegistrationException;
import org.jboss.remoting.CloseHandler;
+import org.jboss.remoting.QualifiedName;
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.log.Logger;
Deleted: remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/QualifiedName.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/QualifiedName.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/main/java/org/jboss/remoting/spi/QualifiedName.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -1,222 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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.remoting.spi;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.io.UnsupportedEncodingException;
-
-/**
- * A qualified name for service registration. A qualified name is a path-like structure comprised of a series of
- * zero or more name segments. The string representation of a qualified name is a sequence of a forward slash
- * ({@code /}) followed by a non-empty URL-encoded name segment.
- */
-public final class QualifiedName implements Comparable<QualifiedName>, Iterable<String> {
-
- /**
- * The root name.
- */
- public static final QualifiedName ROOT_NAME = new QualifiedName(new String[0]);
-
- private final String[] segments;
-
- /**
- * Create a new qualified name from the given name segments.
- *
- * @param nameSegments the name segments
- * @throws NullPointerException if {@code nameSegments} is {@code null} or if any element of that array is {@code null}
- * @throws IllegalArgumentException if an element of {@code nameSegments} is an empty string
- */
- public QualifiedName(final String[] nameSegments) throws NullPointerException, IllegalArgumentException {
- if (nameSegments == null) {
- throw new NullPointerException("segments is null");
- }
- String[] segments = nameSegments.clone();
- for (String s : segments) {
- if (s == null) {
- throw new NullPointerException("Null segment");
- }
- if (s.length() == 0) {
- throw new IllegalArgumentException("Empty segment");
- }
- }
- this.segments = segments;
- }
-
- /**
- * Compare this qualified name to another for equality. Returns {@code true} if both names have the same number of segments
- * with the same content.
- *
- * @param o the object to compare to
- * @return {@code true} if the given object is a qualified name which is equal to this name
- */
- public boolean equals(final Object o) {
- if (this == o) return true;
- if (! (o instanceof QualifiedName)) return false;
- final QualifiedName name = (QualifiedName) o;
- if (!Arrays.equals(segments, name.segments)) return false;
- return true;
- }
-
- /**
- * Get the hash code of this qualified name. Equal to the return value of {@link Arrays#hashCode(Object[]) Arrays.hashCode(segments)}
- * where {@code segments} is the array of decoded segment strings.
- *
- * @return the hash code
- */
- public int hashCode() {
- return Arrays.hashCode(segments);
- }
-
- /**
- * Compare this qualified name to another. Each segment is compared in turn; if they are equal then the comparison
- * carries on to the next segment. If all leading segments are equal but one qualified name has more segments,
- * then the longer name is said to come after the shorter name.
- *
- * @param o the other name
- * @return {@code 0} if the elements are equal, {@code -1} if this name comes before the given name, or {@code 1} if
- * this name comes after the given name
- */
- public int compareTo(final QualifiedName o) {
- if (this == o) return 0;
- String[] a = segments;
- String[] b = o.segments;
- final int alen = a.length;
- final int blen = b.length;
- for (int i = 0; i < alen && i < blen; i ++) {
- final int cmp = a[i].compareTo(b[i]);
- if (cmp != 0) {
- return cmp;
- }
- }
- if (alen < blen) {
- return -1;
- } else if (alen > blen) {
- return 1;
- } else {
- return 0;
- }
- }
-
- /**
- * Get the string representation of this qualified name. The root name is "{@code /}"; all other names are comprised
- * of one or more consecutive character sequences of a forward slash followed by one or more URL-encoded characters.
- *
- * @return the string representation of this name
- */
- public String toString() {
- StringBuilder builder = new StringBuilder();
- if (segments.length == 0) {
- return "/";
- } else for (String segment : segments) {
- try {
- builder.append('/');
- builder.append(URLEncoder.encode(segment, "utf-8"));
- } catch (UnsupportedEncodingException e) {
- // cannot happen
- throw new IllegalStateException(e);
- }
- }
- return builder.toString();
- }
-
- /**
- * Parse a qualified name. A qualified name must consist of either a single forward slash ("{@code /}") or else
- * a series of path components, each comprised of a single forward slash followed by a URL-encoded series of non-forward-slash
- * characters.
- *
- * @param path the path
- * @return the qualified name
- */
- public static QualifiedName parse(String path) {
- List<String> decoded = new ArrayList<String>();
- final int len = path.length();
- if (len < 1) {
- throw new IllegalArgumentException("Empty path");
- }
- if (path.charAt(0) != '/') {
- throw new IllegalArgumentException("Relative paths are not allowed");
- }
- if (len == 1) {
- return ROOT_NAME;
- }
- int segStart = 0;
- int segEnd;
- do {
- segEnd = path.indexOf('/', segStart + 1);
- String segment = segEnd == -1 ? path.substring(segStart + 1) : path.substring(segStart + 1, segEnd);
- if (segment.length() == 0) {
- throw new IllegalArgumentException(segEnd == -1 ? "Invalid trailing slash" : "Empty segment in path");
- }
- try {
- decoded.add(URLDecoder.decode(segment, "utf-8"));
- } catch (UnsupportedEncodingException e) {
- // cannot happen
- throw new IllegalStateException(e);
- }
- segStart = segEnd;
- } while (segEnd != -1);
- return new QualifiedName(decoded.toArray(new String[decoded.size()]));
- }
-
- /**
- * Get an iterator over the sequence of strings.
- *
- * @return an iterator
- */
- public Iterator<String> iterator() {
- return new Iterator<String>() {
- int i;
-
- public boolean hasNext() {
- return i < segments.length;
- }
-
- public String next() {
- try {
- return segments[i++];
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new NoSuchElementException("next() past end");
- }
- }
-
- public void remove() {
- throw new UnsupportedOperationException("remove()");
- }
- };
- }
-
- /**
- * Get the number of segments in this name.
- *
- * @return the number of segments
- */
- public int length() {
- return segments.length;
- }
-}
Modified: remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/NameTestCase.java
===================================================================
--- remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/NameTestCase.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/api/src/test/java/org/jboss/remoting/spi/NameTestCase.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -24,6 +24,7 @@
import junit.framework.TestCase;
import org.jboss.remoting.test.support.LoggingHelper;
+import org.jboss.remoting.QualifiedName;
import java.util.Iterator;
/**
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConnection.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConnection.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexConnection.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -37,7 +37,7 @@
import org.jboss.remoting.spi.NamedServiceRegistry;
import org.jboss.remoting.spi.SpiUtils;
import org.jboss.remoting.spi.AbstractHandleableCloseable;
-import org.jboss.remoting.spi.QualifiedName;
+import org.jboss.remoting.QualifiedName;
import org.jboss.remoting.Endpoint;
import org.jboss.remoting.IndeterminateOutcomeException;
import java.util.concurrent.Executor;
Modified: remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexReadHandler.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexReadHandler.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/protocol/multiplex/src/main/java/org/jboss/remoting/protocol/multiplex/MultiplexReadHandler.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -36,7 +36,7 @@
import org.jboss.remoting.ReplyException;
import org.jboss.remoting.RemoteExecutionException;
import org.jboss.remoting.ServiceRegistrationException;
-import org.jboss.remoting.spi.QualifiedName;
+import org.jboss.remoting.QualifiedName;
import org.jboss.marshalling.Unmarshaller;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.Marshaller;
Modified: remoting3/trunk/protocol/multiplex/src/test/java/org/jboss/remoting/protocol/multiplex/ConnectionTestCase.java
===================================================================
--- remoting3/trunk/protocol/multiplex/src/test/java/org/jboss/remoting/protocol/multiplex/ConnectionTestCase.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/protocol/multiplex/src/test/java/org/jboss/remoting/protocol/multiplex/ConnectionTestCase.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -41,7 +41,7 @@
import org.jboss.remoting.RemoteExecutionException;
import org.jboss.remoting.ClientSource;
import org.jboss.remoting.Client;
-import org.jboss.remoting.spi.QualifiedName;
+import org.jboss.remoting.QualifiedName;
import org.jboss.remoting.spi.NamedServiceRegistry;
import org.jboss.remoting.spi.RequestHandlerSource;
import org.jboss.remoting.spi.Handle;
Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexClientExample.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -26,11 +26,11 @@
import org.jboss.remoting.Remoting;
import org.jboss.remoting.ClientSource;
import org.jboss.remoting.Client;
+import org.jboss.remoting.QualifiedName;
import org.jboss.remoting.protocol.multiplex.MultiplexProtocol;
import org.jboss.remoting.protocol.multiplex.MultiplexConfiguration;
import org.jboss.remoting.protocol.multiplex.MultiplexConnection;
import org.jboss.remoting.spi.NamedServiceRegistry;
-import org.jboss.remoting.spi.QualifiedName;
import org.jboss.remoting.spi.RequestHandlerSource;
import org.jboss.remoting.spi.Handle;
import org.jboss.xnio.IoUtils;
Modified: remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java
===================================================================
--- remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/samples/src/main/java/org/jboss/remoting/samples/simple/MultiplexServerExample.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -30,7 +30,7 @@
import org.jboss.remoting.spi.RequestHandlerSource;
import org.jboss.remoting.spi.Handle;
import org.jboss.remoting.spi.NamedServiceRegistry;
-import org.jboss.remoting.spi.QualifiedName;
+import org.jboss.remoting.QualifiedName;
import org.jboss.xnio.IoUtils;
import org.jboss.xnio.Buffers;
import org.jboss.xnio.IoHandlerFactory;
Modified: remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java
===================================================================
--- remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java 2009-01-08 04:17:15 UTC (rev 4788)
+++ remoting3/trunk/standalone/src/main/java/org/jboss/remoting/Remoting.java 2009-01-08 22:36:45 UTC (rev 4789)
@@ -18,6 +18,8 @@
/**
* The standalone interface into Remoting. This class contains static methods that are useful to standalone programs
* for managing endpoints and services in a simple fashion.
+ *
+ * @apiviz.landmark
*/
public final class Remoting {
15 years, 10 months