001/* 002 * Copyright 2012-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.loader; 018 019import org.springframework.boot.loader.archive.Archive; 020 021/** 022 * {@link Launcher} for WAR based archives. This launcher for standard WAR archives. 023 * Supports dependencies in {@code WEB-INF/lib} as well as {@code WEB-INF/lib-provided}, 024 * classes are loaded from {@code WEB-INF/classes}. 025 * 026 * @author Phillip Webb 027 * @author Andy Wilkinson 028 */ 029public class WarLauncher extends ExecutableArchiveLauncher { 030 031 private static final String WEB_INF = "WEB-INF/"; 032 033 private static final String WEB_INF_CLASSES = WEB_INF + "classes/"; 034 035 private static final String WEB_INF_LIB = WEB_INF + "lib/"; 036 037 private static final String WEB_INF_LIB_PROVIDED = WEB_INF + "lib-provided/"; 038 039 public WarLauncher() { 040 } 041 042 protected WarLauncher(Archive archive) { 043 super(archive); 044 } 045 046 @Override 047 public boolean isNestedArchive(Archive.Entry entry) { 048 if (entry.isDirectory()) { 049 return entry.getName().equals(WEB_INF_CLASSES); 050 } 051 else { 052 return entry.getName().startsWith(WEB_INF_LIB) 053 || entry.getName().startsWith(WEB_INF_LIB_PROVIDED); 054 } 055 } 056 057 public static void main(String[] args) throws Exception { 058 new WarLauncher().launch(args); 059 } 060 061}