001 /**
002 * Copyright 2010-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 package org.kuali.common.jdbc.show;
017
018 import javax.sql.DataSource;
019
020 import org.kuali.common.jdbc.model.context.DatabaseProcessContext;
021 import org.kuali.common.jdbc.service.JdbcService;
022 import org.kuali.common.util.Assert;
023 import org.kuali.common.util.execute.Executable;
024 import org.slf4j.Logger;
025 import org.slf4j.LoggerFactory;
026
027 public final class ShowConfigExecutable implements Executable {
028
029 private static final Logger logger = LoggerFactory.getLogger(ShowConfigExecutable.class);
030 public static final boolean DEFAULT_SKIP = false;
031
032 public ShowConfigExecutable(DatabaseProcessContext context, DataSource dataSource, JdbcService service) {
033 this(context, dataSource, service, DEFAULT_SKIP);
034 }
035
036 public ShowConfigExecutable(DatabaseProcessContext context, DataSource dataSource, JdbcService service, boolean skip) {
037 Assert.noNulls(context, dataSource, service);
038 this.context = context;
039 this.dataSource = dataSource;
040 this.service = service;
041 this.skip = skip;
042 }
043
044 private final DatabaseProcessContext context;
045 private final DataSource dataSource;
046 private final JdbcService service;
047 private final boolean skip;
048
049 @Override
050 public void execute() {
051
052 if (skip) {
053 return;
054 }
055
056 ShowUtils.showOpen(logger, context);
057 ShowUtils.showClose(logger, context, service, dataSource);
058 }
059
060 public DatabaseProcessContext getContext() {
061 return context;
062 }
063
064 public DataSource getDataSource() {
065 return dataSource;
066 }
067
068 public JdbcService getService() {
069 return service;
070 }
071
072 public boolean isSkip() {
073 return skip;
074 }
075
076 }