public void put(URI uri, String unitName, EntityManagerFactory factory) throws Fabric3Exception { if (factory == null) { throw new IllegalArgumentException("EntityManagerFactory was null"); } cache.put(unitName, factory); Set<String> names = contributionCache.get(uri); if (names == null) { names = new HashSet<>(); contributionCache.put(uri, names); } names.add(unitName); export(unitName, factory); }
public void onUndeploy(ClassLoader classLoader) { URI key; if (classLoader instanceof MultiParentClassLoader) { key = ((MultiParentClassLoader) classLoader).getName(); } else { key = Names.BOOT_CONTRIBUTION; } Set<String> names = contributionCache.remove(key); if (names != null) { for (String name : names) { EntityManagerFactory factory = cache.remove(name); factory.close(); remove(name); } } }
private void export(String unitName, EntityManagerFactory factory) throws Fabric3Exception { if (managementService == null) { // management not enabled return; } if (!(factory instanceof HibernateEntityManagerFactory)) { throw new AssertionError("Expected " + HibernateEntityManagerFactory.class.getName() + " but was " + factory.getClass().getName()); } Statistics statistics = ((HibernateEntityManagerFactory) factory).getSessionFactory().getStatistics(); statistics.setStatisticsEnabled(true); managementService.export(encodeName(unitName), "Hibernate", "Hibernate session factory MBeans", statistics); }
private void remove(String unitName) { if (managementService == null) { // management not enabled return; } try { managementService.remove(encodeName(unitName), "Hibernate"); } catch (Fabric3Exception e) { monitor.error(unitName, e); } }
private void export(String unitName, EntityManagerFactory factory) throws Fabric3Exception { if (managementService == null) { // management not enabled return; } if (!(factory instanceof HibernateEntityManagerFactory)) { throw new AssertionError("Expected " + HibernateEntityManagerFactory.class.getName() + " but was " + factory.getClass().getName()); } Statistics statistics = ((HibernateEntityManagerFactory) factory).getSessionFactory().getStatistics(); statistics.setStatisticsEnabled(true); managementService.export(encodeName(unitName), "Hibernate", "Hibernate session factory MBeans", statistics); }
public void put(URI uri, String unitName, EntityManagerFactory factory) throws JpaResolutionException { if (factory == null) { throw new IllegalArgumentException("EntityManagerFactory was null"); } cache.put(unitName, factory); Set<String> names = contributionCache.get(uri); if (names == null) { names = new HashSet<String>(); contributionCache.put(uri, names); } names.add(unitName); export(unitName, factory); }
public void onUninstall(Contribution contribution) { URI uri = contribution.getUri(); ClassLoader classLoader = classLoaderRegistry.getClassLoader(uri); URI key; if (classLoader instanceof MultiParentClassLoader) { key = ((MultiParentClassLoader) classLoader).getNameUri(); } else { key = Names.BOOT_CONTRIBUTION; } Set<String> names = contributionCache.remove(key); if (names != null) { for (String name : names) { EntityManagerFactory factory = cache.remove(name); factory.close(); remove(name); } } }
private void remove(String unitName) { if (managementService == null) { // management not enabled return; } try { managementService.remove(encodeName(unitName), "Hibernate"); } catch (Fabric3Exception e) { monitor.error(unitName, e); } }
public void put(URI uri, String unitName, EntityManagerFactory factory) throws Fabric3Exception { if (factory == null) { throw new IllegalArgumentException("EntityManagerFactory was null"); } cache.put(unitName, factory); Set<String> names = contributionCache.get(uri); if (names == null) { names = new HashSet<>(); contributionCache.put(uri, names); } names.add(unitName); export(unitName, factory); }
public void onUninstall(Contribution contribution) { URI uri = contribution.getUri(); ClassLoader classLoader = classLoaderRegistry.getClassLoader(uri); URI key; if (classLoader instanceof MultiParentClassLoader) { key = ((MultiParentClassLoader) classLoader).getName(); } else { key = Names.BOOT_CONTRIBUTION; } Set<String> names = contributionCache.remove(key); if (names != null) { for (String name : names) { EntityManagerFactory factory = cache.remove(name); factory.close(); remove(name); } } }
private void remove(String unitName) { if (managementService == null) { // management not enabled return; } try { managementService.remove(encodeName(unitName), "Hibernate"); } catch (ManagementException e) { monitor.error(unitName, e); } }
private void export(String unitName, EntityManagerFactory factory) throws JpaResolutionException { if (managementService == null) { // management not enabled return; } StatisticsService statistics = new StatisticsService(); // TODO make configurable if (!(factory instanceof HibernateEntityManagerFactory)) { throw new AssertionError("Expected " + HibernateEntityManagerFactory.class.getName() + " but was " + factory.getClass().getName()); } statistics.setSessionFactory(((HibernateEntityManagerFactory) factory).getSessionFactory()); statistics.setStatisticsEnabled(true); try { managementService.export(encodeName(unitName), "Hibernate", "Hibernate session factory MBeans", statistics); } catch (ManagementException e) { throw new JpaResolutionException("Error exporting management bean for persistence unit: " + unitName, e); } }