package com.sap.mdm.examples; import com.sap.mdm.commands.CommandException; import com.sap.mdm.commands.GetRunningRepositoryListCommand; import com.sap.mdm.net.ConnectionException; import com.sap.mdm.net.ConnectionPool; import com.sap.mdm.net.ConnectionPoolFactory; import com.sap.mdm.server.RepositoryIdentifier; /* * Copyright © 2004-2006 by SAP AG. * All Rights Reserved. * * SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP * products and services mentioned herein as well as their respective logos are * trademarks or registered trademarks of SAP AG in Germany and in several other * countries all over the world. All other product and service names mentioned * are the trademarks of their respective companies. Data contained in this * document serves informational purposes only. National product specifications * may vary. * * These materials are subject to change without notice. These materials are * provided by SAP AG and its affiliated companies (SAP Group) for informational * purposes only, without representation or warranty of any kind, and SAP Group * shall not be liable for errors or omissions with respect to the materials. * The only warranties for SAP Group products and services are those that are * set forth in the express warranty statements accompanying such products and * services, if any. Nothing herein should be construed as constituting an * additional warranty. * */ /** * This example demonstrates retrieving the list of running (loaded) * repositories. The steps are: *
    *
  1. Establishes connection to the MDM server
  2. *
  3. Retrieves the list of running MDM repositories
  4. *
* Commands used:
* GetRunningRepositoryListCommand
*
* Source code for * GetRunningRepositories.java */ public class GetRunningRepositories { private GetRunningRepositories() { } public static void main(String[] args) { // create connection pool String connectionTag = "LOCALHOST"; ConnectionPool connections = null; try { connections = ConnectionPoolFactory.getInstance(connectionTag); } catch (ConnectionException e) { e.printStackTrace(); return; } // get a list of running repositories // this is one of the few commands that doesn't require a session GetRunningRepositoryListCommand cmd = new GetRunningRepositoryListCommand(connections); try { cmd.execute(); } catch (CommandException e) { e.printStackTrace(); return; } RepositoryIdentifier[] reposIds = cmd.getRepositories(); for (int i = 0; i < reposIds.length; i++) { System.out.println(reposIds[i].getName()); } } }