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.QNameHandler;
021
022 import javax.xml.namespace.QName;
023
024 /**
025 * Provides a registry of handlers indexed by specific {@link QName}
026 * instances as well as providing a default handler which is used for processing
027 * SOAP body elements (or REST root elements) if no QName could be matched.
028 *
029 * @version $Revision: 1.6 $
030 */
031 public interface HandlerRegistry {
032
033 /**
034 * Returns the handler bound to the given {@link QName}
035 * or null if no handler is bound to this name
036 *
037 * @param name the name of the element to lookup the handler for
038 * @return the handler bound to the name or null if none is bound
039 */
040 Handler getHandler(QName name);
041
042 /**
043 * Adds a new handler for the given namespace URI
044 *
045 * @param namepaceURI
046 * @param handler
047 */
048 void addHandler(String namepaceURI, Handler handler);
049
050
051 /**
052 * Adds a new handle to a number of different namespace URIs (typically to handle
053 * multiple version URIs for the same handler)
054 *
055 * @param namespaceURIs
056 * @param handler
057 */
058 void addHandler(String[] namespaceURIs, Handler handler);
059
060 /**
061 * Removes a handler from a number of different namespace URIs (typically to handle
062 * multiple version URIs for the same handler)
063 *
064 * @param namespaceURIs
065 * @param handler
066 */
067 void removeHandler(String[] namespaceURIs, Handler handler);
068
069 /**
070 * Adds a new handler for the given {@link QName}
071 *
072 * @param name
073 * @param handler
074 */
075 void addHandler(QName name, Handler handler);
076
077 /**
078 * Removes the handler associated with the given {@link QName}
079 *
080 * @param name
081 * @return
082 */
083 Handler removeHandler(QName name);
084
085 /**
086 * Removes the handler associated with the given namespace URI
087 *
088 * @param namepaceURI
089 */
090 Handler removeHandler(String namepaceURI);
091
092 /**
093 * Removes the handler associated with the given namespace URI
094 *
095 * @param namepaceURI
096 */
097 Handler removeHandler(String namepaceURI, Handler handler);
098
099 /**
100 * Returns the handler that should be used to process the body elements
101 * which by default will be a {@link QNameHandler} which delegates to the
102 * handler for the current {@link QName} otherwise using the handler returned
103 * by {@link #getDefaultHandler()}
104 */
105 Handler getBodyHandler();
106
107 /**
108 * Sets the handler used to process body elements
109 *
110 * @param bodyHandler the new handler used to process body elements
111 */
112 void setBodyHandler(Handler bodyHandler);
113
114 /**
115 * Returns the default handler which is used when processing
116 * body elements which have no {@link QName} matching handler.
117 */
118 Handler getDefaultHandler();
119
120 /**
121 * Sets the default handler used to process body elements
122 * if no handlers are found for a given {@link QName}
123 */
124 void setDefaultHandler(Handler defaultHandler);
125 }