com.ibm.portal.portlet.service
Interface PortletServiceHome
All Superinterfaces:
java.io.Serializable
- public interface PortletServiceHome
- extends java.io.Serializable
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.ibm.portal.propertybroker.service.PropertyBrokerService"); if (psh == null) System.out.println("no PropertyBrokerService Home"); else propertyFactoryService = (PropertyFactory)psh.getPortletService(com.ibm.portal.propertybroker.service.PropertyBrokerService.class); } catch(javax.naming.NameNotFoundException ex) { ... error handling ... }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.
Method Summary
Modifier and Type | Method and Description |
---|---|
|
getPortletService(java.lang.Class service)
Return a service for the given service interface.
|
Method Detail
getPortletService
- com.ibm.portal.portlet.service.PortletService getPortletService( java.lang.Class service)
- throws PortletServiceUnavailableException
Parameters:
service
- the service interface Returns:
an implementation of the requested 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.
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.