Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Code for auto deploying your custom component

Avatar

Avatar
Validate 1
Level 5
yodadobe
Level 5

Likes

12 likes

Total Posts

298 posts

Correct Reply

10 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 5
yodadobe
Level 5

Likes

12 likes

Total Posts

298 posts

Correct Reply

10 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
yodadobe
Level 5

04-04-2013

I wrote an ant script for creating my components for me. It was still tedius to deploy them over and over in Workbench. I wrote the java app below (much of the setup is from sample files in help). I configured my Java project in my IDE to use this file as what runs and to run my ant task to build the component before running. So I can just change code, hit the quick key for run and my new code is deployed on the server to test.

import com.adobe.idp.Document;

import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;

import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;

import com.adobe.idp.dsc.registry.component.client.ComponentRegistryClient;

import com.adobe.idp.dsc.registry.infomodel.Component;

import java.io.FileInputStream;

import java.util.Properties;

public class DeployComponents {

      public static void main(String[] args) {

          try{

              //Set connection properties required to invoke LiveCycle ES2                               

            Properties connectionProps = new Properties();

            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "Your Server");

            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);

            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");

            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "Your ID");

            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "Your Password");

            //Create a ServiceClientFactory object

            ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

            //Create a ComponentRegistryClient object

            ComponentRegistryClient    componentReg = new ComponentRegistryClient(myFactory);

            //Reference a JAR file that represents the component to deploy

            FileInputStream componentFile = new FileInputStream("Your File");

            Document docComponent = new Document(componentFile);

            //Install the component

            Component myComponent;

            System.out.println("Getting current component instance.");

            myComponent = componentReg.getComponent("Name of component you put in component.xml", "version of component");

            if (myComponent.getState() != Component.STOPPED) {

                System.out.println("Stopping current component instance.");

                myComponent = componentReg.stop(myComponent);

            }

            while (myComponent.getState() != Component.STOPPED) {

                System.out.print('.');

                //Thread.sleep(10);

                myComponent = componentReg.getComponent("Name of component you put in component.xml", "version of component");

            }

            System.out.println();

            System.out.println("Uninstalling current component instance.");

            componentReg.uninstall(myComponent);

            myComponent = componentReg.install(docComponent);

            componentReg.start(myComponent);

            System.out.println("The component has been deployed");

        }

        catch(Exception e)

        {

            e.printStackTrace();

        }

    }

}