public final class RuleConstructor extends Object
Provides a fluent API for creating Byteman rules without needing to mess around with String concatenation.
Example:
RuleConstructor rb = RuleConstructor.createRule("myRule")
.onClass("org.jboss.byteman.ExampleClass")
.inMethod("doInterestingStuff")
.atEntry()
.ifTrue()
.doAction("myAction()");
System.out.println(rb.build());
will print:
RULE myRule
CLASS org.jboss.byteman.ExampleClass
METHOD doInterestingStuff
AT ENTRY
IF true
DO myAction()
ENDRULE
Modifier and Type | Class | Description |
---|---|---|
class |
RuleConstructor.ActionClause |
|
class |
RuleConstructor.ClassClause |
|
class |
RuleConstructor.ConditionClause |
|
class |
RuleConstructor.LocationClause |
|
class |
RuleConstructor.MethodClause |
Modifier and Type | Method | Description |
---|---|---|
String |
build() |
Builds the rule defined by this instance of
RuleConstructor
and returns its representation as string. |
static RuleConstructor.ClassClause |
createRule(String ruleName) |
This is where you start.
|
static Instrumentor |
getDefaultInstrumentor() |
Returning value of the previously set default
Instrumentor instance. |
RuleConstructor |
install() |
Installing/submitting rule to the Byteman agent via instance of instrumentor
defined as default to the
RuleConstructor class. |
RuleConstructor |
install(Instrumentor instrumentor) |
Installing/submitting rule to the Byteman agent via instance of instrumentor.
|
static void |
setDefaultInstrumentor(Instrumentor instrumentor) |
Setting default initialize instance of
Instrumentor class
that will be used when install() /submit() method
is used for the created rule.You can define this default Instrumentor which could be used whenever the new rule is submitted to the Byteman agent. null is permitted then install() method throws exception |
RuleConstructor |
submit() |
Facade to method
install() . |
RuleConstructor |
submit(Instrumentor instrumentor) |
Facade to method
install(Instrumentor) . |
static void |
undefineDefaultInstrumentor() |
Undefinining value of default instrumentor.
|
public static final void setDefaultInstrumentor(Instrumentor instrumentor)
Setting default initialize instance of Instrumentor
class
that will be used when install()
/submit()
method
is used for the created rule.
You can define this default Instrumentor which could be used whenever
the new rule is submitted to the Byteman agent.
null
is permitted then install()
method throws exception
instrumentor
- initiated instrumentor instance or nullpublic static final void undefineDefaultInstrumentor()
public static final Instrumentor getDefaultInstrumentor()
Instrumentor
instance.public static final RuleConstructor.ClassClause createRule(String ruleName)
This is where you start.
Byteman
rule builder initialization method.
ruleName
- name of rule is required to construct any rulepublic RuleConstructor install()
Installing/submitting rule to the Byteman agent via instance of instrumentor
defined as default to the RuleConstructor
class.
Internally this:
build()
is called to generate rule as String
Instrumentor
setDefaultInstrumentor(Instrumentor)
IllegalStateException
- if default instrumentor is not setRuntimeException
- if error happens during installation rule
via default instrumentor instancepublic RuleConstructor install(Instrumentor instrumentor)
Installing/submitting rule to the Byteman agent via instance of instrumentor.
Internally this:
build()
is called to generate rule as String
Instrumentor
instrumentor
- instance of instrumentor to be used to submit the rule toNullPointerException
- if instrumentor param is provided as nullRuntimeException
- if error happens during installation rule
via default instrumentor instancepublic RuleConstructor submit()
install()
.IllegalStateException
- if default instrumentor is not setRuntimeException
- if error happens during installation rulepublic RuleConstructor submit(Instrumentor instrumentor)
install(Instrumentor)
.instrumentor
- instance of instrumentor to be used to submit the rule toNullPointerException
- if instrumentor param is provided as nullRuntimeException
- if error happens during installation rulepublic String build()
RuleConstructor
and returns its representation as string.Copyright © 2018. All rights reserved.