001: /*
002: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: package com.sun.xml.internal.ws.client;
026:
027: import com.sun.xml.internal.ws.handler.HandlerResolverImpl;
028: import com.sun.xml.internal.ws.wsdl.WSDLContext;
029:
030: import java.util.ArrayList;
031: import java.util.HashMap;
032: import java.util.HashSet;
033: import java.util.List;
034: import java.util.Set;
035:
036: import javax.xml.namespace.QName;
037:
038: import org.xml.sax.EntityResolver;
039:
040: /**
041: * $author: WS Development Team
042: */
043: public class ServiceContext {
044: private WSDLContext wsdlContext; //from wsdlParsing
045:
046: private Class serviceClass;
047: private HandlerResolverImpl handlerResolver;
048: private QName serviceName; //supplied on creation of service
049: private final HashSet<EndpointIFContext> seiContext = new HashSet<EndpointIFContext>();
050: /**
051: * To be used to resolve WSDL resources.
052: */
053: private final EntityResolver entityResolver;
054: private HashMap<QName, Set<String>> rolesMap = new HashMap<QName, Set<String>>();
055:
056: public ServiceContext(EntityResolver entityResolver) {
057: this .entityResolver = entityResolver;
058: }
059:
060: public ServiceContext(Class serviceClass, QName serviceName,
061: EntityResolver entityResolver) {
062: this .serviceClass = serviceClass;
063: this .serviceName = serviceName;
064: this .entityResolver = entityResolver;
065: }
066:
067: public WSDLContext getWsdlContext() {
068: return wsdlContext;
069: }
070:
071: public void setWsdlContext(WSDLContext wsdlContext) {
072: this .wsdlContext = wsdlContext;
073: }
074:
075: public HandlerResolverImpl getHandlerResolver() {
076: return handlerResolver;
077: }
078:
079: public void setHandlerResolver(HandlerResolverImpl resolver) {
080: this .handlerResolver = resolver;
081: }
082:
083: public Set<String> getRoles(QName portName) {
084: return rolesMap.get(portName);
085: }
086:
087: public void setRoles(QName portName, Set<String> roles) {
088: rolesMap.put(portName, roles);
089: }
090:
091: public EndpointIFContext getEndpointIFContext(String className) {
092: for (EndpointIFContext eif : seiContext) {
093: if (eif.getSei().getName().equals(className)) {
094: //this is the one
095: return eif;
096: }
097: }
098: return null;
099: }
100:
101: public HashSet<EndpointIFContext> getEndpointIFContext() {
102: return seiContext;
103: }
104:
105: public void addEndpointIFContext(EndpointIFContext eifContext) {
106: this .seiContext.add(eifContext);
107: }
108:
109: public void addEndpointIFContext(List<EndpointIFContext> eifContexts) {
110: this .seiContext.addAll(eifContexts);
111: }
112:
113: public Class getServiceClass() {
114: return serviceClass;
115: }
116:
117: public void setServiceClass(Class serviceClass) {
118: this .serviceClass = serviceClass;
119: }
120:
121: public QName getServiceName() {
122: if (serviceName == null) {
123: if (wsdlContext != null) {
124: setServiceName(wsdlContext.getFirstServiceName());
125: }
126: }
127: return serviceName;
128: }
129:
130: public void setServiceName(QName serviceName) {
131: assert (serviceName != null);
132: this .serviceName = serviceName;
133: }
134:
135: public EntityResolver getEntityResolver() {
136: return entityResolver;
137: }
138:
139: public String toString() {
140: return "ServiceContext{" + "wsdlContext=" + wsdlContext
141: + ", handleResolver=" + handlerResolver
142: + ", serviceClass=" + serviceClass + ", serviceName="
143: + serviceName + ", seiContext=" + seiContext
144: + ", entityResolver=" + entityResolver + "}";
145: }
146: }
|