JBoss Remoting SVN: r3486 - remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-02-22 16:13:40 -0500 (Fri, 22 Feb 2008)
New Revision: 3486
Removed:
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointBean.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointDeployer.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointKernelDeployment.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointMetaData.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/ProtocolBean.java
remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/ServiceBean.java
Log:
Let's try again...
Deleted: remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointBean.java
===================================================================
--- remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointBean.java 2008-02-22 17:23:32 UTC (rev 3485)
+++ remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointBean.java 2008-02-22 21:13:40 UTC (rev 3486)
@@ -1,45 +0,0 @@
-package org.jboss.cx.remoting.deployer;
-
-import org.jboss.cx.remoting.Endpoint;
-import org.jboss.cx.remoting.spi.EndpointProvider;
-
-/**
- *
- */
-public final class EndpointBean {
- private EndpointProvider provider;
- private Endpoint endpoint;
- private String endpointName;
-
- public Endpoint getEndpoint() {
- return endpoint;
- }
-
- public EndpointProvider getProvider() {
- return provider;
- }
-
- public void setProvider(final EndpointProvider provider) {
- this.provider = provider;
- }
-
- public String getEndpointName() {
- return endpointName;
- }
-
- public void setEndpointName(final String endpointName) {
- this.endpointName = endpointName;
- }
-
- public void start() {
- endpoint = provider.createEndpoint(endpointName);
- }
-
- public void stop() {
- try {
- endpoint.shutdown();
- } finally {
- endpoint = null;
- }
- }
-}
Deleted: remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointDeployer.java
===================================================================
--- remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointDeployer.java 2008-02-22 17:23:32 UTC (rev 3485)
+++ remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointDeployer.java 2008-02-22 21:13:40 UTC (rev 3486)
@@ -1,32 +0,0 @@
-package org.jboss.cx.remoting.deployer;
-
-import org.jboss.cx.remoting.spi.EndpointProvider;
-import org.jboss.cx.remoting.log.Logger;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-
-/**
- * This is the real endpoint deployer. It takes an endpoint deployment and deployes it.
- */
-public final class EndpointDeployer extends AbstractSimpleRealDeployer<EndpointKernelDeployment> {
- private static final Logger log = Logger.getLogger(EndpointDeployer.class);
-
- private EndpointProvider provider;
-
- public EndpointDeployer() {
- super(EndpointKernelDeployment.class);
- }
-
- public EndpointProvider getProvider() {
- return provider;
- }
-
- public void setProvider(final EndpointProvider provider) {
- log.debug("Setting endpoint provider to %s", provider);
- this.provider = provider;
- }
-
- public void deploy(final DeploymentUnit deploymentUnit, final EndpointKernelDeployment kernelDeployment) throws DeploymentException {
- }
-}
Deleted: remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointKernelDeployment.java
===================================================================
--- remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointKernelDeployment.java 2008-02-22 17:23:32 UTC (rev 3485)
+++ remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointKernelDeployment.java 2008-02-22 21:13:40 UTC (rev 3486)
@@ -1,10 +0,0 @@
-package org.jboss.cx.remoting.deployer;
-
-import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
-import org.jboss.cx.remoting.Endpoint;
-
-/**
- *
- */
-public final class EndpointKernelDeployment extends AbstractKernelDeployment {
-}
Deleted: remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointMetaData.java
===================================================================
--- remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointMetaData.java 2008-02-22 17:23:32 UTC (rev 3485)
+++ remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/EndpointMetaData.java 2008-02-22 21:13:40 UTC (rev 3486)
@@ -1,16 +0,0 @@
-package org.jboss.cx.remoting.deployer;
-
-/**
- *
- */
-public final class EndpointMetaData {
- private String endpointName;
-
- public String getEndpointName() {
- return endpointName;
- }
-
- public void setEndpointName(final String endpointName) {
- this.endpointName = endpointName;
- }
-}
Deleted: remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/ProtocolBean.java
===================================================================
--- remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/ProtocolBean.java 2008-02-22 17:23:32 UTC (rev 3485)
+++ remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/ProtocolBean.java 2008-02-22 21:13:40 UTC (rev 3486)
@@ -1,43 +0,0 @@
-package org.jboss.cx.remoting.deployer;
-
-import org.jboss.cx.remoting.Endpoint;
-import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.spi.protocol.ProtocolRegistrationSpec;
-import org.jboss.cx.remoting.spi.protocol.ProtocolRegistration;
-
-/**
- *
- */
-public final class ProtocolBean {
- private Endpoint endpoint;
- private String scheme;
- private ProtocolRegistrationSpec registrationSpec;
- private ProtocolRegistration registration;
-
- public Endpoint getEndpoint() {
- return endpoint;
- }
-
- public void setEndpoint(final Endpoint endpoint) {
- this.endpoint = endpoint;
- }
-
- public void create() throws RemotingException {
- registrationSpec = ProtocolRegistrationSpec.DEFAULT
- .setScheme(scheme)
- .setProtocolHandlerFactory(null);
- registration = endpoint.registerProtocol(registrationSpec);
- }
-
- public void start() {
- registration.start();
- }
-
- public void stop() {
- registration.stop();
- }
-
- public void destroy() {
- registration.unregister();
- }
-}
Deleted: remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/ServiceBean.java
===================================================================
--- remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/ServiceBean.java 2008-02-22 17:23:32 UTC (rev 3485)
+++ remoting3/trunk/mc-deployers/src/main/java/org/jboss/cx/remoting/deployer/ServiceBean.java 2008-02-22 21:13:40 UTC (rev 3486)
@@ -1,90 +0,0 @@
-package org.jboss.cx.remoting.deployer;
-
-import org.jboss.cx.remoting.ServiceDeploymentSpec;
-import org.jboss.cx.remoting.RequestListener;
-import org.jboss.cx.remoting.Endpoint;
-import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.spi.Registration;
-
-/**
- *
- */
-public final class ServiceBean<I,O> {
- private Class<I> requestType;
- private Class<O> replyType;
- private String serviceGroupName;
- private String serviceType;
- private RequestListener<I,O> requestListener;
- private Endpoint endpoint;
- private Registration registration;
-
- public Class<I> getRequestType() {
- return requestType;
- }
-
- public void setRequestType(final Class<I> requestType) {
- this.requestType = requestType;
- }
-
- public Class<O> getReplyType() {
- return replyType;
- }
-
- public void setReplyType(final Class<O> replyType) {
- this.replyType = replyType;
- }
-
- public String getServiceGroupName() {
- return serviceGroupName;
- }
-
- public void setServiceGroupName(final String serviceGroupName) {
- this.serviceGroupName = serviceGroupName;
- }
-
- public String getServiceType() {
- return serviceType;
- }
-
- public void setServiceType(final String serviceType) {
- this.serviceType = serviceType;
- }
-
- public RequestListener<I, O> getRequestListener() {
- return requestListener;
- }
-
- public void setRequestListener(final RequestListener<I, O> requestListener) {
- this.requestListener = requestListener;
- }
-
- public Endpoint getEndpoint() {
- return endpoint;
- }
-
- public void setEndpoint(final Endpoint endpoint) {
- this.endpoint = endpoint;
- }
-
- public void create() throws RemotingException {
- final ServiceDeploymentSpec<?, ?> deploymentSpec = ServiceDeploymentSpec.DEFAULT
- .setRequestType(requestType)
- .setReplyType(replyType)
- .setServiceGroupName(serviceGroupName)
- .setServiceType(serviceType)
- .setRequestListener(requestListener);
- registration = endpoint.deployService(deploymentSpec);
- }
-
- public void start() {
- registration.start();
- }
-
- public void stop() {
- registration.stop();
- }
-
- public void destroy() {
- registration.unregister();
- }
-}
16 years, 9 months
JBoss Remoting SVN: r3485 - remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-02-22 12:23:32 -0500 (Fri, 22 Feb 2008)
New Revision: 3485
Modified:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java
Log:
javadoc cleanup
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java 2008-02-22 16:58:26 UTC (rev 3484)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java 2008-02-22 17:23:32 UTC (rev 3485)
@@ -37,14 +37,37 @@
* the protocol handler on the remote side.
*
* @param remoteServiceIdentifier the remote service identifier
- * @throws IOException if an error occurs
+ * @throws IOException if an I/O error occurs
*/
void sendServiceActivate(ServiceIdentifier remoteServiceIdentifier) throws IOException;
+ /**
+ * Send the reply to a request.
+ *
+ * @param remoteContextIdentifier the context that the request was received under
+ * @param requestIdentifier the request identifier
+ * @param reply the reply to send
+ * @throws IOException if an I/O error occurs
+ */
void sendReply(ContextIdentifier remoteContextIdentifier, RequestIdentifier requestIdentifier, Object reply) throws IOException;
+ /**
+ * Send an exception reply to a request.
+ *
+ * @param remoteContextIdentifier the context that the request was received under
+ * @param requestIdentifier the request identifier
+ * @param exception the exception to send
+ * @throws IOException if an I/O error occurs
+ */
void sendException(ContextIdentifier remoteContextIdentifier, RequestIdentifier requestIdentifier, RemoteExecutionException exception) throws IOException;
+ /**
+ * Send a notification to the client that a request was cancelled.
+ *
+ * @param remoteContextIdentifier the context that the request was received under
+ * @param requestIdentifier the request identifier
+ * @throws IOException if an I/O error occurs
+ */
void sendCancelAcknowledge(ContextIdentifier remoteContextIdentifier, RequestIdentifier requestIdentifier) throws IOException;
/**
@@ -52,7 +75,7 @@
* if it is undeployed, the session is being shut down, or if the activation request was not accepted.
*
* @param remoteServiceIdentifier the remote service identifier
- * @throws IOException if an error occurs
+ * @throws IOException if an I/O error occurs
*/
void sendServiceTerminate(ServiceIdentifier remoteServiceIdentifier) throws IOException;
@@ -66,7 +89,7 @@
*
* @param serviceIdentifier the service identifier
* @return a context identifier associated with the given service identifier
- * @throws IOException if an error occurs
+ * @throws IOException if an I/O error occurs
*/
ContextIdentifier openContext(ServiceIdentifier serviceIdentifier) throws IOException;
@@ -76,17 +99,24 @@
* on the remote side for this context identifier.
*
* @param contextIdentifier
- * @throws IOException
+ * @throws IOException if an I/O error occurs
*/
void closeContext(ContextIdentifier contextIdentifier) throws IOException;
+ /**
+ * Acquire a new request identifier that will be used to send a request.
+ *
+ * @param contextIdentifier the context identifier
+ * @return the new request identifier
+ * @throws IOException if an I/O error occurs
+ */
RequestIdentifier openRequest(ContextIdentifier contextIdentifier) throws IOException;
/**
* Get a new service identifier that will be used to request a service from the remote side.
*
* @return the new service identifier
- * @throws IOException
+ * @throws IOException if an I/O error occurs
*/
ServiceIdentifier openService() throws IOException;
@@ -96,14 +126,37 @@
*
* @param serviceIdentifier the service identifier
* @param locator the locator for the new service
- * @throws IOException if an error occurs
+ * @throws IOException if an I/O error occurs
*/
void sendServiceRequest(ServiceIdentifier serviceIdentifier, ServiceLocator<?, ?> locator) throws IOException;
+ /**
+ * Send a notification that the client is no longer using the given service.
+ *
+ * @param serviceIdentifier the service identifier
+ * @throws IOException if an I/O error occurs
+ */
void closeService(ServiceIdentifier serviceIdentifier) throws IOException;
+ /**
+ * Send a request to the remote side.
+ *
+ * @param contextIdentifier the context identifier
+ * @param requestIdentifier the request identifier
+ * @param request the request body
+ * @param streamExecutor the executor to use for stream callbacks
+ * @throws IOException if an I/O error occurs
+ */
void sendRequest(ContextIdentifier contextIdentifier, RequestIdentifier requestIdentifier, Object request, Executor streamExecutor) throws IOException;
+ /**
+ * Send a request to cancel a previously sent request.
+ *
+ * @param contextIdentifier the context identifier
+ * @param requestIdentifier the request identifier to cancel
+ * @param mayInterrupt {@code true} if processing may be interrupted
+ * @throws IOException if an I/O error occurs
+ */
void sendCancelRequest(ContextIdentifier contextIdentifier, RequestIdentifier requestIdentifier, boolean mayInterrupt) throws IOException;
/* SESSION methods */
@@ -114,7 +167,7 @@
* the same time.
*
* @return the identifier of a stream
- * @throws IOException
+ * @throws IOException if an I/O error occurs
*/
StreamIdentifier openStream() throws IOException;
@@ -124,7 +177,7 @@
* be released and possibly reused.
*
* @param streamIdentifier
- * @throws IOException
+ * @throws IOException if an I/O error occurs
*/
void closeStream(StreamIdentifier streamIdentifier) throws IOException;
@@ -133,10 +186,17 @@
*
* @param input
* @return the new stream identifier
- * @throws IOException
+ * @throws IOException if an I/O error occurs
*/
StreamIdentifier readStreamIdentifier(ObjectInput input) throws IOException;
+ /**
+ * Write a stream identifier to an object output stream.
+ *
+ * @param output the output to write to
+ * @param identifier the identifier to write
+ * @throws IOException if an I/O error occurs
+ */
void writeStreamIdentifier(ObjectOutput output, StreamIdentifier identifier) throws IOException;
/**
@@ -150,14 +210,14 @@
* @param streamExecutor the executor that should be used to handle stream data
* @return a message buffer into which the message can be written
*
- * @throws IOException if an error occurs
+ * @throws IOException if an I/O error occurs
*/
MessageOutput sendStreamData(StreamIdentifier streamIdentifier, Executor streamExecutor) throws IOException;
/**
* Close the session.
*
- * @throws IOException
+ * @throws IOException if an I/O error occurs
*/
void closeSession() throws IOException;
16 years, 9 months
JBoss Remoting SVN: r3484 - remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-02-22 11:58:26 -0500 (Fri, 22 Feb 2008)
New Revision: 3484
Modified:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java
Log:
Fix javadoc warnings
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java 2008-02-22 16:55:56 UTC (rev 3483)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java 2008-02-22 16:58:26 UTC (rev 3484)
@@ -85,7 +85,7 @@
/**
* Get a new service identifier that will be used to request a service from the remote side.
*
- * @return
+ * @return the new service identifier
* @throws IOException
*/
ServiceIdentifier openService() throws IOException;
@@ -132,7 +132,7 @@
* Read a stream identifier from a message.
*
* @param input
- * @return
+ * @return the new stream identifier
* @throws IOException
*/
StreamIdentifier readStreamIdentifier(ObjectInput input) throws IOException;
16 years, 9 months
JBoss Remoting SVN: r3483 - in remoting3/trunk: api/src/main/java/org/jboss/cx/remoting/spi/protocol and 14 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-02-22 11:55:56 -0500 (Fri, 22 Feb 2008)
New Revision: 3483
Added:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AbstractTypeMap.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicMap.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicStateMachine.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeHashMap.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeKey.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeMap.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/Base64DecodingException.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteInput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteOutput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DelegateIterable.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/HashTypeMap.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/IoUtil.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/LinkedHashTypeMap.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/MessageInput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/MessageOutput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceURI.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedCollection.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedIterator.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedMap.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedQueue.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedSet.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/TypeMap.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/UnmodifiableArrayList.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/WeakHashSet.java
Removed:
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/
Modified:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/CommonKeys.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceDeploymentSpec.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolContext.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandlerFactory.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/stream/StreamContext.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/stream/StreamSerializer.java
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/EndpointWrapper.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpoint.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpointProvider.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundContext.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundRequest.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundContext.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundRequest.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundService.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreSession.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreStream.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalProtocol.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/InputStreamStreamSerializerFactory.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/IteratorStreamSerializerFactory.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSinkStreamSerializerFactory.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSourceStreamSerializerFactory.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/OutputStreamStreamSerailizerFactory.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ProgressStreamStreamSerializerFactory.java
remoting3/trunk/http-se6/src/main/java/org/jboss/cx/remoting/http/se6/ServerInstance.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/HttpProtocolSupport.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpSessionImpl.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/AbstractHttpMessage.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/AbstractOutgoingHttpMessage.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/IncomingHttpMessage.java
remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/OutgoingHttpMessage.java
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppConnection.java
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppProtocolSupport.java
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppServer.java
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/id/JrppRequestIdentifier.java
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/id/JrppServiceIdentifier.java
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/mina/IoBufferByteInput.java
remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/mina/IoBufferByteOutput.java
remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/AbstractSrpSaslParticipant.java
remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpSaslClientImpl.java
remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpSaslServerImpl.java
remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpVerifier.java
remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java
Log:
Move classes from org.jboss.cx.remoting.core.util -> org.jboss.cx.remoting.util
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/CommonKeys.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/CommonKeys.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/CommonKeys.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -3,8 +3,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.jboss.cx.remoting.core.util.AttributeKey;
-import static org.jboss.cx.remoting.core.util.AttributeKey.key;
+import org.jboss.cx.remoting.util.AttributeKey;
+import static org.jboss.cx.remoting.util.AttributeKey.key;
import javax.security.auth.callback.CallbackHandler;
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/Endpoint.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -2,7 +2,7 @@
import java.net.URI;
import java.util.concurrent.ConcurrentMap;
-import org.jboss.cx.remoting.core.util.AttributeMap;
+import org.jboss.cx.remoting.util.AttributeMap;
import org.jboss.cx.remoting.spi.Discovery;
import org.jboss.cx.remoting.spi.Registration;
import org.jboss.cx.remoting.spi.protocol.ProtocolRegistration;
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceDeploymentSpec.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceDeploymentSpec.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/ServiceDeploymentSpec.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -2,7 +2,7 @@
import java.util.Collections;
import java.util.List;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
+import org.jboss.cx.remoting.util.CollectionUtil;
import org.jboss.cx.remoting.spi.InterceptorSpec;
/**
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolContext.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolContext.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolContext.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -4,10 +4,10 @@
import java.util.concurrent.Executor;
import org.jboss.cx.remoting.RemoteExecutionException;
import org.jboss.cx.remoting.ServiceLocator;
-import org.jboss.cx.remoting.core.util.ByteInput;
-import org.jboss.cx.remoting.core.util.ByteOutput;
-import org.jboss.cx.remoting.core.util.MessageInput;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.ByteInput;
+import org.jboss.cx.remoting.util.ByteOutput;
+import org.jboss.cx.remoting.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageOutput;
/**
*
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandler.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -6,7 +6,7 @@
import java.util.concurrent.Executor;
import org.jboss.cx.remoting.RemoteExecutionException;
import org.jboss.cx.remoting.ServiceLocator;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.MessageOutput;
/**
* A protocol handler.
@@ -141,9 +141,9 @@
/**
* Send data over a stream. Returns a message output buffer that the message is written into. When the message
- * is fully written, the {@link org.jboss.cx.remoting.core.util.MessageOutput#commit()} method will be called to perform the transmission. The
+ * is fully written, the {@link org.jboss.cx.remoting.util.MessageOutput#commit()} method will be called to perform the transmission. The
* supplied executor should be passed in to
- * {@link org.jboss.cx.remoting.spi.protocol.ProtocolContext#getMessageOutput(org.jboss.cx.remoting.core.util.ByteOutput, java.util.concurrent.Executor)},
+ * {@link org.jboss.cx.remoting.spi.protocol.ProtocolContext#getMessageOutput(org.jboss.cx.remoting.util.ByteOutput, java.util.concurrent.Executor)},
* if that method is used for serialization.
*
* @param streamIdentifier the stream to send data on
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandlerFactory.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandlerFactory.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/protocol/ProtocolHandlerFactory.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -2,7 +2,7 @@
import java.io.IOException;
import java.net.URI;
-import org.jboss.cx.remoting.core.util.AttributeMap;
+import org.jboss.cx.remoting.util.AttributeMap;
/**
*
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/stream/StreamContext.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/stream/StreamContext.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/stream/StreamContext.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -2,7 +2,7 @@
import java.io.Closeable;
import java.io.IOException;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.MessageOutput;
/**
*
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/stream/StreamSerializer.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/stream/StreamSerializer.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/stream/StreamSerializer.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -1,7 +1,7 @@
package org.jboss.cx.remoting.spi.stream;
import java.io.IOException;
-import org.jboss.cx.remoting.core.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageInput;
/**
*
Modified: remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/EndpointWrapper.java
===================================================================
--- remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/EndpointWrapper.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/spi/wrapper/EndpointWrapper.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -8,7 +8,7 @@
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.ServiceDeploymentSpec;
import org.jboss.cx.remoting.Session;
-import org.jboss.cx.remoting.core.util.AttributeMap;
+import org.jboss.cx.remoting.util.AttributeMap;
import org.jboss.cx.remoting.spi.Discovery;
import org.jboss.cx.remoting.spi.Registration;
import org.jboss.cx.remoting.spi.protocol.ProtocolRegistration;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpoint.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpoint.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpoint.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -19,11 +19,11 @@
import org.jboss.cx.remoting.ServiceDeploymentSpec;
import org.jboss.cx.remoting.ServiceLocator;
import org.jboss.cx.remoting.Session;
+import org.jboss.cx.remoting.util.CollectionUtil;
import org.jboss.cx.remoting.version.Version;
import org.jboss.cx.remoting.log.Logger;
-import org.jboss.cx.remoting.core.util.AtomicStateMachine;
-import org.jboss.cx.remoting.core.util.AttributeMap;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
+import org.jboss.cx.remoting.util.AtomicStateMachine;
+import org.jboss.cx.remoting.util.AttributeMap;
import org.jboss.cx.remoting.spi.Discovery;
import org.jboss.cx.remoting.spi.Registration;
import org.jboss.cx.remoting.spi.protocol.ProtocolContext;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpointProvider.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpointProvider.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreEndpointProvider.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -4,7 +4,7 @@
import java.util.Set;
import org.jboss.cx.remoting.Endpoint;
import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
+import org.jboss.cx.remoting.util.CollectionUtil;
import org.jboss.cx.remoting.spi.EndpointProvider;
/**
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundContext.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundContext.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundContext.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -5,7 +5,7 @@
import org.jboss.cx.remoting.RemoteExecutionException;
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.RequestListener;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
+import org.jboss.cx.remoting.util.CollectionUtil;
import org.jboss.cx.remoting.spi.ServerInterceptorFactory;
import org.jboss.cx.remoting.spi.protocol.ContextIdentifier;
import org.jboss.cx.remoting.spi.protocol.RequestIdentifier;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundRequest.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundRequest.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreInboundRequest.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -5,7 +5,7 @@
import org.jboss.cx.remoting.RequestCancelHandler;
import org.jboss.cx.remoting.RequestContext;
import org.jboss.cx.remoting.RequestListener;
-import org.jboss.cx.remoting.core.util.AtomicStateMachine;
+import org.jboss.cx.remoting.util.AtomicStateMachine;
import org.jboss.cx.remoting.log.Logger;
import org.jboss.cx.remoting.spi.protocol.RequestIdentifier;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundContext.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundContext.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundContext.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -7,8 +7,8 @@
import org.jboss.cx.remoting.RemoteExecutionException;
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.RequestCompletionHandler;
-import org.jboss.cx.remoting.core.util.AtomicStateMachine;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
+import org.jboss.cx.remoting.util.AtomicStateMachine;
+import org.jboss.cx.remoting.util.CollectionUtil;
import org.jboss.cx.remoting.log.Logger;
import org.jboss.cx.remoting.spi.protocol.ContextIdentifier;
import org.jboss.cx.remoting.spi.protocol.RequestIdentifier;
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-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundRequest.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -10,7 +10,7 @@
import org.jboss.cx.remoting.IndeterminateOutcomeException;
import org.jboss.cx.remoting.RemoteExecutionException;
import org.jboss.cx.remoting.RequestCompletionHandler;
-import org.jboss.cx.remoting.core.util.AtomicStateMachine;
+import org.jboss.cx.remoting.util.AtomicStateMachine;
import org.jboss.cx.remoting.log.Logger;
import org.jboss.cx.remoting.spi.protocol.RequestIdentifier;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundService.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundService.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreOutboundService.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -5,8 +5,8 @@
import org.jboss.cx.remoting.ContextSource;
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.ServiceLocator;
-import org.jboss.cx.remoting.core.util.AtomicStateMachine;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
+import org.jboss.cx.remoting.util.AtomicStateMachine;
+import org.jboss.cx.remoting.util.CollectionUtil;
import org.jboss.cx.remoting.log.Logger;
import org.jboss.cx.remoting.spi.ClientInterceptorFactory;
import org.jboss.cx.remoting.spi.protocol.ServiceIdentifier;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreSession.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreSession.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreSession.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -21,13 +21,13 @@
import org.jboss.cx.remoting.ServiceLocator;
import org.jboss.cx.remoting.Session;
import org.jboss.cx.remoting.core.stream.DefaultStreamDetector;
-import org.jboss.cx.remoting.core.util.AtomicStateMachine;
-import org.jboss.cx.remoting.core.util.AttributeMap;
-import org.jboss.cx.remoting.core.util.ByteInput;
-import org.jboss.cx.remoting.core.util.ByteOutput;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
-import org.jboss.cx.remoting.core.util.MessageInput;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.AtomicStateMachine;
+import org.jboss.cx.remoting.util.AttributeMap;
+import org.jboss.cx.remoting.util.ByteInput;
+import org.jboss.cx.remoting.util.ByteOutput;
+import org.jboss.cx.remoting.util.CollectionUtil;
+import org.jboss.cx.remoting.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageOutput;
import org.jboss.cx.remoting.log.Logger;
import org.jboss.cx.remoting.spi.protocol.ContextIdentifier;
import org.jboss.cx.remoting.spi.protocol.ProtocolContext;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreStream.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreStream.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/CoreStream.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -2,8 +2,8 @@
import java.io.IOException;
import java.util.concurrent.Executor;
-import org.jboss.cx.remoting.core.util.MessageInput;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageOutput;
import org.jboss.cx.remoting.log.Logger;
import org.jboss.cx.remoting.spi.protocol.ProtocolHandler;
import org.jboss.cx.remoting.spi.protocol.StreamIdentifier;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalProtocol.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalProtocol.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/LocalProtocol.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -10,10 +10,10 @@
import org.jboss.cx.remoting.RemoteExecutionException;
import org.jboss.cx.remoting.RemotingException;
import org.jboss.cx.remoting.ServiceLocator;
-import org.jboss.cx.remoting.core.util.AttributeMap;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
-import org.jboss.cx.remoting.core.util.MessageInput;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.MessageOutput;
+import org.jboss.cx.remoting.util.AttributeMap;
+import org.jboss.cx.remoting.util.CollectionUtil;
+import org.jboss.cx.remoting.util.MessageInput;
import org.jboss.cx.remoting.log.Logger;
import org.jboss.cx.remoting.spi.protocol.ContextIdentifier;
import org.jboss.cx.remoting.spi.protocol.ProtocolContext;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/InputStreamStreamSerializerFactory.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/InputStreamStreamSerializerFactory.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/InputStreamStreamSerializerFactory.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -3,8 +3,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
-import org.jboss.cx.remoting.core.util.MessageInput;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageOutput;
import org.jboss.cx.remoting.log.Logger;
import org.jboss.cx.remoting.spi.stream.RemoteStreamSerializer;
import org.jboss.cx.remoting.spi.stream.StreamContext;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/IteratorStreamSerializerFactory.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/IteratorStreamSerializerFactory.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/IteratorStreamSerializerFactory.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -2,7 +2,7 @@
import java.io.IOException;
import java.util.Iterator;
-import org.jboss.cx.remoting.core.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageInput;
import org.jboss.cx.remoting.spi.stream.RemoteStreamSerializer;
import org.jboss.cx.remoting.spi.stream.StreamContext;
import org.jboss.cx.remoting.spi.stream.StreamSerializer;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSinkStreamSerializerFactory.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSinkStreamSerializerFactory.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSinkStreamSerializerFactory.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -1,8 +1,8 @@
package org.jboss.cx.remoting.core.stream;
import java.io.IOException;
-import org.jboss.cx.remoting.core.util.MessageInput;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageOutput;
import org.jboss.cx.remoting.spi.stream.RemoteStreamSerializer;
import org.jboss.cx.remoting.spi.stream.StreamContext;
import org.jboss.cx.remoting.spi.stream.StreamSerializer;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSourceStreamSerializerFactory.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSourceStreamSerializerFactory.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ObjectSourceStreamSerializerFactory.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -4,8 +4,8 @@
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Queue;
-import org.jboss.cx.remoting.core.util.MessageInput;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageOutput;
import org.jboss.cx.remoting.spi.stream.RemoteStreamSerializer;
import org.jboss.cx.remoting.spi.stream.StreamContext;
import org.jboss.cx.remoting.spi.stream.StreamSerializer;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/OutputStreamStreamSerailizerFactory.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/OutputStreamStreamSerailizerFactory.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/OutputStreamStreamSerailizerFactory.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -2,8 +2,8 @@
import java.io.IOException;
import java.io.OutputStream;
-import org.jboss.cx.remoting.core.util.MessageInput;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageOutput;
import org.jboss.cx.remoting.spi.stream.RemoteStreamSerializer;
import org.jboss.cx.remoting.spi.stream.StreamContext;
import org.jboss.cx.remoting.spi.stream.StreamSerializer;
Modified: remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ProgressStreamStreamSerializerFactory.java
===================================================================
--- remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ProgressStreamStreamSerializerFactory.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/stream/ProgressStreamStreamSerializerFactory.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -1,8 +1,8 @@
package org.jboss.cx.remoting.core.stream;
import java.io.IOException;
-import org.jboss.cx.remoting.core.util.MessageInput;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageOutput;
import org.jboss.cx.remoting.spi.stream.RemoteStreamSerializer;
import org.jboss.cx.remoting.spi.stream.StreamContext;
import org.jboss.cx.remoting.spi.stream.StreamSerializer;
Modified: remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/HttpProtocolSupport.java
===================================================================
--- remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/HttpProtocolSupport.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/HttpProtocolSupport.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -6,8 +6,8 @@
import java.util.Random;
import org.jboss.cx.remoting.Endpoint;
import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
-import org.jboss.cx.remoting.core.util.AttributeMap;
+import org.jboss.cx.remoting.util.CollectionUtil;
+import org.jboss.cx.remoting.util.AttributeMap;
import org.jboss.cx.remoting.http.spi.RemotingHttpServerContext;
import org.jboss.cx.remoting.http.spi.RemotingHttpSessionContext;
import org.jboss.cx.remoting.http.spi.HttpTransporter;
Modified: remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpSessionImpl.java
===================================================================
--- remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpSessionImpl.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/RemotingHttpSessionImpl.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -5,9 +5,9 @@
import org.jboss.cx.remoting.http.spi.ReadyNotifier;
import org.jboss.cx.remoting.http.spi.OutgoingHttpMessage;
import org.jboss.cx.remoting.http.spi.AbstractOutgoingHttpMessage;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
-import org.jboss.cx.remoting.core.util.MessageOutput;
-import org.jboss.cx.remoting.core.util.ByteOutput;
+import org.jboss.cx.remoting.util.CollectionUtil;
+import org.jboss.cx.remoting.util.MessageOutput;
+import org.jboss.cx.remoting.util.ByteOutput;
import org.jboss.cx.remoting.spi.protocol.ProtocolContext;
import org.jboss.cx.remoting.spi.protocol.ProtocolHandler;
import org.jboss.cx.remoting.spi.protocol.ServiceIdentifier;
Modified: remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/AbstractHttpMessage.java
===================================================================
--- remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/AbstractHttpMessage.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/AbstractHttpMessage.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -3,7 +3,7 @@
import java.util.List;
import java.util.Map;
import java.util.Collections;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
+import org.jboss.cx.remoting.util.CollectionUtil;
/**
*
Modified: remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/AbstractOutgoingHttpMessage.java
===================================================================
--- remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/AbstractOutgoingHttpMessage.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/AbstractOutgoingHttpMessage.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -1,11 +1,5 @@
package org.jboss.cx.remoting.http.spi;
-import org.jboss.cx.remoting.core.util.ByteOutput;
-import java.io.IOException;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
/**
*
*/
Modified: remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/IncomingHttpMessage.java
===================================================================
--- remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/IncomingHttpMessage.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/IncomingHttpMessage.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -2,7 +2,7 @@
import java.io.IOException;
import java.net.InetAddress;
-import org.jboss.cx.remoting.core.util.ByteInput;
+import org.jboss.cx.remoting.util.ByteInput;
/**
*
Modified: remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/OutgoingHttpMessage.java
===================================================================
--- remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/OutgoingHttpMessage.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/http/src/main/java/org/jboss/cx/remoting/http/spi/OutgoingHttpMessage.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -1,7 +1,7 @@
package org.jboss.cx.remoting.http.spi;
import java.io.IOException;
-import org.jboss.cx.remoting.core.util.ByteOutput;
+import org.jboss.cx.remoting.util.ByteOutput;
/**
*
Modified: remoting3/trunk/http-se6/src/main/java/org/jboss/cx/remoting/http/se6/ServerInstance.java
===================================================================
--- remoting3/trunk/http-se6/src/main/java/org/jboss/cx/remoting/http/se6/ServerInstance.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/http-se6/src/main/java/org/jboss/cx/remoting/http/se6/ServerInstance.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -10,8 +10,8 @@
import org.jboss.cx.remoting.http.spi.RemotingHttpSessionContext;
import org.jboss.cx.remoting.http.spi.OutgoingHttpMessage;
import org.jboss.cx.remoting.http.spi.AbstractIncomingHttpMessage;
-import org.jboss.cx.remoting.core.util.ByteInput;
-import org.jboss.cx.remoting.core.util.ByteOutput;
+import org.jboss.cx.remoting.util.ByteInput;
+import org.jboss.cx.remoting.util.ByteOutput;
import com.sun.net.httpserver.BasicAuthenticator;
import com.sun.net.httpserver.Headers;
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-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppConnection.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -21,11 +21,11 @@
import org.jboss.cx.remoting.CommonKeys;
import org.jboss.cx.remoting.RemoteExecutionException;
import org.jboss.cx.remoting.ServiceLocator;
-import org.jboss.cx.remoting.core.util.AtomicStateMachine;
-import org.jboss.cx.remoting.core.util.AttributeMap;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
-import org.jboss.cx.remoting.core.util.MessageInput;
-import org.jboss.cx.remoting.core.util.MessageOutput;
+import org.jboss.cx.remoting.util.AtomicStateMachine;
+import org.jboss.cx.remoting.util.AttributeMap;
+import org.jboss.cx.remoting.util.MessageOutput;
+import org.jboss.cx.remoting.util.MessageInput;
+import org.jboss.cx.remoting.util.CollectionUtil;
import org.jboss.cx.remoting.jrpp.id.IdentifierManager;
import org.jboss.cx.remoting.jrpp.id.JrppContextIdentifier;
import org.jboss.cx.remoting.jrpp.id.JrppRequestIdentifier;
Modified: remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppProtocolSupport.java
===================================================================
--- remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppProtocolSupport.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppProtocolSupport.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -20,7 +20,7 @@
import org.apache.mina.transport.socket.nio.NioSocketConnector;
import org.jboss.cx.remoting.Endpoint;
import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.core.util.AttributeMap;
+import org.jboss.cx.remoting.util.AttributeMap;
import org.jboss.cx.remoting.jrpp.mina.FramingIoFilter;
import org.jboss.cx.remoting.spi.protocol.ProtocolContext;
import org.jboss.cx.remoting.spi.protocol.ProtocolHandler;
Modified: remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppServer.java
===================================================================
--- remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppServer.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/JrppServer.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -14,7 +14,7 @@
import org.apache.mina.handler.multiton.SingleSessionIoHandlerDelegate;
import org.apache.mina.handler.multiton.SingleSessionIoHandlerFactory;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
-import org.jboss.cx.remoting.core.util.AttributeMap;
+import org.jboss.cx.remoting.util.AttributeMap;
import org.jboss.cx.remoting.jrpp.mina.FramingIoFilter;
import org.jboss.cx.remoting.spi.protocol.ProtocolServerContext;
Modified: remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/id/JrppRequestIdentifier.java
===================================================================
--- remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/id/JrppRequestIdentifier.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/id/JrppRequestIdentifier.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -1,7 +1,7 @@
package org.jboss.cx.remoting.jrpp.id;
import java.io.IOException;
-import org.jboss.cx.remoting.core.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageInput;
import org.jboss.cx.remoting.spi.protocol.RequestIdentifier;
/**
Modified: remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/id/JrppServiceIdentifier.java
===================================================================
--- remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/id/JrppServiceIdentifier.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/id/JrppServiceIdentifier.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -1,7 +1,7 @@
package org.jboss.cx.remoting.jrpp.id;
import java.io.IOException;
-import org.jboss.cx.remoting.core.util.MessageInput;
+import org.jboss.cx.remoting.util.MessageInput;
import org.jboss.cx.remoting.spi.protocol.ServiceIdentifier;
/**
Modified: remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/mina/IoBufferByteInput.java
===================================================================
--- remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/mina/IoBufferByteInput.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/mina/IoBufferByteInput.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -2,7 +2,7 @@
import java.io.IOException;
import org.apache.mina.common.IoBuffer;
-import org.jboss.cx.remoting.core.util.ByteInput;
+import org.jboss.cx.remoting.util.ByteInput;
/**
*
Modified: remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/mina/IoBufferByteOutput.java
===================================================================
--- remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/mina/IoBufferByteOutput.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/jrpp/src/main/java/org/jboss/cx/remoting/jrpp/mina/IoBufferByteOutput.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -3,7 +3,7 @@
import java.io.IOException;
import org.apache.mina.common.IoBuffer;
import org.apache.mina.common.IoSession;
-import org.jboss.cx.remoting.core.util.ByteOutput;
+import org.jboss.cx.remoting.util.ByteOutput;
/**
*
Modified: remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/AbstractSrpSaslParticipant.java
===================================================================
--- remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/AbstractSrpSaslParticipant.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/AbstractSrpSaslParticipant.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -19,7 +19,7 @@
import java.util.Map;
import java.util.Random;
import org.jboss.cx.remoting.core.security.sasl.BufferFactory;
-import org.jboss.cx.remoting.core.util.IoUtil;
+import org.jboss.cx.remoting.util.IoUtil;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
Modified: remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpSaslClientImpl.java
===================================================================
--- remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpSaslClientImpl.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpSaslClientImpl.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -10,7 +10,7 @@
import java.util.Map;
import java.util.Random;
import java.util.Set;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
+import org.jboss.cx.remoting.util.CollectionUtil;
import org.jboss.cx.remoting.log.Logger;
import javax.crypto.NoSuchPaddingException;
Modified: remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpSaslServerImpl.java
===================================================================
--- remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpSaslServerImpl.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpSaslServerImpl.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -13,8 +13,8 @@
import java.util.Map;
import java.util.Random;
import java.util.Set;
-import org.jboss.cx.remoting.core.util.Base64DecodingException;
-import org.jboss.cx.remoting.core.util.CollectionUtil;
+import org.jboss.cx.remoting.util.Base64DecodingException;
+import org.jboss.cx.remoting.util.CollectionUtil;
import org.jboss.cx.remoting.log.Logger;
import javax.crypto.NoSuchPaddingException;
Modified: remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpVerifier.java
===================================================================
--- remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpVerifier.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/srp/src/main/java/org/jboss/cx/remoting/core/security/sasl/SrpVerifier.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -10,8 +10,8 @@
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import java.util.Set;
-import org.jboss.cx.remoting.core.util.Base64DecodingException;
-import org.jboss.cx.remoting.core.util.IoUtil;
+import org.jboss.cx.remoting.util.Base64DecodingException;
+import org.jboss.cx.remoting.util.IoUtil;
/**
*
Modified: remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java
===================================================================
--- remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java 2008-02-22 16:50:40 UTC (rev 3482)
+++ remoting3/trunk/standalone/src/main/java/org/jboss/cx/remoting/Remoting.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -3,8 +3,8 @@
import java.io.IOException;
import java.net.URI;
import org.jboss.cx.remoting.core.CoreEndpointProvider;
-import org.jboss.cx.remoting.core.util.AttributeHashMap;
-import org.jboss.cx.remoting.core.util.AttributeMap;
+import org.jboss.cx.remoting.util.AttributeHashMap;
+import org.jboss.cx.remoting.util.AttributeMap;
import org.jboss.cx.remoting.log.Logger;
import org.jboss.cx.remoting.spi.EndpointProvider;
import org.jboss.cx.remoting.spi.wrapper.ContextSourceWrapper;
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AbstractTypeMap.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/AbstractTypeMap.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AbstractTypeMap.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AbstractTypeMap.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,231 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ *
+ */
+public abstract class AbstractTypeMap<B> implements TypeMap<B> {
+ private final ConcurrentMap<Class<? extends B>, B> map;
+ private final Set<Entry<? extends B>> entrySet;
+
+ protected AbstractTypeMap(ConcurrentMap<Class<? extends B>, B> map) {
+ if (map == null) {
+ throw new NullPointerException("map is null");
+ }
+ this.map = map;
+ entrySet = new EntrySet();
+ }
+
+ protected AbstractTypeMap(Map<Class<? extends B>, B> map) {
+ if (map == null) {
+ throw new NullPointerException("map is null");
+ }
+ this.map = new AtomicMap<Class<? extends B>, B>(map);
+ entrySet = new EntrySet();
+ }
+
+ public void clear() {
+ map.clear();
+ }
+
+ public boolean containsKey(final Class<?> key) {
+ return map.containsKey(key);
+ }
+
+ public boolean containsValue(final Object value) {
+ // since we key by type, we can do an O(1) search for value!
+ final Class<? extends Object> claxx = value.getClass();
+ return map.containsKey(claxx) && isEqual(value, map.get(claxx));
+ }
+
+ private static boolean isEqual(final Object a, final Object b) {
+ return (a == null) == (b == null) && (a == null || a.equals(b));
+ }
+
+ public Set<Entry<? extends B>> entrySet() {
+ return entrySet;
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public <T extends B> T get(final Class<T> key) {
+ return (T) map.get(key);
+ }
+
+ public boolean isEmpty() {
+ return map.isEmpty();
+ }
+
+ public Set<Class<? extends B>> keySet() {
+ return map.keySet();
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public <T extends B> T put(final Class<T> key, final T value) {
+ return (T) map.put(key, value);
+ }
+
+ public <T extends B> void putAll(final TypeMap<T> m) {
+ for (Entry<? extends T> e : m.entrySet()) {
+ map.put(e.getKey(), e.getValue());
+ }
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public <T extends B> T remove(final Class<T> key) {
+ return (T) map.remove(key);
+ }
+
+ public int size() {
+ return map.size();
+ }
+
+ public Collection<? extends B> values() {
+ return map.values();
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public <T extends B> T putIfAbsent(final Class<T> key, final T value) {
+ return (T) map.putIfAbsent(key, value);
+ }
+
+ public <T extends B> boolean remove(final Class<T> key, final Object value) {
+ return map.remove(key, value);
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public <T extends B> T replace(final Class<T> key, final T value) {
+ return (T) map.replace(key, value);
+ }
+
+ public <T extends B> boolean replace(final Class<T> key, final T oldValue, final T newValue) {
+ return map.replace(key, oldValue, newValue);
+ }
+
+ private final class EntrySet implements Set<Entry<? extends B>> {
+ private final Set<Map.Entry<Class<? extends B>,B>> entries = map.entrySet();
+
+ private EntrySet() {
+ }
+
+ public int size() {
+ return entries.size();
+ }
+
+ public boolean isEmpty() {
+ return entries.isEmpty();
+ }
+
+ public boolean contains(final Object o) {
+ // containsValue(T)==true implies containsKey(T.class)==true
+ return o instanceof Entry && map.containsValue(((Entry<?>) o).getValue());
+ }
+
+ public Iterator<Entry<? extends B>> iterator() {
+ return new EntryIterator();
+ }
+
+ public Object[] toArray() {
+ throw new UnsupportedOperationException("toArray() not allowed");
+ }
+
+ public <T> T[] toArray(final T[] a) {
+ throw new UnsupportedOperationException("toArray() not allowed");
+ }
+
+ public boolean add(final Entry<? extends B> o) {
+ throw new UnsupportedOperationException("add() not allowed");
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public boolean remove(final Object o) {
+ if (! (o instanceof Entry)) {
+ return false;
+ }
+ Class<? extends B> key = ((Entry<? extends B>)o).getKey();
+ final Object value = ((Entry<? extends B>) o).getValue();
+ return AbstractTypeMap.this.remove(key, value);
+ }
+
+ public boolean containsAll(final Collection<?> c) {
+ for (Object x : c) {
+ if (! contains(x)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean addAll(final Collection<? extends Entry<? extends B>> c) {
+ throw new UnsupportedOperationException("addAll() not allowed");
+ }
+
+ public boolean retainAll(final Collection<?> c) {
+ throw new UnsupportedOperationException("retainAll() not allowed");
+ }
+
+ public boolean removeAll(final Collection<?> c) {
+ throw new UnsupportedOperationException("removeAll() not allowed");
+ }
+
+ public void clear() {
+ map.clear();
+ }
+ }
+
+ private final class EntryIterator implements Iterator<Entry<? extends B>> {
+ private final Iterator<Map.Entry<Class<? extends B>,B>> iterator = map.entrySet().iterator();
+
+ private EntryIterator() {}
+
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public Entry<? extends B> next() {
+ return new EntryImpl(iterator.next());
+ }
+
+ public void remove() {
+ iterator.remove();
+ }
+ }
+
+ private final class EntryImpl<Z> implements Entry<Z> {
+ private final Map.Entry<Class<Z>, Z> entry;
+
+ public EntryImpl(final Map.Entry<Class<Z>, Z> entry) {
+ this.entry = entry;
+ }
+
+ public Class<Z> getKey() {
+ return entry.getKey();
+ }
+
+ public Z getValue() {
+ return entry.getValue();
+ }
+
+ public Z setValue(final Z value) {
+ return entry.setValue(value);
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Entry) {
+ Entry<?> other = (Entry<?>) obj;
+ return isEqual(other.getKey(), entry.getKey()) && isEqual(other.getValue(), entry.getValue());
+ } else {
+ return false;
+ }
+ }
+
+ public int hashCode() {
+ return entry.hashCode();
+ }
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicMap.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/AtomicMap.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicMap.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicMap.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,107 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ *
+ */
+public final class AtomicMap<K, V> implements ConcurrentMap<K, V> {
+ private final Map<K, V> delegate;
+
+ public AtomicMap(final Map<K, V> delegate) {
+ this.delegate = delegate;
+ }
+
+ public int size() {
+ return delegate.size();
+ }
+
+ public boolean isEmpty() {
+ return delegate.isEmpty();
+ }
+
+ public boolean containsKey(final Object key) {
+ return delegate.containsKey(key);
+ }
+
+ public boolean containsValue(final Object value) {
+ return delegate.containsValue(value);
+ }
+
+ public V get(final Object key) {
+ return delegate.get(key);
+ }
+
+ public V put(final K key, final V value) {
+ return delegate.put(key, value);
+ }
+
+ public V remove(final Object key) {
+ return delegate.remove(key);
+ }
+
+ public void putAll(final Map<? extends K, ? extends V> t) {
+ delegate.putAll(t);
+ }
+
+ public void clear() {
+ delegate.clear();
+ }
+
+ public Set<K> keySet() {
+ return delegate.keySet();
+ }
+
+ public Collection<V> values() {
+ return delegate.values();
+ }
+
+ public Set<Entry<K, V>> entrySet() {
+ return delegate.entrySet();
+ }
+
+ public boolean equals(final Object o) {
+ return delegate.equals(o);
+ }
+
+ public int hashCode() {
+ return delegate.hashCode();
+ }
+
+ public V putIfAbsent(final K key, final V value) {
+ if (delegate.containsKey(key)) {
+ return delegate.get(key);
+ } else {
+ return delegate.put(key, value);
+ }
+ }
+
+ public boolean remove(final Object key, final Object value) {
+ if (delegate.containsKey(key) && (value == null && delegate.get(key) == null || delegate.get(key).equals(value))) {
+ delegate.remove(key);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean replace(final K key, final V oldValue, final V newValue) {
+ if (delegate.containsKey(key) && (oldValue == null ? delegate.get(key) == null : delegate.get(key).equals(oldValue))) {
+ delegate.put(key, newValue);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public V replace(final K key, final V value) {
+ if (delegate.containsKey(key)) {
+ return delegate.put(key, value);
+ } else {
+ return null;
+ }
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicStateMachine.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/AtomicStateMachine.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicStateMachine.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AtomicStateMachine.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,506 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ *
+ */
+public final class AtomicStateMachine<T extends Enum<T>> {
+ // protected by {@code lock}
+ private T state;
+
+ private final ReadWriteLock lock = new ReentrantReadWriteLock();
+ private final Lock readLock = lock.readLock();
+ private final Lock writeLock = lock.writeLock();
+ private final Condition cond = writeLock.newCondition();
+
+ public static <T extends Enum<T>> AtomicStateMachine<T> start(final T initialState) {
+ return new AtomicStateMachine<T>(initialState);
+ }
+
+ private AtomicStateMachine(final T state) {
+ if (state == null) {
+ throw new NullPointerException("state is null");
+ }
+ this.state = state;
+ }
+
+ public boolean transition(final T state) {
+ writeLock.lock();
+ try {
+ if (state == null) {
+ throw new NullPointerException("state is null");
+ }
+ if (this.state == state) {
+ return false;
+ }
+ this.state = state;
+ cond.signalAll();
+ return true;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ /**
+ * Transition the state, and hold it at the given state until {@link #release()} is called. Must not be
+ * called if the state is already held from this thread.
+ *
+ * Example:
+ * <pre>
+ * if (state.transitionHold(State.STOPPING)) try {
+ * // do stuff
+ * } finally {
+ * state.release();
+ * }
+ * </pre>
+ *
+ * @param state the target state
+ * @return {@code true} if the transition happened
+ */
+ public boolean transitionHold(final T state) {
+ if (state == null) {
+ throw new NullPointerException("state is null");
+ }
+ writeLock.lock();
+ try {
+ if (this.state == state) {
+ return false;
+ }
+ this.state = state;
+ cond.signalAll();
+ readLock.lock();
+ return true;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public boolean transitionExclusive(final T state) {
+ if (state == null) {
+ throw new NullPointerException("state is null");
+ }
+ writeLock.lock();
+ if (this.state == state) {
+ return false;
+ }
+ this.state = state;
+ cond.signalAll();
+ return true;
+ }
+
+ /**
+ * Release a held state. Must be called from the same thread that is holding the state.
+ */
+ public void release() {
+ readLock.unlock();
+ }
+
+ public void releaseExclusive() {
+ writeLock.unlock();
+ }
+
+ public void releaseDowngrade() {
+ readLock.lock();
+ writeLock.unlock();
+ }
+
+ public boolean transition(final T fromState, final T toState) {
+ if (fromState == null) {
+ throw new NullPointerException("fromState is null");
+ }
+ if (toState == null) {
+ throw new NullPointerException("toState is null");
+ }
+ writeLock.lock();
+ try {
+ if (state != fromState) {
+ return false;
+ }
+ state = toState;
+ cond.signalAll();
+ return true;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public boolean transitionHold(final T fromState, final T toState) {
+ if (fromState == null) {
+ throw new NullPointerException("fromState is null");
+ }
+ if (toState == null) {
+ throw new NullPointerException("toState is null");
+ }
+ writeLock.lock();
+ try {
+ if (state != fromState) {
+ return false;
+ }
+ state = toState;
+ cond.signalAll();
+ readLock.lock();
+ return true;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public boolean transitionExclusive(final T fromState, final T toState) {
+ if (fromState == null) {
+ throw new NullPointerException("fromState is null");
+ }
+ if (toState == null) {
+ throw new NullPointerException("toState is null");
+ }
+ writeLock.lock();
+ boolean ok = false;
+ try {
+ if (state != fromState) {
+ writeLock.unlock();
+ return false;
+ }
+ state = toState;
+ cond.signalAll();
+ ok = true;
+ return true;
+ } finally {
+ if (! ok) {
+ writeLock.unlock();
+ }
+ }
+ }
+
+ public void requireTransition(final T state) {
+ if (! transition(state)) {
+ throw new IllegalStateException("Already in state " + state);
+ }
+ }
+
+ public void requireTransitionHold(final T state) {
+ if (! transitionHold(state)) {
+ throw new IllegalStateException("Already in state " + state);
+ }
+ }
+
+ public void requireTransition(final T fromState, final T toState) {
+ if (! transition(fromState, toState)) {
+ throw new IllegalStateException("Cannot transition from " + fromState + " to " + toState + " (current state is " + state + ")");
+ }
+ }
+
+ public void requireTransitionHold(final T fromState, final T toState) {
+ if (! transitionHold(fromState, toState)) {
+ throw new IllegalStateException("Cannot transition from " + fromState + " to " + toState + " (current state is " + state + ")");
+ }
+ }
+
+ public void requireTransitionExclusive(T fromState, T toState) {
+ if (! transitionExclusive(fromState, toState)) {
+ throw new IllegalStateException("Cannot transition from " + fromState + " to " + toState + " (current state is " + state + ")");
+ }
+ }
+
+
+ public void waitInterruptablyFor(final T state) throws InterruptedException {
+ writeLock.lockInterruptibly();
+ try {
+ while (this.state != state) {
+ cond.await();
+ }
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public void waitFor(final T state) {
+ writeLock.lock();
+ try {
+ while (this.state != state) {
+ cond.awaitUninterruptibly();
+ }
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public void waitForHold(final T state) {
+ writeLock.lock();
+ try {
+ while (this.state != state) {
+ cond.awaitUninterruptibly();
+ }
+ readLock.lock();
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public void waitForAny() {
+ writeLock.lock();
+ try {
+ waitForNot(state);
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public boolean waitInterruptablyFor(final T state, final long timeout, final TimeUnit timeUnit) throws InterruptedException {
+ final long timeoutMillis = timeUnit.toMillis(timeout);
+ final long startTime = System.currentTimeMillis();
+ final long endTime = startTime + timeoutMillis < 0 ? Long.MAX_VALUE : startTime + timeoutMillis;
+ final Date deadline = new Date(endTime);
+ writeLock.lockInterruptibly();
+ try {
+ while (this.state != state) {
+ if (! cond.awaitUntil(deadline)) {
+ return false;
+ }
+ }
+ return true;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public T waitInterruptablyForNot(final T state) throws InterruptedException {
+ writeLock.lockInterruptibly();
+ try {
+ while (this.state == state) {
+ cond.await();
+ }
+ return this.state;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public T waitInterruptablyForNotHold(final T state) throws InterruptedException {
+ writeLock.lockInterruptibly();
+ try {
+ while (this.state == state) {
+ cond.await();
+ }
+ readLock.lockInterruptibly();
+ return this.state;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public T waitForNot(final T state) {
+ writeLock.lock();
+ try {
+ while (this.state == state) {
+ cond.awaitUninterruptibly();
+ }
+ return this.state;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public T waitForNotHold(final T state) {
+ writeLock.lock();
+ try {
+ while (this.state == state) {
+ cond.awaitUninterruptibly();
+ }
+ readLock.lock();
+ return this.state;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public T waitForNotExclusive(final T state) {
+ writeLock.lock();
+ while (this.state == state) {
+ cond.awaitUninterruptibly();
+ }
+ return this.state;
+ }
+
+ public T waitInterruptablyForNot(final T state, final long timeout, final TimeUnit timeUnit) throws InterruptedException {
+ final long timeoutMillis = timeUnit.toMillis(timeout);
+ final long startTime = System.currentTimeMillis();
+ final long endTime = startTime + timeoutMillis < 0 ? Long.MAX_VALUE : startTime + timeoutMillis;
+ final Date deadLine = new Date(endTime);
+ writeLock.lockInterruptibly();
+ try {
+ while (this.state == state) {
+ cond.awaitUntil(deadLine);
+ }
+ return this.state;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+
+ public T waitInterruptablyForNotHold(final T state, final long timeout, final TimeUnit timeUnit) throws InterruptedException {
+ final long timeoutMillis = timeUnit.toMillis(timeout);
+ final long startTime = System.currentTimeMillis();
+ final long endTime = startTime + timeoutMillis < 0 ? Long.MAX_VALUE : startTime + timeoutMillis;
+ final Date deadLine = new Date(endTime);
+ writeLock.lockInterruptibly();
+ try {
+ while (this.state == state) {
+ cond.awaitUntil(deadLine);
+ }
+ readLock.lockInterruptibly();
+ return this.state;
+ } finally {
+ writeLock.unlock();
+ }
+ }
+
+ public T waitForNot(final T state, final long timeout, final TimeUnit timeUnit) {
+ final long timeoutMillis = timeUnit.toMillis(timeout);
+ final long startTime = System.currentTimeMillis();
+ final long endTime = startTime + timeoutMillis < 0 ? Long.MAX_VALUE : startTime + timeoutMillis;
+ final Date deadLine = new Date(endTime);
+ boolean intr = false;
+ writeLock.lock();
+ try {
+ while (this.state == state) {
+ try {
+ if (! cond.awaitUntil(deadLine)) {
+ break;
+ }
+ } catch (InterruptedException e) {
+ intr = true;
+ }
+ }
+ return this.state;
+ } finally {
+ if (intr) {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+
+ public T getState() {
+ readLock.lock();
+ try {
+ return state;
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ public T getStateHold() {
+ readLock.lock();
+ return state;
+ }
+
+ public T getStateExclusive() {
+ writeLock.lock();
+ return state;
+ }
+
+ public boolean inHoldExclusive(T... states) {
+ if (states == null) {
+ throw new NullPointerException("states is null");
+ }
+ writeLock.lock();
+ for (T state : states) {
+ if (this.state == state) {
+ return true;
+ }
+ }
+ writeLock.unlock();
+ return false;
+ }
+
+ public boolean inHold(T... states) {
+ if (states == null) {
+ throw new NullPointerException("states is null");
+ }
+ readLock.lock();
+ for (T state : states) {
+ if (this.state == state) {
+ return true;
+ }
+ }
+ readLock.unlock();
+ return false;
+ }
+
+ public boolean in(T... states) {
+ if (states == null) {
+ throw new NullPointerException("states is null");
+ }
+ readLock.lock();
+ try {
+ for (T state : states) {
+ if (this.state == state) {
+ return true;
+ }
+ }
+ return false;
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ public void require(T state) {
+ if (state == null) {
+ throw new NullPointerException("state is null");
+ }
+ readLock.lock();
+ try {
+ if (this.state != state) {
+ throw new IllegalStateException("Invalid state (expected " + state + ", but current state is " + this.state + ")");
+ }
+ } finally {
+ readLock.unlock();
+ }
+ }
+
+ public void requireHold(T state) {
+ if (state == null) {
+ throw new NullPointerException("state is null");
+ }
+ boolean ok = false;
+ readLock.lock();
+ try {
+ if (this.state != state) {
+ throw new IllegalStateException("Invalid state (expected " + state + ", but current state is " + this.state + ")");
+ }
+ ok = true;
+ } finally {
+ if (! ok) readLock.unlock();
+ }
+ }
+
+ public void requireExclusive(T state) {
+ if (state == null) {
+ throw new NullPointerException("state is null");
+ }
+ boolean ok = false;
+ writeLock.lock();
+ try {
+ if (this.state != state) {
+ throw new IllegalStateException("Invalid state (expected " + state + ", but current state is " + this.state + ")");
+ }
+ ok = true;
+ } finally {
+ if (! ok) writeLock.unlock();
+ }
+ }
+
+ public String toString() {
+ readLock.lock();
+ try {
+ return "State = " + state;
+ } finally {
+ readLock.unlock();
+ }
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeHashMap.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/AttributeHashMap.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeHashMap.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeHashMap.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,105 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ *
+ */
+public final class AttributeHashMap implements AttributeMap {
+ private final ConcurrentMap<AttributeKey<?>, Object> map = CollectionUtil.concurrentMap();
+
+ @SuppressWarnings ({"unchecked"})
+ public <T> T get(AttributeKey<T> key) {
+ return (T) map.get(key);
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public <T> T put(AttributeKey<T> key, T value) {
+ return (T) map.put(key, value);
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public <T> T remove(AttributeKey<T> key) {
+ return (T) map.remove(key);
+ }
+
+ public <T> boolean remove(AttributeKey<T> key, T value) {
+ return map.remove(key, value);
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public <T> T putIfAbsent(AttributeKey<T> key, T value) {
+ return (T) map.putIfAbsent(key, value);
+ }
+
+ public <T> boolean replace(AttributeKey<T> key, T oldValue, T newValue) {
+ return map.replace(key, oldValue, newValue);
+ }
+
+ public <T> boolean containsKey(AttributeKey<T> key) {
+ return map.containsKey(key);
+ }
+
+ public <T> boolean containsValue(T value) {
+ return map.containsValue(value);
+ }
+
+ public Iterable<Entry<?>> entries() {
+ return new Iterable<Entry<?>>() {
+ public Iterator<Entry<?>> iterator() {
+ final Iterator<Map.Entry<AttributeKey<?>, Object>> i = map.entrySet().iterator();
+ return new Iterator<Entry<?>>() {
+ public boolean hasNext() {
+ return i.hasNext();
+ }
+
+ public Entry<?> next() {
+ final Map.Entry<AttributeKey<?>, Object> ie = i.next();
+ return new Entry<Object>() {
+ @SuppressWarnings ({"unchecked"})
+ public AttributeKey<Object> getKey() {
+ return (AttributeKey<Object>) ie.getKey();
+ }
+
+ public Object getValue() {
+ return ie.getValue();
+ }
+
+ public void setValue(final Object newValue) {
+ ie.setValue(newValue);
+ }
+ };
+ }
+
+ public void remove() {
+ i.remove();
+ }
+ };
+ }
+ };
+ }
+
+ public Set<AttributeKey<?>> keySet() {
+ return map.keySet();
+ }
+
+ public Collection<?> values() {
+ return map.values();
+ }
+
+ public boolean isEmpty() {
+ return map.isEmpty();
+ }
+
+ public int size() {
+ return map.size();
+ }
+
+ public void clear() {
+ map.clear();
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeKey.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/AttributeKey.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeKey.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeKey.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,20 @@
+package org.jboss.cx.remoting.util;
+
+/**
+ *
+ */
+public final class AttributeKey<T> {
+ private final String name;
+
+ public static <T> AttributeKey<T> key(String name) {
+ return new AttributeKey<T>(name);
+ }
+
+ public AttributeKey(final String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return "Key \"" + name + "\"";
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeMap.java (from rev 3482, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/AttributeMap.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeMap.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/AttributeMap.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,145 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * A map whose value types are determined by the key.
+ */
+public interface AttributeMap {
+
+ /**
+ * Get a value from the map.
+ *
+ * @param key the key
+ * @return the value
+ */
+ <T> T get(AttributeKey<T> key);
+
+ /**
+ * Store a value into the map. Any previous mapping for this value is overwritten.
+ *
+ * @param key the key
+ * @param value the new value
+ * @return the old value (may be {@code null}), or {@code null} if there was no mapping for this key
+ */
+ <T> T put(AttributeKey<T> key, T value);
+
+ /**
+ * Remove a mapping from the map.
+ *
+ * @param key the key
+ * @return the old value (may be {@code null}), or {@code null} if there was no mapping for this key
+ */
+ <T> T remove(AttributeKey<T> key);
+
+ /**
+ * Remove a mapping from the map. Both the key and value must match the values given.
+ *
+ * @param key the key
+ * @param value the value
+ * @return {@code true} if a matching mapping was located and removed
+ */
+ <T> boolean remove(AttributeKey<T> key, T value);
+
+ /**
+ * Store a value into the map if there is no value currently stored.
+ *
+ * @param key the key
+ * @param value the value
+ * @return the old value if there was a previous mapping
+ */
+ <T> T putIfAbsent(AttributeKey<T> key, T value);
+
+ /**
+ * Replace a mapping in the map.
+ *
+ * @param key the key
+ * @param oldValue the old value
+ * @param newValue the replacement value
+ * @return {@code true} if a matching mapping was located and replaced
+ */
+ <T> boolean replace(AttributeKey<T> key, T oldValue, T newValue);
+
+ /**
+ * Test the map for the presence of a key.
+ *
+ * @param key the key
+ * @return {@code true} if the key is present in the map
+ */
+ <T> boolean containsKey(AttributeKey<T> key);
+
+ /**
+ * Test the map for the presence of a value.
+ *
+ * @param value the value
+ * @return {@code true} if the value is present in the map
+ */
+ <T> boolean containsValue(T value);
+
+ /**
+ * Get all the map entries.
+ *
+ * @return the entries
+ */
+ Iterable<Entry<?>> entries();
+
+ /**
+ * Get the key set for this map. The returned set supports all set operations except for {@code add} and {@code addAll}.
+ *
+ * @return the key set
+ */
+ Set<AttributeKey<?>> keySet();
+
+ /**
+ * Get the collection of values for this map.
+ *
+ * @return the values
+ */
+ Collection<?> values();
+
+ /**
+ * Determine whether this map is empty.
+ *
+ * @return {@code true} if the map has no mappings
+ */
+ boolean isEmpty();
+
+ /**
+ * Determine the number of entries in the map.
+ *
+ * @return the number of entries
+ */
+ int size();
+
+ /**
+ * Clear the map of all mappings.
+ */
+ void clear();
+
+ /**
+ * An entry in the {@code AttributeMap}.
+ */
+ interface Entry<T> {
+ /**
+ * Get the entry key.
+ *
+ * @return the key
+ */
+ AttributeKey<T> getKey();
+
+ /**
+ * Get the entry value.
+ *
+ * @return the value
+ */
+ T getValue();
+
+ /**
+ * Change the entry value.
+ *
+ * @param newValue the new value
+ */
+ void setValue(T newValue);
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/Base64DecodingException.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/Base64DecodingException.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/Base64DecodingException.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/Base64DecodingException.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,21 @@
+package org.jboss.cx.remoting.util;
+
+/**
+ *
+ */
+public final class Base64DecodingException extends Exception {
+ public Base64DecodingException() {
+ }
+
+ public Base64DecodingException(String message) {
+ super(message);
+ }
+
+ public Base64DecodingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public Base64DecodingException(Throwable cause) {
+ super(cause);
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteInput.java (from rev 3482, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ByteInput.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteInput.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteInput.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,44 @@
+package org.jboss.cx.remoting.util;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * A readable source of byte data.
+ */
+public interface ByteInput extends Closeable {
+ /**
+ * Read one byte.
+ *
+ * @return the byte, or -1 if the end of the stream has been reached.
+ * @throws IOException if an I/O error occurs
+ */
+ int read() throws IOException;
+
+ /**
+ * Read a series of bytes into an array.
+ *
+ * @param data the array into which data is to be read
+ * @return the total number of bytes read, or -1 if there are no bytes remaining to read
+ * @throws IOException if an I/O error occurs
+ */
+ int read(byte[] data) throws IOException;
+
+ /**
+ * Read a series of bytes into an array.
+ *
+ * @param data the array into which data is to be read
+ * @param offs the start offset in the {@code data} array at which the data is written
+ * @param len the maximum number of bytes to read
+ * @return the total number of bytes read, or -1 if there are no bytes remaining to read
+ * @throws IOException if an I/O error occurs
+ */
+ int read(byte[] data, int offs, int len) throws IOException;
+
+ /**
+ * Return the number of bytes remaining.
+ *
+ * @return the number of bytes, or -1 if the byte count cannot be determined
+ */
+ int remaining();
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteOutput.java (from rev 3482, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ByteOutput.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteOutput.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ByteOutput.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,52 @@
+package org.jboss.cx.remoting.util;
+
+import java.io.Closeable;
+import java.io.Flushable;
+import java.io.IOException;
+
+/**
+ * A writable destination for byte data.
+ */
+public interface ByteOutput extends Closeable, Flushable {
+ /**
+ * Write a single byte of data. The input argument is truncated to 8 bits.
+ *
+ * @param b the byte to write
+ * @throws IOException if an I/O error occurs
+ */
+ void write(int b) throws IOException;
+
+ /**
+ * Write many bytes of data.
+ *
+ * @param b the bytes to write
+ * @throws IOException if an I/O error occurs
+ */
+ void write(byte[] b) throws IOException;
+
+ /**
+ * Write many bytes of data.
+ *
+ * @param b the bytes to write
+ * @param offs the offset in {@code b} to start reading bytes from
+ * @param len the number of bytes to write
+ * @throws IOException if an I/O error occurs
+ */
+ void write(byte[] b, int offs, int len) throws IOException;
+
+ /**
+ * Commit the written data. This causes the accumulated data to be sent as a message on the underlying
+ * channel.
+ *
+ * @throws IOException if an I/O error occurs
+ */
+ void commit() throws IOException;
+
+ /**
+ * Get a count of the number of bytes written to this message.
+ *
+ * @return the count
+ * @throws IOException if an I/O error occurs
+ */
+ int getBytesWritten() throws IOException;
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/CollectionUtil.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/CollectionUtil.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,148 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Queue;
+import java.util.Set;
+import java.util.WeakHashMap;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ *
+ */
+public final class CollectionUtil {
+ private CollectionUtil() {
+ }
+
+ public static <K, V> ConcurrentMap<K, V> concurrentMap() {
+ if (true) {
+ return concurrentMap(new HashMap<K,V>());
+ } else {
+ return new ConcurrentHashMap<K, V>();
+ }
+ }
+
+ public static <K, V> ConcurrentMap<K, V> concurrentMap(Map<K, V> original) {
+ return new SynchronizedMap<K, V>(original);
+ }
+
+ public static <T> List<T> arrayList() {
+ return new ArrayList<T>();
+ }
+
+ public static <T> List<T> arrayList(List<T> orig) {
+ return new ArrayList<T>(orig);
+ }
+
+ public static <T> Set<T> synchronizedSet(Set<T> nested) {
+ return new SynchronizedSet<T>(nested);
+ }
+
+ public static <T> BlockingQueue<T> synchronizedQueue(Queue<T> nested) {
+ return new SynchronizedQueue<T>(nested);
+ }
+
+ public static <T> Set<T> weakHashSet() {
+ return new WeakHashSet<T>();
+ }
+
+ public static <T> BlockingQueue<T> blockingQueue(int size) {
+ return new ArrayBlockingQueue<T>(size);
+ }
+
+ public static <T> Iterable<T> protectedIterable(Iterable<T> original) {
+ return new DelegateIterable<T>(original);
+ }
+
+ public static <T> Set<T> hashSet() {
+ return new HashSet<T>();
+ }
+
+ public static <T> Iterable<T> loop(final Enumeration<T> enumeration) {
+ return new Iterable<T>() {
+ public Iterator<T> iterator() {
+ return new Iterator<T>() {
+ public boolean hasNext() {
+ return enumeration.hasMoreElements();
+ }
+
+ public T next() {
+ return enumeration.nextElement();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove() not supported");
+ }
+ };
+ }
+ };
+ }
+
+ public static <T> Iterable<T> loop(final Iterator<T> iterator) {
+ return new Iterable<T>() {
+ public Iterator<T> iterator() {
+ return iterator;
+ }
+ };
+ }
+
+ public static Iterable<String> split(final String delimiter, final String subject) {
+ return new Iterable<String>() {
+ public Iterator<String> iterator() {
+ return new Iterator<String>(){
+ private int position = 0;
+
+ public boolean hasNext() {
+ return position != -1;
+ }
+
+ public String next() {
+ if (position == -1) {
+ throw new NoSuchElementException("next() past end of iterator");
+ }
+ final int nextDelim = subject.indexOf(delimiter, position);
+ try {
+ if (nextDelim == -1) {
+ return subject.substring(position);
+ } else {
+ return subject.substring(position, nextDelim);
+ }
+ } finally {
+ position = nextDelim;
+ }
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove() not supported");
+ }
+ };
+ }
+ };
+ }
+
+ public static <K, V> Map<K, V> weakHashMap() {
+ return new WeakHashMap<K, V>();
+ }
+
+
+ public static <K, V> ConcurrentMap<K, V> concurrentWeakHashMap() {
+ return CollectionUtil.<K,V>concurrentMap(CollectionUtil.<K,V>weakHashMap());
+ }
+
+ public static <T> List<T> unmodifiableList(final T[] entries) {
+ return new UnmodifiableArrayList<T>(entries);
+ }
+
+ public static <K, V> Map<K, V> hashMap() {
+ return new HashMap<K, V>();
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DelegateIterable.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/DelegateIterable.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DelegateIterable.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/DelegateIterable.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,18 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Iterator;
+
+/**
+ *
+ */
+public final class DelegateIterable<T> implements Iterable<T> {
+ private final Iterable<T> delegate;
+
+ public DelegateIterable(final Iterable<T> delegate) {
+ this.delegate = delegate;
+ }
+
+ public Iterator<T> iterator() {
+ return delegate.iterator();
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/HashTypeMap.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/HashTypeMap.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/HashTypeMap.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/HashTypeMap.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,12 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.HashMap;
+
+/**
+ *
+ */
+public final class HashTypeMap<B> extends AbstractTypeMap<B> {
+ public HashTypeMap() {
+ super(new HashMap<Class<? extends B>, B>());
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/IoUtil.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/IoUtil.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/IoUtil.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/IoUtil.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,149 @@
+package org.jboss.cx.remoting.util;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+
+/**
+ *
+ */
+public final class IoUtil {
+ public static ByteBuffer getSlice(ByteBuffer source, int length) {
+ ByteBuffer slice = source.duplicate();
+ final int newLimit;
+ if (length < 0) {
+ // calculate from end
+ newLimit = source.limit() - length;
+ } else {
+ // calculate from start
+ newLimit = source.position() + length;
+ }
+ slice.limit(newLimit);
+ source.position(newLimit);
+ return slice;
+ }
+
+ public static void base64Decode(CharBuffer source, ByteBuffer target) throws Base64DecodingException {
+ int triad;
+ while (source.hasRemaining()) {
+ triad = 0;
+ char ch = source.get();
+ if (ch >= 'A' && ch <= 'Z') {
+ triad |= (ch - 'A') << 18;
+ } else if (ch >= 'a' && ch <= 'z') {
+ triad |= (ch - 'a' + 26) << 18;
+ } else if (ch >= '0' && ch <= '9') {
+ triad |= (ch - '0' + 52) << 18;
+ } else if (ch == '+' || ch == '-') {
+ triad |= 62 << 18;
+ } else if (ch == '/' || ch == '_') {
+ triad |= 63 << 18;
+ } else if (ch == '=') {
+ throw new Base64DecodingException("Unexpected padding encountered");
+ }
+ if (! source.hasRemaining()) {
+ throw new Base64DecodingException("Unexpected end of source data");
+ }
+
+ ch = source.get();
+ if (ch >= 'A' && ch <= 'Z') {
+ triad |= (ch - 'A') << 12;
+ } else if (ch >= 'a' && ch <= 'z') {
+ triad |= (ch - 'a' + 26) << 12;
+ } else if (ch >= '0' && ch <= '9') {
+ triad |= (ch - '0' + 52) << 12;
+ } else if (ch == '+' || ch == '-') {
+ triad |= 62 << 12;
+ } else if (ch == '/' || ch == '_') {
+ triad |= 63 << 12;
+ } else if (ch == '=') {
+ throw new Base64DecodingException("Unexpected padding encountered");
+ }
+ if (! source.hasRemaining()) {
+ throw new Base64DecodingException("Unexpected end of source data");
+ }
+
+ ch = source.get();
+ if (ch >= 'A' && ch <= 'Z') {
+ triad |= (ch - 'A') << 6;
+ } else if (ch >= 'a' && ch <= 'z') {
+ triad |= (ch - 'a' + 26) << 6;
+ } else if (ch >= '0' && ch <= '9') {
+ triad |= (ch - '0' + 52) << 6;
+ } else if (ch == '+' || ch == '-') {
+ triad |= 62 << 6;
+ } else if (ch == '/' || ch == '_') {
+ triad |= 63 << 6;
+ } else if (ch == '=') {
+ if (source.hasRemaining() && source.get() == '=') {
+ if (! source.hasRemaining()) {
+ target.put((byte) (triad >> 16));
+ return;
+ } else {
+ throw new Base64DecodingException("Extra data after padding");
+ }
+ } else {
+ throw new Base64DecodingException("Unexpected end of source data");
+ }
+ }
+
+ ch = source.get();
+ if (ch >= 'A' && ch <= 'Z') {
+ triad |= ch - 'A';
+ } else if (ch >= 'a' && ch <= 'z') {
+ triad |= ch - 'a' + 26;
+ } else if (ch >= '0' && ch <= '9') {
+ triad |= ch - '0' + 52;
+ } else if (ch == '+' || ch == '-') {
+ triad |= 62;
+ } else if (ch == '/' || ch == '_') {
+ triad |= 63;
+ } else if (ch == '=') {
+ if (! source.hasRemaining()) {
+ target.putShort((short) (triad >> 8));
+ return;
+ } else {
+ throw new Base64DecodingException("Extra data after padding");
+ }
+ }
+
+ target.put((byte) (triad >> 16));
+ target.putShort((short) triad);
+ }
+ }
+
+ private static final char[] base64table = new char[] {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
+ 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
+ 'w', 'x', 'y', 'z', '0', '1', '2', '3',
+ '4', '5', '6', '7', '8', '9', '+', '/',
+ };
+
+ public static void base64Encode(ByteBuffer source, CharBuffer target) {
+ int idx = 0;
+ while (source.hasRemaining()) {
+ int b = source.get() & 0xff;
+ target.put(base64table[b >>> 2]);
+ idx = b << 4 & 0x3f;
+ if (! source.hasRemaining()) {
+ target.put(base64table[idx]);
+ target.put("==");
+ return;
+ }
+ b = source.get() & 0xff;
+ target.put(base64table[idx | (b >>> 4)]);
+ idx = b << 2 & 0x3f;
+ if (! source.hasRemaining()) {
+ target.put(base64table[idx]);
+ target.put('=');
+ return;
+ }
+ b = source.get() & 0xff;
+ target.put(base64table[idx | (b >>> 6)]);
+ target.put(base64table[b & 0x3f]);
+ }
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/LinkedHashTypeMap.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/LinkedHashTypeMap.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/LinkedHashTypeMap.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/LinkedHashTypeMap.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,12 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.LinkedHashMap;
+
+/**
+ *
+ */
+public final class LinkedHashTypeMap<B> extends AbstractTypeMap<B> {
+ public LinkedHashTypeMap() {
+ super(new LinkedHashMap<Class<? extends B>, B>());
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/MessageInput.java (from rev 3482, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/MessageInput.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/MessageInput.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/MessageInput.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,29 @@
+package org.jboss.cx.remoting.util;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+
+/**
+ * A readable message.
+ */
+public interface MessageInput extends ByteInput, ObjectInput {
+ /**
+ * Read an object using the current context classloader, or, if there is no such classloader, the classloader
+ * which loaded this interface.
+ *
+ * @return the object from the message
+ * @throws ClassNotFoundException if the class of the object could not be resolved by the classloader
+ * @throws IOException if an I/O error occurs
+ */
+ Object readObject() throws ClassNotFoundException, IOException;
+
+ /**
+ * Read an object using the given classloader.
+ *
+ * @param loader the classloader to use
+ * @return the object from the message
+ * @throws ClassNotFoundException if the class of the object could not be resolved by the classloader
+ * @throws IOException if an I/O error occurs
+ */
+ Object readObject(ClassLoader loader) throws ClassNotFoundException, IOException;
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/MessageOutput.java (from rev 3482, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/MessageOutput.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/MessageOutput.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/MessageOutput.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,9 @@
+package org.jboss.cx.remoting.util;
+
+import java.io.ObjectOutput;
+
+/**
+ * A writable message.
+ */
+public interface MessageOutput extends ByteOutput, ObjectOutput {
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceURI.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ServiceURI.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceURI.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/ServiceURI.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,87 @@
+package org.jboss.cx.remoting.util;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ *
+ */
+public final class ServiceURI {
+ public static final String SCHEME = "jrs";
+
+ private static final String FIRST_CHAR = "[$_a-zA-Z]";
+ private static final String SUBSEQUENT_CHAR = "[-+$_a-zA-Z0-9]*";
+ private static final String ID = FIRST_CHAR + SUBSEQUENT_CHAR;
+ private static final String SEPARATOR = "[./]";
+
+ private static final Pattern VALID_PATTERN = Pattern.compile("^(?:" + ID + "(?:" + SEPARATOR + ID + ")*)*$");
+
+ private final URI uri;
+ private final String serviceType;
+ private final String groupName;
+ private final String endpointName;
+
+ public ServiceURI(final String str) throws URISyntaxException {
+ this(new URI(str));
+ }
+
+ public ServiceURI(final URI uri) {
+ this.uri = uri;
+ if (! uri.getScheme().equals(SCHEME)) {
+ throw new IllegalArgumentException("Invalid URI scheme for service");
+ }
+ final String ssp = uri.getSchemeSpecificPart();
+ final int stcp = ssp.indexOf(':');
+ if (stcp == -1) {
+ serviceType = ssp;
+ groupName = "";
+ endpointName = "";
+ } else {
+ serviceType = ssp.substring(0, stcp).trim();
+ final int gncp = ssp.indexOf(':', stcp + 1);
+ if (gncp == -1) {
+ groupName = ssp.substring(stcp + 1).trim();
+ endpointName = "";
+ } else {
+ groupName = ssp.substring(stcp + 1, gncp).trim();
+ // ignore everything after the last :
+ final int encp = ssp.indexOf(':', gncp + 1);
+ if (encp == -1) {
+ endpointName = ssp.substring(gncp + 1).trim();
+ } else {
+ endpointName = ssp.substring(gncp + 1, encp).trim();
+ }
+ }
+ }
+ final Matcher matcher = VALID_PATTERN.matcher(serviceType);
+ if (! matcher.matches()) {
+ throw new IllegalArgumentException("Syntax error in service type URI part");
+ }
+ matcher.reset(groupName);
+ if (! matcher.matches()) {
+ throw new IllegalArgumentException("Syntax error in group name URI part");
+ }
+ matcher.reset(endpointName);
+ if (! matcher.matches()) {
+ throw new IllegalArgumentException("Syntax error in endpoint name URI part");
+ }
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public String getServiceType() {
+ return serviceType;
+ }
+
+ public String getGroupName() {
+ return groupName;
+ }
+
+ public String getEndpointName() {
+ return endpointName;
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedCollection.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/SynchronizedCollection.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedCollection.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedCollection.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,118 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ *
+ */
+public class SynchronizedCollection<V> implements Collection<V> {
+ private final Collection<V> delegate;
+ private final Object monitor;
+
+ public SynchronizedCollection(final Collection<V> delegate) {
+ this.delegate = delegate;
+ monitor = this;
+ }
+
+ protected SynchronizedCollection(final Collection<V> delegate, final Object monitor) {
+ this.delegate = delegate;
+ this.monitor = monitor;
+ }
+
+ public int size() {
+ synchronized (monitor) {
+ return delegate.size();
+ }
+ }
+
+ public boolean isEmpty() {
+ synchronized (monitor) {
+ return delegate.isEmpty();
+ }
+ }
+
+ public boolean contains(final Object o) {
+ synchronized (monitor) {
+ return delegate.contains(o);
+ }
+ }
+
+ public Iterator<V> iterator() {
+ synchronized (monitor) {
+ return new SynchronizedIterator<V>(delegate.iterator(), monitor);
+ }
+ }
+
+ public Object[] toArray() {
+ synchronized (monitor) {
+ return delegate.toArray();
+ }
+ }
+
+ public <T> T[] toArray(final T[] a) {
+ synchronized (monitor) {
+ return delegate.toArray(a);
+ }
+ }
+
+ public boolean add(final V o) {
+ synchronized (monitor) {
+ return delegate.add(o);
+ }
+ }
+
+ public boolean remove(final Object o) {
+ synchronized (monitor) {
+ return delegate.remove(o);
+ }
+ }
+
+ public boolean containsAll(final Collection<?> c) {
+ synchronized (monitor) {
+ return delegate.containsAll(c);
+ }
+ }
+
+ public boolean addAll(final Collection<? extends V> c) {
+ synchronized (monitor) {
+ return delegate.addAll(c);
+ }
+ }
+
+ public boolean removeAll(final Collection<?> c) {
+ synchronized (monitor) {
+ return delegate.removeAll(c);
+ }
+ }
+
+ public boolean retainAll(final Collection<?> c) {
+ synchronized (monitor) {
+ return delegate.retainAll(c);
+ }
+ }
+
+ public void clear() {
+ synchronized (monitor) {
+ delegate.clear();
+ }
+ }
+
+ public boolean equals(final Object o) {
+ synchronized (monitor) {
+ return delegate.equals(o);
+ }
+ }
+
+ public int hashCode() {
+ synchronized (monitor) {
+ return delegate.hashCode();
+ }
+ }
+
+ public String toString() {
+ synchronized (monitor) {
+ return delegate.toString();
+ }
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedIterator.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/SynchronizedIterator.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedIterator.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedIterator.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,52 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Iterator;
+
+/**
+ *
+ */
+public class SynchronizedIterator<T> implements Iterator<T> {
+ private final Iterator<T> delegate;
+ private final Object monitor;
+
+ protected SynchronizedIterator(final Iterator<T> delegate, final Object monitor) {
+ this.delegate = delegate;
+ this.monitor = monitor;
+ }
+
+ public boolean hasNext() {
+ synchronized (monitor) {
+ return delegate.hasNext();
+ }
+ }
+
+ public T next() {
+ synchronized (monitor) {
+ return delegate.next();
+ }
+ }
+
+ public void remove() {
+ synchronized (monitor) {
+ delegate.remove();
+ }
+ }
+
+ public int hashCode() {
+ synchronized (monitor) {
+ return delegate.hashCode();
+ }
+ }
+
+ public boolean equals(Object obj) {
+ synchronized (monitor) {
+ return delegate.equals(obj);
+ }
+ }
+
+ public String toString() {
+ synchronized (monitor) {
+ return delegate.toString();
+ }
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedMap.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/SynchronizedMap.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedMap.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedMap.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,156 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ *
+ */
+public class SynchronizedMap<K, V> implements ConcurrentMap<K, V> {
+ private final Object monitor;
+ private final Map<K, V> delegate;
+
+ public SynchronizedMap(final Map<K, V> delegate) {
+ this.delegate = delegate;
+ monitor = this;
+ }
+
+ protected SynchronizedMap(final Map<K, V> delegate, final Object monitor) {
+ this.monitor = monitor;
+ this.delegate = delegate;
+ }
+
+ public int size() {
+ synchronized (monitor) {
+ return delegate.size();
+ }
+ }
+
+ public boolean isEmpty() {
+ synchronized (monitor) {
+ return delegate.isEmpty();
+ }
+ }
+
+ public boolean containsKey(final Object key) {
+ synchronized (monitor) {
+ return delegate.containsKey(key);
+ }
+ }
+
+ public boolean containsValue(final Object value) {
+ synchronized (monitor) {
+ return delegate.containsValue(value);
+ }
+ }
+
+ public V get(final Object key) {
+ synchronized (monitor) {
+ return delegate.get(key);
+ }
+ }
+
+ public V put(final K key, final V value) {
+ synchronized (monitor) {
+ return delegate.put(key, value);
+ }
+ }
+
+ public V remove(final Object key) {
+ synchronized (monitor) {
+ return delegate.remove(key);
+ }
+ }
+
+ public void putAll(final Map<? extends K, ? extends V> t) {
+ synchronized (monitor) {
+ delegate.putAll(t);
+ }
+ }
+
+ public void clear() {
+ synchronized (monitor) {
+ delegate.clear();
+ }
+ }
+
+ public Set<K> keySet() {
+ synchronized (monitor) {
+ return new SynchronizedSet<K>(delegate.keySet(), monitor);
+ }
+ }
+
+ public Collection<V> values() {
+ synchronized (monitor) {
+ return new SynchronizedCollection<V>(delegate.values(), monitor);
+ }
+ }
+
+ public Set<Entry<K, V>> entrySet() {
+ synchronized (monitor) {
+ return new SynchronizedSet<Entry<K, V>>(delegate.entrySet(), monitor);
+ }
+ }
+
+ public boolean equals(final Object o) {
+ synchronized (monitor) {
+ return delegate.equals(o);
+ }
+ }
+
+ public int hashCode() {
+ synchronized (monitor) {
+ return delegate.hashCode();
+ }
+ }
+
+ public V putIfAbsent(final K key, final V value) {
+ synchronized (monitor) {
+ if (delegate.containsKey(key)) {
+ return delegate.get(key);
+ } else {
+ return delegate.put(key, value);
+ }
+ }
+ }
+
+ public boolean remove(final Object key, final Object value) {
+ synchronized (monitor) {
+ if (delegate.containsKey(key) && (value == null && delegate.get(key) == null || delegate.get(key).equals(value))) {
+ delegate.remove(key);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public boolean replace(final K key, final V oldValue, final V newValue) {
+ synchronized (monitor) {
+ if (delegate.containsKey(key) && (oldValue == null ? delegate.get(key) == null : delegate.get(key).equals(oldValue))) {
+ delegate.put(key, newValue);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public V replace(final K key, final V value) {
+ synchronized (monitor) {
+ if (delegate.containsKey(key)) {
+ return delegate.put(key, value);
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public String toString() {
+ synchronized (monitor) {
+ return delegate.toString();
+ }
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedQueue.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/SynchronizedQueue.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedQueue.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedQueue.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,248 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Queue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+/**
+ *
+ */
+public final class SynchronizedQueue<T> implements BlockingQueue<T> {
+ private final Queue<T> delegate;
+ private final Object monitor;
+
+ public SynchronizedQueue(final Queue<T> delegate) {
+ this.delegate = delegate;
+ monitor = this;
+ }
+
+ protected SynchronizedQueue(final Queue<T> delegate, final Object monitor) {
+ this.monitor = monitor;
+ this.delegate = delegate;
+ }
+
+ public boolean offer(final T o) {
+ synchronized(monitor) {
+ return delegate.offer(o);
+ }
+ }
+
+ public T poll() {
+ synchronized(monitor) {
+ return delegate.poll();
+ }
+ }
+
+ public T remove() {
+ synchronized(monitor) {
+ return delegate.remove();
+ }
+ }
+
+ public T peek() {
+ synchronized(monitor) {
+ return delegate.peek();
+ }
+ }
+
+ public T element() {
+ synchronized(monitor) {
+ return delegate.element();
+ }
+ }
+
+ public int size() {
+ synchronized(monitor) {
+ return delegate.size();
+ }
+ }
+
+ public boolean isEmpty() {
+ synchronized(monitor) {
+ return delegate.isEmpty();
+ }
+ }
+
+ public boolean contains(final Object o) {
+ synchronized(monitor) {
+ return delegate.contains(o);
+ }
+ }
+
+ public Iterator<T> iterator() {
+ synchronized(monitor) {
+ return delegate.iterator();
+ }
+ }
+
+ public Object[] toArray() {
+ synchronized(monitor) {
+ return delegate.toArray();
+ }
+ }
+
+ public <T> T[] toArray(final T[] a) {
+ synchronized(monitor) {
+ return delegate.toArray(a);
+ }
+ }
+
+ public boolean add(final T o) {
+ synchronized(monitor) {
+ return delegate.add(o);
+ }
+ }
+
+ public boolean remove(final Object o) {
+ synchronized(monitor) {
+ return delegate.remove(o);
+ }
+ }
+
+ public boolean containsAll(final Collection<?> c) {
+ synchronized(monitor) {
+ return delegate.containsAll(c);
+ }
+ }
+
+ public boolean addAll(final Collection<? extends T> c) {
+ synchronized(monitor) {
+ return delegate.addAll(c);
+ }
+ }
+
+ public boolean removeAll(final Collection<?> c) {
+ synchronized(monitor) {
+ return delegate.removeAll(c);
+ }
+ }
+
+ public boolean retainAll(final Collection<?> c) {
+ synchronized(monitor) {
+ return delegate.retainAll(c);
+ }
+ }
+
+ public void clear() {
+ synchronized(monitor) {
+ delegate.clear();
+ }
+ }
+
+ public boolean equals(final Object o) {
+ synchronized(monitor) {
+ return delegate.equals(o);
+ }
+ }
+
+ public int hashCode() {
+ synchronized(monitor) {
+ return delegate.hashCode();
+ }
+ }
+
+ public boolean offer(final T o, final long timeout, final TimeUnit unit) throws InterruptedException {
+ long startTime = System.currentTimeMillis();
+ long timeoutMillis = unit.toMillis(timeout);
+ long deadline = startTime + timeoutMillis < 0L ? Long.MAX_VALUE : startTime + timeoutMillis;
+ synchronized(monitor) {
+ for (;;) {
+ if (offer(o)) {
+ return true;
+ }
+ if (deadline <= startTime) {
+ return false;
+ }
+ monitor.wait(deadline - startTime);
+ startTime = System.currentTimeMillis();
+ }
+ }
+ }
+
+ public T poll(final long timeout, final TimeUnit unit) throws InterruptedException {
+ long startTime = System.currentTimeMillis();
+ long timeoutMillis = unit.toMillis(timeout);
+ long deadline = startTime + timeoutMillis < 0L ? Long.MAX_VALUE : startTime + timeoutMillis;
+ synchronized(monitor) {
+ for (;;) {
+ final T v = poll();
+ if (v != null) {
+ return v;
+ }
+ if (deadline <= startTime) {
+ return null;
+ }
+ monitor.wait(deadline - startTime);
+ startTime = System.currentTimeMillis();
+ }
+ }
+ }
+
+ public T take() throws InterruptedException {
+ synchronized(monitor) {
+ for (;;) {
+ final T v = poll();
+ if (v != null) {
+ return v;
+ }
+ monitor.wait();
+ }
+ }
+ }
+
+ public void put(final T o) throws InterruptedException {
+ synchronized(monitor) {
+ for(;;) {
+ if (add(o)) {
+ return;
+ }
+ monitor.wait();
+ }
+ }
+ }
+
+ public int remainingCapacity() {
+ return Integer.MAX_VALUE;
+ }
+
+ public int drainTo(final Collection<? super T> c) {
+ if (c == this) {
+ throw new IllegalArgumentException("Attempt to drain queue to itself");
+ }
+ int cnt = 0;
+ synchronized(monitor) {
+ for (;;) {
+ T v = poll();
+ if (v == null) {
+ return cnt;
+ } else {
+ c.add(v);
+ cnt++;
+ }
+ }
+ }
+ }
+
+ public int drainTo(final Collection<? super T> c, final int maxElements) {
+ if (c == this) {
+ throw new IllegalArgumentException("Attempt to drain queue to itself");
+ }
+ int cnt = 0;
+ synchronized(monitor) {
+ for (;;) {
+ T v = poll();
+ if (v == null) {
+ return cnt;
+ } else {
+ c.add(v);
+ cnt++;
+ if (cnt == maxElements) {
+ return cnt;
+ }
+ }
+ }
+ }
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedSet.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/SynchronizedSet.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedSet.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/SynchronizedSet.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,17 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Set;
+
+/**
+ *
+ */
+public class SynchronizedSet<K> extends SynchronizedCollection<K> implements Set<K> {
+
+ public SynchronizedSet(final Set<K> delegate) {
+ super(delegate);
+ }
+
+ protected SynchronizedSet(final Set<K> delegate, final Object monitor) {
+ super(delegate, monitor);
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/TypeMap.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/TypeMap.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/TypeMap.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/TypeMap.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,45 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ */
+public interface TypeMap<B> {
+ void clear();
+
+ boolean containsKey(Class<?> key);
+
+ boolean containsValue(Object value);
+
+ Set<Entry<? extends B>> entrySet();
+
+ <T extends B> T get(Class<T> key);
+
+ boolean isEmpty();
+
+ Set<Class<? extends B>> keySet();
+
+ <T extends B> T put(Class<T> key, T value);
+
+ <T extends B> void putAll(TypeMap<T> m);
+
+ <T extends B> T remove(Class<T> key);
+
+ int size();
+
+ Collection<? extends B> values();
+
+ <T extends B> T putIfAbsent(Class<T> key, T value);
+
+ <T extends B> boolean remove(Class<T> key, Object value);
+
+ <T extends B> T replace(Class<T> key, T value);
+
+ <T extends B> boolean replace(Class<T> key, T oldValue, T newValue);
+
+ interface Entry<T> extends Map.Entry<Class<T>, T> {
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/UnmodifiableArrayList.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/UnmodifiableArrayList.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/UnmodifiableArrayList.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/UnmodifiableArrayList.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,143 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.AbstractList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+
+/**
+ *
+ */
+public final class UnmodifiableArrayList<T> extends AbstractList<T> implements List<T> {
+
+ private final Object[] entries;
+ private final int offs;
+ private final int length;
+
+ <T> UnmodifiableArrayList(final T[] entries) {
+ this.entries = entries;
+ offs = 0;
+ length = entries.length;
+ }
+
+ <T> UnmodifiableArrayList(final T[] entries, int offs, int length) {
+ if (offs > entries.length) {
+ throw new IndexOutOfBoundsException("Specified offset is greater than array length");
+ }
+ if (offs + length > entries.length) {
+ throw new IndexOutOfBoundsException("Specified offset + length is greater than array length");
+ }
+ this.entries = entries;
+ this.offs = offs;
+ this.length = length;
+ }
+
+ public int size() {
+ return length;
+ }
+
+ public boolean isEmpty() {
+ return length == 0;
+ }
+
+ public boolean contains(final Object o) {
+ for (int i = 0; i < length; i ++) {
+ final Object e = entries[i + offs];
+ if (o==null ? e==null : o.equals(e)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Iterator<T> iterator() {
+ return new ListIteratorImpl<T>();
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public T get(final int index) {
+ if (index >= length || index < 0) {
+ throw new IndexOutOfBoundsException("Invalid get() index: " + index + " (size is " + length + ")");
+ }
+ return (T) entries[offs + index];
+ }
+
+ public ListIterator<T> listIterator() {
+ return new ListIteratorImpl<T>();
+ }
+
+ public ListIterator<T> listIterator(final int index) {
+ return new ListIteratorImpl<T>(index);
+ }
+
+ public List<T> subList(final int fromIndex, final int toIndex) {
+ if (fromIndex < 0 || fromIndex > length) {
+ throw new IndexOutOfBoundsException("fromIndex " + fromIndex + " is not within the bounds of the list (size is " + length + ")");
+ }
+ if (toIndex < 0 || toIndex > length) {
+ throw new IndexOutOfBoundsException("toIndex " + toIndex + " is not within the bounds of the list (size is " + length + ")");
+ }
+ if (fromIndex > toIndex) {
+ throw new IllegalArgumentException("fromIndex " + fromIndex + " is greater than toIndex " + toIndex);
+ }
+ return new UnmodifiableArrayList<T>(entries, offs + fromIndex, toIndex - fromIndex);
+ }
+
+ public final class ListIteratorImpl<T> implements ListIterator<T> {
+ private int i;
+
+ private ListIteratorImpl(final int index) {
+ i = index;
+ }
+
+ private ListIteratorImpl() {
+ }
+
+ public boolean hasNext() {
+ return i < length;
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public T next() {
+ if (i < length) {
+ return (T) entries[offs + i++];
+ } else {
+ throw new NoSuchElementException("next() past end of iterator");
+ }
+ }
+
+ public boolean hasPrevious() {
+ return i > 0;
+ }
+
+ @SuppressWarnings ({"unchecked"})
+ public T previous() {
+ if (i > 0) {
+ return (T) entries[offs + i--];
+ } else {
+ throw new NoSuchElementException("next() past end of iterator");
+ }
+ }
+
+ public int nextIndex() {
+ return i;
+ }
+
+ public int previousIndex() {
+ return i - 1;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove() not allowed");
+ }
+
+ public void set(final T o) {
+ throw new UnsupportedOperationException("set() not allowed");
+ }
+
+ public void add(final T o) {
+ throw new UnsupportedOperationException("add() not allowed");
+ }
+ }
+}
Copied: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/WeakHashSet.java (from rev 3470, remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/WeakHashSet.java)
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/WeakHashSet.java (rev 0)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/util/WeakHashSet.java 2008-02-22 16:55:56 UTC (rev 3483)
@@ -0,0 +1,76 @@
+package org.jboss.cx.remoting.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+/**
+ *
+ */
+public final class WeakHashSet<T> implements Set<T> {
+ private final WeakHashMap<T,Void> map = new WeakHashMap<T,Void>();
+
+ public int size() {
+ return map.size();
+ }
+
+ public boolean isEmpty() {
+ return map.isEmpty();
+ }
+
+ public boolean contains(final Object o) {
+ return map.containsKey(o);
+ }
+
+ public Iterator<T> iterator() {
+ return map.keySet().iterator();
+ }
+
+ public Object[] toArray() {
+ return map.keySet().toArray();
+ }
+
+ public <T> T[] toArray(final T[] a) {
+ return map.keySet().toArray(a);
+ }
+
+ public boolean add(final T o) {
+ try {
+ return ! map.containsKey(o);
+ } finally {
+ map.put(o, null);
+ }
+ }
+
+ public boolean remove(final Object o) {
+ return map.keySet().remove(o);
+ }
+
+ public boolean containsAll(final Collection<?> c) {
+ return map.keySet().containsAll(c);
+ }
+
+ public boolean addAll(final Collection<? extends T> c) {
+ boolean changed = false;
+ for (T t : c) {
+ if (! map.containsKey(t)) {
+ changed = true;
+ map.put(t, null);
+ }
+ }
+ return changed;
+ }
+
+ public boolean retainAll(final Collection<?> c) {
+ return map.keySet().retainAll(c);
+ }
+
+ public boolean removeAll(final Collection<?> c) {
+ return map.keySet().removeAll(c);
+ }
+
+ public void clear() {
+ map.clear();
+ }
+}
16 years, 9 months
JBoss Remoting SVN: r3482 - in remoting3/trunk: util/src/main/java/org/jboss/cx/remoting/core/util and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: david.lloyd(a)jboss.com
Date: 2008-02-22 11:50:40 -0500 (Fri, 22 Feb 2008)
New Revision: 3482
Modified:
remoting3/trunk/build.xml
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/AttributeMap.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ByteInput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ByteOutput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/MessageInput.java
remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/MessageOutput.java
Log:
Javadoc updates
Modified: remoting3/trunk/build.xml
===================================================================
--- remoting3/trunk/build.xml 2008-02-22 09:53:09 UTC (rev 3481)
+++ remoting3/trunk/build.xml 2008-02-22 16:50:40 UTC (rev 3482)
@@ -1197,16 +1197,20 @@
<!-- JAVADOCS -->
<!-- ============================================== -->
- <target name="api-javadoc" depends="api,util">
+ <target name="api-javadoc" depends="api,core,log-jul,standalone,util">
<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">
<packageset dir="api/src/main/java"/>
<packageset dir="util/src/main/java"/>
+ <packageset dir="standalone/src/main/java"/>
<doctitle><![CDATA[<h1>JBoss Remoting 3</h1>]]></doctitle>
<bottom><![CDATA[<i>Copyright © 2008 JBoss, a division of Red Hat, Inc.</i>]]></bottom>
<link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
- <classpath location="util/target/main/classes"/>
+ <classpath>
+ <path refid="log-jul.classpath"/>
+ <path refid="core.classpath"/>
+ </classpath>
</javadoc>
</target>
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/AttributeMap.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/AttributeMap.java 2008-02-22 09:53:09 UTC (rev 3481)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/AttributeMap.java 2008-02-22 16:50:40 UTC (rev 3482)
@@ -4,43 +4,142 @@
import java.util.Set;
/**
- *
+ * A map whose value types are determined by the key.
*/
public interface AttributeMap {
+ /**
+ * Get a value from the map.
+ *
+ * @param key the key
+ * @return the value
+ */
<T> T get(AttributeKey<T> key);
+ /**
+ * Store a value into the map. Any previous mapping for this value is overwritten.
+ *
+ * @param key the key
+ * @param value the new value
+ * @return the old value (may be {@code null}), or {@code null} if there was no mapping for this key
+ */
<T> T put(AttributeKey<T> key, T value);
+ /**
+ * Remove a mapping from the map.
+ *
+ * @param key the key
+ * @return the old value (may be {@code null}), or {@code null} if there was no mapping for this key
+ */
<T> T remove(AttributeKey<T> key);
+ /**
+ * Remove a mapping from the map. Both the key and value must match the values given.
+ *
+ * @param key the key
+ * @param value the value
+ * @return {@code true} if a matching mapping was located and removed
+ */
<T> boolean remove(AttributeKey<T> key, T value);
+ /**
+ * Store a value into the map if there is no value currently stored.
+ *
+ * @param key the key
+ * @param value the value
+ * @return the old value if there was a previous mapping
+ */
<T> T putIfAbsent(AttributeKey<T> key, T value);
+ /**
+ * Replace a mapping in the map.
+ *
+ * @param key the key
+ * @param oldValue the old value
+ * @param newValue the replacement value
+ * @return {@code true} if a matching mapping was located and replaced
+ */
<T> boolean replace(AttributeKey<T> key, T oldValue, T newValue);
+ /**
+ * Test the map for the presence of a key.
+ *
+ * @param key the key
+ * @return {@code true} if the key is present in the map
+ */
<T> boolean containsKey(AttributeKey<T> key);
+ /**
+ * Test the map for the presence of a value.
+ *
+ * @param value the value
+ * @return {@code true} if the value is present in the map
+ */
<T> boolean containsValue(T value);
+ /**
+ * Get all the map entries.
+ *
+ * @return the entries
+ */
Iterable<Entry<?>> entries();
+ /**
+ * Get the key set for this map. The returned set supports all set operations except for {@code add} and {@code addAll}.
+ *
+ * @return the key set
+ */
Set<AttributeKey<?>> keySet();
+ /**
+ * Get the collection of values for this map.
+ *
+ * @return the values
+ */
Collection<?> values();
+ /**
+ * Determine whether this map is empty.
+ *
+ * @return {@code true} if the map has no mappings
+ */
boolean isEmpty();
+ /**
+ * Determine the number of entries in the map.
+ *
+ * @return the number of entries
+ */
int size();
+ /**
+ * Clear the map of all mappings.
+ */
void clear();
+ /**
+ * An entry in the {@code AttributeMap}.
+ */
interface Entry<T> {
+ /**
+ * Get the entry key.
+ *
+ * @return the key
+ */
AttributeKey<T> getKey();
+ /**
+ * Get the entry value.
+ *
+ * @return the value
+ */
T getValue();
+ /**
+ * Change the entry value.
+ *
+ * @param newValue the new value
+ */
void setValue(T newValue);
}
}
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ByteInput.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ByteInput.java 2008-02-22 09:53:09 UTC (rev 3481)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ByteInput.java 2008-02-22 16:50:40 UTC (rev 3482)
@@ -4,14 +4,41 @@
import java.io.IOException;
/**
- *
+ * A readable source of byte data.
*/
public interface ByteInput extends Closeable {
+ /**
+ * Read one byte.
+ *
+ * @return the byte, or -1 if the end of the stream has been reached.
+ * @throws IOException if an I/O error occurs
+ */
int read() throws IOException;
+ /**
+ * Read a series of bytes into an array.
+ *
+ * @param data the array into which data is to be read
+ * @return the total number of bytes read, or -1 if there are no bytes remaining to read
+ * @throws IOException if an I/O error occurs
+ */
int read(byte[] data) throws IOException;
+ /**
+ * Read a series of bytes into an array.
+ *
+ * @param data the array into which data is to be read
+ * @param offs the start offset in the {@code data} array at which the data is written
+ * @param len the maximum number of bytes to read
+ * @return the total number of bytes read, or -1 if there are no bytes remaining to read
+ * @throws IOException if an I/O error occurs
+ */
int read(byte[] data, int offs, int len) throws IOException;
+ /**
+ * Return the number of bytes remaining.
+ *
+ * @return the number of bytes, or -1 if the byte count cannot be determined
+ */
int remaining();
}
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ByteOutput.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ByteOutput.java 2008-02-22 09:53:09 UTC (rev 3481)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/ByteOutput.java 2008-02-22 16:50:40 UTC (rev 3482)
@@ -5,16 +5,48 @@
import java.io.IOException;
/**
- *
+ * A writable destination for byte data.
*/
public interface ByteOutput extends Closeable, Flushable {
+ /**
+ * Write a single byte of data. The input argument is truncated to 8 bits.
+ *
+ * @param b the byte to write
+ * @throws IOException if an I/O error occurs
+ */
void write(int b) throws IOException;
+ /**
+ * Write many bytes of data.
+ *
+ * @param b the bytes to write
+ * @throws IOException if an I/O error occurs
+ */
void write(byte[] b) throws IOException;
+ /**
+ * Write many bytes of data.
+ *
+ * @param b the bytes to write
+ * @param offs the offset in {@code b} to start reading bytes from
+ * @param len the number of bytes to write
+ * @throws IOException if an I/O error occurs
+ */
void write(byte[] b, int offs, int len) throws IOException;
+ /**
+ * Commit the written data. This causes the accumulated data to be sent as a message on the underlying
+ * channel.
+ *
+ * @throws IOException if an I/O error occurs
+ */
void commit() throws IOException;
+ /**
+ * Get a count of the number of bytes written to this message.
+ *
+ * @return the count
+ * @throws IOException if an I/O error occurs
+ */
int getBytesWritten() throws IOException;
}
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/MessageInput.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/MessageInput.java 2008-02-22 09:53:09 UTC (rev 3481)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/MessageInput.java 2008-02-22 16:50:40 UTC (rev 3482)
@@ -4,10 +4,26 @@
import java.io.ObjectInput;
/**
- *
+ * A readable message.
*/
public interface MessageInput extends ByteInput, ObjectInput {
+ /**
+ * Read an object using the current context classloader, or, if there is no such classloader, the classloader
+ * which loaded this interface.
+ *
+ * @return the object from the message
+ * @throws ClassNotFoundException if the class of the object could not be resolved by the classloader
+ * @throws IOException if an I/O error occurs
+ */
Object readObject() throws ClassNotFoundException, IOException;
+ /**
+ * Read an object using the given classloader.
+ *
+ * @param loader the classloader to use
+ * @return the object from the message
+ * @throws ClassNotFoundException if the class of the object could not be resolved by the classloader
+ * @throws IOException if an I/O error occurs
+ */
Object readObject(ClassLoader loader) throws ClassNotFoundException, IOException;
}
Modified: remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/MessageOutput.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/MessageOutput.java 2008-02-22 09:53:09 UTC (rev 3481)
+++ remoting3/trunk/util/src/main/java/org/jboss/cx/remoting/core/util/MessageOutput.java 2008-02-22 16:50:40 UTC (rev 3482)
@@ -3,7 +3,7 @@
import java.io.ObjectOutput;
/**
- *
+ * A writable message.
*/
public interface MessageOutput extends ByteOutput, ObjectOutput {
}
16 years, 9 months
JBoss Remoting SVN: r3481 - in remoting2/branches/2.x/src/etc/org/jboss: test and 3 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-22 04:53:09 -0500 (Fri, 22 Feb 2008)
New Revision: 3481
Added:
remoting2/branches/2.x/src/etc/org/jboss/test/
remoting2/branches/2.x/src/etc/org/jboss/test/remoting/
remoting2/branches/2.x/src/etc/org/jboss/test/remoting/classloader/
remoting2/branches/2.x/src/etc/org/jboss/test/remoting/classloader/race/
remoting2/branches/2.x/src/etc/org/jboss/test/remoting/classloader/race/TestObject.java
Log:
JBREM-900: Used in new unit tests.
Added: remoting2/branches/2.x/src/etc/org/jboss/test/remoting/classloader/race/TestObject.java
===================================================================
--- remoting2/branches/2.x/src/etc/org/jboss/test/remoting/classloader/race/TestObject.java (rev 0)
+++ remoting2/branches/2.x/src/etc/org/jboss/test/remoting/classloader/race/TestObject.java 2008-02-22 09:53:09 UTC (rev 3481)
@@ -0,0 +1,38 @@
+
+/*
+* 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.classloader.race;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 19, 2008
+ * </p>
+ */
+public class TestObject implements Serializable
+{
+}
+
16 years, 9 months
JBoss Remoting SVN: r3480 - remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/compress.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-22 04:51:58 -0500 (Fri, 22 Feb 2008)
New Revision: 3480
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/compress/CompressingUnMarshaller.java
Log:
JBREM-900: Eliminated direct reference to customClassLoader.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/compress/CompressingUnMarshaller.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/compress/CompressingUnMarshaller.java 2008-02-22 09:50:40 UTC (rev 3479)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/compress/CompressingUnMarshaller.java 2008-02-22 09:51:58 UTC (rev 3480)
@@ -105,7 +105,7 @@
GZIPInputStream gzis = new GZIPInputStream(inputStream);
BufferedInputStream bis = new BufferedInputStream(gzis);
SerializationManager manager = SerializationStreamFactory.getManagerInstance(getSerializationType());
- ObjectInputStream ois = manager.createInput(bis, customClassLoader);
+ ObjectInputStream ois = manager.createInput(bis, getClassLoader());
if(wrappedUnMarshaller != null)
{
16 years, 9 months
JBoss Remoting SVN: r3479 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/preferredstream.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-22 04:50:40 -0500 (Fri, 22 Feb 2008)
New Revision: 3479
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/preferredstream/TestUnMarshaller.java
Log:
JBREM-900: Eliminated direct reference to customClassLoader.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/preferredstream/TestUnMarshaller.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/preferredstream/TestUnMarshaller.java 2008-02-22 09:50:07 UTC (rev 3478)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/marshall/preferredstream/TestUnMarshaller.java 2008-02-22 09:50:40 UTC (rev 3479)
@@ -51,7 +51,7 @@
public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
{
SerializableUnMarshaller unmarshaller = new TestUnMarshaller();
- unmarshaller.setClassLoader(customClassLoader);
+ unmarshaller.setClassLoader(getClassLoader());
return unmarshaller;
}
}
16 years, 9 months
JBoss Remoting SVN: r3478 - in remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader: race and 4 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-22 04:50:07 -0500 (Fri, 22 Feb 2008)
New Revision: 3478
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/ClassloaderRaceTestParent.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/bisocket/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/bisocket/BisocketClassloaderRaceTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/http/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/http/HttpClassloaderRaceTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/rmi/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/rmi/RMIClassloaderRaceTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/socket/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/socket/SocketClassloaderRaceTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/test.jar
Log:
JBREM-900: New unit tests.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/ClassloaderRaceTestParent.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/ClassloaderRaceTestParent.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/ClassloaderRaceTestParent.java 2008-02-22 09:50:07 UTC (rev 3478)
@@ -0,0 +1,395 @@
+/*
+* 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.classloader.race;
+
+import java.lang.ref.WeakReference;
+import java.net.InetAddress;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ *
+ * Unit tests for JBREM-900.
+ *
+ * Note: The class org.jboss.test.remoting.classloader.race.TestObject mentioned
+ * in the tests below is found in
+ *
+ * <remoting home>/src/etc/org/jboss/test/remoting/classloader/race.
+ *
+ * It is loaded from
+ *
+ * <remoting home>/output/tests/classes/org/jboss/test/remoting/classloader/race/test.jar.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 19, 2008
+ * </p>
+ */
+public abstract class ClassloaderRaceTestParent extends TestCase
+{
+ private static Logger log = Logger.getLogger(ClassloaderRaceTestParent.class);
+
+ private static boolean firstTime = true;
+ protected static String metadata;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ metadata = System.getProperty("remoting.metadata", "serializationtype=java");
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+ public void testDirectClassloading() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ URL url = ClassloaderRaceTestParent.class.getResource("test.jar");
+ ClassLoader cl1 = new TestClassLoader(new URL[]{url});
+ Class c1 = cl1.loadClass("org.jboss.test.remoting.classloader.race.TestObject");
+ Object testObject1 = c1.newInstance();
+ log.info("classloader1: " + testObject1.getClass().getClassLoader());
+
+ ClassLoader cl2 = new TestClassLoader(new URL[]{url});
+ Class c2 = cl2.loadClass("org.jboss.test.remoting.classloader.race.TestObject");
+ Object testObject2 = c2.newInstance();
+ log.info("classloader2: " + testObject2.getClass().getClassLoader());
+
+ assertFalse(testObject1.getClass().isAssignableFrom(testObject2.getClass()));
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testSequential() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected to: " + locatorURI);
+
+ SimpleInvocationThread t1 = new SimpleInvocationThread(client, "InvocationThread:1");
+ t1.start();
+ t1.join();
+ SimpleInvocationThread t2 = new SimpleInvocationThread(client, "InvocationThread:2");
+ t2.start();
+ t2.join();
+
+ assertEquals(t1.getContextClassLoader(), t1.getResponseClassLoader());
+ assertEquals(t2.getContextClassLoader(), t2.getResponseClassLoader());
+ assertNotSame(t1.getResponseClassLoader(), t2.getResponseClassLoader());
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testSimultaneous() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected to: " + locatorURI);
+
+ int COUNT = 100;
+ log.info("COUNT: " + COUNT);
+ SynchronizedInvocationThread[] threads = new SynchronizedInvocationThread[COUNT];
+ Object lock = new Object();
+ URL url = ClassloaderRaceTestParent.class.getResource("test.jar");
+ ClassLoader cl1 = new TestClassLoader(new URL[]{url});
+ ClassLoader cl2 = new TestClassLoader(new URL[]{url});
+ log.info("classloader1: " + cl1);
+ log.info("classloader2: " + cl2);
+
+ // Create threads that use cl1.
+ for (int i = 0; i < COUNT / 2; i++)
+ {
+ threads[i] = new SynchronizedInvocationThread(client, cl1, i, lock);
+ threads[i].start();
+ }
+
+ // Create threads that use cl2.
+ for (int i = COUNT/2; i < COUNT; i++)
+ {
+ threads[i] = new SynchronizedInvocationThread(client, cl2, i, lock);
+ threads[i].start();
+ }
+
+ // Start threads.
+ Thread.sleep(2000);
+ synchronized (lock)
+ {
+ lock.notifyAll();
+ }
+
+ // Wait for all threads to complete.
+ for (int i = 0; i < COUNT; i++)
+ {
+ threads[i].join();
+ }
+
+ // Checks threads that use cl1.
+ for (int i = 0; i < COUNT / 2; i++)
+ {
+ assertEquals("error in thread " + i, cl1, threads[i].responseClassLoader);
+ }
+
+ // Check threads that use cl2.
+ for (int i = COUNT / 2; i < COUNT; i++)
+ {
+ assertEquals("error in thread " + i, cl2, threads[i].responseClassLoader);
+ }
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected abstract String getTransport();
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI += "/?" + metadata;
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ URL url = ClassloaderRaceTestParent.class.getResource("test.jar");
+ ClassLoader cl1 = new TestClassLoader(new URL[]{url});
+ Class c = cl1.loadClass("org.jboss.test.remoting.classloader.race.TestObject");
+ Object o = c.newInstance();
+ return o;
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ static class TestClassLoader extends URLClassLoader
+ {
+ public TestClassLoader(URL[] urls)
+ {
+ super(urls, null);
+ }
+
+ public Class findClass(String fqn) throws ClassNotFoundException
+ {
+ log.debug(this + " loading class: " + fqn);
+ Class c = super.findClass(fqn);
+ log.debug(this + " loaded class: " + fqn);
+ return c;
+ }
+ }
+
+
+ static class SimpleInvocationThread extends Thread
+ {
+ Client client;
+ String name;
+ ClassLoader contextClassLoader;
+ ClassLoader responseClassLoader;
+
+ public SimpleInvocationThread(Client client, String name)
+ {
+ this.client = client;
+ this.name = name;
+ }
+
+ public void run()
+ {
+ try
+ {
+ URL url = getClass().getResource("test.jar");
+ contextClassLoader = new TestClassLoader(new URL[]{url});
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ log.info(this + " context classloader: " + contextClassLoader);
+ Object response = client.invoke(name);
+ responseClassLoader = response.getClass().getClassLoader();
+ log.info(this + " response classloader: " + responseClassLoader);
+ }
+ catch (Throwable t)
+ {
+ log.error("unable to complete invocation", t);
+ }
+ }
+
+ public ClassLoader getContextClassLoader()
+ {
+ return contextClassLoader;
+ }
+
+ public ClassLoader getResponseClassLoader()
+ {
+ return responseClassLoader;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+ }
+
+
+ static class SynchronizedInvocationThread extends Thread
+ {
+ Client client;
+ String name;
+ ClassLoader contextClassLoader;
+ ClassLoader responseClassLoader;
+ Object lock;
+
+ public SynchronizedInvocationThread(Client client, ClassLoader classLoader,
+ int id, Object lock)
+ {
+ this.client = client;
+ this.contextClassLoader = classLoader;
+ this.name = "SynchronizedInvocationThread:" + id;
+ this.lock = lock;
+ }
+
+ public void run()
+ {
+ try
+ {
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+
+ synchronized (lock)
+ {
+ log.debug(this + " waiting");
+ lock.wait();
+ }
+
+ log.debug(this + " making invocation");
+ Object response = client.invoke(name);
+ responseClassLoader = response.getClass().getClassLoader();
+ log.debug(this + " done");
+ }
+ catch (Throwable t)
+ {
+ log.error("unable to complete invocation", t);
+ }
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+ }
+
+
+ static class Counter
+ {
+ public int count;
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/bisocket/BisocketClassloaderRaceTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/bisocket/BisocketClassloaderRaceTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/bisocket/BisocketClassloaderRaceTestCase.java 2008-02-22 09:50:07 UTC (rev 3478)
@@ -0,0 +1,56 @@
+/*
+* 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.classloader.race.bisocket;
+
+import org.jboss.test.remoting.classloader.race.ClassloaderRaceTestParent;
+
+/**
+ * Unit tests for JBREM-900. See parent class for details.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 22, 2008
+ * </p>
+ */
+public class BisocketClassloaderRaceTestCase extends ClassloaderRaceTestParent
+{
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+
+ public static void main(String[] args)
+ {
+ try
+ {
+ BisocketClassloaderRaceTestCase tc = new BisocketClassloaderRaceTestCase();
+ tc.setUp();
+ tc.testSequential();
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/http/HttpClassloaderRaceTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/http/HttpClassloaderRaceTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/http/HttpClassloaderRaceTestCase.java 2008-02-22 09:50:07 UTC (rev 3478)
@@ -0,0 +1,42 @@
+/*
+* 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.classloader.race.http;
+
+import org.jboss.test.remoting.classloader.race.ClassloaderRaceTestParent;
+
+/**
+ * Unit tests for JBREM-900. See parent class for details.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 22, 2008
+ * </p>
+ */
+public class HttpClassloaderRaceTestCase extends ClassloaderRaceTestParent
+{
+ protected String getTransport()
+ {
+ return "http";
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/rmi/RMIClassloaderRaceTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/rmi/RMIClassloaderRaceTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/rmi/RMIClassloaderRaceTestCase.java 2008-02-22 09:50:07 UTC (rev 3478)
@@ -0,0 +1,42 @@
+/*
+* 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.classloader.race.rmi;
+
+import org.jboss.test.remoting.classloader.race.ClassloaderRaceTestParent;
+
+/**
+ * Unit tests for JBREM-900. See parent class for details.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 22, 2008
+ * </p>
+ */
+public class RMIClassloaderRaceTestCase extends ClassloaderRaceTestParent
+{
+ protected String getTransport()
+ {
+ return "rmi";
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/socket/SocketClassloaderRaceTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/socket/SocketClassloaderRaceTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/socket/SocketClassloaderRaceTestCase.java 2008-02-22 09:50:07 UTC (rev 3478)
@@ -0,0 +1,42 @@
+/*
+* 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.classloader.race.socket;
+
+import org.jboss.test.remoting.classloader.race.ClassloaderRaceTestParent;
+
+/**
+ * Unit tests for JBREM-900. See parent class for details.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 22, 2008
+ * </p>
+ */
+public class SocketClassloaderRaceTestCase extends ClassloaderRaceTestParent
+{
+ protected String getTransport()
+ {
+ return "socket";
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/test.jar
===================================================================
(Binary files differ)
Property changes on: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/classloader/race/test.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 9 months
JBoss Remoting SVN: r3477 - remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-22 04:48:06 -0500 (Fri, 22 Feb 2008)
New Revision: 3477
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java
Log:
JBREM-900: receiveObject() always update object stream's classloader.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java 2008-02-22 09:45:44 UTC (rev 3476)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.java 2008-02-22 09:48:06 UTC (rev 3477)
@@ -97,18 +97,12 @@
Object obj = null;
if (inputStream instanceof ObjectInputStreamWithClassLoader)
{
- if (((ObjectInputStreamWithClassLoader) inputStream).getClassLoader() == null)
- {
- ((ObjectInputStreamWithClassLoader) inputStream).setClassLoader(customClassLoader);
- }
+ ((ObjectInputStreamWithClassLoader) inputStream).setClassLoader(customClassLoader);
objInputStream = (ObjectInputStream) inputStream;
}
else if (inputStream instanceof JBossObjectInputStream)
{
- if (((JBossObjectInputStream) inputStream).getClassLoader() == null)
- {
- ((JBossObjectInputStream) inputStream).setClassLoader(customClassLoader);
- }
+ ((JBossObjectInputStream) inputStream).setClassLoader(customClassLoader);
objInputStream = (ObjectInputStream) inputStream;
}
else if (inputStream instanceof ObjectInputStream)
16 years, 9 months