KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > core > modules > snmp > SNMPAgentConnectionFactory


1 /**
2 * Copyright (c) 2004-2005 jManage.org
3 *
4 * This is a free software; you can redistribute it and/or
5 * modify it under the terms of the license at
6 * http://www.jmanage.org.
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */

14 package org.jmanage.core.modules.snmp;
15
16 import org.jmanage.core.management.ServerConnectionFactory;
17 import org.jmanage.core.management.ServerConnection;
18 import org.jmanage.core.management.ConnectionFailedException;
19 import org.jmanage.core.config.ApplicationConfig;
20 import snmp.SNMPv1CommunicationInterface;
21
22 import java.net.InetAddress JavaDoc;
23
24 /**
25  * @author shashank
26  * Date: Jul 31, 2005
27  */

28 public class SNMPAgentConnectionFactory implements ServerConnectionFactory{
29
30     /**
31      *
32      * @param config
33      * @return
34      * @throws ConnectionFailedException
35      */

36     public ServerConnection getServerConnection(ApplicationConfig config)
37             throws ConnectionFailedException {
38         try{
39             InetAddress JavaDoc hostAddress = InetAddress.getByName(config.getHost());
40             SNMPv1CommunicationInterface commIntf =
41                     new SNMPv1CommunicationInterface(1, hostAddress, "public",
42                             config.getPort().intValue());
43             SNMPAgentConnection connection = new SNMPAgentConnection(commIntf);
44             return connection;
45         }catch(Throwable JavaDoc e){
46             throw new ConnectionFailedException(e);
47         }
48     }
49 }
50
Popular Tags