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: * @(#)ServiceAssemblyDescriptor.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: /**
030: * ArchiveValidator.java
031: *
032: * SUN PROPRIETARY/CONFIDENTIAL.
033: * This software is the proprietary information of Sun Microsystems, Inc.
034: * Use is subject to license terms.
035: *
036: * Created on January 2, 2006, 4:49 PM
037: */package com.sun.jbi.management.descriptor;
038:
039: import com.sun.jbi.ServiceUnitState;
040: import com.sun.jbi.ServiceUnitInfo;
041: import com.sun.jbi.management.descriptor.Jbi;
042: import com.sun.jbi.management.descriptor.ServiceAssembly;
043: import com.sun.jbi.management.util.StringHelper;
044: import com.sun.jbi.management.registry.data.ServiceUnitInfoImpl;
045:
046: import java.util.List;
047:
048: /**
049: *
050: * This class encapsulates the JAXB model for the Shared Library Descriptor
051: *
052: * @author Sun Microsystems, Inc
053: */
054: public class ServiceAssemblyDescriptor {
055:
056: private ServiceAssembly mSaType;
057:
058: /**
059: * Constructs a ServiceAssemblyDescriptor.
060: *
061: * @throws an IllegalArgumentException if the JbiType passed in not that
062: * for a component
063: */
064: public ServiceAssemblyDescriptor(Jbi jbi)
065: throws IllegalArgumentException {
066: mSaType = jbi.getServiceAssembly();
067:
068: if (mSaType == null) {
069: throw new IllegalArgumentException();
070: }
071: }
072:
073: /**
074: * Get the name of the shared library
075: */
076: public String getName() {
077: if (mSaType.getIdentification() != null) {
078: return StringHelper.trim(mSaType.getIdentification()
079: .getName());
080: } else {
081: return "";
082: }
083: }
084:
085: /**
086: * @return the Shared Library Description
087: */
088: public String getDescription() {
089: if (mSaType.getIdentification() != null) {
090: return StringHelper.trim(mSaType.getIdentification()
091: .getDescription());
092: } else {
093: return "";
094: }
095: }
096:
097: /**
098: * @return the Shared Library Class Path elements. White spaces in individual elements
099: * are trimmed.
100: */
101: public List<ServiceUnitInfo> getServiceUnits() {
102:
103: List<ServiceUnitInfo> resultSus = new java.util.ArrayList<ServiceUnitInfo>();
104: List<com.sun.jbi.management.descriptor.ServiceUnit> suList = mSaType
105: .getServiceUnit();
106:
107: for (com.sun.jbi.management.descriptor.ServiceUnit su : suList) {
108: ServiceUnitInfoImpl suInfo = new ServiceUnitInfoImpl();
109: suInfo.setServiceAssemblyName(getName());
110: suInfo.setName(StringHelper.trim(su.getIdentification()
111: .getName()));
112: suInfo.setTargetComponent(StringHelper.trim(su.getTarget()
113: .getComponentName()));
114: suInfo.setState(ServiceUnitState.UNKNOWN);
115:
116: resultSus.add(suInfo);
117: }
118: return resultSus;
119: }
120:
121: }
|