org.restlet.ext.jaxrs
Class JaxRsApplication

java.lang.Object
  extended by org.restlet.Restlet
      extended by org.restlet.Application
          extended by org.restlet.ext.jaxrs.JaxRsApplication
All Implemented Interfaces:
Uniform

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(javax.ws.rs.core.Application appConfig)
           
JaxRsApplication(Context context)
          Creates an new JaxRsApplication.
 
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.
 Restlet createInboundRoot()
           
 Filter getGuard()
          Returns the Guard
 JaxRsRestlet getJaxRsRestlet()
          Returns the used JaxRsRestlet.
 ObjectFactory getObjectFactory()
          Returns the ObjectFactory for root resource class and provider instantiation, if given.
 RoleChecker getRoleChecker()
          Deprecated. Use ClientInfo.getRoles() instead
 Collection<Class<?>> getRootResources()
          Returns an unmodifiable set with the attached root resource classes.
 Collection<String> getRootUris()
          Returns an unmodifiable set of supported URIs (relative to this Application).
 void setApplications(Collection<javax.ws.rs.core.Application> apps)
          Adds the given applications to the available applications.
 void setAuthentication(Authenticator guard, RoleChecker roleChecker)
          Deprecated. Use ClientInfo.getRoles() instead
 void setContext(Context context)
           
 void setGuard(Authenticator guard)
          Set the Guard from the org.restlet.security package.
 void setGuard(Guard guard)
          Deprecated. Use the setGuard(Authenticator) method instead.
 void setObjectFactory(ObjectFactory objectFactory)
          Sets the ObjectFactory for root resource class and provider instantiation.
 void setRoleChecker(RoleChecker roleChecker)
          Deprecated. Use ClientInfo.getRoles() instead
 
Methods inherited from class org.restlet.Application
createOutboundRoot, createRoot, getConnectorService, getConverterService, getCurrent, getDecoderService, getFinderClass, getInboundRoot, getMetadataService, getOutboundRoot, getRangeService, getRole, getRoles, getRoot, getServices, getStatusService, getTaskService, getTunnelService, handle, setClientRoot, setConnectorService, setConverterService, setCurrent, setDecoderService, setFinderClass, setInboundRoot, setInboundRoot, setMetadataService, setOutboundRoot, setRangeService, setRoles, setRoot, setRoot, setStatusService, setTaskService, setTunnelService, start, stop
 
Methods inherited from class org.restlet.Restlet
finalize, getApplication, getAuthor, getContext, getDescription, getLogger, getName, getOwner, isStarted, isStopped, setAuthor, setDescription, setName, setOwner
 
Methods inherited from class java.lang.Object
clone, equals, 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. Attach JAX-RS-Applications by using add(Application).

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

JaxRsApplication

public JaxRsApplication(javax.ws.rs.core.Application appConfig)
                 throws IllegalArgumentException
Parameters:
appConfig -
Throws:
IllegalArgumentException
Method Detail

add

public boolean add(javax.ws.rs.core.Application appConfig)
            throws 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.

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.
Returns:
true, if all resource classes and providers could be added, or false at least one could not be added. Exceptions were logged.
Throws:
IllegalArgumentException - if the given appConfig is null.

createInboundRoot

public Restlet createInboundRoot()
Overrides:
createInboundRoot in class Application

getGuard

public Filter getGuard()
Returns the Guard

Returns:
the Guard

getJaxRsRestlet

public JaxRsRestlet getJaxRsRestlet()
Returns the used JaxRsRestlet.

Returns:
the used JaxRsRestlet.

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

@Deprecated
public RoleChecker getRoleChecker()
Deprecated. Use ClientInfo.getRoles() instead

Returns the current RoleChecker

Returns:
the current RoleChecker

getRootResources

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

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

getRootUris

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

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

setApplications

public void setApplications(Collection<javax.ws.rs.core.Application> apps)
Adds the given applications to the available applications.

Parameters:
apps -

setAuthentication

@Deprecated
public void setAuthentication(Authenticator guard,
                                         RoleChecker roleChecker)
Deprecated. Use ClientInfo.getRoles() instead

Sets the objects to check the authentication. The Authenticator 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(Authenticator), setRoleChecker(RoleChecker)

setContext

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

setGuard

@Deprecated
public void setGuard(Guard guard)
Deprecated. Use the setGuard(Authenticator) method instead.

Sets the Authenticator to use. It should typically use the Context of this application.
The new one is ignored, after the root Restlet is created (see Application.createRoot().

This replaced the guard set via setGuard(org.restlet.security.Authenticator).

Parameters:
guard - the Guard to use.
See Also:
setAuthentication(Authenticator, RoleChecker), setGuard(org.restlet.security.Authenticator)

setGuard

public void setGuard(Authenticator guard)
Set the Guard from the org.restlet.security package. This should be called before the root Restlet is created.

This replaced the guard set via setGuard(org.restlet.security.Guard).

Parameters:
guard - the Guard to use.

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

@Deprecated
public void setRoleChecker(RoleChecker roleChecker)
Deprecated. Use ClientInfo.getRoles() instead

Sets the RoleChecker to use.
If you give an RoleChecker, you should also give a Guard.

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


Copyright © 2005-2011 Noelios Technologies.