2. Expert One-on-One J2EE Design and Development (Rod Johnson) Sıradan Java sınıflarına yetenekler kazandırır. Transactions, Monitoring, Concurrency, Remoting Bağımlılık aktarımını üstlenir Modüler yapılı Core Veri erişimi/entegrasyonu Web AOP Test Spring’e Giriş
9. IoC Container tarafından yaratılıp, bağımlılıkları ve yaşam döngüsü yönetilen basit Java nesneleri (POJO) Tanımlanırken; Sınıfı id ve/veya ismi Scope değeri Bağımlılıkları Yaşam döngüsü metotları belirtilebilir. Container 3 farklı yöntemle beanleri yaratır: Sınıfın yapıcısı (constructor) static factory metot instance factory metot Bean Nedir?
10. Yapıcı ile Static Factory metot ile Bean Yaratma Yöntemleri <bean id="exampleBean" class="examples.ExampleBean"/> <bean id="clientService" class="examples.ClientFactoryService“ factory-method="createClient"/> publicclassClientFactoryService { publicstaticClientServicecreateClient() { new ClientService(); } }
16. init-method destroy-method Bean Yaşam Döngüsü (Devam) <bean id="exampleBean" class="examples.ExampleBean" init-method="init“ destroy-method=“cleanup”/> publicclassExampleBean { publicvoid init() { // do some initialization work } publicvoid cleanup() { // do some destruction work } }
24. Null ve Boş String Aktarımı <!-- Boş String --> <bean class="ExampleBean"> <property name="email" value=""/> </bean> <!-- Null --> <bean class="ExampleBean"> <property name="email"><null/></property> </bean>
25. Modları: byName byType constructor Primitive tipler için kullanılamaz Aynı tip değerinde birden fazla aday bean varsa hata oluşur. Autowire <bean id=“userService” class=“services.UserService” autowire=“byName”/>
28. Farklı transaction APIleri (JTA, JDBC, Hibernate, JPA) üzerine ortak bir model sunar. Transaction gerçekleştirimi değişse bile kodta değişiklik yapmaya gerek yok. Programlama veya tanımlama ile transaction tanımları yapılabilir. Basit API Spring Transaction Desteği
All @Configuration classes are subclassed at startup-time with CGLIB. In the subclass, the child method checks the container first for any cached (scoped) beans before it calls the parent method and creates a new instance.There are a few restrictions due to the fact that CGLIB dynamically adds features at startup-time:Configuration classes should not be finalThey should have a constructor with no arguments
Code is cleaner with the DI principle and decoupling is more effective when objects are provided with their dependencies
Keep in mind that to make “Constructor argument name” work out of the box your code must be compiled with the debug flag enabled so that Spring can look up the parameter name from the constructor. If you can't compile your code with debug flag (or don't want to) you can use @ConstructorProperties JDK annotation to explicitly name your constructor arguments.
In proxy mode (which is the default), only external method calls coming in through the proxy are intercepted. This means that self-invocation, in effect, a method within the target object calling another method of the target object, will not lead to an actual transaction at runtime even if the invoked method is marked with @Transactional.