Java Reference
In-Depth Information
private Customer customer;
public String saveCustomer() {
PremiumCustomer premiumCustomer = (PremiumCustomer) customer;
logger.log(Level.INFO, "Saving the following information \n"
+ "{0} {1}, discount code = {2}",
new Object[]{premiumCustomer.getFirstName(),
//If this was a real application, we would have code to save
//customer data to the database here.
return "premium_customer_confirmation";
Now, we are ready to use our interceptor. After executing the preceding code and
examining the GlassFish log, we can see our interceptor binding type in action.
The lines entering saveCustomer method and leaving saveCustomer method
were added to the log by our interceptor, which was indirectly invoked by our
interceptor binding type.
Custom scopes
In addition to providing several prebuilt scopes, CDI allows us to define our own
custom scopes. This functionality is primarily meant for developers building
frameworks on top of CDI, not for application developers. Nevertheless, NetBeans
provides a wizard for us to create our own CDI custom scopes.
Search WWH ::

Custom Search