01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.frontend.spring;
19:
20: import java.util.List;
21: import java.util.Map;
22:
23: import org.w3c.dom.Element;
24:
25: import org.apache.cxf.common.util.StringUtils;
26: import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
27: import org.apache.cxf.frontend.ServerFactoryBean;
28:
29: import org.springframework.beans.factory.BeanDefinitionStoreException;
30: import org.springframework.beans.factory.support.AbstractBeanDefinition;
31: import org.springframework.beans.factory.support.BeanDefinitionBuilder;
32: import org.springframework.beans.factory.xml.ParserContext;
33:
34: public class ServerFactoryBeanDefinitionParser extends
35: AbstractBeanDefinitionParser {
36:
37: public ServerFactoryBeanDefinitionParser() {
38: super ();
39: setBeanClass(ServerFactoryBean.class);
40: }
41:
42: @Override
43: protected void mapElement(ParserContext ctx,
44: BeanDefinitionBuilder bean, Element el, String name) {
45: if ("properties".equals(name)) {
46: Map map = ctx.getDelegate().parseMapElement(el,
47: bean.getBeanDefinition());
48: bean.addPropertyValue("properties", map);
49: } else if ("executor".equals(name)) {
50: setFirstChildAsProperty(el, ctx, bean,
51: "serviceFactory.executor");
52: } else if ("invoker".equals(name)) {
53: setFirstChildAsProperty(el, ctx, bean,
54: "serviceFactory.invoker");
55: } else if ("binding".equals(name)) {
56: setFirstChildAsProperty(el, ctx, bean, "bindingConfig");
57: } else if ("inInterceptors".equals(name)
58: || "inFaultInterceptors".equals(name)
59: || "outInterceptors".equals(name)
60: || "outFaultInterceptors".equals(name)
61: || "features".equals(name)) {
62: List list = ctx.getDelegate().parseListElement(el,
63: bean.getBeanDefinition());
64: bean.addPropertyValue(name, list);
65: } else {
66: setFirstChildAsProperty(el, ctx, bean, name);
67: }
68: }
69:
70: @Override
71: protected void doParse(Element element, ParserContext ctx,
72: BeanDefinitionBuilder bean) {
73: super .doParse(element, ctx, bean);
74:
75: bean.setInitMethodName("create");
76:
77: // We don't really want to delay the registration of our Server
78: bean.setLazyInit(false);
79: }
80:
81: @Override
82: protected String resolveId(Element elem,
83: AbstractBeanDefinition definition, ParserContext ctx)
84: throws BeanDefinitionStoreException {
85: String id = super .resolveId(elem, definition, ctx);
86: if (StringUtils.isEmpty(id)) {
87: id = getBeanClass().getName() + "--" + hashCode();
88: }
89:
90: return id;
91: }
92:
93: @Override
94: protected boolean hasBusProperty() {
95: return true;
96: }
97:
98: }
|