You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Jetspeed Binette <je...@adinquiry.com> on 2011/02/20 23:44:19 UTC

ServletContextListener for Portlets

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

Re: ServletContextListener for Portlets

Posted by Jetspeed Binette <je...@adinquiry.com>.
I'm thinking org.apache.jetspeed.Jetspeed was added after Jetspeed 2.1? I
have jetspeed-commons-2.1.jar and jetspeed-api-2.1.jar and neither of these
have the org.apache.jetspeed.Jetspeed class.

We are going to be upgrading to the latest Jetspeed in the next few months
so if needed, I guess I can wait until then. I just want to make sure I'm
not missing something.

--
Michael Binette

On Tue, Feb 22, 2011 at 3:14 AM, David Taylor <da...@gmail.com>wrote:

> On Sun, Feb 20, 2011 at 2:44 PM, Jetspeed Binette
> <je...@adinquiry.com> 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: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

Re: ServletContextListener for Portlets

Posted by David Taylor <da...@gmail.com>.
On Sun, Feb 20, 2011 at 2:44 PM, Jetspeed Binette
<je...@adinquiry.com> 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: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org