jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Moritz Rebbert <moritz.rebb...@udo.edu>
Subject Jackrabbit on JBoss: Login outside of Transaction
Date Mon, 27 Oct 2008 16:25:15 GMT
Hi List,

i'm playing around with jackrabbit on jboss. My question is: Is it
possible or intended to start more than one transaction using the same
Session. My Code test code looks like this:[0]

In the first case is do the login within the Transaction. The action
will be rolled back an no node will be created. It is very close to the
example in the JackrabbitOnJBoss article of the jackrabbit wiki. 

But if i want to start the Session befor the utx.begin() like in the
second case. The rollback has no effect and the the node will be
created. But if i want to use more then one Transaction in a single
Session, i have to do the login before the utx.begin();

How can i do something like this.Or is it intend to login and create a
new session, every time i start a transaction? 

The config-property bindSessionToTransaction sounds for me like: If i
set it true, the first case would be supported: new login for every new
transaction. But what about setting it to false?

Regards
Moritz Rebbert

BTW:
My config looks like this:[1]
Im Using jboss-4.2.2.GA. and jackrabbit-jca-1.4.rar.

[0]
@Stateful
@TransactionManagement(TransactionManagementType.BEAN)
public class TestBean implements Test{
	@Resource
	UserTransaction utx;
	public void test(String str){
		Session session = null;
		try{
			//loginAfterBegin
			utx.begin();
			session = repository.login(new SimpleCredentials("asdf","safd".toCharArray()));
			session.getRootNode().addNode("loginAfterBegin()"+str);
			session.save();
			utx.rollback();
		
			//loginBefore begin
			session = repository.login(new SimpleCredentials("asdf","safd".toCharArray()));
			
			utx.begin();
			session.getRootNode().addNode("loginBeforeBegin1"+str);
			session.save();
			utx.rollback();
			
			utx.begin();
			session.getRootNode().addNode("loginBeforeBegin2"+str);
			session.save();
			utx.rollback();

		}catch (Exception e) {
			e.printStackTrace();
		}
		
	}

[1]
jcr-ds.xml:
<connection-factories>
    <tx-connection-factory>
                <jndi-name>jcr/local</jndi-name>
                <xa-transaction/>
                <rar-name>jackrabbit-jca-1.4.rar</rar-name>
                <connection-definition>javax.jcr.Repository</connection-definition>
                <config-property name="homeDir" type="java.lang.String">/ldaphome/rebbert/var/jackrabbit</config-property>
                <config-property name="configFile" type="java.lang.String">classpath:repository.xml</config-property>
                <config-property name="bindSessionToTransaction" type="java.lang.Boolean">false</config-property>
    </tx-connection-factory>
</connection-factories>

repository.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.2//EN"
                           "http://jackrabbit.apache.org/dtd/repository-1.4.dtd">
<Repository>
   <FileSystem 
            class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
       <param name="path" value="${rep.home}/repository"/>
   </FileSystem>

   <Security appName="Jackrabbit">
       <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager"/>
       <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
          <param name="anonymousId" value="anonymous"/>
       </LoginModule>
   </Security>

   <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default" />

   <Workspace name="${wsp.name}">
       <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
           <param name="path" value="${wsp.home}"/>
       </FileSystem>

       <PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager">
                    <param name="driver" value="org.postgresql.Driver"/>
                    <param name="url" value="jdbc:postgresql://localhost:5433/jackrabbit"/>
                    <param name="user" value="postgres"/>
                    <param name="password" value="postgres"/>
                    <param name="schema" value="postgresql"/>
                    <param name="schemaObjectPrefix" value="jcr_${wsp.name}_"/>
                    <param name="externalBLOBs" value="false"/>
       </PersistenceManager>



       <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
           <param name="path" value="${wsp.home}/index" />
       </SearchIndex>
   </Workspace>

   <Versioning rootPath="${rep.home}/versions">
       <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
           <param name="path" value="${rep.home}/versions"/>
       </FileSystem>
       <PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.PostgreSQLPersistenceManager">
                    <param name="driver" value="org.postgresql.Driver"/>
                    <param name="url" value="jdbc:postgresql://localhost:5433/jackrabbit"/>
                    <param name="user" value="postgres"/>
                    <param name="password" value="postgres"/>
                    <param name="schema" value="postgresql"/>
                    <param name="schemaObjectPrefix" value="jcr_versioning_"/>
                    <param name="externalBLOBs" value="false"/>
       </PersistenceManager>
   </Versioning>

   <DataStore class="org.apache.jackrabbit.core.data.FileDataStore">
       <param name="path" value="${rep.home}/repository/datastore"/>
       <param name="minRecordLength" value="100"/>
   </DataStore>
</Repository>


Mime
View raw message