cool hit counter Continued from above_Intefrankly

Continued from above


1. speak outSpring of Type of notification what are the?

spring provides a total of five types of notifications.

Type of notification



Around Notification


Intercepting calls to target methods

Before Pre-notification


Called before the target method call

After Post-notification


Called after the target method call

Throws exception notification


Called when the target method throws an exception

Before advice]: Executed before the join point, before advice does not affect the execution of the join point, unless an exception is thrown here.

Normal return advice [After returning advice]: executed after the normal execution of the join point has completed, or not executed if the join point throws an exception.

After throwing advice]: executed after an exception is thrown by the connection point.

Return notification [After (finally) advice]: executed after the completion of the execution of the join point, whether it completes normally or throws an exception, the contents of the return notification will be executed.

Circulars[Around advice]: Wrap-around notices surround the connection point before and after, For example, before and after a method call。 This is the most powerful Type of notification, Ability to customize some operations before and after method calls。

<bean id="myMethodBeforeAdvice" class="com.cdtax.aop.MyMethodBeforeAdvice"></bean>
<!--  Configuring post-notification -->
<bean id="myAfterReturningAdvice" class="com.cdtax.aop.MyAfterReturningAdvice"></bean>
<!--  Configuring proxy objects -->
<bean id="proxyFactoryBean" class="org.springframework.aop.framework.ProxyFactoryBean"> 
<!--  agent interface collect -->
    <property name="proxyInterfaces">
    <!--  Weave notifications into the proxy object  |  Set of interceptor names-->
    <property name="interceptorNames">
        <!--  equivalent to putting MyMethodBeforeAdvice Pre-notification and proxy objects are associated, We can also think of notifications as interceptors,struts2 The core is the interceptor -->
        <!--  Weaving in post-notification -->
    <!--  Configuring the Proxied Object, You can specify -->
    <property name="target" ref="test1Service">

2. Talk about target object realization interface Not achieved with the target audience interface What's the difference??

(1) If the target object implements an interface, the default is to use the JDK's dynamic proxy mechanism to implement AOP

(2) If the target object implements the interface, you can force spring to use CGLIB to implement the proxy

(3) If the target object does not implement the interface, CGLIB must be used to implement the proxy, spring will automatically switch between CGLIB and JDK dynamic proxy

3. Please describe the difference between JDK dynamic proxy and CGLI proxy?

jdk A dynamic proxy is a target class that implements the interface, and cannot target the class;

CGLI A dynamic proxy is a target class that does not implement interface。 The main thing is to generate a subclass of the specified class, Override the methods in it。

4. Briefly explain what is the role of ProxyFactoryBean?

The role of the ProxyFactoryBean is to apply the cut to the target object in accordance with the configuration information to generate a dynamic proxy object

5. Describe the principle of auto-proxy in Spring?

Spring When generating a proxy object, By default, will use the proxied object's interface to generate proxy objects。 If the proxied object does not implement interface, this time,Spring useableCGLIB Generate proxy objects, At this point the proxy object is a subclass of the object being proxied。

5. Write what are the three elements that need to be specified to create a proxy object?

(1) Set the target object [target] (2) Set the proxy interface [interface] (3) Set the name of the interceptor [which notification to use]

6. Please briefly describe: what is AOP? Briefly describe the AOP core?

Extracting the cross business logic from the program is called a cut. The process of dynamically weaving these cuts into the target object and then generating a proxy object.

AOP core mainly includes the following: (1) Aspect (cut), (2) Joinpoint (connection point), (3) Advice (notification), (4) Pointcut (entry point), (5) Introduction (introduction), (6) Weaving (weaving), (7) Target (target object), (8) Proxy (proxy object)

7. Please describe the meaning of AOP transactions?

The usual way of transaction management in Spring is to encapsulate transaction control for normal java classes using AOP (slice oriented programming), which is implemented through dynamic proxies, and since the interface is instantiated delayed, spring loads the transaction slices in the meantime, through interceptors.

8. Please briefly describe the working mechanism of Spring? Why use Spring's working mechanism?

The working mechanism is IOC, IOC is the idea, dependency injection is the implementation, and the idea of AOP 1.Use IOC to maximize decoupling of object dependencies 2.Uncoupling between modules or components using AOP 3.Simplifying the code of other frameworks 4.It is the lubricant and glue between the frames 5.spring is designed to be non-intrusive. It doesn't feel like it's there in the code 6.spring is a dependency-free design. spring does not depend on any framework and has no dependencies of its own

3. Please briefly describe what Spring is?

Spring is a lightweight container, a lightweight implementation of the J2EE specification, and a "one-stop shop" solution for enterprise applications. The core of this is the bean factory, which is used to construct the Model we need. spring is non-intrusive, and objects in Spring applications do not depend on Spring-specific classes.

4. Briefly describe the components of spring?

Spring consists of six main components.

① Spring Core: the core container, BeanFactory provides component lifecycle management, component creation, assembly, destruction and other functions.

②SpringContext:ApplicationContext, Extended core container, Provide event handling、 Internationalization and other functions。 It offers a number of features for enterprise level services, providesJNDI,EJB,RMI support of。

② Spring AOP: provides tangent support.

③ Spring DAO: provides transaction support, JDBC, DAO support.

④ Spring ORM: Encapsulation or support for popular O/R Mapping.

⑤ Spring Web: provides web application context, providing functional support for web development, such as requests, forms, exceptions, etc.

⑥ Spring Web MVC: full-featured MVC framework , the role is equivalent to Struts .

5.Briefly describe what features are provided by the Spring container?

Spring container provides the management of objects such as Spring container is responsible for generating, assembling and destroying components,, in addition Spring container also provides support for persistence, support for transactions. In addition the Spring container provides features such as internationalization.

6. Describe the advantages of setting value injection?

The advantages of setting up injection: (1) It is more similar to the traditional way of writing JavaBean and is easier for program developers to understand and accept. Setting dependencies via the setter method seems more intuitive and natural. (2) For having complex dependencies, using construction injection would result in a constructor that is too bloated and difficult to read. Spring needs to instantiate all instances of its dependencies at the same time when creating bean instances, thus leading to performance degradation, which can be solved by using set-value injection. (3) Especially if certain attributes are optional, multi-parameter constructors are more unwieldy.

7. Please describe the advantages of construct injection?

Reference Answer: Advantages of Construct Injection: (1) The order of injection of dependencies can be decided in the constructor, and priority dependencies are injected first. (2) For beans whose dependencies do not need to change, construct injection is more useful. Since there is no setter method, all dependencies are set within the constructor, so there is no need to worry about subsequent code breaking dependencies. (3) Dependencies can only be set in the constructor, and then only the creator of the formation can change the dependencies of the formation. The dependencies within the formation are completely transparent to the caller of the formation and are more consistent with the principle of high cohesion.

8. Please briefly describe your understanding of the IOC? What are the biggest benefits of IoC

IOC that is Inversion of Control, is the inversion of control, Ioc moves the responsibility of control creation into the framework and separates it from the application code, using the Ioc container then need to point out what objects the component needs at runtime container will provide it, the container is done by looking at the object's parameter table, but also may be based on configuration data such as xml.

The biggest benefit of IoC is that it reduces the coupling of objects and enables loose coupling of applications. Because the object generation is defined in the XML, when we need to change the implementation of a subclass will become very simple (generally such objects are realistic in some kind of interface), just modify the XML can be.

9. Briefly describe the types of IoC injection?

IOC can be divided into three types of injection, which are constructor injection, property injection and interface injection. Spring mainly supports constructor injection and property injection.

10. What is the difference between dependency injection and traditional programming in Spring?

Reference Answer: In the traditional programming process, it is usually up to the caller to create the instance of the callee. However, in Spring, the job of creating the callee is no longer done by the caller, hence the term control reversal; the job of creating the callee instance is usually done by the Spring container and then injected into the caller, hence the term dependency injection. The main role of dependency injection is to act as a decoupling agent.

1、Basic Introduction to SQL II
2、Dynamic lock screen wallpaper tutorial
3、Testing a Netflix brand of beans is better than expected
4、Javainfrastructuralgt Programming Fundamentals
5、Iron Man made three arrangements to protect Earth and after two failed attempts he even dared to take his life

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送