Class GroovyMethods
- java.lang.Object
-
- groovy.lang.GroovyObjectSupport
-
- groovy.util.Proxy
-
- io.toro.martini.GroovyMethods
-
- All Implemented Interfaces:
GroovyObject
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.
- See Also:
JmsMethods
,CoreMethods
,CsvMethods
,HttpClientMethods
,JabberMethods
,JmsMethods
,LoggerMethods
,MarshallerMethods
,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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GroovyMethods.MartiniPackageSetter
Deprecated.UsePackageMethods.MartiniPackageSetter
instead
-
Constructor Summary
Constructors Constructor Description GroovyMethods()
GroovyMethods(MartiniPackageProvider martiniPackageProvider, io.toro.martini.ipackage.MartiniPackageToPackageConverter martiniMartiniPackageToPackageConverterPayload, List<Object> groovyMethodsClassInstance, io.toro.properties.ToroProperties applicationProperties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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 toPackageMethods.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.static String
getTOROProperty(String key, String defaultValue)
Deprecated.This method has been renamed.static String[]
getTOROPropertyArray(String key)
Deprecated.This method has been renamed.static String[]
getTOROPropertyArray(String key, String[] defaultValue)
Deprecated.This method has been renamed.static String
getTOROPropertyComment(String key)
Deprecated.This method has been renamed.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.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.static void
saveTOROPropertyComment(String key, String comment)
Deprecated.This method has been renamed.void
setAdaptee(Object adaptee)
static <V> V
withPackageEndpoints(GroovyObject obj, Closure<V> closure)
Allow aGroovyObject
to execute a closure against the availableEndpoint
s installed on the package associated with the current thread.Proxy
wrap(Object adaptee)
-
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, setMetaClass
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface groovy.lang.GroovyObject
getProperty, setProperty
-
-
-
-
Constructor Detail
-
GroovyMethods
GroovyMethods()
-
GroovyMethods
GroovyMethods(MartiniPackageProvider martiniPackageProvider, io.toro.martini.ipackage.MartiniPackageToPackageConverter martiniMartiniPackageToPackageConverterPayload, List<Object> groovyMethodsClassInstance, io.toro.properties.ToroProperties applicationProperties)
-
-
Method Detail
-
getPackage
@Deprecated public static MartiniPackage getPackage()
Deprecated.Moved toPackageMethods.getPackage()
Get the package assigned to the current context.- Returns:
- the current context's package
-
withPackageEndpoints
public static <V> V withPackageEndpoints(GroovyObject obj, Closure<V> closure)
Allow aGroovyObject
to execute a closure against the availableEndpoint
s installed on the package associated with the current thread.- Type Parameters:
V
- the expected type- Parameters:
obj
- the object that requires the endpointsclosure
- the closure to invoke- Returns:
- the actual result after invoking the closure against the collection of endpoints
- Throws:
ToroRuntimeException
- if there's no package associated with the current thread
-
saveTOROProperty
@Deprecated public static String saveTOROProperty(String key, String value)
Deprecated.This method has been renamed. Please prefersavePackageProperty(String, String)
.Save an application property.
Application properties are global, and stored in the
core
package'sapplication.properties
file.Example usage:
'key'.saveTOROProperty('value')
- Parameters:
key
- the property keyvalue
- the property value- Returns:
- the saved property value
- Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
saveTOROPropertyComment
@Deprecated public static void saveTOROPropertyComment(String key, String comment)
Deprecated.This method has been renamed. Please prefersavePackagePropertyComment(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'sapplication.properties
file.Example usage:
'key'.saveTOROPropertyComment('This is a comment describing a property.')
- Parameters:
key
- the property keycomment
- the comment to the key- Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getTOROPropertyComment
@Deprecated public static String getTOROPropertyComment(String key)
Deprecated.This method has been renamed. Please prefergetPackagePropertyComment(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'sapplication.properties
file.Example usage:
'key'.getTOROPropertyComment()
- Parameters:
key
- the property key- Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getTOROPropertyArray
@Deprecated public static String[] getTOROPropertyArray(String key, String[] defaultValue)
Deprecated.This method has been renamed. Please prefergetPackagePropertyArray(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'sapplication.properties
file.Example usage:
'key'.getTOROPropertyArray(['default', 'values'])
- Parameters:
key
- the property keydefaultValue
- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValue
if the property doesn't exist - Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getTOROPropertyArray
@Deprecated public static String[] getTOROPropertyArray(String key)
Deprecated.This method has been renamed. Please prefergetPackagePropertyArray(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'sapplication.properties
file.Example usage:
'key'.getTOROPropertyArray()
- Parameters:
key
- the property key- Returns:
- the property value, or
null
if the property doesn't exist - Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getTOROProperty
@Deprecated public static String getTOROProperty(String key)
Deprecated.This method has been renamed. Please prefergetPackageProperty(String)
.Get the value of an application property.
Application properties are global, and stored in the
core
package'sapplication.properties
file.Example usage:
'key'.getTOROProperty()
- Parameters:
key
- the property key- Returns:
- the property value, or
null
if the property doesn't exist - Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getTOROProperty
@Deprecated public static String getTOROProperty(String key, String defaultValue)
Deprecated.This method has been renamed. Please prefergetPackageProperty(String, String)
.Get the value of an application property.
Application properties are global, and stored in the
core
package'sapplication.properties
file.Example usage:
'key'.getTOROProperty('defaultValue')
- Parameters:
key
- the property keydefaultValue
- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValue
if the property doesn't exist - Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
removeTOROProperty
@Deprecated public static String removeTOROProperty(String key)
Deprecated.This method has been renamed. Please preferremovePackageProperty(String)
.Delete an application property.
Application properties are global, and stored in the
core
package'sapplication.properties
file.Example usage:
'key'.removeTOROProperty()
- Parameters:
key
- the property key- Returns:
- the property's assigned value
- Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
savePackageProperty
@Deprecated public static String savePackageProperty(String key, String value)
Deprecated.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')
- Parameters:
key
- the property keyvalue
- the property value- Returns:
- the property's assigned value
- Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
savePackagePropertyComment
@Deprecated public static void savePackagePropertyComment(String key, String comment)
Deprecated.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
Example usage:package.properties
file.'key'.savePackagePropertyComment('This is a comment describing a property.')
- Parameters:
key
- the property keycomment
- the comment to the key- Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getPackagePropertyComment
@Deprecated public static String getPackagePropertyComment(String key)
Deprecated.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()
- Parameters:
key
- the property key- Returns:
- package property comment
- Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getPackagePropertyArray
@Deprecated public static String[] getPackagePropertyArray(String key, String[] defaultValue)
Deprecated.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'])
- Parameters:
key
- the property keydefaultValue
- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValue
if the property doesn't exist - Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getPackagePropertyArray
@Deprecated public static String[] getPackagePropertyArray(String key)
Deprecated.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()
- Parameters:
key
- the property key- Returns:
- the property value, or
null
if the property doesn't exist - Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getPackageProperty
@Deprecated public static String getPackageProperty(String key)
Deprecated.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()
- Parameters:
key
- the property key- Returns:
- the property value, or
null
if the property doesn't exist - Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getPackageProperty
@Deprecated public static String getPackageProperty(String key, String defaultValue)
Deprecated.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')
- Parameters:
key
- the property keydefaultValue
- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValue
if the property doesn't exist - Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
removePackageProperty
@Deprecated public static String removePackageProperty(String key)
Deprecated.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
Example usage:package.properties
file.'key'.removePackageProperty()
- Parameters:
key
- the property key- Returns:
- the property's assigned value
- Throws:
IllegalStateException
- if package has not been set- Since:
- 1.0
-
getApplicationProperty
public static String getApplicationProperty(String key)
Get the value of an application property.
Application properties are global, and stored in the
core
package'sapplication.properties
file.Example usage:
'key'.getApplicationProperty()
- Parameters:
key
- the property key- Returns:
- the property value, or
null
if the property doesn't exist - Since:
- 1.0
-
getApplicationProperty
public static String getApplicationProperty(String key, String defaultValue)
Get the value of an application property.
Application properties are global, and stored in the
core
package'sapplication.properties
file.Example usage:
'key'.getApplicationProperty('defaultValue')
- Parameters:
key
- the property keydefaultValue
- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValue
if the property doesn't exist - Since:
- 1.0
-
getAdaptee
public Object getAdaptee()
- Overrides:
getAdaptee
in classProxy
-
setAdaptee
public void setAdaptee(Object adaptee)
- Overrides:
setAdaptee
in classProxy
-
invokeMethod
public Object invokeMethod(String name, Object args)
- Specified by:
invokeMethod
in interfaceGroovyObject
- Overrides:
invokeMethod
in classProxy
-
-