com.noelios.restlet
Class Engine

java.lang.Object
  extended by org.restlet.util.Engine
      extended by com.noelios.restlet.Engine

public class Engine
extends Engine

Restlet factory supported by the engine.

Author:
Jerome Louvel

Field Summary
static java.lang.String DESCRIPTOR_AUTHENTICATION
           
static java.lang.String DESCRIPTOR_AUTHENTICATION_PATH
           
static java.lang.String DESCRIPTOR_CLIENT
           
static java.lang.String DESCRIPTOR_CLIENT_PATH
           
static java.lang.String DESCRIPTOR_PATH
           
static java.lang.String DESCRIPTOR_SERVER
           
static java.lang.String DESCRIPTOR_SERVER_PATH
           
static java.lang.String VERSION
          Complete version.
static java.lang.String VERSION_HEADER
          Complete version header.
 
Fields inherited from class org.restlet.util.Engine
MAJOR_NUMBER, MINOR_NUMBER, RELEASE_NUMBER
 
Constructor Summary
Engine()
          Constructor that will automatically attempt to discover connectors.
Engine(boolean discoverHelpers)
          Constructor.
 
Method Summary
 int authenticate(Request request, Guard guard)
           
 void challenge(Response response, boolean stale, Guard guard)
           
 void copyResponseHeaders(java.lang.Iterable<Parameter> responseHeaders, Response response)
          Copies the given header parameters into the given Response.
 void copyResponseHeaders(Response response, Series<Parameter> headers)
          Copies the headers of the given Response into the given Series.
 Resource createDirectoryResource(Directory directory, Request request, Response response)
           
 ApplicationHelper createHelper(Application application)
           
 ClientHelper createHelper(Client client, java.lang.String helperClass)
           
 ComponentHelper createHelper(Component component)
           
 ServerHelper createHelper(Server server, java.lang.String helperClass)
           
 AuthenticationHelper findHelper(ChallengeScheme challengeScheme, boolean clientSide, boolean serverSide)
          Finds the authentication helper supporting the given scheme.
 void fireContextChanged(Restlet restlet, Context context)
          Indicates that a Restlet's context has changed.
 java.lang.String formatCookie(Cookie cookie)
           
 java.lang.String formatCookieSetting(CookieSetting cookieSetting)
           
 java.lang.String formatDimensions(java.util.Collection<Dimension> dimensions)
           
 java.lang.String formatUserAgent(java.util.List<Product> products)
           
static Engine getInstance()
          Returns the registered Noelios Restlet engine.
static int getJavaMajorVersion()
          Parses the "java.version" system property and returns the first digit of the version number of the Java Runtime Environment (e.g.
static int getJavaMinorVersion()
          Parses the "java.version" system property and returns the second digit of the version number of the Java Runtime Environment (e.g.
static int getJavaUpdateVersion()
          Parses the "java.version" system property and returns the update release number of the Java Runtime Environment (e.g.
 Variant getPreferredVariant(ClientInfo client, java.util.List<Variant> variants, Language defaultLanguage)
           
 java.util.List<AuthenticationHelper> getRegisteredAuthentications()
          Returns the list of available authentication helpers.
 java.util.List<ClientHelper> getRegisteredClients()
          Returns the list of available client connectors.
 java.util.List<ServerHelper> getRegisteredServers()
          Returns the list of available server connectors.
 void parse(Form form, Representation webForm)
           
 void parse(Form form, java.lang.String queryString, CharacterSet characterSet, boolean decode, char separator)
           
 MediaType parseContentType(java.lang.String contentType)
           
 Cookie parseCookie(java.lang.String cookie)
           
 CookieSetting parseCookieSetting(java.lang.String cookieSetting)
           
 java.util.List<Product> parseUserAgent(java.lang.String userAgent)
           
static Engine register()
          Registers a new Noelios Restlet Engine.
static Engine register(boolean discoverConnectors)
          Registers a new Noelios Restlet Engine.
 void registerDefaultAuthentications()
          Registers the default authentication helpers.
 void registerDefaultConnectors()
          Registers the default client and server connectors.
 void registerHelper(java.lang.ClassLoader classLoader, java.net.URL configUrl, java.util.List helpers, java.lang.Class constructorClass)
          Registers a helper.
 void registerHelpers(java.lang.ClassLoader classLoader, java.util.Enumeration<java.net.URL> configUrls, java.util.List helpers, java.lang.Class constructorClass)
          Registers a list of helpers.
 void registerUrlFactory()
          Registers a factory that is used by the URL class to create the URLConnection instances when the URL.openConnection() or URL.openStream() methods are invoked.
 java.lang.String toBase64(byte[] target)
           
 java.lang.String toMd5(java.lang.String target)
           
 
Methods inherited from class org.restlet.util.Engine
getClassLoader, hashCode, loadClass, setInstance, setUserClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DESCRIPTOR_AUTHENTICATION

public static final java.lang.String DESCRIPTOR_AUTHENTICATION
See Also:
Constant Field Values

DESCRIPTOR_PATH

public static final java.lang.String DESCRIPTOR_PATH
See Also:
Constant Field Values

DESCRIPTOR_AUTHENTICATION_PATH

public static final java.lang.String DESCRIPTOR_AUTHENTICATION_PATH
See Also:
Constant Field Values

DESCRIPTOR_CLIENT

public static final java.lang.String DESCRIPTOR_CLIENT
See Also:
Constant Field Values

DESCRIPTOR_CLIENT_PATH

public static final java.lang.String DESCRIPTOR_CLIENT_PATH
See Also:
Constant Field Values

DESCRIPTOR_SERVER

public static final java.lang.String DESCRIPTOR_SERVER
See Also:
Constant Field Values

DESCRIPTOR_SERVER_PATH

public static final java.lang.String DESCRIPTOR_SERVER_PATH
See Also:
Constant Field Values

VERSION

public static final java.lang.String VERSION
Complete version.

See Also:
Constant Field Values

VERSION_HEADER

public static final java.lang.String VERSION_HEADER
Complete version header.

See Also:
Constant Field Values
Constructor Detail

Engine

public Engine()
Constructor that will automatically attempt to discover connectors.


Engine

public Engine(boolean discoverHelpers)
Constructor.

Parameters:
discoverHelpers - True if helpers should be automatically discovered.
Method Detail

getInstance

public static Engine getInstance()
Returns the registered Noelios Restlet engine.

Returns:
The registered Noelios Restlet engine.

getJavaMajorVersion

public static int getJavaMajorVersion()
Parses the "java.version" system property and returns the first digit of the version number of the Java Runtime Environment (e.g. "1" for "1.3.0").

Returns:
The major version number of the Java Runtime Environment.
See Also:
Official Java versioning

getJavaMinorVersion

public static int getJavaMinorVersion()
Parses the "java.version" system property and returns the second digit of the version number of the Java Runtime Environment (e.g. "3" for "1.3.0").

Returns:
The minor version number of the Java Runtime Environment.
See Also:
Official Java versioning

getJavaUpdateVersion

public static int getJavaUpdateVersion()
Parses the "java.version" system property and returns the update release number of the Java Runtime Environment (e.g. "10" for "1.3.0_10").

Returns:
The release number of the Java Runtime Environment or 0 if it does not exist.
See Also:
Official Java versioning

register

public static Engine register()
Registers a new Noelios Restlet Engine.

Returns:
The registered engine.

register

public static Engine register(boolean discoverConnectors)
Registers a new Noelios Restlet Engine.

Parameters:
discoverConnectors - True if connectors should be automatically discovered.
Returns:
The registered engine.

authenticate

public int authenticate(Request request,
                        Guard guard)
Specified by:
authenticate in class Engine

challenge

public void challenge(Response response,
                      boolean stale,
                      Guard guard)
Specified by:
challenge in class Engine

copyResponseHeaders

public void copyResponseHeaders(java.lang.Iterable<Parameter> responseHeaders,
                                Response response)
Copies the given header parameters into the given Response.

Specified by:
copyResponseHeaders in class Engine
Parameters:
responseHeaders - The headers to copy.
response - The response to update. Must contain a Representation to copy the representation headers in it.
See Also:
Engine.copyResponseHeaders(java.lang.Iterable, org.restlet.data.Response)

copyResponseHeaders

public void copyResponseHeaders(Response response,
                                Series<Parameter> headers)
Copies the headers of the given Response into the given Series.

Specified by:
copyResponseHeaders in class Engine
Parameters:
response - The response to update. Should contain a Representation to copy the representation headers from it.
headers - The Series to copy the headers in.
See Also:
Engine.copyResponseHeaders(Response, Series)

createDirectoryResource

public Resource createDirectoryResource(Directory directory,
                                        Request request,
                                        Response response)
                                 throws java.io.IOException
Specified by:
createDirectoryResource in class Engine
Throws:
java.io.IOException

createHelper

public ApplicationHelper createHelper(Application application)
Specified by:
createHelper in class Engine

createHelper

public ClientHelper createHelper(Client client,
                                 java.lang.String helperClass)
Specified by:
createHelper in class Engine

createHelper

public ComponentHelper createHelper(Component component)
Specified by:
createHelper in class Engine

createHelper

public ServerHelper createHelper(Server server,
                                 java.lang.String helperClass)
Specified by:
createHelper in class Engine

findHelper

public AuthenticationHelper findHelper(ChallengeScheme challengeScheme,
                                       boolean clientSide,
                                       boolean serverSide)
Finds the authentication helper supporting the given scheme.

Parameters:
challengeScheme - The challenge scheme to match.
clientSide - Indicates if client side support is required.
serverSide - Indicates if server side support is required.
Returns:
The authentication helper or null.

fireContextChanged

public void fireContextChanged(Restlet restlet,
                               Context context)
Indicates that a Restlet's context has changed.

Specified by:
fireContextChanged in class Engine
Parameters:
restlet - The Restlet with a changed context.
context - The new context.

formatCookie

public java.lang.String formatCookie(Cookie cookie)
                              throws java.lang.IllegalArgumentException
Specified by:
formatCookie in class Engine
Throws:
java.lang.IllegalArgumentException

formatCookieSetting

public java.lang.String formatCookieSetting(CookieSetting cookieSetting)
                                     throws java.lang.IllegalArgumentException
Specified by:
formatCookieSetting in class Engine
Throws:
java.lang.IllegalArgumentException

formatDimensions

public java.lang.String formatDimensions(java.util.Collection<Dimension> dimensions)
Specified by:
formatDimensions in class Engine

formatUserAgent

public java.lang.String formatUserAgent(java.util.List<Product> products)
                                 throws java.lang.IllegalArgumentException
Specified by:
formatUserAgent in class Engine
Throws:
java.lang.IllegalArgumentException

getPreferredVariant

public Variant getPreferredVariant(ClientInfo client,
                                   java.util.List<Variant> variants,
                                   Language defaultLanguage)
Specified by:
getPreferredVariant in class Engine

getRegisteredAuthentications

public java.util.List<AuthenticationHelper> getRegisteredAuthentications()
Returns the list of available authentication helpers.

Returns:
The list of available authentication helpers.

getRegisteredClients

public java.util.List<ClientHelper> getRegisteredClients()
Returns the list of available client connectors.

Returns:
The list of available client connectors.

getRegisteredServers

public java.util.List<ServerHelper> getRegisteredServers()
Returns the list of available server connectors.

Returns:
The list of available server connectors.

parse

public void parse(Form form,
                  Representation webForm)
Specified by:
parse in class Engine

parse

public void parse(Form form,
                  java.lang.String queryString,
                  CharacterSet characterSet,
                  boolean decode,
                  char separator)
Specified by:
parse in class Engine

parseContentType

public MediaType parseContentType(java.lang.String contentType)
                           throws java.lang.IllegalArgumentException
Specified by:
parseContentType in class Engine
Throws:
java.lang.IllegalArgumentException

parseCookie

public Cookie parseCookie(java.lang.String cookie)
                   throws java.lang.IllegalArgumentException
Specified by:
parseCookie in class Engine
Throws:
java.lang.IllegalArgumentException

parseCookieSetting

public CookieSetting parseCookieSetting(java.lang.String cookieSetting)
                                 throws java.lang.IllegalArgumentException
Specified by:
parseCookieSetting in class Engine
Throws:
java.lang.IllegalArgumentException

parseUserAgent

public java.util.List<Product> parseUserAgent(java.lang.String userAgent)
                                       throws java.lang.IllegalArgumentException
Specified by:
parseUserAgent in class Engine
Throws:
java.lang.IllegalArgumentException

registerDefaultAuthentications

public void registerDefaultAuthentications()
Registers the default authentication helpers.


registerDefaultConnectors

public void registerDefaultConnectors()
Registers the default client and server connectors.


registerHelper

public void registerHelper(java.lang.ClassLoader classLoader,
                           java.net.URL configUrl,
                           java.util.List helpers,
                           java.lang.Class constructorClass)
Registers a helper.

Parameters:
classLoader - The classloader to use.
configUrl - Configuration URL to parse
helpers - The list of helpers to update.
constructorClass - The constructor parameter class to look for.

registerHelpers

public void registerHelpers(java.lang.ClassLoader classLoader,
                            java.util.Enumeration<java.net.URL> configUrls,
                            java.util.List helpers,
                            java.lang.Class constructorClass)
Registers a list of helpers.

Parameters:
classLoader - The classloader to use.
configUrls - Configuration URLs to parse
helpers - The list of helpers to update.
constructorClass - The constructor parameter class to look for.

registerUrlFactory

public void registerUrlFactory()
Registers a factory that is used by the URL class to create the URLConnection instances when the URL.openConnection() or URL.openStream() methods are invoked.

The implementation is based on the client dispatcher of the current context, as provided by Context.getCurrent() method.


toBase64

public java.lang.String toBase64(byte[] target)
Specified by:
toBase64 in class Engine

toMd5

public java.lang.String toMd5(java.lang.String target)
Specified by:
toMd5 in class Engine


Copyright © 2005-2008 Noelios Technologies.