You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Edgar Merino <do...@gmail.com> on 2008/12/05 22:23:05 UTC
Jackrabbit jetty Resource
Hello,
I've been trying to find out information on how to configure jetty
to register a repository throug JNDI to be used by a web application,
however I've found only one source saying it should be done
programatically
(http://www.nabble.com/migration-from-tomcat-to-jetty-td9631457.html#a9631457),
isn't there a way to accomplish this using the jetty-env.xml file?
Thanks in advance,
Edgar Merino
Re: Jackrabbit jetty Resource (SOLVED)
Posted by Edgar Merino <do...@gmail.com>.
Well, this was an easy task, it was just a matter of creating a simple
implementation of a JackrabbitRepository and using that with jetty,
everything is working fine now, here's the code in case it's useful to
anyone else (most of it was taken from BindableRepository):
public class JettyRepository implements JackrabbitRepository {
private transient Thread hook;
private TransientRepository repo;
private String configPath;
private String homePath;
public void setConfigFilePath(String configPath) {
this.configPath = configPath;
if (homePath != null) {
init();
}
}
public void setRepHomeDir(String homePath) {
this.homePath = homePath;
if (configPath != null) {
init();
}
}
public void init() {
try {
this.repo = new TransientRepository();
} catch (Exception e) {
e.printStackTrace();
}
hook = new Thread() {
public void run() {
shutdown();
}
};
Runtime.getRuntime().addShutdownHook(hook);
}
public String getDescriptor(String key) {
return repo.getDescriptor(key);
}
public String[] getDescriptorKeys() {
return repo.getDescriptorKeys();
}
public Session login(Credentials credentials, String workspaceName)
throws LoginException, NoSuchWorkspaceException, RepositoryException {
return repo.login(credentials, workspaceName);
}
public Session login(Credentials credentials) throws LoginException,
RepositoryException {
return repo.login(credentials);
}
public Session login(String workspaceName) throws LoginException,
NoSuchWorkspaceException, RepositoryException {
return repo.login(workspaceName);
}
public Session login() throws LoginException, RepositoryException {
return repo.login();
}
public void shutdown() {
repo.shutdown();
try {
Runtime.getRuntime().removeShutdownHook(hook);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Edgar Merino
Edgar Merino escribió:
> Hello,
> I've been trying to find out information on how to configure
> jetty to register a repository throug JNDI to be used by a web
> application, however I've found only one source saying it should be
> done programatically
> (http://www.nabble.com/migration-from-tomcat-to-jetty-td9631457.html#a9631457),
> isn't there a way to accomplish this using the jetty-env.xml file?
>
> Thanks in advance,
> Edgar Merino
>