public class VirtualHost extends Router
Request.getHostRef()
: the URI of the host that received
the request. Note that the same IP address can correspond to multiple domain
names and therefore receive request with different "hostRef" URIs.Request.getResourceRef()
: the URI of the target
resource of the request. If this reference is relative, then it is based on
the "hostRef", otherwise it is maintained as received. This difference is
useful for resources identified by URNs or for Web proxies or Web caches.Response.getServerInfo()
: the information about the
server connector receiving the requests such as it IP address and port
number.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.Pattern
,
Wikipedia -
Virtual Hosting,
Apache - Virtual
HostingBEST, CUSTOM, FIRST, LAST, MODE_BEST_MATCH, MODE_CUSTOM, MODE_FIRST_MATCH, MODE_LAST_MATCH, MODE_NEXT_MATCH, MODE_RANDOM_MATCH, NEXT, RANDOM
Constructor and Description |
---|
VirtualHost()
Constructor.
|
VirtualHost(Context parentContext)
Constructor.
|
VirtualHost(Context parentContext,
String hostDomain,
String hostPort,
String hostScheme,
String resourceDomain,
String resourcePort,
String resourceScheme,
String serverAddress,
String serverPort)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Route |
attach(Restlet target)
Attaches a target Restlet to this router with an empty URI pattern.
|
Route |
attach(String uriPattern,
Restlet target)
Attaches a target Restlet to this router based on a given URI pattern.
|
Route |
attachDefault(Restlet defaultTarget)
Attaches a Restlet to this router as the default target to invoke when no
route matches.
|
Finder |
createFinder(Class<?> targetClass)
Creates a new finder instance based on the "targetClass" property.
|
protected Route |
createRoute(String uriPattern,
Restlet target,
int matchingMode)
Creates a new route for the given URI pattern, target and matching mode.
|
static Integer |
getCurrent()
Returns the virtual host code associated to the current thread.
|
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 |
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.
|
static void |
setCurrent(Integer code)
Sets the virtual host code associated with the current thread.
|
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 |
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.
|
attach, attach, attach, attach, attachDefault, createRoute, detach, detach, doHandle, getCustom, getDefaultMatchingMode, getDefaultMatchingQuery, getDefaultMatchQuery, getDefaultRoute, getFinderClass, getMatchingMode, getMaxAttempts, getNext, getRequiredScore, getRetryDelay, getRoutes, getRoutingMode, handle, logRoute, setDefaultMatchingMode, setDefaultMatchingQuery, setDefaultMatchQuery, setDefaultRoute, setFinderClass, setMaxAttempts, setRequiredScore, setRetryDelay, setRoutes, setRoutingMode, start, stop
finalize, getApplication, getAuthor, getContext, getDescription, getLogger, getName, getOwner, isStarted, isStopped, setAuthor, setContext, setDescription, setName, setOwner
public VirtualHost()
public VirtualHost(Context parentContext)
parentContext
- The parent component's context.public VirtualHost(Context parentContext, String hostDomain, String hostPort, String hostScheme, String resourceDomain, String resourcePort, String resourceScheme, String serverAddress, String serverPort)
parentContext
- The parent component's 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.Pattern
public static Integer getCurrent()
public static String getIpAddress(String domain)
domain
- The domain name.public static String getLocalHostAddress()
public static String getLocalHostName()
public static void setCurrent(Integer code)
code
- The thread's virtual host code.public Route attach(Restlet target)
Context.createChildContext()
method.public Route attach(String uriPattern, Restlet target)
Context.createChildContext()
method.public Route attachDefault(Restlet defaultTarget)
Context.createChildContext()
method.attachDefault
in class Router
defaultTarget
- The Restlet to use as the default target.public Finder createFinder(Class<?> targetClass)
Context.createChildContext()
method.createFinder
in class Router
targetClass
- The target Resource class to attach.protected Route createRoute(String uriPattern, Restlet target, int matchingMode)
Router
Router.getDefaultMatchingQuery()
.createRoute
in class Router
uriPattern
- The URI pattern that must match the relative part of the
resource URI.target
- The target Restlet to attach.matchingMode
- The matching mode.public String getHostDomain()
Pattern
class for details on the syntax.public String getHostPort()
Pattern
class for details on the syntax.public String getHostScheme()
Pattern
class for details on the syntax.public String getResourceDomain()
Pattern
class for details on the syntax.public String getResourcePort()
Pattern
class for details on the syntax.public String getResourceScheme()
Pattern
class for details on the syntax.public String getServerAddress()
Pattern
class for details on the syntax.public String getServerPort()
Pattern
class for details on the syntax.public void setHostDomain(String hostDomain)
Pattern
class for details on the syntax.hostDomain
- The hostRef host domain to match.public void setHostPort(String hostPort)
Pattern
class for details on the syntax.hostPort
- The hostRef host port to match.public void setHostScheme(String hostScheme)
Pattern
class for details on the syntax.hostScheme
- The hostRef scheme to match.public void setResourceDomain(String resourceDomain)
Pattern
class for details on the syntax.resourceDomain
- The resourceRef host domain to match.public void setResourcePort(String resourcePort)
Pattern
class for details on the syntax.resourcePort
- The resourceRef host port to match.public void setResourceScheme(String resourceScheme)
Pattern
class for details on the syntax.resourceScheme
- The resourceRef scheme to match.public void setServerAddress(String serverAddress)
Pattern
class for details on the syntax.serverAddress
- The listening server address.Copyright © 2005–2016. All rights reserved.