KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > explorer > DCI > AssemblyUUIDContext


1 /*====================================================================
2
3 Objectweb Browser framework
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): Jerome Moroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26 package org.objectweb.openccm.explorer.DCI;
27
28 import org.ist.coach.DCI.AssemblyManager;
29 import org.ist.coach.DCI.DCIDeployment;
30 import org.ist.coach.DCI.UnknownAssembly;
31 import org.objectweb.util.explorer.api.Context;
32 import org.objectweb.util.explorer.api.Entry;
33 import org.objectweb.util.explorer.core.naming.lib.DefaultEntry;
34
35 /**
36  * This context provides the instances of the given assembly model.
37  *
38  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jerome Moroy</a>
39  *
40  * @version 0.1
41  */

42 public class AssemblyUUIDContext
43   implements Context
44 {
45
46     /**
47      * Provides a name depending on the AssemblyManager id.
48      */

49     protected String JavaDoc getName(AssemblyManager assemblyManager){
50         String JavaDoc returnedValue = "Assembly ";
51         String JavaDoc assemblyId = assemblyManager.ass_id();
52         if(assemblyId.indexOf(":")!=-1)
53             returnedValue = assemblyId.substring(0,assemblyId.indexOf(":"));
54         return returnedValue;
55     }
56     
57     /* (non-Javadoc)
58      * @see org.objectweb.util.explorer.api.Context#getEntries(java.lang.Object)
59      */

60     public Entry[] getEntries(Object JavaDoc object) {
61         AssemblyUUIDWrapper assemblyUUIDWrapper = (AssemblyUUIDWrapper)object;
62         DCIDeployment DCIDeploy = assemblyUUIDWrapper.getDCIDeployment();
63         String JavaDoc assemblyUUID = assemblyUUIDWrapper.getUUID();
64         java.util.List JavaDoc v = new java.util.Vector JavaDoc();
65
66         try {
67             String JavaDoc[] instanceUUID = DCIDeploy.get_assembly_instances(assemblyUUID);
68             for (int i = 0; i < instanceUUID.length; i++) {
69                 AssemblyManager assemblyManager = DCIDeploy.get_assembly_manager(instanceUUID[i]);
70                 AssemblyManagerWrapperWithDCIDeployment am = new AssemblyManagerWrapperWithDCIDeployment();
71                 am.setAssemblyManager(assemblyManager);
72                 am.setDCIDeployment(DCIDeploy);
73                 am.setUUID(instanceUUID[i]);
74                 v.add(new DefaultEntry(getName(assemblyManager) + " (" + (i+1) + ")", am));
75             }
76         } catch (UnknownAssembly e) {
77             e.printStackTrace();
78         }
79         
80         // Return the array of entry
81
return (Entry[]) v.toArray(new Entry[0]);
82     }
83
84 }
85
Popular Tags