Modifier and Type | Field and Description |
---|---|
Tuple |
child |
protected String |
code
The original punchlet code
|
protected long |
eventCount |
protected com.codahale.metrics.MetricRegistry |
metricRegistry
The associated codahale metric registry
|
RuntimeContext |
r
The punchlet runtime context
|
protected org.thales.punch.libraries.utils.api.IUUIDGenerator |
uuidGenerator
Our generator of short yet unique message identifier.
|
Tuple |
world
The world tuple allows for generic communications with the external environments
|
Constructor and Description |
---|
PunchletContext(RuntimeContext r)
The runtime context is passed.
|
Modifier and Type | Method and Description |
---|---|
String |
ecount()
Return a counter, increased everytime you call it.
|
boolean |
every(long number)
For testing performance punchlets it is handy to have something like this.
|
void |
execute(Tuple root)
Execute the punchlet.
|
String |
getPath() |
String |
getPersistentId()
Deprecated.
|
Properties |
getProperties()
Return the properties associated to this punchlet, i.e.
|
String |
getRuntimeId()
Return a runtime identifier.
|
Tuple |
getWorldTuple()
Return the world tuple associated to your punchlet
|
void |
invoke(Tuple root)
This method only invoke the punchlet execute method and takes care of catching all
exception to make them transformed as punch runtime exceptions.
|
void |
setCode(String code)
Set the original punchlet code.
|
void |
setPath(String path)
Associate a path to this punchlet.
|
PunchletContext |
setPersistentId(String puid)
Set this punchlet persistent identifier
|
PunchletContext |
setProperties(Properties properties)
A punchlet can have properties associated.
|
PunchletContext |
setRuntimeId(String ruid)
Deprecated.
|
protected com.codahale.metrics.MetricRegistry metricRegistry
public Tuple world
public Tuple child
public final RuntimeContext r
protected long eventCount
protected org.thales.punch.libraries.utils.api.IUUIDGenerator uuidGenerator
protected String code
public PunchletContext(RuntimeContext r)
Watch out, the runtime context can be null for a punchlet instance.
r
- the runtime context associated to the punchletpublic void setPath(String path)
path
- the punchlet pathpublic String getPath()
public void setCode(String code)
code
- the punchlet codepublic String ecount()
The corresponding counter starts at 0, and is associated to your punchlet.
public void invoke(Tuple root)
root
- the input tuplepublic void execute(Tuple root)
{
[es_type] = \"apache\";
}
These simple punchlet are compiled into a running punchlet implementing this class.
Note that a punchlet can be injected with additional json resource tuples, i.e. tuple that hold the content of static json files, containing configuration data. These are automatically injected as fields in your punchlet.
root
- the root tuple. This one is mandatory@Deprecated public String getPersistentId()
public String getRuntimeId()
public Tuple getWorldTuple()
public PunchletContext setPersistentId(String puid)
puid
- the persistent identifierpublic Properties getProperties()
@Deprecated public PunchletContext setRuntimeId(String ruid)
Use this with caution. It is most useful for testing purpose.
ruid
- a String supposed to be a runtime identifier of your punchlet.public PunchletContext setProperties(Properties properties)
properties
- the declared propertiespublic boolean every(long number)
number
- numberCopyright © 2023. All rights reserved.