/**
* Copyright (C) 2015 Orange
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.francetelecom.clara.cloud.webapp.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
/**
* Created by WOOJ7232 on 26/05/2015.
*/
@Configuration
@Profile("!cloud")
public class DatasourceDefaultContext {
// <beans profile="default">
// <!-- activiti datasource : used for production -->
// <jee:jndi-lookup id="activitiDS" jndi-name="jdbc/activitiDS" />
// <jee:jndi-lookup id="datasource" jndi-name="jdbc/cloud-webappDataSource" />
@Bean(name = "activitiDS")
public DataSource getActivitiDatasource() throws NamingException {
Context ctx = new InitialContext();
return (DataSource) ctx.lookup("jdbc/activitiDS");
}
@Bean(name = "datasource")
@Primary
public DataSource getWebappDatasource() throws NamingException {
Context ctx = new InitialContext();
return (DataSource) ctx.lookup("jdbc/cloud-webappDataSource");
}
}