public static Collection getPersistenceUnits()

in jpa-container/src/main/java/org/apache/aries/jpa/container/parser/impl/PersistenceUnitParser.java [60:95]


    public static Collection<PersistenceUnit> getPersistenceUnits(Bundle bundle) {
        Collection<PersistenceUnit> punits = new ArrayList<PersistenceUnit>();
        Dictionary<String, String> headers = bundle.getHeaders();
        String metaPersistence = headers.get(PERSISTENCE_UNIT_HEADER);

        Set<String> locations = new HashSet<String>();
        if (metaPersistence == null) {
            return punits;
        }

        if (!metaPersistence.isEmpty()) {
            // Split apart the header to get the individual entries
            for (String s : metaPersistence.split(",")) {
                locations.add(s.trim());
            }
        }
        
        if (!locations.contains(DEFAULT_PERSISTENCE_LOCATION)) {
            locations.add(DEFAULT_PERSISTENCE_LOCATION);
        }

        // Find the file and add it to our list
        for (String location : locations) {
            try {
                InputStream is = locateFile(bundle, location);
                if (is != null) {
                    parse(bundle, is, punits);
                }
            } catch (Exception e) {
                LOG.error("exception.while.locating.descriptor", e);
                return Collections.emptySet();
            }
        }
        
        return punits;
    }