This documentation is for WSO2 ESB version 4.5.0. View documentation for the latest release.

Backup WSO2 Registry Resource to a File

Following code shows, how to programmetically backup WSO2 Registry Resource to a file using RemoteRegistry.

import org.wso2.carbon.registry.app.RemoteRegistry;
import org.wso2.carbon.registry.core.exceptions.RegistryException;

import java.net.URL;
import java.net.MalformedURLException;
import java.io.FileWriter;
import java.io.FileReader;
import java.io.IOException;

public class RemoteRegistrySampleTest {
  public static void main(String[] args) {
    System.setProperty("javax.net.ssl.trustStore", "CARBON_HOME/resources/security/client-truststore.jks");
    System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
    System.setProperty("javax.net.ssl.trustStoreType", "JKS");

    RemoteRegistry esb2xRemoteRegistry = null;
    try {
      esb2xRemoteRegistry = new RemoteRegistry(new URL("https://localhost:9443/registry"), "admin", "admin");
      esb2xRemoteRegistry.dump("/esb-resources", new FileWriter("/home/heshan/Dev/wso2_heshan/temp/registry.xml"));
    } catch (RegistryException e) {
      e.printStackTrace();
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}