public class GroovyJaxrsPublisher extends Object
ResourceBinder Groovy based RESTful services.| Modifier and Type | Field and Description |
|---|---|
protected ResourceBinder |
binder |
protected GroovyClassLoaderProvider |
classLoaderProvider |
protected static Charset |
DEFAULT_CHARSET
Default character set.
|
protected static String |
DEFAULT_CHARSET_NAME
Default character set name.
|
protected org.exoplatform.services.script.groovy.GroovyScriptInstantiator |
instantiator |
protected Map<ResourceId,String> |
resources |
| Constructor and Description |
|---|
GroovyJaxrsPublisher(ResourceBinder binder,
org.exoplatform.services.script.groovy.GroovyScriptInstantiator instantiator)
Create GroovyJaxrsPublisher which is able publish per-request and
singleton resources.
|
GroovyJaxrsPublisher(ResourceBinder binder,
org.exoplatform.services.script.groovy.GroovyScriptInstantiator instantiator,
GroovyClassLoaderProvider classLoaderProvider) |
| Modifier and Type | Method and Description |
|---|---|
protected groovy.lang.GroovyCodeSource |
createCodeSource(URL url)
Create
GroovyCodeSource from given location (URL). |
protected Object |
createInstance(Class clazz) |
groovy.lang.GroovyClassLoader |
getGroovyClassLoader()
Deprecated.
|
ObjectFactory<AbstractResourceDescriptor> |
getResource(ResourceId resourceId)
Get resource corresponded to specified id
resourceId . |
boolean |
isPublished(ResourceId resourceId)
Check is groovy resource with specified id is published or not
|
void |
publishPerRequest(InputStream in,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties)
Parse given stream and publish result as per-request RESTful service.
|
void |
publishPerRequest(InputStream in,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties,
SourceFolder[] src,
SourceFile[] files)
Parse given stream and publish result as per-request RESTful service.
|
void |
publishPerRequest(String source,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties)
Parse given
source and publish result as per-request RESTful
service. |
void |
publishPerRequest(String source,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties,
SourceFolder[] src,
SourceFile[] files)
Parse given
source and publish result as per-request RESTful
service. |
void |
publishPerRequest(String source,
String charset,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties)
Parse given
source and publish result as per-request RESTful
service. |
void |
publishPerRequest(String source,
String charset,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties,
SourceFolder[] src,
SourceFile[] files)
Parse given
source and publish result as per-request RESTful
service. |
void |
publishSingleton(InputStream in,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties)
Parse given stream and publish result as singleton RESTful service.
|
void |
publishSingleton(InputStream in,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties,
SourceFolder[] src,
SourceFile[] files)
Parse given stream and publish result as singleton RESTful service.
|
void |
publishSingleton(String source,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties)
Parse given
source and publish result as singleton RESTful
service. |
void |
publishSingleton(String source,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties,
SourceFolder[] src,
SourceFile[] files)
Parse given
source and publish result as singleton RESTful
service. |
void |
publishSingleton(String source,
String charset,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties)
Parse given
source and publish result as singleton RESTful
service. |
void |
publishSingleton(String source,
String charset,
ResourceId resourceId,
javax.ws.rs.core.MultivaluedMap<String,String> properties,
SourceFolder[] src,
SourceFile[] files)
Parse given
source and publish result as singleton RESTful
service. |
void |
setGroovyClassLoader(groovy.lang.GroovyClassLoader gcl)
Deprecated.
|
ObjectFactory<AbstractResourceDescriptor> |
unpublishResource(ResourceId resourceId)
Unpublish resource with specified id.
|
void |
validateResource(InputStream in,
String name)
Validate does stream contain Groovy source code which is conforms with
requirement to JAX-RS resource.
|
void |
validateResource(InputStream in,
String name,
SourceFolder[] src,
SourceFile[] files)
Validate does stream contain Groovy source code which is conforms with
requirement to JAX-RS resource.
|
void |
validateResource(String source,
String name)
Validate does
source contain Groovy source code which is
conforms with requirement to JAX-RS resource. |
void |
validateResource(String source,
String name,
SourceFolder[] src,
SourceFile[] files)
Validate does
source contain Groovy source code which is
conforms with requirement to JAX-RS resource. |
void |
validateResource(String source,
String charset,
String name,
SourceFolder[] src,
SourceFile[] files)
Validate does
source contain Groovy source code which is
conforms with requirement to JAX-RS resource. |
protected static final String DEFAULT_CHARSET_NAME
protected static final Charset DEFAULT_CHARSET
protected final ResourceBinder binder
protected final org.exoplatform.services.script.groovy.GroovyScriptInstantiator instantiator
protected final GroovyClassLoaderProvider classLoaderProvider
protected final Map<ResourceId,String> resources
public GroovyJaxrsPublisher(ResourceBinder binder, org.exoplatform.services.script.groovy.GroovyScriptInstantiator instantiator, GroovyClassLoaderProvider classLoaderProvider)
public GroovyJaxrsPublisher(ResourceBinder binder, org.exoplatform.services.script.groovy.GroovyScriptInstantiator instantiator)
PerRequestObjectFactory, instance of singleton
resources will be created by GroovyScriptInstantiator.binder - resource binderinstantiator - instantiate java object from given groovy source@Deprecated public groovy.lang.GroovyClassLoader getGroovyClassLoader()
@Deprecated public void setGroovyClassLoader(groovy.lang.GroovyClassLoader gcl)
gcl - groovy class loaderNullPointerException - if gcl == nullpublic ObjectFactory<AbstractResourceDescriptor> getResource(ResourceId resourceId)
resourceId .resourceId - resource idnullpublic boolean isPublished(ResourceId resourceId)
resourceId - id of resource to be checkedtrue if resource is published and false
otherwisepublic void publishPerRequest(InputStream in, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties)
in - stream which contains groovy source code of RESTful serviceresourceId - id to be assigned to resourceproperties - optional resource properties. This parameter may be
nullNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic void publishPerRequest(InputStream in, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties, SourceFolder[] src, SourceFile[] files)
in - stream which contains Groovy source code of RESTful serviceresourceId - id to be assigned to resourceproperties - optional resource properties. This parameter may be
nullsrc - additional path to Groovy sourcesfiles - Groovy source files to be added in build path directlyNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic final void publishPerRequest(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties)
source and publish result as per-request RESTful
service.source - groovy source code of RESTful serviceresourceId - id to be assigned to resourceproperties - optional resource properties. This parameter may be
nullNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic final void publishPerRequest(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties, SourceFolder[] src, SourceFile[] files)
source and publish result as per-request RESTful
service.source - groovy source code of RESTful serviceresourceId - id to be assigned to resourceproperties - optional resource properties. This parameter may be
nullsrc - additional path to Groovy sourcesfiles - Groovy source files to be added in build path directlyNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic final void publishPerRequest(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties)
source and publish result as per-request RESTful
service.source - groovy source code of RESTful servicecharset - source string charset. May be null than
default charset will be in useresourceId - id to be assigned to resourceproperties - optional resource properties. This parameter may be
null.UnsupportedCharsetException - if charset is unsupportedNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic final void publishPerRequest(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties, SourceFolder[] src, SourceFile[] files)
source and publish result as per-request RESTful
service.source - groovy source code of RESTful servicecharset - source string charset. May be null than
default charset will be in useresourceId - id to be assigned to resourceproperties - optional resource properties. This parameter may be
null.src - additional path to Groovy sourcesfiles - Groovy source files to be added in build path directlyUnsupportedCharsetException - if charset is unsupportedNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic void publishSingleton(InputStream in, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties)
in - stream which contains groovy source code of RESTful serviceresourceId - id to be assigned to resourceproperties - optional resource properties. This parameter may be
nullNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic void publishSingleton(InputStream in, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties, SourceFolder[] src, SourceFile[] files)
in - stream which contains groovy source code of RESTful serviceresourceId - id to be assigned to resourceproperties - optional resource properties. This parameter may be
nullsrc - additional path to Groovy sourcesfiles - Groovy source files to be added in build path directlyNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic final void publishSingleton(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties)
source and publish result as singleton RESTful
service.source - groovy source code of RESTful serviceresourceId - name of resourceproperties - optional resource properties. This parameter may be
null.NullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic final void publishSingleton(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties, SourceFolder[] src, SourceFile[] files)
source and publish result as singleton RESTful
service.source - groovy source code of RESTful serviceresourceId - name of resourceproperties - optional resource properties. This parameter may be
null.src - additional path to Groovy sourcesfiles - Groovy source files to be added in build path directlyNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic final void publishSingleton(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties)
source and publish result as singleton RESTful
service.source - groovy source code of RESTful servicecharset - source string charset. May be null than
default charset will be in useresourceId - name of resourceproperties - optional resource properties. This parameter may be
null.UnsupportedCharsetException - if charset is unsupportedNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic final void publishSingleton(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String,String> properties, SourceFolder[] src, SourceFile[] files)
source and publish result as singleton RESTful
service.source - groovy source code of RESTful servicecharset - source string charset. May be null than
default charset will be in useresourceId - name of resourceproperties - optional resource properties. This parameter may be
null.src - additional path to Groovy sourcesfiles - Groovy source files to be added in build path directlyUnsupportedCharsetException - if charset is unsupportedNullPointerException - if resourceId == nullResourcePublicationException - see
ResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException - if compilation fails from source errorspublic ObjectFactory<AbstractResourceDescriptor> unpublishResource(ResourceId resourceId)
resourceId - id of resource to be unpublishedtrue if resource was published and false
otherwise, e.g. because there is not resource corresponded to
supplied resourceIdpublic void validateResource(InputStream in, String name, SourceFolder[] src, SourceFile[] files) throws MalformedScriptException
in - Groovy source streamname - script name. This name will be used by GroovyClassLoader to
identify script, e.g. specified name will be used in error
message in compilation of Groovy fails. If this parameter is
null then GroovyClassLoader will use automatically
generated namesrc - additional path to Groovy sourcesfiles - Groovy source files to be added in build path directlyMalformedScriptException - if source has errors or there is no
required JAX-RS annotationpublic void validateResource(InputStream in, String name) throws MalformedScriptException
in - Groovy source streamname - script name. This name will be used by GroovyClassLoader to
identify script, e.g. specified name will be used in error
message in compilation of Groovy fails. If this parameter is
null then GroovyClassLoader will use automatically
generated nameMalformedScriptException - if source has errors or there is no
required JAX-RS annotationpublic final void validateResource(String source, String charset, String name, SourceFolder[] src, SourceFile[] files) throws MalformedScriptException
source contain Groovy source code which is
conforms with requirement to JAX-RS resource.source - Groovy source code as Stringcharset - source string charset. May be null than
default charset will be in usename - script name. This name will be used by GroovyClassLoader to
identify script, e.g. specified name will be used in error
message in compilation of Groovy fails. If this parameter is
null then GroovyClassLoader will use automatically
generated namesrc - additional path to Groovy sourcesfiles - Groovy source files to be added in build path directlyMalformedScriptException - if source has errors or there is no
required JAX-RS annotationpublic final void validateResource(String source, String name, SourceFolder[] src, SourceFile[] files) throws MalformedScriptException
source contain Groovy source code which is
conforms with requirement to JAX-RS resource.source - Groovy source code as Stringname - script name. This name will be used by GroovyClassLoader to
identify script, e.g. specified name will be used in error
message in compilation of Groovy fails. If this parameter is
null then GroovyClassLoader will use automatically
generated namesrc - additional path to Groovy sourcesfiles - Groovy source files to be added in build path directlyMalformedScriptException - if source has errors or there is no
required JAX-RS annotationpublic final void validateResource(String source, String name) throws MalformedScriptException
source contain Groovy source code which is
conforms with requirement to JAX-RS resource.source - Groovy source code as Stringname - script name. This name will be used by GroovyClassLoader to
identify script, e.g. specified name will be used in error
message in compilation of Groovy fails. If this parameter is
null then GroovyClassLoader will use automatically
generated nameMalformedScriptException - if source has errors or there is no
required JAX-RS annotationprotected Object createInstance(Class clazz) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
protected groovy.lang.GroovyCodeSource createCodeSource(URL url) throws IOException
GroovyCodeSource from given location (URL).url - groovy source urlIOExceptionCopyright © 2020 eXo Platform SAS. All Rights Reserved.