KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > generation > PauseGenerator


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.apache.cocoon.generation;
17
18 import java.io.IOException JavaDoc;
19
20 import org.apache.cocoon.ProcessingException;
21 import org.apache.cocoon.generation.FileGenerator;
22 import org.xml.sax.SAXException JavaDoc;
23
24 /**
25  * This generator extends the usual FileGenerator with a pause parameter.
26  * During generation of the content, this generator pauses for the given
27  * amount of time.
28  * This is very usefull for caching tests.
29  *
30  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
31  * @version CVS $Id: PauseGenerator.java 30932 2004-07-29 17:35:38Z vgritsenko $
32  * @since 2.1
33  */

34 public class PauseGenerator
35     extends FileGenerator {
36
37
38     public void generate()
39     throws IOException JavaDoc, SAXException JavaDoc, ProcessingException {
40         long secs = this.parameters.getParameterAsLong("pause", 60);
41         this.getLogger().debug("Waiting for " + secs + " secs.");
42         try {
43             Thread.sleep(secs * 1000);
44         } catch (InterruptedException JavaDoc ie) {
45         }
46         this.getLogger().debug("Finished waiting.");
47         super.generate();
48     }
49
50 }
51
Popular Tags