public final class GroovyMethods
extends groovy.util.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
,
StringGroovyMethods
,
SwingGroovyMethods
,
XmlGroovyMethods
,
ArrayUtils
,
BooleanUtils
,
DateFormatUtils
,
DateUtils
,
DigestUtils
,
NumberUtils
,
RandomStringUtils
,
StringEscapeUtils
,
StringMethods
Modifier and Type | Class and Description |
---|---|
static class |
GroovyMethods.MartiniPackageSetter
Deprecated.
Use
PackageMethods.MartiniPackageSetter instead |
Constructor and Description |
---|
GroovyMethods() |
GroovyMethods(MartiniPackageProvider martiniPackageProvider,
io.toro.martini.ipackage.MartiniPackageToPackageConverter martiniMartiniPackageToPackageConverterPayload,
List<Object> groovyMethodsClassInstance,
io.toro.properties.ToroProperties systemProperties) |
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 MartiniPackage |
getPackage()
Deprecated.
Moved to
PackageMethods.getPackage() |
static String |
getPackageProperty(String key)
Deprecated.
|
static String |
getPackageProperty(String key,
String defaultValue)
Deprecated.
|
static String[] |
getPackagePropertyArray(String key)
Deprecated.
|
static String[] |
getPackagePropertyArray(String key,
String[] defaultValue)
Deprecated.
|
static String |
getPackagePropertyComment(String key)
Deprecated.
|
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)
Deprecated.
|
static String |
removeTOROProperty(String key)
Deprecated.
This method has been renamed. Please prefer
removePackageProperty(String) . |
static String |
savePackageProperty(String key,
String value)
Deprecated.
|
static void |
savePackagePropertyComment(String key,
String comment)
Deprecated.
|
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(groovy.lang.GroovyObject obj,
groovy.lang.Closure<V> closure)
Allow a
GroovyObject to execute a closure against the available
Endpoint s installed on the package associated with the current thread. |
groovy.util.Proxy |
wrap(Object adaptee) |
GroovyMethods()
GroovyMethods(MartiniPackageProvider martiniPackageProvider, io.toro.martini.ipackage.MartiniPackageToPackageConverter martiniMartiniPackageToPackageConverterPayload, List<Object> groovyMethodsClassInstance, io.toro.properties.ToroProperties systemProperties)
@Deprecated public static MartiniPackage getPackage()
PackageMethods.getPackage()
public static <V> V withPackageEndpoints(groovy.lang.GroovyObject obj, groovy.lang.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)
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 valueIllegalStateException
- if package has not been set@Deprecated public static void saveTOROPropertyComment(String key, String comment)
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 keyIllegalStateException
- if package has not been set@Deprecated public static String getTOROPropertyComment(String key)
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 keyIllegalStateException
- if package has not been set@Deprecated public static String[] getTOROPropertyArray(String key, String[] defaultValue)
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 existIllegalStateException
- if package has not been set@Deprecated public static String[] getTOROPropertyArray(String key)
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 existIllegalStateException
- if package has not been set@Deprecated public static String getTOROProperty(String key)
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 existIllegalStateException
- if package has not been set@Deprecated public static String getTOROProperty(String key, String defaultValue)
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 existIllegalStateException
- if package has not been set@Deprecated public static String removeTOROProperty(String key)
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 keyIllegalStateException
- if package has not been set@Deprecated public static String savePackageProperty(String key, String value)
PackageMethods.savePackageProperty(String, String)
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 valueIllegalStateException
- if package has not been set@Deprecated public static void savePackagePropertyComment(String key, String comment)
PackageMethods.savePackagePropertyComment(String, String)
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 keyIllegalStateException
- if package has not been set@Deprecated public static String getPackagePropertyComment(String key)
PackageMethods.getPackagePropertyComment(String)
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 keyIllegalStateException
- if package has not been set@Deprecated public static String[] getPackagePropertyArray(String key, String[] defaultValue)
PackageMethods.getPackagePropertyArray(String, String[])
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 existIllegalStateException
- if package has not been set@Deprecated public static String[] getPackagePropertyArray(String key)
PackageMethods.getPackagePropertyArray(String)
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 existIllegalStateException
- if package has not been set@Deprecated public static String getPackageProperty(String key)
PackageMethods.getPackageProperty(String)
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 existIllegalStateException
- if package has not been set@Deprecated public static String getPackageProperty(String key, String defaultValue)
PackageMethods.getPackageProperty(String, String)
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 existIllegalStateException
- if package has not been set@Deprecated public static String removePackageProperty(String key)
PackageMethods.removePackageProperty(String)
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 keyIllegalStateException
- if package has not been setpublic 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 groovy.util.Proxy wrap(Object adaptee)
wrap
in class groovy.util.Proxy
public Object getAdaptee()
getAdaptee
in class groovy.util.Proxy
public void setAdaptee(Object adaptee)
setAdaptee
in class groovy.util.Proxy
public Object invokeMethod(String name, Object args)
invokeMethod
in interface groovy.lang.GroovyObject
invokeMethod
in class groovy.util.Proxy
public Iterator iterator()
iterator
in class groovy.util.Proxy
Copyright © 2020. All rights reserved.