KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > descriptor > componentassembly > ccm > deployer > installer > ComponentfileDeployerContext


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Briclet Frédéric.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer;
28
29 import java.util.Iterator JavaDoc;
30 import java.util.LinkedList JavaDoc;
31 import org.objectweb.openccm.descriptor.componentassembly.Componentfile;
32 import org.objectweb.openccm.descriptor.componentassembly.beans.ComponentfileBean;
33 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.*;
34 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.util.FileinarchiveDeployer;
35 import org.objectweb.openccm.descriptor.softpkg.beans.ImplementationBean;
36 import org.objectweb.openccm.descriptor.softpkg.beans.ImplementationBeanImpl;
37 import org.objectweb.openccm.descriptor.softpkg.beans.SoftpkgBean;
38 import org.objectweb.openccm.descriptor.softpkg.ccm.ImplementationDeployer;
39 import org.objectweb.openccm.descriptor.softpkg.ccm.SoftpkgDeployer;
40
41 /**
42  * The componentfile deployer context defines all the connection requires for
43  * softpkg tree initialization.
44  *
45  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Frédéric</a>
46  *
47  * @version 0.1
48  */

49 public abstract class ComponentfileDeployerContext
50        extends ChildDeployerContext
51     {
52     // ==================================================================
53
//
54
// Internal state.
55
//
56
// ==================================================================
57
private FileinarchiveDeployer fia;
58     private ComponentfileBean comp;
59     private SoftpkgBean softpkg;
60     private SoftpkgDeployer softpkgDeployer;
61     private LinkedList JavaDoc implementationBeans;
62     private LinkedList JavaDoc implementationDeployers;
63
64     // ==================================================================
65
//
66
// Constructors.
67
//
68
// ==================================================================
69
public ComponentfileDeployerContext() {
70         implementationBeans = new LinkedList JavaDoc();
71         implementationDeployers = new LinkedList JavaDoc();
72     }
73     // ==================================================================
74
//
75
// Internal methods.
76
//
77
// ==================================================================
78
// ==================================================================
79
//
80
// Public accessors methods.
81
//
82
// ==================================================================
83
public void
84     connectImplementation(ImplementationBean impl)
85     {
86         implementationBeans.addLast(impl);
87     }
88
89     public ImplementationBean[]
90     getImplementations()
91     {
92         return (ImplementationBean[]) implementationBeans.toArray(
93             new ImplementationBeanImpl[implementationDeployers.size()]);
94     }
95
96     public void
97     connectImplementationDeployer(ImplementationDeployer impl)
98     {
99         implementationDeployers.addLast(impl);
100     }
101
102     public ImplementationDeployer[]
103     getImplementationDeployers()
104     {
105         return (ImplementationDeployer[]) implementationDeployers.toArray(
106             new ImplementationDeployer[implementationDeployers.size()]);
107     }
108
109     public ImplementationDeployer
110     getImplementationDeployer(String JavaDoc id)
111     {
112         for (Iterator JavaDoc it = implementationDeployers.iterator(); it.hasNext();) {
113             ImplementationDeployer impl = (ImplementationDeployer) it.next();
114             if (impl.getImplementation().getId().equals(id))
115                 return impl;
116         }
117         return null;
118     }
119
120     public void
121     connectFileinarchiveDeployer(FileinarchiveDeployer fia)
122     {
123         this.fia = fia;
124     }
125
126     public FileinarchiveDeployer
127     getFileinarchiveDeployer()
128     {
129         return fia;
130     }
131
132     public void
133     connectComponentfile(ComponentfileBean comp)
134     {
135         this.comp = comp;
136         connectDeployerDescription(comp);
137     }
138
139     public Componentfile
140     getComponentfile()
141     {
142         return comp;
143     }
144     
145     /**
146      * @return
147      */

148     public SoftpkgBean
149     getSoftpkg()
150     {
151         return softpkg;
152     }
153
154     /**
155      * @param bean
156      */

157     public void
158     connectSoftpkg(SoftpkgBean bean)
159     {
160         softpkg = bean;
161     }
162
163     /**
164      * @return
165      */

166     public SoftpkgDeployer
167     getSoftpkgDeployer()
168     {
169         return softpkgDeployer;
170     }
171
172     /**
173      * @param deployer
174      */

175     public void
176     connectSoftpkgDeployer(SoftpkgDeployer deployer)
177     {
178         softpkgDeployer = deployer;
179     }
180
181     public abstract void
182     initializeSoftpkgTree()
183     throws InitializationError;
184     
185     /**
186      * This initialization method is used to check that all the services and
187      * information required to deploy are presents. If all is OK the deployer
188      * is put in inactive deployer state waiting for the deployment processing.
189      *
190      * @exception InitializationError is thrown if a problem is detected
191      */

192     public void
193     initialize()
194     throws InitializationError
195     {
196         if (getComponentfile() == null)
197             getErrorManager().submitException(
198                 new InitializationError(
199                     this,
200                     "Connection on Componentfile is required"
201                         + "check the handler code it must specify this connection"));
202
203         if (getFileinarchiveDeployer() == null)
204             getErrorManager().submitException(
205                 new InitializationError(
206                     this,
207                     "A fileinarchive must be specified in componentfile element,"
208                         + "check you componentfiles element description.\n"
209                         + getStringifiedDeployerDescription()));
210         initializeSoftpkgTree();
211         getLifeCycleManager().stepEndedSuccessFully();
212     }
213
214
215 }
216
Popular Tags