jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edgar Merino <donvo...@gmail.com>
Subject Re: Jackrabbit jetty Resource (SOLVED)
Date Fri, 05 Dec 2008 23:38:32 GMT
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
>


Mime
View raw message