View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
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, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package com.isenshi.util.extlib;
17  
18  import java.sql.Connection;
19  import java.sql.SQLException;
20  import java.util.Hashtable;
21  
22  import javax.sql.DataSource;
23  
24  import org.apache.slide.common.NamespaceAccessToken;
25  import org.apache.slide.common.ServiceInitializationFailedException;
26  import org.apache.slide.common.ServiceParameterErrorException;
27  import org.apache.slide.common.ServiceParameterMissingException;
28  import org.apache.slide.store.impl.rdbms.JDBCStore;
29  import org.seasar.framework.container.S2Container;
30  import org.seasar.framework.container.factory.SingletonS2ContainerFactory;
31  import org.seasar.tuigwaa.util.TgwResource;
32  
33  
34  public class S2Store extends JDBCStore {
35  
36  	public synchronized void initialize(NamespaceAccessToken token) throws ServiceInitializationFailedException {
37  		super.alreadyInitialized = true;
38  	}
39  	
40  	public void setParameters(Hashtable parameters) throws ServiceParameterErrorException, ServiceParameterMissingException {
41  		String driver = TgwResource.getProperty("database.driver");
42  		String adapter = TgwResource.getProperty("slide." + driver);
43  		parameters.put("adapter", adapter);
44  		super.setParameters(parameters);
45  	}
46  	
47  	protected Connection getNewConnection() throws SQLException {
48  		S2Container container = SingletonS2ContainerFactory.getContainer();
49  		DataSource dataSource = (DataSource)container.getComponent("basedb.dataSource");
50  		return dataSource.getConnection();
51  	}
52  }