Search in sources :

Example 1 with TbSysCtxBean

use of com.netsteadfast.greenstep.po.hbm.TbSysCtxBean in project bamboobsc by billchen198318.

the class WebSystemCtxBeanSupportListener method processBean.

private void processBean(ServletContextEvent event, String type) {
    try {
        List<TbSysCtxBean> ctxBeans = this.findSysCtxBeanList(type);
        for (int i = 0; ctxBeans != null && i < ctxBeans.size(); i++) {
            TbSysCtxBean bean = ctxBeans.get(i);
            try {
                Object executerObj = Class.forName(bean.getClassName()).newInstance();
                if (!(executerObj instanceof ContextInitializedAndDestroyedBean)) {
                    logger.warn("class not instanceof ContextInitializedAndDestroyedBean : " + bean.getClassName());
                    continue;
                }
                Method[] methods = executerObj.getClass().getMethods();
                for (Method method : methods) {
                    if (method.getName().equals("execute")) {
                        try {
                            method.invoke(executerObj, event);
                        } catch (ServiceException se) {
                            se.printStackTrace();
                            logger.warn(se.getMessage().toString());
                        } catch (Exception e) {
                            e.printStackTrace();
                            logger.error(e.getMessage().toString());
                        }
                    }
                }
            } catch (ClassNotFoundException cnfe) {
                cnfe.printStackTrace();
                logger.error(cnfe.getMessage().toString());
            }
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) Method(java.lang.reflect.Method) TbSysCtxBean(com.netsteadfast.greenstep.po.hbm.TbSysCtxBean) ContextInitializedAndDestroyedBean(com.netsteadfast.greenstep.base.model.ContextInitializedAndDestroyedBean) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Aggregations

ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)1 ContextInitializedAndDestroyedBean (com.netsteadfast.greenstep.base.model.ContextInitializedAndDestroyedBean)1 TbSysCtxBean (com.netsteadfast.greenstep.po.hbm.TbSysCtxBean)1 Method (java.lang.reflect.Method)1