本文整理汇总了Java中javax.jcr.Session.getWorkspace方法的典型用法代码示例。如果您正苦于以下问题:Java Session.getWorkspace方法的具体用法?Java Session.getWorkspace怎么用?Java Session.getWorkspace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jcr.Session
的用法示例。
在下文中一共展示了Session.getWorkspace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
}
示例2: initialize
import javax.jcr.Session; //导入方法依赖的package包/类
static void initialize( Session session )
throws RepositoryException
{
// TODO: consider using namespaces for facets instead of the current approach:
// (if used, check if actually called by normal injection)
// for ( String facetId : metadataFacetFactories.keySet() )
// {
// session.getWorkspace().getNamespaceRegistry().registerNamespace( facetId, facetId );
// }
Workspace workspace = session.getWorkspace();
NamespaceRegistry registry = workspace.getNamespaceRegistry();
if ( !Arrays.asList( registry.getPrefixes() ).contains( "archiva" ) )
{
registry.registerNamespace( "archiva", "http://archiva.apache.org/jcr/" );
}
NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.NAMESPACE_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.PROJECT_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.PROJECT_VERSION_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.ARTIFACT_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.FACET_NODE_TYPE );
registerMixinNodeType( nodeTypeManager, JcrMetadataRepository.DEPENDENCY_NODE_TYPE );
}
示例3: setUp
import javax.jcr.Session; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
deleteDirectory(REPO_PATH);
super.setUp();
Session session = getRepository().login(new SimpleCredentials("user", "pass".toCharArray()));
Workspace workspace = session.getWorkspace();
workspace.createWorkspace(CUSTOM_WORKSPACE_NAME);
session.save();
session.logout();
}