All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jwebmp.guicedpersistence.implementations.GuicedPersistenceDestroyer Maven / Gradle / Ivy

Go to download

A complete JPA 2.1 implementation for Standalone or EE Implementation. Enables Multiple Persistence units with full JTA Support using BTM. Perfect for Guice implementations, test suites, and Guice enabled Web Applications or EAR Projects. Requires JDK 8

There is a newer version: 0.66.0.1
Show newest version
package com.jwebmp.guicedpersistence.implementations;

import com.google.inject.persist.PersistService;
import com.jwebmp.guicedinjection.GuiceContext;
import com.jwebmp.guicedinjection.interfaces.IGuicePreDestroy;
import com.jwebmp.guicedpersistence.db.DatabaseModule;
import com.jwebmp.logger.LogFactory;

import java.lang.annotation.Annotation;
import java.util.logging.Level;
import java.util.logging.Logger;

public class GuicedPersistenceDestroyer
		implements IGuicePreDestroy
{
	private static final Logger log = LogFactory.getLog("GuicedPersistenceDestroyer");

	@Override
	public void onDestroy()
	{
		for (Class boundAnnotation : DatabaseModule.getBoundAnnotations())
		{
			try
			{
				log.log(Level.INFO, "Stopping EMF and Persist Service [" + boundAnnotation.getCanonicalName() + "]");
				PersistService service = GuiceContext.get(PersistService.class, boundAnnotation);
				service.stop();
			}
			catch (Exception e)
			{
				log.log(Level.SEVERE, "Unable to close entity managers and factories for annotation [" + boundAnnotation.getCanonicalName() + "]", e);
			}
		}

	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy