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 ShowDbaConfigExecutable implements Executable {
028
029 private static final Logger logger = LoggerFactory.getLogger(ShowDbaConfigExecutable.class);
030
031 public static final boolean DEFAULT_SKIP = false;
032
033 public ShowDbaConfigExecutable(DatabaseProcessContext context, DataSource dataSource, JdbcService service) {
034 this(context, dataSource, service, DEFAULT_SKIP);
035 }
036
037 public ShowDbaConfigExecutable(DatabaseProcessContext context, DataSource dataSource, JdbcService service, boolean skip) {
038 Assert.noNulls(context, dataSource, service);
039 this.context = context;
040 this.dataSource = dataSource;
041 this.service = service;
042 this.skip = skip;
043 }
044
045 private final DatabaseProcessContext context;
046 private final DataSource dataSource;
047 private final JdbcService service;
048 private final boolean skip;
049
050 @Override
051 public void execute() {
052
053 if (skip) {
054 return;
055 }
056
057 ShowUtils.showOpen(logger, context);
058 ShowUtils.showDba(logger, context.getConnections().getDba());
059 ShowUtils.showClose(logger, context, service, dataSource);
060 }
061
062 public DatabaseProcessContext getContext() {
063 return context;
064 }
065
066 public DataSource getDataSource() {
067 return dataSource;
068 }
069
070 public JdbcService getService() {
071 return service;
072 }
073
074 public boolean isSkip() {
075 return skip;
076 }
077
078 }