/** * Find all persistence-units from all accessible {@code META-INF/persistence.xml} resources * * @param integration The Map of integration settings * * @return List of descriptors for all discovered persistence-units. */ public static List<ParsedPersistenceXmlDescriptor> locatePersistenceUnits(Map integration) { final PersistenceXmlParser parser = new PersistenceXmlParser( ClassLoaderServiceImpl.fromConfigSettings( integration ), PersistenceUnitTransactionType.RESOURCE_LOCAL ); parser.doResolve( integration ); return new ArrayList<>( parser.persistenceUnits.values() ); }
/** * Parse a specific {@code persistence.xml} with the assumption that it defines a single * persistence-unit. * * @param persistenceXmlUrl The {@code persistence.xml} URL * @param transactionType The specific PersistenceUnitTransactionType to incorporate into the persistence-unit descriptor * @param integration The Map of integration settings * * @return The single persistence-unit descriptor */ @SuppressWarnings("WeakerAccess") public static ParsedPersistenceXmlDescriptor locateIndividualPersistenceUnit( URL persistenceXmlUrl, PersistenceUnitTransactionType transactionType, Map integration) { final PersistenceXmlParser parser = new PersistenceXmlParser( ClassLoaderServiceImpl.fromConfigSettings( integration ), transactionType ); parser.parsePersistenceXml( persistenceXmlUrl, integration ); assert parser.persistenceUnits.size() == 1; return parser.persistenceUnits.values().iterator().next(); }
/** * Generic method to parse a specified {@code persistence.xml} and return a Map of descriptors * for all discovered persistence-units keyed by the PU name. * * @param persistenceXmlUrl The URL of the {@code persistence.xml} to parse * @param transactionType The specific PersistenceUnitTransactionType to incorporate into the persistence-unit descriptor * @param integration The Map of integration settings * * @return Map of persistence-unit descriptors keyed by the PU name */ public static Map<String, ParsedPersistenceXmlDescriptor> parse( URL persistenceXmlUrl, PersistenceUnitTransactionType transactionType, Map integration) { PersistenceXmlParser parser = new PersistenceXmlParser( ClassLoaderServiceImpl.fromConfigSettings( integration ), transactionType ); parser.doResolve( integration ); return parser.persistenceUnits; }
/** * Parse a specific {@code persistence.xml} and return the descriptor for the persistence-unit with matching name * * @param persistenceXmlUrl The {@code persistence.xml} URL * @param name The PU name to match * @param transactionType The specific PersistenceUnitTransactionType to incorporate into the persistence-unit descriptor * @param integration The Map of integration settings * * @return The matching persistence-unit descriptor */ @SuppressWarnings("WeakerAccess") public static ParsedPersistenceXmlDescriptor locateNamedPersistenceUnit( URL persistenceXmlUrl, String name, PersistenceUnitTransactionType transactionType, Map integration) { assert StringHelper.isNotEmpty( name ); final PersistenceXmlParser parser = new PersistenceXmlParser( ClassLoaderServiceImpl.fromConfigSettings( integration ), transactionType ); parser.parsePersistenceXml( persistenceXmlUrl, integration ); assert parser.persistenceUnits.containsKey( name ); return parser.persistenceUnits.get( name ); }
/** * Find all persistence-units from all accessible {@code META-INF/persistence.xml} resources * * @param integration The Map of integration settings * * @return List of descriptors for all discovered persistence-units. */ public static List<ParsedPersistenceXmlDescriptor> locatePersistenceUnits(Map integration) { final PersistenceXmlParser parser = new PersistenceXmlParser( ClassLoaderServiceImpl.fromConfigSettings( integration ), PersistenceUnitTransactionType.RESOURCE_LOCAL ); parser.doResolve( integration ); return new ArrayList<>( parser.persistenceUnits.values() ); }
/** * Parse a specific {@code persistence.xml} with the assumption that it defines a single * persistence-unit. * * @param persistenceXmlUrl The {@code persistence.xml} URL * @param transactionType The specific PersistenceUnitTransactionType to incorporate into the persistence-unit descriptor * @param integration The Map of integration settings * * @return The single persistence-unit descriptor */ @SuppressWarnings("WeakerAccess") public static ParsedPersistenceXmlDescriptor locateIndividualPersistenceUnit( URL persistenceXmlUrl, PersistenceUnitTransactionType transactionType, Map integration) { final PersistenceXmlParser parser = new PersistenceXmlParser( ClassLoaderServiceImpl.fromConfigSettings( integration ), transactionType ); parser.parsePersistenceXml( persistenceXmlUrl, integration ); assert parser.persistenceUnits.size() == 1; return parser.persistenceUnits.values().iterator().next(); }
/** * Generic method to parse a specified {@code persistence.xml} and return a Map of descriptors * for all discovered persistence-units keyed by the PU name. * * @param persistenceXmlUrl The URL of the {@code persistence.xml} to parse * @param transactionType The specific PersistenceUnitTransactionType to incorporate into the persistence-unit descriptor * @param integration The Map of integration settings * * @return Map of persistence-unit descriptors keyed by the PU name */ public static Map<String, ParsedPersistenceXmlDescriptor> parse( URL persistenceXmlUrl, PersistenceUnitTransactionType transactionType, Map integration) { PersistenceXmlParser parser = new PersistenceXmlParser( ClassLoaderServiceImpl.fromConfigSettings( integration ), transactionType ); parser.doResolve( integration ); return parser.persistenceUnits; }
/** * Parse a specific {@code persistence.xml} and return the descriptor for the persistence-unit with matching name * * @param persistenceXmlUrl The {@code persistence.xml} URL * @param name The PU name to match * @param transactionType The specific PersistenceUnitTransactionType to incorporate into the persistence-unit descriptor * @param integration The Map of integration settings * * @return The matching persistence-unit descriptor */ @SuppressWarnings("WeakerAccess") public static ParsedPersistenceXmlDescriptor locateNamedPersistenceUnit( URL persistenceXmlUrl, String name, PersistenceUnitTransactionType transactionType, Map integration) { assert StringHelper.isNotEmpty( name ); final PersistenceXmlParser parser = new PersistenceXmlParser( ClassLoaderServiceImpl.fromConfigSettings( integration ), transactionType ); parser.parsePersistenceXml( persistenceXmlUrl, integration ); assert parser.persistenceUnits.containsKey( name ); return parser.persistenceUnits.get( name ); }