X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=server%2Fruntime%2Forg.argeo.server.jackrabbit%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fjackrabbit%2FJackrabbitContainer.java;h=3b83941cfade149844b768a15dc56e1c6d4e4269;hb=ada93169e85b906c38407f02514edde1dc193503;hp=d9cf424e63e7155f433b034e2c10d2d5352ad25c;hpb=231507d4e7c8aa9676fd65bcd13d4558f78ff86f;p=lgpl%2Fargeo-commons.git diff --git a/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitContainer.java b/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitContainer.java index d9cf424e6..3b83941cf 100644 --- a/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitContainer.java +++ b/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/jackrabbit/JackrabbitContainer.java @@ -115,6 +115,7 @@ public class JackrabbitContainer implements Repository, ResourceLoaderAware { /** Actually creates a new repository. */ protected void createJackrabbitRepository() { + long begin = System.currentTimeMillis(); try { // remote repository if (uri != null && !uri.trim().equals("")) { @@ -122,7 +123,7 @@ public class JackrabbitContainer implements Repository, ResourceLoaderAware { params.put( org.apache.jackrabbit.commons.JcrUtils.REPOSITORY_URI, uri); - repository = (JackrabbitRepository) new Jcr2davRepositoryFactory() + repository = new Jcr2davRepositoryFactory() .getRepository(params); if (repository == null) throw new ArgeoException("Remote Davex repository " + uri @@ -161,8 +162,10 @@ public class JackrabbitContainer implements Repository, ResourceLoaderAware { else repository = RepositoryImpl.create(repositoryConfig); - log.info("Initialized Jackrabbit repository " + repository + " in " - + getHomeDirectory() + " with config " + configuration); + double duration = ((double) (System.currentTimeMillis() - begin)) / 1000; + log.info("Initialized Jackrabbit repository in " + duration + + " s, home: " + getHomeDirectory() + ", config: " + + configuration); } catch (Exception e) { throw new ArgeoException("Cannot create Jackrabbit repository " + getHomeDirectory(), e); @@ -232,31 +235,16 @@ public class JackrabbitContainer implements Repository, ResourceLoaderAware { /** Lazy init. */ protected File getHomeDirectory() { - return homeDirectory; - // if (home != null) - // return home; - // - // try { - // String osgiData = System.getProperty("osgi.instance.area"); - // if (osgiData != null) - // osgiData = osgiData.substring("file:".length()); - // String path; - // if (homeDirectory == null) - // path = "./jackrabbit"; - // else - // path = homeDirectory; - // if (path.startsWith(".") && osgiData != null) { - // home = new File(osgiData + '/' + path).getCanonicalFile(); - // } else - // home = new File(path).getCanonicalFile(); - // return home; - // } catch (Exception e) { - // throw new ArgeoException("Cannot define Jackrabbit home based on " - // + homeDirectory, e); - // } + try { + return homeDirectory.getCanonicalFile(); + } catch (IOException e) { + throw new ArgeoException("Cannot get canonical file for " + + homeDirectory, e); + } } public void dispose() throws Exception { + long begin = System.currentTimeMillis(); if (repository != null) { if (repository instanceof JackrabbitRepository) ((JackrabbitRepository) repository).shutdown(); @@ -274,11 +262,13 @@ public class JackrabbitContainer implements Repository, ResourceLoaderAware { + getHomeDirectory()); } + double duration = ((double) (System.currentTimeMillis() - begin)) / 1000; if (uri != null && !uri.trim().equals("")) log.info("Destroyed Jackrabbit repository with uri " + uri); else - log.info("Destroyed Jackrabbit repository " + repository + " in " - + getHomeDirectory() + " with config " + configuration); + log.info("Destroyed Jackrabbit repository in " + duration + + " s, home: " + getHomeDirectory() + ", config " + + configuration); } /**