KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > acting > ClearPersistentStoreAction


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.acting;
17
18 import org.apache.avalon.framework.parameters.Parameters;
19 import org.apache.avalon.framework.thread.ThreadSafe;
20 import org.apache.cocoon.environment.Redirector;
21 import org.apache.cocoon.environment.SourceResolver;
22 import org.apache.excalibur.store.Store;
23
24 import java.util.Map JavaDoc;
25
26 /**
27  * Simple action which ensures the persistent store is cleared.
28  *
29  * @author <a HREF="mailto:g-froehlich@gmx.de">Gerhard Froehlich</a>
30  * @version CVS $Id: ClearPersistentStoreAction.java 30932 2004-07-29 17:35:38Z vgritsenko $
31  */

32 public class ClearPersistentStoreAction extends ServiceableAction implements ThreadSafe {
33
34     public Map JavaDoc act(Redirector redirector,
35                     SourceResolver resolver,
36                     Map JavaDoc objectModel,
37                     String JavaDoc src,
38                     Parameters par
39     ) throws Exception JavaDoc {
40         if ( this.manager.hasService( Store.PERSISTENT_STORE) ) {
41             final Store store_persistent = (Store)this.manager.lookup(Store.ROLE);
42
43             try {
44                 store_persistent.clear();
45                 return EMPTY_MAP;
46             } catch (Exception JavaDoc ex) {
47                 getLogger().debug("Exception while trying to Clearing the Store", ex);
48                 return null;
49             } finally {
50                 this.manager.release( store_persistent );
51             }
52         } else {
53             getLogger().info("Unable to clear persistent store as no persistent store is configured.");
54             return null;
55         }
56     }
57 }
58
Popular Tags