当前位置: 首页>>代码示例>>Java>>正文


Java Session.isLive方法代码示例

本文整理汇总了Java中javax.jcr.Session.isLive方法的典型用法代码示例。如果您正苦于以下问题:Java Session.isLive方法的具体用法?Java Session.isLive怎么用?Java Session.isLive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jcr.Session的用法示例。


在下文中一共展示了Session.isLive方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testJcrProducer

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testJcrProducer() throws Exception {
    Exchange exchange = createExchangeWithBody("<hello>world!</hello>");
    exchange.getIn().setHeader(JcrConstants.JCR_NODE_NAME, "node");
    exchange.getIn().setHeader("my.contents.property", exchange.getIn().getBody());
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    Session session = openSession();
    try {
        Node node = session.getNodeByIdentifier(uuid);
        assertNotNull(node);
        assertEquals("/home/test/node", node.getPath());
        assertEquals("<hello>world!</hello>", node.getProperty("my.contents.property").getString());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:JcrProducerTest.java

示例2: testNodeTypeIsSpecified

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testNodeTypeIsSpecified() throws Exception {
    Exchange exchange = createExchangeWithBody("Test");
    exchange.getIn().removeHeader("testClass"); //there is no definition of such property in nt:resource
    exchange.getIn().setHeader(JcrConstants.JCR_NODE_NAME, "typedNode");
    exchange.getIn().setHeader(JcrConstants.JCR_NODE_TYPE, "nt:folder");
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    Session session = openSession();
    try {
        Node node = session.getNodeByIdentifier(uuid);
        assertNotNull(node);
        assertEquals("/home/test/typedNode", node.getPath());
        assertEquals("nt:folder", node.getPrimaryNodeType().getName());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:JcrProducerTest.java

示例3: testCreateNodeWithAuthentication

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testCreateNodeWithAuthentication() throws Exception {
    Exchange exchange = createExchangeWithBody("<message>hello!</message>");
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    assertNotNull("Out body was null; expected JCR node UUID", uuid);
    Session session = getRepository().login(
            new SimpleCredentials("admin", "admin".toCharArray()));
    try {
        Node node = session.getNodeByIdentifier(uuid);
        assertNotNull(node);
        assertEquals(BASE_REPO_PATH + "/node", node.getPath());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:JcrAuthLoginTest.java

示例4: testJcrNodePathCreation

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testJcrNodePathCreation() throws Exception {
    Exchange exchange = createExchangeWithBody("<body/>");
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    assertNotNull("Out body was null; expected JCR node UUID", uuid);
    Session session = openSession();
    try {
        Node node = session.getNodeByIdentifier(uuid);
        assertNotNull(node);
        assertEquals("/home/test/node/with/path", node.getPath());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:JcrNodePathCreationTest.java

示例5: testJcrNodePathCreationMultiValued

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testJcrNodePathCreationMultiValued() throws Exception {
    Exchange exchange = createExchangeWithBody(multiValued);
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    assertNotNull("Out body was null; expected JCR node UUID", uuid);
    Session session = openSession();
    try {
        Node node = session.getNodeByIdentifier(uuid);
        assertNotNull(node);
        assertEquals("/home/test/node/with/path", node.getPath());
        assertTrue(node.getProperty("my.contents.property").isMultiple());
        assertArrayEquals(multiValued, node.getProperty("my.contents.property").getValues());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:JcrNodePathCreationTest.java

示例6: testJcrProducer

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testJcrProducer() throws Exception {
    Exchange exchange = createExchangeWithBody("<hello>world!</hello>");
    Exchange out = template.send("direct:a", exchange);
    assertNotNull(out);
    String uuid = out.getOut().getBody(String.class);
    Session session = openSession(CUSTOM_WORKSPACE_NAME);
    try {
        Node node = session.getNodeByIdentifier(uuid);
        Workspace workspace = session.getWorkspace();
        assertEquals(CUSTOM_WORKSPACE_NAME, workspace.getName());
        assertNotNull(node);
        assertEquals("/home/test/node", node.getPath());
        assertEquals("<hello>world!</hello>", node.getProperty("my.contents.property").getString());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:JcrProducerDifferentWorkspaceTest.java

示例7: six

import javax.jcr.Session; //导入方法依赖的package包/类
public void six() {
	Session session = null; // Noncompliant
	String plotTwist = "twist";
	plotTwist = "anotherTwist";
	plotTwist = getMeAnotherTwist();
	plotTwist = StringUtils.capitalize(plotTwist);
	try {
		session = repository.loginService(null, null);
	} catch (RepositoryException e) {
		e.printStackTrace();
	} finally {
		if (session != null && session.isLive()) {
			//	session.logout();
			plotTwist.toString();
		}
	}
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:18,代码来源:SessionLogoutSix.java

示例8: testCreateNodeAndSubNode

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testCreateNodeAndSubNode() throws Exception {
    Session session = openSession();

    try {
        // create node
        Exchange exchange1 = ExchangeBuilder.anExchange(context)
            .withHeader(JcrConstants.JCR_NODE_NAME, "node")
            .build();
        Exchange out1 = template.send("direct:a", exchange1);
        assertNotNull(out1);
        String uuidNode = out1.getOut().getBody(String.class);

        Node node = session.getNodeByIdentifier(uuidNode);
        assertNotNull(node);
        assertEquals("/home/test/node", node.getPath());
        
        // create sub node
        Exchange exchange2 = ExchangeBuilder.anExchange(context)
            .withHeader(JcrConstants.JCR_NODE_NAME, "node/subnode")
            .build();
        Exchange out2 = template.send("direct:a", exchange2);
        assertNotNull(out2);
        String uuidSubNode = out2.getOut().getBody(String.class);
        
        Node subNode = session.getNodeByIdentifier(uuidSubNode);
        assertNotNull(subNode);
        assertEquals("/home/test/node/subnode", subNode.getPath());
        assertNotNull(subNode.getParent());
        assertEquals("/home/test/node", subNode.getParent().getPath());
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:37,代码来源:JcrProducerSubNodeTest.java

示例9: two

import javax.jcr.Session; //导入方法依赖的package包/类
public void two() {
	Session session = null;
	try {
		session = repository.loginAdministrative(null);
	} catch (RepositoryException e) {
		e.printStackTrace();
	} finally {
		if (session != null && session.isLive()) {
			session.logout();
		}
	}
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:13,代码来源:SessionLogoutTwo.java

示例10: five

import javax.jcr.Session; //导入方法依赖的package包/类
public void five() {
	Session session = null; // Noncompliant
	try {
		session = repository.loginAdministrative(null);
	} catch (RepositoryException e) {
		e.printStackTrace();
	} finally {
		if (session != null && session.isLive()) {
			//	session.logout();
		}
	}
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:13,代码来源:SessionLogoutFive.java

示例11: three

import javax.jcr.Session; //导入方法依赖的package包/类
public void three() {
	Session session = null;
	try {
		session = repository.loginService(null, null);
	} catch (RepositoryException e) {
		e.printStackTrace();
	} finally {
		if (session != null && session.isLive()) {
			session.logout();
		}
	}
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:13,代码来源:SessionLogoutThree.java

示例12: one

import javax.jcr.Session; //导入方法依赖的package包/类
public void one() {
	Session session = null;
	try {
		session = createAdminSession();
	} finally {
		if (session != null && session.isLive()) {
			session.logout();
		}
	}
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:11,代码来源:SessionLogoutOne.java

示例13: createGroups

import javax.jcr.Session; //导入方法依赖的package包/类
/**
 * Create user groups for authors and testers.
 *
 * @param bundleContext The bundle context provided by the component.
 */
private void createGroups(BundleContext bundleContext){
    ServiceReference SlingRepositoryFactoryReference = bundleContext.getServiceReference(SlingRepository.class.getName());
    SlingRepository repository = (SlingRepository)bundleContext.getService(SlingRepositoryFactoryReference);

    Session session = null;

    if (repository != null) {
        try {
            session = repository.loginAdministrative(null);

            if (session != null && session instanceof JackrabbitSession) {
                UserManager userManager = ((JackrabbitSession)session).getUserManager();
                ValueFactory valueFactory = session.getValueFactory();

                Authorizable authors = userManager.getAuthorizable(PublickConstants.GROUP_ID_AUTHORS);

                if (authors == null) {
                    authors = userManager.createGroup(PublickConstants.GROUP_ID_AUTHORS);
                    authors.setProperty(GROUP_DISPLAY_NAME, valueFactory.createValue(PublickConstants.GROUP_DISPLAY_AUTHORS));
                }

                Authorizable testers = userManager.getAuthorizable(PublickConstants.GROUP_ID_TESTERS);

                if (testers == null) {
                    testers = userManager.createGroup(PublickConstants.GROUP_ID_TESTERS);
                    testers.setProperty(GROUP_DISPLAY_NAME, valueFactory.createValue(PublickConstants.GROUP_DISPLAY_TESTERS));
                }
            }
        } catch (RepositoryException e) {
            LOGGER.error("Could not get session", e);
        } finally {
            if (session != null && session.isLive()) {
                session.logout();
                session = null;
            }
        }
    }
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:44,代码来源:Activator.java

示例14: testJcrConsumer

import javax.jcr.Session; //导入方法依赖的package包/类
@Test
public void testJcrConsumer() throws Exception {
    // start consumer thread first
    JcrConsumerThread consumerThread = new JcrConsumerThread();
    consumerThread.start();
    // wait until the consumer thread has tried to receive event at least once
    while (consumerThread.getReceiveTrialTimes() < 1) {
        Thread.sleep(10L);
    }

    // now create a node under the specified event node path

    Session session = openSession();

    try {
        Node folderNode = session.getRootNode();

        for (String folderNodeName : absPath.split("\\/")) {
            if (!"".equals(folderNodeName)) {
                if (folderNode.hasNode(folderNodeName)) {
                    folderNode.getNode(folderNodeName).remove();
                }

                folderNode = folderNode.addNode(folderNodeName, "nt:unstructured");
            }
        }

        folderNode.addNode("node", "nt:unstructured");
        session.save();
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }

    // wait until the consumer thread captures an event
    consumerThread.join();

    Exchange exchange = consumerThread.getExchange();
    assertNotNull(exchange);

    Message message = exchange.getIn();
    assertNotNull(message);
    assertTrue(message instanceof JcrMessage);
    EventIterator eventIterator = ((JcrMessage)message).getEventIterator();
    assertNotNull(eventIterator);
    assertEquals(1, eventIterator.getSize());

    List<?> eventList = message.getBody(List.class);
    assertEquals(1, eventList.size());
    Event event = (Event) eventList.get(0);
    assertEquals(Event.NODE_ADDED, event.getType());
    assertNotNull(event.getPath());
    assertTrue(event.getPath().startsWith(absPath));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:56,代码来源:JcrConsumerTest.java


注:本文中的javax.jcr.Session.isLive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。