Examples of MicroKernel


Examples of org.apache.jackrabbit.mk.api.MicroKernel

        KernelNodeState oldBase = base;
        NodeState oldHead = head;
        String oldHeadRevision = headRevision;
        boolean success = false;
        try {
            MicroKernel kernel = store.getKernel();
            JsopDiff diff = new JsopDiff(store);
            if (headRevision == null) {
                // no persistent branch yet
                if (head.equals(base)) {
                    // nothing to persist
                    success = true;
                    return;
                } else {
                    // create branch
                    headRevision = kernel.branch(base.getRevision());
                    head.compareAgainstBaseState(base, diff);
                }
            } else {
                // compare against head of branch
                NodeState branchHead = store.getRootState(headRevision);
                if (head.equals(branchHead)) {
                    // nothing to persist
                    success = true;
                    return;
                } else {
                    head.compareAgainstBaseState(branchHead, diff);
                }
            }
            // if we get here we have something to persist
            // and a branch exists
            headRevision = kernel.commit("", diff.toString(), headRevision, null);
            head = store.getRootState(headRevision);
            success = true;
        } finally {
            // revert to old state if unsuccessful
            if (!success) {
View Full Code Here

Examples of org.apache.jackrabbit.mk.api.MicroKernel

    protected SolrServer server;
    protected OakSolrConfiguration configuration;

    @Before
    public void setUp() throws Exception {
        MicroKernel microKernel = new MicroKernelImpl();
        store = new KernelNodeStore(microKernel);
        state = createInitialState(microKernel);
        server = TestUtils.createSolrServer();
        configuration = TestUtils.getTestConfiguration();
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.api.MicroKernel

    public static RepositoryFixture getMemory(final long cacheSize) {
        return new OakRepositoryFixture("Oak-Memory") {
            @Override
            public Repository[] setUpCluster(int n) throws Exception {
                Repository[] cluster = new Repository[n];
                MicroKernel kernel = new MicroKernelImpl();
                for (int i = 0; i < cluster.length; i++) {
                    Oak oak = new Oak(new KernelNodeStore(kernel, cacheSize));
                    cluster[i] = new Jcr(oak).createRepository();
                }
                return cluster;
View Full Code Here

Examples of org.apache.jackrabbit.mk.api.MicroKernel

    @Override
    @Before
    public void setUp() throws Exception {
        super.setUp();
        MicroKernel microKernel = new MicroKernelImpl();
        store = new KernelNodeStore(microKernel);
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.api.MicroKernel

*/
public class PropertyIndexTest {

    @Test
    public void test() {
        MicroKernel mk = new MicroKernelImpl();
        Indexer indexer = new Indexer(mk, "index");
        indexer.init();
        PropertyIndex index = indexer.createPropertyIndex("id", true);

        String head = mk.getHeadRevision();

        // meta data
        String meta = mk.getNodes("/index", head);
        Assert.assertEquals("{\":childNodeCount\":1,\"id:id\":{\":childNodeCount\":0}}", meta);

        String oldHead = head;

        Assert.assertEquals(null, index.getPath("1", head));

        head = mk.commit("/", "+\"test\" : {\"id\":\"1\"}", head, null);
        head = mk.commit("/", "+\"test2\" : {\"id\":\"2\"}", head, null);

        Assert.assertEquals("/test", index.getPath("1", head));
        Assert.assertEquals("/test2", index.getPath("2", head));

        Assert.assertEquals("/test", index.getPath("1", oldHead));
        Assert.assertEquals("/test2", index.getPath("2", oldHead));

        Assert.assertEquals("/test", index.getPath("1", head));
        Assert.assertEquals("/test2", index.getPath("2", head));

        head = mk.commit("/", "-\"test2\"", head, null);
        head = mk.commit("/test", "+\"test\" : {\"id\":\"3\"}", head, null);

        Assert.assertEquals("/test/test", index.getPath("3", head));

        // Recreate the indexer
        indexer = new Indexer(mk);
        indexer.init();
        index = indexer.createPropertyIndex("id", true);
        head = mk.getHeadRevision();
        Assert.assertEquals("/test/test", index.getPath("3", head));
        Assert.assertEquals(null, index.getPath("0", head));

        Assert.assertEquals("/test", index.getPath("1", head));
        head = mk.commit("/", "^ \"test/id\": 100", head, null);
        Assert.assertEquals(null, index.getPath("1", head));
        Assert.assertEquals("/test", index.getPath("100", head));

        Assert.assertEquals("/test/test", index.getPath("3", head));
        head = mk.commit("/", "- \"test\"", head, null);
        Assert.assertEquals(null, index.getPath("100", head));
        Assert.assertEquals(null, index.getPath("3", head));
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.api.MicroKernel

        test("simple:");
        test("simple:fs:target/temp;clean");
    }

    private static void test(String url) throws ParseException {
        MicroKernel mk = MicroKernelFactory.getInstance(url);
        System.out.println(url);
        String head = mk.getHeadRevision();
        head = mk.commit("/", "+ \"hello\" : {}", head, null);
        String move = "> \"hello\": \"world\" ";
        String set = "^ \"world/x\": 1 ";
        try {
            head = mk.commit("/", move + set, head, null);
            System.out.println("move & set worked");
        } catch (Exception e) {
            System.out.println("move & set didn't work:");
            e.printStackTrace(System.out);
            head = mk.commit("/", move, head, null);
            head = mk.commit("/", set, head, null);
        }
        System.out.println();
        mk.dispose();
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.api.MicroKernel

*/
public class PrefixIndexTest {

    @Test
    public void test() {
        MicroKernel mk = new MicroKernelImpl();
        Indexer indexer = new Indexer(mk, "index");
        indexer.init();
        PrefixIndex index = indexer.createPrefixIndex("d:");

        String head = mk.getHeadRevision();

        // meta data
        String meta = mk.getNodes("/index", head);
        Assert.assertEquals("{\":childNodeCount\":1,\"prefix:d:\":{\":childNodeCount\":0}}", meta);

        Assert.assertEquals("", getPathList(index, "d:1", head));

        head = mk.commit("/", "+\"test\" : {\"blob\":\"d:1\"}", head, null);
        head = mk.commit("/", "+\"test2\" : {\"blob2\":\"d:2\"}", head, null);

        Assert.assertEquals("/test/blob", getPathList(index, "d:1", head));
        Assert.assertEquals("/test2/blob2", getPathList(index, "d:2", head));

        head = mk.commit("/", "^\"test2/blob2\" : null", head, null);
        Assert.assertEquals("", getPathList(index, "d:2", head));

        head = mk.commit("/", "^\"test2/blob2\" : \"d:2\" ", head, null);
        Assert.assertEquals("/test2/blob2", getPathList(index, "d:2", head));

        head = mk.commit("/", "+\"test3\" : {\"blob3\":\"d:1\"}", head, null);
        head = mk.commit("/", "+\"test4\" : {\"blob4\":\"d:2\"}", head, null);

        Assert.assertEquals("/test/blob, /test3/blob3", getPathList(index, "d:1", head));
        Assert.assertEquals("/test2/blob2, /test4/blob4", getPathList(index, "d:2", head));

        head = mk.commit("/", "+\"test5\" : {\"blobs\":[\"a:0\",\"d:2\"]}", head, null);
        head = mk.commit("/", "+\"test6\" : {\"data\":[true, false, null, 1, -1]}", head, null);
        Assert.assertEquals("/test2/blob2, /test4/blob4, /test5/blobs", getPathList(index, "d:2", head));

        head = mk.commit("/", "+\"test7\" : {\"a\":\"d:4\", \"b\":\"d:4\"}", head, null);
        Assert.assertEquals("/test7/a, /test7/b", getPathList(index, "d:4", head));
        head = mk.commit("/", "^\"test7/a\" : null", head, null);
        Assert.assertEquals("/test7/b", getPathList(index, "d:4", head));
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.api.MicroKernel

    protected NodeState state;

    @Before
    public void setUp() {
        MicroKernel microKernel = new MicroKernelImpl();
        store = new KernelNodeStore(microKernel);
        valueFactory = store.getValueFactory();

        state = createInitialState(microKernel);
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.api.MicroKernel

    @Before
    public void setup() {
        counter = 0;

        MicroKernel mk1 = new MicroKernelImpl("./target/mk1/" + random.nextInt());
        store1 = new KernelNodeStore(mk1);
        vf = store1.getValueFactory();
        mk1.commit("", "+\"/test\":{} +\"/test/root\":{}", mk1.getHeadRevision(), "");
        root1 = new RootImpl(store1, "test");

        MicroKernel mk2 = new MicroKernelImpl("./target/mk2/" + random.nextInt());
        store2 = new KernelNodeStore(mk2);
        mk2.commit("", "+\"/test\":{} +\"/test/root\":{}", mk2.getHeadRevision(), "");
        root2 = new RootImpl(store2, "test");
    }
View Full Code Here

Examples of org.apache.jackrabbit.mk.api.MicroKernel

            if (index < 0) {
                throw ExceptionFactory.get("Expected url format: sec:user@pass:<url>");
            }
            String user = userPass.substring(0, index);
            String pass = userPass.substring(index + 1);
            final MicroKernel mk = getInstance(u);
            try {
                return new SecurityWrapper(mk, user, pass) {
                    @Override
                    public void dispose() {
                        super.dispose();
                        mk.dispose();
                    }
                };
            } catch (MicroKernelException e) {
                mk.dispose();
                throw e;
            }
        } else if (head.equals("virtual")) {
            MicroKernel mk = getInstance(tail);
            try {
                return new VirtualRepositoryWrapper(mk);
            } catch (MicroKernelException e) {
                mk.dispose();
                throw e;
            }
        } else if (head.equals("index")) {
            return new IndexWrapper(getInstance(tail));
        } else if (head.equals("http")) {
            return new Client(url);
        } else if (head.equals("http-bridge")) {
            MicroKernel mk = getInstance(tail);

            final Server server = new Server(mk);
            try {
                server.start();
            } catch (IOException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.