Unlock Spring frame pose 1

Posted by g.grillo on Sun, 01 Dec 2019 09:58:50 +0100

Spring

Introduction: spring framework is a Java platform, which provides comprehensive infrastructure support for Java application development. Spring is responsible for infrastructure, so you can focus on application development.
Spring allows you to build applications from "plain old Java objects" (POJO) and implement enterprise application services through non-invasive POJO. This function is applicable to the programming model of Java SE, and all or part of it is applicable to the Java EE model.

Ioc (dependency injection)

1. What: it used to take the initiative to go to new when creating objects. ioc mode provides ioc service provider, which solves the problem that the injected object depends on the dependent object and reduces the coupling.
2. Dependency injection mode
a) constructor injection
B) setter injection
c) interface injection, which is more invasive and less used

Ioc two main containers

Beanfactory container (Interface)

//The root interface for accessing a Spring bean container.
//Access the root interface of the Spring bean container.
public interface BeanFactory {
    String FACTORY_BEAN_PREFIX = "&";

    //Returns an instance of the specified bean, which can be shared or stand-alone.
    Object getBean(String var1) throws BeansException;

    //Returns an instance of the specified bean, which can be shared or stand-alone.
    <T> T getBean(String var1, Class<T> var2) throws BeansException;

    //Returns an instance of the specified bean, which can be shared or stand-alone.
    <T> T getBean(Class<T> var1) throws BeansException;

    //Returns an instance of the specified bean, which can be shared or stand-alone.
    Object getBean(String var1, Object... var2) throws BeansException;

    //Returns an instance of the specified bean, which can be shared or stand-alone.
    <T> T getBean(Class<T> var1, Object... var2) throws BeansException;
    
    //Does this bean factory contain a bean definition with the given name or a singleton instance registered externally?
    boolean containsBean(String var1);

    //Is this bean a shared singleton?
    boolean isSingleton(String var1) throws NoSuchBeanDefinitionException;
    
    //Is ben a prototype? That is to say, {@ link ා getBean} always returns an independent instance?
    boolean isPrototype(String var1) throws NoSuchBeanDefinitionException;

    //Checks whether the bean with the given name matches the specified type.
    boolean isTypeMatch(String var1, ResolvableType var2) throws NoSuchBeanDefinitionException;

    //Checks whether the bean with the given name matches the specified type.
    boolean isTypeMatch(String var1, Class<?> var2) throws NoSuchBeanDefinitionException;

    //Determines the type of bean with the given name. More specifically, * determines the type of object that {@ link ා getBean} will return for the given name
    Class<?> getType(String var1) throws NoSuchBeanDefinitionException;
    
    //Returns the alias, if any, for the given bean name. *When used in the {@ link ා getBean} call, all of these aliases point to the same bean.
    String[] getAliases(String var1);
}

Applicationcontext container (Interface)

public interface ApplicationContext extends EnvironmentCapable, 
ListableBeanFactory, HierarchicalBeanFactory, MessageSource, ApplicationEventPublisher, ResourcePatternResolver {
   
    //Returns the unique ID of this application context.
    String getId();
    
    //Returns the name of the deployed application to which this context belongs.
    String getApplicationName();

    //Returns the friendly name of this context
    String getDisplayName();

    //Returns a timestamp when this context is first loaded.
    long getStartupDate();

    //Returns the parent context, or {@ code null} if there is no parent, which is the root of the context hierarchy.
    ApplicationContext getParent();

    //Exposes AutowireCapableBeanFactory functionality for this context.
    AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException;
}



From the inheritance relationship, we can see that the function of Applicationcontext container is stronger than that of Beanfactory container

Reference resources:

http://ifeve.com/overview-get...

Mobile terminal public address

Welcome to the public bl, share Java related information technology and life insights.

Topics: Java Spring Programming less