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,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 classGroovyMethods.MartiniPackageSetterDeprecated.UsePackageMethods.MartiniPackageSetterinstead
-
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 ObjectgetAdaptee()static StringgetApplicationProperty(String key)Get the value of an application property.static StringgetApplicationProperty(String key, String defaultValue)Get the value of an application property.static MartiniPackagegetPackage()Deprecated.Moved toPackageMethods.getPackage()static StringgetPackageProperty(String key)Deprecated.static StringgetPackageProperty(String key, String defaultValue)Deprecated.static String[]getPackagePropertyArray(String key)Deprecated.static String[]getPackagePropertyArray(String key, String[] defaultValue)Deprecated.static StringgetPackagePropertyComment(String key)Deprecated.static StringgetTOROProperty(String key)Deprecated.This method has been renamed.static StringgetTOROProperty(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 StringgetTOROPropertyComment(String key)Deprecated.This method has been renamed.ObjectinvokeMethod(String name, Object args)Iteratoriterator()static StringremovePackageProperty(String key)Deprecated.static StringremoveTOROProperty(String key)Deprecated.This method has been renamed.static StringsavePackageProperty(String key, String value)Deprecated.static voidsavePackagePropertyComment(String key, String comment)Deprecated.static StringsaveTOROProperty(String key, String value)Deprecated.This method has been renamed.static voidsaveTOROPropertyComment(String key, String comment)Deprecated.This method has been renamed.voidsetAdaptee(Object adaptee)static <V> VwithPackageEndpoints(GroovyObject obj, Closure<V> closure)Allow aGroovyObjectto execute a closure against the availableEndpoints installed on the package associated with the current thread.Proxywrap(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 aGroovyObjectto execute a closure against the availableEndpoints 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
corepackage'sapplication.propertiesfile.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
corepackage'sapplication.propertiesfile.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
corepackage'sapplication.propertiesfile.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
corepackage'sapplication.propertiesfile.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
defaultValueif 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
corepackage'sapplication.propertiesfile.Example usage:
'key'.getTOROPropertyArray()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif 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
corepackage'sapplication.propertiesfile.Example usage:
'key'.getTOROProperty()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif 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
corepackage'sapplication.propertiesfile.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
defaultValueif 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
corepackage'sapplication.propertiesfile.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.propertiesfile.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.propertiesfile.'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.propertiesfile.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.propertiesfile.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
defaultValueif 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.propertiesfile.Example usage:
'key'.getPackagePropertyArray()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif 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.propertiesfile.Example usage:
'key'.getPackageProperty()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif 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.propertiesfile.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
defaultValueif 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.propertiesfile.'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
corepackage'sapplication.propertiesfile.Example usage:
'key'.getApplicationProperty()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif 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
corepackage'sapplication.propertiesfile.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
defaultValueif the property doesn't exist - Since:
- 1.0
-
getAdaptee
public Object getAdaptee()
- Overrides:
getAdapteein classProxy
-
setAdaptee
public void setAdaptee(Object adaptee)
- Overrides:
setAdapteein classProxy
-
invokeMethod
public Object invokeMethod(String name, Object args)
- Specified by:
invokeMethodin interfaceGroovyObject- Overrides:
invokeMethodin classProxy
-
-