Improve GIS
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.jackrabbit / src / main / java / org / argeo / jackrabbit / JackrabbitContainer.java
index 0ad12327fc47f5168133d208892c99dd94c3984a..3dab19312dd57dd3ba8fe1d58055976400b9623b 100644 (file)
@@ -89,7 +89,24 @@ public class JackrabbitContainer implements InitializingBean, DisposableBean,
        private Executor systemExecutor;
        private Credentials adminCredentials;
 
+       // transition from legacy spring approach
+       private Boolean alreadyInitialized = false;
+       private Boolean alreadyDisposed = false;
+
+       /** @deprecated explicitly declare {@link #init()} as init-method instead. */
        public void afterPropertiesSet() throws Exception {
+               log.warn("## This initialization approach is deprecated and will be removed,"
+                               + " declare init-method=\"init\" instead.");
+               if (!alreadyInitialized)
+                       initImpl();
+       }
+
+       public void init() throws Exception {
+               initImpl();
+               alreadyInitialized = true;
+       }
+
+       protected void initImpl() throws Exception {
                if (repository != null) {
                        // we are just wrapping another repository
                        importNodeTypeDefinitions(repository);
@@ -143,6 +160,47 @@ public class JackrabbitContainer implements InitializingBean, DisposableBean,
                                + homeDirectory + " with config " + configuration);
        }
 
+       /**
+        * @deprecated explicitly declare {@link #dispose()} as destroy-method
+        *             instead.
+        */
+       public void destroy() throws Exception {
+               log.warn("## This dispose approach is deprecated and will be removed,"
+                               + " declare destroy-method=\"dispose\" instead.");
+               if (!alreadyDisposed)
+                       disposeImpl();
+       }
+
+       public void dispose() throws Exception {
+               disposeImpl();
+               alreadyDisposed = true;
+       }
+
+       protected void disposeImpl() throws Exception {
+               if (repository != null) {
+                       if (repository instanceof JackrabbitRepository)
+                               ((JackrabbitRepository) repository).shutdown();
+                       else if (repository instanceof RepositoryImpl)
+                               ((RepositoryImpl) repository).shutdown();
+                       else if (repository instanceof TransientRepository)
+                               ((TransientRepository) repository).shutdown();
+               }
+
+               if (inMemory)
+                       if (homeDirectory.exists()) {
+                               FileUtils.deleteDirectory(homeDirectory);
+                               if (log.isDebugEnabled())
+                                       log.debug("Deleted Jackrabbit home directory "
+                                                       + homeDirectory);
+                       }
+
+               if (uri != null && !uri.trim().equals(""))
+                       log.info("Destroyed Jackrabbit repository with uri " + uri);
+               else
+                       log.info("Destroyed Jackrabbit repository " + repository + " in "
+                                       + homeDirectory + " with config " + configuration);
+       }
+
        protected Properties getConfigurationProperties() {
                InputStream propsIn = null;
                Properties vars;
@@ -221,31 +279,6 @@ public class JackrabbitContainer implements InitializingBean, DisposableBean,
                        action.run();
        }
 
-       public void destroy() throws Exception {
-               if (repository != null) {
-                       if (repository instanceof JackrabbitRepository)
-                               ((JackrabbitRepository) repository).shutdown();
-                       else if (repository instanceof RepositoryImpl)
-                               ((RepositoryImpl) repository).shutdown();
-                       else if (repository instanceof TransientRepository)
-                               ((TransientRepository) repository).shutdown();
-               }
-
-               if (inMemory)
-                       if (homeDirectory.exists()) {
-                               FileUtils.deleteDirectory(homeDirectory);
-                               if (log.isDebugEnabled())
-                                       log.debug("Deleted Jackrabbit home directory "
-                                                       + homeDirectory);
-                       }
-
-               if (uri != null && !uri.trim().equals(""))
-                       log.info("Destroyed Jackrabbit repository with uri " + uri);
-               else
-                       log.info("Destroyed Jackrabbit repository " + repository + " in "
-                                       + homeDirectory + " with config " + configuration);
-       }
-
        // JCR REPOSITORY (delegated)
        public String getDescriptor(String key) {
                return repository.getDescriptor(key);