/** * Returns the helped Restlet context. * * @return The helped Restlet context. */ @Override public Context getContext() { if (Edition.CURRENT == Edition.GWT) { return null; } return super.getContext(); }
/** * Returns the actual ephemeral port used when the listening port is set to * '0'. The default value is '-1' if no ephemeral port is known. See * InetSocketAddress#InetSocketAddress(int) and ServerSocket#getLocalPort() * methods for details. * * @return The actual ephemeral port used. */ public int getEphemeralPort() { return (Integer) getHelper().getAttributes().get("ephemeralPort"); }
/** * Returns the helped Restlet context. * * @return The helped Restlet context. */ public Context getContext() { return getHelped().getContext(); }
SslContextFactory result = (SslContextFactory) ((helper.getContext() == null) ? null : helper.getContext().getAttributes().get("sslContextFactory")); String[] sslContextFactoryNames = helper.getHelpedParameters() .getValuesArray("sslContextFactory"); SslContextFactory.class); result = sslContextFactoryClass.newInstance(); result.init(helper.getHelpedParameters()); } catch (ClassNotFoundException e) { Context.getCurrentLogger().log( result.init(helper.getHelpedParameters());
@Override public synchronized void stop() throws Exception { if (isStarted()) { // Must be invoked as a first step super.stop(); if (getHelper() != null) { getHelper().stop(); } } }
@Override public synchronized void start() throws Exception { if (isStopped()) { if (getHelper() != null) { getHelper().start(); } // Must be invoked as a last step super.start(); } }
@Override public void handle(Request request, Response response) { super.handle(request, response); if (getHelper() != null) { getHelper().handle(request, response); } else { StringBuilder sb = new StringBuilder(); sb.append("No available client connector supports the required protocol: "); sb.append("'").append(request.getProtocol().getName()).append("'."); sb.append(" Please add the JAR of a matching connector to your classpath."); response.setStatus(Status.CONNECTOR_ERROR_INTERNAL, sb.toString()); } }
SslContextFactory result = (SslContextFactory) ((helper.getContext() == null) ? null : helper.getContext().getAttributes().get("sslContextFactory")); String[] sslContextFactoryNames = helper.getHelpedParameters() .getValuesArray("sslContextFactory"); SslContextFactory.class); result = sslContextFactoryClass.newInstance(); result.init(helper.getHelpedParameters()); } catch (ClassNotFoundException e) { Context.getCurrentLogger().log( result.init(helper.getHelpedParameters());
@Override public synchronized void stop() throws Exception { if (isStarted()) { // Must be invoked as a first step super.stop(); if (getHelper() != null) { getHelper().stop(); } } }
@Override public synchronized void start() throws Exception { if (isStopped()) { if (getHelper() != null) { getHelper().start(); } // Must be invoked as a last step super.start(); } }
@Override public void handle(Request request, Response response) { super.handle(request, response); if (getFirstInboundFilter() != null) { getFirstInboundFilter().handle(request, response); } else { final Restlet next = this.inboundNext; if (next != null) { next.handle(request, response); } else { response.setStatus(Status.SERVER_ERROR_INTERNAL); getHelped() .getLogger() .log(Level.SEVERE, "The " + getHelped().getClass().getName() + " class has no Restlet defined to process calls. Maybe it wasn't properly started."); } } }
SslContextFactory result = (SslContextFactory) ((helper.getContext() == null) ? null : helper.getContext().getAttributes().get("sslContextFactory")); String[] sslContextFactoryNames = helper.getHelpedParameters() .getValuesArray("sslContextFactory"); SslContextFactory.class); result = sslContextFactoryClass.newInstance(); result.init(helper.getHelpedParameters()); } catch (ClassNotFoundException e) { Context.getCurrentLogger().log( result.init(helper.getHelpedParameters());
/** * Handles a call. * * @param request * The request to handle. * @param response * The response to update. */ public void handle(Request request, Response response) { // Associate the response to the current thread Response.setCurrent(response); // Associate the context to the current thread if (getContext() != null) { Context.setCurrent(getContext()); } }
/** * Returns the helped Restlet parameters. * * @return The helped Restlet parameters. */ public Series<Parameter> getHelpedParameters() { Series<Parameter> result = null; if ((getHelped() != null) && (getHelped().getContext() != null)) { result = getHelped().getContext().getParameters(); } else { result = new Series<Parameter>(Parameter.class); } return result; }
/** * Returns the metadata service. If the parent application doesn't exist, a * new instance is created. * * @return The metadata service. */ public MetadataService getMetadataService() { MetadataService result = null; if (getHelped() != null) { org.restlet.Application application = getHelped().getApplication(); if (application != null) { result = application.getMetadataService(); } } if (result == null) { result = new MetadataService(); } return result; }