Class GroovyJaxrsPublisher
java.lang.Object
org.exoplatform.services.rest.ext.groovy.GroovyJaxrsPublisher
- Direct Known Subclasses:
GroovyScript2RestLoader.InnerGroovyJaxrsPublisher
Manage via
ResourceBinder Groovy based RESTful services.- Version:
- $Id$
- Author:
- Andrey Parfonov
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.exoplatform.services.rest.impl.ResourceBinderprotected final GroovyClassLoaderProviderprotected static final CharsetDefault character set.protected static final StringDefault character set name.protected final GroovyScriptInstantiatorprotected final Map<ResourceId, String> -
Constructor Summary
ConstructorsConstructorDescriptionGroovyJaxrsPublisher(org.exoplatform.services.rest.impl.ResourceBinder binder, GroovyScriptInstantiator instantiator) Create GroovyJaxrsPublisher which is able publish per-request and singleton resources.GroovyJaxrsPublisher(org.exoplatform.services.rest.impl.ResourceBinder binder, GroovyScriptInstantiator instantiator, GroovyClassLoaderProvider classLoaderProvider) -
Method Summary
Modifier and TypeMethodDescriptionprotected groovy.lang.GroovyCodeSourcecreateCodeSource(URL url) CreateGroovyCodeSourcefrom given location (URL).protected ObjectcreateInstance(Class clazz) groovy.lang.GroovyClassLoaderDeprecated.org.exoplatform.services.rest.ObjectFactory<org.exoplatform.services.rest.resource.AbstractResourceDescriptor> getResource(ResourceId resourceId) Get resource corresponded to specified idresourceId.booleanisPublished(ResourceId resourceId) Check is groovy resource with specified id is published or notvoidpublishPerRequest(InputStream in, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse given stream and publish result as per-request RESTful service.voidpublishPerRequest(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.final voidpublishPerRequest(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse givensourceand publish result as per-request RESTful service.final voidpublishPerRequest(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties, SourceFolder[] src, SourceFile[] files) Parse givensourceand publish result as per-request RESTful service.final voidpublishPerRequest(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse givensourceand publish result as per-request RESTful service.final voidpublishPerRequest(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties, SourceFolder[] src, SourceFile[] files) Parse givensourceand publish result as per-request RESTful service.voidpublishSingleton(InputStream in, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse given stream and publish result as singleton RESTful service.voidpublishSingleton(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.final voidpublishSingleton(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse givensourceand publish result as singleton RESTful service.final voidpublishSingleton(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties, SourceFolder[] src, SourceFile[] files) Parse givensourceand publish result as singleton RESTful service.final voidpublishSingleton(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse givensourceand publish result as singleton RESTful service.final voidpublishSingleton(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties, SourceFolder[] src, SourceFile[] files) Parse givensourceand publish result as singleton RESTful service.voidsetGroovyClassLoader(groovy.lang.GroovyClassLoader gcl) Deprecated.org.exoplatform.services.rest.ObjectFactory<org.exoplatform.services.rest.resource.AbstractResourceDescriptor> unpublishResource(ResourceId resourceId) Unpublish resource with specified id.voidvalidateResource(InputStream in, String name) Validate does stream contain Groovy source code which is conforms with requirement to JAX-RS resource.voidvalidateResource(InputStream in, String name, SourceFolder[] src, SourceFile[] files) Validate does stream contain Groovy source code which is conforms with requirement to JAX-RS resource.final voidvalidateResource(String source, String name) Validate doessourcecontain Groovy source code which is conforms with requirement to JAX-RS resource.final voidvalidateResource(String source, String charset, String name, SourceFolder[] src, SourceFile[] files) Validate doessourcecontain Groovy source code which is conforms with requirement to JAX-RS resource.final voidvalidateResource(String source, String name, SourceFolder[] src, SourceFile[] files) Validate doessourcecontain Groovy source code which is conforms with requirement to JAX-RS resource.
-
Field Details
-
DEFAULT_CHARSET_NAME
Default character set name.- See Also:
-
DEFAULT_CHARSET
Default character set. -
binder
protected final org.exoplatform.services.rest.impl.ResourceBinder binder -
instantiator
-
classLoaderProvider
-
resources
-
-
Constructor Details
-
GroovyJaxrsPublisher
public GroovyJaxrsPublisher(org.exoplatform.services.rest.impl.ResourceBinder binder, GroovyScriptInstantiator instantiator, GroovyClassLoaderProvider classLoaderProvider) -
GroovyJaxrsPublisher
public GroovyJaxrsPublisher(org.exoplatform.services.rest.impl.ResourceBinder binder, GroovyScriptInstantiator instantiator) Create GroovyJaxrsPublisher which is able publish per-request and singleton resources. Any required dependencies for per-request resource injected byPerRequestObjectFactory, instance of singleton resources will be created byGroovyScriptInstantiator.- Parameters:
binder- resource binderinstantiator- instantiate java object from given groovy source
-
-
Method Details
-
getGroovyClassLoader
Deprecated.- Returns:
- get underling groovy class loader
-
setGroovyClassLoader
Deprecated.Set groovy class loader.- Parameters:
gcl- groovy class loader- Throws:
NullPointerException- ifgcl == null
-
getResource
public org.exoplatform.services.rest.ObjectFactory<org.exoplatform.services.rest.resource.AbstractResourceDescriptor> getResource(ResourceId resourceId) Get resource corresponded to specified idresourceId.- Parameters:
resourceId- resource id- Returns:
- resource or
null
-
isPublished
Check is groovy resource with specified id is published or not- Parameters:
resourceId- id of resource to be checked- Returns:
trueif resource is published andfalseotherwise
-
publishPerRequest
public 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.- Parameters:
in- stream which contains groovy source code of RESTful serviceresourceId- id to be assigned to resourceproperties- optional resource properties. This parameter may benull- Throws:
NullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishPerRequest
public 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.- Parameters:
in- stream which contains Groovy source code of RESTful serviceresourceId- id to be assigned to resourceproperties- optional resource properties. This parameter may benullsrc- additional path to Groovy sourcesfiles- Groovy source files to be added in build path directly- Throws:
NullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishPerRequest
public final void publishPerRequest(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse givensourceand publish result as per-request RESTful service.- Parameters:
source- groovy source code of RESTful serviceresourceId- id to be assigned to resourceproperties- optional resource properties. This parameter may benull- Throws:
NullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishPerRequest
public final void publishPerRequest(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties, SourceFolder[] src, SourceFile[] files) Parse givensourceand publish result as per-request RESTful service.- Parameters:
source- groovy source code of RESTful serviceresourceId- id to be assigned to resourceproperties- optional resource properties. This parameter may benullsrc- additional path to Groovy sourcesfiles- Groovy source files to be added in build path directly- Throws:
NullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishPerRequest
public final void publishPerRequest(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse givensourceand publish result as per-request RESTful service.- Parameters:
source- groovy source code of RESTful servicecharset- source string charset. May benullthan default charset will be in useresourceId- id to be assigned to resourceproperties- optional resource properties. This parameter may benull.- Throws:
UnsupportedCharsetException- ifcharsetis unsupportedNullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishPerRequest
public final void publishPerRequest(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties, SourceFolder[] src, SourceFile[] files) Parse givensourceand publish result as per-request RESTful service.- Parameters:
source- groovy source code of RESTful servicecharset- source string charset. May benullthan default charset will be in useresourceId- id to be assigned to resourceproperties- optional resource properties. This parameter may benull.src- additional path to Groovy sourcesfiles- Groovy source files to be added in build path directly- Throws:
UnsupportedCharsetException- ifcharsetis unsupportedNullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Class, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishSingleton
public void publishSingleton(InputStream in, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse given stream and publish result as singleton RESTful service.- Parameters:
in- stream which contains groovy source code of RESTful serviceresourceId- id to be assigned to resourceproperties- optional resource properties. This parameter may benull- Throws:
NullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishSingleton
public 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.- Parameters:
in- stream which contains groovy source code of RESTful serviceresourceId- id to be assigned to resourceproperties- optional resource properties. This parameter may benullsrc- additional path to Groovy sourcesfiles- Groovy source files to be added in build path directly- Throws:
NullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishSingleton
public final void publishSingleton(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse givensourceand publish result as singleton RESTful service.- Parameters:
source- groovy source code of RESTful serviceresourceId- name of resourceproperties- optional resource properties. This parameter may benull.- Throws:
NullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishSingleton
public final void publishSingleton(String source, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties, SourceFolder[] src, SourceFile[] files) Parse givensourceand publish result as singleton RESTful service.- Parameters:
source- groovy source code of RESTful serviceresourceId- name of resourceproperties- optional resource properties. This parameter may benull.src- additional path to Groovy sourcesfiles- Groovy source files to be added in build path directly- Throws:
NullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishSingleton
public final void publishSingleton(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties) Parse givensourceand publish result as singleton RESTful service.- Parameters:
source- groovy source code of RESTful servicecharset- source string charset. May benullthan default charset will be in useresourceId- name of resourceproperties- optional resource properties. This parameter may benull.- Throws:
UnsupportedCharsetException- ifcharsetis unsupportedNullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
publishSingleton
public final void publishSingleton(String source, String charset, ResourceId resourceId, javax.ws.rs.core.MultivaluedMap<String, String> properties, SourceFolder[] src, SourceFile[] files) Parse givensourceand publish result as singleton RESTful service.- Parameters:
source- groovy source code of RESTful servicecharset- source string charset. May benullthan default charset will be in useresourceId- name of resourceproperties- optional resource properties. This parameter may benull.src- additional path to Groovy sourcesfiles- Groovy source files to be added in build path directly- Throws:
UnsupportedCharsetException- ifcharsetis unsupportedNullPointerException- ifresourceId == nullorg.exoplatform.services.rest.impl.ResourcePublicationException- seeResourceBinder.addResource(Object, MultivaluedMap)org.codehaus.groovy.control.CompilationFailedException- if compilation fails from source errors
-
unpublishResource
public org.exoplatform.services.rest.ObjectFactory<org.exoplatform.services.rest.resource.AbstractResourceDescriptor> unpublishResource(ResourceId resourceId) Unpublish resource with specified id.- Parameters:
resourceId- id of resource to be unpublished- Returns:
trueif resource was published andfalseotherwise, e.g. because there is not resource corresponded to suppliedresourceId
-
validateResource
public void validateResource(InputStream in, String name, SourceFolder[] src, SourceFile[] files) throws MalformedScriptException Validate does stream contain Groovy source code which is conforms with requirement to JAX-RS resource.- Parameters:
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 isnullthen GroovyClassLoader will use automatically generated namesrc- additional path to Groovy sourcesfiles- Groovy source files to be added in build path directly- Throws:
MalformedScriptException- if source has errors or there is no required JAX-RS annotation
-
validateResource
Validate does stream contain Groovy source code which is conforms with requirement to JAX-RS resource.- Parameters:
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 isnullthen GroovyClassLoader will use automatically generated name- Throws:
MalformedScriptException- if source has errors or there is no required JAX-RS annotation
-
validateResource
public final void validateResource(String source, String charset, String name, SourceFolder[] src, SourceFile[] files) throws MalformedScriptException Validate doessourcecontain Groovy source code which is conforms with requirement to JAX-RS resource.- Parameters:
source- Groovy source code as Stringcharset- source string charset. May benullthan 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 isnullthen GroovyClassLoader will use automatically generated namesrc- additional path to Groovy sourcesfiles- Groovy source files to be added in build path directly- Throws:
MalformedScriptException- if source has errors or there is no required JAX-RS annotation
-
validateResource
public final void validateResource(String source, String name, SourceFolder[] src, SourceFile[] files) throws MalformedScriptException Validate doessourcecontain Groovy source code which is conforms with requirement to JAX-RS resource.- Parameters:
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 isnullthen GroovyClassLoader will use automatically generated namesrc- additional path to Groovy sourcesfiles- Groovy source files to be added in build path directly- Throws:
MalformedScriptException- if source has errors or there is no required JAX-RS annotation
-
validateResource
Validate doessourcecontain Groovy source code which is conforms with requirement to JAX-RS resource.- Parameters:
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 isnullthen GroovyClassLoader will use automatically generated name- Throws:
MalformedScriptException- if source has errors or there is no required JAX-RS annotation
-
createInstance
protected Object createInstance(Class clazz) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException -
createCodeSource
CreateGroovyCodeSourcefrom given location (URL).- Parameters:
url- groovy source url- Returns:
- GroovyCodeSource
- Throws:
IOException
-