vendredi 5 juin 2015

Get classname of ManagedBean in runtime

Helo!

I wrote an interceptor that make logging by this mehtod.

    @AroundInvoke
    public Object logMethodInvocation(InvocationContext ic) throws Exception{
    FileHandler fileHandler= new FileHandler("log.log");
    SimpleFormatter formatter=new SimpleFormatter();
    Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
    fileHandler.setFormatter(formatter);
    logger.addHandler(fileHandler);
    logger.log(Level.INFO,"Method name: {0}.{1}", new Object[]{ic.getClass().getSimpleName(), ic.getMethod().getName()});
    return ic.proceed();
}

As Result i get this for all classas as name:

Info: Method name: EjbInvocation.getFile1

not the real name of the bean(e.g. MyBean.getFile1)

What should i do to get the real name of the bean instead of EjbInvocation?





Aucun commentaire:

Enregistrer un commentaire