KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > configuration > EngineConfigurationFactoryDefault


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.apache.axis.configuration;
18
19 import org.apache.axis.AxisProperties;
20 import org.apache.axis.EngineConfiguration;
21 import org.apache.axis.EngineConfigurationFactory;
22 import org.apache.axis.components.logger.LogFactory;
23 import org.apache.commons.logging.Log;
24
25
26 /**
27  * This is a default implementation of EngineConfigurationFactory.
28  * It is user-overrideable by a system property without affecting
29  * the caller. If you decide to override it, use delegation if
30  * you want to inherit the behaviour of this class as using
31  * class extension will result in tight loops. That is, your
32  * class should implement EngineConfigurationFactory and keep
33  * an instance of this class in a member field and delegate
34  * methods to that instance when the default behaviour is
35  * required.
36  *
37  * @author Richard A. Sitze
38  * @author Glyn Normington (glyn@apache.org)
39  */

40 public class EngineConfigurationFactoryDefault
41     implements EngineConfigurationFactory
42 {
43     protected static Log log =
44         LogFactory.getLog(EngineConfigurationFactoryDefault.class.getName());
45
46     public static final String JavaDoc OPTION_CLIENT_CONFIG_FILE = "axis.ClientConfigFile";
47     public static final String JavaDoc OPTION_SERVER_CONFIG_FILE = "axis.ServerConfigFile";
48
49     protected static final String JavaDoc CLIENT_CONFIG_FILE = "client-config.wsdd";
50     protected static final String JavaDoc SERVER_CONFIG_FILE = "server-config.wsdd";
51
52     protected String JavaDoc clientConfigFile;
53     protected String JavaDoc serverConfigFile;
54
55     /**
56      * Creates and returns a new EngineConfigurationFactory.
57      * If a factory cannot be created, return 'null'.
58      *
59      * The factory may return non-NULL only if:
60      * - it knows what to do with the param (param == null)
61      * - it can find it's configuration information
62      *
63      * @see org.apache.axis.configuration.EngineConfigurationFactoryFinder
64      */

65     public static EngineConfigurationFactory newFactory(Object JavaDoc param) {
66         if (param != null)
67             return null; // not for us.
68

69         /**
70          * Default, let this one go through.
71          *
72          * The REAL reason we are not trying to make any
73          * decision here is because it's impossible
74          * (without refactoring FileProvider) to determine
75          * if a *.wsdd file is present or not until the configuration
76          * is bound to an engine.
77          *
78          * FileProvider/EngineConfiguration pretend to be independent,
79          * but they are tightly bound to an engine instance...
80          */

81         return new EngineConfigurationFactoryDefault();
82     }
83
84     /**
85      * Create the default engine configuration and detect whether the user
86      * has overridden this with their own.
87      */

88     protected EngineConfigurationFactoryDefault() {
89         clientConfigFile =
90             AxisProperties.getProperty(OPTION_CLIENT_CONFIG_FILE,
91                                        CLIENT_CONFIG_FILE);
92
93         serverConfigFile =
94             AxisProperties.getProperty(OPTION_SERVER_CONFIG_FILE,
95                                        SERVER_CONFIG_FILE);
96     }
97
98      /**
99       * Get a default client engine configuration.
100       *
101       * @return a client EngineConfiguration
102       */

103     public EngineConfiguration getClientEngineConfig() {
104         return new FileProvider(clientConfigFile);
105     }
106
107     /**
108      * Get a default server engine configuration.
109      *
110      * @return a server EngineConfiguration
111      */

112     public EngineConfiguration getServerEngineConfig() {
113         return new FileProvider(serverConfigFile);
114     }
115 }
116
Popular Tags