Community articleService SPI
Added by IBM contributorIBM on June 26, 2014
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

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



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:
  • Whether an application is installed
  • Whether an application is enabled
  • Web address of the application
  • Web address used to communicate with the application from another application
In addition, you can use the service SPIs to build accurate, fully qualified web addresses to each application service.

The lc.spi.jar file contains the Server and User SPIs and is stored in the EAR file in the root installation directory of the following IBM Connections applications: Activities, Blogs, Communities, Bookmarks, Files, Forums, News, and Wikis.

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());
			  }
		  }
	  }
}



You can either: