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: /*
038: * RMProvider.java
039: *
040: * @author Mike Grogan
041: * Created on November 25, 2005, 9:50 AM
042: *
043: */
044:
045: package com.sun.xml.ws.rm.jaxws.runtime;
046:
047: import java.util.Hashtable;
048: import com.sun.xml.ws.rm.Message;
049: import javax.xml.bind.Marshaller;
050: import javax.xml.bind.Unmarshaller;
051: import com.sun.xml.ws.rm.RMException;
052: import com.sun.xml.ws.rm.jaxws.util.ProcessingFilter;
053: import com.sun.xml.ws.rm.jaxws.runtime.OutboundSequence;
054: import com.sun.xml.ws.rm.jaxws.runtime.InboundSequence;
055:
056: /**
057: * RMProvider is a base class for <code>RMSource</code> and
058: * <code>RMDestination</code> that provides storage for Lists of
059: * <code>InboundSequences</code> and <code>OutboundSequences</code> and
060: * handles the processing of messages coming from the network.
061: *
062: */
063: public abstract class RMProvider<INBOUNDSEQUENCE extends InboundSequence, OUTBOUNDSEQUENCE extends OutboundSequence> {
064:
065: protected ProcessingFilter filter = null;
066:
067: /**
068: */
069: public RMProvider() {
070: }
071:
072: /**
073: * Sets and instance of ProcessingFilter to be used for diagnostic/debugging
074: * purposes.
075: *
076: * @param filter The ProcessingFilter to be used.
077: */
078: public void setProcessingFilter(ProcessingFilter filter) {
079: this .filter = filter;
080: }
081:
082: /**
083: * Returns the ProcessingFilter instance that has been designated for use for
084: * diagnostic/debugging purposes.
085: *
086: * @return The filter that has been set by calling <code>setProcessingFilter</code>.
087: * Returns null if no ProcessingFilter has been set.
088: */
089: public ProcessingFilter getProcessingFilter() {
090: return filter;
091: }
092:
093: /*
094: * Contains all the <code>OutboundSequences</code> managed
095: * by this <code>RMProvider</code>. For an <code>RMSource</code>
096: * these are the "primary" sequences and <code>inboundMap</code>
097: * represents their "companion" sequences.
098: */
099: protected Hashtable<String, OUTBOUNDSEQUENCE> outboundMap = new Hashtable<String, OUTBOUNDSEQUENCE>();
100:
101: /*
102: * Contains all the <code>InboundSequences</code> managed
103: * by this <code>RMProvider</code>. For an <code>RMDestination</code>
104: * these are the "primary" sequences and <code>inboundMap</code>
105: * represents their "companion" sequences.
106: */
107: protected Hashtable<String, INBOUNDSEQUENCE> inboundMap = new Hashtable<String, INBOUNDSEQUENCE>();
108:
109: /**
110: * Look up <code>OutboundSequence</code> with given id.
111: *
112: * @param The sequence id
113: */
114: public OUTBOUNDSEQUENCE getOutboundSequence(String id) {
115: return outboundMap.get(id);
116: }
117:
118: /**
119: * Look up <code>OutboundSequence</code> with given id.
120: *
121: * @param The sequence id
122: */
123: public INBOUNDSEQUENCE getInboundSequence(String id) {
124: return inboundMap.get(id);
125: }
126:
127: /*
128: * Instance of a Helper class to handle inbound messages based
129: * on their WS-RM protocol headers
130: */
131: protected InboundMessageProcessor messageProcessor = new InboundMessageProcessor(
132: this );
133:
134: /*
135: * Process normal application message using <code>InboundMessageProcessor</code>
136: * field.
137: *
138: * @param mess The inbound message.
139: *
140: */
141: public void processInboundMessage(Message mess,
142: Marshaller marshaller, Unmarshaller unmarshaller)
143: throws RMException {
144: messageProcessor.processMessage(mess, marshaller, unmarshaller);
145: }
146:
147: public InboundMessageProcessor getInboundMessageProcessor() {
148: return messageProcessor;
149: }
150:
151: }
|