Hi Frank,

Frank Villarreal wrote:

Question about Portal Services:

I know that in Pluto, you are able to create a "Portal Service" that may be
utilized by the portlet container (and in effect, portlets within it). I've
noted that in Jetspeed2, services are configured within the Spring file
"jetspeed-spring.xml". Another thing that I also noticed, is that the
services defined within that assembly file did not appear to implement any
special interface ... whereas in Pluto I was under the impression that
"services" had to implement a designated "Service" interface (w/init &
destroy methods). Is this not the case in J2's implementation?


No it is not the case with J2. The Spring Framework allows us the flexibility of developing a service layer without having to implement specific lifecyclye and other interfaces.

But anyway .... here is my MAIN question .... HOW do you get acquire a
"reference" on a portal service instance from within a portlet's "init" or
"processAction" methods???? For example, if I created a service in J2 named
"MyService", from within my portlet's init method, how do I grab a handle on
it?


if you look inside the jetspeed-spring.xml, you will notice this bean definition near the top:

<!-- Portlet Services -->
<bean id="PortalServices"
class="org.apache.jetspeed.services.JetspeedPortletServices" >
<constructor-arg>
<map>
<entry key="PortletRegistryComponent">
<ref bean="org.apache.jetspeed.components.portletregistry.PortletRegistry" />
</entry>
<entry key="SearchComponent">
<ref bean="org.apache.jetspeed.search.SearchEngine"/>
</entry>
<entry key="PAM">
<ref bean="PAM" />
</entry> <entry key="UserManager">
<ref bean="org.apache.jetspeed.security.UserManager"/>
</entry>
<entry key="PageManager">
<ref bean="org.apache.jetspeed.page.PageManager"/>
</entry>
<entry key="RoleManager">
<ref bean="org.apache.jetspeed.security.RoleManager"/>
</entry>
<entry key="GroupManager">
<ref bean="org.apache.jetspeed.security.GroupManager"/>
</entry> <entry key="Profiler">
<ref bean="org.apache.jetspeed.profiler.Profiler"/>
</entry> <entry key="SSO">
<ref bean="org.apache.jetspeed.sso.SSOProvider"/>
</entry> <entry key="EntityAccessor">
<ref bean='org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent'/>
</entry>
</map>
</constructor-arg>
</bean>


This bean exposes pre-existing services (defined further down within the jetspeed-spring.xml) that can subsequently be accessed by you portlets through the javax.portlet.PortletContext.

For a portlet to access an exposed service, you will need to define a jetspeed-portlet.xml extended deployment descriptor to your portlet app. This file lives in the WEB-INF directory of your application. This example is taken from the the jetspeed-portlet.xml in the applications/pam portlet app in jetspeed:

<portlet-app id="security" version="1.0"
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd";
xmlns:js="http://portals.apache.org/jetspeed";
xmlns:dc="http://www.purl.org/dc";>
<dc:title>Security Portlets</dc:title>
<dc:title xml:lang="en">Security Portlets</dc:title>
<dc:creator>J2 Team</dc:creator>
<portlet>
<portlet-name>LoginPortlet</portlet-name>
<dc:title>Login Portlet</dc:title>
<dc:creator>J2 Team</dc:creator>
</portlet>


   <portlet>
       <portlet-name>LocaleSelectorPortlet</portlet-name>
       <dc:title>Locale Selector Portlet</dc:title>
       <dc:creator>J2 Team</dc:creator>
   </portlet>

<js:services>
<js:service name='SearchComponent'/>
<js:service name='PortletRegistryComponent'/>
<js:service name='UserManager'/>
<js:service name='PageManager'/>
<js:service name='RoleManager'/>
<js:service name='GroupManager'/>
<js:service name='Profiler'/>
</js:services>
</portlet-app>


notice the <js:services> element, this is where you would define which, previously defined services should be made available to this app.

Here is an example of accessing the Portlet Registry service within a portlet:

PortletRegistry registry = (PortletRegistry)context.getAttribute("cps:PortletRegistryComponent");

Notice that all service are prefixed with "cps:" automatically to avoid collisions with any other attributes the might be in the portlet contenxt.

HTH,




Example ....

public class MyPortlet extends GenericServletPortlet
{
   public void init(PortletConfig config)
        throws PortletException
   {
       super.init(config);
       MyService myserv = (MyService) <<????WHAT-GOES-HERE????>>;
       if (null == myserv)
       {
           throw new PortletException("Could not acquire MyService!");
       }
   }
}


I'm having a very hard time finding any discussion or documentation on this anywhere ... hey, I even bought the book by Jeff Linwood and Dave Minter about building portals ... still no luck ...

Thanks,

- Frank


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]







--
"Great minds discuss ideas. Average minds discuss events. Small minds discuss 
people."  - Admiral Hyman Rickover

*******************************************
*           Scott T. Weaver               *
*         <[EMAIL PROTECTED]>             *
*     <http://www.einnovation.com>        *
* --------------------------------------  *
*   Apache Jetspeed Enterprise Portal     *
*     Apache Pluto Portlet Container      *
*                                         *
* OpenEdit, Website Content Management    *
*     <http://www.openedit.org>           *
*******************************************


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to