On Sun, Feb 20, 2011 at 2:44 PM, Jetspeed Binette
<[email protected]> wrote:
> I use a ServletContextListener to setup a bunch of java.util.TimerTask
> routines that run hourly, importing some files. There is a new requirement
> that fits this same pattern but it needs to access the Jetspeed UserManager
> and GroupManager. I do this in other parts of our app but only from
> Portlets. I use the PortletContext to get the global UserManager and it
> works perfectly.
>
> My issue is that I don't have access to PortletConfig or PortletContext from
> the ServletContextListenener.
>
> Where would the best place to be to create my TimerTask and have access to
> the PortletContext. I've seen Liferay has a PortletContextListener that can
> be used to replace the ServletContextListener but I don't see the
> same/similar thing for Jetspeed.
>
> Or, is there some way to get a handle of the PortletConfig/PortletContext
> from within my current ServletContextListener?
>
> --
> Michael Binette
>
Not sure if this is the best advice, but there is a static accessor to
get Jetspeed spring beans from the shared jetspeed-commons jar,
Jetspeed.getComponentManager().getComponent("spring-id-or-name-of-component"),
which you can call from the ServletContextListener. I prefer not to
use this method since it lets you access any spring bean whether or
not its a public service, plus it totally bypasses using the
PortletContext/jetspeed-portlet.xml. I will review this again later
and see if I can find a better way

So for the two services referenced above:

UserManager userManager = (UserManager)
    
Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.security.UserManager");
GroupManager userManager = (GroupManager)
    
Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.security.GroupManager");

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to