[jboss-remoting-commits] JBoss Remoting SVN: r6105 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Wed Sep 15 18:12:25 EDT 2010


Author: ron.sigal at jboss.com
Date: 2010-09-15 18:12:24 -0400 (Wed, 15 Sep 2010)
New Revision: 6105

Added:
   remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/RemoteClassTableWrapper.java
Log:
JBREM-1228: Wrapper used by RemoteClassTableTestCase.

Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/RemoteClassTableWrapper.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/RemoteClassTableWrapper.java	                        (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/RemoteClassTableWrapper.java	2010-09-15 22:12:24 UTC (rev 6105)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3;
+
+import java.io.IOException;
+
+import org.jboss.marshalling.ClassTable;
+import org.jboss.marshalling.Unmarshaller;
+import org.jboss.remoting3.service.classtable.ClassLookupRequest;
+import org.jboss.remoting3.service.classtable.ClassLookupResponse;
+import org.jboss.remoting3.test.RemoteClassTableTestCase;
+import org.jboss.xnio.OptionMap;
+import org.jboss.xnio.log.Logger;
+
+/**
+ *
+ * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ *
+ * Copyright Sep 8, 2010
+ */
+public class RemoteClassTableWrapper implements ClassTable {
+   public int classesWritten;
+   public int classesRead;
+   public Writer savedWriter;
+   public boolean writerMatches;
+   public int remoteResolutions;
+
+   private static final Logger log = Logger.getLogger(RemoteClassTableTestCase.class);
+
+   private RemoteClassTable remoteClassTable;
+
+   public RemoteClassTableWrapper(final Client<ClassLookupRequest, ClassLookupResponse> resolver) {
+      remoteClassTable = new RemoteClassTable(resolver);
+   }
+
+   public RemoteClassTableWrapper() {
+      remoteClassTable = new RemoteClassTable();      
+   }
+
+   public Writer getClassWriter(Class<?> clazz) throws IOException {
+      Writer writer = remoteClassTable.getClassWriter(clazz);
+      if(classesWritten++ == 0) {
+         savedWriter = writer;
+      } else {
+         writerMatches = (writer == savedWriter);
+      }
+      log.info(this + " returning " + writer);
+      return writer;
+   }
+
+   public Class<?> readClass(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException {
+      Class<?> clazz = remoteClassTable.readClass(unmarshaller);
+      classesRead++;
+      log.info(this + " returning " + clazz);
+      return clazz;
+   }
+
+   public ClientListener<ClassLookupRequest, ClassLookupResponse> getClientListener() {
+      return new RctClientListenerWrapper();
+   }
+
+   private class RctClientListenerWrapper implements ClientListener<ClassLookupRequest, ClassLookupResponse> {
+      public RequestListener<ClassLookupRequest, ClassLookupResponse> handleClientOpen(final ClientContext clientContext, final OptionMap optionMap) {
+         return new RctRequestListenerWrapper(remoteClassTable.getClientListener().handleClientOpen(clientContext, optionMap));
+      }
+   }
+   
+   private class RctRequestListenerWrapper implements RequestListener<ClassLookupRequest, ClassLookupResponse> {
+      private RequestListener<ClassLookupRequest, ClassLookupResponse> rctRequestListener;
+      
+      public RctRequestListenerWrapper(RequestListener<ClassLookupRequest, ClassLookupResponse> rctRequestListener) {
+         remoteResolutions++;
+         this.rctRequestListener = rctRequestListener;
+      }
+      
+      public void handleRequest(final RequestContext<ClassLookupResponse> requestContext, final ClassLookupRequest request) throws RemoteExecutionException {
+         rctRequestListener.handleRequest(requestContext, request);
+      }
+  }
+}



More information about the jboss-remoting-commits mailing list