1 25 26 package org.objectweb.easybeans.naming.interceptors; 27 28 import javax.naming.Context ; 29 import javax.naming.NamingException ; 30 31 import org.objectweb.easybeans.api.EasyBeansInterceptor; 32 import org.objectweb.easybeans.api.EasyBeansInvocationContext; 33 import org.objectweb.easybeans.log.JLog; 34 import org.objectweb.easybeans.log.JLogFactory; 35 import org.objectweb.easybeans.naming.NamingManager; 36 37 41 public class EZBENCInterceptor implements EasyBeansInterceptor { 42 43 46 private static JLog logger = JLogFactory.getLog(EZBENCInterceptor.class); 47 48 51 private static NamingManager namingManager = null; 52 53 57 public EZBENCInterceptor() { 58 if (namingManager == null) { 59 try { 60 namingManager = NamingManager.getInstance(); 61 } catch (NamingException e) { 62 throw new IllegalStateException ("Cannot get the naming manager", e); 63 } 64 } 65 } 66 67 74 public Object intercept(final EasyBeansInvocationContext invocationContext) throws Exception { 75 Context oldContext = namingManager.setComponentContext(invocationContext.getFactory().getJavaContext()); 76 try { 77 return invocationContext.proceed(); 78 } finally { 79 logger.debug("Unset ENC environment"); 80 namingManager.resetComponentContext(oldContext); 81 } 82 } 83 } 84 | Popular Tags |