KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > agent > AgentExtensionDefinition


1 package com.sslexplorer.agent;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 import org.jdom.Element;
7
8 import com.sslexplorer.extensions.ExtensionDescriptor;
9
10 /**
11  * Defines everything the server needs to know about an <i>Agent Extension</i>.
12  * <p>
13  * The <i>SSL-Explorer Agent may be extended using <i>Agent Extensions</i>. These
14  * are simply additional classes with an optional <b>className</b> that points to
15  * a class that gets initialised when the extension is loaded.
16  * <p>
17  * Agent extensions that require 3rd party libraries may add additional elements
18  * to the classpath using {@link #addClassPath(String)}.
19  * <p>
20  * Agent extensions may add additional JVM arguments that will be used when the
21  * agent is started using {@link #addJVMArgument(String)}.
22  * <p>
23  * Before an extension will work, the server calls the
24  * appropriate {@link AgentExtensionVerifier#verifyAccess(String, com.sslexplorer.security.User)}.
25  *
26  * @author Lee David Painter <a HREF="mailto:lee@3sp.com">&lt;lee@3sp.com&gt;</a>
27  * @see AgentExtensionVerifier
28  */

29 public class AgentExtensionDefinition {
30
31     // Private instance variables
32

33     private ExtensionDescriptor descriptor;
34     private String JavaDoc className;
35     private List JavaDoc classPath = new ArrayList JavaDoc();
36     private List JavaDoc jvmArgs = new ArrayList JavaDoc();
37     private String JavaDoc plugin;
38     private Element agentXML;
39     
40     /**
41      * Constructor.
42      *
43      * @param descriptor descriptor this extension is attached to
44      * @param className class to load or <code>null</code> if this extension just adds new resources to the classpath
45      * @param plugin the plugin the extension is attached to
46      */

47     public AgentExtensionDefinition(ExtensionDescriptor descriptor, String JavaDoc className, String JavaDoc plugin, Element agentXML) {
48         this.descriptor = descriptor;
49         this.className = className;
50         this.plugin = plugin;
51         agentXML.detach();
52         this.agentXML = agentXML;
53     }
54     
55     public Element getAgentXML() {
56         return agentXML;
57     }
58     
59     /**
60      * Get the ID of the plugin this extension is attached to.
61      *
62      * @return plugin id
63      */

64     public String JavaDoc getPlugin() {
65         return plugin;
66     }
67     
68     /**
69      * Get the Id of the descriptor this extension is attached to.
70      *
71      * @return plugin id
72      */

73     public String JavaDoc getName() {
74         return descriptor.getId();
75     }
76     
77     /**
78      * Get the extension descriptor this agent extension is attached to.
79      *
80      * @return extension descriptor.
81      */

82     public ExtensionDescriptor getDescriptor() {
83         return descriptor;
84     }
85     
86     /**
87      * Get the classname the agent should initialise when the extension is
88      * loaded. This may be <code>null</code> if the extension simply adds more
89      * resources to the classpath (e.g. Language Packs).
90      *
91      * @return classname of class to initialise on agent startup
92      */

93     public String JavaDoc getClassName() {
94         return className;
95     }
96     
97     /**
98      * Get a list of {@link String} objects detailing the classpath
99      *
100      * @return classpath
101      */

102     public List JavaDoc getClassPath() {
103         return classPath;
104     }
105     
106     /**
107      * Add a new element to the classpath
108      * @param jarfile
109      */

110     public void addClassPath(String JavaDoc jarfile) {
111         classPath.add(jarfile);
112     }
113     
114     /**
115      * Add an additional JVM argument to be used when the agent is started.
116      *
117      * @param arg JVM argument
118      */

119     public void addJVMArgument(String JavaDoc arg) {
120         jvmArgs.add(arg);
121     }
122     
123     /**
124      * Get a list of {@link String} objects details additional JVM arguments that
125      * must be used when the agent is launched.
126      *
127      * @return jvm arguments
128      */

129     public List JavaDoc getJVMArguments() {
130         return jvmArgs;
131     }
132
133 }
Popular Tags