/******************************************************************************* * Copyright (c) 2007 Cambridge Semantics Incorporated. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Cambridge Semantics Incorporated *******************************************************************************/ package org.openanzo.client.sample; import org.openanzo.client.AnzoClient; import org.openanzo.client.AnzoClientConfigurationFactory; import org.openanzo.rdf.RDFFormat; import org.openanzo.rdf.utils.ReadWriteUtils; import org.openanzo.rdf.utils.SmartEncodingInputStream; /** * * This simple example instantiates a client AnzoClient that connects to the server. This example works against the ready-to-run standalone server. * <p> * In this example, show how to reset the repository. The features is useful in testing, but is not meant for use in production environments. * <p> * * @author Ben Szekely ( <a href="mailto:ben@cambridgesemantics.com">ben@cambridgesemantics.com </a> * */ public class ResetRepository { /** * Test reset repository * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { AnzoClient anzoClient = null; // use a try-finally to make sure the anzoClients are closed properly try { // prepare the configuration for the client String username = "default"; String password = "123"; String host = "localhost"; int port = 61616; boolean useSsl = false; // instantiate a anzo client anzoClient = new AnzoClient(AnzoClientConfigurationFactory.createJMSConfiguration(username, password, host, port, useSsl)); // connect the client anzoClient.connect(); anzoClient.reset(ReadWriteUtils.loadStatements(SmartEncodingInputStream.createSmartReader(ResetRepository.class.getClassLoader().getResourceAsStream("initialize.trig")), RDFFormat.TRIG, ""), null); System.err.println("The repository has been reset."); } finally { if (anzoClient != null) anzoClient.close(); } } }