001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: package com.sun.istack.ws;
037:
038: import java.util.Collection;
039: import java.util.Collections;
040: import java.util.HashSet;
041: import java.util.Set;
042:
043: import com.sun.mirror.apt.*;
044: import com.sun.mirror.declaration.*;
045:
046: import com.sun.tools.ws.processor.modeler.annotation.AnnotationProcessorContext;
047: import com.sun.tools.ws.processor.modeler.annotation.WebServiceAP;
048:
049: /*
050: * The JAX-WS {@com.sun.mirror.apt.AnnotationProcessorFactory AnnotationProcessorFactory}
051: * class used by the <a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/apt.html">APT</a>
052: * framework.
053: */
054: public class AnnotationProcessorFactoryImpl implements
055: AnnotationProcessorFactory {
056:
057: private static WebServiceAP wsAP;
058: /*
059: * Processor doesn't examine any options.
060: */
061: static final Collection<String> supportedOptions = Collections
062: .unmodifiableSet(new HashSet<String>());
063:
064: /*
065: * Supports javax.jws.*, javax.jws.soap.* and javax.xml.ws.* annotations.
066: */
067: static Collection<String> supportedAnnotations;
068: static {
069: Collection<String> types = new HashSet<String>();
070: types.add("javax.jws.HandlerChain");
071: types.add("javax.jws.Oneway");
072: types.add("javax.jws.WebMethod");
073: types.add("javax.jws.WebParam");
074: types.add("javax.jws.WebResult");
075: types.add("javax.jws.WebService");
076: types.add("javax.jws.soap.InitParam");
077: types.add("javax.jws.soap.SOAPBinding");
078: types.add("javax.jws.soap.SOAPMessageHandler");
079: types.add("javax.jws.soap.SOAPMessageHandlers");
080: types.add("javax.xml.ws.BeginService");
081: types.add("javax.xml.ws.EndService");
082: types.add("javax.xml.ws.BindingType");
083: types.add("javax.xml.ws.ParameterIndex");
084: types.add("javax.xml.ws.RequestWrapper");
085: types.add("javax.xml.ws.ResponseWrapper");
086: types.add("javax.xml.ws.ServiceMode");
087: types.add("javax.xml.ws.WebEndpoint");
088: types.add("javax.xml.ws.WebFault");
089: types.add("javax.xml.ws.WebServiceClient");
090: types.add("javax.xml.ws.WebServiceProvider");
091: types.add("javax.xml.ws.WebServiceRef");
092:
093: types.add("javax.xml.ws.security.MessageSecurity");
094: supportedAnnotations = Collections
095: .unmodifiableCollection(types);
096: }
097:
098: public AnnotationProcessorFactoryImpl() {
099: }
100:
101: public Collection<String> supportedOptions() {
102: return supportedOptions;
103: }
104:
105: public Collection<String> supportedAnnotationTypes() {
106: return supportedAnnotations;
107: }
108:
109: /*
110: * Return an instance of the {@link com.sun.istack.ws.WSAP WSAP} AnnotationProcesor.
111: */
112: public AnnotationProcessor getProcessorFor(
113: Set<AnnotationTypeDeclaration> atds,
114: AnnotationProcessorEnvironment apEnv) {
115:
116: if (wsAP == null) {
117: AnnotationProcessorContext context = new AnnotationProcessorContext();
118: wsAP = new WebServiceAP(null, context, null, null);
119:
120: }
121: wsAP.init(apEnv);
122: return wsAP;
123: }
124: }
|