Broke circular references between NodeService beans, NodeIndexer, Lucene and back to NodeService.

- NodeIndexer is now bootstrapped to pull out reference to the Lucene beans

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28892 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2011-07-08 14:20:48 +00:00
parent f4c07c0fe9
commit 4d34d73c4c
3 changed files with 33 additions and 29 deletions

View File

@@ -162,6 +162,13 @@
</property> </property>
</bean> </bean>
<!-- node indexing for ADM -->
<bean id="nodeIndexer" class="org.alfresco.repo.node.index.NodeIndexer">
<property name="disabled">
<value>${index.tracking.disableInTransactionIndexing}</value>
</property>
</bean>
<!-- Bootstrap the AVM --> <!-- Bootstrap the AVM -->
<bean id="avmBootstrap" class="org.alfresco.repo.avm.AvmBootstrap" > <bean id="avmBootstrap" class="org.alfresco.repo.avm.AvmBootstrap" >
<property name="avmLockingAwareService"> <property name="avmLockingAwareService">

View File

@@ -182,16 +182,6 @@
</property> </property>
</bean> </bean>
<!-- node indexing for ADM -->
<bean id="nodeIndexer" class="org.alfresco.repo.node.index.NodeIndexer">
<property name="disabled">
<value>${index.tracking.disableInTransactionIndexing}</value>
</property>
<property name="indexer">
<ref bean="indexerComponent" />
</property>
</bean>
<!-- Node cleanup --> <!-- Node cleanup -->
<bean id="nodeCleanupRegistry" class="org.alfresco.repo.node.cleanup.NodeCleanupRegistry" /> <bean id="nodeCleanupRegistry" class="org.alfresco.repo.node.cleanup.NodeCleanupRegistry" />
<bean id="nodeCleanupBase" abstract="true" init-method="register"> <bean id="nodeCleanupBase" abstract="true" init-method="register">

View File

@@ -18,44 +18,37 @@
*/ */
package org.alfresco.repo.node.index; package org.alfresco.repo.node.index;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.search.Indexer; import org.alfresco.repo.search.Indexer;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
/** /**
* Passes index information to the index services. * Passes index information to the index services.
* *
* @author Derek Hulley * @author Derek Hulley
*/ */
@SuppressWarnings("unused") public class NodeIndexer extends AbstractLifecycleBean
public class NodeIndexer
{ {
private static Log logger = LogFactory.getLog(NodeIndexer.class); private static Log logger = LogFactory.getLog(NodeIndexer.class);
/** the component to index the node hierarchy */ /** the component to index the node hierarchy */
private Indexer indexer; private Indexer indexer;
/** ready to use or not */
private volatile boolean started;
/** enabled or disabled */ /** enabled or disabled */
private boolean enabled; private boolean enabled;
public NodeIndexer() public NodeIndexer()
{ {
started = false;
enabled = true; enabled = true;
} }
/**
* @param indexer the indexer that will be index
*/
public void setIndexer(Indexer indexer)
{
this.indexer = indexer;
}
/** /**
* Explicit property to disable in-transaction indexing. * Explicit property to disable in-transaction indexing.
* *
@@ -71,6 +64,20 @@ public class NodeIndexer
this.enabled = enabled; this.enabled = enabled;
} }
@Override
protected void onBootstrap(ApplicationEvent event)
{
// Dig the indexer out of the context
indexer = (Indexer) super.getApplicationContext().getBean("indexerComponent");
started = true;
}
@Override
protected void onShutdown(ApplicationEvent event)
{
started = false;
}
public void indexDeleteStore(StoreRef storeRef) public void indexDeleteStore(StoreRef storeRef)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
@@ -82,7 +89,7 @@ public class NodeIndexer
public void indexCreateNode(ChildAssociationRef childAssocRef) public void indexCreateNode(ChildAssociationRef childAssocRef)
{ {
if (enabled) if (enabled && started)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
@@ -94,7 +101,7 @@ public class NodeIndexer
public void indexUpdateNode(NodeRef nodeRef) public void indexUpdateNode(NodeRef nodeRef)
{ {
if (enabled) if (enabled && started)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
@@ -106,7 +113,7 @@ public class NodeIndexer
public void indexDeleteNode(ChildAssociationRef childAssocRef) public void indexDeleteNode(ChildAssociationRef childAssocRef)
{ {
if (enabled) if (enabled && started)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
@@ -118,7 +125,7 @@ public class NodeIndexer
public void indexCreateChildAssociation(ChildAssociationRef childAssocRef) public void indexCreateChildAssociation(ChildAssociationRef childAssocRef)
{ {
if (enabled) if (enabled && started)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
@@ -130,7 +137,7 @@ public class NodeIndexer
public void indexDeleteChildAssociation(ChildAssociationRef childAssocRef) public void indexDeleteChildAssociation(ChildAssociationRef childAssocRef)
{ {
if (enabled) if (enabled && started)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
@@ -142,7 +149,7 @@ public class NodeIndexer
public void indexUpdateChildAssociation(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) public void indexUpdateChildAssociation(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef)
{ {
if (enabled) if (enabled && started)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {