KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > plugins > invocation > InvocationPlugin


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.server.plugins.invocation;
10
11 import org.jboss.portal.common.metadata.MetaData;
12 import org.jboss.portal.common.metadata.MetaDataHolder;
13 import org.jboss.portal.server.invocation.Interceptor;
14 import org.jboss.portal.server.metadata.InterceptorListMetaData;
15 import org.jboss.portal.server.metadata.InterceptorMetaData;
16 import org.jboss.portal.server.plugins.PluginService;
17
18 /**
19  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
20  * @version $Revision: 1.2 $
21  */

22 public class InvocationPlugin
23    extends PluginService
24 {
25
26    private Interceptor[] stack;
27
28    private InterceptorListMetaData metaData;
29
30    public void setMetaData(MetaData metaData)
31    {
32       this.metaData = (InterceptorListMetaData)metaData;
33    }
34
35    public MetaData getMetaData()
36    {
37       return metaData;
38    }
39
40    public void start() throws Exception JavaDoc
41    {
42       int size = metaData.getList().size();
43       Interceptor[] stack = new Interceptor[size];
44       for (int i = size - 1;i >= 0;i--)
45       {
46          InterceptorMetaData interceptorMD = (InterceptorMetaData)metaData.getList().get(i);
47          Class JavaDoc clazz = Thread.currentThread().getContextClassLoader().loadClass(interceptorMD.getClassName());
48          Interceptor interceptor = (Interceptor)clazz.newInstance();
49          stack[i] = interceptor;
50          if (interceptor instanceof MetaDataHolder)
51          {
52             ((MetaDataHolder)interceptor).setMetaData(interceptorMD);
53          }
54       }
55       this.stack = stack;
56    }
57
58    public void stop()
59    {
60       this.stack = null;
61    }
62
63    public Interceptor[] getStack()
64    {
65       return stack;
66    }
67 }
68
Popular Tags