04-29-2011 03:59 PM
<bean id="templateNodeFactory"
class="org.alfresco.repo.template.TemplateNodeFactory"
p:serviceRegistry-ref="serviceRegistry" />
public class TemplateNodeFactory
{
private ServiceRegistry services;
private TemplateImageResolver resolver;
@Required
public void setServiceRegistry( ServiceRegistry services )
{
this.services = services;
}
public void setTemplateImageResolver( TemplateImageResolver resolver )
{
this.resolver = resolver;
}
/**
* Creates a new TemplateNode for the nodeRef
*
* @param nodeRef
* @return
*/
public TemplateNode createTemplateNode( NodeRef nodeRef )
{
return createTemplateNode(nodeRef,this.services,this.resolver);
}
/**
* Creates a new TemplateNode for the nodeRef
*
* @param nodeRef
* @param services
* @param resolver
* @return
*/
protected TemplateNode createTemplateNode(
NodeRef nodeRef,
ServiceRegistry services,
TemplateImageResolver resolver )
{
return new CoreTemplateNode(nodeRef, services, resolver);
}
}
The factory class could then be extended to return the appropriate implementation. There are probably other ways of going about this, but this would certainly be helpful.
/* templateNodeClass node would be specified as a bean property, p:templateNodeClass="package.MyTemplateNode" */
protected TemplateNode createTemplateNode( NodeRef nodeRef, ServiceRegistry services, TemplateImageResolver resolver )
{
try {
Constructor<TemplateNode> constructor = templateNodeClass.getConstructor(NodeRef.class,ServiceRegistry.class,TemplateImageResolver.class);
return constructor.newInstance(nodeRef,services,resolver);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
02-15-2012 04:10 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.