Refine search
public AdminRestletResource() { _helixMirrorMakerManager = (HelixMirrorMakerManager) getApplication().getContext() .getAttributes().get(HelixMirrorMakerManager.class.toString()); }
/** * Returns the parent application if it exists, or null. * * @return The parent application if it exists, or null. */ public Application getApplication() { return Application.getCurrent(); }
_component.getClients().add(Protocol.WAR); final Context applicationContext = _component.getContext().createChildContext(); applicationContext.getAttributes().put(ControllerConf.class.toString(), _config); applicationContext.getAttributes().put(HelixMirrorMakerManager.class.toString(), _helixMirrorMakerManager); applicationContext.getAttributes().put(ValidationManager.class.toString(), _validationManager); _controllerRestApp.setContext(applicationContext);
public static Context getCurrentApplicationContext() { Application application = Application.getCurrent(); if (application == null) { return null; } return application.getContext(); }
/** * 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; }
/** * Called by OSGi DS to inject the router provider service * * @param routerProvider * the router provider service */ public void bindRouterProvider(RouterProvider routerProvider) { this.routerProvider = routerProvider; if (application != null) application.setInboundRoot(routerProvider .getInboundRoot(application.getContext())); }
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."); parentContext.createChildContext()); final Context applicationContext = application.getContext(); .getInitParameterNames(); enum1.hasMoreElements();) { initParam = enum1.nextElement(); applicationContext.getParameters().add(initParam, servletConfig.getInitParameter(initParam));
.getDescription())); if (application.toString().equals(application.getName())) { LOGGER.log(Level.WARNING, "Please provide a name to your application by overriding its method getName. Used " contract.setName(application.getClass().getSimpleName()); } else { contract.setName(application.getName()); application.getInboundRoot(), null /*
application.setContext(new ServletContextAdapter(this, parentContext)); } catch (NoSuchMethodException e) { final Context applicationContext = application.getContext(); .getInitParameterNames(); enum1.hasMoreElements();) { initParam = enum1.nextElement(); applicationContext.getParameters().add(initParam, servletConfig.getInitParameter(initParam)); .getInitParameterNames(); enum1.hasMoreElements();) { initParam = enum1.nextElement(); applicationContext.getParameters().add(initParam, getServletContext().getInitParameter(initParam));
final Context appContext = Application.getCurrent().getContext(); final ExecutorService opPool = (ExecutorService) appContext.getAttributes().get("asyncOperationPool"); final ConcurrentHashMap<String, Future> opStatuses = (ConcurrentHashMap<String, Future>) appContext.getAttributes().get( "asyncOperationStatuses");
if (isStopped()) { super.start(); if (getHelper() != null) { getHelper().start(); if (getConnectorService() != null) { getConnectorService().start(); if (getConverterService() != null) { getConverterService().start(); if (getDecoderService() != null) { getDecoderService().start(); if (getMetadataService() != null) { getMetadataService().start(); if (getRangeService() != null) { getRangeService().start(); if (getStatusService() != null) { getStatusService().start(); if (getTaskService() != null) { getTaskService().start(); if (getTunnelService() != null) { getTunnelService().start();
/** * 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; }
if (Application.getCurrent() != null && !Application.getCurrent().isDebugging()) { Context.getCurrentLogger() .log(Level.WARNING, "The cause of the exception should be null except in debug mode"); representationObject, variant); } catch (Exception e) { Context.getCurrentLogger().log( Level.WARNING, "Could not serialize throwable class "
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); } } }); }
@Override public synchronized void start() throws Exception { setName( polygeneApplication.name() ); Series<Parameter> parameters = getContext().getParameters(); String mode = parameters.getFirstValue( "org.apache.polygene.runtime.mode" ); super.start(); getLogger().info( "RestApplication successfully started." ); }
metadataService = Application.getCurrent().getMetadataService(); StringTokenizer stt = new StringTokenizer(extensions, "."); while (stt.hasMoreTokens()) {
Router router = new Router(); // Remove final from this. router.attachDefault(HttpListener.class); Component component = new Component(); Context ctx = component.getApplication().getContext().createChildContext(); // Remove final ctx.getAttributes().put("mysharedobj", new MySharedObj()); org.restlet.Application myApp = new org.restlet.Application(ctx) { @Override public org.restlet.Restlet createInboundRoot() { return router; }; };
Filter filter = null; for (Service service : getHelped().getServices()) { if (service.isEnabled()) { : getContext().createChildContext()); : getContext().createChildContext()); setInboundNext(getHelped().getInboundRoot());
/** * Returns the metadata service of the parent application. * * @return The metadata service of the parent application. */ public MetadataService getMetadataService() { return getApplication().getMetadataService(); }
@Override public Representation getRepresentation(Status status, Request request, Response response) { // Create the data model Map<String, String> dataModel = new ConcurrentHashMap<String, String>(); dataModel.put("applicationName", Application.getCurrent().getName()); dataModel.put("statusDescription", response.getStatus() .getDescription()); dataModel.put("statusReasonPhrase", response.getStatus() .getReasonPhrase()); // Load the FreeMarker template Representation mailFtl = new ClientResource( LocalReference.createClapReference(getClass().getPackage()) + "/MailStatus.ftl").get(); // Wraps the bean with a FreeMarker representation return new TemplateRepresentation(mailFtl, dataModel, MediaType.TEXT_HTML); }