01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.axis2;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20:
21: import javax.xml.ws.WebServiceException;
22: import javax.xml.ws.handler.Handler;
23: import javax.xml.ws.handler.HandlerResolver;
24:
25: import org.apache.geronimo.jaxws.annotations.AnnotationException;
26: import org.apache.geronimo.jaxws.annotations.AnnotationProcessor;
27: import org.apache.geronimo.xbeans.javaee.HandlerChainType;
28: import org.apache.geronimo.xbeans.javaee.HandlerChainsType;
29:
30: /**
31: * @version $Rev$ $Date$
32: */
33: public class Axis2HandlerResolver implements HandlerResolver {
34:
35: private HandlerChainsType handlerChains;
36:
37: private ClassLoader classLoader;
38:
39: private Class serviceClass;
40:
41: private AnnotationProcessor annotationProcessor;
42:
43: public Axis2HandlerResolver(ClassLoader classLoader,
44: Class serviceClass, HandlerChainsType handlerChains,
45: AnnotationProcessor annotationProcessor) {
46: this .classLoader = classLoader;
47: this .serviceClass = serviceClass;
48: this .handlerChains = handlerChains;
49: this .annotationProcessor = annotationProcessor;
50: }
51:
52: public List<Handler> getHandlerChain(
53: javax.xml.ws.handler.PortInfo portInfo) {
54:
55: GeronimoHandlerChainBuilder builder = new GeronimoHandlerChainBuilder(
56: this .classLoader, portInfo);
57:
58: List<Handler> handlers = null;
59: if (this .handlerChains == null) {
60: handlers = builder
61: .buildHandlerChainFromClass(this .serviceClass);
62: } else {
63: handlers = new ArrayList<Handler>();
64: for (HandlerChainType handlerChain : this .handlerChains
65: .getHandlerChainArray()) {
66: handlers
67: .addAll(builder
68: .buildHandlerChainFromConfiguration(handlerChain));
69: }
70: handlers = builder.sortHandlers(handlers);
71: }
72:
73: if (this .annotationProcessor != null) {
74: try {
75: for (Handler handler : handlers) {
76: this .annotationProcessor
77: .processAnnotations(handler);
78: this .annotationProcessor
79: .invokePostConstruct(handler);
80: }
81: } catch (AnnotationException e) {
82: throw new WebServiceException(
83: "Handler annotation failed", e);
84: }
85: }
86:
87: return handlers;
88: }
89:
90: }
|