KickJava   Java API By Example, From Geeks To Geeks.

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


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.ComponentfileBeanImpl;
30 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.*;
31 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.util.FileinarchiveDeployer;
32 import org.objectweb.openccm.descriptor.softpkg.beans.ImplementationBean;
33 import org.objectweb.openccm.descriptor.softpkg.beans.SoftpkgBeanImpl;
34 import org.objectweb.openccm.descriptor.softpkg.ccm.ImplementationDeployer;
35 import org.objectweb.openccm.descriptor.softpkg.ccm.SoftpkgDeployer;
36 import org.objectweb.openccm.descriptor.softpkg.ccm.SoftpkgDeployerHandler;
37 import org.objectweb.openccm.descriptor.softpkg.ccm.SoftpkgRootDeployerContext;
38
39 /**
40  * This handler is used to produce componentfiledeployer from an
41  * componentfile bean .
42  *
43  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Frédéric</a>
44  *
45  * @version 0.1
46  */

47 public class ComponentfileDeployerHandler
48        extends HandlerBase
49     {
50     // ==================================================================
51
//
52
// Internal state.
53
//
54
// ==================================================================
55
private ComponentfileDeployer _deploy;
56     // ==================================================================
57
//
58
// Constructors.
59
//
60
// ==================================================================
61
// ==================================================================
62
//
63
// Internal methods.
64
//
65
// ==================================================================
66
// ==================================================================
67
//
68
// Public methods.
69
//
70
// ==================================================================
71
/**
72      * This initialization method is used to check that all the services and
73      * information required to deploy are presents. If all is OK the deployer
74      * is put in inactive deployer state waiting for the deployment processing.
75      *
76      * @exception InitializationError is thrown if a problem is detected
77      */

78     public Object JavaDoc
79     getInstance(ComponentfileBeanImpl comp)
80     throws InitializationError
81     {
82         if (_deploy == null) {
83             _deploy = new ComponentfileDeployer();
84             _deploy.connectComponentfile(comp);
85             applyCommonConfig(_deploy);
86
87             if (comp.getFileinarchive() != null)
88                 _deploy.connectFileinarchiveDeployer(
89                     (FileinarchiveDeployer) getDeployer(comp
90                         .getFileinarchive()));
91
92             _deploy.initialize();
93
94             SoftpkgDeployer softDeployer =
95                 (SoftpkgDeployer) getDeployer2(_deploy.getSoftpkg());
96             _deploy.connectSoftpkgDeployer(softDeployer);
97
98             ImplementationBean[] ib = _deploy.getImplementations();
99
100             for (int i = 0; i < ib.length; i++) {
101                 ImplementationDeployer id =
102                     (ImplementationDeployer) getDeployer(ib[i]);
103                 _deploy.connectImplementationDeployer(id);
104             }
105         }
106         return (_deploy);
107     }
108     
109     public Object JavaDoc getDeployer2(Object JavaDoc obj)
110     throws InitializationError
111     {
112         try{
113             SoftpkgBeanImpl sbi=(SoftpkgBeanImpl)obj;
114             SoftpkgDeployerHandler tmp =
115                 (SoftpkgDeployerHandler)
116                     sbi.getExtensionManager()
117                        .getExtensionByName(resolveExtention(sbi));
118
119             SoftpkgRootDeployerContext srdc=new SoftpkgRootDeployerContext();
120             srdc.connectZipEntryRetriever
121                 (_deploy.getFileinarchiveDeployer().getInnerArchive());
122             
123             srdc.connectGlobalDeployerContext(getRootDeployerContext());
124             tmp.connectRootDeployerContext(srdc);
125             tmp.connectHandlerContext(getHandlerContext());
126
127             return tmp.getInstance(sbi);
128         }
129         catch(Exception JavaDoc e){
130             e.printStackTrace();
131             throw new InitializationError(_deploy,e," Failed during softpkg retrieval");
132         }
133      }
134 }
135
Popular Tags