Created
January 2, 2013 08:19
-
-
Save wojtekerbetowski/4433014 to your computer and use it in GitHub Desktop.
Putting things together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final def advice = new MethodAdvice() { | |
@Override | |
void advise(MethodInvocation invocation) { | |
logger.debug("Entering method") | |
invocation.proceed() | |
} | |
} | |
def transformer = new PlasticClassTransformer() { | |
@Override | |
void transform(PlasticClass plasticClass) { | |
def method = plasticClass.methods.find {it.description.methodName == 'myBusinessMethod'} | |
method.addAdvice(advice) | |
} | |
} | |
def delegate = new StandardDelegate(transformer) | |
def plasticManager = PlasticManager | |
.withContextClassLoader() | |
.packages(['pl.erbetowski.plastic.logging']) | |
.delegate(delegate) | |
.create() | |
def instantiator = plasticManager.getClassInstantiator('pl.erbetowski.plastic.logging.FakeService') | |
return instantiator.newInstance() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment