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.dataretrieval;
21:
22: /**
23: * Factory to constructor Axis2 Data Locators based on the specified
24: * Dialect.
25: */
26:
27: public class DataLocatorFactory {
28: private static org.apache.axis2.dataretrieval.WSDLDataLocator wsdlDataLocator = null;
29: private static org.apache.axis2.dataretrieval.PolicyDataLocator policyDataLocator = null;
30: private static org.apache.axis2.dataretrieval.SchemaDataLocator schemaDataLocator = null;
31:
32: /*
33: * Return instance of default Data Locator for the dialect.
34: */
35: public static AxisDataLocator createDataLocator(String dialect) {
36: return (createDataLocator(dialect, null));
37: }
38:
39: public static AxisDataLocator createDataLocator(String dialect,
40: ServiceData[] serviceDataArray) {
41: AxisDataLocator dataLocator;
42:
43: if (dialect.equals(DRConstants.SPEC.DIALECT_TYPE_WSDL)) {
44: dataLocator = getWsdlDataLocator(serviceDataArray);
45: } else if (dialect.trim().equals(
46: DRConstants.SPEC.DIALECT_TYPE_POLICY)) {
47: if (policyDataLocator == null) {
48: dataLocator = new PolicyDataLocator(serviceDataArray);
49: } else {
50: dataLocator = policyDataLocator;
51: }
52: } else if (dialect.equals(DRConstants.SPEC.DIALECT_TYPE_SCHEMA)) {
53: if (schemaDataLocator == null) {
54: dataLocator = new SchemaDataLocator(serviceDataArray);
55: } else {
56: dataLocator = schemaDataLocator;
57: }
58: } else {
59: dataLocator = null;
60: }
61: return dataLocator;
62: }
63:
64: protected static AxisDataLocator getWsdlDataLocator(
65: ServiceData[] serviceDataArray) {
66:
67: if (wsdlDataLocator == null) {
68: wsdlDataLocator = new org.apache.axis2.dataretrieval.WSDLDataLocator(
69: serviceDataArray);
70: } else {
71: wsdlDataLocator.setServiceData(serviceDataArray);
72: }
73: return wsdlDataLocator;
74: }
75:
76: }
|