001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id$
023: */
024: package com.bostechcorp.cbesb.common.sa.service;
025:
026: import java.util.HashMap;
027: import java.util.Vector;
028:
029: import com.bostechcorp.cbesb.common.sa.component.AbstractComponent;
030: import com.bostechcorp.cbesb.common.sa.component.BootstrapComponent;
031: import com.bostechcorp.cbesb.common.util.generators.ServiceAssemblyDOMBuildXMLGenerator;
032: import com.bostechcorp.cbesb.common.util.generators.ServiceAssemblyDOMJbiXMLGenerator;
033:
034: public class ServiceAssembly {
035:
036: public ServiceAssembly() {
037: super ();
038:
039: }
040:
041: private String name;
042: private String description;
043:
044: public String getDescription() {
045: return description;
046: }
047:
048: public void setDescription(String description) {
049: this .description = description;
050: }
051:
052: public String getName() {
053: return name;
054: }
055:
056: public void setName(String name) {
057: this .name = name;
058: }
059:
060: private Vector<AbstractComponent> componentList = new Vector<AbstractComponent>();
061:
062: private Vector<Connection> connectionList = new Vector<Connection>();
063:
064: private HashMap<String, AbstractComponent> componentMap = new HashMap<String, AbstractComponent>();
065:
066: public void deploy(String saPath, String suPath) throws Exception {
067: addComponent(new BootstrapComponent());
068: generateBuildXML(saPath, getName());
069:
070: Vector<AbstractComponent> componentList = getComponentList();
071: for (int i = 0; i < componentList.size(); i++) {
072: AbstractComponent component = componentList.get(i);
073: component.setContainerAssembly(this );// this is required for the JBI deployment
074: component.deploy(suPath, getName());
075: }
076: generateJBIXML(saPath);
077: }
078:
079: public Vector<AbstractComponent> getComponentList() {
080: return componentList;
081: }
082:
083: public void addComponent(AbstractComponent component) {
084: this .componentList.add(component);
085: this .componentMap.put(component.getName(), component);
086: }
087:
088: public HashMap getComponentMap() {
089: return componentMap;
090: }
091:
092: public Vector<Connection> getConnectionList() {
093: return connectionList;
094: }
095:
096: public void addConnection(Connection connection) {
097: this .connectionList.add(connection);
098: }
099:
100: public void generateJBIXML(String saPath) throws Exception {
101:
102: ServiceAssemblyDOMJbiXMLGenerator jXMLGenerator = new ServiceAssemblyDOMJbiXMLGenerator(
103: saPath, this .getName(), this .getDescription());
104: jXMLGenerator.setContentFromLists(getComponentList(),
105: getConnectionList(), componentMap);
106: jXMLGenerator.write();
107:
108: }
109:
110: public void generateBuildXML(String path, String saName)
111: throws Exception {
112:
113: ServiceAssemblyDOMBuildXMLGenerator buildXMLGenerator = new ServiceAssemblyDOMBuildXMLGenerator(
114: path, saName);
115: //buildXMLGenerator.
116: buildXMLGenerator.setComponentListTarget(getComponentList());
117: buildXMLGenerator.write();
118:
119: }
120:
121: public AbstractComponent getComponentByName(String name) {
122: return this.componentMap.get(name);
123: }
124:
125: }
|