01: /*
02: * <copyright>
03: *
04: * Copyright 2001-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26: package org.cougaar.lib.vishnu.client.custom;
27:
28: import com.bbn.vishnu.scheduling.SchedulingData;
29: import org.cougaar.lib.vishnu.client.VishnuAggregatorPlugin;
30: import org.cougaar.lib.vishnu.client.XMLProcessor;
31: import org.cougaar.lib.vishnu.client.XMLizer;
32: import org.w3c.dom.Document;
33:
34: import java.util.Collection;
35: import java.util.List;
36: import java.util.Map;
37:
38: /**
39: * Uses CustomDataXMLize to create Vishnu objects either directly or through XML. <p>
40: *
41: * Data translation process left to the writer of XMLizer created in <tt>createXMLizer</tt>.
42: *
43: */
44: public class CustomVishnuAggregatorPlugin extends
45: VishnuAggregatorPlugin {
46:
47: /**
48: * Overrides VishnuPlugin.createXMLProcessor <p>
49: *
50: * Use a different data xmlizer to create the data xml stream to send to vishnu,<br>
51: * specifically, TranscomDataXMLize.
52: *
53: */
54: protected XMLProcessor createXMLProcessor() {
55: if (isDebugEnabled())
56: debug(getName()
57: + ".createXMLProcessor - creating TRANSCOM xml processor.");
58:
59: return new XMLProcessor(getMyParams(), getName(),
60: getClusterName(), domUtil, comm, getConfigFinder(),
61: logger, logger, logger) {
62: public void createDataXMLizer(Map nameToDescrip,
63: String assetClassName) {
64: if (isDebugEnabled())
65: debug(this .getName()
66: + ".createDataXMLizer - setting data xmlizer.");
67:
68: setDataXMLizer(createXMLizer(getRunDirectly()));
69: }
70: };
71: }
72:
73: /** override to use a different XMLizer */
74: protected XMLizer createXMLizer(boolean direct) {
75: return new CustomDataXMLize(direct, logger);
76: }
77:
78: /**
79: * Creates lists of Vishnu objects.
80: *
81: * @param tasksAndResources - Cougaar tasks and resources to translate
82: * @param vishnuTasks - list to add Vishnu tasks to
83: * @param vishnuResources - list to add Vishnu resources to
84: * @param objectFormat - contains field type info necessary to create fields on Vishnu objects
85: * @param timeOps - time object used when making Vishnu dates
86: */
87: public void prepareVishnuObjects(List alpObjects,
88: Collection changed, List vishnuTasks, List vishnuResources,
89: List changedVishnuResources, Document formatDoc,
90: SchedulingData schedData) {
91: DirectTranslator dt = (DirectTranslator) getDataXMLizer();
92: ((CustomDataXMLize) dt).setFormatDoc(formatDoc, schedData);
93: dt.createVishnuObjects(alpObjects, changed, vishnuTasks,
94: vishnuResources, changedVishnuResources);
95: }
96: }
|