KickJava   Java API By Example, From Geeks To Geeks.

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


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): Philippe Merle.
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.DestinationBeanImpl;
30 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.*;
31 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.util.FindbyDeployer;
32
33 /**
34  * This handler is used to produce DestinationDeployer from an
35  * destination bean. The implementation use the current
36  * DestinationDeployerfactory to found the right destination
37  * deployer to use.
38  *
39  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Frédéric</a>
40  *
41  * @version 0.1
42  */

43 public class DestinationDeployerHandler
44      extends HandlerBase
45 {
46     // ==================================================================
47
//
48
// Internal state.
49
//
50
// ==================================================================
51

52     private DestinationDeployerBase _deploy;
53
54     // ==================================================================
55
//
56
// Constructors.
57
//
58
// ==================================================================
59

60     // ==================================================================
61
//
62
// Internal methods.
63
//
64
// ==================================================================
65

66     // ==================================================================
67
//
68
// Public methods.
69
//
70
// ==================================================================
71

72     /**
73      * Produce the destinationdeployer deployer binded
74      * to the given @param cons.
75      *
76      * @param cons The destination bean
77      * @return The deployer produced in initialize state
78      * @throws InitializationError Thrown if a problem is detected
79      */

80     public Object JavaDoc
81     getInstance(DestinationBeanImpl cons)
82     throws InitializationError
83     {
84         if (_deploy == null)
85         {
86             if (getRootDeployerContext()
87                 .getDestinationDeployerFactory()== null)
88                 throw new InitializationError(_deploy, null,
89                             "Cannot found a valid Destination Deployer, no DestinationDelpoyerFactory connected");
90
91 /* Code related to the 2nd IST COACH project redefinition
92    of the destination element done.
93 */

94
95             try
96             {
97
98                 // Controls if children were set.
99
if( (cons.getNode()==null)
100                    && ( (cons.getInstallation()==null)
101                        || (cons.getActivation()==null)
102                       )
103                   )
104                 {
105                     throw new InitializationError(_deploy,
106                                                   null,
107                                                   "The <node> child or the nodes <installation> and <activation>" +
108                                                   " must be present in the <destination>\n" +
109                                                   "Check the <destination> Description:\n" +
110                                                   getStringifiedDescription(cons));
111                 }
112
113                 String JavaDoc deployType = null;
114                 if(cons.getNode() != null)
115                 {
116                     deployType = NodeDeployer.getNodeManagerType();
117                 }
118                 else
119                 {
120                     deployType = cons.getActivation().getType().trim();
121                 }
122
123                 _deploy = getRootDeployerContext()
124                           .getDestinationDeployerFactory()
125                           .getDestinationDeployer(deployType);
126             }
127             catch (UnknownDestinationDeployer e)
128             {
129                 throw new InitializationError(_deploy, e, e.getMessage());
130             }
131
132             _deploy.connectDestination(cons);
133
134             applyCommonConfig(_deploy);
135
136             if(cons.getNode() != null)
137             {
138                 _deploy.connectNodeDeployer((NodeDeployer)getDeployer(cons.getNode()));
139             }
140
141             if (cons.getActivation() != null && cons.getActivation().getFindby() != null)
142             {
143                 _deploy.connectFindbyDeployer(
144                     (FindbyDeployer)getDeployer(cons.getActivation().getFindby())
145                 );
146             }
147
148             _deploy.initialize();
149
150         }
151         return (_deploy);
152     }
153
154 }
155
Popular Tags