org.restlet
Class VirtualHost

java.lang.Object
  extended by org.restlet.Uniform
      extended by org.restlet.Restlet
          extended by org.restlet.Router
              extended by org.restlet.VirtualHost

public class VirtualHost
extends Router

Router of calls from Server connectors to Restlets. The attached Restlets are typically Applications.

A virtual host is defined along three properties:

When creating a new instance, you can define Java regular expressions (Pattern) that must match the domain name, port, scheme for references or IP address and port number for server information. The default values match everything.

Author:
Jerome Louvel (contact@noelios.com)
See Also:
Pattern, Wikipedia - Virtual Hosting, Apache - Virtual Hosting

Field Summary
 
Fields inherited from class org.restlet.Router
BEST, CUSTOM, FIRST, LAST, NEXT, RANDOM
 
Constructor Summary
VirtualHost()
          Constructor.
VirtualHost(Context context)
          Constructor.
VirtualHost(Context context, String hostDomain, String hostPort, String hostScheme, String resourceDomain, String resourcePort, String resourceScheme, String serverAddress, String serverPort)
          Constructor.
 
Method Summary
protected  Route createRoute(String uriPattern, Restlet target)
          Creates a new route for the given URI pattern and target.
 String getHostDomain()
          Returns the hostRef host domain to match.
 String getHostPort()
          Returns the hostRef host port to match.
 String getHostScheme()
          Returns the hostRef scheme to match.
static String getIpAddress(String domain)
          Returns the IP address of a given domain name.
static String getLocalHostAddress()
          Returns the local host IP address.
static String getLocalHostName()
          Returns the local host name.
 String getName()
          Returns the display name.
 String getResourceDomain()
          Returns the resourceRef host domain to match.
 String getResourcePort()
          Returns the resourceRef host port to match.
 String getResourceScheme()
          Returns the resourceRef scheme to match.
 String getServerAddress()
          Returns the listening server address.
 String getServerPort()
          Returns the listening server port.
 void setHostDomain(String hostDomain)
          Sets the hostRef host domain to match.
 void setHostPort(String hostPort)
          Sets the hostRef host port to match.
 void setHostScheme(String hostScheme)
          Sets the hostRef scheme to match.
 void setName(String name)
          Sets the display name.
 void setResourceDomain(String resourceDomain)
          Sets the resourceRef host domain to match.
 void setResourcePort(String resourcePort)
          Sets the resourceRef host port to match.
 void setResourceScheme(String resourceScheme)
          Sets the resourceRef scheme to match.
 void setServerAddress(String serverAddress)
          Sets the listening server address.
 void setServerPort(String serverPort)
          Sets the listening server port.
 
Methods inherited from class org.restlet.Router
attach, attach, attach, attachDefault, attachDefault, detach, getCustom, getDefaultRoute, getFinderClass, getMaxAttempts, getNext, getRequiredScore, getRetryDelay, getRoutes, getRoutingMode, handle, setDefaultRoute, setFinderClass, setMaxAttempts, setRequiredScore, setRetryDelay, setRoutingMode
 
Methods inherited from class org.restlet.Restlet
getContext, getLogger, init, isStarted, isStopped, setContext, start, stop
 
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

VirtualHost

public VirtualHost()
Constructor. Note that usage of this constructor is not recommended as the Router won't have a proper context set. In general you will prefer to use the other constructor and pass it the parent component's context.


VirtualHost

public VirtualHost(Context context)
Constructor. Accepts all incoming requests by default, use the set methods to restrict the matchable patterns.

Parameters:
context - The context.

VirtualHost

public VirtualHost(Context context,
                   String hostDomain,
                   String hostPort,
                   String hostScheme,
                   String resourceDomain,
                   String resourcePort,
                   String resourceScheme,
                   String serverAddress,
                   String serverPort)
Constructor.

Parameters:
context - The context.
hostDomain - The hostRef host domain pattern to match.
hostPort - The hostRef host port pattern to match.
hostScheme - The hostRef scheme protocol pattern to match.
resourceDomain - The resourceRef host domain pattern to match.
resourcePort - The resourceRef host port pattern to match.
resourceScheme - The resourceRef scheme protocol pattern to match.
serverAddress - The listening server address pattern to match.
serverPort - The listening server port pattern to match.
Method Detail

getIpAddress

public static String getIpAddress(String domain)
Returns the IP address of a given domain name.

Parameters:
domain - The domain name.
Returns:
The IP address.

getLocalHostAddress

public static String getLocalHostAddress()
Returns the local host IP address.

Returns:
The local host IP address.

getLocalHostName

public static String getLocalHostName()
Returns the local host name.

Returns:
The local host name.

createRoute

protected Route createRoute(String uriPattern,
                            Restlet target)
Description copied from class: Router
Creates a new route for the given URI pattern and target.

Overrides:
createRoute in class Router
Parameters:
uriPattern - The URI pattern that must match the relative part of the resource URI.
target - The target Restlet to attach.
Returns:
The created route.

getHostDomain

public String getHostDomain()
Returns the hostRef host domain to match. Uses patterns in java.util.regex.

Returns:
The hostRef host domain to match.

getHostPort

public String getHostPort()
Returns the hostRef host port to match. Uses patterns in java.util.regex.

Returns:
The hostRef host port to match.

getHostScheme

public String getHostScheme()
Returns the hostRef scheme to match. Uses patterns in java.util.regex.

Returns:
The hostRef scheme to match.

getName

public String getName()
Returns the display name.

Returns:
The display name.

getResourceDomain

public String getResourceDomain()
Returns the resourceRef host domain to match. Uses patterns in java.util.regex.

Returns:
The resourceRef host domain to match.

getResourcePort

public String getResourcePort()
Returns the resourceRef host port to match. Uses patterns in java.util.regex.

Returns:
The resourceRef host port to match.

getResourceScheme

public String getResourceScheme()
Returns the resourceRef scheme to match. Uses patterns in java.util.regex.

Returns:
The resourceRef scheme to match.

getServerAddress

public String getServerAddress()
Returns the listening server address. Uses patterns in java.util.regex.

Returns:
The listening server address.

getServerPort

public String getServerPort()
Returns the listening server port. Uses patterns in java.util.regex.

Returns:
The listening server port.

setHostDomain

public void setHostDomain(String hostDomain)
Sets the hostRef host domain to match. Uses patterns in java.util.regex.

Parameters:
hostDomain - The hostRef host domain to match.

setHostPort

public void setHostPort(String hostPort)
Sets the hostRef host port to match. Uses patterns in java.util.regex.

Parameters:
hostPort - The hostRef host port to match.

setHostScheme

public void setHostScheme(String hostScheme)
Sets the hostRef scheme to match. Uses patterns in java.util.regex.

Parameters:
hostScheme - The hostRef scheme to match.

setName

public void setName(String name)
Sets the display name.

Parameters:
name - The display name.

setResourceDomain

public void setResourceDomain(String resourceDomain)
Sets the resourceRef host domain to match. Uses patterns in java.util.regex.

Parameters:
resourceDomain - The resourceRef host domain to match.

setResourcePort

public void setResourcePort(String resourcePort)
Sets the resourceRef host port to match. Uses patterns in java.util.regex.

Parameters:
resourcePort - The resourceRef host port to match.

setResourceScheme

public void setResourceScheme(String resourceScheme)
Sets the resourceRef scheme to match. Uses patterns in java.util.regex.

Parameters:
resourceScheme - The resourceRef scheme to match.

setServerAddress

public void setServerAddress(String serverAddress)
Sets the listening server address. Uses patterns in java.util.regex.

Parameters:
serverAddress - The listening server address.

setServerPort

public void setServerPort(String serverPort)
Sets the listening server port. Uses patterns in java.util.regex.

Parameters:
serverPort - The listening server port.


Copyright © 2005-2007 Noelios Technologies.