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

com.guicedee.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: 62
Show newest version
package com.guicedee.guicedpersistence.implementations;

import com.google.inject.persist.PersistService;
import com.guicedee.guicedinjection.GuiceContext;
import com.guicedee.guicedinjection.interfaces.IGuicePreDestroy;
import com.guicedee.guicedpersistence.db.DatabaseModule;
import com.guicedee.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);
			}
		}
	}

	@Override
	public Integer sortOrder()
	{
		return 500;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy