KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > OpenCCM_DCI > cif > AssemblyManagerImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@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 Frederic
23 Contributor(s): ---------------------------------------------
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.OpenCCM_DCI.cif;
28
29 import org.objectweb.openccm.OpenCCM_DCI.*;
30
31 /**
32  * This is the implementation of the AssemblyManager component type.
33  *
34  * This class inherits from the skeleton
35  * generated by the OpenCCM's CIF to Java mapping generator.
36  *
37  * @author <a HREF="mailto:Frederic.Briclet@lifl.fr">Briclet Frederic</A>
38  */

39
40 public class AssemblyManagerImpl
41      extends org.objectweb.openccm.OpenCCM_DCI.
42              AssemblyManagerSessionComposition.AssemblyManagerImpl
43 {
44     // ==================================================================
45
//
46
// Internal state.
47
//
48
// ==================================================================
49
// assembly descriptor file path
50
private String JavaDoc assemblyLoc;
51     // assembly manager registration interface
52
private org.objectweb.openccm.OpenCCM_DCI.AssemblyManagerRegistration AMR;
53     //registration cookie
54
private org.omg.Components.Cookie cookie;
55     //internal boolean to manage the removal of component
56
private boolean removed;
57     //The AssemblyManager instanceID
58
public String JavaDoc instanceUUID;
59     //Reference on the main interface
60
private org.objectweb.openccm.OpenCCM_DCI.AssemblyManager AM;
61     
62     private String JavaDoc suffix=null;
63
64     // ==================================================================
65
//
66
// Internal methods.
67
//
68
// ==================================================================
69

70     // ==================================================================
71
//
72
// Constructor.
73
//
74
// ==================================================================
75
public AssemblyManagerImpl(String JavaDoc xmlFilePath){
76         this.assemblyLoc=xmlFilePath;
77         suffix=System.currentTimeMillis()+"";
78         suffix.substring(suffix.length()-5,suffix.length());
79         suffix=":AssemblyManagerInstance:"+suffix;
80         //System.err.println("AMI >> AIM"+instanceUUID+"created");
81
}
82     
83     // ==================================================================
84
//
85
// public methods.
86
//
87
// ==================================================================
88

89     
90     public void
91     configuration_complete()
92     {
93         
94         try{
95                       
96             AMR=get_context().get_connection_assembly_manager_registration();
97
98             org.omg.Components.SessionContext sc=
99                 (org.omg.Components.SessionContext)get_context();
100             AM=org.objectweb.openccm.
101                 OpenCCM_DCI.AssemblyManagerHelper
102                 .narrow(sc.get_CCM_object());
103                 
104             cookie=
105                 AMR.register_assembly_manager(AM);
106             ((AssemblySegImpl)obtain_executor("assembly"))
107                 .setupAssemblyManager(org.objectweb.openccm.
108                                       OpenCCM_DCI.AssemblyManagerHelper
109                                       .narrow(sc.get_CCM_object()));
110             ((AssemblySegImpl)obtain_executor("assembly"))
111                 .setupXMLFilePath(assemblyLoc);
112             ((AssemblySegImpl)obtain_executor("assembly")).registerAssembly();
113             instanceUUID=((AssemblySegImpl)obtain_executor("assembly")).getName()+suffix;
114         }
115         catch(Exception JavaDoc e){
116             e.printStackTrace();
117         }
118         
119         
120     }
121     
122     
123     public void
124     ccm_remove()
125     throws org.omg.Components.CCMException
126     {
127         //System.err.println("AMI>> remove request1");
128

129         /*TODO add the possibility to aware a node of DCI stop*/
130         if(!removed){
131             removed=true;
132             ((AssemblySegImpl)obtain_executor("assembly")).unregisterAssembly();
133             try{
134                 // System.err.println("AMI>> remove request2");
135
AMR.unregister_assembly_manager(cookie);
136                 get_context().push_assembly_manager_removed
137                     (new AssemblyManagerRemovedImpl(AM));
138                 //CSMR.unregister_component_server_manager(cookie);
139

140                 if(org.omg.Components.Deployment.AssemblyState.INSERVICE==
141                    ((AssemblySegImpl)obtain_executor("assembly")).get_state())
142                     ((AssemblySegImpl)obtain_executor("assembly")).tear_down();
143             }
144             catch(Exception JavaDoc e )
145                 {
146                     System.out.println("Cannot tear_down assembly");
147                     e.printStackTrace();
148                 }
149            
150         }
151     }
152     
153     public void
154     push(org.objectweb.openccm.OpenCCM_DCI.ComponentServerManagerRemoved csmr)
155     {
156         return ;
157     }
158
159     // ==================================================================
160
//
161
// Accessor methods.
162
//
163
// ==================================================================
164

165     public org.ist.coach.DCI.DeploymentDescriptor[] descriptors(){
166         return new org.ist.coach.DCI.DeploymentDescriptor[0];
167     }
168
169     public String JavaDoc ass_id(){
170         
171         return instanceUUID;
172         
173     }
174     
175     public void
176     assembly_loc(java.lang.String JavaDoc assemblyLoc)
177     {
178         this.assemblyLoc=assemblyLoc;
179     }
180     
181     public String JavaDoc
182     assembly_loc()
183     {
184         return this.assemblyLoc;
185     }
186   
187
188 }
189
190
Popular Tags