01: /*
02: * Copyright 2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.ws.server.endpoint.mapping;
18:
19: import java.lang.annotation.Annotation;
20:
21: import org.springframework.beans.BeansException;
22: import org.springframework.beans.factory.config.BeanPostProcessor;
23: import org.springframework.ws.server.endpoint.annotation.Endpoint;
24:
25: /**
26: * Abstract base for {@link org.springframework.ws.server.EndpointMapping} implementations that map classes tagged with
27: * an annotation. By default the annotation is {@link Endpoint}, but this can be overriden in subclasses.
28: * <p/>
29: * The methods of each bean carrying @Endpoint will be registered using {@link #registerMethods(Object)}.
30: *
31: * @author Arjen Poutsma
32: * @since 1.0.0
33: */
34: public abstract class AbstractAnnotationMethodEndpointMapping extends
35: AbstractMethodEndpointMapping implements BeanPostProcessor {
36:
37: public final Object postProcessBeforeInitialization(Object bean,
38: String beanName) throws BeansException {
39: if (getEndpointClass(bean).getAnnotation(
40: getEndpointAnnotationType()) != null) {
41: registerMethods(bean);
42: }
43: return bean;
44: }
45:
46: /** Returns the 'endpoint' annotation type. Default is {@link Endpoint}. */
47: protected Class<? extends Annotation> getEndpointAnnotationType() {
48: return Endpoint.class;
49: }
50:
51: public final Object postProcessAfterInitialization(Object bean,
52: String beanName) throws BeansException {
53: return bean;
54: }
55:
56: }
|