KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ve > luz > ica > jackass > deploy > util > Application


1 /*
2  * Copyright (c) 2003 by The Jackass Team
3  * Licensed under the Open Software License version 2.0
4  */

5 package ve.luz.ica.jackass.deploy.util;
6
7 import java.util.HashMap JavaDoc;
8 import java.util.Iterator JavaDoc;
9 import java.util.Map JavaDoc;
10
11 import ve.luz.ica.jackass.deploy.descriptor.ica.ComponentChoiceIca;
12 import ve.luz.ica.jackass.deploy.descriptor.ica.ComponentIcaType;
13 import ve.luz.ica.jackass.deploy.descriptor.ica.IcaComponents;
14 import ve.luz.ica.jackass.deploy.descriptor.ica.IcaJackassApplication;
15 import ve.luz.ica.jackass.deploy.descriptor.standard.ComponentChoice;
16 import ve.luz.ica.jackass.deploy.descriptor.standard.ComponentType;
17 import ve.luz.ica.jackass.deploy.descriptor.standard.Components;
18 import ve.luz.ica.jackass.deploy.descriptor.standard.JackassApplication;
19
20 /**
21  * Application objects allow access to the information stored in the deployment descriptors.
22  * This class is a wrapper around the JackassApplication and IcaJackassApplication classes
23  * generated by Castor.
24  * @author Carlos Arévalo
25  */

26 public class Application
27 {
28     /**
29      * The standard descriptor file name
30      */

31     public static final String JavaDoc STANDARD_DESCRIPTOR_NAME = "deployment.xml";
32
33     /**
34      * The ica descriptor file name
35      */

36     public static final String JavaDoc ICA_DESCRIPTOR_NAME = "ica.xml";
37
38     private JackassApplication jackApplication = null;
39     private IcaJackassApplication icaApplication = null;
40     private Map JavaDoc components = null;
41
42     /**
43      * Class contructor
44      * @param jackApp the Castor generated JackassApplication object. It contains the
45      * information stored in the standard deployment descriptor.
46      * @param icaApp the Castor generated IcaJackassApplication object. It contains the
47      * information stored in the non-standard ica desployment descriptor.
48      */

49     public Application(JackassApplication jackApp, IcaJackassApplication icaApp)
50     {
51         this.jackApplication = jackApp;
52         this.icaApplication = icaApp;
53         this.components = new HashMap JavaDoc();
54
55         Components compList = jackApplication.getComponents();
56         IcaComponents icaCompList = icaApplication.getIcaComponents();
57
58         for (int i = 0; i<compList.getComponentChoiceCount(); ++i)
59         {
60             ComponentChoice compChoice = compList.getComponentChoice(i);
61             //ComponentChoiceIca compChoiceIca = icaCompList.getComponentChoiceIca(i);
62
ComponentType compType = null;
63             if ((compType = compChoice.getStatelessComponent()) != null)
64             {
65                 ComponentIcaType compIcaType = null;
66                 for (int j = 0; j<icaCompList.getComponentChoiceIcaCount(); ++j)
67                 {
68                     ComponentChoiceIca compChoiceIca = icaCompList.getComponentChoiceIca(j);
69                     ComponentIcaType tempCompIcaType = compChoiceIca.getIcaStatelessComponent();
70                     if (tempCompIcaType.getName().equals(compType.getName()))
71                     {
72                         compIcaType = tempCompIcaType;
73                     }
74                 }
75                 Component component = new Component(compType, compIcaType);
76                 components.put(component.getName(), component);
77             }
78         }
79     }
80
81     /**
82      * Returns the number of components in the application
83      * @return the number of components.
84      */

85     public int getComponentCount()
86     {
87         return components.size();
88     }
89
90     /**
91      * Returns a component given its name. The returned Component object is a wrapper
92      * around the Castor generated Component objects.
93      * @param name the name of the component
94      * @return the requested component
95      */

96     public Component getComponent(String JavaDoc name)
97     {
98         return (Component) components.get(name);
99     }
100
101     /**
102      * Gets a Castor generated standard component given its name.
103      * @param name the name of the component to retrieve
104      * @return the requested component.
105      */

106     public ComponentType getStandardComponent(String JavaDoc name)
107     {
108         Component comp = (Component) components.get(name);
109         return comp.getStandardComponent();
110     }
111
112     /**
113      * Gets a Castor generated ica component given its name.
114      * @param name the name of the component to retrieve
115      * @return the requested component.
116      */

117     public ComponentIcaType getIcaComponent(String JavaDoc name)
118     {
119         Component comp = (Component) components.get(name);
120         return comp.getIcaComponent();
121     }
122
123     /**
124      * Returns the value of field 'components'.
125      *
126      * @return the value of field 'components'.
127      */

128     public Iterator JavaDoc getComponents()
129     {
130         return this.components.values().iterator();
131     } //-- ve.luz.ica.jackass.deploy.descriptor.Components getComponents()
132

133     /**
134      * Returns the value of field 'description'.
135      *
136      * @return the value of field 'description'.
137      */

138     public java.lang.String JavaDoc getDescription()
139     {
140         return this.jackApplication.getDescription();
141     } //-- java.lang.String getDescription()
142

143     /**
144      * Returns the value of field 'displayName'.
145      *
146      * @return the value of field 'displayName'.
147      */

148     public java.lang.String JavaDoc getDisplayName()
149     {
150         return this.jackApplication.getDisplayName();
151     } //-- java.lang.String getDisplayName()
152

153     /**
154      * Returns the value of field 'name'.
155      *
156      * @return the value of field 'name'.
157      */

158     public java.lang.String JavaDoc getName()
159     {
160         return this.jackApplication.getName();
161     } //-- java.lang.String getName()
162

163     /**
164      * Returns the value of field 'properties'.
165      *
166      * @return the value of field 'properties'.
167      */

168     public ve.luz.ica.jackass.deploy.descriptor.standard.Properties getProperties()
169     {
170         return this.jackApplication.getProperties();
171     } //-- ve.luz.ica.jackass.deploy.descriptor.Properties getProperties()
172

173 }
174
Popular Tags