-
Notifications
You must be signed in to change notification settings - Fork 16
Method Invocation
Mihail Kuznetsov edited this page Mar 16, 2015
·
2 revisions
method invocation
Since version 1.0.1 EverRest make possible to customize process of method invocation.
- Create subclass of
org.everrest.core.impl.method.MethodInvokerDecorator
public class MyMethodInvokerDecorator extends MethodInvokerDecorator
{
public MyMethodInvokerDecorator(MethodInvoker invoker)
{
super(invoker);
}
@Override
public Object invokeMethod(Object resource, GenericMethodResource genericMethodResource, ApplicationContext context)
{
// Do something before
Object result = super.invokeMethod(resource, genericMethodResource, context);
// Do something after
return result;
}
}
- Implement
org.everrest.core.impl.method.MethodInvokerDecoratorFactory
.
public class MyMethodInvokerDecoratorFactory implements MethodInvokerDecoratorFactory
{
@Override
public MethodInvokerDecorator makeDecorator(MethodInvoker invoker)
{
return new MyMethodInvokerDecorator(invoker);
}
}
- Create file
META-INF/services/org.everrest.core.impl.method.MethodInvokerDecoratorFactory
with content:
org.everrest.test.MyMethodInvokerDecoratorFactory
See details about ServiceLoader
-
NOTE: If you create war file then be sure file
org.everrest.core.impl.method.MethodInvokerDecoratorFactory
is in${my_application}/WEB-INF/classes/META-INF/services
folder (not in folder${my_application}/META-INF/services
). Otherwise file is not available for web application class loaded.