Java 类org.hibernate.jmx.StatisticsService 实例源码

项目:ComputationalEconomy    文件:JMXRegistration.java   
public static void init() {
    mBeans.clear();
    try {
        mBeans.put(new ObjectName("compecon.jmx:type=NumberOfAgentsModel"),
                new JmxNumberOfAgentsModel());
        mBeans.put(new ObjectName("compecon.jmx:type=TimeSystemModel"),
                new JmxTimeSystemModel());

        // hibernate stats mbean
        final StatisticsService statsMBean = new StatisticsService();
        statsMBean.setSessionFactory(HibernateUtil.getSessionFactory());
        statsMBean.setStatisticsEnabled(true);
        mBeans.put(new ObjectName("Hibernate:application=Statistics"),
                statsMBean);

        for (final Entry<ObjectName, Object> entry : mBeans.entrySet()) {
            mBeanServer.registerMBean(entry.getValue(), entry.getKey());
        }
    } catch (MalformedObjectNameException | InstanceAlreadyExistsException
            | MBeanRegistrationException | NotCompliantMBeanException e) {
        e.printStackTrace();
    }
}
项目:termitaria    文件:BLExportImport.java   
public static void main(String[] args) throws FileNotFoundException {


    String fileName = "export_import\\result1.xml";

    StatisticsService ss = (StatisticsService) appCtx.getBean("hibernateStats");

    OrganisationContainers orgCs = new OrganisationContainers();
    Organisation org = DaoBeanFactory.getInstance().getDaoOrganisation().getForExport(35);
    OrganisationContainer orgC = new OrganisationContainer();
    orgC.setOrganisation(org);
    List<OrganisationContainer> orgContainers = new ArrayList<OrganisationContainer>();
    orgContainers.add(orgC);
    orgCs.setOrgCs(orgContainers);
    try {
        //BLExportImport.getInstance().exportToFile(orgCs,  fileName);
        BLExportImport.getInstance().importFromFile(fileName);
    } catch (BusinessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    //mainImport(fileName);


}