KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > archivist > ArchivistFactory


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.deployment.archivist;
24
25 import java.io.IOException JavaDoc;
26 import java.io.File JavaDoc;
27 import java.io.FileNotFoundException JavaDoc;
28 import java.util.logging.Level JavaDoc;
29 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
30
31 import com.sun.enterprise.deployment.deploy.shared.AbstractArchive;
32 import com.sun.enterprise.deployment.util.DOLUtils;
33
34 /**
35  * This factory class is responsible for creating Archivists
36  *
37  * @author Jerome Dochez
38  * @version
39  */

40 public class ArchivistFactory {
41     
42     private static PluggableArchivistsHelper defaultArchivists;
43     
44     /** no need to create ArchivistFactory */
45     private ArchivistFactory() {
46     }
47
48     
49     private static void init() {
50         
51         if (defaultArchivists!=null)
52             return;
53         
54         // initialize our default Archivists helper singleton
55
// instance.
56
defaultArchivists = new PluggableArchivistsHelper();
57         defaultArchivists.registerArchivist(new ApplicationArchivist());
58         defaultArchivists.registerArchivist(new WebArchivist());
59         defaultArchivists.registerArchivist(new ConnectorArchivist());
60         defaultArchivists.registerArchivist(new AppClientArchivist());
61         defaultArchivists.registerArchivist(new EjbArchivist());
62     }
63
64     public static PluggableArchivists getPluggableArchivists() {
65         init();
66         return defaultArchivists;
67     }
68     
69     /**
70      * @return a new Archivist implementation for the type passed.
71      * Supported types are defined in the application.xml DTD
72      */

73     public static Archivist getArchivistForType(ModuleType JavaDoc type) {
74         init();
75         return defaultArchivists.getArchivistForType(type);
76     }
77     
78     /**
79      * @return a new Archivist implementation for the archive file type
80      * Supported J2EE modules are defined in the J2EE platform spec
81      */

82     public static Archivist getArchivistForArchive(File JavaDoc jarFileOrDirectory) throws IOException JavaDoc {
83         init();
84         return defaultArchivists.getArchivistForArchive(jarFileOrDirectory);
85     }
86     
87     /**
88      * @return a new Archivist implementation for the archive file type
89      * Supported J2EE modules are defined in the J2EE platform spec
90      */

91     public static Archivist getArchivistForArchive(String JavaDoc path) throws IOException JavaDoc {
92         init();
93         return defaultArchivists.getArchivistForArchive(path);
94     }
95         
96     /**
97      * @return a new Archivist implementation for the archive file type
98      * Supported J2EE modules are defined in the J2EE platform spec
99      */

100     public static Archivist getArchivistForArchive(AbstractArchive archive) throws IOException JavaDoc {
101         init();
102         return defaultArchivists.getArchivistForArchive(archive);
103     }
104     
105     /**
106      * register a new type of archivist
107      * @param archivist to register...
108      */

109     public static void registerArchivist(Archivist archivist) {
110         init();
111         defaultArchivists.registerArchivist(archivist);
112     }
113 }
114
Popular Tags