/** * Back controller is retrieved from the spring context and started. */ protected void startController() { try { // start on brand new instance. IBackendController backendController = (IBackendController) getApplicationContext() .getBean("applicationBackController"); BackendControllerHolder.setThreadBackendController(backendController); backendController.start(getStartupLocale(), getClientTimeZone()); } catch (RuntimeException ex) { LOG.error("applicationBackController could not be instantiated.", ex); throw ex; } }
/** * {@inheritDoc} */ @Override public void start() { startController(); }
/** * Executes a backend action. * * @param action * the backend action to execute. * @param initialContext * the initial action context. * @param subject * the JAAS subject to execute the action for. * @param locale * the locale used to execute the action. * @return true if the action execution was successful. */ protected boolean executeAction(BackendAction action, Map<String, Object> initialContext, Subject subject, Locale locale) { configureApplicationSession(subject, locale); Map<String, Object> startupActionContext = new HashMap<>(); startupActionContext.putAll(getBackendController() .getInitialActionContext()); startupActionContext.putAll(initialContext); boolean success = getBackendController().execute(action, startupActionContext); return success; }
/** * Configures session on the backend controller. * * @param subject * the JAAS subject containing the user principal. * @param locale * the locale to use. */ protected void configureApplicationSession(Subject subject, Locale locale) { IApplicationSession session = getBackendController() .getApplicationSession(); session.setSubject(subject); session.setLocale(locale); }
/** * {@inheritDoc} */ @Override public void start() { try { super.start(); executeAction(); } finally { IBackendController bc = getBackendController(); if (bc != null) { bc.cleanupRequestResources(); } } }