Service SPI 

You can use the IBM Connections Service SPI to learn about the applications running in your IBM Connections deployment.

You can use the Service SPIs to learn the following information about each application:

In addition, you can use the service SPIs to build accurate, fully qualified web addresses to each application service.

Example:

import java.net.URL;
 
import com.ibm.connections.spi.service.Service;
import com.ibm.connections.spi.service.ServiceHelper;
import com.ibm.connections.spi.service.ServiceNotAvailableException;
 
 
public class ServiceSPIExample {
 
     private static final String PROFILE_PATH = 
     "/html/profileView.do?userid=";
     
     /*
      * Example check to see if the Activities service is enabled
      */
     public boolean isActivitiesEnabled() {
        return Service.ACTIVITIES.isEnabled();
     }
 
     /*
      * Example use of the ServiceHelper to build product URLs.
      */
     public URL getPersonProfile(String userid) {
       URL profileURL = null;
 
       try {
         profileURL = 
         ServiceHelper.INSTANCE().buildURLFromPath(Service.PROFILES, 
         PROFILE_PATH + userid, false);
       } catch (ServiceNotAvailableException snae) {
          // PROFILES service is not installed, or is not enabled
       }
       
       return profileURL;
     }
     
     /*
      * Example use of Service to print out details of all 
     * installed services
      */
     public void printServices() {        
        for(Service service: ServiceHelper.INSTANCE().getInstalledServices()) {
           boolean enabled = service.isEnabled();
           URL serviceURL = null;
           if(enabled) {
              try {
                 serviceURL = service.getServiceURL();
              } catch (ServiceNotAvailableException snae) {
                 // We know
              }
           }
           
           System.out.println("Service name: " + service.name());
           System.out.println("Service enabled: " + enabled);
           if(serviceURL != null) {
              System.out.println("Service URL: " + serviceURL.toExternalForm());
           }
        }
     }
}

For more information about how to use the SPI, see the IBM_Connections_3.0.1_Service_and_User_SPI">Service SPI javadoc.


Parent topic

IBM Connections SPIs

+

Search Tips   |   Advanced Search