Package org.modeshape.jcr

Examples of org.modeshape.jcr.ModeShapeEngine


    protected static boolean print = true;

    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 = SequencerDemo.class.getClassLoader().getResource("my-repository.json");
            RepositoryConfiguration config = RepositoryConfiguration.read(url);

            // Verify the configuration for the repository ...
            Problems problems = config.validate();
            if (problems.hasErrors()) {
                //CHECKSTYLE:OFF
                System.err.println("Problems starting the engine.");
                System.err.println(problems);
                System.exit(-1);
                //CHECKSTYLE:ON
            }

            // Deploy the repository ...
            repository = engine.deploy(config);
            repositoryName = config.getName();
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(-1);
            return;
        }

        Session session = null;
        JcrTools tools = new JcrTools();
        try {
            // Get the repository
            repository = engine.getRepository(repositoryName);

            // Create a session ...
            session = repository.login("default");

            // Create the '/files' node that is an 'nt:folder' ...
            Node root = session.getRootNode();
            Node filesNode = root.addNode("files", "nt:folder");
            assert filesNode != null;

            // Update a couple of files ...
            tools.uploadFile(session, "/files/caution.png", getFile("caution.png"));
            tools.uploadFile(session, "/files/sample1.mp3", getFile("sample1.mp3"));
            tools.uploadFile(session, "/files/fixedWidthFile.txt", getFile("fixedWidthFile.txt"));
            tools.uploadFile(session, "/files/JcrRepository.class", getFile("JcrRepository.clazz"));

            // Save the session ...
            session.save();

            // Now look for the output. Note that sequencing may take a bit, so we'll cheat by just trying
            // to find the node until we can find it, waiting a maximum amount of time before failing.
            // The proper way is to either use events or not to expect the sequencers have finished.
            Node png = findNodeAndWait(session, "/images/caution.png", 10, TimeUnit.SECONDS);
            if (print) tools.printSubgraph(png);

            Node sampleMp3 = findNodeAndWait(session, "/audio/sample1.mp3", 10, TimeUnit.SECONDS);
            if (print) tools.printSubgraph(sampleMp3);

            Node javaClass = findNodeAndWait(session, "/java/JcrRepository.class", 10, TimeUnit.SECONDS);
            if (print) tools.printSubgraph(javaClass);

            Node textFile = findNodeAndWait(session, "/text/fixedWidthFile.txt", 10, TimeUnit.SECONDS);
            if (print) tools.printSubgraph(textFile);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (session != null) session.logout();
            //CHECKSTYLE:OFF
            System.out.println("Shutting down engine ...");
            try {
                engine.shutdown().get();
                System.out.println("Success!");
            } catch (Exception e) {
                e.printStackTrace();
            }
            //CHECKSTYLE:ON
View Full Code Here


    public void start(ServletContext context) throws RemoteException {
        String url = context.getInitParameter("config-url");
       
        repositoryNames = new ArrayList<>();
       
        engine = new ModeShapeEngine();
        engine.start();
       
        try {
            RepositoryConfiguration config = RepositoryConfiguration.read(context.getResource(url));
            engine.deploy(config);
View Full Code Here

        environment = new TestingEnvironment(this);
        txnMgr = org.infinispan.test.TestingUtil.getTransactionManager(environment.getCacheContainer().getCache(REPO_NAME));
        INFINISPAN_STARTUP.stop();
        MODESHAPE_STARTUP.start();
        config = new RepositoryConfiguration(REPO_NAME, environment);
        engine = new ModeShapeEngine();
        engine.start();
        engine.deploy(config);
        repository = engine.startRepository(config.getName()).get();
        session = repository.login();
        MODESHAPE_STARTUP.stop();
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.ModeShapeEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.