hi,
yes, interceptor works fine with other component without @Startup 

At first, i have two annotations 

  | @Target(TYPE)
  | @Documented
  | @Retention(RUNTIME)
  | @Interceptors(KleberInterceptor.class)
  | public @interface Kleber 
  | {
  |     
  | }
  | 



interceptor is supposed to check filed with @Jndi annotation and take the 
string from @jndi for jndi lookup

  | public class KleberInterceptor {
  | 
  |     @PostConstruct
  |     public Object jndiLookup(InvocationContext invocation )throws Exception{
  |             Object target = invocation.getTarget();
  |             Field[] fields = target.getClass().getDeclaredFields();
  |             
  |             try{
  |                     InitialContext ctx = new InitialContext();
  |                     for(Field field: fields){
  |                             Jndi jndi = field.getAnnotation(Jndi.class);
  |                             if(jndi!=null){
  |                                     Object obj = ctx.lookup(jndi.value());
  |                                     field.setAccessible(true);
  |                                     field.set(target, obj);
  |                             }
  |                     }
  |                     
  |             }catch(Exception ex){
  |                     ex.printStackTrace();
  |             }
  |             
  |             return invocation.proceed();
  |     }
  |         
  |        @AroundInvoke
  |        otherMethods............
  | 
  | 
  | }
  | 

I can not use @Kleber on a component which already has a @Startup, what i can 
do now ,is to write jndi lookup codes directly in @Startup component, and it 
works.....

is there any better way to inject jndi resouce in @Startup Seam component?




View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4108946#4108946

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4108946
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to