KickJava   Java API By Example, From Geeks To Geeks.

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


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.WebComponentDescriptor;
29 import com.sun.enterprise.deployment.annotation.ProcessingContext;
30
31 /**
32  * This provides a context for a collection of web components with the same
33  * impl class name.
34  *
35  * @author Shing Wai Chan
36  */

37 public class WebComponentsContext extends AnnotationContext
38             implements ComponentContext {
39
40     private WebComponentContext[] webCompContexts;
41     private String JavaDoc componentClassName;
42
43     public WebComponentsContext(WebComponentDescriptor[] webComps) {
44         webCompContexts = new WebComponentContext[webComps.length];
45         for (int i = 0; i < webComps.length ; i++) {
46             webCompContexts[i] = new WebComponentContext(webComps[i]);
47         }
48         if (webComps[0].isServlet()) {
49             componentClassName = webComps[0].getWebComponentImplementation();
50         }
51     }
52    
53     /**
54      * Create a new instance of WebComponentContext.
55      * Note that, for performance, we don't make a safe copy of array here.
56      */

57     public WebComponentsContext(WebComponentContext[] webCompContexts) {
58         this.webCompContexts = webCompContexts;
59         this.componentClassName = webCompContexts[0].getComponentClassName();
60     }
61
62     /**
63      * Note that, for performance, we don't make a safe copy of array here.
64      */

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