KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > invocation > portal > ViewInterceptor


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.invocation.portal;
10
11 import java.util.ArrayList JavaDoc;
12 import java.util.List JavaDoc;
13
14 import org.jboss.portal.server.Portal;
15 import org.jboss.portal.server.PortalRequest;
16 import org.jboss.portal.server.PortalServer;
17 import org.jboss.portal.server.invocation.AttachmentKey;
18 import org.jboss.portal.server.invocation.Interceptor;
19 import org.jboss.portal.server.invocation.Invocation;
20
21 /**
22  * Compute the view. Basic implementation
23  *
24  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
25  * @version $Revision: 1.4 $
26  */

27 public class ViewInterceptor implements Interceptor
28 {
29    public Object JavaDoc invoke(Invocation invocation)
30    {
31       try
32       {
33          // User the default portal as target
34
PortalRequest req = (PortalRequest)invocation.getAttachment(AttachmentKey.PORTAL_REQUEST);
35          PortalServer container = req.getServer();
36          Portal portal = container.getDefaultPortal();
37
38          // Get all windows in the portal
39
List JavaDoc windows = new ArrayList JavaDoc();
40          windows.addAll(portal.getWindows());
41
42          // Follow invocation path
43
invocation.setAttachment(AttachmentKey.VIEW, windows);
44          invocation.setAttachment(AttachmentKey.PORTAL, portal);
45          return invocation.invokeNext();
46       }
47       finally
48       {
49          invocation.removeAttachment(AttachmentKey.VIEW);
50       }
51    }
52 }
53
Popular Tags