KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > remoting > transport > mock > MockClientInvoker


1 /***************************************
2  * *
3  * JBoss: The OpenSource J2EE WebOS *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  ***************************************/

9 package org.jboss.test.remoting.transport.mock;
10
11 import java.io.IOException JavaDoc;
12 import java.util.Map JavaDoc;
13 import org.jboss.remoting.ConnectionFailedException;
14 import org.jboss.remoting.InvokerLocator;
15 import org.jboss.remoting.RemoteClientInvoker;
16 import org.jboss.remoting.marshal.Marshaller;
17 import org.jboss.remoting.marshal.UnMarshaller;
18
19 /**
20  * MockClientInvoker
21  *
22  * @author <a HREF="mailto:jhaynie@vocalocity.net">Jeff Haynie</a>
23  * @version $Revision: 1.1 $
24  */

25 public class MockClientInvoker extends RemoteClientInvoker
26 {
27    private final MockServerInvoker server;
28    private boolean loaded = false;
29
30    public MockClientInvoker(InvokerLocator locator, MockServerInvoker server)
31    {
32       super(locator);
33       this.server = server;
34    }
35
36    /**
37     * subclasses must implement this method to provide a hook to connect to the remote server, if this applies
38     * to the specific transport. However, in some transport implementations, this may not make must difference since
39     * the connection is not persistent among invocations, such as SOAP. In these cases, the method should
40     * silently return without any processing.
41     *
42     * @throws ConnectionFailedException
43     */

44    protected void handleConnect()
45          throws ConnectionFailedException
46    {
47    }
48
49    /**
50     * subclasses must implement this method to provide a hook to disconnect from the remote server, if this applies
51     * to the specific transport. However, in some transport implementations, this may not make must difference since
52     * the connection is not persistent among invocations, such as SOAP. In these cases, the method should
53     * silently return without any processing.
54     */

55    protected void handleDisconnect()
56    {
57    }
58
59
60    public void connect()
61          throws ConnectionFailedException
62    {
63    }
64
65    public void disconnect()
66    {
67    }
68
69    protected String JavaDoc getDefaultDataType()
70    {
71       return null;
72    }
73
74    public boolean isConnected()
75    {
76       return false;
77    }
78
79    protected Object JavaDoc transport(String JavaDoc sessionId, Object JavaDoc invocation, Map JavaDoc metadata, Marshaller marshaller, UnMarshaller unmarshaller)
80          throws IOException JavaDoc, ConnectionFailedException
81    {
82       return server.invoke(invocation);
83    }
84 }
85
Popular Tags