View Javadoc

1   /*
2    * Copyright  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.kandula.storage;
18  
19  import org.apache.axis2.context.ConfigurationContext;
20  import org.apache.kandula.Constants;
21  
22  /***
23   * @author <a href="mailto:thilina@opensource.lk"> Thilina Gunarathne </a>
24   */
25  public class StorageFactory {
26  	private static StorageFactory instance = new StorageFactory();
27  
28  	private ConfigurationContext configurationContext = null;
29  
30  	private Store clientStore = null;
31  
32  	private StorageFactory() {
33  	}
34  
35  	public static StorageFactory getInstance() {
36  		return instance;
37  	}
38  
39  	public Store getStore() {
40  		if (configurationContext == null)
41  			return null;
42  		Store store = (Store) configurationContext
43  				.getProperty(Constants.KANDULA_STORE);
44  		if (store == null) {
45  			store = new SimpleStore();
46  			configurationContext.setProperty(Constants.KANDULA_STORE, store);
47  		}
48  		return store;
49  	}
50  
51  	/*
52  	 * TODO: Have to remove this. This is a hack done to get through the interop
53  	 */
54  	public Store getInitiatorStore() {
55  		if (clientStore == null) {
56  			clientStore = new SimpleStore();
57  		}
58  		return clientStore;
59  	}
60  
61  	public void setConfigurationContext(
62  			ConfigurationContext configurationContext) {
63  		this.configurationContext = configurationContext;
64  	}
65  
66  	/*
67  	 * TODO : Remove this... Parts of the Hack done for Interop
68  	 */
69  	public ConfigurationContext getConfigurationContext() {
70  		return configurationContext;
71  	}
72  }