01: /**
02: * $Id: GenericPortletMembershipListener.java,v 1.4 2007/02/06 22:10:19 pm95875 Exp $
03: * Copyright 2005 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.portlet.service.provision;
14:
15: import javax.servlet.ServletContext;
16: import javax.portlet.PortletContext;
17:
18: /**
19: * An abstract class implementing PortletMembershipListener.
20: * Listeners can be configured for each portlet in sun-portlet.xml file.
21: * Methods on these listeners are invoked everytime a member is added or removed in a
22: * community, that is using this portlet. Framework initializes the listener instance with
23: * the PortletContext in the init() method.
24: */
25: abstract public class GenericPortletMembershipListener implements
26: PortletMembershipListener {
27:
28: private PortletContext _portletContext;
29: private ServletContext _servletContext;
30:
31: /**
32: * Called by framework when an instance is created. When overwritten, super.init(context) must
33: * be called to initialize it correctly.
34: *
35: * @param pc portlet context
36: * @param sc servlet context
37: * @exception com.sun.portal.portlet.service.provision.PortletMembershipException
38: */
39: public void init(PortletContext pc)
40: throws PortletMembershipException {
41: _portletContext = pc;
42: _servletContext = null;
43: }
44:
45: /**
46: * Called by framework when an instance is created. When overwritten, super.init(context) must
47: * be called to initialize it correctly.
48: *
49: * @param pc portlet context
50: * @exception com.sun.portal.portlet.service.provision.PortletMembershipException
51: */
52: public void init(PortletContext pc, javax.servlet.ServletContext sc)
53: throws PortletMembershipException {
54: _portletContext = pc;
55: _servletContext = sc;
56: }
57:
58: /**
59: * returns the PortletContext.
60: * @return PortletContext
61: */
62: public PortletContext getPortletContext() {
63: return _portletContext;
64: }
65:
66: /**
67: * returns the ServletContext.
68: * @return ServletContext
69: */
70: public ServletContext getServletContext() {
71: return _servletContext;
72: }
73:
74: /**
75: * Called when a member is added to the community.
76: *
77: * @param event membership event
78: * @exception com.sun.portal.portlet.service.provision.PortletMembershipException
79: */
80: abstract public void memberAdded(PortletMembershipEvent event)
81: throws PortletMembershipException;
82:
83: /**
84: * Called when a member is removed from the community.
85: *
86: * @param event
87: * @exception com.sun.portal.portlet.service.provision.PortletMembershipException
88: */
89: abstract public void memberRemoved(PortletMembershipEvent event)
90: throws PortletMembershipException;
91:
92: }
|