jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Klimetschek" <aklim...@day.com>
Subject Re: getting a user transaction
Date Mon, 11 Aug 2008 16:31:43 GMT
Here is some sample code for using transactions (for the client side):

http://markmail.org/message/slakkcbezbsiqrw6

Regards,
Alex

On Sun, Jul 27, 2008 at 12:54 PM, Sebastian Prehn
<sebastian.prehn@planetswebdesign.de> wrote:
> Hi!
> I need help setting up a jackrabbit. I use the RMI-server and all my tests
> (without TAs) work just fine.
>
> However, I need to get a UserTransaction in the client now?
>
>
>
> I setup the server as follows:
> public void setUpRI() throws RepositoryException, Exception {
>    String configFile = "/home/basti/TestAppRep/repository.xml";
>    String repHomeDir = "/home/basti/TestAppRep";
>
>    Hashtable env = new Hashtable();
>    env.put(Context.INITIAL_CONTEXT_FACTORY,
>            "org.apache.jackrabbit.core.jndi" +
>            ".provider.DummyInitialContextFactory");
>
>    env.put(Context.PROVIDER_URL, "localhost");
>
>    InitialContext ctx = new InitialContext(env);
>
>    RegistryHelper.registerRepository(ctx,
>            "repo",
>            configFile,
>            repHomeDir,
>            true);
>
>    Repository repository = (Repository) ctx.lookup("repo");
>
>    String name = "ri_rmi"; // The RMI URL for the repository
>    int port = 12345;
>    RemoteAdapterFactory factory = new ServerAdapterFactory();
>    RemoteRepository remote = factory.getRemoteRepository(repository);
>
>    Registry registry = java.rmi.registry.LocateRegistry.createRegistry(port);
>
>    try {
>    registry.unbind(name);
>    } catch (NotBoundException ex ){
>      // ignore
>    }
>    registry.rebind(name, remote);  // Make the RMI binding using
> java.rmi.Naming
>
>  }
>
>
>
> and here is the client code.
>
> ClientRepositoryFactory factory = new ClientRepositoryFactory();
>    Repository repository = factory.getRepository("//localhost:12345/ri_rmi");
>    session = repository.login(new
> SimpleCredentials("username", "password".toCharArray()), "default");
>
> regards,
> Sebastian
>
>
> --
> PLANETS-Webdesign - Web Applications
> Sebastian Prehn
> Balbierstr.8 67663 Kaiserslautern
> www.planetswebdesign.de
> PGP keyID: 0x3507AF63
>



-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message