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.transport.tcp.server;
038:
039: import com.sun.istack.NotNull;
040: import com.sun.xml.ws.api.DistributedPropertySet;
041: import com.sun.xml.ws.api.PropertySet;
042: import com.sun.xml.ws.api.message.Packet;
043: import com.sun.xml.ws.api.pipe.Codec;
044: import com.sun.xml.ws.api.server.WSEndpoint;
045: import com.sun.xml.ws.transport.tcp.util.ChannelContext;
046: import com.sun.xml.ws.transport.tcp.util.TCPConstants;
047: import com.sun.xml.ws.transport.tcp.util.WSTCPException;
048: import java.io.IOException;
049:
050: /**
051: * @author Alexey Stashok
052: */
053: public final class TCPServiceChannelWSAdapter extends TCPAdapter {
054: private final WSTCPAdapterRegistry adapterRegistry;
055:
056: public TCPServiceChannelWSAdapter(@NotNull
057: final String name, @NotNull
058: final String urlPattern, @NotNull
059: final WSEndpoint endpoint, @NotNull
060: final WSTCPAdapterRegistry adapterRegistry) {
061: super (name, urlPattern, endpoint);
062: this .adapterRegistry = adapterRegistry;
063: }
064:
065: @Override
066: protected TCPAdapter.TCPToolkit createToolkit() {
067: return new ServiceChannelTCPToolkit();
068: }
069:
070: class ServiceChannelTCPToolkit extends TCPAdapter.TCPToolkit {
071: private final ServiceChannelWSSatellite serviceChannelWSSatellite;
072:
073: public ServiceChannelTCPToolkit() {
074: serviceChannelWSSatellite = new ServiceChannelWSSatellite(
075: TCPServiceChannelWSAdapter.this );
076: }
077:
078: // Taking Codec from virtual connection's ChannelContext
079: @Override
080: protected @NotNull
081: Codec getCodec(@NotNull
082: final ChannelContext context) {
083: return codec;
084: }
085:
086: @Override
087: protected void handle(@NotNull
088: final TCPConnectionImpl con) throws IOException, WSTCPException {
089: serviceChannelWSSatellite.setConnectionContext(con
090: .getChannelContext());
091: super .handle(con);
092: }
093:
094: @Override
095: public void addCustomPacketSattellites(@NotNull
096: final Packet packet) {
097: super .addCustomPacketSattellites(packet);
098: packet.addSatellite(serviceChannelWSSatellite);
099: }
100: };
101:
102: public static final class ServiceChannelWSSatellite extends
103: DistributedPropertySet {
104: private final TCPServiceChannelWSAdapter serviceChannelWSAdapter;
105: private ChannelContext channelContext;
106:
107: ServiceChannelWSSatellite(@NotNull
108: final TCPServiceChannelWSAdapter serviceChannelWSAdapter) {
109: this .serviceChannelWSAdapter = serviceChannelWSAdapter;
110: }
111:
112: protected void setConnectionContext(
113: final ChannelContext channelContext) {
114: this .channelContext = channelContext;
115: }
116:
117: @Property(TCPConstants.ADAPTER_REGISTRY)
118: public @NotNull
119: WSTCPAdapterRegistry getAdapterRegistry() {
120: return serviceChannelWSAdapter.adapterRegistry;
121: }
122:
123: @Property(TCPConstants.CHANNEL_CONTEXT)
124: public ChannelContext getChannelContext() {
125: return channelContext;
126: }
127:
128: private static final PropertyMap model;
129: static {
130: model = parse(ServiceChannelWSSatellite.class);
131: }
132:
133: public PropertySet.PropertyMap getPropertyMap() {
134: return model;
135: }
136: }
137: }
|