KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer;
27
28 // Local Interface Import Statements
29
import org.objectweb.openccm.descriptor.componentassembly.beans.ComponentfilerefBeanImpl;
30 import org.objectweb.openccm.descriptor.componentassembly.beans.ComponentinstantiationBean;
31 import org.objectweb.openccm.descriptor.componentassembly.beans.HomeplacementBeanImpl;
32 import org.objectweb.openccm.descriptor.componentassembly.beans.RegisterwithhomefinderBeanImpl;
33 import org.objectweb.openccm.descriptor.componentassembly.beans.RegisterwithnamingBeanImpl;
34 import org.objectweb.openccm.descriptor.componentassembly.beans.RegisterwithtraderBeanImpl;
35 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.HandlerBase;
36 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.InitializationError;
37 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.registrar.*;
38 import org.objectweb.openccm.descriptor.softpkg.ccm.DefaultDescriptorDeployer;
39 import org.objectweb.openccm.descriptor.softpkg.ccm.DescriptorDeployerInterface;
40
41 /**
42  * This handler is used to produce homeplacementdeployer from an
43  * homeplacement bean .
44  *
45  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Frédéric</a>
46  *
47  * @version 0.1
48  */

49 public class HomeplacementDeployerHandler
50        extends HandlerBase
51     {
52     // ==================================================================
53
//
54
// Internal state.
55
//
56
// ==================================================================
57
private HomeplacementDeployer _deploy;
58     // ==================================================================
59
//
60
// Constructors.
61
//
62
// ==================================================================
63
// ==================================================================
64
//
65
// Internal methods.
66
//
67
// ==================================================================
68
// ==================================================================
69
//
70
// Public methods.
71
//
72
// ==================================================================
73
/**
74      * Produce the homeplacement deployer binded
75      * to the givean @param homeplacement.
76      *
77      * @param homeplacement The homeplacement bean
78      * @return the deployer produced in initialize state
79      * @throws InitializationError thrown if a problem is detected
80      */

81     public Object JavaDoc
82     getInstance(HomeplacementBeanImpl homeplacement)
83     throws InitializationError
84     {
85         if(_deploy==null){
86             _deploy=new HomeplacementDeployer();
87             _deploy.connectHomeplacement(homeplacement);
88             applyCommonConfig(_deploy);
89             if(homeplacement.getComponentinstantiationList()!=null)
90             for(java.util.Iterator JavaDoc i=homeplacement.getComponentinstantiationList().iterator();i.hasNext(); ){
91                ComponentinstantiationDeployer current=(ComponentinstantiationDeployer)
92                                             getDeployer((ComponentinstantiationBean)i.next());
93                _deploy.connectComponentInstantiationDeployer(current);
94             }
95             if(homeplacement.getRegisterwithnamingList()!=null)
96                 for(java.util.Iterator JavaDoc i=homeplacement.getRegisterwithnamingList().iterator();i.hasNext(); ){ ;
97                   _deploy.connectRegisterwithnamingDeployer
98                             ((RegisterwithnamingDeployer)
99                             getDeployer((RegisterwithnamingBeanImpl)i.next()));
100                }
101             if(homeplacement.getRegisterwithtraderList()!=null)
102                 for(java.util.Iterator JavaDoc i=homeplacement.getRegisterwithtraderList().iterator();i.hasNext(); ){ ;
103                   _deploy.connectRegisterwithtraderDeployer
104                             ((RegisterwithtraderDeployer)
105                             getDeployer((RegisterwithtraderBeanImpl)i.next()));
106                }
107             _deploy.connectHomeplacementInfo
108                   ( (HomeplacementDeployInfo)
109                           homeplacement.getExtensionManager().
110                           getExtensionByName("ccm.deployer.installer.DeployInfo")
111                           .getInstance() );
112
113             if(homeplacement.getDestination()!=null)
114                 _deploy.connectDestinationDeployer
115                 ((DestinationDeployer)getDeployer(homeplacement.getDestination()));
116    
117             ComponentfileDeployer componentfile;
118             
119             if(homeplacement.getComponentfileref()==null)
120                  throw new InitializationError(_deploy,"No componentfileref was specified "+
121                                    "check you homeplacement element description it must specify it\n"+
122                                    _deploy.getStringifiedDeployerDescription()
123                                      );
124             if(homeplacement.getComponentimplref()==null)
125                  throw new InitializationError(_deploy,"No componentimplref was specified "+
126                                    "check you homeplacement element description it must specify it\n"+
127                                    _deploy.getStringifiedDeployerDescription()
128                                      );
129             
130             try{
131                 if(((ComponentfilerefBeanImpl)
132                                 homeplacement
133                                 .getComponentfileref())
134                                 .pullIdref()==null)
135                 throw new InitializationError
136                             (_deploy,"The componentfileref "+homeplacement
137                                 .getComponentfileref().getIdref()+" is not a valid componentfile "+
138                                 "identifiant, check your CAD file it specifies bad componentfile"+
139                                 " idref\n"+_deploy.getStringifiedDeployerDescription());
140                 
141                 if(((ComponentfilerefBeanImpl)
142                               homeplacement
143                               .getComponentfileref())
144                               .pullIdref()==null)
145                  throw new InitializationError(_deploy,"Bad componentfile identifiant was specified "+
146                            homeplacement.getComponentfileref().getIdref()+
147                            " denote a non existing componentfile check you homeplacement element description\n"+
148                            _deploy.getStringifiedDeployerDescription()
149                              );
150                               
151                 componentfile=(ComponentfileDeployer)
152                                 getDeployer(((ComponentfilerefBeanImpl)
153                                               homeplacement
154                                               .getComponentfileref())
155                                               .pullIdref());
156             }
157            catch(java.lang.ClassCastException JavaDoc e){
158                  throw new InitializationError(_deploy,"Similar identifiants was detected, it was expected that "+
159                                                homeplacement.getComponentfileref().getIdref()+
160                                                " denote a componentfile but a "+
161                                                 ((ComponentfilerefBeanImpl)
162                                                 homeplacement.getComponentfileref())
163                                                 .pullIdref().getClass().getName()+" was found "+
164                                                 "check your CAD file a identifiant is used for two different elements;"+
165                                                 " To achieved successfully the deployment use different name for this two identifiants");
166             }
167             catch(java.lang.NullPointerException JavaDoc e){
168                  throw new InitializationError(_deploy,"Bad componentfileref was specified "+
169                                                homeplacement.getComponentfileref().getIdref()+
170                                                " denote a non existing componentfile check you homeplacement element description\n"+
171                                                _deploy.getStringifiedDeployerDescription()
172                                                  );
173             }
174                             
175             _deploy.connectSoftpkgDeployer(componentfile.getSoftpkgDeployer());
176            
177                        
178             if(componentfile.getImplementationDeployer
179                 (homeplacement.getComponentimplref().getIdref())!=null){
180             
181                 _deploy.connectImplementationDeployer
182                     (componentfile.getImplementationDeployer
183                     (homeplacement.getComponentimplref().getIdref()));
184               
185                 }
186             else {
187                  throw new InitializationError(_deploy,"Bad componentimplref was specified "+
188                                homeplacement.getComponentimplref().getIdref()+
189                                " denote a non existing implementation check you homeplacement element description\n"+
190                                _deploy.getStringifiedDeployerDescription()
191                                  );
192             }
193             if(_deploy.getDestinationDeployer()!=null)
194             {
195                 ((DestinationDeployerContext)
196                 _deploy.getDestinationDeployer())
197                         .connectSoftpkgDeployer(_deploy.getSoftpkgDeployer());
198             
199                 ((DestinationDeployerContext)
200                   _deploy.getDestinationDeployer())
201                          .connectImplementationDeployer
202                          (_deploy.getImplementationDeployer());
203                   
204             }
205             DescriptorDeployerInterface descr=new DefaultDescriptorDeployer();
206             if(_deploy.getSoftpkgDeployer().getDescriptorDeployers()!=null&&
207                _deploy.getSoftpkgDeployer().getDescriptorDeployers().length>0){
208
209                    descr=_deploy.getSoftpkgDeployer().getDescriptorDeployers()[0];
210
211                }
212
213             if(_deploy.getImplementationDeployer().getDescriptorDeployers()!=null&&
214                _deploy.getImplementationDeployer().getDescriptorDeployers().length>0){
215
216                    descr=_deploy.getImplementationDeployer().getDescriptorDeployers()[0];
217
218                }
219
220             if(homeplacement.getRegisterwithhomefinderList()!=null)
221                for(java.util.Iterator JavaDoc i=homeplacement.getRegisterwithhomefinderList().iterator();i.hasNext(); ){
222                    RegisterwithhomefinderDeployer rwhf=
223                            ((RegisterwithhomefinderDeployer)
224                            getDeployer((RegisterwithhomefinderBeanImpl)i.next()));
225                     rwhf.connectDescriptorDeployer(descr);
226                    _deploy.connectRegisterwithhomefinderDeployer(rwhf);
227               }
228             // The homplacementis initialize by it parents.
229
//_deploy.initialize();
230
}
231   
232         return (_deploy);
233     }
234
235 }
236
Popular Tags