use of org.apache.jackrabbit.rmi.client.ClientAdapterFactory in project jackrabbit by apache.
the class RepositoryStubImpl method getRepository.
@Override
public synchronized Repository getRepository() throws RepositoryStubException {
if (repository == null) {
try {
Repository repo = super.getRepository();
principal = findKnownPrincipal(repo);
RemoteAdapterFactory raf = new ServerAdapterFactory();
remote = raf.getRemoteRepository(repo);
// Make sure that the remote reference survives serialization
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(buffer);
oos.writeObject(RemoteObject.toStub(remote));
oos.close();
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
LocalAdapterFactory laf = new ClientAdapterFactory();
repository = laf.getRepository((RemoteRepository) ois.readObject());
} catch (Exception e) {
throw new RepositoryStubException(e);
}
}
return repository;
}
use of org.apache.jackrabbit.rmi.client.ClientAdapterFactory in project jackrabbit by apache.
the class ConnectToJNDIServer method execute.
/**
* {@inheritDoc}
*/
public boolean execute(Context ctx) throws Exception {
String url = (String) ctx.get(this.urlKey);
if (log.isDebugEnabled()) {
log.debug("connecting to jndi server at " + url);
}
InitialContext iCtx = new InitialContext();
ClientAdapterFactory adapter = new ClientAdapterFactory();
RemoteRepository remote = (RemoteRepository) iCtx.lookup(url);
Repository repo = adapter.getRepository(remote);
CommandHelper.setRepository(ctx, repo, "jndi " + url);
return false;
}
Aggregations