Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
EasyBeans Copyright (C) 2009 Bull S.A.S. Contact: This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -------------------------------------------------------------------------- $Id: 5612 2010-10-04 14:13:02Z benoitf $ --------------------------------------------------------------------------

Copyright (c) 1998, 2008 Oracle. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 which accompanies this distribution. The Eclipse Public License is available at and the Eclipse Distribution License is available at Contributors: Oracle - initial API and implementation from Oracle TopLink /
 package org.eclipse.persistence.internal.jpa.deployment;
This is an implementation of Archive when container returns a file: url that refers to a jar file. e.g. file:/tmp/a_ear/lib/pu.jar

Adriana Danes : Allow to search the classes in a war file
 public class JarFileArchive implements Archive {
     private JarFile jarFile;
     private URL rootURL;
     private Logger logger;
     public JarFileArchive(JarFile jarFilethrows MalformedURLException {
     public JarFileArchive(JarFile jarFileLogger loggerthrows MalformedURLException {
         logger.entering("JarFileArchive""JarFileArchive"// NOI18N
                 new Object[] {jarFile});
         this. = logger;
         this. = jarFile;
          = new File(jarFile.getName()).toURI().toURL();
         logger.logp(."JarFileArchive""JarFileArchive"// NOI18N
                 "rootURL = {0}"); // NOI18N
     public Iterator<StringgetEntries() {
         Enumeration<JarEntryjarEntries = .entries();
         ArrayList<Stringresult = new ArrayList<String>();
         while (jarEntries.hasMoreElements()) {
             final JarEntry jarEntry = jarEntries.nextElement();
             if (!jarEntry.isDirectory()) { // exclude directory entries
                 String entryName = jarEntry.getName();
                 if (isWar()) {
                     // Check if entry name needs treatment
                     entryName = treat(entryName);
         return result.iterator();
     public InputStream getEntry(String entryPaththrows IOException {
         InputStream is = null;
        final ZipEntry entry = .getEntry(entryPath);
        if (entry != null) {
            is = .getInputStream(entry);
        return is;
    public URL getEntryAsURL(String entryPaththrows IOException {
        return .getEntry(entryPath) != null ? new URL("jar:" +  + "!/" + entryPath) : null// NOI18N
    public URL getRootURL() {
        return ;

    private final String warSuffix = ".war";
    private final String classSuffix = ".class";
    private final String webPrefix = "WEB-INF/classes";
    private final int webPrefixAfterIndex = .length();
    private boolean isWar() {
        String rootPath = .getPath();
        if (rootPath.endsWith()) {
            return true;
        return false;
    private String treat(final String name) {
        // treat WEB-INF/classes case
        if (name.endsWith()) {
            if (name.startsWith()) {
                return name.substring( + 1);
        return name;
New to GrepCode? Check out our FAQ X