本文整理了Java中org.restlet.routing.VirtualHost
类的一些代码示例,展示了VirtualHost
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。VirtualHost
类的具体详情如下:
包路径:org.restlet.routing.VirtualHost
类名称:VirtualHost
[英]Router of calls from Server connectors to Restlets. The attached Restlets are typically Applications.
A virtual host is defined along three properties:
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.
[中]从服务器连接器到RESTlet的呼叫路由器。附加的RESTlet通常是应用程序。
虚拟主机由三个属性定义:
*请求的请求#getHostRef():接收请求的主机的URI。请注意,同一IP地址可以对应多个域名,因此可以使用不同的“hostRef”URI接收请求。
*请求的请求#getResourceRef():请求的目标资源的URI。如果该引用是相对的,则它基于“hostRef”,否则它将保持为接收状态。这种差异对于URN标识的资源、Web代理或Web缓存非常有用。
*response's response#getServerInfo():有关接收请求的服务器连接器的信息,如it IP地址和端口号。
创建新实例时,可以定义Java正则表达式(Java.util.regex.Pattern),该表达式必须与域名、端口、引用方案或服务器信息的IP地址和端口号相匹配。默认值与所有内容匹配。
并发性注意:这个类或其子类的实例可以由多个线程同时调用,因此必须是线程安全的。在成员变量中存储状态时,应该特别小心。
代码示例来源:origin: uber/chaperone
_component.getDefaultHost().attach(_controllerRestApp);
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.platform
Endpoint result = null;
for (Route route : virtualHost.getRoutes()) {
if (route.getNext() != null) {
Application app = getNextApplication(route.getNext());
&& application.getClass().equals(app.getClass())) {
String hostDomain = null;
if (virtualHost.getHostDomain() != null
&& !".*".equals(virtualHost.getHostDomain())) {
if (virtualHost.getHostDomain().contains("|")) {
hostDomain = virtualHost.getHostDomain().split("|")[0];
} else {
hostDomain = virtualHost.getHostDomain();
if (!".*".equals(virtualHost.getHostScheme())) {
scheme = Protocol.valueOf(virtualHost
.getHostScheme());
.getHostPort()));
} catch (Exception e) {
代码示例来源:origin: org.restlet.jee/org.restlet.ext.wadl
if (vh.getHostDomain().equals(hostDomain)
&& vh.getHostPort().equals(hostPort)
&& vh.getHostScheme().equals(hostScheme)) {
host = vh;
host = new VirtualHost(component.getContext().createChildContext());
host.setHostDomain(hostDomain);
host.setHostPort(hostPort);
host.setHostScheme(hostScheme);
component.getHosts().add(host);
代码示例来源:origin: org.restlet.osgi/org.restlet
@Override
protected void logRoute(org.restlet.routing.Route route) {
if (getLogger().isLoggable(Level.FINE)) {
if (route instanceof HostRoute) {
VirtualHost vhost = ((HostRoute) route).getVirtualHost();
if (getComponent().getDefaultHost() == vhost) {
getLogger().fine("Default virtual host selected");
} else {
getLogger().fine(
"Virtual host selected: \"" + vhost.getHostScheme()
+ "\", \"" + vhost.getHostDomain()
+ "\", \"" + vhost.getHostPort() + "\"");
}
} else {
super.logRoute(route);
}
}
}
代码示例来源:origin: org.restlet/org.restlet.ext.servlet
log("[Restlet] Attaching application: " + this.application
+ " to URI: " + uriPattern);
component.getDefaultHost().attach(uriPattern,
this.application);
if (component.getDefaultHost().getRoutes().isEmpty()) {
.getDefaultRoute() != null;
} else {
for (final Route route : component.getDefaultHost()
.getRoutes()) {
if (route.getTemplate().getPattern() == null) {
addFullServletPath = true;
for (final VirtualHost virtualHost : component
.getHosts()) {
if (virtualHost.getRoutes().isEmpty()) {
.getDefaultRoute() != null;
} else {
for (final Route route : virtualHost
.getRoutes()) {
if (route.getTemplate().getPattern() == null) {
addFullServletPath = true;
.getDefaultRoute();
if (defaultRoute != null) {
defaultRoute.getTemplate().setPattern(
代码示例来源:origin: org.restlet.osgi/org.restlet
if (matches(getVirtualHost().getHostDomain(), hostDomain)
&& matches(getVirtualHost().getHostPort(), hostPort)
&& matches(getVirtualHost().getHostScheme(), hostScheme)
&& matches(getVirtualHost().getResourceDomain(), resourceDomain)
&& matches(getVirtualHost().getResourcePort(), resourcePort)
&& matches(getVirtualHost().getResourceScheme(), resourceScheme)
&& matches(getVirtualHost().getServerAddress(), serverAddress)
&& matches(getVirtualHost().getServerPort(), serverPort)) {
result = 1F;
"Call score for the \"" + getVirtualHost().getName()
+ "\" host: " + result);
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Stop all applications attached to a virtual host
*
* @param host
* @throws Exception
*/
private void stopHostApplications(VirtualHost host) throws Exception {
for (Route route : host.getRoutes()) {
if (route.getNext().isStarted()) {
route.getNext().stop();
}
}
}
代码示例来源:origin: org.restlet.osgi/org.restlet
for (Route route : host.getRoutes()) {
Restlet next = route.getNext();
代码示例来源:origin: org.restlet.jee/org.restlet.ext.wadl
/**
* Attaches the application to the given host using the WADL base reference.
*
* @param host
* The virtual host to attach to.
*/
public void attachToHost(VirtualHost host) {
if (getBaseRef() != null) {
final String path = getBaseRef().getPath();
if (path == null) {
host.attach("", this);
} else {
host.attach(path, this);
}
} else {
getLogger()
.warning(
"The WADL application has no base reference defined. Unable to guess the virtual host.");
}
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.apispark
Endpoint result = null;
for (Route route : virtualHost.getRoutes()) {
if (route.getNext() != null) {
Application app = getNextApplication(route.getNext());
&& application.getClass().equals(app.getClass())) {
String hostDomain = null;
if (virtualHost.getHostDomain() != null
&& !".*".equals(virtualHost.getHostDomain())) {
if (virtualHost.getHostDomain().contains("|")) {
hostDomain = virtualHost.getHostDomain().split("|")[0];
} else {
hostDomain = virtualHost.getHostDomain();
if (!".*".equals(virtualHost.getHostScheme())) {
scheme = Protocol.valueOf(virtualHost
.getHostScheme());
.getHostPort()));
} catch (Exception e) {
代码示例来源:origin: org.restlet.jse/org.restlet.example
/**
* Creates and starts component. Pass 'auto' or 'explicit' (or a prefix of
* either) to control how the Injector is created. Default is auto.
*/
public static void main(String[] args) throws Exception {
if (args.length > 0) {
if ("explicit".startsWith(args[0])) {
mode = Mode.EXPLICIT_INJECTOR;
} else if (!"auto".startsWith(args[0])) {
System.out
.println("Call with prefix of 'auto' (default) or 'explicit'");
System.exit(1);
}
}
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getDefaultHost().attach(new Main());
component.start();
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.platform
Endpoint result = null;
for (Route route : virtualHost.getRoutes()) {
if (route.getNext() != null) {
Application app = getNextApplication(route.getNext());
&& application.getClass().equals(app.getClass())) {
String hostDomain = null;
if (virtualHost.getHostDomain() != null
&& !".*".equals(virtualHost.getHostDomain())) {
if (virtualHost.getHostDomain().contains("|")) {
hostDomain = virtualHost.getHostDomain().split("|")[0];
} else {
hostDomain = virtualHost.getHostDomain();
if (!".*".equals(virtualHost.getHostScheme())) {
scheme = Protocol.valueOf(virtualHost
.getHostScheme());
.getHostPort()));
} catch (Exception e) {
代码示例来源:origin: icclab/cyclops
component.getDefaultHost().attach(new RuleEngine().createInboundRoot());
} catch (org.hibernate.HibernateException | DatabaseException e) {
String log = String.format("Couldn't load facts and rules from backend database via Hibernate: %s", e.getMessage());
代码示例来源:origin: org.restlet.jse/org.restlet.ext.platform
Endpoint result = null;
for (Route route : virtualHost.getRoutes()) {
if (route.getNext() != null) {
Application app = getNextApplication(route.getNext());
&& application.getClass().equals(app.getClass())) {
String hostDomain = null;
if (virtualHost.getHostDomain() != null
&& !".*".equals(virtualHost.getHostDomain())) {
if (virtualHost.getHostDomain().contains("|")) {
hostDomain = virtualHost.getHostDomain().split("|")[0];
} else {
hostDomain = virtualHost.getHostDomain();
if (!".*".equals(virtualHost.getHostScheme())) {
scheme = Protocol.valueOf(virtualHost
.getHostScheme());
.getHostPort()));
} catch (Exception e) {
代码示例来源:origin: org.restlet.jse/org.restlet.example
public static void main(String[] args) throws Exception {
// Create a new Restlet component and add a HTTP server connector to it
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8111);
// Then attach it to the local host
component.getDefaultHost().attach("/trace",
Part05_RestletComponents.class);
// Now, let's start the component!
// Note that the HTTP server connector is also automatically started.
component.start();
}
代码示例来源:origin: org.restlet.gae/org.restlet.ext.platform
Endpoint result = null;
for (Route route : virtualHost.getRoutes()) {
if (route.getNext() != null) {
Application app = getNextApplication(route.getNext());
&& application.getClass().equals(app.getClass())) {
String hostDomain = null;
if (virtualHost.getHostDomain() != null
&& !".*".equals(virtualHost.getHostDomain())) {
if (virtualHost.getHostDomain().contains("|")) {
hostDomain = virtualHost.getHostDomain().split("|")[0];
} else {
hostDomain = virtualHost.getHostDomain();
if (!".*".equals(virtualHost.getHostScheme())) {
scheme = Protocol.valueOf(virtualHost
.getHostScheme());
.getHostPort()));
} catch (Exception e) {
代码示例来源:origin: dice-group/AGDISTIS
public static void main(String[] args) {
try {
// Create a new Component.
Component component = new Component();
// Add a new HTTP server listening on port 8082.
component.getServers().add(Protocol.HTTP, 8080);
// Attach the sample application.
component.getDefaultHost().attach(new RestletApplication());
// Start the component.
component.start();
} catch (Exception e) {
// Something is wrong.
e.printStackTrace();
}
}
代码示例来源:origin: uber/uReplicator
public void start() throws Exception {
_component.getServers().add(Protocol.HTTP, _config.getManagerPort());
_component.getClients().add(Protocol.FILE);
_component.getClients().add(Protocol.JAR);
Context applicationContext = _component.getContext().createChildContext();
LOGGER.info("Injecting conf and helix to the api context");
applicationContext.getAttributes().put(ManagerConf.class.toString(), _config);
applicationContext.getAttributes().put(ControllerHelixManager.class.toString(), _controllerHelixManager);
applicationContext.getAttributes()
.put(SourceKafkaClusterValidationManager.class.toString(), _srcKafkaValidationManager);
Application managerRestApp = new ManagerRestApplication(null);
managerRestApp.setContext(applicationContext);
_component.getDefaultHost().attach(managerRestApp);
try {
LOGGER.info("Starting helix manager");
_controllerHelixManager.start();
LOGGER.info("Starting source kafka cluster validation manager");
_srcKafkaValidationManager.start();
LOGGER.info("Starting API component");
_component.start();
} catch (final Exception e) {
LOGGER.error("Caught exception while starting uReplicator-Manager", e);
throw e;
}
}
代码示例来源:origin: icclab/cyclops
component.getDefaultHost().attach(new Service().createInboundRoot());
} catch (Exception e) {
String log = String.format("Couldn't create router and initialise things accordingly: %s", e.getMessage());
代码示例来源:origin: icclab/cyclops
component.getDefaultHost().attach(new Service().createInboundRoot());
} catch (Exception e) {
String log = String.format("Couldn't create router and initialise things accordingly: %s", e.getMessage());
内容来源于网络,如有侵权,请联系作者删除!