jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Prehn <sebastian.pr...@planetswebdesign.de>
Subject getting a user transaction
Date Sun, 27 Jul 2008 10:54:23 GMT
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

Mime
View raw message