jpa/subsystem/src/main/java/org/jboss/as/jpa/container/PersistenceUnitSearch.java
private static PersistenceUnitMetadata findWithinDeployment(DeploymentUnit unit, String persistenceUnitName) {
        if (traceEnabled) {
            ROOT_LOGGER.tracef("pu findWithinDeployment searching for %s", persistenceUnitName);
        }

        for (ResourceRoot root : DeploymentUtils.allResourceRoots(unit)) {
            PersistenceUnitMetadataHolder holder = root.getAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS);
            if (holder == null || holder.getPersistenceUnits() == null) {
                if (traceEnabled) {
                    ROOT_LOGGER.tracef("pu findWithinDeployment skipping empty pu holder for %s", persistenceUnitName);
                }
                continue;
            }

            ambiguousPUError(unit, persistenceUnitName, holder);
            persistenceUnitName = defaultPersistenceUnitName(persistenceUnitName, holder);

            for (PersistenceUnitMetadata persistenceUnit : holder.getPersistenceUnits()) {
                if (traceEnabled) {
                    ROOT_LOGGER.tracef("findWithinDeployment check '%s' against pu '%s'", persistenceUnitName, persistenceUnit.getPersistenceUnitName());
                }
                if (persistenceUnitName == null || persistenceUnitName.length() == 0 || persistenceUnit.getPersistenceUnitName().equals(persistenceUnitName)) {
                    if (traceEnabled) {
                        ROOT_LOGGER.tracef("findWithinDeployment matched '%s' against pu '%s'", persistenceUnitName, persistenceUnit.getPersistenceUnitName());
                    }
                    return persistenceUnit;
                }
            }
        }
        return null;
    }
private static PersistenceUnitMetadata findWithinDeployment(DeploymentUnit unit, String persistenceUnitName) {
        if (traceEnabled) {
            ROOT_LOGGER.tracef("pu findWithinDeployment searching for %s", persistenceUnitName);
        }

        for (ResourceRoot root : DeploymentUtils.allResourceRoots(unit)) {
            PersistenceUnitMetadataHolder holder = root.getAttachment(PersistenceUnitMetadataHolder.PERSISTENCE_UNITS);
            if (holder == null || holder.getPersistenceUnits() == null) {
                if (traceEnabled) {
                    ROOT_LOGGER.tracef("pu findWithinDeployment skipping empty pu holder for %s", persistenceUnitName);
                }
                continue;
            }

            ambiguousPUError(unit, persistenceUnitName, holder);
            persistenceUnitName = defaultPersistenceUnitName(persistenceUnitName, holder);

            for (PersistenceUnitMetadata persistenceUnit : holder.getPersistenceUnits()) {
                if (traceEnabled) {
                    ROOT_LOGGER.tracef("findWithinDeployment check '%s' against pu '%s'", persistenceUnitName, persistenceUnit.getPersistenceUnitName());
                }
                if (persistenceUnitName == null || persistenceUnitName.length() == 0 || persistenceUnit.getPersistenceUnitName().equals(persistenceUnitName)) {
                    if (traceEnabled) {
                        ROOT_LOGGER.tracef("findWithinDeployment matched '%s' against pu '%s'", persistenceUnitName, persistenceUnit.getPersistenceUnitName());
                    }
                    return persistenceUnit;
                }
            }
        }
        return null;
    }
private static PersistenceUnitMetadata findWithinDeployment ( DeploymentUnit unit , String persistenceUnitName ) { if ( traceEnabled ) { ROOT_LOGGER . tracef ( "pu findWithinDeployment searching for %s" , persistenceUnitName ) ; } for ( ResourceRoot root : DeploymentUtils . allResourceRoots ( unit ) ) { PersistenceUnitMetadataHolder holder = root . getAttachment ( PersistenceUnitMetadataHolder . PERSISTENCE_UNITS ) ; if ( holder == null || holder . getPersistenceUnits ( ) == null ) { if ( traceEnabled ) { ROOT_LOGGER . tracef ( "pu findWithinDeployment skipping empty pu holder for %s" , persistenceUnitName ) ; } continue ; } ambiguousPUError ( unit , persistenceUnitName , holder ) ; persistenceUnitName = defaultPersistenceUnitName ( persistenceUnitName , holder ) ; for ( PersistenceUnitMetadata persistenceUnit : holder . getPersistenceUnits ( ) ) { if ( traceEnabled ) { ROOT_LOGGER . tracef ( "findWithinDeployment check '%s' against pu '%s'" , persistenceUnitName , persistenceUnit . getPersistenceUnitName ( ) ) ; } if ( persistenceUnitName == null || persistenceUnitName . length ( ) == 0 || persistenceUnit . getPersistenceUnitName ( ) . equals ( persistenceUnitName ) ) { if ( traceEnabled ) { ROOT_LOGGER . tracef ( "findWithinDeployment matched '%s' against pu '%s'" , persistenceUnitName , persistenceUnit . getPersistenceUnitName ( ) ) ; } return persistenceUnit ; } } } return null ; }
/*
When finding the default persistence unit, the first persistence unit encountered is returned.
/ * When finding the default persistence unit the first persistence unit encountered is returned .