All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nanocontainer.nanowar.RequestScopeObjectReference Maven / Gradle / Ivy

The newest version!
/*****************************************************************************
 * Copyright (C) NanoContainer Organization. All rights reserved.            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *                                                                           *
 *****************************************************************************/
package org.nanocontainer.nanowar;

import org.picocontainer.defaults.ObjectReference;

import javax.servlet.ServletRequest;

/**
 * References an object that lives as an attribute of the
 * ServletRequest.
 *
 * @author Joe Walnes
 */
public class RequestScopeObjectReference implements ObjectReference {

    private ServletRequest request;
    private String key;

    public RequestScopeObjectReference(ServletRequest request, String key) {
        this.request = request;
        this.key = key;
    }

    public void set(Object item) {
        request.setAttribute(key, item);
    }

    public Object get() {
        return request.getAttribute(key);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy