Tree PREV CLASS NEXT CLASS SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD com.ibm.portal.portlet.service
Interface PortletServiceHome
public interface PortletServiceHomeInterface for retrieving portlet services. Portlet services are accessed by a JNDI lookup; the lookup returns an implementation of this interface, which allows to get the actual portlet service.
The default JNDI name for looking up a portletservice is portletservice/ followed by the name of the service interface. If a portal provides any implementation for a portlet service interface, it will always register the service under that name.
If an application requires more flexibility in the selection of a portlet service implementation, it may instead look up the portlet service under a portlet specific JNDI alias; the administrator is then responsible for mapping that alias to an actual service implementation using the application server administration facilities.
Coding example for looking up a service:
PortletServiceHome psh; javax.naming.Context ctx = new javax.naming.InitialContext(); try { psh = (PortletServiceHome) ctx.lookup("portletservice/com.mycomp.WombatService"); } catch(javax.naming.NameNotFoundException ex) { ... error handling ... } ... // use the service WombatService service = (WombatService) psh.getService(WombatService.class); service.feedWombat();The returned PortletServiceHome object is valid for the lifetime of the portal. It is recommended to perform the JNDI lookup in the init method of the portlet and store the PortletServiceHome object home in an instance variable. Note that it is not permitted to access references to the actual service for longer than one request. The service must be retrieved again from the PortletServiceHome object whenever it is used in another request.
- Since:
- 5.1
Method Summary
<T extends PortletService>
TgetPortletService(java.lang.Class<T> service)
Return a service for the given service interface.
Method Detail getPortletService
<T extends PortletService> T getPortletService(java.lang.Class<T> service) throws PortletServiceUnavailableException
- Return a service for the given service interface.
Service references obtained by calling this method may only be accessed within the request in which they were retrieved.
Note that you may cast the returned service only to the interface that has been requested. Programmers must not assume that the returned object will be the actual implementation of the service, it may also be a proxy object that passes calls to the service implementation. Therefore it is illegal to cast the returned service to any extended or alternative interface.
- Parameters:
- service - the service interface
- Returns:
- an implementation of the reqested interface
- Throws:
- PortletServiceIllegalInterfaceException - if the service home cannot provide an an implementation for the requested interface.
- PortletServiceInstatiationException - if the creation of a service implementation failed.
- PortletServiceUnvailableException - if a service implementation could be created but an exception occured during the service-specific intialization.
- PortletServiceUnavailableException
Tree PREV CLASS NEXT CLASS SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD