View Javadoc

1   /**
2    * Copyright 2010-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.jdbc.show;
17  
18  import javax.sql.DataSource;
19  
20  import org.kuali.common.jdbc.model.context.DatabaseProcessContext;
21  import org.kuali.common.jdbc.service.JdbcService;
22  import org.kuali.common.util.Assert;
23  import org.kuali.common.util.execute.Executable;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  
27  public final class ShowDbaConfigExecutable implements Executable {
28  
29  	private static final Logger logger = LoggerFactory.getLogger(ShowDbaConfigExecutable.class);
30  
31  	public static final boolean DEFAULT_SKIP = false;
32  
33  	public ShowDbaConfigExecutable(DatabaseProcessContext context, DataSource dataSource, JdbcService service) {
34  		this(context, dataSource, service, DEFAULT_SKIP);
35  	}
36  
37  	public ShowDbaConfigExecutable(DatabaseProcessContext context, DataSource dataSource, JdbcService service, boolean skip) {
38  		Assert.noNulls(context, dataSource, service);
39  		this.context = context;
40  		this.dataSource = dataSource;
41  		this.service = service;
42  		this.skip = skip;
43  	}
44  
45  	private final DatabaseProcessContext context;
46  	private final DataSource dataSource;
47  	private final JdbcService service;
48  	private final boolean skip;
49  
50  	@Override
51  	public void execute() {
52  
53  		if (skip) {
54  			return;
55  		}
56  
57  		ShowUtils.showOpen(logger, context);
58  		ShowUtils.showDba(logger, context.getConnections().getDba());
59  		ShowUtils.showClose(logger, context, service, dataSource);
60  	}
61  
62  	public DatabaseProcessContext getContext() {
63  		return context;
64  	}
65  
66  	public DataSource getDataSource() {
67  		return dataSource;
68  	}
69  
70  	public JdbcService getService() {
71  		return service;
72  	}
73  
74  	public boolean isSkip() {
75  		return skip;
76  	}
77  
78  }