KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > descriptor > componentassembly > ccm > deployer > installer > ComponentfileDeployer


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
28
29 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer;
30
31 // Import all the packages required
32
import java.io.InputStreamReader JavaDoc;
33 import org.objectweb.openccm.descriptor.ZipEntryRetriever;
34 import org.objectweb.openccm.descriptor.componentassembly.beans.*;
35 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.InitializationError;
36 import org.objectweb.openccm.descriptor.softpkg.*;
37 import org.objectweb.openccm.descriptor.softpkg.beans.*;
38
39 /**
40  *
41  * ComponentFileDeployer is used to read xml file information.
42  *
43  * @author <a HREF="mailto:Frederic.Briclet@lifl.fr">Briclet Frederic</a>
44  *
45  * @version 0.1
46  */

47 public class ComponentfileDeployer
48        extends ComponentfileDeployerContext
49     {
50
51     // ==================================================================
52
//
53
// Internal state.
54
//
55
// ==================================================================
56

57     /*Prefix for the outputed message*/
58     private String JavaDoc prefix="ComponentFileDeployer >> ";
59
60     // ==================================================================
61
//
62
// Constructor.
63
//
64
// ==================================================================
65

66
67     // ==================================================================
68
//
69
// Internal methods.
70
//
71
// ==================================================================
72

73
74     // ==================================================================
75
//
76
// Public methods.
77
//
78
// ==================================================================
79

80     /**
81      * Initialize the imbricated softpkg tree precised in xml file
82      * @throws InitializationError if a problem occured during initialization
83      */

84     public void
85     initializeSoftpkgTree()
86     throws InitializationError
87     {
88         try {
89             ZipEntryRetriever zer =
90                 getFileinarchiveDeployer().getInnerArchive();
91             
92             
93             String JavaDoc csdname ;
94             if(getFileinarchiveDeployer().getFileinarchive().getName()!=null
95                 &&getFileinarchiveDeployer().getFileinarchive().getName().endsWith(".csd"))
96                 
97                 csdname=getFileinarchiveDeployer().getFileinarchive().getName();
98             else csdname= zer.getZipEntriesEndingBy(".csd")[0];
99             
100
101             //Take only the first file which ending by .csd an exception
102
// must be thrown later
103

104             InputStreamReader JavaDoc reader =
105                 new InputStreamReader JavaDoc(
106                     zer.getZipEntryISIgnoringDelimiterType(csdname));
107             getRootDeployerContext().connectOpenReader(reader);
108             SoftpkgBean soft = SoftpkgBeanImpl.unmarshalBean(reader, true);
109             connectSoftpkg(soft);
110             //Browse all the implementation to store the reference of Java implementation
111
for (java.util.Iterator JavaDoc i = soft.getImplementationList().iterator();
112                 i.hasNext();
113                 ) {
114                 ImplementationBeanImpl ii = (ImplementationBeanImpl) i.next();
115                 if (((Programminglanguage) ii
116                     .getProgramminglanguageList()
117                     .get(0))
118                     .getName()
119                     .equalsIgnoreCase("java")) {
120                     connectImplementation(ii);
121                 }
122             }
123
124         } catch (Exception JavaDoc e) {
125             throw new InitializationError(
126                 this,
127                 e,
128                 "Fatal error:\n"
129                     + prefix
130                     + "Cannot open CSD file ["
131                     + getFileinarchiveDeployer().getFileinarchive().getName()
132                     + "] in the current ComponentAssembly archive.\n"
133                     + getStringifiedDeployerDescription());
134         }
135
136         getLifeCycleManager().stepEndedSuccessFully();
137     }
138 }
139
Popular Tags