Package org.apache.openjpa.lib.meta

Examples of org.apache.openjpa.lib.meta.MetaDataIterator


                }
            }
        }
        if (rsrcs != null) {
            String rsrc;
            MetaDataIterator mitr;
            for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                rsrc = (String) itr.next();
                if (rsrc.endsWith(".jar")) {
                    url = AccessController.doPrivileged(
                            J2DoPrivHelper.getResourceAction(loader, rsrc));
                    if (url != null) {
                        if (log.isTraceEnabled()) {
                            log.trace(_loc.get("scanning-jar-stream-url", url));
                        }
                        try {
                            InputStream is = (InputStream) AccessController.doPrivileged(
                                    J2DoPrivHelper.openStreamAction(url));
                            scan(new ZipStreamMetaDataIterator(new ZipInputStream(is), newMetaDataFilter()), cparser,
                                    names, true, url);
                        } catch (PrivilegedActionException pae) {
                            throw (IOException) pae.getException();
                        }
                    }
                } else {
                    if (log.isTraceEnabled()) {
                        log.trace(_loc.get("scanning-resource", rsrc));
                    }
                    mitr = new ResourceMetaDataIterator(rsrc, loader);
                    OpenJPAConfiguration conf = repos.getConfiguration();
                    Map peMap = null;
                    if (conf instanceof OpenJPAConfigurationImpl) {
                        peMap = ((OpenJPAConfigurationImpl) conf).getPersistenceEnvironment();
                    }
                    URL puUrl = peMap == null ? null : (URL) peMap.get(PERSISTENCE_UNIT_ROOT_URL);
                    List<String> mappingFileNames =
                            peMap == null ? null : (List<String>) peMap.get(MAPPING_FILE_NAMES);
                    List<URL> jars = peMap == null ? null : (List<URL>) peMap.get(JAR_FILE_URLS);
                    String puUrlString = puUrl == null ? null : puUrl.toString();
                    if (log.isTraceEnabled()) {
                        log.trace(_loc.get("pu-root-url", puUrlString));
                    }

                    List<URL> mitrUrls = new ArrayList<URL>(3);
                    while (mitr.hasNext()) {
                        url = (URL) mitr.next();
                        String urlString = url.toString();
                        if (log.isTraceEnabled()) {
                            log.trace(_loc.get("resource-url", urlString));
                        }
                        if (peMap != null) {
                            //OPENJPA-2102: decode the URL to remove such things a spaces (' ') encoded as '%20'
                            if (puUrlString != null && decode(urlString).indexOf(decode(puUrlString)) != -1) {
                                mitrUrls.add(url);
                            }
                            if (mappingFileNames != null && !mappingFileNames.isEmpty()) {
                                for (String mappingFileName : mappingFileNames) {
                                    if (log.isTraceEnabled()) {
                                        log.trace(_loc.get("mapping-file-name", mappingFileName));
                                    }
                                    if (urlString.indexOf(mappingFileName) != -1) {
                                        mitrUrls.add(url);
                                    }
                                }
                            }

                            if (jars != null && !jars.isEmpty()) {
                                for (URL jarUrl : jars) {
                                    if (log.isTraceEnabled()) {
                                        log.trace(_loc.get("jar-file-url", jarUrl));
                                    }
                                    if (urlString.indexOf(jarUrl.toString()) != -1) {
                                        mitrUrls.add(url);
                                    }
                                }
                            }
                        } else {
                            mitrUrls.add(url);
                        }
                    }
                    mitr.close();

                    for (Object obj : mitrUrls) {
                        url = (URL) obj;
                        clss = cparser.parseTypeNames(new URLMetaDataIterator(url));
                        List<String> newNames = Arrays.asList(clss);
View Full Code Here


                }
            }
        }
        if (rsrcs != null) {
            String rsrc;
            MetaDataIterator mitr;
            for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                rsrc = (String) itr.next();
                if (rsrc.endsWith(".jar")) {
                    url = (URL) AccessController.doPrivileged(
                        J2DoPrivHelper.getResourceAction(loader, rsrc));
                    if (url != null) {
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scanning-jar-stream-url", url));
                        try {
                            InputStream is = (InputStream)
                                AccessController.doPrivileged(
                                    J2DoPrivHelper.openStreamAction(url));
                            scan(new ZipStreamMetaDataIterator
                                (new ZipInputStream(is),
                                newMetaDataFilter()), cparser, names, true,
                                url);
                        } catch (PrivilegedActionException pae) {
                            throw (IOException) pae.getException();
                        }
                    }
                } else {
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("scanning-resource", rsrc));
                    mitr = new ResourceMetaDataIterator(rsrc, loader);
                    while (mitr.hasNext()) {
                        url = (URL) mitr.next();
                        clss = cparser.parseTypeNames(new URLMetaDataIterator
                            (url));
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scan-found-names", clss, rsrc));
                        names.addAll(Arrays.asList(clss));
                        mapPersistentTypeNames(url, clss);
                    }
                    mitr.close();
                }
            }
        }
        if (cpath != null) {
            String[] dirs = (String[]) cpath.toArray(new String[cpath.size()]);
View Full Code Here

                }
            }
        }
        if (rsrcs != null) {
            String rsrc;
            MetaDataIterator mitr;
            for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                rsrc = (String) itr.next();
                if (rsrc.endsWith(".jar")) {
                    url = AccessController.doPrivileged(
                        J2DoPrivHelper.getResourceAction(loader, rsrc));
                    if (url != null) {
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scanning-jar-stream-url", url));
                        try {
                            InputStream is = (InputStream)
                                AccessController.doPrivileged(
                                    J2DoPrivHelper.openStreamAction(url));
                            scan(new ZipStreamMetaDataIterator
                                (new ZipInputStream(is),
                                newMetaDataFilter()), cparser, names, true,
                                url);
                        } catch (PrivilegedActionException pae) {
                            throw (IOException) pae.getException();
                        }
                    }
                } else {
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("scanning-resource", rsrc));
                    mitr = new ResourceMetaDataIterator(rsrc, loader);
                    OpenJPAConfiguration conf = repos.getConfiguration();
                    Map peMap = null;
                    if (conf instanceof OpenJPAConfigurationImpl)
                        peMap = ((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment();
                    URL puUrl = peMap == null ? null : (URL) peMap.get(PERSISTENCE_UNIT_ROOT_URL);
                    List<String> mappingFileNames =
                        peMap == null ? null : (List<String>) peMap.get(MAPPING_FILE_NAMES);
                    List<URL> jars = peMap == null ? null : (List<URL>)peMap.get(JAR_FILE_URLS);
                    String puUrlString = puUrl == null ? null : puUrl.toString();
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("pu-root-url", puUrlString));

                    URL puORMUrl = null;
                    try {
                        if (puUrlString != null) {
                            String puORMUrlStr = puUrlString + (puUrlString.endsWith("/") ? "" : "/") + rsrc;
                            puORMUrl = AccessController.doPrivileged(J2DoPrivHelper.createURL(puORMUrlStr));
                        }
                    } catch (PrivilegedActionException e) {
                        throw new IOException("Error generating puORMUrlStr.", e.getCause());
                    }

                    List<URL> urls = new ArrayList<URL>(3);
                    while (mitr.hasNext()) {
                        url = (URL) mitr.next();
                        String urlString = url.toString();
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("resource-url", urlString));
                        if (peMap != null) {
                          //OPENJPA-2102: decode the URL to remove such things a spaces (' ') encoded as '%20'
                            if (puUrlString != null && decode(urlString).indexOf(decode(puUrlString)) != -1) {
                                urls.add(url);
                            } else if (puORMUrl != null && puORMUrl.equals(url)) {
                                // Check URL equality to support encapsulating URL protocols
                                urls.add(url);
                            }
                            if (mappingFileNames != null && mappingFileNames.size() != 0) {
                                for (String mappingFileName : mappingFileNames) {
                                    if (log.isTraceEnabled())
                                        log.trace(_loc.get("mapping-file-name", mappingFileName));
                                    if (urlString.indexOf(mappingFileName) != -1)
                                        urls.add(url);
                                }
                            }

                            if (jars != null && jars.size() != 0) {
                                for (URL jarUrl : jars) {
                                    if (log.isTraceEnabled())
                                        log.trace(_loc.get("jar-file-url", jarUrl));
                                    if (urlString.indexOf(jarUrl.toString()) != -1)
                                        urls.add(url);
                                }
                            }
                        } else {
                            urls.add(url);
                        }
                    }
                    mitr.close();

                    for (Object obj : urls) {
                        url = (URL) obj;
                        clss = cparser.parseTypeNames(new URLMetaDataIterator
                            (url));
View Full Code Here

                }
            }
        }
        if (rsrcs != null) {
            String rsrc;
            MetaDataIterator mitr;
            for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                rsrc = (String) itr.next();
                if (rsrc.endsWith(".jar")) {
                    url = AccessController.doPrivileged(
                            J2DoPrivHelper.getResourceAction(loader, rsrc));
                    if (url != null) {
                        if (log.isTraceEnabled()) {
                            log.trace(_loc.get("scanning-jar-stream-url", url));
                        }
                        try {
                            InputStream is = (InputStream) AccessController.doPrivileged(
                                    J2DoPrivHelper.openStreamAction(url));
                            scan(new ZipStreamMetaDataIterator(new ZipInputStream(is), newMetaDataFilter()), cparser,
                                    names, true, url);
                        } catch (PrivilegedActionException pae) {
                            throw (IOException) pae.getException();
                        }
                    }
                } else {
                    if (log.isTraceEnabled()) {
                        log.trace(_loc.get("scanning-resource", rsrc));
                    }
                    mitr = new ResourceMetaDataIterator(rsrc, loader);
                    OpenJPAConfiguration conf = repos.getConfiguration();
                    Map peMap = null;
                    if (conf instanceof OpenJPAConfigurationImpl) {
                        peMap = ((OpenJPAConfigurationImpl) conf).getPersistenceEnvironment();
                    }
                    URL puUrl = peMap == null ? null : (URL) peMap.get(PERSISTENCE_UNIT_ROOT_URL);
                    List<String> mappingFileNames =
                            peMap == null ? null : (List<String>) peMap.get(MAPPING_FILE_NAMES);
                    List<URL> jars = peMap == null ? null : (List<URL>) peMap.get(JAR_FILE_URLS);
                    String puUrlString = puUrl == null ? null : puUrl.toString();
                    if (log.isTraceEnabled()) {
                        log.trace(_loc.get("pu-root-url", puUrlString));
                    }

                    List<URL> mitrUrls = new ArrayList<URL>(3);
                    while (mitr.hasNext()) {
                        url = (URL) mitr.next();
                        String urlString = url.toString();
                        if (log.isTraceEnabled()) {
                            log.trace(_loc.get("resource-url", urlString));
                        }
                        if (peMap != null) {
                            //OPENJPA-2102: decode the URL to remove such things a spaces (' ') encoded as '%20'
                            if (puUrlString != null && decode(urlString).indexOf(decode(puUrlString)) != -1) {
                                mitrUrls.add(url);
                            }
                            if (mappingFileNames != null && !mappingFileNames.isEmpty()) {
                                for (String mappingFileName : mappingFileNames) {
                                    if (log.isTraceEnabled()) {
                                        log.trace(_loc.get("mapping-file-name", mappingFileName));
                                    }
                                    if (urlString.indexOf(mappingFileName) != -1) {
                                        mitrUrls.add(url);
                                    }
                                }
                            }

                            if (jars != null && !jars.isEmpty()) {
                                for (URL jarUrl : jars) {
                                    if (log.isTraceEnabled()) {
                                        log.trace(_loc.get("jar-file-url", jarUrl));
                                    }
                                    if (urlString.indexOf(jarUrl.toString()) != -1) {
                                        mitrUrls.add(url);
                                    }
                                }
                            }
                        } else {
                            mitrUrls.add(url);
                        }
                    }
                    mitr.close();

                    for (Object obj : mitrUrls) {
                        url = (URL) obj;
                        clss = cparser.parseTypeNames(new URLMetaDataIterator(url));
                        List<String> newNames = Arrays.asList(clss);
View Full Code Here

                }
            }
        }
        if (rsrcs != null) {
            String rsrc;
            MetaDataIterator mitr;
            for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                rsrc = (String) itr.next();
                if (rsrc.endsWith(".jar")) {
                    url = (URL) AccessController.doPrivileged(
                        J2DoPrivHelper.getResourceAction(loader, rsrc));
                    if (url != null) {
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scanning-jar-stream-url", url));
                        try {
                            InputStream is = (InputStream)
                                AccessController.doPrivileged(
                                    J2DoPrivHelper.openStreamAction(url));
                            scan(new ZipStreamMetaDataIterator
                                (new ZipInputStream(is),
                                newMetaDataFilter()), cparser, names, true,
                                url);
                        } catch (PrivilegedActionException pae) {
                            throw (IOException) pae.getException();
                        }
                    }
                } else {
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("scanning-resource", rsrc));
                    mitr = new ResourceMetaDataIterator(rsrc, loader);
                    while (mitr.hasNext()) {
                        url = (URL) mitr.next();
                        clss = cparser.parseTypeNames(new URLMetaDataIterator
                            (url));
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scan-found-names", clss, rsrc));
                        names.addAll(Arrays.asList(clss));
                        mapPersistentTypeNames(url, clss);
                    }
                    mitr.close();
                }
            }
        }
        if (cpath != null) {
            String[] dirs = (String[]) cpath.toArray(new String[cpath.size()]);
View Full Code Here

                }
            }
        }
        if (rsrcs != null) {
            String rsrc;
            MetaDataIterator mitr;
            for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                rsrc = (String) itr.next();
                if (rsrc.endsWith(".jar")) {
                    url = AccessController.doPrivileged(
                        J2DoPrivHelper.getResourceAction(loader, rsrc));
                    if (url != null) {
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scanning-jar-stream-url", url));
                        try {
                            InputStream is = (InputStream)
                                AccessController.doPrivileged(
                                    J2DoPrivHelper.openStreamAction(url));
                            scan(new ZipStreamMetaDataIterator
                                (new ZipInputStream(is),
                                newMetaDataFilter()), cparser, names, true,
                                url);
                        } catch (PrivilegedActionException pae) {
                            throw (IOException) pae.getException();
                        }
                    }
                } else {
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("scanning-resource", rsrc));
                    mitr = new ResourceMetaDataIterator(rsrc, loader);
                    OpenJPAConfiguration conf = repos.getConfiguration();
                    Map peMap = null;
                    if (conf instanceof OpenJPAConfigurationImpl)
                        peMap = ((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment();
                    URL puUrl = peMap == null ? null : (URL) peMap.get(PERSISTENCE_UNIT_ROOT_URL);
                    List<String> mappingFileNames =
                        peMap == null ? null : (List<String>) peMap.get(MAPPING_FILE_NAMES);
                    List<URL> jars = peMap == null ? null : (List<URL>)peMap.get(JAR_FILE_URLS);
                    String puUrlString = puUrl == null ? null : puUrl.toString();
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("pu-root-url", puUrlString));
         
                    URL puORMUrl = null;
                    try {
                        if (puUrlString != null) {
                            String puORMUrlStr = puUrlString + (puUrlString.endsWith("/") ? "" : "/") + rsrc;
                            puORMUrl = AccessController.doPrivileged(J2DoPrivHelper.createURL(puORMUrlStr));
                        }
                    } catch (PrivilegedActionException e) {
                        throw new IOException("Error generating puORMUrlStr.",
                                e.getCause());
                    }
         
                    List<URL> urls = new ArrayList<URL>(3);
                    while (mitr.hasNext()) {
                        url = (URL) mitr.next();
                        String urlString = url.toString();
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("resource-url", urlString));
                        if (peMap != null) {
                            //OPENJPA-2102: decode the URL to remove such things a spaces (' ') encoded as '%20'
                            if (puUrlString != null && decode(urlString).indexOf(decode(puUrlString)) != -1) {
                                urls.add(url);
                            } else if (puORMUrl != null && puORMUrl.equals(url)) {
                                // Check URL equality to support encapsulating URL protocols
                                urls.add(url);
                            }

                            if (mappingFileNames != null && mappingFileNames.size() != 0) {
                                for (String mappingFileName : mappingFileNames) {
                                    if (log.isTraceEnabled())
                                        log.trace(_loc.get("mapping-file-name", mappingFileName));
                                    if (urlString.indexOf(mappingFileName) != -1)
                                        urls.add(url);
                                }
                            }

                            if (jars != null && jars.size() != 0) {
                                for (URL jarUrl : jars) {
                                    if (log.isTraceEnabled())
                                        log.trace(_loc.get("jar-file-url", jarUrl));
                                    if (urlString.indexOf(jarUrl.toString()) != -1)
                                        urls.add(url);
                                }
                            }
                        } else {
                            urls.add(url);
                        }
                    }
                    mitr.close();

                    for (Object obj : urls) {
                        url = (URL) obj;
                        clss = cparser.parseTypeNames(new URLMetaDataIterator
                            (url));
View Full Code Here

                }
            }
        }
        if (rsrcs != null) {
            String rsrc;
            MetaDataIterator mitr;
            for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                rsrc = (String) itr.next();
                if (rsrc.endsWith(".jar")) {
                    url = AccessController.doPrivileged(
                        J2DoPrivHelper.getResourceAction(loader, rsrc));
                    if (url != null) {
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scanning-jar-stream-url", url));
                        try {
                            InputStream is = (InputStream)
                                AccessController.doPrivileged(
                                    J2DoPrivHelper.openStreamAction(url));
                            scan(new ZipStreamMetaDataIterator
                                (new ZipInputStream(is),
                                newMetaDataFilter()), cparser, names, true,
                                url);
                        } catch (PrivilegedActionException pae) {
                            throw (IOException) pae.getException();
                        }
                    }
                } else {
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("scanning-resource", rsrc));
                    mitr = new ResourceMetaDataIterator(rsrc, loader);
                    while (mitr.hasNext()) {
                        url = (URL) mitr.next();
                        clss = cparser.parseTypeNames(new URLMetaDataIterator
                            (url));
                        List<String> newNames = Arrays.asList(clss);
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scan-found-names", newNames,
                                    rsrc));
                        names.addAll(newNames);
                        mapPersistentTypeNames(url, clss);
                    }
                    mitr.close();
                }
            }
        }
        if (cpath != null) {
            String[] dirs = (String[]) cpath.toArray(new String[cpath.size()]);
View Full Code Here

                }
            }
        }
        if (rsrcs != null) {
            String rsrc;
            MetaDataIterator mitr;
            for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                rsrc = (String) itr.next();
                if (rsrc.endsWith(".jar")) {
                    url = AccessController.doPrivileged(
                        J2DoPrivHelper.getResourceAction(loader, rsrc));
                    if (url != null) {
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scanning-jar-stream-url", url));
                        try {
                            InputStream is = (InputStream)
                                AccessController.doPrivileged(
                                    J2DoPrivHelper.openStreamAction(url));
                            scan(new ZipStreamMetaDataIterator
                                (new ZipInputStream(is),
                                newMetaDataFilter()), cparser, names, true,
                                url);
                        } catch (PrivilegedActionException pae) {
                            throw (IOException) pae.getException();
                        }
                    }
                } else {
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("scanning-resource", rsrc));
                    mitr = new ResourceMetaDataIterator(rsrc, loader);
                    OpenJPAConfiguration conf = repos.getConfiguration();
                    Map peMap = null;
                    if (conf instanceof OpenJPAConfigurationImpl)
                        peMap = ((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment();
                    URL puUrl = peMap == null ? null : (URL) peMap.get(PERSISTENCE_UNIT_ROOT_URL);
                    List<String> mappingFileNames =
                        peMap == null ? null : (List<String>) peMap.get(MAPPING_FILE_NAMES);
                    List<URL> jars = peMap == null ? null : (List<URL>)peMap.get(JAR_FILE_URLS);
                    String puUrlString = puUrl == null ? null : puUrl.toString();
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("pu-root-url", puUrlString));

                    List<URL> urls = new ArrayList<URL>(3);
                    while (mitr.hasNext()) {
                        url = (URL) mitr.next();
                        String urlString = url.toString();
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("resource-url", urlString));
                        if (peMap != null) {
                            if (puUrlString != null && urlString.indexOf(puUrlString) != -1)
                                urls.add(url);
                            if (mappingFileNames != null && mappingFileNames.size() != 0) {
                                for (String mappingFileName : mappingFileNames) {
                                    if (log.isTraceEnabled())
                                        log.trace(_loc.get("mapping-file-name", mappingFileName));
                                    if (urlString.indexOf(mappingFileName) != -1)
                                        urls.add(url);
                                }
                            }

                            if (jars != null && jars.size() != 0) {
                                for (URL jarUrl : jars) {
                                    if (log.isTraceEnabled())
                                        log.trace(_loc.get("jar-file-url", jarUrl));
                                    if (urlString.indexOf(jarUrl.toString()) != -1)
                                        urls.add(url);
                                }
                            }
                        } else {
                            urls.add(url);
                        }
                    }
                    mitr.close();

                    for (Object obj : urls) {
                        url = (URL) obj;
                        clss = cparser.parseTypeNames(new URLMetaDataIterator
                            (url));
View Full Code Here

                }
            }
        }
        if (rsrcs != null) {
            String rsrc;
            MetaDataIterator mitr;
            for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                rsrc = (String) itr.next();
                if (rsrc.endsWith(".jar")) {
                    url = AccessController.doPrivileged(
                        J2DoPrivHelper.getResourceAction(loader, rsrc));
                    if (url != null) {
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scanning-jar-stream-url", url));
                        try {
                            InputStream is = (InputStream)
                                AccessController.doPrivileged(
                                    J2DoPrivHelper.openStreamAction(url));
                            scan(new ZipStreamMetaDataIterator
                                (new ZipInputStream(is),
                                newMetaDataFilter()), cparser, names, true,
                                url);
                        } catch (PrivilegedActionException pae) {
                            throw (IOException) pae.getException();
                        }
                    }
                } else {
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("scanning-resource", rsrc));
                    mitr = new ResourceMetaDataIterator(rsrc, loader);
                    OpenJPAConfiguration conf = repos.getConfiguration();
                    Map peMap = null;
                    if (conf instanceof OpenJPAConfigurationImpl)
                        peMap = ((OpenJPAConfigurationImpl)conf).getPersistenceEnvironment();
                    URL puUrl = peMap == null ? null : (URL) peMap.get(PERSISTENCE_UNIT_ROOT_URL);
                    List<String> mappingFileNames =
                        peMap == null ? null : (List<String>) peMap.get(MAPPING_FILE_NAMES);
                    List<URL> jars = peMap == null ? null : (List<URL>)peMap.get(JAR_FILE_URLS);
                    String puUrlString = puUrl == null ? null : puUrl.toString();
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("pu-root-url", puUrlString));

                    List<URL> urls = new ArrayList<URL>(3);
                    while (mitr.hasNext()) {
                        url = (URL) mitr.next();
                        String urlString = url.toString();
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("resource-url", urlString));
                        if (peMap != null) {
                          //OPENJPA-2102: decode the URL to remove such things a spaces (' ') encoded as '%20'
                            if (puUrlString != null && decode(urlString).indexOf(decode(puUrlString)) != -1)
                                urls.add(url);
                            if (mappingFileNames != null && mappingFileNames.size() != 0) {
                                for (String mappingFileName : mappingFileNames) {
                                    if (log.isTraceEnabled())
                                        log.trace(_loc.get("mapping-file-name", mappingFileName));
                                    if (urlString.indexOf(mappingFileName) != -1)
                                        urls.add(url);
                                }
                            }

                            if (jars != null && jars.size() != 0) {
                                for (URL jarUrl : jars) {
                                    if (log.isTraceEnabled())
                                        log.trace(_loc.get("jar-file-url", jarUrl));
                                    if (urlString.indexOf(jarUrl.toString()) != -1)
                                        urls.add(url);
                                }
                            }
                        } else {
                            urls.add(url);
                        }
                    }
                    mitr.close();

                    for (Object obj : urls) {
                        url = (URL) obj;
                        clss = cparser.parseTypeNames(new URLMetaDataIterator
                            (url));
View Full Code Here

                }
            }
        }
        if (rsrcs != null) {
            String rsrc;
            MetaDataIterator mitr;
            for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                rsrc = (String) itr.next();
                if (rsrc.endsWith(".jar")) {
                    url = AccessController.doPrivileged(
                        J2DoPrivHelper.getResourceAction(loader, rsrc));
                    if (url != null) {
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scanning-jar-stream-url", url));
                        try {
                            InputStream is = (InputStream)
                                AccessController.doPrivileged(
                                    J2DoPrivHelper.openStreamAction(url));
                            scan(new ZipStreamMetaDataIterator
                                (new ZipInputStream(is),
                                newMetaDataFilter()), cparser, names, true,
                                url);
                        } catch (PrivilegedActionException pae) {
                            throw (IOException) pae.getException();
                        }
                    }
                } else {
                    if (log.isTraceEnabled())
                        log.trace(_loc.get("scanning-resource", rsrc));
                    mitr = new ResourceMetaDataIterator(rsrc, loader);
                    while (mitr.hasNext()) {
                        url = (URL) mitr.next();
                        clss = cparser.parseTypeNames(new URLMetaDataIterator
                            (url));
                        List<String> newNames = Arrays.asList(clss);
                        if (log.isTraceEnabled())
                            log.trace(_loc.get("scan-found-names", newNames,
                                    rsrc));
                        names.addAll(newNames);
                        mapPersistentTypeNames(url, clss);
                    }
                    mitr.close();
                }
            }
        }
        if (cpath != null) {
            String[] dirs = (String[]) cpath.toArray(new String[cpath.size()]);
View Full Code Here

TOP

Related Classes of org.apache.openjpa.lib.meta.MetaDataIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.