Example usage for org.springframework.orm.jpa.persistenceunit MutablePersistenceUnitInfo getJarFileUrls

List of usage examples for org.springframework.orm.jpa.persistenceunit MutablePersistenceUnitInfo getJarFileUrls

Introduction

In this page you can find the example usage for org.springframework.orm.jpa.persistenceunit MutablePersistenceUnitInfo getJarFileUrls.

Prototype

@Override
    public List<URL> getJarFileUrls() 

Source Link

Usage

From source file:com.hmed.config.MultiConfigAwarePersistenceUnitManager.java

/**
 * Copies a persistence unit to another one. Takes care of copying both
 * managed classes and urls.//from   ww  w.j ava2 s .co m
 *
 * @param from the persistence unit to copy
 * @param to the target (copied) persistence unit
 */
protected void copyPersistenceUnit(MutablePersistenceUnitInfo from, MutablePersistenceUnitInfo to) {
    // Copy jar file urls
    for (URL url : from.getJarFileUrls()) {
        to.addJarFileUrl(url);
    }
    for (String s : from.getManagedClassNames()) {
        to.addManagedClassName(s);
    }
}

From source file:net.ggtools.maven.ddlgenerator.MultiConfigAwarePersistenceUnitManager.java

/**
 * Copies a persistence unit to another one. Takes care of copying both
 * managed classes and urls./*from  ww  w  . j ava  2 s.co  m*/
 *
 * @param from the persistence unit to copy
 * @param to   the target (copied) persistence unit
 */
protected void copyPersistenceUnit(MutablePersistenceUnitInfo from, MutablePersistenceUnitInfo to) {
    for (String s : from.getMappingFileNames()) {
        to.addMappingFileName(s);
    }
    for (String s : from.getManagedClassNames()) {
        to.addManagedClassName(s);
    }
    // Copy jar file urls
    for (URL url : from.getJarFileUrls()) {
        to.addJarFileUrl(url);
    }
}

From source file:com.hmed.config.MultiConfigAwarePersistenceUnitManager.java

protected void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) {
    super.postProcessPersistenceUnitInfo(pui);

    // This our template persistence unit that we are post-processing
    // so let's just skip.
    if (isApplicationPersistenceUnit(pui)) {
        return;/*from  ww w  .  j a  v  a 2s .co m*/
    }

    final MutablePersistenceUnitInfo mainPui = getMainPersistenceUnitInfo(pui);

    if (strict) {
        pui.addJarFileUrl(pui.getPersistenceUnitRootUrl());
    }

    if (mainPui != null) {
        if (strict) {
            if (logger.isDebugEnabled()) {
                logger.debug("Merging existing jar file urls " + mainPui.getJarFileUrls()
                        + " to persistence unit [" + pui.getPersistenceUnitName() + "]");
            }
            copyPersistenceUnit(mainPui, pui);
            if (logger.isDebugEnabled()) {
                logger.debug("Persistence unit[" + pui.getPersistenceUnitName() + "] has now "
                        + "the following jar file urls " + pui.getJarFileUrls() + "");
            }
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("Merging information from [" + pui.getPersistenceUnitName() + "] " + "to ["
                        + mainPui.getPersistenceUnitName() + "]");
            }
            mergePersistenceUnit(pui, mainPui);
            if (logger.isDebugEnabled()) {
                logger.debug("Persistence unit[" + mainPui.getPersistenceUnitName() + "] has now "
                        + "the following jar file urls " + mainPui.getJarFileUrls() + "");
            }
        }
    } else if (!pui.getPersistenceUnitName().equals(persistenceUnitName)) {
        logger.debug("Adding persistence unit [" + pui.getPersistenceUnitName() + "] as is (no merging)");
    }
}

From source file:net.ggtools.maven.ddlgenerator.MultiConfigAwarePersistenceUnitManager.java

/**
 * {@inheritDoc}.//from  w w  w.  j  a va  2s  . c  o m
 */
@Override
protected void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) {
    super.postProcessPersistenceUnitInfo(pui);

    // This our template persistence unit that we are post-processing
    // so let's just skip.
    if (isApplicationPersistenceUnit(pui)) {
        return;
    }

    final MutablePersistenceUnitInfo mainPui = getMainPersistenceUnitInfo(pui);

    if (strict) {
        pui.addJarFileUrl(pui.getPersistenceUnitRootUrl());
    }

    if (mainPui != null) {
        if (strict) {
            if (log.isDebugEnabled()) {
                log.debug("Merging existing jar file urls " + mainPui.getJarFileUrls()
                        + " to persistence unit [" + pui.getPersistenceUnitName() + "]");
            }
            copyPersistenceUnit(mainPui, pui);
            if (log.isDebugEnabled()) {
                log.debug("Persistence unit[" + pui.getPersistenceUnitName() + "] has now "
                        + "the following jar file urls " + pui.getJarFileUrls() + "");
            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Merging information from [" + pui.getPersistenceUnitName() + "] " + "to ["
                        + mainPui.getPersistenceUnitName() + "]");
            }
            mergePersistenceUnit(pui, mainPui);
            if (log.isDebugEnabled()) {
                log.debug("Persistence unit[" + mainPui.getPersistenceUnitName() + "] has now "
                        + "the following jar file urls " + mainPui.getJarFileUrls());
            }
        }
    } else if (!pui.getPersistenceUnitName().equals(persistenceUnitName)) {
        log.debug("Adding persistence unit [" + pui.getPersistenceUnitName() + "] as is (no merging)");
    }
}

From source file:org.broadleafcommerce.common.extensibility.jpa.MergePersistenceUnitManager.java

@Override
protected void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo newPU) {
    super.postProcessPersistenceUnitInfo(newPU);
    ConfigurationOnlyState state = ConfigurationOnlyState.getState();
    String persistenceUnitName = newPU.getPersistenceUnitName();
    MutablePersistenceUnitInfo pui = getMergedUnit(persistenceUnitName, newPU);

    List<String> managedClassNames = newPU.getManagedClassNames();
    for (String managedClassName : managedClassNames) {
        if (!pui.getManagedClassNames().contains(managedClassName)) {
            pui.addManagedClassName(managedClassName);
        }/*from  ww  w. jav  a 2  s  .  c  om*/
    }
    List<String> mappingFileNames = newPU.getMappingFileNames();
    for (String mappingFileName : mappingFileNames) {
        if (!pui.getMappingFileNames().contains(mappingFileName)) {
            pui.addMappingFileName(mappingFileName);
        }
    }
    pui.setExcludeUnlistedClasses(newPU.excludeUnlistedClasses());
    for (URL url : newPU.getJarFileUrls()) {
        // Avoid duplicate class scanning by Ejb3Configuration. Do not re-add the URL to the list of jars for this
        // persistence unit or duplicate the persistence unit root URL location (both types of locations are scanned)
        if (!pui.getJarFileUrls().contains(url) && !pui.getPersistenceUnitRootUrl().equals(url)) {
            pui.addJarFileUrl(url);
        }
    }
    if (pui.getProperties() == null) {
        pui.setProperties(newPU.getProperties());
    } else {
        Properties props = newPU.getProperties();
        if (props != null) {
            for (Object key : props.keySet()) {
                pui.getProperties().put(key, props.get(key));
                for (BroadleafClassTransformer transformer : classTransformers) {
                    try {
                        transformer.compileJPAProperties(props, key);
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
    }
    if (state == null || !state.isConfigurationOnly()) {
        if (newPU.getJtaDataSource() != null) {
            pui.setJtaDataSource(newPU.getJtaDataSource());
        }
        if (newPU.getNonJtaDataSource() != null) {
            pui.setNonJtaDataSource(newPU.getNonJtaDataSource());
        }
    } else {
        pui.getProperties().setProperty("hibernate.hbm2ddl.auto", "none");
        pui.getProperties().setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false");
    }
    pui.setTransactionType(newPU.getTransactionType());
    if (newPU.getPersistenceProviderClassName() != null) {
        pui.setPersistenceProviderClassName(newPU.getPersistenceProviderClassName());
    }
    if (newPU.getPersistenceProviderPackageName() != null) {
        pui.setPersistenceProviderPackageName(newPU.getPersistenceProviderPackageName());
    }
}