KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > agent > client > networkplaces > NetworkPlaceManager


1 package com.sslexplorer.agent.client.networkplaces;
2
3 import java.io.IOException JavaDoc;
4
5 import com.maverick.multiplex.Request;
6 import com.maverick.util.ByteArrayReader;
7 import com.maverick.util.ByteArrayWriter;
8 import com.sslexplorer.agent.client.AbstractResourceManager;
9 import com.sslexplorer.agent.client.Agent;
10
11 /**
12  * This class manages network places allowing them to be launched from the agent.
13  *
14  * @author Lee David Painter
15  *
16  */

17 public class NetworkPlaceManager extends AbstractResourceManager {
18
19
20     // #ifdef DEBUG
21
static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(NetworkPlaceManager.class);
22     // #endif
23

24     /**
25      * Network pplace resource type ID
26      */

27     public final static int NETWORK_PLACE_RESOURCE_TYPE_ID = 2;
28     
29     /**
30      * Setup and launch web forward
31      */

32     public static final String JavaDoc SETUP_AND_LAUNCH_NETWORK_PLACE = "setupAndLaunchNetworkPlace@3sp.com"; //$NON-NLS-1$
33

34     public NetworkPlaceManager(Agent agent) {
35         super(agent);
36     }
37
38     public void getNetworkPlaceResources() {
39         super.getResources(NETWORK_PLACE_RESOURCE_TYPE_ID, "Network Places");
40     }
41
42     public void launchResource(int resourceId) {
43         try {
44             ByteArrayWriter baw = new ByteArrayWriter();
45             baw.writeInt(resourceId);
46             Request request = new Request(SETUP_AND_LAUNCH_NETWORK_PLACE, baw.toByteArray());
47             if (agent.getConnection().sendRequest(request, true) && request.getRequestData()!=null) {
48                 ByteArrayReader bar = new ByteArrayReader(request.getRequestData());
49                 String JavaDoc uri = bar.readString();
50                 agent.getGUI().openBrowser(uri);
51                 // #ifdef DEBUG
52
log.debug("Network place setup");
53                 // #endif
54
// processLaunchRequest(request);
55
} else {
56                 // #ifdef DEBUG
57
log.error("Failed to setup and launch network place");
58                 // #endif
59
}
60         } catch (IOException JavaDoc e) {
61             // #ifdef DEBUG
62
log.error("Failed to setup and launch network place", e);
63             // #endif
64
}
65     }
66 }
67
Popular Tags