From b37ec1237974ebd44004456914d4fab84460a25f Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Mon, 5 Feb 2007 17:23:09 +0000 Subject: [PATCH] Fix AR-1208 - Issuers were using Spring init to load data. The Hibernate database auto-update was switch on and this bypassed the SchemaBootstrap. - Added an AvmBootstrap bean for initializing AVM components that require DB interaction git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5042 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/avm-services-context.xml | 6 +- config/alfresco/bootstrap-context.xml | 10 +++ config/alfresco/hibernate-context.xml | 4 +- .../org/alfresco/repo/avm/AvmBootstrap.java | 72 +++++++++++++++++++ source/java/org/alfresco/repo/avm/Issuer.java | 2 +- 5 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 source/java/org/alfresco/repo/avm/AvmBootstrap.java diff --git a/config/alfresco/avm-services-context.xml b/config/alfresco/avm-services-context.xml index 71b53eae65..30f24286f4 100644 --- a/config/alfresco/avm-services-context.xml +++ b/config/alfresco/avm-services-context.xml @@ -6,8 +6,7 @@ - + node @@ -16,8 +15,7 @@ - + layer diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index 1d9f58fa79..a360122959 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -49,6 +49,16 @@ + + + + + + + + + + diff --git a/config/alfresco/hibernate-context.xml b/config/alfresco/hibernate-context.xml index 013d83a6aa..22b3444c45 100644 --- a/config/alfresco/hibernate-context.xml +++ b/config/alfresco/hibernate-context.xml @@ -31,7 +31,7 @@ - true + false @@ -58,7 +58,7 @@ org/jbpm/graph/action/Script.hbm.xml - org/jbpm/db/hibernate.queries.hbm.xml + org/jbpm/db/hibernate.queries.hbm.xml org/jbpm/graph/def/ProcessDefinition.hbm.xml org/jbpm/graph/def/Node.hbm.xml org/jbpm/graph/def/Transition.hbm.xml diff --git a/source/java/org/alfresco/repo/avm/AvmBootstrap.java b/source/java/org/alfresco/repo/avm/AvmBootstrap.java new file mode 100644 index 0000000000..07e18f7459 --- /dev/null +++ b/source/java/org/alfresco/repo/avm/AvmBootstrap.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2006 Alfresco, Inc. + * + * Licensed under the Mozilla Public License version 1.1 + * with a permitted attribution clause. You may obtain a + * copy of the License at + * + * http://www.alfresco.org/legal/license.txt + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + */ +package org.alfresco.repo.avm; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.util.AbstractLifecycleBean; +import org.springframework.context.ApplicationEvent; + +/** + * This component ensures that the AVM system is properly bootstrapped + * and that this is done in the correct order relative to other + * bootstrap components. + * + * @see #setIssuers(List) + * @see org.alfresco.repo.avm.Issuer + * + * @author Derek Hulley + */ +public class AvmBootstrap extends AbstractLifecycleBean +{ + private List issuers; + + public AvmBootstrap() + { + issuers = new ArrayList(0); + } + + /** + * Provide a list of {@link Issuer issuers} to bootstrap on context initialization. + * + * @see #onBootstrap(ApplicationEvent) + */ + public void setIssuers(List issuers) + { + this.issuers = issuers; + } + + /** + * Initialize the issuers. + */ + @Override + protected void onBootstrap(ApplicationEvent event) + { + for (Issuer issuer : issuers) + { + issuer.initialize(); + } + } + + /** NO-OP */ + @Override + protected void onShutdown(ApplicationEvent event) + { + // Nothing + } +} diff --git a/source/java/org/alfresco/repo/avm/Issuer.java b/source/java/org/alfresco/repo/avm/Issuer.java index 712ab3d24f..5be23d095a 100644 --- a/source/java/org/alfresco/repo/avm/Issuer.java +++ b/source/java/org/alfresco/repo/avm/Issuer.java @@ -65,7 +65,7 @@ public class Issuer /** * After the database is up, get our value. */ - public void init() + public void initialize() { class TxnWork implements TransactionUtil.TransactionWork {