JBoss Remoting SVN: r4048 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-23 20:31:58 -0400 (Wed, 23 Apr 2008)
New Revision: 4048
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/PortUtil.java
Log:
JBREM-966: Replaced SecureRandom with Random.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/PortUtil.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/PortUtil.java 2008-04-23 22:06:36 UTC (rev 4047)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/PortUtil.java 2008-04-24 00:31:58 UTC (rev 4048)
@@ -29,7 +29,8 @@
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.security.SecureRandom;
+import java.util.Random;
+
import org.jboss.logging.Logger;
/**
@@ -163,10 +164,8 @@
public static int getRandomStartingPort()
{
- int minPort = 2000;
- int maxPort = 65535;
- int count = maxPort - minPort + 1;
- int port = new SecureRandom().nextInt(count) + minPort;
+ int range = MAX_LEGAL_PORT - MIN_UNPRIVILEGED_PORT + 1;
+ int port = new Random(System.currentTimeMillis()).nextInt(range) + MIN_UNPRIVILEGED_PORT;
return port;
}
16 years, 9 months
JBoss Remoting SVN: r4047 - in remoting3/trunk: util/src/main/java/org/jboss/cx/remoting/util and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-04-23 18:06:36 -0400 (Wed, 23 Apr 2008)
New Revision: 4047
Modified:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/CompositeObjectResolver.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java
Log:
Fix resolver order
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/CompositeObjectResolver.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/CompositeObjectResolver.java 2008-04-23 17:13:47 UTC (rev 4046)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/CompositeObjectResolver.java 2008-04-23 22:06:36 UTC (rev 4047)
@@ -26,7 +26,7 @@
}
public Object readResolve(Object object) throws IOException {
- for (ObjectResolver resolver : resolvers) {
+ for (ObjectResolver resolver : CollectionUtil.reverse(resolvers)) {
object = resolver.readResolve(object);
}
return object;
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java 2008-04-23 17:13:47 UTC (rev 4046)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java 2008-04-23 22:06:36 UTC (rev 4047)
@@ -17,6 +17,7 @@
import java.util.Queue;
import java.util.Set;
import java.util.WeakHashMap;
+import java.util.ListIterator;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
@@ -565,4 +566,66 @@
}
}
+
+ public static <T> ListIterator<T> reverse(ListIterator<T> original) {
+ if (original instanceof ReverseListIterator) {
+ return ((ReverseListIterator<T>)original).original;
+ } else {
+ return new ReverseListIterator<T>(original);
+ }
+ }
+
+ public static <T> Iterable<T> reverse(final List<T> list) {
+ return new Iterable<T>() {
+ public Iterator<T> iterator() {
+ return reverse(list.listIterator());
+ }
+ };
+ }
+
+ private static final class ReverseListIterator<T> implements ListIterator<T> {
+
+ private final ListIterator<T> original;
+
+ private ReverseListIterator(final ListIterator<T> original) {
+ this.original = original;
+ }
+
+ public boolean hasNext() {
+ return original.hasPrevious();
+ }
+
+ public T next() {
+ return original.previous();
+ }
+
+ public boolean hasPrevious() {
+ return original.hasNext();
+ }
+
+ public T previous() {
+ return original.next();
+ }
+
+ public int nextIndex() {
+ return original.previousIndex();
+ }
+
+ public int previousIndex() {
+ return original.nextIndex();
+ }
+
+ public void remove() {
+ original.remove();
+ }
+
+ public void set(final T o) {
+ original.set(o);
+ }
+
+ public void add(final T o) {
+ original.add(o);
+ original.previous();
+ }
+ }
}
16 years, 9 months
JBoss Remoting SVN: r4046 - in remoting3/trunk: core/src/main/java/org/jboss/cx/remoting/core and 1 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-04-23 13:13:47 -0400 (Wed, 23 Apr 2008)
New Revision: 4046
Added:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/CompositeObjectResolver.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/ClientResolver.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/ClientSourceResolver.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationMarhsaller.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationMarshallerFactory.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationObjectMessageInput.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationObjectMessageOutput.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/StreamResolver.java
Modified:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/Marshaller.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/MarshallerFactory.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/ObjectResolver.java
Log:
Separated Marshaller implementation
Added: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/CompositeObjectResolver.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/CompositeObjectResolver.java (rev 0)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/CompositeObjectResolver.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -0,0 +1,34 @@
+package org.jboss.cx.remoting.spi.marshal;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Collections;
+import org.jboss.cx.remoting.util.CollectionUtil;
+
+/**
+ *
+ */
+public final class CompositeObjectResolver implements ObjectResolver {
+
+ private static final long serialVersionUID = -5506005026832413276L;
+
+ private final List<ObjectResolver> resolvers;
+
+ public CompositeObjectResolver(List<ObjectResolver> resolvers) {
+ this.resolvers = Collections.unmodifiableList(CollectionUtil.arrayList(resolvers));
+ }
+
+ public Object writeReplace(Object object) throws IOException {
+ for (ObjectResolver resolver : resolvers) {
+ object = resolver.writeReplace(object);
+ }
+ return object;
+ }
+
+ public Object readResolve(Object object) throws IOException {
+ for (ObjectResolver resolver : resolvers) {
+ object = resolver.readResolve(object);
+ }
+ return object;
+ }
+}
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/Marshaller.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/Marshaller.java 2008-04-23 04:09:14 UTC (rev 4045)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/Marshaller.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -2,20 +2,32 @@
import java.io.IOException;
import java.io.Serializable;
-import org.jboss.cx.remoting.util.DataMessageInput;
-import org.jboss.cx.remoting.util.DataMessageOutput;
import org.jboss.cx.remoting.util.ObjectMessageInput;
import org.jboss.cx.remoting.util.ObjectMessageOutput;
+import org.jboss.cx.remoting.util.ByteMessageOutput;
+import org.jboss.cx.remoting.util.ByteMessageInput;
/**
- *
+ * A marshaller/unmarshaller for transmitting data over a wire protocol of some sort. Each marshaller instance is
+ * guaranteed to be used by only one thread. Marshallers are not pooled or reused in any way.
*/
public interface Marshaller extends Serializable {
- ObjectMessageOutput getMessageOutput(DataMessageOutput dataMessageOutput) throws IOException;
- ObjectMessageInput getMessageInput(DataMessageInput dataMessageInput) throws IOException;
+ /**
+ * Get a message writer that marshals to the given stream.
+ *
+ * @param byteMessageOutput the target stream
+ * @return the message writer
+ * @throws IOException if an error occurs
+ */
+ ObjectMessageOutput getMessageOutput(ByteMessageOutput byteMessageOutput) throws IOException;
- void addFirstObjectResolver(ObjectResolver resolver);
-
- void addLastObjectResolver(ObjectResolver resolver);
+ /**
+ * Get a message reader that unmarshals from the given stream.
+ *
+ * @param byteMessageInput the source stream
+ * @return the message reader
+ * @throws IOException if an error occurs
+ */
+ ObjectMessageInput getMessageInput(ByteMessageInput byteMessageInput) throws IOException;
}
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/MarshallerFactory.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/MarshallerFactory.java 2008-04-23 04:09:14 UTC (rev 4045)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/MarshallerFactory.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -6,5 +6,5 @@
*
*/
public interface MarshallerFactory {
- Marshaller createRootMarshaller(ClassLoader classLoader) throws IOException;
+ Marshaller createRootMarshaller(ObjectResolver resolver, ClassLoader classLoader) throws IOException;
}
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/ObjectResolver.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/ObjectResolver.java 2008-04-23 04:09:14 UTC (rev 4045)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/marshal/ObjectResolver.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -4,10 +4,30 @@
import java.io.Serializable;
/**
- *
+ * A resolver for marshallers. Instances of this interface are used to dynamically substitute marker objects for
+ * objects that behave specially, such as streams. Instances of this interface are used by multiple threads and may
+ * be reused any number of times.
+ * <p/>
+ * All instances of this interface that are associated with a session will be called in sequence, each instance getting
+ * the return value of the previous instance.
*/
public interface ObjectResolver extends Serializable {
- Object readResolve(Object original) throws IOException;
+ /**
+ * Substitute a real object with an object for the stream.
+ *
+ * @param original the real object
+ * @return the object for the stream
+ * @throws IOException if an error occurs
+ */
Object writeReplace(Object original) throws IOException;
+
+ /**
+ * Substitute an object from the stream with the real object.
+ *
+ * @param original the object from the stream
+ * @return the real object
+ * @throws IOException if an error occurs
+ */
+ Object readResolve(Object original) throws IOException;
}
Added: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/ClientResolver.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/ClientResolver.java (rev 0)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/ClientResolver.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -0,0 +1,36 @@
+package org.jboss.cx.remoting.core.marshal;
+
+import java.io.IOException;
+import org.jboss.cx.remoting.core.AbstractRealClient;
+import org.jboss.cx.remoting.core.ClientMarker;
+import org.jboss.cx.remoting.spi.marshal.ObjectResolver;
+import org.jboss.cx.remoting.spi.protocol.ClientIdentifier;
+
+/**
+ *
+ */
+public final class ClientResolver implements ObjectResolver {
+
+ private static final long serialVersionUID = 7850552704308592325L;
+
+ public Object writeReplace(final Object original) throws IOException {
+ if (original instanceof AbstractRealClient) {
+ AbstractRealClient client = (AbstractRealClient) original;
+
+ return null;
+ } else {
+ return original;
+ }
+ }
+
+ public Object readResolve(final Object original) throws IOException {
+ if (original instanceof ClientMarker) {
+ ClientMarker clientMarker = (ClientMarker) original;
+ ClientIdentifier clientIdentifier = clientMarker.getClientIdentifer();
+
+ return null;
+ } else {
+ return original;
+ }
+ }
+}
Added: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/ClientSourceResolver.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/ClientSourceResolver.java (rev 0)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/ClientSourceResolver.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -0,0 +1,21 @@
+package org.jboss.cx.remoting.core.marshal;
+
+import java.io.IOException;
+import org.jboss.cx.remoting.spi.marshal.ObjectResolver;
+
+/**
+ *
+ */
+public final class ClientSourceResolver implements ObjectResolver {
+
+ private static final long serialVersionUID = 7850552704308592325L;
+
+ public Object writeReplace(final Object original) throws IOException {
+ return null;
+ }
+
+ public Object readResolve(final Object original) throws IOException {
+
+ return null;
+ }
+}
\ No newline at end of file
Added: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationMarhsaller.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationMarhsaller.java (rev 0)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationMarhsaller.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -0,0 +1,33 @@
+package org.jboss.cx.remoting.core.marshal;
+
+import java.io.IOException;
+import org.jboss.cx.remoting.spi.marshal.Marshaller;
+import org.jboss.cx.remoting.spi.marshal.ObjectResolver;
+import org.jboss.cx.remoting.util.ByteMessageInput;
+import org.jboss.cx.remoting.util.ByteMessageOutput;
+import org.jboss.cx.remoting.util.ObjectMessageInput;
+import org.jboss.cx.remoting.util.ObjectMessageOutput;
+
+/**
+ *
+ */
+public class JBossSerializationMarhsaller implements Marshaller {
+
+ private static final long serialVersionUID = -8197192536466706414L;
+
+ private final ObjectResolver resolver;
+ private final ClassLoader classLoader;
+
+ public JBossSerializationMarhsaller(final ObjectResolver resolver, final ClassLoader classLoader) {
+ this.resolver = resolver;
+ this.classLoader = classLoader;
+ }
+
+ public ObjectMessageOutput getMessageOutput(final ByteMessageOutput byteMessageOutput) throws IOException {
+ return new JBossSerializationObjectMessageOutput(resolver, byteMessageOutput);
+ }
+
+ public ObjectMessageInput getMessageInput(final ByteMessageInput byteMessageInput) throws IOException {
+ return new JBossSerializationObjectMessageInput(resolver, byteMessageInput, classLoader);
+ }
+}
Added: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationMarshallerFactory.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationMarshallerFactory.java (rev 0)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationMarshallerFactory.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -0,0 +1,16 @@
+package org.jboss.cx.remoting.core.marshal;
+
+import java.io.IOException;
+import org.jboss.cx.remoting.spi.marshal.Marshaller;
+import org.jboss.cx.remoting.spi.marshal.MarshallerFactory;
+import org.jboss.cx.remoting.spi.marshal.ObjectResolver;
+
+/**
+ *
+ */
+public class JBossSerializationMarshallerFactory implements MarshallerFactory {
+
+ public Marshaller createRootMarshaller(final ObjectResolver resolver, final ClassLoader classLoader) throws IOException {
+ return new JBossSerializationMarhsaller(resolver, classLoader);
+ }
+}
Added: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationObjectMessageInput.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationObjectMessageInput.java (rev 0)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationObjectMessageInput.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -0,0 +1,108 @@
+package org.jboss.cx.remoting.core.marshal;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectStreamClass;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+import org.jboss.cx.remoting.spi.marshal.ObjectResolver;
+import org.jboss.cx.remoting.util.ByteMessageInput;
+import org.jboss.cx.remoting.util.ObjectMessageInput;
+import org.jboss.serial.io.JBossObjectInputStream;
+
+/**
+ *
+ */
+public class JBossSerializationObjectMessageInput extends JBossObjectInputStream implements ObjectMessageInput {
+
+ private final ObjectResolver resolver;
+ private final ByteMessageInput dataMessageInput;
+
+ public JBossSerializationObjectMessageInput(final ObjectResolver resolver, final ByteMessageInput dataMessageInput, final ClassLoader classLoader) throws IOException {
+ super(new InputStream() {
+
+ public int read(final byte b[]) throws IOException {
+ return dataMessageInput.read(b);
+ }
+
+ public int read(final byte b[], final int off, final int len) throws IOException {
+ return dataMessageInput.read(b, off, len);
+ }
+
+ public int available() throws IOException {
+ return dataMessageInput.remaining();
+ }
+
+ public void close() throws IOException {
+ dataMessageInput.close();
+ }
+
+ public boolean markSupported() {
+ return false;
+ }
+
+ public int read() throws IOException {
+ return dataMessageInput.read();
+ }
+ }, classLoader);
+ if (resolver == null) {
+ throw new NullPointerException("resolver is null");
+ }
+ if (dataMessageInput == null) {
+ throw new NullPointerException("dataMessageInput is null");
+ }
+ if (classLoader == null) {
+ throw new NullPointerException("classLoader is null");
+ }
+ enableResolveObject(true);
+ this.resolver = resolver;
+ this.dataMessageInput = dataMessageInput;
+ }
+
+ public int remaining() {
+ return dataMessageInput.remaining();
+ }
+
+ protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
+ final String name = desc.getName();
+ ClassLoader classLoader = getClassLoader();
+ if (primitiveTypes.containsKey(name)) {
+ return primitiveTypes.get(name);
+ } else {
+ return Class.forName(name, false, classLoader);
+ }
+ }
+
+ protected Class<?> resolveProxyClass(final String[] interfaceNames) throws IOException, ClassNotFoundException {
+ final ClassLoader classLoader = getClassLoader();
+ final int length = interfaceNames.length;
+ final Class<?>[] interfaces = new Class[length];
+ for (int i = 0; i < length; i ++) {
+ interfaces[i] = Class.forName(interfaceNames[i], false, classLoader);
+ }
+ return Proxy.getProxyClass(classLoader, interfaces);
+ }
+
+ protected Object resolveObject(final Object obj) throws IOException {
+ return resolver.readResolve(obj);
+ }
+
+ private static final Map<String, Class<?>> primitiveTypes = new HashMap<String, Class<?>>();
+
+ private static <T> void add(Class<T> type) {
+ primitiveTypes.put(type.getName(), type);
+ }
+
+ static {
+ add(void.class);
+ add(boolean.class);
+ add(byte.class);
+ add(short.class);
+ add(int.class);
+ add(long.class);
+ add(float.class);
+ add(double.class);
+ add(char.class);
+ }
+}
Added: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationObjectMessageOutput.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationObjectMessageOutput.java (rev 0)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/JBossSerializationObjectMessageOutput.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -0,0 +1,58 @@
+package org.jboss.cx.remoting.core.marshal;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.jboss.cx.remoting.spi.marshal.ObjectResolver;
+import org.jboss.cx.remoting.util.ByteMessageOutput;
+import org.jboss.cx.remoting.util.ObjectMessageOutput;
+import org.jboss.serial.io.JBossObjectOutputStream;
+
+/**
+ *
+ */
+public class JBossSerializationObjectMessageOutput extends JBossObjectOutputStream implements ObjectMessageOutput {
+
+ private final ObjectResolver resolver;
+ private final ByteMessageOutput dataMessageOutput;
+
+ public JBossSerializationObjectMessageOutput(final ObjectResolver resolver, final ByteMessageOutput dataMessageOutput) throws IOException {
+ super(new OutputStream() {
+ public void write(final int b) throws IOException {
+ dataMessageOutput.write(b);
+ }
+
+ public void write(final byte b[]) throws IOException {
+ dataMessageOutput.write(b);
+ }
+
+ public void write(final byte b[], final int off, final int len) throws IOException {
+ dataMessageOutput.write(b, off, len);
+ }
+
+ public void flush() throws IOException {
+ dataMessageOutput.flush();
+ }
+
+ public void close() throws IOException {
+ dataMessageOutput.close();
+ }
+ });
+ enableReplaceObject(true);
+ this.resolver = resolver;
+ this.dataMessageOutput = dataMessageOutput;
+ }
+
+ public void commit() throws IOException {
+ flush();
+ dataMessageOutput.commit();
+ }
+
+ public int getBytesWritten() throws IOException {
+ flush();
+ return dataMessageOutput.getBytesWritten();
+ }
+
+ protected Object replaceObject(final Object obj) throws IOException {
+ return resolver.writeReplace(obj);
+ }
+}
Added: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/StreamResolver.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/StreamResolver.java (rev 0)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/marshal/StreamResolver.java 2008-04-23 17:13:47 UTC (rev 4046)
@@ -0,0 +1,39 @@
+package org.jboss.cx.remoting.core.marshal;
+
+import java.io.IOException;
+import java.util.concurrent.Executor;
+import org.jboss.cx.remoting.core.StreamMarker;
+import org.jboss.cx.remoting.core.util.OrderedExecutorFactory;
+import org.jboss.cx.remoting.spi.marshal.ObjectResolver;
+
+/**
+ *
+ */
+public final class StreamResolver implements ObjectResolver {
+
+ private static final long serialVersionUID = -5060456855964622071L;
+
+ private final Executor streamExecutor;
+
+ public StreamResolver(OrderedExecutorFactory factory) {
+ streamExecutor = factory.getOrderedExecutor();
+ }
+
+ public StreamResolver(final Executor streamExecutor) {
+ this.streamExecutor = streamExecutor;
+ }
+
+ public Object writeReplace(final Object original) throws IOException {
+ // todo - run thru stream detector(s)?
+ return null;
+ }
+
+ public Object readResolve(final Object original) throws IOException {
+ if (original instanceof StreamMarker) {
+ StreamMarker streamMarker = (StreamMarker) original;
+ return null;
+ } else {
+ return original;
+ }
+ }
+}
16 years, 9 months
JBoss Remoting SVN: r4045 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-23 00:09:14 -0400 (Wed, 23 Apr 2008)
New Revision: 4045
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestServer.java
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestCase.java
Log:
JBREM-930: Replaced HTTPInvokerTestServer with StressHTTPInvokerTestServer which gives coyote 1000 worker threads.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestCase.java 2008-04-23 03:01:27 UTC (rev 4044)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestCase.java 2008-04-23 04:09:14 UTC (rev 4045)
@@ -35,7 +35,7 @@
{
addTestClasses(StressHTTPInvokerTestClient.class.getName(),
1,
- HTTPInvokerTestServer.class.getName());
+ StressHTTPInvokerTestServer.class.getName());
}
protected Level getTestHarnessLogLevel()
@@ -45,7 +45,7 @@
protected Level getTestLogLevel()
{
- return Level.DEBUG;
+ return Level.INFO;
}
/**
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestServer.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestServer.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestServer.java 2008-04-23 04:09:14 UTC (rev 4045)
@@ -0,0 +1,54 @@
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.test.remoting.transport.http.keep_alive;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest;
+import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase;
+import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Apr 22, 2008
+ * </p>
+ */
+public class StressHTTPInvokerTestServer extends HTTPInvokerTestServer
+{
+ public void setUp() throws Exception
+ {
+ serverPort = 8888;
+ Map metadata = new HashMap();
+ String newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA);
+ if(newMetadata != null && newMetadata.length() > 0)
+ {
+ metadata.putAll(PerformanceServerTest.parseMetadataString(newMetadata));
+ }
+ metadata.put("maxProcessors", "1000");
+ init(metadata);
+ }
+}
+
16 years, 9 months
JBoss Remoting SVN: r4044 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-22 23:01:27 -0400 (Tue, 22 Apr 2008)
New Revision: 4044
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
Log:
JBREM-934: Removed unnecessary imports.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java 2008-04-23 02:59:30 UTC (rev 4043)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java 2008-04-23 03:01:27 UTC (rev 4044)
@@ -20,7 +20,6 @@
import org.jboss.remoting.marshal.serializable.SerializableMarshaller;
import org.jboss.util.propertyeditor.PropertyEditors;
-import java.beans.IntrospectionException;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
@@ -30,9 +29,6 @@
import java.net.Socket;
import java.net.InetSocketAddress;
import java.net.SocketException;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
16 years, 9 months
JBoss Remoting SVN: r4043 - remoting2/branches/2.x.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-22 22:59:30 -0400 (Tue, 22 Apr 2008)
New Revision: 4043
Modified:
remoting2/branches/2.x/build.xml
Log:
JBREM-920: Replaced if="isJDK5" with unless="isJDK4".
Modified: remoting2/branches/2.x/build.xml
===================================================================
--- remoting2/branches/2.x/build.xml 2008-04-23 01:42:10 UTC (rev 4042)
+++ remoting2/branches/2.x/build.xml 2008-04-23 02:59:30 UTC (rev 4043)
@@ -270,7 +270,7 @@
<path id="third_party.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
- <exclude name="apache-tomcat/*.jar" if="isJDK5"/>
+ <exclude name="apache-tomcat/*.jar" unless="isJDK4"/>
<exclude name="jbossweb/*.jar" if="isJDK4"/>
</fileset>
</path>
@@ -873,7 +873,7 @@
</target>
<!-- runs functional tests with jboss serialization if using jdk 1.5 -->
- <target name="tests.functional.serialization.jboss" if="isJDK5">
+ <target name="tests.functional.serialization.jboss" unless="isJDK4">
<antcall target="tests.functional.main" inheritrefs="true">
<param name="remoting.metadata.key" value="remoting.metadata"/>
<param name="metadata" value="serializationtype=jboss"/>
@@ -894,7 +894,7 @@
<antcall target="tests.functional.main.serialization.jboss" inheritrefs="true"/>
</target>
- <target name="tests.functional.serialization.jboss.core" if="isJDK5">
+ <target name="tests.functional.serialization.jboss.core" unless="isJDK4">
<antcall target="tests.functional.main.core" inheritrefs="true">
<param name="remoting.metadata.key" value="remoting.metadata"/>
<param name="metadata" value="serializationtype=jboss"/>
@@ -924,7 +924,7 @@
</antcall>
</target>
- <target name="tests.functional.serialization.jboss.http" if="isJDK5">
+ <target name="tests.functional.serialization.jboss.http" unless="isJDK4">
<antcall target="tests.functional.http.jbossweb">
<param name="serialization" value="jboss"/>
</antcall>
@@ -933,7 +933,7 @@
</antcall>
</target>
- <target name="tests.functional.http.jbossweb" if="isJDK5">
+ <target name="tests.functional.http.jbossweb" unless="isJDK4">
<antcall target="tests.functional.main.http" inheritrefs="true">
<param name="remoting.metadata.key" value="remoting.metadata"/>
<param name="metadata" value="serializationtype=${serialization}"/>
@@ -981,7 +981,7 @@
</antcall>
</target>
- <target name="tests.functional.serialization.jboss.http.core" if="isJDK5">
+ <target name="tests.functional.serialization.jboss.http.core" unless="isJDK4">
<antcall target="tests.functional.http.jbossweb.core" inheritrefs="true">
<param name="serialization" value="jboss"/>
</antcall>
@@ -990,7 +990,7 @@
</antcall>
</target>
- <target name="tests.functional.http.jbossweb.core" if="isJDK5">
+ <target name="tests.functional.http.jbossweb.core" unless="isJDK4">
<antcall target="tests.functional.main.http.core" inheritrefs="true">
<param name="remoting.metadata.key" value="remoting.metadata"/>
<param name="metadata" value="serializationtype=${serialization}"/>
@@ -1183,7 +1183,7 @@
</junit>
</target>
- <target name="tests.functional.main.isJDK5" depends="tests.jars" if="isJDK5">
+ <target name="tests.functional.main.isJDK5" depends="tests.jars" unless="isJDK4">
<mkdir dir="${output.tests.results}"/>
<mkdir dir="${output.tests.tmp}"/>
<junit printsummary="true" fork="yes" includeantruntime="true" tempdir="${output.tests.tmp}">
@@ -1214,7 +1214,7 @@
</junit>
</target>
- <target name="tests.functional.main.isJDK5.core" depends="tests.jars" if="isJDK5">
+ <target name="tests.functional.main.isJDK5.core" depends="tests.jars" unless="isJDK4">
<mkdir dir="${output.tests.results}"/>
<mkdir dir="${output.tests.tmp}"/>
<junit printsummary="true" fork="yes" includeantruntime="true" tempdir="${output.tests.tmp}">
@@ -1301,7 +1301,6 @@
<mkdir dir="${output.tests.results}"/>
<mkdir dir="${output.tests.tmp}"/>
<echo>http (strict security) with ${version}: ${metadata}</echo>
- <echo>ant.library.dir: ${ant.library.dir}</echo>
<junit
printsummary="true" fork="yes" includeantruntime="true"
tempdir="${output.tests.tmp}" maxmemory="1024m">
@@ -1487,7 +1486,7 @@
<param name="metadata" value="serializationtype=java"/>
</antcall>
</target>
- <target name="test.socket.serialization.jboss" if="isJDK5">
+ <target name="test.socket.serialization.jboss" unless="isJDK4">
<antcall target="tests.socket" inheritrefs="true">
<param name="metadata" value="serializationtype=jboss"/>
</antcall>
@@ -2477,7 +2476,7 @@
</target>
- <target name="tests.performance.serialization.jboss" depends="configure" if="isJDK5">
+ <target name="tests.performance.serialization.jboss" depends="configure" unless="isJDK4">
<antcall target="tests.performance.rmi" inheritrefs="true">
<param name="remoting.metadata.key" value="remoting.metadata"/>
@@ -2957,6 +2956,15 @@
<sysproperty key="jrunit.send_on_all_interfaces" value="${sendOnAllInterfaces}"/>
<sysproperty key="jrunit.send_interfaces" value="${sendInterfaces}"/>
<sysproperty key="jboss-junit-configuration" value="${jboss-junit-configuration}"/>
+ <sysproperty key="${java.security.manager.key}" value="${java.security.manager}"/>
+ <sysproperty key="java.security.policy" value="${java.security.policy}"/>
+ <sysproperty key="java.security.debug" value="${java.security.debug}"/>
+ <sysproperty key="build.home" value="${basedir}"/>
+ <sysproperty key="remoting.jar.dir" value="${basedir}/output/lib"/>
+ <sysproperty key="log4j.jar.dir" value="${basedir}/lib/apache-log4j/lib"/>
+ <sysproperty key="log4j.config.dir" value="${basedir}/src/etc"/>
+ <sysproperty key="ant.library.dir" value="${ant.library.dir}"/>
+
<formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
extension="-${jboss-junit-configuration}.xml"/>
<!-- <batchtest fork="yes" todir="${output.tests.performance}/${transport}/${numofclients}/${numofcalls}/${payloadsize}"-->
@@ -3358,7 +3366,7 @@
</antcall>
</target>
- <target name="tests.stress.serialization.jboss" depends="configure" if="isJDK5">
+ <target name="tests.stress.serialization.jboss" depends="configure" unless="isJDK4">
<antcall target="tests.stress.run" inheritrefs="true">
<param name="transport" value="rmi"/>
</antcall>
16 years, 9 months
JBoss Remoting SVN: r4042 - remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-04-22 21:42:10 -0400 (Tue, 22 Apr 2008)
New Revision: 4042
Modified:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ConcurrentReferenceHashMap.java
Log:
Merge in Jason's latest updates
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ConcurrentReferenceHashMap.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ConcurrentReferenceHashMap.java 2008-04-23 00:38:20 UTC (rev 4041)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ConcurrentReferenceHashMap.java 2008-04-23 01:42:10 UTC (rev 4042)
@@ -309,38 +309,31 @@
final int hash;
volatile Object valueRef;
final HashEntry<K,V> next;
- final ReferenceType keyType;
- final ReferenceType valueType;
HashEntry(K key, int hash, HashEntry<K,V> next, V value,
ReferenceType keyType, ReferenceType valueType,
ReferenceQueue<K> refQueue) {
- this.keyType = keyType;
- this.valueType = valueType;
- this.keyRef = newKeyReference(key, hash, refQueue);
+ this.keyRef = newKeyReference(key, keyType, hash, refQueue);
this.hash = hash;
this.next = next;
- this.valueRef = newValueReference(value);
+ this.valueRef = newValueReference(value, valueType);
}
- final Object newKeyReference(K key, int hash, ReferenceQueue<K> refQueue) {
- switch (keyType) {
- case WEAK:
- return new WeakKeyReference<K>(key, hash, refQueue);
- case SOFT:
- return new SoftKeyReference<K>(key, hash, refQueue);
- }
+ final Object newKeyReference(K key, ReferenceType keyType, int hash,
+ ReferenceQueue<K> refQueue) {
+ if (keyType == ReferenceType.WEAK)
+ return new WeakKeyReference<K>(key, hash, refQueue);
+ if (keyType == ReferenceType.SOFT)
+ return new SoftKeyReference<K>(key, hash, refQueue);
return key;
}
- final Object newValueReference(V value) {
- switch (valueType) {
- case WEAK:
- return new WeakReference<V>(value);
- case SOFT:
- return new SoftReference<V>(value);
- }
+ final Object newValueReference(V value, ReferenceType valueType) {
+ if (valueType == ReferenceType.WEAK)
+ return new WeakReference<V>(value);
+ if (valueType == ReferenceType.SOFT)
+ return new SoftReference<V>(value);
return value;
}
@@ -365,8 +358,8 @@
return (V) value;
}
- final void setValue(V value) {
- this.valueRef = newValueReference(value);
+ final void setValue(V value, ReferenceType valueType) {
+ this.valueRef = newValueReference(value, valueType);
}
@SuppressWarnings("unchecked")
@@ -588,7 +581,7 @@
boolean replaced = false;
if (e != null && oldValue.equals(e.value())) {
replaced = true;
- e.setValue(newValue);
+ e.setValue(newValue, valueType);
}
return replaced;
} finally {
@@ -607,7 +600,7 @@
V oldValue = null;
if (e != null) {
oldValue = e.value();
- e.setValue(newValue);
+ e.setValue(newValue, valueType);
}
return oldValue;
} finally {
@@ -638,7 +631,7 @@
if (e != null) {
oldValue = e.value();
if (!onlyIfAbsent)
- e.setValue(value);
+ e.setValue(value, valueType);
}
else {
oldValue = null;
16 years, 9 months
JBoss Remoting SVN: r4041 - remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-04-22 20:38:20 -0400 (Tue, 22 Apr 2008)
New Revision: 4041
Modified:
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppConnection.java
Log:
Do not close the connection if no read ping has arrived; this makes debugging impossible
Modified: remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppConnection.java
===================================================================
--- remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppConnection.java 2008-04-23 00:12:28 UTC (rev 4040)
+++ remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppConnection.java 2008-04-23 00:38:20 UTC (rev 4041)
@@ -697,9 +697,6 @@
final ObjectMessageOutput output = protocolContext.getMessageOutput(new IoBufferByteMessageOutput(buffer, ioSession));
write(output, MessageType.PING);
output.commit();
- } else if (idleStatus == IdleStatus.READER_IDLE) {
- // No message since last communication - close the connection.
- close();
}
}
16 years, 9 months
JBoss Remoting SVN: r4040 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/util.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-22 20:12:28 -0400 (Tue, 22 Apr 2008)
New Revision: 4040
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/util/PortUtilTestCase.java
Log:
JBREM-966: (1) Increased size of portArray[]; (2) fixed comparison with countToWait.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/util/PortUtilTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/util/PortUtilTestCase.java 2008-04-22 17:46:44 UTC (rev 4039)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/util/PortUtilTestCase.java 2008-04-23 00:12:28 UTC (rev 4040)
@@ -41,7 +41,7 @@
public void setUp()
{
- portArray = new byte[20000];
+ portArray = new byte[65536];
}
public void testFindingFreePorts()
@@ -83,7 +83,7 @@
{
countToWait.increment();
- if(countToWait.get() < maxWaitNumber)
+ if(countToWait.get() > maxWaitNumber)
{
break;
}
16 years, 9 months
JBoss Remoting SVN: r4039 - remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-04-22 13:46:44 -0400 (Tue, 22 Apr 2008)
New Revision: 4039
Modified:
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundRequest.java
Log:
Fix a bug where exceptions are not rethrown
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundRequest.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundRequest.java 2008-04-22 17:21:59 UTC (rev 4038)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundRequest.java 2008-04-22 17:46:44 UTC (rev 4039)
@@ -114,7 +114,7 @@
}
public void handleException(final RemoteExecutionException exception) {
- if (state.transitionExclusive(State.WAITING, State.DONE)) try {
+ if (state.transitionExclusive(State.WAITING, State.EXCEPTION)) try {
CoreOutboundRequest.this.exception = exception;
} finally {
state.releaseDowngrade();
@@ -216,8 +216,6 @@
throw exception;
case DONE:
return reply;
- case WAITING:
- return null;
case TERMINATED:
throw new IndeterminateOutcomeException("Request terminated abruptly; outcome unknown");
}
@@ -237,8 +235,6 @@
throw exception;
case DONE:
return reply;
- case WAITING:
- return null;
case TERMINATED:
throw new IndeterminateOutcomeException("Request terminated abruptly; outcome unknown");
}
16 years, 9 months