KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > descriptor > softpkg > ccm > ImplementationDeployer


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.softpkg.ccm;
27
28 import java.util.LinkedList JavaDoc;
29
30 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.DeployerInactiveState;
31 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.FatalDeploymentException;
32 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer.CodeDeployerVisitor;
33 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer.DependencyDeployerVisitor;
34 import org.omg.Components.ConfigValue;
35 import org.omg.Components.Deployment.ComponentInstallation;
36
37 /**
38  * The implementationDeployer is used to resolve the dependencies
39  * on a implementation and install the implementation.
40  *
41  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Frédéric</a>
42  *
43  * @version 0.1
44  */

45 public class ImplementationDeployer
46        extends ImplementationDeployerContext
47 {
48     // ==================================================================
49
//
50
// Internal state.
51
//
52
// ==================================================================
53
private ComponentInstallation comp;
54     private LinkedList JavaDoc config;
55     private String JavaDoc entryPoint;
56     // ==================================================================
57
//
58
// Constructors.
59
//
60
// ==================================================================
61
// ==================================================================
62
//
63
// Internal methods.
64
//
65
// ==================================================================
66

67     /**
68      * Internal method to resolve all the dependency describes in the
69      * implementation.
70      * @return the resulting configvalue
71      * @throws FatalDeploymentException if a fatal error occured
72      */

73     private ConfigValue[]
74     processDependencies()
75     throws FatalDeploymentException
76     {
77         config=new LinkedList JavaDoc();
78         traverse(this,getDependencyDeployers());
79         return (ConfigValue[])config.toArray(new ConfigValue[config.size()]);
80     }
81     
82
83     // ==================================================================
84
//
85
// Public methods.
86
//
87
// ==================================================================
88
/**
89      * Install the current implementation including all the dependency
90      * @param comp the componentinstallation to use for installing
91      * @throws FatalDeploymentException if a fatal error occured
92      */

93     public ConfigValue[]
94     install(ComponentInstallation comp)
95     throws FatalDeploymentException
96     {
97         this.comp=comp;
98         traverse(this,getCodeDeployers());
99         return processDependencies();
100     }
101     /**
102      * The Dependency deployer visitor to solve dependency and code.
103      *
104      * @param deployer The dependency to execute
105      * @param status The implementationdeployer current status
106      * @throws FatalDeploymentException if a fatal error occured
107      */

108     public void
109     visit(DependencyDeployer deployer,DeployerInactiveState status)
110     throws FatalDeploymentException
111     {
112         try{
113             deployer.resolveDependency(comp);
114         }
115         catch(DependencyResolutionFailureException e)
116         {
117             getErrorManager().submitException(e);
118         }
119     }
120     /**
121      * The code deployer visitor to install code.
122      *
123      * @param codeDeployer the codeDeployer to execute
124      * @param status the implementation current status
125      * @throws FatalDeploymentException if a fatal error occured
126      */

127     public void
128     visit(CodeDeployer codeDeployer, DeployerInactiveState status)
129     throws FatalDeploymentException
130     {
131         try{
132             entryPoint=codeDeployer.intallCode(comp,getImplementation().getId());
133         }
134         catch(CodeInstallationFailureException e)
135         {
136             getErrorManager().submitException(e);
137         }
138     }
139     /**
140      * Visitor method taking in parameter the visitor to execute on all
141      * the dependencies.
142      *
143      * @param depVisitor the dependency visitor
144      * @throws DependencyResolutionFailureException if an error
145      * occured during the visit.
146      */

147     public void
148     visitDependencyDeployers(DependencyDeployerVisitor depVisitor)
149     throws DependencyResolutionFailureException
150     {
151         DependencyDeployer depDepl[]=getDependencyDeployers();
152         for(int i=0;i<depDepl.length;i++)
153             depVisitor.visit(depDepl[i]);
154     }
155     /**
156      * Visitor method taking in parameter the visitor to execute on all
157      * the codesdeployer.
158      *
159      * @param codeVisitor the codeVisitor
160      * @throws CodeInstallationFailureException if an error
161      * occured during the visit.
162      */

163     public void
164     visitCodeDeployers(CodeDeployerVisitor codeVisitor)
165     throws CodeInstallationFailureException
166     {
167         CodeDeployer codeDepl[]=getCodeDeployers();
168            for(int i=0;i<codeDepl.length;i++)
169                  codeVisitor.visit(codeDepl[i]);
170     }
171     /**
172      * Return the implementation entrypoint
173      * @return the implementation entrypoint
174      */

175     public String JavaDoc
176     getEntryPoint()
177     {
178         return entryPoint;
179     }
180     
181 }
182
Popular Tags