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

com.blade.ioc.Container Maven / Gradle / Ivy

/**
 * Copyright (c) 2015, biezhi 王爵 ([email protected])
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.blade.ioc;

import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * IOC container top interface
 *
 * @author	biezhi
 * @since	1.0
 */
public interface Container {

	/**
	 * According to the bean name and object function to obtain a bean object
	 * 
	 * @param name		bean name
	 * @param scope		object scope, single case or each time it is created
	 * @param  		generic
	 * @return			return object
	 */
	 T getBean(String name, Scope scope);

    /**
     * According to the class and the object function to obtain a bean object
     * 
     * @param type		class type
     * @param scope		object scope, single case or each time it is created
     * @param  		generic
     * @return			return object
     */
     T getBean(Class type, Scope scope);

    /**
     * @return Return the name of all bean
     */
    Set getBeanNames();
    
    /**
     * @param  		generic
     * @return Return a collection of all bean
     */
     Collection getBeans();
    
    /**
     * Class bean set in the IOC container for matching based on annotations
     * 
     * @param annotation	annotation class type
     * @return				return all class by annotation
     */
    List> getClassesByAnnotation(Class annotation);
    
    /**
     * To obtain a set of bean objects that match the IOC container
     * 
     * @param annotation	annotation class type
     * @param  			generic
     * @return				return all bean by annotation
     */
     List getBeansByAnnotation(Class annotation);
    
    /**
     * To determine if there is a bean, according to the class type
     * 
     * @param clazz		class type
     * @return			return class is exist
     */
    boolean hasBean(Class clazz);

    /**
     * According to name Bena to determine whether there is
     * 
     * @param name		bean name, usually class name
     * @return			return class is exist
     */
    boolean hasBean(String name);
    
    /**
     * Remove an bean object from the IOC container by name
     * 
     * @param clazz			to remove the class bean type 
     * @return				return if remove success 
     */
    boolean removeBean(Class clazz);
    
    /**
     * @return	clean container
     */
    boolean removeAll();
    
    /**
     * To determine whether the comment in the annotations can be registered into the IOC container
     * 
     * @param annotations	annotation array to detect 
     * @return				return is register
     */
    boolean isRegister(Annotation[] annotations);

    /**
     * Register an object to the bean container
     * 
     * @param object	bean object
     * @return			return register bean
     */
    Object registerBean(Object object);
    
    /**
     * Initialization IOC injection 
     */
    void initWired();
    
    /**
     * Inject a object 
     * @param object	to inject object 
     */
    void injection(Class clazz, Object object);
    
    /**
     * @return Returns the all bean objects in the IOC container
     */
    Map, Object> getBeanMap();
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy