/** * {@inheritDoc} * * @param locale * the locale * @return the long time pattern */ @Override public String getLongTimePattern(Locale locale) { return getTranslation(TIME_FORMAT_LONG_KEY, locale); }
/** * Gets client type. * * @return the client type */ @Override public EClientType getClientType() { return getApplicationSession().getClientType(); }
/** * Execute delayed actions. * * @param actionHandler * the action handler */ @Override public void executeDelayedActions(IActionHandler actionHandler) { ((AbstractController) getBackendController()).executeDelayedActions(this); super.executeDelayedActions(actionHandler); }
/** * {@inheritDoc} */ public void checkAccess(ISecurable securable) { SecurityHelper.checkAccess(getApplicationSession().getSubject(), securable, getTranslationProvider(), getLocale()); }
/** * Gets the subject out of the application session. * <p> * {@inheritDoc} * * @return the subject */ @Override public Subject getSubject() { return getApplicationSession().getSubject(); }
/** * To string. * * @return original toString completed with user name. */ @Override public String toString() { return new ToStringBuilder(this).append("user", getApplicationSession().getUsername()).toString(); }
/** * {@inheritDoc} */ @Override protected void applyGateDependencyInjection(IGate gate, IActionHandler actionHandler) { super.applyGateDependencyInjection(gate, actionHandler); if (gate instanceof IApplicationSessionAware && actionHandler instanceof IController) { ((IApplicationSessionAware) gate).setApplicationSession(((IController) actionHandler).getApplicationSession()); } }
/** * Gets a translation provider out of the action context. * * @param context * the action context. * @return the translation provider. */ protected ITranslationProvider getTranslationProvider( Map<String, Object> context) { return getController(context).getTranslationProvider(); } }
/** * Delegates to the master controller if any. * * @param action * the action * @param context * the context */ @Override public synchronized void executeLater(IAction action, Map<String, Object> context) { if (masterController != null) { masterController.executeLater(action, context); } else { super.executeLater(action, context); } }
private static void appendToInternalActionState(Class<?> clazz, IAction action, Map<String, Object> state) throws IllegalAccessException { for (Field field : clazz.getDeclaredFields()) { if (!field.isSynthetic()) { field.setAccessible(true); Object fieldValue = field.get(action); if (fieldValue instanceof IAction) { fieldValue = extractInternalActionState((IAction) fieldValue); } state.put(clazz.getName() + "." + field.getName(), fieldValue); } } Class<?> superClazz = clazz.getSuperclass(); if (superClazz != null && !Object.class.equals(superClazz)) { appendToInternalActionState(superClazz, action, state); } }
/** * Utility method used to extract (recursively through the action chain) the * internal state of an action. This state should be used (using equals) in * order guarantee that the internal state of an action has not changed during * it's execution since actions are meant to be singletons this would violate * thread-safety. * * @param action * the action to extract the internal state for. * @return the internal action chain state. * * @throws IllegalAccessException * whenever an exception occurs accessing the internal private state of the * action through reflection. */ public static Map<String, Object> extractInternalActionState(IAction action) throws IllegalAccessException { HashMap<String, Object> state = new HashMap<>(); appendToInternalActionState(action.getClass(), action, state); return state; }
/** * Dumps the application elements along with their actual types. * * @param args main arguments */ public static void main(String... args) { ListableBeanFactory applicationContext = new ClassPathXmlApplicationContext( "/org/jspresso/framework/application/commons.xml", "/org/jspresso/framework/application/backend/persistence/hibernate/commons-hibernate.xml", "/org/jspresso/framework/application/frontend/commons-frontend.xml", "/org/jspresso/framework/application/mock-config.xml"); String[] beanNames = applicationContext.getBeanDefinitionNames(); Arrays.sort(beanNames, String.CASE_INSENSITIVE_ORDER); for (String beanName : beanNames) { Class<?> beanType = applicationContext.getType(beanName); outputLine(beanName, beanType); String[] aliases = applicationContext.getAliases(beanName); if (aliases != null) { for (String alias : aliases) { outputLine(alias, beanType); } } } }
LoginContext lc; try { lc = new LoginContext(getLoginContextName(), lch); } catch (LoginException le) { LOG.error("Cannot create LoginContext.", le);
/** * {@inheritDoc} */ @Override protected void applyGateDependencyInjection(IGate gate, IActionHandler actionHandler) { super.applyGateDependencyInjection(gate, actionHandler); if (gate instanceof IApplicationSessionAware && actionHandler instanceof IController) { ((IApplicationSessionAware) gate) .setApplicationSession(((IController) actionHandler) .getApplicationSession()); } } }
/** * {@inheritDoc} * * @param locale * the locale * @return the short time pattern */ @Override public String getShortTimePattern(Locale locale) { return getTranslation(TIME_FORMAT_SHORT_KEY, locale); }
/** * {@inheritDoc} * * @param locale * the locale * @return the time pattern */ @Override public String getTimePattern(Locale locale) { return getTranslation(TIME_FORMAT_KEY, locale); }
/** * {@inheritDoc} * * @param locale * the locale * @return the decimal separator */ @Override public String getDecimalSeparator(Locale locale) { return getTranslation(DECIMAL_SEPARATOR_KEY, locale); }
/** * {@inheritDoc} * * @param locale * the locale * @return the thousands separator */ @Override public String getThousandsSeparator(Locale locale) { return getTranslation(THOUSANDS_SEPARATOR_KEY, locale); }
/** * {@inheritDoc} * * @param locale * the locale * @return the date pattern */ @Override public String getDatePattern(Locale locale) { return getTranslation(DATE_FORMAT_KEY, locale); }
/** * {@inheritDoc} * * @param locale * the locale * @return the first day of week */ @Override public int getFirstDayOfWeek(Locale locale) { return Integer.parseInt(getTranslation(FIRST_DAY_OF_WEEK_KEY, Integer.toString(1), locale)); }