01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.portal.layout.renderer.aspect.impl;
18:
19: import org.apache.avalon.framework.activity.Disposable;
20: import org.apache.avalon.framework.activity.Initializable;
21: import org.apache.cocoon.portal.event.EventManager;
22: import org.apache.cocoon.portal.event.Receiver;
23:
24: /**
25: * This aspect creates an event and subscribes to it as well
26: *
27: * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
28: *
29: * @version CVS $Id: AbstractActionAspect.java 433543 2006-08-22 06:22:54Z crossley $
30: */
31: public abstract class AbstractActionAspect 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
42: .lookup(EventManager.ROLE);
43: eventManager.unsubscribe(this );
44: } catch (Exception ignore) {
45: // ignore exceptions
46: } finally {
47: this .manager.release(eventManager);
48: }
49:
50: this .manager = null;
51: }
52: }
53:
54: /* (non-Javadoc)
55: * @see org.apache.avalon.framework.activity.Initializable#initialize()
56: */
57: public void initialize() throws Exception {
58: EventManager eventManager = null;
59: try {
60: eventManager = (EventManager) this.manager
61: .lookup(EventManager.ROLE);
62: eventManager.subscribe(this);
63: } finally {
64: this.manager.release(eventManager);
65: }
66: }
67:
68: }
|