Spring AOP + AspectJ annotation example (Spring 3.0)Īn example to show you how to integrate AspectJ annotation with Spring framework.However, this example is demonstrated in Spring 3.0. The sequence of the AOP interceptor will affect the functionality.Īn auto proxy creator example to create proxy object for your beans automatically, useful to avoid creating many duplicated proxy objects.ĪspectJ supported since Spring 2.0, more flexible and powerful. Spring AOP Example – Pointcut, AdvisorĮxamples and explanations about different types of Spring’s Pointcut and Advisor.Put it simply, an interceptor to intercept some methods.Įxamples and explanations about different types of Spring’s advices. The Spring AOP modularize cross-cutting concerns in aspects. It means choosing “autowire by constructor” if default constructor is found, otherwise uses “autowire by type”.Įxamples to show how to define ‘auto-wiring’ modes in annotation.Įxample to identify which bean is qualified to autowired on a field. If the name of a bean is same as the name of another bean property, auto wire it.Īctually, it’s autowiring by Type in constructor argument. If the data type of a bean is compatible with the data type of other bean property, auto wire it. Summary of 5 types auto wiring modes in Spring. Spring ‘auto-wiring’ modes to wire or beans automatically, both in XML and annotation. Spring Filter components in auto scanningĮxample to filter certain components in auto scanning mode.Spring is able to scan, detect and register your bean automatically.Įnable Spring to auto scan, detect and register your beans. The regular expression to evaluate the condition. Spring EL ternary operator (if-then-else) example.Spring EL supports most of the standard relational, logical and mathematical operators. Reference bean, bean property using a dot (.) symbol. Quick start to use the Spring expression language (EL). Spring 3.0 introduces features rich and powerful expression language known as Spring expression language, or Spring EL. Perform certain actions upon bean initialization and destruction. Bean init-method and destroy-method example.Bean InitializingBean and DisposableBean example.Spring dependency checking with AnnotationĬreate a custom annotation ,which is equivalent to annotation.Spring comes with 4 dependency checking modes to make sure the required properties have been set in bean. Inheritance is very useful for a bean to share common values, properties or configuration. Spring PropertyPlaceholderConfigurer exampleĮxternalize the deployment details into a properties file, and access from a bean configuration file via a special format – $.Normally, Spring is accepting date variable, here’s a tip to use CustomDateEditor to work around it. Spring inject Date into bean property – CustomDateEditor.Spring Collections (List, Set, Map, and Properties) exampleĮxample to inject values into collections type (List, Set, Map, and Properties).Ĭreate a concrete List collection class (ArrayList and LinkedList), and inject it into bean property.Ĭreate a concrete Set collection class (HashSet and TreeSet), and inject it into bean property.Ĭreate a concrete Map collection class (HashMap and TreeMap), and inject it into bean property.Whenever a bean is used for one particular property only, it’s always advised to declare it as an inner bean.īean scope is used to decide which type of bean instance should be return from the Spring container back to the caller. Load multiple Spring bean configuration fileĭevelopers always categorize different bean configuration files in different modules folder, here’s a tip to show you how to load multiple Spring bean configuration files.Three ways to inject value into bean properties. Inject value into bean properties in Spring.How beans access to each other by specify the bean references in the same or different bean configuration file. All the classes you need to use in Spring Ioc container are considered “bean”, and declared in a Spring bean configuration file or via annotation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |