KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > descriptor > componentassembly > ccm > deployer > registrar > RegistercomponentDeployer


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.registrar;
27
28 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.DeployerActiveState;
29 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.DeployerInactiveState;
30 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.FatalDeploymentException;
31 import org.omg.CORBA.Object JavaDoc;
32 import org.omg.Components.CCMObject;
33
34 /**
35  * CLASS_DESCRIPTION.
36  *
37  * @author <a HREF="mailto:briclet@lifl.fr">Briclet Frédéric</a>
38  *
39  * @version 0.1
40  */

41 public class RegistercomponentDeployer
42        extends RegistercomponentDeployerContext
43     {
44     // ==================================================================
45
//
46
// Internal state.
47
//
48
// ==================================================================
49
private Object JavaDoc to_register;
50     // ==================================================================
51
//
52
// Constructors.
53
//
54
// ==================================================================
55
// ==================================================================
56
//
57
// Internal methods.
58
//
59
// ==================================================================
60
// ==================================================================
61
//
62
// Public methods.
63
//
64
// ==================================================================
65
/**
66      * makecomponentRegistration execute the component registration
67      * @param component The component to register
68      * @throws FatalDeploymentException if a fatal problem occured
69      */

70     public void
71     makeComponentRegistration(CCMObject component)
72     throws FatalDeploymentException {
73        to_register=component;
74        
75        try{
76            if(getRegistercomponent().getProvidesidentifier()!=null)
77                        to_register=component.provide_facet(getRegistercomponent()
78                                                            .getProvidesidentifier().getValue());
79             else if(getRegistercomponent().getConsumesidentifier()!=null)
80                        to_register=component.get_consumer(getRegistercomponent()
81                                                           .getConsumesidentifier().getValue());
82        }
83        catch(Exception JavaDoc e){
84             //getErrorManager().submitException(e);
85
//TODO définir l'erreur appropriée.
86
}
87                                                                  
88        traverse(this,getRegisterwithnamingDeployers());
89        traverse(this,getRegisterwithtraderDeployers());
90        getLifeCycleManager().stepEndedSuccessFully();
91     }
92     /**
93      * Unregister the component reference.
94      *
95      * @throws FatalDeploymentException if a fatal problem occured
96      */

97     public void
98     undoComponentRegistration()
99     throws FatalDeploymentException
100     {
101        traverse(this,getRegisterwithnamingDeployers());
102        traverse(this,getRegisterwithtraderDeployers());
103        getLifeCycleManager().stepEndedSuccessFully();
104     }
105     /**
106      * RegisterwithnamingDeployer visitor used to make the registration
107      * @param deployer The registration deployer to execute
108      * @param status The Registercomponent current status
109      * @throws FatalDeploymentException if a fatal problem occured
110      */

111     public void
112     visit(RegisterwithnamingDeployer deployer,DeployerInactiveState status)
113     throws FatalDeploymentException
114     {
115         try{
116             deployer.rebind(to_register);
117         }
118         catch(NameserviceRegistrationFailureException e){
119             getErrorManager().submitException(e);
120         }
121
122     }
123     /**
124      * RegisterwithnamingDeployer visitor used to make the unregistration
125      * @param deployer The registration deployer to execute
126      * @param status The Registercomponent current status
127      * @throws FatalDeploymentException if a fatal problem occured
128      */

129     public void
130     visit(RegisterwithnamingDeployer deployer,DeployerActiveState status)
131     throws FatalDeploymentException
132     {
133         try{
134             deployer.unbind();
135         }
136         catch(NameserviceRegistrationFailureException e){
137             getErrorManager().submitException(e);
138         }
139
140     }
141     /**
142      * RegisterwithtraderDeployer visitor used to make the registration
143      * @param deployer The registration deployer to execute
144      * @param status The Registercomponent current status
145      * @throws FatalDeploymentException if a fatal problem occured
146      */

147     public void
148     visit(RegisterwithtraderDeployer deployer,DeployerInactiveState status)
149     throws FatalDeploymentException
150     {
151         try{
152             deployer.deploy(to_register);
153         }
154         catch(Exception JavaDoc e){
155             //getErrorManager().submitException(e);
156
}
157     }
158     /**
159      * RegisterwithtraderDeployer visitor used to make the registration
160      * @param deployer The registration deployer to execute
161      * @param status The Registercomponent current status
162      * @throws FatalDeploymentException if a fatal problem occured
163      */

164     public void
165     visit(RegisterwithtraderDeployer deployer,DeployerActiveState status)
166     throws FatalDeploymentException
167     {
168        try{
169            deployer.tearDown();
170        }
171        catch(Exception JavaDoc e){
172           // getErrorManager().submitException(e);
173
}
174     }
175     
176 }
177
Popular Tags