KickJava   Java API By Example, From Geeks To Geeks.

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


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 OMG IDL3 demo3::Consumer 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 AssemblyManagerXMLImpl
41      extends org.objectweb.openccm.OpenCCM_DCI.
42              AssemblyManagerSessionComposition.AssemblyManagerImpl
43 {
44     // ==================================================================
45
//
46
// Internal state.
47
//
48
// ==================================================================
49

50     private String JavaDoc assemblyLoc;
51     private String JavaDoc xmlFilePath;
52     private org.objectweb.openccm.OpenCCM_DCI.AssemblyManagerRegistration AMR;
53     private org.omg.Components.Cookie cookie;
54     private boolean removed;
55     private String JavaDoc xml;
56     //The AssemblyManager instanceID
57
public String JavaDoc instanceUUID;
58     //Reference on the main interface
59
private org.objectweb.openccm.OpenCCM_DCI.AssemblyManager AM;
60
61     // ==================================================================
62
//
63
// Internal methods.
64
//
65
// ==================================================================
66

67
68     // ==================================================================
69
//
70
// Constructor
71
//
72
// ==================================================================
73
public AssemblyManagerXMLImpl(String JavaDoc xml){
74         this.xml=xml;
75         instanceUUID=System.currentTimeMillis()+"";
76         instanceUUID.substring(instanceUUID.length()-5,instanceUUID.length());
77         instanceUUID="AssemblyManagerInstance"+instanceUUID;
78         // System.err.println("AMI >> AIM"+instanceUUID+"created");
79

80     }
81     // ==================================================================
82
//
83
// Public methods.
84
//
85
// ==================================================================
86

87     public void
88     configuration_complete()
89     {
90         
91         try{
92             //((AssemblySegImpl)obtain_executor("assembly")).setupXML(xml);
93
//((NodeManagementSegImpl)obtain_executor("node_management")).setupDCI();
94
AMR=get_context().get_connection_assembly_manager_registration();
95         
96         try{
97             org.omg.Components.SessionContext sc=
98                 (org.omg.Components.SessionContext)get_context();
99
100             AM=org.objectweb.openccm.
101                 OpenCCM_DCI.AssemblyManagerHelper
102                 .narrow(sc.get_CCM_object());
103
104             cookie=AMR.register_assembly_manager(AM);
105             
106             ((AssemblySegImpl)obtain_executor("assembly"))
107                 .setupAssemblyManager(org.objectweb.openccm.
108                                       OpenCCM_DCI.AssemblyManagerHelper
109                                       .narrow(sc.get_CCM_object()));
110            
111         }
112         catch(Exception JavaDoc e)
113             {
114                 e.printStackTrace();
115             }
116
117         }
118         catch(Exception JavaDoc e){
119             e.printStackTrace();
120         }
121         
122         
123     }
124     
125     
126     public void
127     ccm_remove()
128     throws org.omg.Components.CCMException
129     {
130         /*TODO add the possibility to aware a node of DCI stop*/
131         if(!removed){
132             removed=true;
133             try{
134                 AMR.unregister_assembly_manager(cookie);
135                 get_context().push_assembly_manager_removed
136                     (new AssemblyManagerRemovedImpl(AM));
137                 //CSMR.unregister_component_server_manager(cookie);
138
if(org.omg.Components.Deployment.AssemblyState.INSERVICE==
139                    ((AssemblySegImpl)obtain_executor("assembly")).get_state())
140                     ((AssemblySegImpl)obtain_executor("assembly")).tear_down();
141                         }
142             catch(Exception JavaDoc e )
143                 {
144                     System.out.println("Cannot tear_down assembly");
145                     e.printStackTrace();
146                 }
147            
148         }
149     }
150
151     public void
152     push(org.objectweb.openccm.OpenCCM_DCI.ComponentServerManagerRemoved csmr)
153     {
154         return ;
155     }
156
157     // ==================================================================
158
//
159
// Accessor methods.
160
//
161
// ==================================================================
162

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