02-03-2009 08:00 AM
02-06-2009 09:01 AM
02-13-2009 04:29 AM
02-13-2009 05:31 AM
ContentServicePolicies.OnContentReadPolicy
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.ContentServicePolicies;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
public class ContentReadAccessEvent implements ContentServicePolicies.OnContentReadPolicy{
private PolicyComponent policyComponent;
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
public void init(){
this.policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onContentRead"),
ContentModel.TYPE_CONTENT,
new JavaBehaviour(this, "onContentRead", Behaviour.NotificationFrequency.EVERY_EVENT));
}
@Override
public void onContentRead(NodeRef nodeRef) {
//do some things here
}
}
02-13-2009 06:50 AM
02-13-2009 10:03 AM
<bean id="contentServiceInterceptor" class="de.dmc.alfresco.configuration.ContentServiceInterceptor"/>
<bean id="readerInterceptor" class="de.dmc.alfresco.configuration.ContentReaderInterceptor"/>
<bean id="ContentService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>org.alfresco.service.cmr.repository.ContentService</value>
</property>
<property name="target">
<ref bean="contentService"/>
</property>
<property name="interceptorNames">
<list>
<idref bean="ContentService_transaction"/>
<idref bean="AuditMethodInterceptor"/>
<idref bean="exceptionTranslator"/>
<idref bean="mlContentInterceptor"/>
<idref bean="ContentService_security"/>
<idref bean="ContentService_security"/>
<idref bean="contentServiceInterceptor"/>
</list>
</property>
</bean>
package de.dmc.alfresco.configuration;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.alfresco.service.cmr.repository.ContentReader;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
public class ContentServiceInterceptor implements MethodInterceptor{
class ContentReaderHandler implements InvocationHandler {
private ContentReader cdr;
public ContentReaderHandler(ContentReader cdr){
this.cdr = cdr;
}
public Object invoke(Object proxy, Method method, Object[] args) {
try {
if(method.getName().startsWith("getContent")){
//here we begin to count
}
System.out.println(method.getName());
return method.invoke(cdr, args);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if(invocation.getMethod().getName().equals("getReader")){
Class cdrClass = Class.forName("org.alfresco.service.cmr.repository.ContentReader");
return Proxy.newProxyInstance(cdrClass.getClassLoader(),
new Class[] { cdrClass },
new ContentReaderHandler((ContentReader)invocation.proceed()));
}
return invocation.proceed();
}
}
02-14-2009 06:54 AM
02-15-2009 01:03 PM
02-15-2009 02:39 PM
02-15-2009 04:25 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.