Java Reference
In-Depth Information
As can be seen above, all we need to do to register our interceptor is to use the
<interceptor> tag in beans.xml , with one or more nested <class> tags containing
the fully qualified names of our interceptors.
The final step before we can use our interceptor binding type is to annotate the class
to be intercepted with our interceptor binding type.
package com.ensode.controller;
import com.ensode.interceptorbinding.LoggingInterceptorBinding;
import com.ensode.model.Customer;
import com.ensode.model.PremiumCustomer;
import com.ensode.qualifier.Premium;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
public class PremiumCustomerController {
private static final Logger logger = Logger.getLogger(
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";
Search WWH ::

Custom Search