KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > layout > renderer > aspect > impl > AbstractActionAspect


1 /*
2  * Copyright 1999-2002,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.portal.layout.renderer.aspect.impl;
17
18 import org.apache.avalon.framework.activity.Disposable;
19 import org.apache.avalon.framework.activity.Initializable;
20 import org.apache.cocoon.portal.event.EventManager;
21 import org.apache.cocoon.portal.event.Receiver;
22
23 /**
24  * This aspect creates an event and subscribes to it as well
25  *
26  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
27  *
28  * @version CVS $Id: AbstractActionAspect.java 219049 2005-07-14 15:11:52Z cziegeler $
29  */

30 public abstract class AbstractActionAspect
31     extends AbstractAspect
32     implements Receiver, Disposable, Initializable {
33
34     /* (non-Javadoc)
35      * @see org.apache.avalon.framework.activity.Disposable#dispose()
36      */

37     public void dispose() {
38         if ( this.manager != null ) {
39             EventManager eventManager = null;
40             try {
41                 eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
42                 eventManager.unsubscribe( this );
43             } catch (Exception JavaDoc ignore) {
44                 // ignore exceptions
45
} finally {
46                 this.manager.release( eventManager );
47             }
48             
49             this.manager = null;
50         }
51     }
52
53     /* (non-Javadoc)
54      * @see org.apache.avalon.framework.activity.Initializable#initialize()
55      */

56     public void initialize() throws Exception JavaDoc {
57         EventManager eventManager = null;
58         try {
59             eventManager = (EventManager)this.manager.lookup(EventManager.ROLE);
60             eventManager.subscribe( this );
61         } finally {
62             this.manager.release( eventManager );
63         }
64     }
65
66 }
67
Popular Tags