KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > annotation > context > EjbsContext


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.context;
24
25 import java.lang.annotation.ElementType JavaDoc;
26 import java.lang.reflect.AnnotatedElement JavaDoc;
27
28 import com.sun.enterprise.deployment.EjbDescriptor;
29 import com.sun.enterprise.deployment.annotation.ProcessingContext;
30
31
32 /**
33  * This provides a context for a collection of Ejbs with the ejb class name.
34  *
35  * @Author Shing Wai Chan
36  */

37 public class EjbsContext extends AnnotationContext
38         implements ComponentContext {
39     
40     private EjbContext[] ejbContexts;
41     private String JavaDoc componentClassName;
42
43     public EjbsContext(EjbDescriptor[] ejbDescs, Class JavaDoc ejbClass) {
44         ejbContexts = new EjbContext[ejbDescs.length];
45         for (int i = 0; i < ejbDescs.length ; i++) {
46             ejbContexts[i] = new EjbContext(ejbDescs[i], ejbClass);
47         }
48         this.componentClassName = ejbClass.getName();
49     }
50    
51     /**
52      * Create a new instance of EjbContext.
53      * Note that, for performance, we don't make a safe copy of array here.
54      */

55     public EjbsContext(EjbContext[] ejbContexts) {
56         this.ejbContexts = ejbContexts;
57         this.componentClassName = ejbContexts[0].getComponentClassName();
58     }
59
60     /**
61      * Note that, for performance, we don't make a safe copy of array here.
62      */

63     public EjbContext[] getEjbContexts() {
64         return ejbContexts;
65     }
66     
67     public void endElement(ElementType JavaDoc type, AnnotatedElement JavaDoc element) {
68         
69         if (ElementType.TYPE.equals(type)) {
70             // done with processing this class, let's pop this context
71
getProcessingContext().popHandler();
72         }
73     }
74
75     public String JavaDoc getComponentClassName() {
76         return componentClassName;
77     }
78       
79 }
80
Popular Tags