_controllerRestApp.setContext(applicationContext);
@Override public void setContext(Context context) { super.setContext(context); this.jaxRsRestlet.setContext(context); }
/** * Called to construct the actual application instance. Extenders will * generally override this method. * * @param context * the Restlet application context * @return the newly constructed application instance */ protected Application doCreateApplication(Context context) { // FIXME Workaround for a bug in Restlet 2.1M7 - the context should be // passed to the Application // constructor. Application app = new Application(); app.setContext(context); return app; }
/** * Creates the restlet application that will be used to handle all rest calls * Takes a map of paths to resource classes * <p/> * Use the following three lines to access the routing multibinder: * TypeLiteral<String> pathType = new TypeLiteral<String>() {}; * TypeLiteral<Class<? extends ServerResource>> clazzType = new TypeLiteral<Class<? extends ServerResource>>() {}; * MapBinder<String, Class<? extends ServerResource>> resourceBinder = MapBinder.newMapBinder(binder(), pathType, clazzType); * resourceBinder.bind("/my/path").toInstance(MyResource.class); */ @Provides Application createApplication( FinderFactory factory, Map<String, Class<? extends ServerResource>> routes ) { Context context = new Context(); Application application = new Application(); application.setContext( context ); Router router = new Router( context ); // Set binding rules here for ( Entry<String, Class<? extends ServerResource>> entry : routes.entrySet() ) { final Class<? extends ServerResource> resource = entry.getValue(); logger.info( "Binding '" + entry.getKey() + "' to " + resource ); router.attach( entry.getKey(), factory.finder( resource ) ); } application.setInboundRoot( router ); return application; }
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; } }
_controllerRestApp.setContext(applicationContext);
application.setContext(new ServletContextAdapter(this, parentContext)); } catch (NoSuchMethodException e) {
application.setContext(parentContext.createChildContext()); } catch (NoSuchMethodException e) { log("[Restlet] ServerServlet couldn't invoke the constructor of the target class. Please check this class has a constructor without parameter. The constructor with a parameter of type Context will be used instead.");