KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > TransportMapping


1 /*_############################################################################
2   _##
3   _## SNMP4J - TransportMapping.java
4   _##
5   _## Copyright 2003-2007 Frank Fock and Jochen Katz (SNMP4J.org)
6   _##
7   _## Licensed under the Apache License, Version 2.0 (the "License");
8   _## you may not use this file except in compliance with the License.
9   _## You may obtain a copy of the License at
10   _##
11   _## http://www.apache.org/licenses/LICENSE-2.0
12   _##
13   _## Unless required by applicable law or agreed to in writing, software
14   _## distributed under the License is distributed on an "AS IS" BASIS,
15   _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   _## See the License for the specific language governing permissions and
17   _## limitations under the License.
18   _##
19   _##########################################################################*/

20
21
22
23 package org.snmp4j;
24
25 import java.io.IOException JavaDoc;
26 import org.snmp4j.smi.Address;
27 import org.snmp4j.transport.TransportListener;
28
29 /**
30  * The <code>TransportMapping</code> defines the common interface for SNMP
31  * transport mappings. A transport mapping can only support a single
32  * transport protocol.
33  *
34  * @author Frank Fock
35  * @version 1.6
36  */

37 public interface TransportMapping {
38
39   /**
40    * Gets the <code>Address</code> class that is this transport mapping
41    * supports.
42    * @return
43    * a subclass of {@link Address}.
44    */

45   Class JavaDoc getSupportedAddressClass();
46
47   /**
48    * Returns the address that represents the incoming address this transport
49    * mapping uses to listen for incoming packets.
50    *
51    * @return
52    * the address for incoming packets or <code>null</code> this transport
53    * mapping is not configured to listen for incoming packets.
54    * @since 1.6
55    */

56   Address getListenAddress();
57
58   /**
59    * Sends a message to the supplied address using this transport.
60    * @param address
61    * an <code>Address</code> instance denoting the target address.
62    * @param message
63    * the whole message as an array of bytes.
64    * @throws IOException
65    */

66   void sendMessage(Address address, byte[] message) throws IOException JavaDoc;
67
68   /**
69    * Adds a message dispatcher to the transport. Normally, at least one
70    * message dispatcher needs to be added to process responses (or requests).
71    * @param dispatcher
72    * a MessageDispatcher instance.
73    * @see MessageDispatcherImpl
74    * @deprecated
75    * Use {@link #addTransportListener} instead. This method has
76    * been deprecated because the direct coupling between MessageDispatcher
77    * and TransportMappings is not flexible enough and prevents reusing
78    * TransportMappings for other purposes. This method will be removed
79    * with SNMP4J 2.0.
80    */

81   void addMessageDispatcher(MessageDispatcher dispatcher);
82
83   /**
84    * Removes a message dispatcher. Incoming messages will no longer be
85    * propagated to the supplied message dispatcher.
86    * @param dispatcher
87    * a previously added MessageDispatcher instance.
88    * @see #addMessageDispatcher
89    * @deprecated
90    * Use {@link #removeTransportListener} instead.
91    */

92   void removeMessageDispatcher(MessageDispatcher dispatcher);
93
94   /**
95    * Adds a transport listener to the transport. Normally, at least one
96    * transport listener needs to be added to process incoming messages.
97    * @param transportListener
98    * a <code>TransportListener</code> instance.
99    * @since 1.6
100    */

101   void addTransportListener(TransportListener transportListener);
102
103   /**
104    * Removes a transport listener. Incoming messages will no longer be
105    * propagated to the supplied <code>TransportListener</code>.
106    * @param transportListener
107    * a <code>TransportListener</code> instance.
108    * @since 1.6
109    */

110   void removeTransportListener(TransportListener transportListener);
111
112   /**
113    * Closes the transport an releases all bound resources synchronously.
114    * @throws IOException
115    */

116   void close() throws IOException JavaDoc;
117
118   /**
119    * Listen for incoming messages. For connection oriented transports, this
120    * method needs to be called before {@link #sendMessage} is called for the
121    * first time.
122    * @throws IOException
123    */

124   void listen() throws IOException JavaDoc;
125
126   /**
127    * Returns <code>true</code> if the transport mapping is listening for
128    * incoming messages. For connection oriented transport mappings this
129    * is a prerequisite to be able to send SNMP messages. For connectionless
130    * transport mappings it is a prerequisite to be able to receive responses.
131    * @return
132    * <code>true</code> if this transport mapping is listening for messages.
133    * @since 1.1
134    */

135   boolean isListening();
136
137   /**
138    * Gets the maximum length of an incoming message that can be successfully
139    * processed by this transport mapping implementation.
140    * @return
141    * an integer > 484.
142    */

143   int getMaxInboundMessageSize();
144 }
145
146
Popular Tags