View Javadoc
1   /**
2    * Copyright 2010-2014 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.util;
17  
18  import java.io.PrintStream;
19  
20  import org.slf4j.Logger;
21  import org.slf4j.LoggerFactory;
22  
23  /**
24   * Print a dot to the console each time we make progress
25   * 
26   * @deprecated
27   */
28  @Deprecated
29  public abstract class AbstractProgressInformer {
30  
31  	private static final Logger logger = LoggerFactory.getLogger(AbstractProgressInformer.class);
32  
33  	protected long progress;
34  
35  	PrintStream printStream = System.out;
36  	String startToken = "[INFO] Progress: ";
37  	String progressToken = ".";
38  	String completeToken = "\n";
39  	LogMsg startMessage;
40  	LogMsg stopMessage;
41  
42  	/**
43  	 * Thread safe method exposing the current progress
44  	 */
45  	public synchronized long getProgress() {
46  		return progress;
47  	}
48  
49  	/**
50  	 * Print the start token
51  	 */
52  	public void start() {
53  		if (startMessage != null) {
54  			LoggerUtils.log(startMessage, logger);
55  		}
56  
57  		Assert.notNull(printStream, "printStream is null");
58  		this.progress = 0;
59  
60  		printStream.print(startToken);
61  	}
62  
63  	/**
64  	 * Print the stop token
65  	 */
66  	public void stop() {
67  		printStream.print(completeToken);
68  
69  		if (stopMessage != null) {
70  			LoggerUtils.log(stopMessage, logger);
71  		}
72  	}
73  
74  	public PrintStream getPrintStream() {
75  		return printStream;
76  	}
77  
78  	public void setPrintStream(PrintStream printStream) {
79  		this.printStream = printStream;
80  	}
81  
82  	public String getStartToken() {
83  		return startToken;
84  	}
85  
86  	public void setStartToken(String startToken) {
87  		this.startToken = startToken;
88  	}
89  
90  	public String getCompleteToken() {
91  		return completeToken;
92  	}
93  
94  	public void setCompleteToken(String completeToken) {
95  		this.completeToken = completeToken;
96  	}
97  
98  	public String getProgressToken() {
99  		return progressToken;
100 	}
101 
102 	public void setProgressToken(String progressToken) {
103 		this.progressToken = progressToken;
104 	}
105 
106 	public LogMsg getStartMessage() {
107 		return startMessage;
108 	}
109 
110 	public void setStartMessage(LogMsg startMessage) {
111 		this.startMessage = startMessage;
112 	}
113 
114 	public LogMsg getStopMessage() {
115 		return stopMessage;
116 	}
117 
118 	public void setStopMessage(LogMsg stopMessage) {
119 		this.stopMessage = stopMessage;
120 	}
121 
122 }