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

org.picocontainer.behaviors.Guarded Maven / Gradle / Ivy

There is a newer version: 2.15
Show newest version
/*****************************************************************************
 * Copyright (C) PicoContainer 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.picocontainer.behaviors;

import org.picocontainer.ComponentAdapter;
import org.picocontainer.LifecycleStrategy;
import org.picocontainer.ObjectReference;
import org.picocontainer.PicoCompositionException;
import org.picocontainer.PicoContainer;
import org.picocontainer.ComponentLifecycle;

import java.lang.reflect.Type;
import java.io.Serializable;

/**
 * behaviour for allows components to be guarded by another component
 *
 * @author Paul Hammant
 * @param 
 */
@SuppressWarnings("serial")
public class Guarded extends AbstractBehavior {
    private final String guard;

    public Guarded(ComponentAdapter delegate, String guard) {
        super(delegate);
        this.guard = guard;
    }

    public T getComponentInstance(PicoContainer container, Type into) throws PicoCompositionException {
        container.getComponent(guard);
        return super.getComponentInstance(container, into);
    }

    public String getDescriptor() {
        return "Guarded(with " + guard + ")";
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy