JSF Scope & CDI

RequestScoped <ConversationScoped < SessionScoped

 

 

How does JSF 2 ConversationScope work?

http://stackoverflow.com/questions/7788430/how-does-jsf-2-conversationscope-work

 

 

http://docs.oracle.com/javaee/6/api/javax/enterprise/context/ConversationScoped.html

 

 

What is  CDI?

http://refcardz.dzone.com/refcardz/contexts-and-depencency?oid=hom16925

 

 

 

What is the purpose of the @Model annotation?

http://sfwk.org/Documentation/WhatIsThePurposeOfTheModelAnnotation

 

 

 

 

http://docs.oracle.com/javaee/6/tutorial/doc/gkhic.html

 

 

public void creditPayment(@Observes @Credit PaymentEvent event) {
    ...
}

public void debitPayment(@Observes @Debit PaymentEvent event) {
    ...
}

Observer methods can also be conditional or transactional:

  • A conditional observer method is notified of an event only if an instance of the bean that defines the observer method already exists in the current context. To declare a conditional observer method, specifynotifyObserver=IF_EXISTS as an argument to @Observes:

    @Observes(notifyObserver=IF_EXISTS)

    To obtain the default unconditional behavior, you can specify @Observes(notifyObserver=ALWAYS).

  • A transactional observer method is notified of an event during the before completion or after completion phase of the transaction in which the event was fired. You can also specify that the notification is to occur only after the transaction has completed successfully or unsuccessfully. To specify a transactional observer method, use any of the following arguments to @Observes:

    @Observes(during=BEFORE_COMPLETION)
    
    @Observes(during=AFTER_COMPLETION)
    
    @Observes(during=AFTER_SUCCESS)
    
    @Observes(during=AFTER_FAILURE)

    To obtain the default non-transactional behavior, specify @Observes(during=IN_PROGRESS).

    An observer method that is called before completion of a transaction may call the setRollbackOnlymethod on the transaction instance to force a transaction rollback.

 

Decorator vs.  Interceptor 

Decorators are outwardly similar to interceptors. However, they actually perform tasks complementary to those performed by interceptors. Interceptors perform cross-cutting tasks associated with method invocation and with the lifecycles of beans, but cannot perform any business logic. Decorators, on the other hand, do perform business logic by intercepting business methods of beans. This means that instead of being reusable for different kinds of applications as interceptors are, their logic is specific to a particular application.

 

If an application has both interceptors and decorators, the interceptors are invoked first. This means, in effect, that you cannot intercept a decorator.

 

decorator   http://docs.jboss.org/cdi/spec/1.0/html/decorators.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值