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()
           
 Authenticator getAuthenticator()
          Returns the Authenticator.
 Authenticator getGuard()
          Deprecated. Use getAuthenticator() instead.
 JaxRsRestlet getJaxRsRestlet()
          Returns the used JaxRsRestlet.
 ObjectFactory getObjectFactory()
          Returns the ObjectFactory for root resource class and provider instantiation, if given.
 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 setAuthenticator(Authenticator authenticator)
          Sets the Authenticator to use.
 void setContext(Context context)
           
 void setGuard(Authenticator authenticator)
          Deprecated. Use setAuthenticator(Authenticator) instead.
 void setObjectFactory(ObjectFactory objectFactory)
          Sets the ObjectFactory for root resource class and provider instantiation.
 
Methods inherited from class org.restlet.Application
createOutboundRoot, getConnectorService, getConnegService, getConverterService, getCurrent, getDecoderService, getEncoderService, getInboundRoot, getMetadataService, getOutboundRoot, getRangeService, getRole, getRoles, getServices, getStatusService, getTaskService, getTunnelService, handle, setClientRoot, setConnectorService, setConnegService, setConverterService, setCurrent, setDecoderService, setEncoderService, setInboundRoot, setInboundRoot, setMetadataService, setOutboundRoot, setOutboundRoot, setRangeService, setRoles, setStatusService, setTaskService, setTunnelService, start, stop
 
Methods inherited from class org.restlet.Restlet
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setDescription, setFinderClass, 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

getAuthenticator

public Authenticator getAuthenticator()
Returns the Authenticator.

Returns:
the Authenticator.

getGuard

@Deprecated
public Authenticator getGuard()
Deprecated. Use getAuthenticator() instead.

Returns the Authenticator.

Returns:
the Authenticator.

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.

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 -

setAuthenticator

public void setAuthenticator(Authenticator authenticator)
Sets the Authenticator to use. This should be called before the root Restlet is created.

This replaced the guard set via setGuard(Authenticator).

Parameters:
authenticator - The Authenticator to use.

setContext

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

setGuard

@Deprecated
public void setGuard(Authenticator authenticator)
Deprecated. Use setAuthenticator(Authenticator) instead.

Sets the Authenticator to use. This should be called before the root Restlet is created.

This replaced the guard set via setGuard(Authenticator).

Parameters:
authenticator - The Authenticator 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.


Copyright © 2005-2013 Restlet.