KickJava   Java API By Example, From Geeks To Geeks.

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


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
27 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.registrar;
28
29
30 import org.objectweb.openccm.descriptor.componentassembly.Registerwithhomefinder;
31 /**
32  * Specific deployer allowing to register/unregister a home
33  * in the homefinder.
34  *
35  * @author <a HREF="mailto:frederic.briclet@lifl.fr">Briclet Frederic</a>
36  *
37  * @version 0.1
38  */

39
40 public class RegisterwithhomefinderDeployer
41        extends RegisterwithhomefinderDeployerContext
42     {
43     // ==================================================================
44
//
45
// Internal state.
46
//
47
// ==================================================================
48
/* the home registration cookie*/
49     private org.omg.Components.Cookie cookie;
50     /*registration home name*/
51     private String JavaDoc registrationName;
52     /*System.err.println prefix*/
53     private String JavaDoc prefix=">> HomeFinder Registration >>";
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      * Public method to register a home.
74      *
75      * @param descriptor descriptor containing CCD file path.
76      * @param homeToRegister The home to register.
77      */

78     public void
79     register_home(org.objectweb.openccm.descriptor.softpkg.Descriptor descriptor,
80                   org.omg.Components.CCMHome homeToRegister)
81     {
82         Registerwithhomefinder rwhfi=getRegisterwithhomefinder();
83         if(getRootDeployerContext().getHomeRegistration()==null)
84             {
85        
86                 System.err.println
87                    (prefix+ "Cannot found HomeFinder reference, the HomeFinder service hasn't be started");
88                 System.err.println
89                    (prefix+ "To start the HomeFinder service from console just execute finder_start script");
90                 System.err.println
91                     (prefix+"The HomeFinder registration will be skipped");
92          /*Skip the registration*/
93          return ;
94         }
95         
96         try{
97             cookie=getHomeregistration()
98                     .register_home(homeToRegister,
99                                    getDescriptorDeployer().getHomeRepid(),
100                                    getDescriptorDeployer().getComponentRepid(),
101                                    rwhfi.getName());
102        }
103         catch(Exception JavaDoc e){
104             System.err.println(prefix+"Problem occured during homefinder registration of"+ rwhfi.getName());
105             System.err.println(e.getMessage());
106         }
107         getLifeCycleManager().stepEndedSuccessFully();
108     }
109     
110     /**
111      * Public method to unregister the home registered by this deployer instance.
112      */

113     public void
114     unregister_home()
115     {
116         try{
117             if(cookie!=null)
118                 getHomeregistration().unregister_home(cookie);
119         }
120         catch(Exception JavaDoc e){
121             System.err.println(prefix+" Problem occured during unregistration of "+registrationName);
122             System.err.println(e.getMessage());
123         }
124         getLifeCycleManager().stepEndedSuccessFully();
125     }
126         
127
128 }
129
Popular Tags