public final class GroovyMethods extends Proxy
Provides commonly used Martini Runtime functions, as well as useful utilities to the Groovy engine. This is included in the Groovy engine through its extension module functionality.
Before using this in your scripts, you should read up on Closures (also consider reading more about them here.
Aside from this utility class, you can also use built-in utility classes included by the Groovy Engine and Martini Runtime. See the list of classes below to learn more about the functionalities available to you when writing Groovy scripts in Martini.
JmsMethods
,
CoreMethods
,
CsvMethods
,
HttpClientMethods
,
JabberMethods
,
JmsMethods
,
LoggerMethods
,
MarshallerMethods
,
MonitorMethods
,
ProxyRequestMethods
,
RestMethods
,
RssMethods
,
SolrMethods
,
SqlMethods
,
TrackerMethods
,
UtilMethods
,
VelocityMethods
,
VfsMethods
,
WebSocketMethods
,
WidgetPageMethods
,
DefaultGroovyMethods
,
DateGroovyMethods
,
EncodingGroovyMethods
,
IOGroovyMethods
,
NioGroovyMethods
,
ProcessGroovyMethods
,
ResourceGroovyMethods
,
SocketGroovyMethods
,
SqlGroovyMethods
,
StringGroovyMethods
,
SwingGroovyMethods
,
XmlGroovyMethods
,
ArrayUtils
,
BooleanUtils
,
DateFormatUtils
,
DateUtils
,
DigestUtils
,
NumberUtils
,
RandomStringUtils
,
StringEscapeUtils
,
StringMethods
Modifier and Type | Class and Description |
---|---|
static class |
GroovyMethods.MartiniPackageSetter
An internal class used for setting the
MartiniPackage of the ThreadLocal |
Modifier and Type | Method and Description |
---|---|
Object |
getAdaptee() |
static String |
getApplicationProperty(String key)
Get the value of an application property.
|
static String |
getApplicationProperty(String key,
String defaultValue)
Get the value of an application property.
|
static io.toro.martini.ipackage.MartiniPackage |
getPackage()
Get the package assigned to the current context.
|
static String |
getPackageProperty(String key)
Get the value of a package property.
|
static String |
getPackageProperty(String key,
String defaultValue)
Get the value of a package property.
|
static String[] |
getPackagePropertyArray(String key)
Get the value of a package property as an array.
|
static String[] |
getPackagePropertyArray(String key,
String[] defaultValue)
Get the value of a package property as an array.
|
static String |
getPackagePropertyComment(String key)
Get the comment of a package property, useful for understanding the property's purpose.
|
static String |
getTOROProperty(String key)
Deprecated.
This method has been renamed. Please prefer
getPackageProperty(String) . |
static String |
getTOROProperty(String key,
String defaultValue)
Deprecated.
This method has been renamed. Please prefer
getPackageProperty(String, String) . |
static String[] |
getTOROPropertyArray(String key)
Deprecated.
This method has been renamed. Please prefer
getPackagePropertyArray(String) . |
static String[] |
getTOROPropertyArray(String key,
String[] defaultValue)
Deprecated.
This method has been renamed. Please prefer
getPackagePropertyArray(String, String[]) . |
static String |
getTOROPropertyComment(String key)
Deprecated.
This method has been renamed. Please prefer
getPackagePropertyComment(String) . |
Object |
invokeMethod(String name,
Object args) |
Iterator |
iterator() |
static String |
removePackageProperty(String key)
Delete a package property.
|
static String |
removeTOROProperty(String key)
Deprecated.
This method has been renamed. Please prefer
removePackageProperty(String) . |
static String |
savePackageProperty(String key,
String value)
Save a package property.
|
static void |
savePackagePropertyComment(String key,
String comment)
Add a comment to a package property, useful for providing a description of the property.
|
static String |
saveTOROProperty(String key,
String value)
Deprecated.
This method has been renamed. Please prefer
savePackageProperty(String, String) . |
static void |
saveTOROPropertyComment(String key,
String comment)
Deprecated.
This method has been renamed. Please prefer
savePackagePropertyComment(String, String) . |
void |
setAdaptee(Object adaptee) |
static <V> V |
withPackageEndpoints(GroovyObject obj,
Closure<V> closure)
Allow a
GroovyObject to execute a closure against the available
Endpoint s installed on the package associated with the current thread. |
Proxy |
wrap(Object adaptee) |
getMetaClass, setMetaClass
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProperty, setProperty
public static io.toro.martini.ipackage.MartiniPackage getPackage()
public static <V> V withPackageEndpoints(GroovyObject obj, Closure<V> closure)
GroovyObject
to execute a closure against the available
Endpoint
s installed on the package associated with the current thread.V
- the expected typeobj
- the object that requires the endpointsclosure
- the closure to invokeToroRuntimeException
- if there's no package associated with the current thread@Deprecated public static String saveTOROProperty(String key, String value) throws Exception
savePackageProperty(String, String)
.Save an application property.
Application properties are global,
and stored in the core
package's application.properties
file.
Example usage:
'key'.saveTOROProperty('value')
key
- the property keyvalue
- the property valueException
@Deprecated public static void saveTOROPropertyComment(String key, String comment) throws Exception
savePackagePropertyComment(String, String)
.Add a comment to an application property, useful for providing a description of the property.
Application properties are global,
and stored in the core
package's application.properties
file.
Example usage:
'key'.saveTOROPropertyComment('This is a comment describing a property.')
key
- the property keycomment
- the comment to the keyException
@Deprecated public static String getTOROPropertyComment(String key) throws Exception
getPackagePropertyComment(String)
.Get the comment of an application property, useful for understanding the property's purpose.
<Application properties are global,
and stored in the core
package's application.properties
file.
Example usage:
'key'.getTOROPropertyComment()
key
- the property keyException
@Deprecated public static String[] getTOROPropertyArray(String key, String[] defaultValue) throws ToroException
getPackagePropertyArray(String, String[])
.Get the value of an application property as an array. Every comma-separated value in the property is assigned to one array element.
Application properties are global,
and stored in the core
package's application.properties
file.
Example usage:
'key'.getTOROPropertyArray(['default', 'values'])
key
- the property keydefaultValue
- the value to return if the property doesn't existdefaultValue
if the property doesn't existToroException
@Deprecated public static String[] getTOROPropertyArray(String key) throws ToroException
getPackagePropertyArray(String)
.Get the value of an application property as an array. Every comma-separated value in the property is assigned to one array element.
Application properties are global,
and stored in the core
package's application.properties
file.
Example usage:
'key'.getTOROPropertyArray()
key
- the property keynull
if the property doesn't existToroException
@Deprecated public static String getTOROProperty(String key) throws ToroException
getPackageProperty(String)
.Get the value of an application property.
Application properties are global,
and stored in the core
package's application.properties
file.
Example usage:
'key'.getTOROProperty()
key
- the property keynull
if the property doesn't existToroException
@Deprecated public static String getTOROProperty(String key, String defaultValue) throws ToroException
getPackageProperty(String, String)
.Get the value of an application property.
Application properties are global,
and stored in the core
package's application.properties
file.
Example usage:
'key'.getTOROProperty('defaultValue')
key
- the property keydefaultValue
- the value to return if the property doesn't existdefaultValue
if the property doesn't existToroException
@Deprecated public static String removeTOROProperty(String key) throws ToroException
removePackageProperty(String)
.Delete an application property.
Application properties are global,
and stored in the core
package's application.properties
file.
Example usage:
'key'.removeTOROProperty()
key
- the property keyToroException
public static String savePackageProperty(String key, String value) throws Exception
Save a package property.
Package properties are local only to a package.
This one-liner saves the property to the package in the current context;
specifically in the package's package.properties
file.
Example usage:
'key'.saveTOROProperty('value')
key
- the property keyvalue
- the property valueException
public static void savePackagePropertyComment(String key, String comment) throws Exception
Add a comment to a package property, useful for providing a description of the property.
Package properties are local only to a package.
This one-liner saves the property comment to the package in the current context;
specifically in the package's package.properties
file.
'key'.savePackagePropertyComment('This is a comment describing a property.')
key
- the property keycomment
- the comment to the keyException
public static String getPackagePropertyComment(String key) throws Exception
Get the comment of a package property, useful for understanding the property's purpose.
Package properties are local only to a package.
This one-liner fetches the property comment from the package in the current context;
specifically in the package's package.properties
file.
Example usage:
'key'.getPackagePropertyComment()
key
- the property keyException
public static String[] getPackagePropertyArray(String key, String[] defaultValue) throws ToroException
Get the value of a package property as an array. Every comma-separated value in the property is assigned to one array element.
Package properties are local only to a package.
This one-liner fetches the property from the package in the current context;
specifically in the package's package.properties
file.
Example usage:
'key'.getPackagePropertyArray(['default', 'values'])
key
- the property keydefaultValue
- the value to return if the property doesn't existdefaultValue
if the property doesn't existToroException
public static String[] getPackagePropertyArray(String key) throws ToroException
Get the value of a package property as an array. Every comma-separated value in the property is assigned to one array element.
Package properties are local only to a package.
This one-liner fetches the property from the package in the current context;
specifically in the package's package.properties
file.
Example usage:
'key'.getPackagePropertyArray()
key
- the property keynull
if the property doesn't existToroException
public static String getPackageProperty(String key) throws ToroException
Get the value of a package property.
Package properties are local only to a package.
This one-liner fetches the property from the package in the current context;
specifically in the package's package.properties
file.
Example usage:
'key'.getPackageProperty()
key
- the property keynull
if the property doesn't existToroException
public static String getPackageProperty(String key, String defaultValue) throws ToroException
Get the value of a package property.
Package properties are local only to a package.
This one-liner fetches the property from the package in the current context;
specifically in the package's package.properties
file.
Example usage:
'key'.getPackageProperty('defaultValue')
key
- the property keydefaultValue
- the value to return if the property doesn't existdefaultValue
if the property doesn't existToroException
public static String removePackageProperty(String key) throws ToroException
Delete a package property.
Package properties are local only to a package.
This one-liner removes the property from the package in the current context;
specifically in the package's package.properties
file.
'key'.removePackageProperty()
key
- the property keyToroException
public static String getApplicationProperty(String key)
Get the value of an application property.
Application properties are global,
and stored in the core
package's application.properties
file.
Example usage:
'key'.getApplicationProperty()
key
- the property keynull
if the property doesn't existpublic static String getApplicationProperty(String key, String defaultValue)
Get the value of an application property.
Application properties are global,
and stored in the core
package's application.properties
file.
Example usage:
'key'.getApplicationProperty('defaultValue')
key
- the property keydefaultValue
- the value to return if the property doesn't existdefaultValue
if the property doesn't existpublic Object getAdaptee()
getAdaptee
in class Proxy
public void setAdaptee(Object adaptee)
setAdaptee
in class Proxy
public Object invokeMethod(String name, Object args)
invokeMethod
in interface GroovyObject
invokeMethod
in class Proxy
Copyright © 2019. All rights reserved.