|
1 |
| ------------------ Spring ----------------- |
2 |
| -
|
3 |
| -Basic idea of IoC pattern. Benefits. |
4 |
| - By applying DI in your projects, you�ll find that your code will |
5 |
| - become significantly simpler, easier to understand, and easier to test. |
6 |
| - With DI, objects are given their dependencies at creation time |
7 |
| - by some third party that coordinates each object in the system. Objects aren�t |
8 |
| - expected to create or obtain their dependencies�dependencies are injected into the |
9 |
| - objects that need them. |
10 |
| - The key benefit of DI�loose coupling. If an object only knows about its |
11 |
| - dependencies by their interface (not by their implementation or how they�re |
12 |
| - instantiated), then the dependency can be swapped out with a different |
13 |
| - implementation without the depending object knowing the difference. |
14 |
| - One of the most common ways that a dependency will be swapped out is with a |
15 |
| - mock implementation during testing. |
16 |
| -
|
17 |
| -What is Spring configuration file? How does it look like? |
18 |
| - <?xml version="1.0"encoding="UTF-8"?> |
19 |
| - <beans xmlns="http://www.springframework.org/schema/beans" |
20 |
| - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
21 |
| - xsi:schemaLocation="http://www.springframework.org/schema/beans |
22 |
| - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" [...] > |
23 |
| -
|
24 |
| - [...] |
25 |
| - <bean id="knight"class="com.springinaction.knights.BraveKnight"> <constructor-argref="quest"/> </bean> |
26 |
| - <bean id="quest" class="com.springinaction.knights.SlayDragonQuest"/> |
27 |
| - [...] |
28 |
| -
|
29 |
| - </beans> |
30 |
| -
|
31 |
| -Out of the box bean scopes (singleton, prototype, request, session, global session) |
32 |
| - singleton Scopes the bean definition to a single instance per Spring container (default). |
33 |
| - prototype Allows a bean to be instantiated any number of times (once per use). |
34 |
| - request Scopes a bean definition to an HTTP request. Only valid when used with a |
35 |
| - web-capable Spring context (such as with Spring MVC). |
36 |
| - session Scopes a bean definition to an HTTP session. Only valid when used with a |
37 |
| - web-capable Spring context (such as with Spring MVC). |
38 |
| - global-session Scopes a bean definition to a global HTTP session. Only valid when used in a portlet context. |
39 |
| -
|
40 |
| -What are the types of Dependency Injection Spring supports? |
41 |
| - Injecting through constructors |
42 |
| - Injecting into bean properties |
43 |
| -
|
44 |
| -Autowiring. Types of autowiring. |
45 |
| - byName Attempts to match all properties of the autowired bean with beans |
46 |
| - that have the same name (or ID) as the properties. Properties for which there�s |
47 |
| - no matching bean will remain unwired. |
48 |
| - byType Attempts to match all properties of the autowired bean with beans |
49 |
| - whose types are assignable to the properties. Properties for which there�s no |
50 |
| - matching bean will remain unwired. |
51 |
| - constructor Tries to match up a constructor of the autowired bean with |
52 |
| - beans whose types are assignable to the constructor arguments. |
53 |
| - autodetect Attempts to apply constructor autowiring first. If that fails, |
54 |
| - byType will be tried. |
55 |
| -
|
56 |
| -What are inner beans. |
57 |
| - Inner beans are beans that are defined within the scope of another bean. |
58 |
| - Note that the inner beans don�t have an id attribute set. Though it�s perfectly legal |
59 |
| - to declare an ID for an inner bean, it�s not necessary because you�ll never refer to the |
60 |
| - inner bean by name. This highlights the main drawback of using inner beans: they |
61 |
| - can�t be reused. Inner beans are only useful for injection once and can�t be referred |
62 |
| - to by other beans. |
63 |
| - You may also find that using inner-bean definitions has a negative impact on the |
64 |
| - readability of the XML in the Spring context files. |
65 |
| -
|
66 |
| -What modules does Spring Framework have? |
67 |
| - Spring Framework Runtime |
68 |
| - DataAccess/Integration |
69 |
| - JDBC ORM OXM JMS |
70 |
| - Transactions |
71 |
| - Web (MVC/Remoting) |
72 |
| - Web Servlet Portlet Struts |
73 |
| - AOP Aspects Instumentation |
74 |
| - Core Container |
75 |
| - Beans Core Context ExpressionLanguage |
76 |
| - Test |
77 |
| - http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/overview.html |
78 |
| -
|
79 |
| -Could you please tell us about Spring? What is the most important feature(s) of Spring? |
80 |
| - Lightweight and minimally invasive development with plain old Java objects(POJOs) |
81 |
| - Loose coupling through dependency injection and interface orientation |
82 |
| - Declarative programming through aspects and common conventions |
83 |
| - Boilerplate reduction through aspects and templates |
84 |
| -
|
85 |
| -What are ORM�s Spring supports ? |
86 |
| - Spring provides support for several persistence frameworks, including Hibernate, |
87 |
| - iBATIS, Java Data Objects (JDO), and the Java Persistence API (JPA). |
88 |
| -
|
89 |
| -How to integrate Spring and Hibernate using HibernateDaoSupport? |
90 |
| - not reccomended http://stackoverflow.com/questions/5104765/hibernatedaosupport-is-not-recommended-why |
91 |
| - 1)configure session factory |
92 |
| - <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation. AnnotationSessionFactoryBean"> |
93 |
| - <propertyname="dataSource"ref="dataSource"/> |
94 |
| - <propertyname="packagesToScan" value="com.habuma.spitter.domain"/> |
95 |
| - <propertyname="hibernateProperties"> |
96 |
| - <props> |
97 |
| - <propkey="dialect">org.hibernate.dialect.HSQLDialect</prop> |
98 |
| - </props> |
99 |
| - </property> |
100 |
| - </bean> |
101 |
| - 2)create dao class by extending HibernateDaoSupport |
102 |
| - class ExampleDao extends HibernateDaoSupport { |
103 |
| - ... |
104 |
| - List<aa> bb = (List<aa>)getHibernateTemplate().find("from cc"); |
105 |
| - } |
106 |
| -
|
| 1 | +----------------- Spring ----------------- |
| 2 | + |
| 3 | +Basic idea of IoC pattern. Benefits. |
| 4 | + By applying DI in your projects, you�ll find that your code will |
| 5 | + become significantly simpler, easier to understand, and easier to test. |
| 6 | + With DI, objects are given their dependencies at creation time |
| 7 | + by some third party that coordinates each object in the system. Objects aren�t |
| 8 | + expected to create or obtain their dependencies�dependencies are injected into the |
| 9 | + objects that need them. |
| 10 | + The key benefit of DI�loose coupling. If an object only knows about its |
| 11 | + dependencies by their interface (not by their implementation or how they�re |
| 12 | + instantiated), then the dependency can be swapped out with a different |
| 13 | + implementation without the depending object knowing the difference. |
| 14 | + One of the most common ways that a dependency will be swapped out is with a |
| 15 | + mock implementation during testing. |
| 16 | + |
| 17 | +What is Spring configuration file? How does it look like? |
| 18 | + <?xml version="1.0"encoding="UTF-8"?> |
| 19 | + <beans xmlns="http://www.springframework.org/schema/beans" |
| 20 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 21 | + xsi:schemaLocation="http://www.springframework.org/schema/beans |
| 22 | + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" [...] > |
| 23 | + |
| 24 | + [...] |
| 25 | + <bean id="knight"class="com.springinaction.knights.BraveKnight"> <constructor-argref="quest"/> </bean> |
| 26 | + <bean id="quest" class="com.springinaction.knights.SlayDragonQuest"/> |
| 27 | + [...] |
| 28 | + |
| 29 | + </beans> |
| 30 | + |
| 31 | +Out of the box bean scopes (singleton, prototype, request, session, global session) |
| 32 | + singleton Scopes the bean definition to a single instance per Spring container (default). |
| 33 | + prototype Allows a bean to be instantiated any number of times (once per use). |
| 34 | + request Scopes a bean definition to an HTTP request. Only valid when used with a |
| 35 | + web-capable Spring context (such as with Spring MVC). |
| 36 | + session Scopes a bean definition to an HTTP session. Only valid when used with a |
| 37 | + web-capable Spring context (such as with Spring MVC). |
| 38 | + global-session Scopes a bean definition to a global HTTP session. Only valid when used in a portlet context. |
| 39 | + |
| 40 | +What are the types of Dependency Injection Spring supports? |
| 41 | + Injecting through constructors |
| 42 | + Injecting into bean properties |
| 43 | + |
| 44 | +Autowiring. Types of autowiring. |
| 45 | + byName Attempts to match all properties of the autowired bean with beans |
| 46 | + that have the same name (or ID) as the properties. Properties for which there�s |
| 47 | + no matching bean will remain unwired. |
| 48 | + byType Attempts to match all properties of the autowired bean with beans |
| 49 | + whose types are assignable to the properties. Properties for which there�s no |
| 50 | + matching bean will remain unwired. |
| 51 | + constructor Tries to match up a constructor of the autowired bean with |
| 52 | + beans whose types are assignable to the constructor arguments. |
| 53 | + autodetect Attempts to apply constructor autowiring first. If that fails, |
| 54 | + byType will be tried. |
| 55 | + |
| 56 | +What are inner beans. |
| 57 | + Inner beans are beans that are defined within the scope of another bean. |
| 58 | + Note that the inner beans don�t have an id attribute set. Though it�s perfectly legal |
| 59 | + to declare an ID for an inner bean, it�s not necessary because you�ll never refer to the |
| 60 | + inner bean by name. This highlights the main drawback of using inner beans: they |
| 61 | + can�t be reused. Inner beans are only useful for injection once and can�t be referred |
| 62 | + to by other beans. |
| 63 | + You may also find that using inner-bean definitions has a negative impact on the |
| 64 | + readability of the XML in the Spring context files. |
| 65 | + |
| 66 | +What modules does Spring Framework have? |
| 67 | + Spring Framework Runtime |
| 68 | + DataAccess/Integration |
| 69 | + JDBC ORM OXM JMS |
| 70 | + Transactions |
| 71 | + Web (MVC/Remoting) |
| 72 | + Web Servlet Portlet Struts |
| 73 | + AOP Aspects Instumentation |
| 74 | + Core Container |
| 75 | + Beans Core Context ExpressionLanguage |
| 76 | + Test |
| 77 | + http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/overview.html |
| 78 | + |
| 79 | +Could you please tell us about Spring? What is the most important feature(s) of Spring? |
| 80 | + Lightweight and minimally invasive development with plain old Java objects(POJOs) |
| 81 | + Loose coupling through dependency injection and interface orientation |
| 82 | + Declarative programming through aspects and common conventions |
| 83 | + Boilerplate reduction through aspects and templates |
| 84 | + |
| 85 | +What are ORM�s Spring supports ? |
| 86 | + Spring provides support for several persistence frameworks, including Hibernate, |
| 87 | + iBATIS, Java Data Objects (JDO), and the Java Persistence API (JPA). |
| 88 | + |
| 89 | +How to integrate Spring and Hibernate using HibernateDaoSupport? |
| 90 | + not reccomended http://stackoverflow.com/questions/5104765/hibernatedaosupport-is-not-recommended-why |
| 91 | + 1)configure session factory |
| 92 | + <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation. AnnotationSessionFactoryBean"> |
| 93 | + <propertyname="dataSource"ref="dataSource"/> |
| 94 | + <propertyname="packagesToScan" value="com.habuma.spitter.domain"/> |
| 95 | + <propertyname="hibernateProperties"> |
| 96 | + <props> |
| 97 | + <propkey="dialect">org.hibernate.dialect.HSQLDialect</prop> |
| 98 | + </props> |
| 99 | + </property> |
| 100 | + </bean> |
| 101 | + 2)create dao class by extending HibernateDaoSupport |
| 102 | + class ExampleDao extends HibernateDaoSupport { |
| 103 | + ... |
| 104 | + List<aa> bb = (List<aa>)getHibernateTemplate().find("from cc"); |
| 105 | + } |
| 106 | + |
0 commit comments