1 package org
.argeo
.server
.jackrabbit
;
4 import java
.io
.InputStream
;
6 import javax
.jcr
.Credentials
;
7 import javax
.jcr
.LoginException
;
8 import javax
.jcr
.NoSuchWorkspaceException
;
9 import javax
.jcr
.Repository
;
10 import javax
.jcr
.RepositoryException
;
11 import javax
.jcr
.Session
;
13 import org
.apache
.commons
.io
.IOUtils
;
14 import org
.apache
.jackrabbit
.core
.RepositoryImpl
;
15 import org
.apache
.jackrabbit
.core
.config
.RepositoryConfig
;
16 import org
.springframework
.beans
.factory
.DisposableBean
;
17 import org
.springframework
.beans
.factory
.InitializingBean
;
18 import org
.springframework
.core
.io
.Resource
;
20 public class JackrabbitContainer
implements InitializingBean
, DisposableBean
,
22 private Resource configuration
;
23 private File homeDirectory
;
25 private RepositoryImpl repository
;
27 public void afterPropertiesSet() throws Exception
{
28 RepositoryConfig config
;
29 InputStream in
= configuration
.getInputStream();
31 config
= RepositoryConfig
.create(in
, homeDirectory
33 } catch (Exception e
) {
34 throw new RuntimeException("Cannot read configuration", e
);
36 IOUtils
.closeQuietly(in
);
39 repository
= RepositoryImpl
.create(config
);
42 public void destroy() throws Exception
{
43 if (repository
!= null)
44 repository
.shutdown();
47 // JCR REPOSITORY (delegated)
48 public String
getDescriptor(String key
) {
49 return repository
.getDescriptor(key
);
52 public String
[] getDescriptorKeys() {
53 return repository
.getDescriptorKeys();
56 public Session
login() throws LoginException
, RepositoryException
{
57 return repository
.login();
60 public Session
login(Credentials credentials
, String workspaceName
)
61 throws LoginException
, NoSuchWorkspaceException
,
63 return repository
.login(credentials
, workspaceName
);
66 public Session
login(Credentials credentials
) throws LoginException
,
68 return repository
.login(credentials
);
71 public Session
login(String workspaceName
) throws LoginException
,
72 NoSuchWorkspaceException
, RepositoryException
{
73 return repository
.login(workspaceName
);
77 public void setHomeDirectory(File homeDirectory
) {
78 this.homeDirectory
= homeDirectory
;
81 public void setConfiguration(Resource configuration
) {
82 this.configuration
= configuration
;