public static void main(String[] argv) { // Create and start the engine ... ModeShapeEngine engine = new ModeShapeEngine(); engine.start(); // Load the configuration for a repository via the classloader (can also use path to a file)... Repository repository = null; String repositoryName = null; try { URL url = ModeShapeExample.class.getClassLoader().getResource("my-repository-config.json"); RepositoryConfiguration config = RepositoryConfiguration.read(url); // We could change the name of the repository programmatically ... // config = config.withName("Some Other Repository"); // Verify the configuration for the repository ... Problems problems = config.validate(); if (problems.hasErrors()) { System.err.println("Problems starting the engine."); System.err.println(problems); System.exit(-1); } // Deploy the repository ... repository = engine.deploy(config); repositoryName = config.getName(); } catch (Throwable e) { e.printStackTrace(); System.exit(-1); return; } Session session = null; try { // Get the repository repository = engine.getRepository(repositoryName); // Create a session ... session = repository.login("default"); // Get the root node ... Node root = session.getRootNode(); assert root != null; System.out.println( "Found the root node in the \"" + session.getWorkspace().getName() + "\" workspace"); } catch (RepositoryException e) { e.printStackTrace(); } finally { if (session != null) session.logout(); System.out.println("Shutting down engine ..."); try { engine.shutdown().get(); System.out.println("Success!"); } catch (Exception e) { e.printStackTrace(); } } }
@BeforeClass public static void beforeAll() throws Exception { RepositoryConfiguration config = RepositoryConfiguration.read("config/repo-config-git-federation.json"); startRepository(config); // registerNodeTypes("cnd/flex.cnd"); Session session = getSession(); Node testRoot = session.getRootNode().addNode("repos"); session.save(); FederationManager fedMgr = session.getWorkspace().getFederationManager(); fedMgr.createProjection(testRoot.getPath(), "local-git-repo", "/", "git-modeshape"); }
@Override protected RepositoryConfiguration createRepositoryConfiguration( String repositoryName, Environment environment) throws Exception { return RepositoryConfiguration.read(getRepositoryConfigStream(), repositoryName) .with(environment); }