jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Jackrabbit Wiki] Update of "JackrabbitOnJBoss" by edgarpoce
Date Fri, 28 Jul 2006 15:47:10 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jackrabbit Wiki" for change notification.

The following page has been changed by edgarpoce:
http://wiki.apache.org/jackrabbit/JackrabbitOnJBoss

The comment on the change is:
how to access the repository from session beans

------------------------------------------------------------------------------
  ## page was renamed from JackrabbitInJBoss
  This document describes how to 
-  * Deploy Jackrabbit with JCA.
+  * Deploy Jackrabbit on JBoss with JCA.
   * Expose the local repository through JNDI and WEBDAV to remote clients.
+  * Access the repository from session beans
-  * Connect remotely from a java program, or from a command line tool (contrib/jcr-commands).
+  * Access the repository remotely from a java program, or from a command line tool (contrib/jcr-commands).
  
  Feel free to make changes to this document.
  
@@ -49, +50 @@

  
  Now the webdav server is running at http://localhost:8080/jackrabbit-server
  
+ === Access the repository from a session bean ===
+ 
+ EJB3 example
+ 
+ ==== Container managed transactions ====
+ 
+ {{{
+ @Stateless
+ public class TestCMT implements TestCMTBean {
+ 	
+ 	public void test() throws Exception {
+ 		InitialContext ctx = new InitialContext() ;
+ 		Repository repo = (Repository) ctx.lookup("java:jcr/local") ;
+ 		Credentials cred = new SimpleCredentials("user",new char[]{'´p','w','d'}) ;
+ 		Session s = repo.login(cred) ;
+ 		s.getRootNode().addNode("foo") ;
+ 		s.save();
+ 	}
+ 
+ }
+ }}}
+ 
+ ==== Bean managed transactions ====
+ 
+ {{{
+ @Stateless
+ @TransactionManagement(TransactionManagementType.BEAN)
+ public class TestBMT implements TestBMTBean {
+ 	
+ 	
+ 	@Resource
+ 	UserTransaction utx ;
+ 
+ 	public void test() throws Exception {
+ 		utx.begin() ;
+ 		InitialContext ctx = new InitialContext();
+ 		Repository repo = (Repository) ctx.lookup("java:jcr/local");
+ 		Credentials cred = new SimpleCredentials("user",new char[]{'´p','w','d'}) ;
+ 		Session s = repo.login(cred);
+ 		s.getRootNode().addNode("foo");
+ 		s.save();
+ 		utx.commit() ;
+ 	}
+ 
+ }
+ }}}
+ 
- === Accessing the repository remotely from the command line interface ===
+ === Access the repository remotely from the command line interface ===
   * checkout jcr-commands from subversion
   * build with "maven jar:jar"
   * unzip the generated zip file at ./target into a folder of your choice

Mime
View raw message