You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Anibal Sanchez <an...@oquma.com> on 2009/12/16 11:39:01 UTC
JnpClientRepositoryFactory
Hi,
I have a question, how do you connect to RMI repository at a JNP address
with Jboss AS ? Which is the standard way ?
To solve the problem I've created a new class JnpClientRepositoryFactory.
Changing the getRepository method to:
/**
* Returns a client wrapper for a remote content repository. The remote
* repository is looked up from the RMI registry using the given URL by
* the returned {@link SafeClientRepository} instance.
* <p>
* The current implementation of this method will not throw any of the
* declared exceptions (because of the {@link SafeClientRepository}
being
* used), but the throws clauses are kept for backwards compatibility
and
* potential future use. Clients should be prepared to handle exceptions
* from this method.
*
* @param url the RMI URL of the remote repository
* @return repository client
* @throws MalformedURLException if the given URL is malfored
* @throws NotBoundException if the given URL points to nothing
* @throws ClassCastException if the given URL points to something
unknown
* @throws RemoteException if the remote repository can not be accessed
*/
public Repository getRepository(final String initial_context_factory,
final String provider_url, final String url_pkg_prefixes, final String url)
throws MalformedURLException, NotBoundException,
ClassCastException, RemoteException {
return new SafeClientRepository(factory) {
protected RemoteRepository getRemoteRepository()
throws RemoteException {
try {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
initial_context_factory);
env.put(Context.PROVIDER_URL, provider_url);
env.put(Context.URL_PKG_PREFIXES, url_pkg_prefixes);
InitialContext ctx = new InitialContext(env);
return (RemoteRepository) ctx.lookup(url);
} catch (NamingException e) {
throw new RemoteException("JnpClientRepositoryFactory -
Not found URL: " + url, e);
} catch (ClassCastException e) {
throw new RemoteException("JnpClientRepositoryFactory -
Unknown target: " + url, e);
}
}
};
}
Thanks,
Anibal