001/*
002 * Copyright 2012-2017 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.autoconfigure.integration;
018
019import javax.sql.DataSource;
020
021import org.springframework.boot.jdbc.AbstractDataSourceInitializer;
022import org.springframework.boot.jdbc.DataSourceInitializationMode;
023import org.springframework.core.io.ResourceLoader;
024import org.springframework.util.Assert;
025
026/**
027 * Initializer for Spring Integration schema.
028 *
029 * @author Vedran Pavic
030 * @since 2.0.0
031 */
032public class IntegrationDataSourceInitializer extends AbstractDataSourceInitializer {
033
034        private final IntegrationProperties.Jdbc properties;
035
036        public IntegrationDataSourceInitializer(DataSource dataSource,
037                        ResourceLoader resourceLoader, IntegrationProperties properties) {
038                super(dataSource, resourceLoader);
039                Assert.notNull(properties, "IntegrationProperties must not be null");
040                this.properties = properties.getJdbc();
041        }
042
043        @Override
044        protected DataSourceInitializationMode getMode() {
045                return this.properties.getInitializeSchema();
046        }
047
048        @Override
049        protected String getSchemaLocation() {
050                return this.properties.getSchema();
051        }
052
053}