KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > annotation > impl > EjbJarScanner


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.annotation.impl;
24
25 import java.io.File JavaDoc;
26 import java.io.FileFilter JavaDoc;
27 import java.io.IOException JavaDoc;
28 import java.lang.reflect.Array JavaDoc;
29 import java.lang.reflect.Method JavaDoc;
30 import java.net.URL JavaDoc;
31 import java.net.URLClassLoader JavaDoc;
32 import java.util.Iterator JavaDoc;
33 import java.util.Set JavaDoc;
34 import java.util.logging.Level JavaDoc;
35
36 import com.sun.enterprise.deployment.EjbBundleDescriptor;
37 import com.sun.enterprise.deployment.EjbDescriptor;
38 import com.sun.enterprise.deployment.EjbSessionDescriptor;
39 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
40 import com.sun.enterprise.deployment.EjbInterceptor;
41
42 /**
43  * Implementation of the Scanner interface for Ejb jar.
44  *
45  * @author Shing Wai Chan
46  */

47 public class EjbJarScanner extends ModuleScanner {
48     public EjbJarScanner(File JavaDoc archiveFile, EjbBundleDescriptor desc)
49             throws IOException JavaDoc {
50         this(archiveFile, desc, null);
51     }
52
53     /**
54      * This scanner will scan the archiveFile for annotation processing.
55      * @param archiveFile
56      * @param classLoader
57      */

58     public EjbJarScanner(File JavaDoc archiveFile, EjbBundleDescriptor desc,
59         ClassLoader JavaDoc classLoader) throws IOException JavaDoc {
60         if (AnnotationUtils.getLogger().isLoggable(Level.FINE)) {
61             AnnotationUtils.getLogger().fine("archiveFile is " + archiveFile);
62             AnnotationUtils.getLogger().fine("classLoader is " + classLoader);
63         }
64         this.archiveFile = archiveFile;
65         this.classLoader = classLoader;
66         if (archiveFile.isDirectory()) {
67             addScanDirectory(archiveFile);
68
69             // always add session beans, message driven beans,
70
// interceptor classes that are defined in ejb-jar.xml r
71
// regardless of they have annotation or not
72
for (Iterator JavaDoc ejbs = desc.getEjbs().iterator(); ejbs.hasNext();) {
73                 EjbDescriptor ejbDesc = (EjbDescriptor)ejbs.next();
74                 if (ejbDesc instanceof EjbSessionDescriptor ||
75                     ejbDesc instanceof EjbMessageBeanDescriptor) {
76                     addScanClassName(ejbDesc.getEjbClassName());
77                 }
78             }
79
80             for (Iterator JavaDoc interceptors = desc.getInterceptors().iterator();
81                 interceptors.hasNext();) {
82                 EjbInterceptor interceptor =
83                     (EjbInterceptor)interceptors.next();
84                 addScanClassName(interceptor.getInterceptorClassName());
85             }
86
87         } // else in app client jar
88

89     }
90 }
91
Popular Tags