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

com.guicedee.services.hibernate.PersistenceFileHandler Maven / Gradle / Ivy

Go to download

JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves

There is a newer version: 62
Show newest version
package com.guicedee.services.hibernate;

import com.guicedee.guicedinjection.interfaces.IFileContentsScanner;
import com.guicedee.logger.LogFactory;
import io.github.classgraph.ResourceList;
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;

/**
 * Loads persistence units from persistence files as found on the registered classpath
 */
@SuppressWarnings("unused")
public class PersistenceFileHandler
		implements IFileContentsScanner
{
	/**
	 * The logger
	 */
	private static final Logger log = LogFactory.getLog("PersistenceFileHandler");
	/**
	 * The property that marks a persistence unit as ignore
	 */
	private static final String ignorePersistenceUnitProperty = "guicedpersistence.ignore";
	/**
	 * A list of all registered persistence units
	 */
	private static final Set persistenceUnits = new HashSet<>();

	/**
	 * A new persistence file handler
	 */
	public PersistenceFileHandler()
	{
		//No Config Required
	}

	/**
	 * Returns all the persistence units that were found or loaded
	 *
	 * @return A set of persistence units
	 */
	public static Set getPersistenceUnits()
	{
		return PersistenceFileHandler.persistenceUnits;
	}

	/**
	 * Method getIgnorePersistenceUnitProperty returns the ignorePersistenceUnitProperty of this PersistenceFileHandler object.
	 * 

* The property that marks a persistence unit as ignore * * @return the ignorePersistenceUnitProperty (type String) of this PersistenceFileHandler object. */ @SuppressWarnings("WeakerAccess") public static String getIgnorePersistenceUnitProperty() { return ignorePersistenceUnitProperty; } /** * Returns a contents processer to run on match * * @return the maps of file identifiers and contents */ @Override public Map onMatch() { Map map = new HashMap<>(); PersistenceFileHandler.log.info("Loading Persistence File Handling - persistence.xml"); ResourceList.ByteArrayConsumer processor = new PersistenceByteArrayConsumer(); map.put("persistence.xml", processor); return map; } /** * Method hashCode ... * * @return int */ @Override public int hashCode() { return super.hashCode(); } /** * Method equals ... * * @param obj * of type Object * * @return boolean */ @Override public boolean equals(Object obj) { if (obj == null) { return false; } return obj.getClass() .equals(getClass()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy