The first day of Spring

1.Spring ioc

  Inversion of Control, to solve the problem completely dependent on the top of the lower layer, the upper layer to achieve control of the lower

  The underlying principle: xml + reflector + Analytical vessel design patterns +

  Note xml files must be placed under the src directory

  Gets the container in three ways:

  ① ApplicationContext context=new ClassPathXmlApplicationContext("xml文件名");

  ApplicationContext context = new new ②   FileSystemXmlApplicationContext (absolute path in the local directory)

  ③ ApplicationContext context = new xmlBeanFactory ( "Resource File") // Obsolete

  Gets the object from the bean container two ways

  ① achieved by reflection

  ② configured through the xml id or name

  note

    Achieved by reflection, xml configuration corresponding to only one class is the only class

    xml configuration id is unique

  javaBean create opportunity

    When the object is a singleton, it will be executed when the container load created when the object is a multi-mode example, will get executed when the container object from.

    The default mode Spring single embodiment, may be provided in the design pattern disposed scope attribute bean,

    singleton: singleton pattern (default)

    prototype: multiple columns

  

2.Of

 Ioc idea is realized through xml configuration automatically manage the javaBean.

 Implementation: configuration or add annotations in xml

3. Built-bean and bean External 

  All external bean bean settings are available, only their own built-in bean bean available

4. Custom ioc steps of:

  Guide package

  Create objects parse the xml

  Create a file input stream and read xml file

  Parse xml file

  Get with the label

  Gets the label with the under label

  Under the label traversal with label

  Get id

  Get class

  Get byte code file by reflecting

  Create objects based bytecode object

  The acquired id map with the object into the collection

  Gets the label under sub-tab

  Traversing the sub-tab under sub-tab

  Gets the name attribute

  Acquiring property ref

  Get the object by key map according to the acquired attribute ref

  Acquisition method name

  Acquisition method by reflection

  Call invoke execution method 

  

 

Guess you like

Origin www.cnblogs.com/sunners/p/12051538.html