Upload
cleverson-sacramento
View
1.721
Download
1
Embed Size (px)
DESCRIPTION
Slides que apresentei no primeiro JavaOne Brasil em 2010 sobre a nova versão 2.0 do framework Demoiselle. Para mais detalhes, acesse: http://cleversonsacramento.wordpress.com/2010/12/14/o-primeiro-javaone-no-brasil/
Citation preview
demoiselleframework
2.0
zyc/
cleversonsacramento. . com
robsonximenes/
robsonximenes@ .com
2.0
mar20080.1
dez20081.0
abr20091.0.3
nov20091.1.0
ago20101.1.5
dez20102.0.0
dez20101.2.0
dez20102.0.0-B2
JSF?
Hibernate?
AspectJ?
Eclipse?
JBoss?
Seam?Guice?Spring?
contextdependency
injection
and
jsr 299
c o r eextensions
components
jpa jsf swing
br.gov.frameworkdemoisellestereotype
message
annotation
exceptiontemplate
transaction
util
br.gov.frameworkdemoiselle.internalbootstrap
factoryproxy
interceptor
impl
class B { @Inject A a;}
class A {}
class B {
@Inject FacesContext context;
}
class FacesContextFactory {
@Producespublic FacesContext create() {
return FacesContext.getCurrentInstance();}
}
class LoggerFactory {
@Producespublic Logger create(InjectionPoint ip) {
return create(ip.getMember().getDeclaringClass());}
private Logger create(Class type) {Logger logger = LoggerFactory.getLogger(type);return new LoggerProxy(logger);
}}
class A {
@Inject EntityManager em;
public inserir (String s) {...}}
class B {
@Inject A a;
@Transactional public carga () { a.inserir(“1”); a.inserir(“2”); }}
@InterceptorBinding@Target({METHOD, TYPE})public @interface Transactional { }
@Interceptor @Transactionalclass TransactionInterceptor {
...
@AroundInvokepublic Object manage(InvocationContext ctx) {
initiate(); // begin
Object result = null;try {
result = ctx.proceed();
} catch (Exception cause) {handleException(cause); // marca para rollbackthrow cause;
} finally {complete(); // commit ou rollback
}
return result;}
}
# demoiselle.properties
frameworkdemoiselle.transaction.class=
br.gov.frameworkdemoiselle.transaction.NoTransaction*br.gov.frameworkdemoiselle.transaction.JPATransactionbr.gov.frameworkdemoiselle.transaction.JTATransaction
seupacote.SuaEstrategiaDeTransacao
class B {
@Startup @Transactional
public carga () {…}
@Shutdown @Transactional
public descarga () {…}}
@PersistenceControllerclass A {
@Inject EntityManager em;
}
@BusinessControllerclass B {
@Inject A a;
}
@Controller@Stereotype@Target(TYPE)public @interface PersistenceController { }
@Controller@Stereotype@Target(TYPE)public @interface BusinessController { }
arquitetura cebola
@Controller@Stereotype@Target(TYPE)public @interface PersistenceController { }
@Controller@Stereotype@Target(TYPE)public @interface BusinessController { }
@BusinessControllerclass B {
@Startup @Transactional
public carga () {…}
@ExceptionHandler public trata (CrecaException e) {…}}
@Interceptor @Controllerclass TransactionInterceptor {
...
@AroundInvokepublic Object manage(InvocationContext ctx) {
Object result = null;try {
result = ctx.proceed();
} catch (Exception cause) {
if (!handleException(cause)) { // delega aos tratadoresthrow cause;
}}
return result;}
}
http://demoiselle.svn.sf.net/svnroot/demoiselle/framework
/branches/demoiselle-2.0
forum.frameworkdemoiselle.gov.br
demoiselle-proposal