Tips for writing software that do not wake you up at 2am. A topic highly influenced by Michael T. Nygard's book Release It and lessons we've learnt at GoodData.
Tips for writing software that do not wake you up at 2am. A topic highly influenced by Michael T. Nygard's book Release It and lessons we've learnt at GoodData.
The document discusses various features of the Spring framework including EJB support, creating custom beans, JNDI lookup, remoting, JMS, and mail support. Spring can simplify creation of EJB session and message-driven beans. Custom beans can implement interfaces to define business logic. Spring supports lookup of resources through JNDI and exposing services via remoting protocols like RMI, HTTP invoker, and JMS. It also provides utilities for sending mail.
This document provides an overview of the Spring Integration framework. It discusses key concepts like channels, endpoints, routers, filters and transformers. It describes common integration scenarios like file transfer, database integration and messaging. The goals of Spring Integration are to provide a simple model for complex enterprise integration and facilitate asynchronous, message-driven behavior within Spring applications. An example demonstrates converting a message to uppercase using a service activator and channels.
* Jakým způsobem můžeme vystavovat aplikační logiku
* RPC versus výměna zpráv
* Rozdíl SOAP a REST služby, za jakých okolností bychom měli použít jedno nebo druhé
* Spring WS
* Návrh kontraktu
* Ukázka Endpointu
* Spring MVC REST
* Návrh REST resourcu
* Ukázka REST controlleru
The document discusses using MongoDB as an alternative to a relational database in Java applications. It outlines some of the drawbacks of using an ORM with an RDBMS, such as complexity in the data access layer. MongoDB offers a simpler document model where data is stored in JSON-like documents without a predefined schema. The presentation demonstrates basic CRUD operations in MongoDB from the Java driver and discusses architecture considerations like lack of transactions when using MongoDB. It also provides an example of how MongoDB is deployed in a clustered configuration for the GoodData platform.
The document discusses the author's experience with NoSQL databases from a Java developer perspective. Prototypes were created using Voldemort, CouchDB, and Neo4J. Implementing connectors for new databases required creating new Java classes, mappings, and DDL for each. CouchDB provides a simpler approach with three document types, a schemaless structure, elastic extensibility, and direct mapping between Java beans and JSON without an ORM or need for deep ORM knowledge.
The document discusses various features of the Spring framework including EJB support, creating custom beans, JNDI lookup, remoting, JMS, and mail support. Spring can simplify creation of EJB session and message-driven beans. Custom beans can implement interfaces to define business logic. Spring supports lookup of resources through JNDI and exposing services via remoting protocols like RMI, HTTP invoker, and JMS. It also provides utilities for sending mail.
This document provides an overview of the Spring Integration framework. It discusses key concepts like channels, endpoints, routers, filters and transformers. It describes common integration scenarios like file transfer, database integration and messaging. The goals of Spring Integration are to provide a simple model for complex enterprise integration and facilitate asynchronous, message-driven behavior within Spring applications. An example demonstrates converting a message to uppercase using a service activator and channels.
* Jakým způsobem můžeme vystavovat aplikační logiku
* RPC versus výměna zpráv
* Rozdíl SOAP a REST služby, za jakých okolností bychom měli použít jedno nebo druhé
* Spring WS
* Návrh kontraktu
* Ukázka Endpointu
* Spring MVC REST
* Návrh REST resourcu
* Ukázka REST controlleru
The document discusses using MongoDB as an alternative to a relational database in Java applications. It outlines some of the drawbacks of using an ORM with an RDBMS, such as complexity in the data access layer. MongoDB offers a simpler document model where data is stored in JSON-like documents without a predefined schema. The presentation demonstrates basic CRUD operations in MongoDB from the Java driver and discusses architecture considerations like lack of transactions when using MongoDB. It also provides an example of how MongoDB is deployed in a clustered configuration for the GoodData platform.
The document discusses the author's experience with NoSQL databases from a Java developer perspective. Prototypes were created using Voldemort, CouchDB, and Neo4J. Implementing connectors for new databases required creating new Java classes, mappings, and DDL for each. CouchDB provides a simpler approach with three document types, a schemaless structure, elastic extensibility, and direct mapping between Java beans and JSON without an ORM or need for deep ORM knowledge.
1. Spring framework
Motto: Musíte rozbít vejce když chcete udělat omeletu
Spring framework training materials by Roman Pichlík is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Sunday 13 May 2012 1
2. Řízení transakcí
Commit, rollback, programové a deklarativní použití transakcí
Sunday 13 May 2012 2
3. Transakce
• Správné použití a pochopení
transakcí je jednou ze základních
výzev J2EE aplikací
• Transakce
• nedělitelná jednotka operace
• ACID
Sunday 13 May 2012 3
5. Transakce v Jave
• Každý framework nebo
technologie má vlastní API
• JPA, Hibernate, JDBC, JTA...
• Transakce dělíme
• Lokální
• Globální
Sunday 13 May 2012 5
6. Transakce v Jave
• Vetšinou aplikací - lokální
transakce
• autocommit
• řízení transakcí per connection
Sunday 13 May 2012 6
22. • Spring podporuje možnost definovat/ovládat transakce
• programově
• deklarativně
• Spring definuje abstraktní transakční API
• to umožňuje stejný přístup k řízení transakcí pro různé
frameworky
• Hibernate, iBatis, JPA, JDBC
• V mnohém přebírá úspěšný koncept EJB
• CMT
• izolace, propagace
Sunday 13 May 2012 22
23. Transakční manažer
• Pro využití transakcí musíme nadefinovat transakční manager beanu
• HibernateTransactionManager
• DataSourceTransactionManager
• JtaTransactionManager
• Podle typu transakčního manageru se definuje i jeho závislost
• DataSourceTransactionManager závisí na datasource
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
Sunday 13 May 2012 23
24. Deklarativní řízení
• Založeno na AOP
• Rollback
RuntimteException
• XML
• Anotace
• @Transactional
Sunday 13 May 2012 24
29. Výjimky
• běhová (runtime) => vždy rollback
• kontrolovaná (checked) =>
neovlivňuje
• možno změnit chování viz atribut
• rollbackFor
• noRollbackFor
Sunday 13 May 2012 29
30. Programový způsob
• Stará dobrá template method
• TransactionTemplate
• Méně flexibilní pro práci s except.
• netřeba explicitní commit/
rollback
• RuntimeException
• status.setRoolbackOnly()
Sunday 13 May 2012 30
32. Transakce test
public class MyService {
@Transactional
public void doSomething() {
//code ommited...
}
public void addSomething() {
doSomething();
//code ommited...
deleteSomething();
}
@Transactional
protected void deleteSomething() {
//code ommited...
}
}
Sunday 13 May 2012 32
33. • Nadefinujte pro předchozí DAO objekt transakce
• Vyzkoušejte programový způsob
• transakce nad vice metodami
• vyzkoušejte rollback
• Deklarativní způsob
• anotace
• XML
Sunday 13 May 2012 33