本文整理汇总了Java中org.restlet.routing.VirtualHost类的典型用法代码示例。如果您正苦于以下问题:Java VirtualHost类的具体用法?Java VirtualHost怎么用?Java VirtualHost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VirtualHost类属于org.restlet.routing包,在下文中一共展示了VirtualHost类的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: Component
点赞 3
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Constructor.
*/
public Component() {
super();
this.hosts = new CopyOnWriteArrayList<VirtualHost>();
this.clients = new ClientList(null);
this.servers = new ServerList(null, this);
this.realms = new CopyOnWriteArrayList<Realm>();
this.services = new ServiceList(getContext());
if (Engine.getInstance() != null) {
// To be done before setting the helper...
this.services.add(new org.restlet.service.TaskService());
this.helper = new ComponentHelper(this);
Context childContext = getContext().createChildContext();
this.defaultHost = new VirtualHost(childContext);
this.internalRouter = new InternalRouter(childContext);
this.services.add(new LogService());
getLogService().setContext(childContext);
this.services.add(new StatusService());
this.clients.setContext(childContext);
this.servers.setContext(childContext);
}
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:27,
代码来源:Component.java
示例2: logRoute
点赞 3
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
@Override
protected void logRoute(org.restlet.routing.Route route) {
if (getLogger().isDebugEnabled()) {
if (route instanceof HostRoute) {
VirtualHost vhost = ((HostRoute) route).getVirtualHost();
if (getComponent().getDefaultHost() == vhost) {
getLogger().debug("Default virtual host selected");
} else {
getLogger().debug(
"Virtual host selected: \"" + vhost.getHostScheme()
+ "\", \"" + vhost.getHostDomain()
+ "\", \"" + vhost.getHostPort() + "\"");
}
} else {
super.logRoute(route);
}
}
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:20,
代码来源:ServerRouter.java
示例3: setUp
点赞 3
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
component = PowerMockito.mock(Component.class, RETURNS_DEEP_STUBS);
ServerList list = PowerMockito.mock(ServerList.class);
PowerMockito.doReturn(list).when(component).getServers();
PowerMockito.doReturn(mock(Server.class)).when(list).add(any(Protocol.class), anyInt());
VirtualHost host = PowerMockito.mock(VirtualHost.class);
PowerMockito.doReturn(host).when(component).getDefaultHost();
PowerMockito.doReturn(mock(TemplateRoute.class))
.when(host).attach(anyString(), any(RMrouterApplication.class));
PowerMockito.doNothing().when(component).start();
PowerMockito.whenNew(Component.class).withNoArguments().thenReturn(component);
OdenOsPropertyLoader loader = PowerMockito.spy(OdenOsPropertyLoader.getInstance());
Whitebox.setInternalState(OcnRMServ.class, "loader", loader);
dummyLogger = mock(Logger.class);
Whitebox.setInternalState(OcnRMServ.class, "logger", dummyLogger);
}
开发者ID:o3project,
项目名称:ocnrm,
代码行数:24,
代码来源:OcnRMServTest.java
示例4: LRSystemComponent
点赞 3
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Constructor.
*
* @throws Exception
*/
public LRSystemComponent() throws Exception {
// Set basic properties
setName("License Recognition Server");
setDescription("License Recognition");
setOwner("Software college");
setAuthor("Justin Yang");
// Add connectors
getClients().add(new Client(Protocol.CLAP));
getClients().add(new Client(Protocol.FILE));
Server server = new Server(new Context(), Protocol.HTTP, 8183);
// Tracing
getServers().add(server);
LRSystemApplication app = new LRSystemApplication();
// Configure the default virtual host
VirtualHost host = getDefaultHost();
// Attach the application to the default virtual host
host.attachDefault(app);
}
开发者ID:yang2012,
项目名称:LicenseRecognition,
代码行数:30,
代码来源:LRSystemComponent.java
示例5: setHosts
点赞 2
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Sets the modifiable list of virtual hosts. Note that the order of virtual
* hosts in this list will be used to check the first one that matches. This
* method clears the current list and adds all entries in the parameter
* list.
*
* @param hosts
* A list of virtual hosts.
*/
public void setHosts(List<VirtualHost> hosts) {
synchronized (getHosts()) {
if (hosts != getHosts()) {
getHosts().clear();
if (hosts != null) {
getHosts().addAll(hosts);
}
}
}
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:21,
代码来源:Component.java
示例6: startRouters
点赞 2
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Starts the virtual hosts and the internal router.
*
* @throws Exception
*/
protected synchronized void startRouters() throws Exception {
if (this.internalRouter != null) {
this.internalRouter.start();
}
if (this.defaultHost != null) {
this.defaultHost.start();
}
for (VirtualHost host : getHosts()) {
host.start();
}
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:19,
代码来源:Component.java
示例7: stopRouters
点赞 2
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Stops the virtual hosts and the internal router.
*
* @throws Exception
*/
protected synchronized void stopRouters() throws Exception {
for (VirtualHost host : getHosts()) {
host.stop();
}
if (this.defaultHost != null) {
this.defaultHost.stop();
}
if (this.internalRouter != null) {
this.internalRouter.stop();
}
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:19,
代码来源:Component.java
示例8: start
点赞 2
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/** Starts the Restlet. */
@Override
public synchronized void start() throws Exception {
// Attach all virtual hosts
for (VirtualHost host : getComponent().getHosts()) {
getRoutes().add(new HostRoute(this, host));
}
// Also attach the default host if it exists
if (getComponent().getDefaultHost() != null) {
getRoutes().add(
new HostRoute(this, getComponent().getDefaultHost()));
}
// If no host matches, display and error page with a precise message
final Restlet noHostMatched = new Restlet(getComponent().getContext()
.createChildContext()) {
@Override
public void handle(Request request, Response response) {
response.setStatus(Status.CLIENT_ERROR_NOT_FOUND,
"No virtual host could handle the request");
}
};
setDefaultRoute(new org.restlet.routing.TemplateRoute(this, "",
noHostMatched));
// Start the router
super.start();
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:31,
代码来源:ServerRouter.java
示例9: stop
点赞 2
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
@Override
public synchronized void stop() throws Exception {
// Stop the server's router
getServerRouter().stop();
// Stop all applications
stopHostApplications(getHelped().getDefaultHost());
for (VirtualHost host : getHelped().getHosts()) {
stopHostApplications(host);
}
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:13,
代码来源:ComponentHelper.java
示例10: stopHostApplications
点赞 2
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* 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();
}
}
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:14,
代码来源:ComponentHelper.java
示例11: doHandle
点赞 2
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
@Override
protected int doHandle(Request request, Response response) {
int result = CONTINUE;
Protocol protocol = request.getProtocol();
if (protocol.equals(Protocol.RIAP)) {
// Let's dispatch it
LocalReference cr = new LocalReference(request.getResourceRef());
Component component = getComponent();
if (component != null) {
if (cr.getRiapAuthorityType() == LocalReference.RIAP_COMPONENT) {
// This causes the baseRef of the resource reference to be
// set as if it had actually arrived from a server
// connector.
request.getResourceRef().setBaseRef(
request.getResourceRef().getHostIdentifier());
// Ask the private internal route to handle the call
component.getInternalRouter().handle(request, response);
} else if (cr.getRiapAuthorityType() == LocalReference.RIAP_HOST) {
VirtualHost host = null;
VirtualHost currentHost = null;
final Integer hostHashCode = VirtualHost.getCurrent();
// Lookup the virtual host
for (final Iterator<VirtualHost> hostIter = getComponent()
.getHosts().iterator(); (host == null)
&& hostIter.hasNext();) {
currentHost = hostIter.next();
if (currentHost.hashCode() == hostHashCode) {
host = currentHost;
}
}
if ((host == null) && (component.getDefaultHost() != null)) {
if (component.getDefaultHost().hashCode() == hostHashCode) {
host = component.getDefaultHost();
}
}
if (host != null) {
// This causes the baseRef of the resource reference to
// be set as if it had actually arrived from a server
// connector.
request.getResourceRef().setBaseRef(
request.getResourceRef().getHostIdentifier());
// Ask the virtual host to handle the call
host.handle(request, response);
} else {
getLogger()
.warn("No virtual host is available to route the RIAP Host request.");
result = STOP;
}
} else {
getLogger()
.warn("Unknown RIAP authority. Only \"component\" is supported.");
result = STOP;
}
} else {
getLogger().warn("No component is available to route the RIAP request.");
result = STOP;
}
} else {
getComponentContext().getComponentHelper().getClientRouter()
.handle(request, response);
}
return result;
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:73,
代码来源:ComponentClientDispatcher.java
示例12: start
点赞 2
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
@Override
public synchronized void start() throws Exception {
// Checking if all applications have proper connectors
boolean success = checkVirtualHost(getHelped().getDefaultHost());
if (success) {
for (VirtualHost host : getHelped().getHosts()) {
success = success && checkVirtualHost(host);
}
}
// Let's actually start the component
if (!success) {
getHelped().stop();
} else {
Filter filter = null;
for (Service service : getHelped().getServices()) {
if (service.isEnabled()) {
// Attach the service inbound filters
filter = service
.createInboundFilter((getContext() == null) ? null
: getContext().createChildContext());
if (filter != null) {
addInboundFilter(filter);
}
// Attach the service outbound filters
filter = service
.createOutboundFilter((getContext() == null) ? null
: getContext().createChildContext());
if (filter != null) {
addOutboundFilter(filter);
}
}
}
// Re-attach the original filter's attached Restlet
setInboundNext(getServerRouter());
}
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:44,
代码来源:ComponentHelper.java
示例13: getVirtualHost
点赞 2
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
public VirtualHost getVirtualHost() {
return defaultVHost;
}
开发者ID:alexmilowski,
项目名称:xproclet,
代码行数:4,
代码来源:ConfiguredHost.java
示例14: getDefaultHost
点赞 1
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Returns the default virtual host.
*
* @return The default virtual host.
*/
public VirtualHost getDefaultHost() {
return this.defaultHost;
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:9,
代码来源:Component.java
示例15: getHosts
点赞 1
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Returns the modifiable list of virtual hosts. Note that the order of
* virtual hosts in this list will be used to check the first one that
* matches.
*
* @return The modifiable list of virtual hosts.
*/
public List<VirtualHost> getHosts() {
return this.hosts;
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:11,
代码来源:Component.java
示例16: setDefaultHost
点赞 1
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Sets the default virtual host.
*
* @param defaultHost
* The default virtual host.
*/
public void setDefaultHost(VirtualHost defaultHost) {
this.defaultHost = defaultHost;
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:10,
代码来源:Component.java
示例17: HostRoute
点赞 1
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Constructor.
*
* @param router
* The parent router.
* @param target
* The target virtual host.
*/
public HostRoute(Router router, VirtualHost target) {
super(router, target);
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:12,
代码来源:HostRoute.java
示例18: getVirtualHost
点赞 1
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Returns the target virtual host.
*
* @return The target virtual host.
*/
public VirtualHost getVirtualHost() {
return (VirtualHost) getNext();
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:9,
代码来源:HostRoute.java
示例19: setNext
点赞 1
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Sets the next virtual host.
*
* @param next
* The next virtual host.
*/
public void setNext(VirtualHost next) {
super.setNext(next);
}
开发者ID:restlet,
项目名称:restlet-framework,
代码行数:10,
代码来源:HostRoute.java
示例20: getHost
点赞 1
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* The virtual host that routed this request.
*
* @return The virtual host
*/
public VirtualHost getHost()
{
return VirtualHostInjector.getVirtualHost( getRequest() );
}
开发者ID:tliron,
项目名称:prudence,
代码行数:10,
代码来源:ConversationService.java
示例21: getVirtualHost
点赞 1
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* The virtual host for the request.
*
* @param request
* The request
* @return The virtual host
*/
public static VirtualHost getVirtualHost( Request request )
{
return (VirtualHost) request.getAttributes().get( ATTRIBUTE );
}
开发者ID:tliron,
项目名称:prudence,
代码行数:12,
代码来源:VirtualHostInjector.java
示例22: VirtualHostInjector
点赞 1
import org.restlet.routing.VirtualHost; //导入依赖的package包/类
/**
* Constructor.
*
* @param context
* The context
* @param virtualHost
* The virtual host
*/
public VirtualHostInjector( Context context, VirtualHost virtualHost )
{
super( context );
this.virtualHost = virtualHost;
}
开发者ID:tliron,
项目名称:prudence,
代码行数:14,
代码来源:VirtualHostInjector.java