01: /*
02: * Copyright 2006 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.wsdl.wsdl11;
18:
19: import javax.xml.transform.Source;
20:
21: import org.springframework.beans.factory.InitializingBean;
22: import org.springframework.util.Assert;
23:
24: /**
25: * <code>Wsdl11Definition</code> that creates a WSDL definition at runtime, using a {@link Wsdl11DefinitionBuilder}. Can
26: * be instructed to build abstract or concrete parts of the definition, by setting the <code>buildAbstractPart</code>
27: * and <code>buildConcretePart</code> properties.
28: *
29: * @author Arjen Poutsma
30: * @see #setBuilder(Wsdl11DefinitionBuilder)
31: * @see #setBuildAbstractPart(boolean)
32: * @see #setBuildConcretePart(boolean)
33: * @since 1.0.0
34: */
35: public class DynamicWsdl11Definition implements Wsdl11Definition,
36: InitializingBean {
37:
38: private Wsdl11DefinitionBuilder builder;
39:
40: private Wsdl11Definition definition;
41:
42: private boolean buildAbstractPart = true;
43:
44: private boolean buildConcretePart = true;
45:
46: public void setBuilder(Wsdl11DefinitionBuilder builder) {
47: this .builder = builder;
48: }
49:
50: /**
51: * Indicates whether the built definition should contain an abstract part. If set to <code>true</code> (the default)
52: * the definition will contain types, messages, and portTypes; if <code>false</code>, it will not.
53: */
54: public void setBuildAbstractPart(boolean buildAbstractPart) {
55: this .buildAbstractPart = buildAbstractPart;
56: }
57:
58: /**
59: * Indicates whether the built definition should contain an concrete part. If set to <code>true</code> (the default)
60: * the definition will contain bindings, and services; if <code>false</code>, it will not.
61: */
62: public void setBuildConcretePart(boolean buildConcretePart) {
63: this .buildConcretePart = buildConcretePart;
64: }
65:
66: public void afterPropertiesSet() throws Exception {
67: Assert.notNull(builder, "builder is required");
68: builder.buildDefinition();
69: builder.buildImports();
70: if (buildAbstractPart) {
71: builder.buildTypes();
72: builder.buildMessages();
73: builder.buildPortTypes();
74: }
75: if (buildConcretePart) {
76: builder.buildBindings();
77: builder.buildServices();
78: }
79: definition = builder.getDefinition();
80: }
81:
82: public Source getSource() {
83: return definition.getSource();
84: }
85: }
|