org.restlet.ext.jaxrs
Class JaxRsApplication

java.lang.Object
  extended by org.restlet.Uniform
      extended by org.restlet.Restlet
          extended by org.restlet.Application
              extended by org.restlet.ext.jaxrs.JaxRsApplication

public class JaxRsApplication
extends Application

This is the main class to be used for the instantiation of a JAX-RS runtime environment.

To set up a JAX-RS runtime environment you should instantiate a JaxRsApplication(Context).

At least add the JaxRsApplication to a Component.

Concurrency note: instances of this class or its subclasses can be invoked by several threads at the same time and therefore must be thread-safe. You should be especially careful when storing state in member variables.

Author:
Stephan Koops

Constructor Summary
JaxRsApplication()
          Creates an new JaxRsApplication.
JaxRsApplication(Context context)
          Creates an new JaxRsApplication, without any access control.
 
Method Summary
 boolean add(javax.ws.rs.core.Application appConfig)
           Attaches a JAX-RS Application to this JaxRsApplication.
The providers are available for all root resource classes provided to this JaxRsApplication.
 boolean add(javax.ws.rs.core.Application appConfig, boolean clearMetadataIfFirst)
          Attaches a JAX-RS Application to this Application.
The providers are available for all root resource classes provided to this JaxRsApplication.
 Restlet createRoot()
           
 Guard getGuard()
          Returns the Guard
 ObjectFactory getObjectFactory()
          Returns the ObjectFactory for root resource class and provider instantiation, if given.
 RoleChecker getRoleChecker()
          Returns the current RoleChecker
 java.util.Collection<java.lang.Class<?>> getRootResources()
          Returns an unmodifiable set with the attached root resource classes.
 java.util.Collection<java.lang.String> getRootUris()
          Returns an unmodifiable set of supported URIs (relative to this Application).
 void setAuthentication(Guard guard, RoleChecker roleChecker)
          Sets the objects to check the authentication.
 void setContext(Context context)
           
 void setGuard(Guard guard)
          Sets the Guard to use.
 void setObjectFactory(ObjectFactory objectFactory)
          Sets the ObjectFactory for root resource class and provider instantiation.
 void setRoleChecker(RoleChecker roleChecker)
          Sets the RoleChecker to use.
If you give an RoleChecker, you should also give a Guard.
 
Methods inherited from class org.restlet.Application
getAuthor, getConnectorService, getConverterService, getCurrent, getDecoderService, getDescription, getMetadataService, getName, getOwner, getRangeService, getRoot, getStatusService, getTaskService, getTunnelService, handle, setAuthor, setConnectorService, setConverterService, setCurrent, setDecoderService, setDescription, setMetadataService, setName, setOwner, setRangeService, setRoot, setStatusService, setTaskService, setTunnelService, start, stop
 
Methods inherited from class org.restlet.Restlet
getApplication, getContext, getLogger, init, isStarted, isStopped
 
Methods inherited from class org.restlet.Uniform
delete, delete, get, get, handle, head, head, options, options, post, post, put, put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaxRsApplication

public JaxRsApplication()
Creates an new JaxRsApplication.

See Also:
JaxRsApplication(Context)

JaxRsApplication

public JaxRsApplication(Context context)
Creates an new JaxRsApplication, without any access control. Attach JAX-RS-Applications by using add(Application).
If a method calls SecurityContext.isUserInRole(String), status 500 is returned to the client, see RoleChecker.REJECT_WITH_ERROR. Use setGuard(Guard) and setRoleChecker(RoleChecker) or setAuthentication(Guard, RoleChecker), to set access control.

Parameters:
context - The application's dedicated context based on the protected parent component's context.
Method Detail

add

public boolean add(javax.ws.rs.core.Application appConfig)
            throws java.lang.IllegalArgumentException

Attaches a JAX-RS Application to this JaxRsApplication.
The providers are available for all root resource classes provided to this JaxRsApplication. If you won't mix them, instantiate another JaxRsApplication.

If the given JAX-RS Application is the first attached Application, the default extension mappings are remove and replaced by the given, see TunnelService.

Parameters:
appConfig - Contains the classes to load as root resource classes and as providers. Invalid root resource classes and provider classes are ignored, according to JAX-RS specification.
The JAX-RS class javax.ws.rs.ApplicationConfig will be renamed to javax.ws.rs.Application in the next JAX-RS release.
Returns:
true, if all resource classes and providers could be added, or false if not.
Throws:
java.lang.IllegalArgumentException - if the appConfig is null.
See Also:
add(Application, boolean)

add

public boolean add(javax.ws.rs.core.Application appConfig,
                   boolean clearMetadataIfFirst)
            throws java.lang.IllegalArgumentException
Attaches a JAX-RS Application to this Application.
The providers are available for all root resource classes provided to this JaxRsApplication. If you won't mix them, instantiate another JaxRsApplication.

Parameters:
appConfig - Contains the classes to load as root resource classes and as providers. Invalid root resource classes and provider classes are ignored, according to JAX-RS specification.
The JAX-RS class javax.ws.rs.ApplicationConfig will be renamed to javax.ws.rs.Application in the next JAX-RS release.
clearMetadataIfFirst - If this flag is true and the given ApplicationConfig is the first attached ApplicationConfig, the default extension mappings are remove an replaced by the given, see TunnelService
Returns:
true, if all resource classes and providers could be added, or false if not.
Throws:
java.lang.IllegalArgumentException - if the appConfig is null.
See Also:
add(Application)

createRoot

public Restlet createRoot()
Overrides:
createRoot in class Application

getGuard

public Guard getGuard()
Returns the Guard

Returns:
the Guard

getObjectFactory

public ObjectFactory getObjectFactory()
Returns the ObjectFactory for root resource class and provider instantiation, if given.

Returns:
the ObjectFactory for root resource class and provider instantiation, if given.

getRoleChecker

public RoleChecker getRoleChecker()
Returns the current RoleChecker

Returns:
the current RoleChecker

getRootResources

public java.util.Collection<java.lang.Class<?>> getRootResources()
Returns an unmodifiable set with the attached root resource classes.

Returns:
an unmodifiable set with the attached root resource classes.

getRootUris

public java.util.Collection<java.lang.String> getRootUris()
Returns an unmodifiable set of supported URIs (relative to this Application).

Returns:
an unmodifiable set of supported URIs (relative).

setAuthentication

public void setAuthentication(Guard guard,
                              RoleChecker roleChecker)
Sets the objects to check the authentication. The Guard checks the username and password (e.g.), the RoleChecker manages the role management for the JAX-RS extension.

Parameters:
guard - the Guard to use.
roleChecker - the RoleChecker to use
See Also:
setGuard(Guard), setRoleChecker(RoleChecker)

setContext

public void setContext(Context context)
Overrides:
setContext in class Restlet

setGuard

public void setGuard(Guard guard)
Sets the Guard to use. It should typically use the Context of this application.
The new one is ignored, after the root Restlet is created (see createRoot().

Parameters:
guard - the Guard to use.
See Also:
setAuthentication(Guard, RoleChecker)

setObjectFactory

public void setObjectFactory(ObjectFactory objectFactory)
Sets the ObjectFactory for root resource class and provider instantiation.

Parameters:
objectFactory - the ObjectFactory for root resource class and provider instantiation.

setRoleChecker

public void setRoleChecker(RoleChecker roleChecker)
Sets the RoleChecker to use.
If you give an RoleChecker, you should also give a Guard.

Parameters:
roleChecker -
See Also:
setAuthentication(Guard, RoleChecker), setGuard(Guard)


Copyright © 2005-2008 Noelios Technologies.