Take a survey

API Quick Starts (Code Examples) > Components and Services API Quick Starts > Quick Start: Removing components using the Java API

Quick Start: Removing components using the Java API
The following Java code example removes a component by using the Java API.
package com.adobe.sample.components;
/**
 * This Java Quick Start deploys a component using the Java API
 * and uses the following JAR files:
 * 1. adobe-livecycle-client.jar
 * 2. adobe-usermanager-client.jar
 * 3. adobe-workflow-client-sdk.jar
 * 4. adobe-utilities.jar
 * 5. jbossall-client.jar (use a different JAR file if LiveCycle ES is not deployed on Jboss)
 */
import java.util.*;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.registry.component.client.*;
import com.adobe.idp.dsc.registry.infomodel.Component;
 
public class RemoveComponent {
 
	public static void main(String[] args) {
		
		try{
			//Set connection properties	
			Properties ConnectionProps = new Properties();
			ConnectionProps.setProperty("DSC_DEFAULT_EJB_ENDPOINT", "jnp://localhost:1099");
			ConnectionProps.setProperty("DSC_TRANSPORT_PROTOCOL","EJB");          
			ConnectionProps.setProperty("DSC_SERVER_TYPE", "JBoss");
			ConnectionProps.setProperty("DSC_CREDENTIAL_USERNAME", "administrator");
			ConnectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", "password");
			
			//Create a ServiceClientFactory object
			ServiceClientFactory myFactory = ServiceClientFactory.createInstance(ConnectionProps);
 
			//Create a ComponentRegistryClient object
			ComponentRegistryClient	componentReg = new ComponentRegistryClient(myFactory); 
			
			//Retrieve the Id of the component to remove from the service container
			Component myComponent = componentReg.getComponent("com.adobe.livecycle.sample.email.emailSampleComponent", "1.0");
			
			//Determine if the component is in a running state
			if (myComponent.getState()== Component.RUNNING)
			{
				//Stop the component
				Component stoppedComponent = componentReg.stop(myComponent);
				
				//Uninstall the component
				componentReg.uninstall(stoppedComponent);
			}
			else
				componentReg.uninstall(myComponent);
				
			System.out.println("The component was removed.");
			}
			
			catch(Exception e)
			{
				e.printStackTrace();
			}
	}
}
 

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/quickStarts_Components.22.6.html