KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mx > interceptor > Interceptor


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.mx.interceptor;
23
24 import org.jboss.logging.Logger;
25 import org.jboss.mx.server.Invocation;
26
27 /**
28  * This interface defines MBean interceptors. All MBean interceptors must
29  * implement this interface.
30  *
31  * @see org.jboss.mx.interceptor.AbstractInterceptor
32  *
33  * @author <a HREF="mailto:juha@jboss.org">Juha Lindfors</a>.
34  * @version $Revision: 37459 $
35  */

36 public interface Interceptor
37 {
38
39    /**
40     * Returns the name of this interceptor. Notice that for shared interceptors
41     * this name must be unique among the shared interceptors in the MBean
42     * server.
43     */

44    String JavaDoc getName();
45    
46    /**
47     * Returns true if this interceptor is shared by multiple invokers;
48     * false otherwise. Non-shared interceptors should always return false.
49     * Shared interceptors return false if they have not been registered
50     * to the MBean server yet. Shared interceptors must always return true
51     * after they have been registered to the server.
52     *
53     * @return true if shared;false otherwise
54     */

55    boolean isShared();
56       
57    /**
58     * The <tt>invoke</tt> method is called when the invocation object passes
59     * this interceptor.
60     */

61    Object JavaDoc invoke(Invocation invocation) throws Throwable JavaDoc;
62
63    /**
64     * Called by the {@link org.jboss.mx.server.MBeanInvoker MBeanInvoker} on
65     * a non-shared interceptors to set a logger reference for this interceptor.
66     * The interceptor implementation may use the invoker's logger for recording
67     * log information. <p>
68     *
69     * Shared interceptors should set up their log facility through other means
70     * as they are invoked by several different MBean invokers. To access the
71     * log implementation of the originating invoker for a particular invocation,
72     * an interceptor may query they invocation context for invoker reference.
73     */

74    void setLogger(Logger log);
75
76    /**
77     * This method is part of the interceptor's lifecycle. It is
78     * called by the invoker during the initialization of the interceptor
79     * instance. <p>
80     *
81     * For shared interceptors the lifecycle is driven by the MBean registration.
82     * This method is called before the MBean is registered to the server. <p>
83     *
84     * Concrete interceptor implementations can override this method to provide
85     * initialization code that should be executed before the interceptor
86     * is registered. <p>
87     *
88     * Any exception that is propagated from this method to its caller will
89     * cancel the interceptor registration.
90     *
91     * @throws Exception if you want to cancel the interceptor registration
92     */

93    void init() throws Exception JavaDoc;
94
95    /**
96     * This method is part of the interceptor's lifecycle. It is
97     * called by the invoker during the interceptor initialization process. <p>
98     *
99     * For shared interceptors the lifecycle is driven by the MBean registration.
100     * This method is called after the MBean is registered to the
101     * server as part of the
102     * {@link javax.management.MBeanRegistration#postRegister} execution. <p>
103     *
104     * Concrete interceptor implementations can override this method to provide
105     * initialization code that should be executed once the MBean server and
106     * object name references for this interceptor have been resolved.
107     */

108    void start();
109
110    /**
111     * This method is part of the interceptor lifecycle. It is
112     * called by the invoker during the interceptor removal. <p>
113     *
114     * For shared interceptors the lifecycle is driven by the MBean
115     * unregistration. This method is called after the MBean is registered to the
116     * server as part of the
117     * {@link javax.management.MBeanRegistration#preDeregister} execution. <p>
118     *
119     * Concrete interceptor implementations can override this
120     * method to provide cleanup code that should be executed before the
121     * interceptor is unregistered. <p>
122     *
123     * Any exception that is propagated from this method to its caller will
124     * cancel the interceptor unregistration.
125     *
126     * @throws Exception if you want to cancel the interceptor unregistration
127     */

128    void stop() throws Exception JavaDoc;
129
130    /**
131     * This method is part of the interceptor lifecycle. It is called by the
132     * invoker durin the interceptor removal. <p>
133     *
134     * For shared interceptors the lifecycle is driven by the MBean
135     * unregistration. This method is called after the MBean is registered to the
136     * server as part of the
137     * {@link javax.management.MBeanRegistration#postDeregister} execution. <p>
138     *
139     * Concrete interceptor implementations can override this method to provide
140     * cleanup code that should be executed once the interceptor is no longer
141     * registered to the MBean server.
142     */

143    void destroy();
144    
145 }
146
147
148
Popular Tags