ChallengeScheme.HTTP_DIGEST, "Authentication Required"); guard.getSecrets().put(authLogin, authPassword.toCharArray()); component.getDefaultHost().attach(guard); guard.setNext(new EngineApplication(engine)); component.start();
host.setHostDomain(item.getNodeValue()); host.setHostPort(item.getNodeValue()); host.setHostScheme(item.getNodeValue()); host.setName(item.getNodeValue()); host.setResourceDomain(item.getNodeValue()); host.setResourcePort(item.getNodeValue()); host.setResourceScheme(item.getNodeValue()); host.setServerAddress(item.getNodeValue()); host.setServerPort(item.getNodeValue());
log("[Noelios Restlet Engine] - 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(
parseHost(getDefaultHost(), childNode); } else if ("host".equals(childNode.getNodeName())) { final VirtualHost host = new VirtualHost(getContext()); parseHost(host, childNode); getHosts().add(host);
@Override protected int beforeHandle(Request request, Response response) { final int result = super.beforeHandle(request, response); // Set the request's root reference request.setRootRef(request.getResourceRef().getBaseRef()); // Save the hash code of the current host setCurrent(VirtualHost.this.hashCode()); return result; } };
public void execute(final Runnable runnable) { // Save the thread local variables final Application currentApplication = Application.getCurrent(); final Context currentContext = Context.getCurrent(); final Integer currentVirtualHost = VirtualHost.getCurrent(); final Response currentResponse = Response.getCurrent(); executorService.execute(new Runnable() { public void run() { // Copy the thread local variables Response.setCurrent(currentResponse); Context.setCurrent(currentContext); VirtualHost.setCurrent(currentVirtualHost); Application.setCurrent(currentApplication); try { // Run the user task runnable.run(); } finally { // Reset the thread local variables Response.setCurrent(null); Context.setCurrent(null); VirtualHost.setCurrent(-1); Application.setCurrent(null); } } }); }
/** * Creates a new finder instance based on the "targetClass" property. * * In addition to super class behavior, this method will set the context of * the finder by creating a protected context via the * {@link Context#createChildContext()} method. * * @param targetClass * The target Resource class to attach. * @return The new finder instance. */ @Override protected Finder createFinder(Class<? extends Resource> targetClass) { Finder result = super.createFinder(targetClass); result.setContext(getContext().createChildContext()); return result; }
this.defaultHost = new VirtualHost(getContext()); this.internalRouter = new Router(getContext() .createChildContext()) {
/** * Attaches a target Restlet to the default host. * * @param target * The target Restlet. */ public void setDefaultTarget(Restlet target) { getDefaultHost().attach(target); }
ChallengeScheme.HTTP_DIGEST, "Authentication Required"); guard.getSecrets().put(authLogin, authPassword.toCharArray()); component.getDefaultHost().attach(guard); guard.setNext(new EngineApplication(engine)); component.start();