KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.sun.enterprise.deployment.annotation.Scanner;
27 import com.sun.enterprise.deployment.annotation.AnnotationProcessor;
28 import com.sun.enterprise.deployment.annotation.AnnotationHandler;
29 //import com.sun.enterprise.deployment.annotation.handlers.*;
30
import com.sun.enterprise.deployment.annotation.impl.AnnotationProcessorImpl;
31 /**
32  * The Factory is responsible for initializing a ready to use AnnotationProcessor.
33  *
34  * @author Jerome Dochez
35  */

36 public class Factory {
37     
38     protected static AnnotationProcessorImpl systemProcessor=null;
39     
40     /** we do no Create new instances of Factory */
41     protected Factory() {
42     }
43
44     private static void init() {
45     }
46
47     /**
48      * Return a fully initialized AnnotationProcessor where all the system
49      * annotation handlers have been registered.
50      * @return initialized AnnotationProcessor instance
51      */

52     public static AnnotationProcessor getAnnotationProcessor() {
53         
54         init();
55
56         // we use a delegation system. The System annotation processor is
57
// always the same instance. The user gets handed over a new
58
// instance of the annotation processor which no annotation handler
59
// registered. The user uses that instance to register it's own (if
60
// any) annotation handler.
61
AnnotationProcessorImpl processor = new AnnotationProcessorImpl();
62         processor.setDelegate(systemProcessor);
63         return processor;
64     }
65     
66     /**
67      * Return a empty AnnotationProcessor with no annotation handlers registered
68      * @return initialized AnnotationProcessor instance
69      */

70     public static AnnotationProcessor getDefaultAnnotationProcessor() {
71         return new AnnotationProcessorImpl();
72     }
73 }
74
Popular Tags