1 17 18 package org.apache.geronimo.naming.java; 19 20 import javax.naming.Context ; 21 22 import org.apache.geronimo.interceptor.Interceptor; 23 import org.apache.geronimo.interceptor.Invocation; 24 import org.apache.geronimo.interceptor.InvocationResult; 25 26 32 public class ComponentContextInterceptor implements Interceptor { 33 private final Interceptor next; 34 private final Context compContext; 35 36 40 public ComponentContextInterceptor(Interceptor next, Context compContext) { 41 assert next != null; 42 assert compContext != null; 43 this.next = next; 44 this.compContext = compContext; 45 } 46 47 public InvocationResult invoke(Invocation invocation) throws Throwable { 48 Context oldContext = RootContext.getComponentContext(); 49 try { 50 RootContext.setComponentContext(compContext); 51 return next.invoke(invocation); 52 } finally { 53 RootContext.setComponentContext(oldContext); 54 } 55 } 56 } 57 | Popular Tags |