1    //
2    // SwitchRMI  Framework
3    // Copyright (c) 2000-2002 by Michael J. Henderson & Associates.
4    //
5    // Michael Henderson
6    // mailto:mikehenderson@dunelm.org.uk
7    //
8    // This library is free software.
9    //
10   // You may redistribute it and/or modify it under the terms of the GNU
11   // Lesser General Public License as published by the Free Software Foundation.
12   //
13   // Version 2.1 of the license should be included with this distribution in
14   // the file LICENSE, as well as License.html. If the license is not
15   // included with this distribution, you may find a copy at the FSF web
16   // site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
17   // Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.
18   //
19   // This library is distributed in the hope that it will be useful,
20   // but WITHOUT ANY WARRANTY; without even the implied waranty of
21   // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22   // Lesser General Public License for more details.
23   //
24   // $Id: RmiTransportBase.java,v 1.1 2002/11/11 22:19:48 mikehenderson Exp $
25   package com.mjh.switchrmi;
26   
27   import com.mjh.util.UrlInfo;
28   
29   import java.io.*;
30   
31   import java.net.*;
32   
33   import org.apache.log4j.Logger;
34   
35   /**
36    * @author michaelh
37    *
38    * To change this generated comment edit the template variable "typecomment":
39    * Window>Preferences>Java>Templates.
40    * To enable and disable the creation of type comments go to
41    * Window>Preferences>Java>Code Generation.
42    */
43   public abstract class RmiTransportBase
44       implements RmiTransport
45   {
46       private static final Logger log = 
47               Logger.getLogger(RmiTransportBase.class.getName());
48       private String mimeType;
49       private String targetUrl;
50       private String transportType = RmiTransport.SYNCHRONOUS;
51       private String transportName = "unknown";
52       private Object sessionID;
53   
54       /**
55        * Constructor for RmiTransportBase.
56        */
57       public RmiTransportBase()
58       {
59       }
60   
61       protected void setName(String name)
62       {
63           transportName = name;
64       }
65   
66       public String getUrl()
67       {
68           return targetUrl;
69       }
70   
71       public void setUrl(String url)
72       {
73           targetUrl = url;
74       }
75   
76       public UrlInfo getUrlInfo(RmiContext context)
77                          throws MalformedURLException
78       {
79           return new UrlInfo(context.getUrl());
80       }
81   
82       public String getName()
83       {
84           return transportName;
85       }
86   
87       /**
88        * @see com.mjh.switchrmi.RmiTransport#getType()
89        */
90       public String getType()
91       {
92           return transportType;
93       }
94   
95       public void setType(String type)
96       {
97           transportType = type;
98   
99           // should check it is one of the allowed types and throw exception
100      }
101  
102      public void setSessionIdentifier(Object identifier)
103      {
104          sessionID = identifier;
105      }
106  
107      public Object getSessionIdentifier()
108      {
109          return sessionID;
110      }
111  
112      /**
113       * @see com.mjh.switchrmi.RmiTransport#getInputStream()
114       */
115      public InputStream getInputStream(RmiContext context)
116          throws IOException
117      {
118          return null;
119      }
120  
121      /**
122       * @see com.mjh.switchrmi.RmiTransport#getOutputStream()
123       */
124      public OutputStream getOutputStream(RmiContext context)
125          throws IOException
126      {
127          return null;
128      }
129  
130      /**
131       * @see com.mjh.switchrmi.RmiTransport#send()
132       */
133      public void send(RmiContext context)
134                throws Exception
135      {
136      }
137  
138      /**
139       * @see com.mjh.switchrmi.RmiTransport#recv()
140       */
141      public void recv(RmiContext context)
142                throws Exception
143      {
144      }
145  
146      private void debug(String msg)
147      {
148          log.debug(msg);
149      }
150  }