001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)ComponentInfoImpl.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.management.registry.data;
030:
031: import com.sun.jbi.ComponentState;
032: import com.sun.jbi.ComponentType;
033: import com.sun.jbi.ServiceUnitInfo;
034: import com.sun.jbi.management.ComponentInfo;
035:
036: import java.util.ArrayList;
037: import java.util.HashMap;
038: import java.util.List;
039: import java.util.Map;
040: import java.util.Properties;
041: import java.util.Set;
042:
043: /**
044: * This interface provides information on components (Binding Components,
045: * Service Engines, and Shared Libraries.
046: *
047: * @author Sun Microsystems, Inc.
048: */
049: public class ComponentInfoImpl implements ComponentInfo {
050: private List<String> mClassPathElements;
051: private String mComponentClassName;
052: private ComponentType mComponentType;
053: private ComponentState mComponentState;
054: private String mDescription;
055: private String mInstallRoot;
056: private String mWorkspaceRoot;
057: private String mName;
058: private String mJbiXmlString;
059: private List<String> mSharedLibraryNames;
060: private boolean mIsClassLoaderSelfFirst;
061: private boolean mIsBootstrapClassLoaderSelfFirst;
062: private Map<String, String> mProps;
063: private List<ServiceUnitInfo> mServiceUnitList;
064: private String mBootstrapClassName;
065: private List<String> mBootstrapClassPathElements;
066: private long mTimestamp;
067: private int mUpgradeNumber;
068:
069: // Component Configuration
070: private Variable[] mEnvVars;
071: private Properties mConfigs;
072: private Map<String, Properties> mApplicationConfigs;
073:
074: /**
075: * Determine if the supplied Object is equal to this one.
076: * @param object - the Object to be compared with this one.
077: * @return true if the supplied Object is equal to this one.
078: */
079: public boolean equals(Object object) {
080: return (object.hashCode() == this .hashCode());
081: }
082:
083: /**
084: * Get the class path elements. For BCs and SEs this is the list of elements
085: * that comprise the runtime class path; for Shared Libraries it is the list
086: * of elements that comprise the shared class path. Each element in the list
087: * is a String representing a single jar file or directory.
088: * @return List of jar files and directories that comprise the class path
089: * for the component or shared library.
090: */
091: public List getClassPathElements() {
092: if (mClassPathElements == null) {
093: mClassPathElements = new ArrayList();
094: }
095: return mClassPathElements;
096: }
097:
098: public void setClassPathElements(List<String> elements) {
099: mClassPathElements = elements;
100: }
101:
102: public void addClassPathElement(String element) {
103: getClassPathElements().add(element);
104: }
105:
106: /**
107: * Get the component class name. For BCs and SEs this is the name of
108: * the class that implements the
109: * <CODE>javax.jbi.component.Component</CODE>
110: * interface; for Shared Libraries it is null.
111: * @return the name of the Component class.
112: */
113: public String getComponentClassName() {
114: return mComponentClassName;
115: }
116:
117: public void setComponentClassName(String className) {
118: mComponentClassName = className;
119: }
120:
121: /**
122: * Get the component type.
123: * @return the component type: ComponentInfo.BINDING, ComponentInfo.ENGINE,
124: * or ComponentInfo.SHARED_LIBRARY.
125: */
126: public ComponentType getComponentType() {
127: return mComponentType;
128: }
129:
130: public void setComponentType(ComponentType type) {
131: mComponentType = type;
132: }
133:
134: /**
135: * Get the description of the component.
136: * @return the String describing the component.
137: */
138: public String getDescription() {
139: return mDescription;
140: }
141:
142: public void setDescription(String descr) {
143: mDescription = descr;
144: }
145:
146: /**
147: * Get the directory into which this component is installed.
148: * @return the directory into which this component is installed.
149: */
150: public String getInstallRoot() {
151: return mInstallRoot;
152: }
153:
154: public void setInstallRoot(String installRoot) {
155: mInstallRoot = installRoot;
156: }
157:
158: /**
159: * Get the workspace for the component
160: * @return this components workspace directory.
161: */
162: public String getWorkspaceRoot() {
163: return mWorkspaceRoot;
164: }
165:
166: public void setWorkspaceRoot(String workspaceRoot) {
167: mWorkspaceRoot = workspaceRoot;
168: }
169:
170: /**
171: * Get the name of the component.
172: * @return the name of the component.
173: */
174: public String getName() {
175: return mName;
176: }
177:
178: public void setName(String name) {
179: mName = name;
180: }
181:
182: /**
183: * Get the timestamp associated with archive.
184: * @return the timestamp of the archive.
185: */
186: public long getTimestamp() {
187: return (mTimestamp);
188: }
189:
190: public void setTimestamp(long timestamp) {
191: mTimestamp = timestamp;
192: }
193:
194: /**
195: * Get the grade associated with a component.
196: * @return the upgrade number of the component.
197: */
198: public long getUpgradeNumber() {
199: return (mUpgradeNumber);
200: }
201:
202: public void setUpgradeNumber(int upgradeNumber) {
203: mUpgradeNumber = upgradeNumber;
204: }
205:
206: /**
207: * Get the list of ServiceUnitInfo objects representing all the SUs that
208: * are currently deployed to this component; for Shared Libraries this is
209: * null.
210: * @return List of ServiceUnitInfo objects.
211: */
212: public List getServiceUnitList() {
213: if (mServiceUnitList == null) {
214: mServiceUnitList = new ArrayList();
215: }
216: return mServiceUnitList;
217: }
218:
219: public void setServiceUnitList(List<ServiceUnitInfo> list) {
220: mServiceUnitList = list;
221: }
222:
223: public void addServiceUnitInfo(ServiceUnitInfo suInfo) {
224: getServiceUnitList().add(suInfo);
225: }
226:
227: /**
228: * Get the list of Shared Libraries required by this component. For BCs
229: * and SEs, this is the list of Shared Library names in the order that they
230: * appear in the class loader chain; for Shared Libraries this is null.
231: * @return List of Strings containing Shared Library names.
232: */
233: public List getSharedLibraryNames() {
234: if (mSharedLibraryNames == null) {
235: mSharedLibraryNames = new ArrayList();
236: }
237: return mSharedLibraryNames;
238:
239: }
240:
241: public void setSharedLibraryNames(List<String> list) {
242: mSharedLibraryNames = list;
243: }
244:
245: public void addSharedLibrary(String sharedLibraryName) {
246: getSharedLibraryNames().add(sharedLibraryName);
247: }
248:
249: /**
250: * Get the Status of the Component. For Shared Libraries this is always
251: * SHUTDOWN.
252: * @return should be of the values: LOADED, SHUTDOWN, STOPPED and STARTED
253: */
254: public ComponentState getStatus() {
255: return mComponentState;
256: }
257:
258: public void setStatus(ComponentState state) {
259: mComponentState = state;
260: }
261:
262: /**
263: * Get a hash code for this ComponentInfo.
264: * @return the hash code for the object.
265: */
266: public int hashCode() {
267: // --- See what all Mark W. uses
268: return 0;
269: }
270:
271: /**
272: * Get the installation specific properties for the component.
273: *
274: * @return a Map of the properties
275: */
276: public Map getProperties() {
277: if (mProps == null) {
278: mProps = new HashMap();
279: }
280: return mProps;
281: }
282:
283: public void setProperty(String key, String value) {
284: getProperties().put(key, value);
285: }
286:
287: /**
288: * @return true/false depending on the value of the bootstrapClassLoaderSelfFirst
289: * attribute. This method returns false for shared libraries.
290: */
291: public boolean isBootstrapClassLoaderSelfFirst() {
292: return mIsBootstrapClassLoaderSelfFirst;
293: }
294:
295: public void setBootstrapClassLoaderSelfFirst(boolean flag) {
296: mIsBootstrapClassLoaderSelfFirst = flag;
297: }
298:
299: /**
300: * @return true/false depending on the value of the {Component}ClassLoaderSelfFirst
301: * attribute.
302: */
303: public boolean isClassLoaderSelfFirst() {
304: return mIsClassLoaderSelfFirst;
305: }
306:
307: public void setClassLoaderSelfFirst(boolean flag) {
308: mIsClassLoaderSelfFirst = flag;
309: }
310:
311: /**
312: * Get the class path elements that this BC or SE needs in its bootstrap
313: * runtime environment.
314: * @return A list of the elements of the bootstrap class path as strings.
315: */
316: public java.util.List getBootstrapClassPathElements() {
317: if (mBootstrapClassPathElements == null) {
318: mBootstrapClassPathElements = new ArrayList();
319: }
320: return mBootstrapClassPathElements;
321: }
322:
323: public void setBootstrapClassPathElements(List elements) {
324: mBootstrapClassPathElements = elements;
325: }
326:
327: /**
328: * Get the class name of the bootstrap implementation for this BC or SE.
329: * @return The bootstrap class name.
330: */
331: public String getBootstrapClassName() {
332: return mBootstrapClassName;
333: }
334:
335: public void setBootstrapClassName(String name) {
336: mBootstrapClassName = name;
337: }
338:
339: /**
340: * @return the Installation Descriptor [jbi.xml] for the
341: * Component / Shared Library.
342: */
343: public String getInstallationDescriptor() {
344: return mJbiXmlString;
345: }
346:
347: /**
348: * @param jbiXml - the string representation of the installation descriptor
349: * for this Component / Shared Library
350: */
351: public void setInstallationDescriptor(String jbiXml) {
352: mJbiXmlString = jbiXml;
353: }
354:
355: /**
356: * Return an XML string representing this component.
357: * @return The XML that represents this component's attributes.
358: */
359: public String toXmlString() {
360: return "<?xml>";
361: }
362:
363: /**
364: * Get the Environment Variables
365: *
366: * @return an array of Variables set on the component. If there are zero
367: * environment variables et on the component an empty array is returned.
368: */
369: public Variable[] getVariables() {
370: if (mEnvVars == null) {
371: mEnvVars = new Variable[0];
372: }
373: return mEnvVars;
374: }
375:
376: /**
377: * Get the static component configuration.
378: *
379: * @return the components constant configuration.
380: */
381: public Properties getConfiguration() {
382: if (mConfigs == null) {
383: mConfigs = new Properties();
384: }
385: return mConfigs;
386: }
387:
388: /**
389: * Get a specific application configuration.
390: *
391: * @return the application configuration whose name = configName. If one does not exist
392: * an empty properties object is returned.
393: */
394: public Properties getApplicationConfiguration(String name) {
395: if (getApplicationConfigurations().containsKey(name)) {
396: return getApplicationConfigurations().get(name);
397: } else
398: return new Properties();
399: }
400:
401: /**
402: * Get the names of all application configurations set on the component.
403: *
404: * @return a list of names of all application configurations. If there are zero
405: * application configurations set on the component an empty array is returned.
406: */
407: public String[] getApplicationConfigurationNames() {
408: Set configNames = getApplicationConfigurations().keySet();
409:
410: String[] result = new String[configNames.size()];
411: configNames.toArray(result);
412: return result;
413: }
414:
415: /**
416: * Set the Environment Variables
417: *
418: * @param envVars - an array of Variables set on the component.
419: */
420: public void setVariables(Variable[] envVars) {
421: mEnvVars = envVars;
422: }
423:
424: /**
425: * Set the static component configuration.
426: *
427: * @param configs the components constant configuration.
428: */
429: public void setConfiguration(Properties configs) {
430: mConfigs = configs;
431: }
432:
433: /**
434: * Get a specific application configuration.
435: *
436: * @return the application configuration whose name = configName. If one does not exist
437: * an empty properties object is returned.
438: */
439: public void setApplicationConfiguration(String name,
440: Properties applicationConfig) {
441: getApplicationConfigurations().put(name, applicationConfig);
442: }
443:
444: /**
445: * @return the application Configuration Map.
446: */
447: private Map<String, Properties> getApplicationConfigurations() {
448: if (mApplicationConfigs == null) {
449: mApplicationConfigs = new HashMap();
450: }
451:
452: return mApplicationConfigs;
453: }
454: }
|