001/* 002 * Copyright 2012-2016 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 super(); 041 } 042 043 protected WarLauncher(Archive archive) { 044 super(archive); 045 } 046 047 @Override 048 public boolean isNestedArchive(Archive.Entry entry) { 049 if (entry.isDirectory()) { 050 return entry.getName().equals(WEB_INF_CLASSES); 051 } 052 else { 053 return entry.getName().startsWith(WEB_INF_LIB) 054 || entry.getName().startsWith(WEB_INF_LIB_PROVIDED); 055 } 056 } 057 058 public static void main(String[] args) throws Exception { 059 new WarLauncher().launch(args); 060 } 061 062}