Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request closes #29
After experimenting with AST and bytecode verifiers I came up with a relatively easy way to provide the extensibility of the core BTrace functionality by the means of external plugins. Very importantly, introducing external plugins doesn’t incur any additional overhead on top of the one caused by the extension functionality itself.
Creating a New Service
Creating a new service is just a matter of extending one of the following two classes
SimpleService
A stateless service which can even be a singleton. It has no access to the BTrace runtime and can rely on the provided values.
RuntimeService
For each BTraceRuntime a new service instance will be created. The service can use BTrace features exposed via BTraceRuntime - eg. send messages over the wire channel.
Using Services
Services become available by adding the jars containing them to the bootclasspath. (eg. via agent options)
The recommended way to use services in the script is to create fields of the appropriate service type and annotate them by the @injected annotation.
There is an alternative approach valid only for locally accessible services.
These two approaches are functionally equivalent - it really depends on the script author which one she should choose.