| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| SoapConfiguration |
|
| 0.0;0 |
| 1 | /* | |
| 2 | Copyright (c) 2006, University of Tromsø | |
| 3 | All rights reserved. | |
| 4 | ||
| 5 | Redistribution and use in source and binary forms, with or without | |
| 6 | modification, are permitted provided that the following conditions are met: | |
| 7 | ||
| 8 | * Redistributions of source code must retain the above copyright notice, this list | |
| 9 | of conditions and the following disclaimer. | |
| 10 | ||
| 11 | * Redistributions in binary form must reproduce the above copyright notice, this | |
| 12 | list of conditions and the following disclaimer in the documentation and/or other | |
| 13 | materials provided with the distribution. | |
| 14 | ||
| 15 | * Neither the name of the University of Tromsø nor the names of its contributors may | |
| 16 | be used to endorse or promote products derived from this software without specific | |
| 17 | prior written permission. | |
| 18 | ||
| 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | |
| 20 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
| 21 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | |
| 22 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
| 23 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | |
| 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
| 25 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
| 27 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | |
| 28 | DAMAGE. | |
| 29 | */ | |
| 30 | ||
| 31 | package axis.dynamic; | |
| 32 | ||
| 33 | import java.util.Collections; | |
| 34 | import java.util.Hashtable; | |
| 35 | import java.util.List; | |
| 36 | import java.util.Map; | |
| 37 | import java.util.concurrent.ConcurrentHashMap; | |
| 38 | ||
| 39 | import javax.xml.namespace.QName; | |
| 40 | ||
| 41 | import org.apache.axis.AxisEngine; | |
| 42 | import org.apache.axis.ConfigurationException; | |
| 43 | import org.apache.axis.EngineConfiguration; | |
| 44 | import org.apache.axis.Handler; | |
| 45 | import org.apache.axis.encoding.TypeMappingRegistry; | |
| 46 | import org.apache.axis.encoding.TypeMappingRegistryImpl; | |
| 47 | ||
| 48 | /** | |
| 49 | * abstract base class for dynamic Axis {@link EngineConfiguration}s. | |
| 50 | */ | |
| 51 | 0 | public abstract class SoapConfiguration implements EngineConfiguration |
| 52 | { | |
| 53 | /** the transport handlers. */ | |
| 54 | 0 | protected final Map<QName, Handler> _transports = new ConcurrentHashMap<QName, Handler>(); |
| 55 | ||
| 56 | /** this will register the Axis default type mappings */ | |
| 57 | 0 | protected final TypeMappingRegistry _tmr = new TypeMappingRegistryImpl(); |
| 58 | ||
| 59 | /** the global request handler (may be a handler chain) */ | |
| 60 | 0 | protected Handler _globalRequest = null; |
| 61 | ||
| 62 | /** the global response handler (may be a handler chain) */ | |
| 63 | 0 | protected Handler _globalResponse = null; |
| 64 | ||
| 65 | /** reference to the engine that uses this configuration, set in {@link #configureEngine} */ | |
| 66 | protected /* volatile ? */ AxisEngine _engine; | |
| 67 | ||
| 68 | /** synchronization shouldn't be necessary, it's a Hashtable and only modified on startup */ | |
| 69 | 0 | protected final Hashtable<String, String> _globalOptions = new Hashtable<String, String>(); |
| 70 | ||
| 71 | /** | |
| 72 | * called from {@link AxisEngine#init()}. Note: when this method is called, the given engine already | |
| 73 | * has a reference to this object. | |
| 74 | * @param engine | |
| 75 | * @throws ConfigurationException | |
| 76 | * @see EngineConfiguration#configureEngine(AxisEngine) | |
| 77 | * @see AxisEngine#init() | |
| 78 | */ | |
| 79 | public void configureEngine( AxisEngine engine ) throws ConfigurationException | |
| 80 | { | |
| 81 | 0 | _engine = engine; |
| 82 | // engine already knows this object - now it loads our options. | |
| 83 | 0 | _engine.refreshGlobalOptions(); |
| 84 | 0 | } |
| 85 | ||
| 86 | /** | |
| 87 | * We don't write ourselves out, so this is a no-op. | |
| 88 | * @param engine | |
| 89 | */ | |
| 90 | public void writeEngineConfig(AxisEngine engine) | |
| 91 | { | |
| 92 | // nothing to do | |
| 93 | 0 | } |
| 94 | ||
| 95 | /** | |
| 96 | * Returns the global configuration options. | |
| 97 | * @return the global options | |
| 98 | */ | |
| 99 | public Hashtable<String, String> getGlobalOptions() | |
| 100 | { | |
| 101 | 0 | return _globalOptions; |
| 102 | } | |
| 103 | ||
| 104 | /** | |
| 105 | * Returns a global request handler. | |
| 106 | * @return the global request handler (may be a handler chain) | |
| 107 | */ | |
| 108 | public Handler getGlobalRequest() | |
| 109 | { | |
| 110 | 0 | return _globalRequest; |
| 111 | } | |
| 112 | ||
| 113 | /** | |
| 114 | * Set the global request Handler | |
| 115 | * @param globalRequest (may be a handler chain) | |
| 116 | */ | |
| 117 | public void setGlobalRequest( Handler globalRequest ) | |
| 118 | { | |
| 119 | 0 | _globalRequest = globalRequest; |
| 120 | 0 | } |
| 121 | ||
| 122 | /** | |
| 123 | * Returns a global response handler. | |
| 124 | * @return the global response handler (may be a handler chain) | |
| 125 | */ | |
| 126 | public Handler getGlobalResponse() | |
| 127 | { | |
| 128 | 0 | return _globalResponse; |
| 129 | } | |
| 130 | ||
| 131 | /** | |
| 132 | * Set the global response Handler | |
| 133 | * @param globalResponse (may be a handler chain) | |
| 134 | */ | |
| 135 | public void setGlobalResponse( Handler globalResponse ) | |
| 136 | { | |
| 137 | 0 | _globalResponse = globalResponse; |
| 138 | 0 | } |
| 139 | ||
| 140 | /** | |
| 141 | * We do not use handlers with a 'global' name, so this method always returns null. | |
| 142 | * @param qname | |
| 143 | * @return global handler with given name | |
| 144 | * @see EngineConfiguration#getHandler(QName) | |
| 145 | */ | |
| 146 | public Handler getHandler( QName qname ) | |
| 147 | { | |
| 148 | 0 | return null; |
| 149 | } | |
| 150 | ||
| 151 | /** | |
| 152 | * Get our TypeMappingRegistry. | |
| 153 | * @return the TypeMappingRegistry of this configuration. | |
| 154 | */ | |
| 155 | public TypeMappingRegistry getTypeMappingRegistry() | |
| 156 | { | |
| 157 | 0 | return _tmr; |
| 158 | } | |
| 159 | ||
| 160 | /** | |
| 161 | * @param qname | |
| 162 | * @return the transport for the given name, may be null | |
| 163 | * @see EngineConfiguration#getTransport(QName) | |
| 164 | */ | |
| 165 | public Handler getTransport( QName qname ) | |
| 166 | { | |
| 167 | 0 | return _transports.get(qname); |
| 168 | } | |
| 169 | ||
| 170 | /** | |
| 171 | * sets the transport for the given name | |
| 172 | * @param name e.g. "http" | |
| 173 | * @param transport | |
| 174 | */ | |
| 175 | public void deployTransport( String name, Handler transport ) | |
| 176 | { | |
| 177 | 0 | _transports.put(new QName(name), transport); |
| 178 | 0 | } |
| 179 | ||
| 180 | /** | |
| 181 | * removes the transport for the given name | |
| 182 | * @param name | |
| 183 | */ | |
| 184 | public void undeployTransport( String name ) | |
| 185 | { | |
| 186 | 0 | _transports.remove(new QName(name)); |
| 187 | 0 | } |
| 188 | ||
| 189 | /** | |
| 190 | * currently, we don't use roles, so this method always returns null. | |
| 191 | * @return empty list | |
| 192 | */ | |
| 193 | public List<String> getRoles() | |
| 194 | { | |
| 195 | 0 | return Collections.emptyList(); |
| 196 | } | |
| 197 | ||
| 198 | } |