Interface PortletServiceHome

  • All Superinterfaces:


    public interface PortletServiceHome
    Interface 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/");
      if (psh == null) 
       System.out.println("no PropertyBrokerService Home");
       propertyFactoryService = (PropertyFactory)psh.getPortletService(;
     } 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 getPortletService(java.lang.Class 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.

        service - the service interface
        an implementation of the requested interface
        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.
IBM WebSphere Application ServerTM
Release 9.0