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:
037: package com.sun.xml.ws.api.server;
038:
039: /**
040: * Root of the SPI implemented by the container
041: * (such as application server.)
042: *
043: * <p>
044: * Often technologies that are built on top of JAX-WS
045: * (such as Tango) needs to negotiate private contracts between
046: * them and the container. This interface allows such technologies
047: * to query the negotiated SPI by using the {@link #getSPI(Class)}.
048: *
049: * <p>
050: * For example, if a security pipe needs to get some information
051: * from a container, they can do the following:
052: * <ol>
053: * <li>Negotiate an interface with the container and define it.
054: * (let's call it <tt>ContainerSecuritySPI</tt>.)
055: * <li>The container will implement <tt>ContainerSecuritySPI</tt>.
056: * <li>At the runtime, a security pipe gets
057: * {@link WSEndpoint} and then to {@link Container}.
058: * <li>It calls <tt>container.getSPI(ContainerSecuritySPI.class)</tt>
059: * <li>The container returns an instance of <tt>ContainerSecuritySPI</tt>.
060: * <li>The security pipe talks to the container through this SPI.
061: * </ol>
062: *
063: * <p>
064: * This protects JAX-WS from worrying about the details of such contracts,
065: * while still providing the necessary service of hooking up those parties.
066: *
067: * <p>
068: * Technologies that run inside JAX-WS server runtime can access this object through
069: * {@link WSEndpoint#getContainer()}. In the client runtime, it can be accessed from
070: * {@link ContainerResolver#getContainer()}
071: *
072: * @author Kohsuke Kawaguchi
073: * @see WSEndpoint
074: */
075: public abstract class Container {
076: /**
077: * For derived classes.
078: */
079: protected Container() {
080: }
081:
082: /**
083: * Gets the specified SPI.
084: *
085: * <p>
086: * This method works as a kind of directory service
087: * for SPIs between technologies on top of JAX-WS
088: * and the container.
089: *
090: * @param spiType
091: * Always non-null.
092: *
093: * @return
094: * null if such an SPI is not implemented by this container.
095: */
096: public abstract <T> T getSPI(Class<T> spiType);
097:
098: /**
099: * Constant that represents a "no {@link Container}",
100: * which always returns null from {@link #getSPI(Class)}.
101: */
102: public static final Container NONE = new Container() {
103: public <T> T getSPI(Class<T> spiType) {
104: return null;
105: }
106: };
107: }
|