KickJava   Java API By Example, From Geeks To Geeks.

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


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 OpenCCM_DCI::AssemblyManagerMoedl
33  * component type.
34  *
35  * This class inherits from the skeleton
36  * generated by the OpenCCM's CIF to Java mapping generator.
37  *
38  * @author <a HREF="mailto:Frederic.Briclet@lifl.fr">Briclet Frederic</A>
39  */

40
41 public class AssemblyManagerModelImpl
42      extends org.objectweb.openccm.OpenCCM_DCI.
43              AssemblyManagerModelSessionComposition.AssemblyManagerModelImpl
44 {
45
46     // ==================================================================
47
//
48
// Internal state.
49
//
50
// ==================================================================
51
//The XML descriptor ressource
52
private String JavaDoc xml_descriptor;
53     // The assembly uuid
54
private String JavaDoc assemblyUUID;
55     
56     private byte[] componentArchive;
57     
58     //Private boolean state
59
private boolean removed=false;
60     
61     private org.omg.Components.Cookie cookie;
62     
63     private org.objectweb.openccm.OpenCCM_DCI
64         .AssemblyManagerModelRegistration AMMR;
65     
66     // ==================================================================
67
//
68
// Internal state.
69
//
70
// ==================================================================
71
// ==================================================================
72
//
73
// Constructor.
74
//
75
// ==================================================================
76
public AssemblyManagerModelImpl(String JavaDoc xml_descriptor){
77         this.xml_descriptor=xml_descriptor;
78         //Build an assembly uuid
79
assemblyUUID=System.currentTimeMillis()+"";
80         assemblyUUID.substring(assemblyUUID.length()-5,assemblyUUID.length());
81         assemblyUUID="AAM:"+assemblyUUID;
82     }
83     
84     public AssemblyManagerModelImpl(byte[] componentArchive){
85             this.componentArchive=componentArchive;
86             //Build an assembly uuid
87
assemblyUUID=System.currentTimeMillis()+"";
88             assemblyUUID.substring(assemblyUUID.length()-5,assemblyUUID.length());
89             assemblyUUID="AAM:"+assemblyUUID;
90         }
91     // ==================================================================
92
//
93
// Accessor methods
94
//
95
// ==================================================================
96
public String JavaDoc xml_descriptor(){
97         if(xml_descriptor==null)
98             return "Not Component assembly description available";
99         return xml_descriptor;
100         
101     }
102     
103     public String JavaDoc assemblyUUID(){
104         return assemblyUUID;
105     }
106     // ==================================================================
107
//
108
// Common component methods.
109
//
110
// ==================================================================
111
public void
112     configuration_complete()
113     {
114         try{
115             if(xml_descriptor!=null)
116                 ((AssemblyInstanceManagementSegImpl)
117                  obtain_executor("assembly_instance_management"))
118                     .setupXML(xml_descriptor);
119             else {
120                     ((AssemblyInstanceManagementSegImpl)
121                     obtain_executor("assembly_instance_management"))
122                        .setupComponentArchive(componentArchive);
123                        assemblyUUID=((AssemblyInstanceManagementSegImpl)
124                                     obtain_executor("assembly_instance_management")).getModelName()
125                                     +":"+assemblyUUID;
126                     }
127                     
128            org.omg.Components.SessionContext sc=
129                 (org.omg.Components.SessionContext)get_context();
130                 
131             AMMR=get_context()
132             .get_connection_assembly_manager_model_registration();
133             
134             cookie= AMMR.register_assembly_manager_model
135                 (org.objectweb.openccm.
136                  OpenCCM_DCI.AssemblyManagerModelHelper
137                  .narrow(sc.get_CCM_object()));
138             ((AssemblyInstanceManagementSegImpl)
139                     obtain_executor("assembly_instance_management"))
140                     .setupCookie(cookie);
141                 
142         }
143         catch(Exception JavaDoc e){
144             e.printStackTrace();
145         }
146     }
147     
148     /**
149      * Implementation of the removing method.
150      * A removinf event will be sent soon.
151      */

152     public void
153     ccm_remove()
154     throws org.omg.Components.CCMException
155     {
156         System.err.println("Assembly manager removed invoke:boolean value:"+removed);
157         
158         if(removed) return;
159             
160         try{
161             //The disconnection processing is done by the facet
162
//AMMR.unregister_assembly_manager_model(cookie);
163

164                     
165             removed=true;
166             
167             ((AssemblyInstanceManagementSegImpl)
168                      obtain_executor("assembly_instance_management"))
169                         .uninstall();
170     
171     
172                    
173             }
174             catch(Exception JavaDoc e){
175                     e.printStackTrace();
176                 }
177             
178             
179     }
180
181     public void
182     push(AssemblyManagerRemoved amr)
183     {
184
185         try
186             {
187                 // System.err.println("AMMI >> Disconnect received");
188
((AssemblyInstanceManagementSegImpl)
189                  obtain_executor("assembly_instance_management"))
190                     .disconnectRemovedAssembly(amr.assembly_manager_ref);
191             }
192         catch(Exception JavaDoc e){
193             e.printStackTrace();
194         }
195     }
196 }
197
Popular Tags