KickJava   Java API By Example, From Geeks To Geeks.

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


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.factory;
24
25 import java.util.HashSet JavaDoc;
26 import java.util.Set JavaDoc;
27
28 import com.sun.enterprise.deployment.annotation.AnnotationHandler;
29 import com.sun.enterprise.deployment.annotation.AnnotationProcessor;
30 import com.sun.enterprise.deployment.annotation.handlers.*;
31 import com.sun.enterprise.deployment.annotation.impl.AnnotationProcessorImpl;
32
33 /**
34  * This factory is responsible for initializing a ready to use
35  * AnnotationProcessor.
36  *
37  * @author Shing Wai Chan
38  */

39 public class SJSASFactory extends Factory {
40     private static Set JavaDoc<String JavaDoc> annotationClassNames = new HashSet JavaDoc<String JavaDoc>();
41
42     private SJSASFactory() {
43     }
44
45     public static AnnotationProcessor getAnnotationProcessor() {
46         init();
47         return Factory.getAnnotationProcessor();
48     }
49
50     public static Set JavaDoc<String JavaDoc> getAnnotations() {
51         init();
52         return (HashSet JavaDoc)((HashSet JavaDoc)annotationClassNames).clone();
53     }
54
55     private static void init() {
56         if (systemProcessor == null) {
57             synchronized(Factory.class) {
58                 if (systemProcessor == null) {
59                     // initialize our system annotation processor...
60
systemProcessor = new AnnotationProcessorImpl();
61                     for (AnnotationHandler anHandler : getSystemAnnotationHandlers()) {
62                         systemProcessor.pushAnnotationHandler(anHandler);
63                         annotationClassNames.add("L" +
64                             anHandler.getAnnotationType().getName().
65                             replace('.', '/') + ";");
66                     }
67                 }
68             }
69         }
70
71     }
72
73     private static AnnotationHandler[] getSystemAnnotationHandlers() {
74         return new AnnotationHandler[] {
75                 new DenyAllHandler(),
76                 new ApplicationExceptionHandler(),
77                 new AroundInvokeHandler(),
78                 new DeclareRolesHandler(),
79                 new EntityManagerFactoryReferenceHandler(),
80                 new EntityManagerFactoryReferencesHandler(),
81                 new EntityManagerReferenceHandler(),
82                 new EntityManagerReferencesHandler(),
83                 new ExcludeClassInterceptorsHandler(),
84                 new ExcludeDefaultInterceptorsHandler(),
85                 new EJBHandler(),
86                 new EJBsHandler(),
87                 new HandlerChainHandler(),
88                 new InitHandler(),
89                 new InterceptorsHandler(),
90                 new MessageDrivenHandler(),
91                 new PermitAllHandler(),
92                 new PostActivateHandler(),
93                 new PostConstructHandler(),
94                 new PreDestroyHandler(),
95                 new PrePassivateHandler(),
96                 new ResourceHandler(),
97                 new RolesAllowedHandler(),
98                 new ResourcesHandler(),
99                 new RemoveHandler(),
100                 new RunAsHandler(),
101                 new StatefulHandler(),
102                 new StatelessHandler(),
103                 new TimeoutHandler(),
104                 new TransactionAttributeHandler(),
105                 new TransactionManagementHandler(),
106                 new WebServiceHandler(),
107                 new WebServiceProviderHandler(),
108         new WebServiceRefHandler(),
109         new WebServiceRefsHandler()
110         };
111     }
112 }
113
Popular Tags