Package net.sourceforge.stripes.config

Examples of net.sourceforge.stripes.config.Configuration


     * @param ctx the ExecutionContext being used to process the current request
     * @return a Resolution if any interceptor determines that the request processing should
     *         be aborted in favor of another Resolution, null otherwise.
     */
    public static Resolution resolveHandler(final ExecutionContext ctx) throws Exception {
        final Configuration config = StripesFilter.getConfiguration();
        ctx.setLifecycleStage(LifecycleStage.HandlerResolution);
        ctx.setInterceptors(config.getInterceptors(LifecycleStage.HandlerResolution));

        return ctx.wrap( new Interceptor() {
            public Resolution intercept(ExecutionContext ctx) throws Exception {
                ActionBean bean = ctx.getActionBean();
                ActionBeanContext context = ctx.getActionBeanContext();
                ActionResolver resolver = config.getActionResolver();

                // Then lookup the event name and handler method etc.
                String eventName = resolver.getEventName(bean.getClass(), context);
                context.setEventName(eventName);

View Full Code Here


                                                    final boolean validate) throws Exception {
        // Bind the value to the bean - this includes performing field level validation
        final Method handler = ctx.getHandler();
        final boolean doBind = handler == null || handler.getAnnotation(DontBind.class) == null;
        final boolean doValidate = doBind && validate && (handler == null || handler.getAnnotation(DontValidate.class) == null);
        final Configuration config = StripesFilter.getConfiguration();

        ctx.setLifecycleStage(LifecycleStage.BindingAndValidation);
        ctx.setInterceptors(config.getInterceptors(LifecycleStage.BindingAndValidation));

        return ctx.wrap(new Interceptor() {
            public Resolution intercept(ExecutionContext ctx) throws Exception {
                if (doBind) {
                    ActionBeanPropertyBinder binder = config.getActionBeanPropertyBinder();
                    binder.bind(ctx.getActionBean(), ctx.getActionBeanContext(), doValidate);
                    fillInValidationErrors(ctx);
                }
                return null;
            }
View Full Code Here

        final ValidationErrors errors = ctx.getActionBeanContext().getValidationErrors();
        final ActionBean bean = ctx.getActionBean();
        final Method handler = ctx.getHandler();
        final boolean doBind = handler != null && handler.getAnnotation(DontBind.class) == null;
        final boolean doValidate = doBind && handler.getAnnotation(DontValidate.class) == null;
        Configuration config = StripesFilter.getConfiguration();

        // Run the bean's methods annotated with @ValidateMethod if the following conditions are met:
        //   l. This event is not marked to bypass binding
        //   2. This event is not marked to bypass validation (doValidate == true)
        //   3. We have no errors so far OR alwaysInvokeValidate is true
        if (doValidate) {

            ctx.setLifecycleStage(LifecycleStage.CustomValidation);
            ctx.setInterceptors(config.getInterceptors(LifecycleStage.CustomValidation));

            return ctx.wrap( new Interceptor() {
        public Resolution intercept(ExecutionContext context) throws Exception {
                    // Run any of the annotated validation methods
                    Method[] validations = findCustomValidationMethods(bean.getClass());
View Full Code Here

     *        type conversion should occur
     * @return a Resolution if the error handling code determines that some kind of resolution
     *         should be processed in favor of continuing on to handler invocation
     */
    public static Resolution invokeEventHandler(ExecutionContext ctx) throws Exception {
        final Configuration config = StripesFilter.getConfiguration();
        final Method handler = ctx.getHandler();
        final ActionBean bean = ctx.getActionBean();

        // Finally execute the handler method!
        ctx.setLifecycleStage(LifecycleStage.EventHandling);
        ctx.setInterceptors(config.getInterceptors(LifecycleStage.EventHandling));

        return ctx.wrap( new Interceptor() {
            public Resolution intercept(ExecutionContext ctx) throws Exception {
                Object returnValue = handler.invoke(bean);
                fillInValidationErrors(ctx);
View Full Code Here

     * @param ctx the current execution context representing the request
     * @param resolution the resolution to be executed unless another is substituted by an
     *        interceptor before calling ctx.proceed()
     */
    public static void executeResolution(ExecutionContext ctx, Resolution resolution) throws Exception {
        final Configuration config = StripesFilter.getConfiguration();

        ctx.setLifecycleStage(LifecycleStage.ResolutionExecution);
        ctx.setInterceptors(config.getInterceptors(LifecycleStage.ResolutionExecution));
        ctx.setResolution(resolution);

        Resolution retval = ctx.wrap( new Interceptor() {
            public Resolution intercept(ExecutionContext context) throws Exception {
                ActionBeanContext abc = context.getActionBeanContext();
View Full Code Here

    /**
     * Returns the Configuration that is being used to process the current request.
     */
    public static Configuration getConfiguration() {
        Configuration configuration = StripesFilter.configurationStash.get();

        // If the configuration wasn't available in thread local, check to see if we only
        // know about one configuration in total, and if so use that one
        if (configuration == null) {
            synchronized (StripesFilter.configurations) {
View Full Code Here

    }

    /** Gets a reference to the default configuration, which can be used for simple testing. */
    public static synchronized Configuration getDefaultConfiguration() {
        if (configuration == null) {
            Configuration configuration = new DefaultConfiguration();
            MockFilterConfig filterConfig = new MockFilterConfig();
            filterConfig.addAllInitParameters(getDefaultFilterParams());
            MockServletContext mockServletContext = createServletContext();
            try {
                filterConfig.setServletContext(mockServletContext);
                configuration.setBootstrapPropertyResolver(new BootstrapPropertyResolver(filterConfig));
                configuration.init();
                StripesTestFixture.configuration = configuration;
            } finally {
                mockServletContext.close();
            }
        }
View Full Code Here

    public static String encrypt(String input) {
        if (input == null)
            input = "";

        // encryption is disabled in debug mode
        Configuration configuration = StripesFilter.getConfiguration();
        if (configuration != null && configuration.isDebugMode())
            return input;

        try {
            // First size the output
            Cipher cipher = getCipher(Cipher.ENCRYPT_MODE);
View Full Code Here

    public static String decrypt(String input) {
        if (input == null)
            return null;

        // encryption is disabled in debug mode
        Configuration configuration = StripesFilter.getConfiguration();
        if (configuration != null && configuration.isDebugMode())
            return input;

        // First un-base64 the String
        byte[] bytes = Base64.decode(input, BASE64_OPTIONS);
        if (bytes == null || bytes.length < 1) {
View Full Code Here

     *
     * @return a byte[] of key material, or null
     */
    protected static byte[] getKeyMaterialFromConfig() {
        try {
            Configuration config = StripesFilter.getConfiguration();
            if (config != null) {
                String key = config.getBootstrapPropertyResolver().getProperty(CONFIG_ENCRYPTION_KEY);
                if (key != null) {
                    return key.getBytes();
                }
            }
        }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.config.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.