KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > annotation > factory > ScannerFactory


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
24 package com.sun.enterprise.deployment.annotation.factory;
25
26 import java.io.File JavaDoc;
27 import java.io.FileFilter JavaDoc;
28 import java.io.FileInputStream JavaDoc;
29 import java.io.IOException JavaDoc;
30 import java.util.jar.Attributes JavaDoc;
31 import java.util.jar.Manifest JavaDoc;
32
33 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
34
35 import com.sun.enterprise.deployment.annotation.impl.AppClientScanner;
36 import com.sun.enterprise.deployment.annotation.impl.EjbJarScanner;
37 import com.sun.enterprise.deployment.annotation.impl.WarScanner;
38 import com.sun.enterprise.deployment.annotation.Scanner;
39 import com.sun.enterprise.deployment.ApplicationClientDescriptor;
40 import com.sun.enterprise.deployment.archivist.Archivist;
41 import com.sun.enterprise.deployment.BundleDescriptor;
42 import com.sun.enterprise.deployment.deploy.shared.AbstractArchive;
43 import com.sun.enterprise.deployment.WebBundleDescriptor;
44 import com.sun.enterprise.deployment.EjbBundleDescriptor;
45
46 /**
47  * The Factory is reponsible for creating Scanner.
48  *
49  * @author Shing Wai Chan
50  */

51 public class ScannerFactory {
52     private ScannerFactory() {
53     }
54
55     public static Scanner createScanner(BundleDescriptor bundleDesc,
56             Archivist archivist, AbstractArchive abstractArchive,
57             ClassLoader JavaDoc classLoader) throws IOException JavaDoc {
58         Scanner scanner = null;
59         File JavaDoc f = new File JavaDoc(abstractArchive.getArchiveUri());
60
61         if (ModuleType.EJB.equals(archivist.getModuleType())) {
62             scanner = new EjbJarScanner(f, (EjbBundleDescriptor)bundleDesc,
63                    classLoader);
64         } else if (ModuleType.WAR.equals(archivist.getModuleType())) {
65             scanner = new WarScanner(f, (WebBundleDescriptor)bundleDesc,
66                    classLoader);
67         } else if (ModuleType.CAR.equals(archivist.getModuleType())) {
68             ApplicationClientDescriptor appClientDesc =
69                     (ApplicationClientDescriptor)bundleDesc;
70
71             scanner = new AppClientScanner(f, appClientDesc, classLoader);
72         }
73
74         return scanner;
75     }
76 }
77
Popular Tags