001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.codehaus.activesoap; 019 020 import org.codehaus.activesoap.handler.SoapHandler; 021 import org.codehaus.activesoap.handler.Policy; 022 import org.codehaus.activesoap.handler.DefaultHandlerRegistry; 023 import org.codehaus.activesoap.soap.Soap12; 024 import org.codehaus.activesoap.soap.SoapVersion; 025 026 import java.util.Collections; 027 import java.util.HashSet; 028 import java.util.Set; 029 030 /** 031 * This class represents a SOAP service which is capable of handling 032 * multiple concurrent requests from arbitrary transports. 033 * This service can be configured in strict mode, to handle one exact version of SOAP 034 * or in a more relaxed mode where a best effort will be made to handle any SOAP version 035 * or even pure REST services. 036 * 037 * @version $Revision: 1.11 $ 038 */ 039 public class SoapService extends RestService { 040 041 private SoapVersion soapVersion; 042 private Set roles = Collections.synchronizedSet(new HashSet()); 043 private Set encodingStyles = Collections.synchronizedSet(new HashSet()); 044 private boolean intermediary; 045 046 public SoapService() { 047 this(Soap12.getInstance()); 048 } 049 050 public SoapService(HandlerRegistry handlerRegistry) { 051 this(handlerRegistry, Soap12.getInstance()); 052 } 053 054 public SoapService(HandlerRegistry handlerRegistry, SoapVersion soapVersion) { 055 super(handlerRegistry); 056 this.soapVersion = soapVersion; 057 init(); 058 } 059 060 public SoapService(SoapVersion soapVersion) { 061 this.soapVersion = soapVersion; 062 init(); 063 } 064 065 private void init() { 066 // register the default SOAP handler 067 setRootHandler(new SoapHandler(soapVersion)); 068 069 // lets auto-default the SOAP-encoding style 070 encodingStyles.add(soapVersion.getSoapEncodingStyle()); 071 } 072 073 /** 074 * Return true if this SOAP node has the given role 075 */ 076 public boolean hasRole(String role) { 077 return roles.contains(role); 078 } 079 080 // Properties 081 //------------------------------------------------------------------------- 082 public boolean isIntermediary() { 083 return intermediary; 084 } 085 086 public void setIntermediary(boolean intermediary) { 087 this.intermediary = intermediary; 088 } 089 090 public SoapVersion getSoapVersion() { 091 return soapVersion; 092 } 093 094 public void setSoapVersion(SoapVersion soapVersion) { 095 this.soapVersion = soapVersion; 096 } 097 098 public Set getRoles() { 099 return roles; 100 } 101 102 public void setRoles(Set roles) { 103 this.roles = roles; 104 } 105 106 public Set getEncodingStyles() { 107 return encodingStyles; 108 } 109 110 public void setEncodingStyles(Set encodingStyles) { 111 this.encodingStyles = encodingStyles; 112 } 113 114 }