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: */
19:
20: package org.apache.axis2.wsdl.codegen.extension;
21:
22: import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
23: import org.apache.axis2.wsdl.codegen.CodeGenerationException;
24: import org.apache.axis2.wsdl.databinding.CDefaultTypeMapper;
25: import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
26: import org.apache.axis2.wsdl.databinding.TypeMapper;
27: import org.apache.axis2.wsdl.i18n.CodegenMessages;
28:
29: public class DefaultDatabindingExtension extends
30: AbstractDBProcessingExtension {
31:
32: public void engage(CodeGenConfiguration configuration)
33: throws CodeGenerationException {
34: TypeMapper mapper = configuration.getTypeMapper();
35: if (testFallThrough(configuration.getDatabindingType())) {
36: //if it's fall through for the default databinding extension and a mapper has
37: //not yet being set, then there's a problem.
38: //Hence check the mapper status here
39:
40: if (mapper == null) {
41: //this shouldn't happen
42: throw new CodeGenerationException(CodegenMessages
43: .getMessage("extension.noProperDatabinding"));
44: }
45: return;
46: }
47: //the mapper has not been populated yet. since this extension is
48: //registered for -d none, we have to generate a new type mapper
49: //that serves only the default types
50: if (mapper == null) {
51: if (configuration.getOutputLanguage() != null
52: && !configuration.getOutputLanguage().trim()
53: .equals("")
54: && configuration.getOutputLanguage().toLowerCase()
55: .equals("c")) {
56: configuration.setTypeMapper(new CDefaultTypeMapper());
57:
58: } else {
59: configuration.setTypeMapper(new DefaultTypeMapper());
60: }
61:
62: }
63: }
64: }
|