KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Axis" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation. For more
52  * information on the Apache Software Foundation, please see
53  * <http://www.apache.org/>.
54  */

55
56 package org.jboss.axis.configuration;
57
58 import org.jboss.axis.AxisProperties;
59 import org.jboss.axis.EngineConfiguration;
60 import org.jboss.axis.EngineConfigurationFactory;
61 import org.jboss.logging.Logger;
62
63
64 /**
65  * This is a default implementation of EngineConfigurationFactory.
66  * It is user-overrideable by a system property without affecting
67  * the caller. If you decide to override it, use delegation if
68  * you want to inherit the behaviour of this class as using
69  * class extension will result in tight loops. That is, your
70  * class should implement EngineConfigurationFactory and keep
71  * an instance of this class in a member field and delegate
72  * methods to that instance when the default behaviour is
73  * required.
74  *
75  * @author Richard A. Sitze
76  * @author Glyn Normington (glyn@apache.org)
77  */

78 public class EngineConfigurationFactoryDefault
79         implements EngineConfigurationFactory
80 {
81    private static Logger log = Logger.getLogger(EngineConfigurationFactoryDefault.class.getName());
82
83    public static final String JavaDoc OPTION_CLIENT_CONFIG_FILE = "axis.ClientConfigFile";
84    public static final String JavaDoc OPTION_SERVER_CONFIG_FILE = "axis.ServerConfigFile";
85
86    protected static final String JavaDoc CLIENT_CONFIG_FILE = "client-config.wsdd";
87    protected static final String JavaDoc SERVER_CONFIG_FILE = "server-config.wsdd";
88
89    private String JavaDoc clientConfigFile;
90
91    private String JavaDoc serverConfigFile;
92
93    /**
94     * Creates and returns a new EngineConfigurationFactory.
95     * If a factory cannot be created, return 'null'.
96     * <p/>
97     * The factory may return non-NULL only if:
98     * - it knows what to do with the param (param == null)
99     * - it can find it's configuration information
100     *
101     * @see org.jboss.axis.configuration.EngineConfigurationFactoryFinder
102     */

103    public static EngineConfigurationFactory newFactory(Object JavaDoc param)
104    {
105       if (param != null)
106          return null; // not for us.
107

108       /**
109        * Default, let this one go through.
110        *
111        * The REAL reason we are not trying to make any
112        * decision here is because it's impossible
113        * (without refactoring FileProvider) to determine
114        * if a *.wsdd file is present or not until the configuration
115        * is bound to an engine.
116        *
117        * FileProvider/EngineConfiguration pretend to be independent,
118        * but they are tightly bound to an engine instance...
119        */

120       return new EngineConfigurationFactoryDefault();
121    }
122
123    /**
124     * Create the default engine configuration and detect whether the user
125     * has overridden this with their own.
126     */

127    protected EngineConfigurationFactoryDefault()
128    {
129       clientConfigFile =
130               AxisProperties.getProperty(OPTION_CLIENT_CONFIG_FILE,
131                       CLIENT_CONFIG_FILE);
132
133       serverConfigFile =
134               AxisProperties.getProperty(OPTION_SERVER_CONFIG_FILE,
135                       SERVER_CONFIG_FILE);
136    }
137
138    /**
139     * Get a default client engine configuration.
140     *
141     * @return a client EngineConfiguration
142     */

143    public EngineConfiguration getClientEngineConfig()
144    {
145       return new FileProvider(clientConfigFile);
146    }
147
148    /**
149     * Get a default server engine configuration.
150     *
151     * @return a server EngineConfiguration
152     */

153    public EngineConfiguration getServerEngineConfig()
154    {
155       return new FileProvider(serverConfigFile);
156    }
157 }
158
Popular Tags