Remove a few uses of ServiceRegistry where dependencies on the relevant services are cleaner, and note where the ServiceRegistry really is required

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18781 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2010-02-23 12:16:49 +00:00
parent 6241c8906e
commit a4d8f92c70
3 changed files with 58 additions and 32 deletions

View File

@@ -429,6 +429,7 @@
<property name="authorityService"> <property name="authorityService">
<ref bean="authorityService"></ref> <ref bean="authorityService"></ref>
</property> </property>
<!-- The service registry is needed as TemplateNodes are used -->
<property name="serviceRegistry"> <property name="serviceRegistry">
<ref bean="ServiceRegistry"></ref> <ref bean="ServiceRegistry"></ref>
</property> </property>
@@ -521,6 +522,7 @@
</bean> </bean>
<bean id="script" class="org.alfresco.repo.action.executer.ScriptActionExecuter" parent="action-executer"> <bean id="script" class="org.alfresco.repo.action.executer.ScriptActionExecuter" parent="action-executer">
<!-- The service registry is needed as ScriptAction needs it -->
<property name="serviceRegistry"> <property name="serviceRegistry">
<ref bean="ServiceRegistry" /> <ref bean="ServiceRegistry" />
</property> </property>
@@ -565,7 +567,7 @@
</property> </property>
</bean> </bean>
<!-- deprecated - see "wcm-submit" (wcm-services-context.xml) --> <!-- deprecated - see "wcm-submit" (wcm-services-context.xml) -->
<bean id="simple-avm-submit" class="org.alfresco.repo.avm.actions.SimpleAVMSubmitAction" parent="action-executer"> <bean id="simple-avm-submit" class="org.alfresco.repo.avm.actions.SimpleAVMSubmitAction" parent="action-executer">
<property name="avmService"> <property name="avmService">
<ref bean="AVMService"/> <ref bean="AVMService"/>
@@ -581,7 +583,7 @@
</property> </property>
</bean> </bean>
<!-- deprecated --> <!-- deprecated -->
<bean id="start-avm-workflow" class="org.alfresco.repo.avm.actions.StartAVMWorkflowAction" parent="action-executer"> <bean id="start-avm-workflow" class="org.alfresco.repo.avm.actions.StartAVMWorkflowAction" parent="action-executer">
<property name="workflowService"> <property name="workflowService">
<ref bean="WorkflowService"/> <ref bean="WorkflowService"/>
@@ -594,7 +596,7 @@
</property> </property>
</bean> </bean>
<!-- deprecated --> <!-- deprecated -->
<bean id="simple-avm-promote" class="org.alfresco.repo.avm.actions.SimpleAVMPromoteAction" parent="action-executer"> <bean id="simple-avm-promote" class="org.alfresco.repo.avm.actions.SimpleAVMPromoteAction" parent="action-executer">
<property name="avmSyncService"> <property name="avmSyncService">
<ref bean="avmSyncService"/> <ref bean="avmSyncService"/>
@@ -604,7 +606,7 @@
</property> </property>
</bean> </bean>
<!-- deprecated - see "wcm-revert-snapshot" (wcm-services-context.xml) --> <!-- deprecated - see "wcm-revert-snapshot" (wcm-services-context.xml) -->
<bean id="avm-revert-store" class="org.alfresco.repo.avm.actions.AVMRevertStoreAction" parent="action-executer"> <bean id="avm-revert-store" class="org.alfresco.repo.avm.actions.AVMRevertStoreAction" parent="action-executer">
<property name="avmSyncService"> <property name="avmSyncService">
<ref bean="avmSyncService"/> <ref bean="avmSyncService"/>
@@ -614,7 +616,7 @@
</property> </property>
</bean> </bean>
<!-- deprecated --> <!-- deprecated -->
<bean id="avm-revert-list" class="org.alfresco.repo.avm.actions.AVMRevertListAction" parent="action-executer"> <bean id="avm-revert-list" class="org.alfresco.repo.avm.actions.AVMRevertListAction" parent="action-executer">
<property name="avmSyncService"> <property name="avmSyncService">
<ref bean="avmSyncService"/> <ref bean="avmSyncService"/>
@@ -624,7 +626,7 @@
</property> </property>
</bean> </bean>
<!-- deprecated - note: still used by Web-Client (FileDetailsBean) --> <!-- deprecated - note: still used by Web-Client (FileDetailsBean) -->
<bean id="avm-revert-to-version" class="org.alfresco.repo.avm.actions.AVMRevertToVersionAction" parent = "action-executer"> <bean id="avm-revert-to-version" class="org.alfresco.repo.avm.actions.AVMRevertToVersionAction" parent = "action-executer">
<property name="avmService"> <property name="avmService">
<ref bean="AVMLockingAwareService"/> <ref bean="AVMLockingAwareService"/>
@@ -634,7 +636,7 @@
</property> </property>
</bean> </bean>
<!-- deprecated - see "wcm-undo" (wcm-services-context.xml) --> <!-- deprecated - see "wcm-undo" (wcm-services-context.xml) -->
<bean id="avm-undo-list" class="org.alfresco.repo.avm.actions.AVMUndoSandboxListAction" parent="action-executer"> <bean id="avm-undo-list" class="org.alfresco.repo.avm.actions.AVMUndoSandboxListAction" parent="action-executer">
<property name="avmService"> <property name="avmService">
<ref bean="AVMService"/> <ref bean="AVMService"/>
@@ -647,7 +649,7 @@
</property> </property>
</bean> </bean>
<!-- deprecated - note: still used by Web-Client (*Deploy*) --> <!-- deprecated - note: still used by Web-Client (*Deploy*) -->
<bean id="avm-deploy-website" class="org.alfresco.repo.avm.actions.AVMDeployWebsiteAction" parent="action-executer"> <bean id="avm-deploy-website" class="org.alfresco.repo.avm.actions.AVMDeployWebsiteAction" parent="action-executer">
<!-- Run avm-deploy-website action on the deployment queue --> <!-- Run avm-deploy-website action on the deployment queue -->
@@ -719,7 +721,7 @@
</property> </property>
</bean> </bean>
<!-- deprecated --> <!-- deprecated -->
<bean id="avm-link-validation" class="org.alfresco.linkvalidation.LinkValidationAction" parent="action-executer" lazy-init="true"> <bean id="avm-link-validation" class="org.alfresco.linkvalidation.LinkValidationAction" parent="action-executer" lazy-init="true">
<property name="linkValidationService"> <property name="linkValidationService">
<ref bean="LinkValidationService"/> <ref bean="LinkValidationService"/>

View File

@@ -27,9 +27,10 @@ import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
@@ -56,8 +57,11 @@ public class MessageServiceImpl implements MessageService
private Lock writeLock = lock.writeLock(); private Lock writeLock = lock.writeLock();
// dependencies // dependencies
private ServiceRegistry serviceRegistry;
private TenantService tenantService; private TenantService tenantService;
private SearchService searchService;
private ContentService contentService;
private NamespaceService namespaceService;
private NodeService nodeService;
/** /**
* List of registered bundles * List of registered bundles
@@ -77,16 +81,29 @@ public class MessageServiceImpl implements MessageService
private List<MessageDeployer> messageDeployers = new ArrayList<MessageDeployer>(); private List<MessageDeployer> messageDeployers = new ArrayList<MessageDeployer>();
public void setNamespaceService(NamespaceService namespaceService)
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{ {
this.serviceRegistry = serviceRegistry; this.namespaceService = namespaceService;
} }
public void setSearchService(SearchService searchService) {
this.searchService = searchService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setTenantService(TenantService tenantService) public void setTenantService(TenantService tenantService)
{ {
this.tenantService = tenantService; this.tenantService = tenantService;
} }
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
public void setResourceBundleBaseNamesCache(SimpleCache<String, Set<String>> resourceBundleBaseNamesCache) public void setResourceBundleBaseNamesCache(SimpleCache<String, Set<String>> resourceBundleBaseNamesCache)
{ {
@@ -537,19 +554,16 @@ public class MessageServiceImpl implements MessageService
// TODO - need to replace basic strategy with a more complete // TODO - need to replace basic strategy with a more complete
// search & instantiation strategy similar to ResourceBundle.getBundle() // search & instantiation strategy similar to ResourceBundle.getBundle()
// Consider search query with basename* and then apply strategy ... // Consider search query with basename* and then apply strategy ...
SearchService searchService = serviceRegistry.getSearchService(); NodeRef rootNode = nodeService.getRootNode(storeRef);
NamespaceService resolver = serviceRegistry.getNamespaceService();
NodeRef rootNode = serviceRegistry.getNodeService().getRootNode(storeRef);
// first attempt - with locale // first attempt - with locale
List<NodeRef> nodeRefs = searchService.selectNodes(rootNode, path+"_"+locale+PROPERTIES_FILE_SUFFIX, null, resolver, false); List<NodeRef> nodeRefs = searchService.selectNodes(rootNode, path+"_"+locale+PROPERTIES_FILE_SUFFIX, null, namespaceService, false);
if ((nodeRefs == null) || (nodeRefs.size() == 0)) if ((nodeRefs == null) || (nodeRefs.size() == 0))
{ {
// second attempt - basename // second attempt - basename
nodeRefs = searchService.selectNodes(rootNode, path+PROPERTIES_FILE_SUFFIX, null, resolver, false); nodeRefs = searchService.selectNodes(rootNode, path+PROPERTIES_FILE_SUFFIX, null, namespaceService, false);
if ((nodeRefs == null) || (nodeRefs.size() == 0)) if ((nodeRefs == null) || (nodeRefs.size() == 0))
{ {
@@ -566,7 +580,7 @@ public class MessageServiceImpl implements MessageService
{ {
NodeRef messageResourceNodeRef = nodeRefs.get(0); NodeRef messageResourceNodeRef = nodeRefs.get(0);
ContentReader cr = serviceRegistry.getContentService().getReader(messageResourceNodeRef, ContentModel.PROP_CONTENT); ContentReader cr = contentService.getReader(messageResourceNodeRef, ContentModel.PROP_CONTENT);
resBundle = new MessagePropertyResourceBundle(new InputStreamReader(cr.getContentInputStream(), cr.getEncoding())); resBundle = new MessagePropertyResourceBundle(new InputStreamReader(cr.getContentInputStream(), cr.getEncoding()));
} }

View File

@@ -32,10 +32,13 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionDefinition; import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.action.ParameterDefinition; import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Wrapper; import org.mozilla.javascript.Wrapper;
@@ -54,12 +57,15 @@ public final class ScriptAction implements Serializable, Scopeable
/** Converter with knowledge of action parameter values */ /** Converter with knowledge of action parameter values */
private ActionValueConverter converter; private ActionValueConverter converter;
private ServiceRegistry services;
/** Action state */ /** Action state */
private Action action; private Action action;
private ActionDefinition actionDef; private ActionDefinition actionDef;
private ServiceRegistry services;
private ActionService actionService;
private NamespaceService namespaceService;
private TransactionService transactionService;
private ScriptableParameterMap<String, Serializable> parameters = null; private ScriptableParameterMap<String, Serializable> parameters = null;
@@ -72,6 +78,10 @@ public final class ScriptAction implements Serializable, Scopeable
public ScriptAction(ServiceRegistry services, Action action, ActionDefinition actionDef) public ScriptAction(ServiceRegistry services, Action action, ActionDefinition actionDef)
{ {
this.services = services; this.services = services;
this.actionService = services.getActionService();
this.namespaceService = services.getNamespaceService();
this.transactionService = services.getTransactionService();
this.action = action; this.action = action;
this.actionDef = actionDef; this.actionDef = actionDef;
this.converter = new ActionValueConverter(); this.converter = new ActionValueConverter();
@@ -141,7 +151,7 @@ public final class ScriptAction implements Serializable, Scopeable
actionParams.put(name, value); actionParams.put(name, value);
} }
} }
services.getActionService().executeAction(action, node.getNodeRef()); actionService.executeAction(action, node.getNodeRef());
// Parameters may have been updated by action execution, so reset cache // Parameters may have been updated by action execution, so reset cache
this.parameters = null; this.parameters = null;
@@ -180,11 +190,11 @@ public final class ScriptAction implements Serializable, Scopeable
{ {
public Object execute() throws Throwable public Object execute() throws Throwable
{ {
services.getActionService().executeAction(action, node.getNodeRef()); actionService.executeAction(action, node.getNodeRef());
return null; return null;
} }
}; };
services.getTransactionService().getRetryingTransactionHelper().doInTransaction( transactionService.getRetryingTransactionHelper().doInTransaction(
executionActionCallback, executionActionCallback,
readOnly, readOnly,
newTxn); newTxn);
@@ -218,7 +228,7 @@ public final class ScriptAction implements Serializable, Scopeable
actionParams.put(name, value); actionParams.put(name, value);
} }
} }
services.getActionService().executeAction(action, nodeRef); actionService.executeAction(action, nodeRef);
// Parameters may have been updated by action execution, so reset cache // Parameters may have been updated by action execution, so reset cache
this.parameters = null; this.parameters = null;
@@ -254,11 +264,11 @@ public final class ScriptAction implements Serializable, Scopeable
{ {
public Object execute() throws Throwable public Object execute() throws Throwable
{ {
services.getActionService().executeAction(action, nodeRef); actionService.executeAction(action, nodeRef);
return null; return null;
} }
}; };
services.getTransactionService().getRetryingTransactionHelper().doInTransaction( transactionService.getRetryingTransactionHelper().doInTransaction(
executionActionCallback, executionActionCallback,
readOnly, readOnly,
newTxn); newTxn);
@@ -289,7 +299,7 @@ public final class ScriptAction implements Serializable, Scopeable
ParameterDefinition paramDef = actionDef.getParameterDefintion(paramName); ParameterDefinition paramDef = actionDef.getParameterDefintion(paramName);
if (paramDef != null && paramDef.getType().equals(DataTypeDefinition.QNAME)) if (paramDef != null && paramDef.getType().equals(DataTypeDefinition.QNAME))
{ {
return ((QName) value).toPrefixString(services.getNamespaceService()); return ((QName) value).toPrefixString(namespaceService);
} }
else else
{ {
@@ -331,7 +341,7 @@ public final class ScriptAction implements Serializable, Scopeable
} }
else else
{ {
return QName.createQName(stringQName, services.getNamespaceService()); return QName.createQName(stringQName, namespaceService);
} }
} }
else else