KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > descriptor > componentassembly > gui > ComponentfileZipper


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): Christophe Contreras
23 Contributor(s):
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.descriptor.componentassembly.gui;
28
29 import org.objectweb.openccm.descriptor.componentassembly.beans.*;
30 import org.objectweb.openccm.descriptor.componentassembly.*;
31 import org.objectweb.openccm.descriptor.softpkg.beans.SoftpkgBean;
32 import org.objectweb.openccm.descriptor.softpkg.beans.SoftpkgBeanImpl;
33 import org.objectweb.openccm.descriptor.softpkg.gui.SoftpkgZipper;
34
35 /**
36  * This is an extension to the Apollon generated framework around componentassembly DTD
37  * it looks for subelements that could contain files to archive
38  * and calls their own zipper extensions to do the same job
39  * any found file name is sent to a zip factory
40  *
41  */

42 public class ComponentfileZipper
43 {
44     // ==================================================================
45
//
46
// Internal state.
47
//
48
// ==================================================================
49

50     // ==================================================================
51
//
52
// Constructors.
53
//
54
// ==================================================================
55

56     // ==================================================================
57
//
58
// Public methods.
59
//
60
// ==================================================================
61

62     /**
63      * The zip method called from parents
64      *
65      */

66     public void
67     zipCall(
68         ComponentfileBean componentfile
69         , org.objectweb.openccm.packaging.ZipFactory zip_factory
70         )
71     {
72         FileinarchiveBean fileinarchive
73          = (FileinarchiveBean)
74             componentfile.getFileinarchive();
75
76         // goes through sub element and call its zip method
77
if (fileinarchive != null)
78         {
79             FileinarchiveZipper sub_zipper
80              = (FileinarchiveZipper) fileinarchive
81                 .getExtensionManager()
82                 .getExtensionByName("gui.Zipper")
83                 .getInstance();
84
85             sub_zipper.zipCall(fileinarchive, zip_factory);
86
87
88             // identifies the component file (CAR or CSD)
89
java.io.File JavaDoc component_file
90                 = new java.io.File JavaDoc(fileinarchive.getName());
91
92             // a flat AAR with CSD inside
93
if (component_file.exists()
94                 && fileinarchive.getName().toLowerCase().endsWith("csd")
95                 && fileinarchive.getLink() == null
96                 )
97             {
98                 try
99                 {
100                     SoftpkgBean csd_instance
101                         = SoftpkgBeanImpl.unmarshalBean(component_file);
102
103                     SoftpkgZipper csd_zipper
104                         = (SoftpkgZipper)
105                             csd_instance
106                                 .getExtensionManager()
107                                 .getExtensionByName("gui.Zipper")
108                                 .getInstance();
109
110                     csd_zipper.zipCall(csd_instance, zip_factory);
111
112                 } catch (java.io.IOException JavaDoc exc) {
113                     System.err.println(
114                         "Could not open "
115                         +fileinarchive.getName()
116                         +" for archive dependencies");
117                 }
118             }
119         }
120     }
121 }
122
Popular Tags