Repository: tomee Updated Branches: refs/heads/tomee-1.7.x fbb34e385 -> bd7dbd0f3
http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/tomee/apache-tomee/src/main/resources/service.install.as.admin.bat ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/resources/service.install.as.admin.bat b/tomee/apache-tomee/src/main/resources/service.install.as.admin.bat index 8569a4d..dcfbe6b 100644 --- a/tomee/apache-tomee/src/main/resources/service.install.as.admin.bat +++ b/tomee/apache-tomee/src/main/resources/service.install.as.admin.bat @@ -1,33 +1,33 @@ -@echo off -cls -REM================================================ -REM Licensed to the Apache Software Foundation (ASF) under one or more -REM contributor license agreements. See the NOTICE file distributed with -REM this work for additional information regarding copyright ownership. -REM The ASF licenses this file to You under the Apache License, Version 2.0 -REM (the "License"); you may not use this file except in compliance with -REM the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. -REM _______________________________________________ -REM $Rev$ -REM================================================ - -@if not "%ECHO%" == "" echo %ECHO% -@if "%OS%" == "Windows_NT" setlocal - -if "%OS%" == "Windows_NT" ( - set "DIRNAME=%~dp0%" -) else ( - set DIRNAME=.\ -) - -pushd %DIRNAME% - +@echo off +cls +REM================================================ +REM Licensed to the Apache Software Foundation (ASF) under one or more +REM contributor license agreements. See the NOTICE file distributed with +REM this work for additional information regarding copyright ownership. +REM The ASF licenses this file to You under the Apache License, Version 2.0 +REM (the "License"); you may not use this file except in compliance with +REM the License. You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM _______________________________________________ +REM $Rev$ +REM================================================ + +@if not "%ECHO%" == "" echo %ECHO% +@if "%OS%" == "Windows_NT" setlocal + +if "%OS%" == "Windows_NT" ( + set "DIRNAME=%~dp0%" +) else ( + set DIRNAME=.\ +) + +pushd %DIRNAME% + service install \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/tomee/apache-tomee/src/main/resources/service.remove.as.admin.bat ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/resources/service.remove.as.admin.bat b/tomee/apache-tomee/src/main/resources/service.remove.as.admin.bat index 3b5d4ac..bc5fe0a 100644 --- a/tomee/apache-tomee/src/main/resources/service.remove.as.admin.bat +++ b/tomee/apache-tomee/src/main/resources/service.remove.as.admin.bat @@ -1,33 +1,33 @@ -@echo off -cls -REM================================================ -REM Licensed to the Apache Software Foundation (ASF) under one or more -REM contributor license agreements. See the NOTICE file distributed with -REM this work for additional information regarding copyright ownership. -REM The ASF licenses this file to You under the Apache License, Version 2.0 -REM (the "License"); you may not use this file except in compliance with -REM the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. -REM _______________________________________________ -REM $Rev$ -REM================================================ - -@if not "%ECHO%" == "" echo %ECHO% -@if "%OS%" == "Windows_NT" setlocal - -if "%OS%" == "Windows_NT" ( - set "DIRNAME=%~dp0%" -) else ( - set DIRNAME=.\ -) - -pushd %DIRNAME% - +@echo off +cls +REM================================================ +REM Licensed to the Apache Software Foundation (ASF) under one or more +REM contributor license agreements. See the NOTICE file distributed with +REM this work for additional information regarding copyright ownership. +REM The ASF licenses this file to You under the Apache License, Version 2.0 +REM (the "License"); you may not use this file except in compliance with +REM the License. You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM _______________________________________________ +REM $Rev$ +REM================================================ + +@if not "%ECHO%" == "" echo %ECHO% +@if "%OS%" == "Windows_NT" setlocal + +if "%OS%" == "Windows_NT" ( + set "DIRNAME=%~dp0%" +) else ( + set DIRNAME=.\ +) + +pushd %DIRNAME% + service remove \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/tomee/apache-tomee/src/main/resources/tomee.bat ---------------------------------------------------------------------- diff --git a/tomee/apache-tomee/src/main/resources/tomee.bat b/tomee/apache-tomee/src/main/resources/tomee.bat index a945bbd..6c6045e 100644 --- a/tomee/apache-tomee/src/main/resources/tomee.bat +++ b/tomee/apache-tomee/src/main/resources/tomee.bat @@ -1,85 +1,85 @@ -@echo off -rem Licensed to the Apache Software Foundation (ASF) under one or more -rem contributor license agreements. See the NOTICE file distributed with -rem this work for additional information regarding copyright ownership. -rem The ASF licenses this file to You under the Apache License, Version 2.0 -rem (the "License"); you may not use this file except in compliance with -rem the License. You may obtain a copy of the License at -rem -rem http://www.apache.org/licenses/LICENSE-2.0 -rem -rem Unless required by applicable law or agreed to in writing, software -rem distributed under the License is distributed on an "AS IS" BASIS, -rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -rem See the License for the specific language governing permissions and -rem limitations under the License. - -if "%OS%" == "Windows_NT" setlocal - -set port=8080 - -rem Guess CATALINA_HOME if not defined -set "CURRENT_DIR=%cd%" -if not "%CATALINA_HOME%" == "" goto gotHome -set "CATALINA_HOME=%CURRENT_DIR%" -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -cd .. -set "CATALINA_HOME=%cd%" -cd "%CURRENT_DIR%" -:gotHome - -if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome -echo The CATALINA_HOME environment variable is not defined correctly -echo This environment variable is needed to run this program -goto end -:okHome - -rem Copy CATALINA_BASE from CATALINA_HOME if not defined -if not "%CATALINA_BASE%" == "" goto gotBase -set "CATALINA_BASE=%CATALINA_HOME%" -:gotBase - -rem Ensure that any user defined CLASSPATH variables are not used on startup, -rem but allow them to be specified in setenv.bat, in rare case when it is needed. -set CLASSPATH= - -rem Get standard Java environment variables -if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath -echo Cannot find "%CATALINA_HOME%\bin\setclasspath.bat" -echo This file is needed to run this program -goto end -:okSetclasspath -call "%CATALINA_HOME%\bin\setclasspath.bat" %1 -if errorlevel 1 goto end - - -if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir -set "CATALINA_TMPDIR=%CATALINA_BASE%\temp" -:gotTmpdir - - -rem create classpath -setlocal enabledelayedexpansion - -set cp="%CATALINA_HOME%\bin\tomcat-juli.jar" -set lib="%CATALINA_HOME%\lib\" -echo %lib% -for %%F in (%lib%/*.jar) do ( - set cp=!cp!;%%F% -) - -if ""%1"" == ""deploy"" goto doDeploy -if ""%1"" == ""undeploy"" goto doUndeploy -goto doExec - -:doDeploy -:doUndeploy -%_RUNJAVA% -cp "%cp%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" org.apache.openejb.cli.Bootstrap %1 -s http://localhost:%port%/tomee/ejb %2 -goto end - -:doExec -%_RUNJAVA% -cp "%cp%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" org.apache.openejb.cli.Bootstrap %* -goto end - -:end - +@echo off +rem Licensed to the Apache Software Foundation (ASF) under one or more +rem contributor license agreements. See the NOTICE file distributed with +rem this work for additional information regarding copyright ownership. +rem The ASF licenses this file to You under the Apache License, Version 2.0 +rem (the "License"); you may not use this file except in compliance with +rem the License. You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +if "%OS%" == "Windows_NT" setlocal + +set port=8080 + +rem Guess CATALINA_HOME if not defined +set "CURRENT_DIR=%cd%" +if not "%CATALINA_HOME%" == "" goto gotHome +set "CATALINA_HOME=%CURRENT_DIR%" +if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome +cd .. +set "CATALINA_HOME=%cd%" +cd "%CURRENT_DIR%" +:gotHome + +if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome +echo The CATALINA_HOME environment variable is not defined correctly +echo This environment variable is needed to run this program +goto end +:okHome + +rem Copy CATALINA_BASE from CATALINA_HOME if not defined +if not "%CATALINA_BASE%" == "" goto gotBase +set "CATALINA_BASE=%CATALINA_HOME%" +:gotBase + +rem Ensure that any user defined CLASSPATH variables are not used on startup, +rem but allow them to be specified in setenv.bat, in rare case when it is needed. +set CLASSPATH= + +rem Get standard Java environment variables +if exist "%CATALINA_HOME%\bin\setclasspath.bat" goto okSetclasspath +echo Cannot find "%CATALINA_HOME%\bin\setclasspath.bat" +echo This file is needed to run this program +goto end +:okSetclasspath +call "%CATALINA_HOME%\bin\setclasspath.bat" %1 +if errorlevel 1 goto end + + +if not "%CATALINA_TMPDIR%" == "" goto gotTmpdir +set "CATALINA_TMPDIR=%CATALINA_BASE%\temp" +:gotTmpdir + + +rem create classpath +setlocal enabledelayedexpansion + +set cp="%CATALINA_HOME%\bin\tomcat-juli.jar" +set lib="%CATALINA_HOME%\lib\" +echo %lib% +for %%F in (%lib%/*.jar) do ( + set cp=!cp!;%%F% +) + +if ""%1"" == ""deploy"" goto doDeploy +if ""%1"" == ""undeploy"" goto doUndeploy +goto doExec + +:doDeploy +:doUndeploy +%_RUNJAVA% -cp "%cp%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" org.apache.openejb.cli.Bootstrap %1 -s http://localhost:%port%/tomee/ejb %2 +goto end + +:doExec +%_RUNJAVA% -cp "%cp%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" org.apache.openejb.cli.Bootstrap %* +goto end + +:end + http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/Contexts.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/Contexts.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/Contexts.java index 78434d0..dd8a6b1 100644 --- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/Contexts.java +++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/Contexts.java @@ -1,148 +1,148 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tomee.catalina; - -import org.apache.catalina.Container; -import org.apache.catalina.Context; -import org.apache.catalina.Globals; -import org.apache.catalina.Host; -import org.apache.catalina.core.StandardContext; -import org.apache.catalina.core.StandardEngine; -import org.apache.catalina.core.StandardHost; -import org.apache.catalina.util.ContextName; - -import java.io.File; - -public class Contexts { - public static String getHostname(final StandardContext ctx) { - String hostName = null; - final Container parentHost = ctx.getParent(); - if (parentHost != null) { - hostName = parentHost.getName(); - } - if ((hostName == null) || (hostName.length() < 1)) { - hostName = "_"; - } - return hostName; - } - - public static File warPath(final Context standardContext) { - final File file = realWarPath(standardContext); - if (file == null) { - return null; - } - - final String name = file.getName(); - if (!file.isDirectory() && name.endsWith(".war")) { - final File extracted = new File(file.getParentFile(), name.substring(0, name.length() - ".war".length())); - if (extracted.exists()) { - return extracted; - } - } - return file; - } - - public static File realWarPath(final Context standardContext) { - if (standardContext == null) { - return null; - } - - final File docBase; - Container container = standardContext; - while (container != null) { - if (container instanceof Host) { - break; - } - container = container.getParent(); - } - - if (standardContext.getDocBase() != null) { - File file = new File(standardContext.getDocBase()); - if (!file.isAbsolute()) { - if (container == null) { - docBase = new File(engineBase(standardContext), standardContext.getDocBase()); - } else { - final String appBase = ((Host) container).getAppBase(); - file = new File(appBase); - if (!file.isAbsolute()) { - file = new File(engineBase(standardContext), appBase); - } - docBase = new File(file, standardContext.getDocBase()); - } - } else { - docBase = file; - } - } else { - final String path = standardContext.getPath(); - if (path == null) { - throw new IllegalStateException("Can't find docBase"); - } else { - docBase = new File(new ContextName(path, standardContext.getWebappVersion()).getBaseName()); - } - } - - if (!docBase.exists()) { // for old compatibility, will be removed soon - return oldRealWarPath(standardContext); - } - - final String name = docBase.getName(); - if (name.endsWith(".war")) { - final File extracted = new File(docBase.getParentFile(), name.substring(0, name.length() - ".war".length())); - if (extracted.exists()) { - return extracted; - } - } - - return docBase; - } - - private static File engineBase(final Context standardContext) { - String base=System.getProperty(Globals.CATALINA_BASE_PROP); - if( base == null ) { - final StandardEngine eng = (StandardEngine) standardContext.getParent().getParent(); - base = eng.getBaseDir(); - } - return new File(base); - } - - @Deprecated - private static File oldRealWarPath(final Context standardContext) { - String doc = standardContext.getDocBase(); - // handle ROOT case - if (doc == null || doc.length() == 0) { - doc = "ROOT"; - } - - File war = new File(doc); - if (war.exists()) { - return war; - } - - final StandardHost host = (StandardHost) standardContext.getParent(); - final String base = host.getAppBase(); - war = new File(base, doc); - if (war.exists()) { - return war; - } - - war = new File(new File(System.getProperty("catalina.home"), base), doc); - if (war.exists()) { - return war; - } - return new File(new File(System.getProperty("catalina.base"), base), doc); // shouldn't occur - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomee.catalina; + +import org.apache.catalina.Container; +import org.apache.catalina.Context; +import org.apache.catalina.Globals; +import org.apache.catalina.Host; +import org.apache.catalina.core.StandardContext; +import org.apache.catalina.core.StandardEngine; +import org.apache.catalina.core.StandardHost; +import org.apache.catalina.util.ContextName; + +import java.io.File; + +public class Contexts { + public static String getHostname(final StandardContext ctx) { + String hostName = null; + final Container parentHost = ctx.getParent(); + if (parentHost != null) { + hostName = parentHost.getName(); + } + if ((hostName == null) || (hostName.length() < 1)) { + hostName = "_"; + } + return hostName; + } + + public static File warPath(final Context standardContext) { + final File file = realWarPath(standardContext); + if (file == null) { + return null; + } + + final String name = file.getName(); + if (!file.isDirectory() && name.endsWith(".war")) { + final File extracted = new File(file.getParentFile(), name.substring(0, name.length() - ".war".length())); + if (extracted.exists()) { + return extracted; + } + } + return file; + } + + public static File realWarPath(final Context standardContext) { + if (standardContext == null) { + return null; + } + + final File docBase; + Container container = standardContext; + while (container != null) { + if (container instanceof Host) { + break; + } + container = container.getParent(); + } + + if (standardContext.getDocBase() != null) { + File file = new File(standardContext.getDocBase()); + if (!file.isAbsolute()) { + if (container == null) { + docBase = new File(engineBase(standardContext), standardContext.getDocBase()); + } else { + final String appBase = ((Host) container).getAppBase(); + file = new File(appBase); + if (!file.isAbsolute()) { + file = new File(engineBase(standardContext), appBase); + } + docBase = new File(file, standardContext.getDocBase()); + } + } else { + docBase = file; + } + } else { + final String path = standardContext.getPath(); + if (path == null) { + throw new IllegalStateException("Can't find docBase"); + } else { + docBase = new File(new ContextName(path, standardContext.getWebappVersion()).getBaseName()); + } + } + + if (!docBase.exists()) { // for old compatibility, will be removed soon + return oldRealWarPath(standardContext); + } + + final String name = docBase.getName(); + if (name.endsWith(".war")) { + final File extracted = new File(docBase.getParentFile(), name.substring(0, name.length() - ".war".length())); + if (extracted.exists()) { + return extracted; + } + } + + return docBase; + } + + private static File engineBase(final Context standardContext) { + String base=System.getProperty(Globals.CATALINA_BASE_PROP); + if( base == null ) { + final StandardEngine eng = (StandardEngine) standardContext.getParent().getParent(); + base = eng.getBaseDir(); + } + return new File(base); + } + + @Deprecated + private static File oldRealWarPath(final Context standardContext) { + String doc = standardContext.getDocBase(); + // handle ROOT case + if (doc == null || doc.length() == 0) { + doc = "ROOT"; + } + + File war = new File(doc); + if (war.exists()) { + return war; + } + + final StandardHost host = (StandardHost) standardContext.getParent(); + final String base = host.getAppBase(); + war = new File(base, doc); + if (war.exists()) { + return war; + } + + war = new File(new File(System.getProperty("catalina.home"), base), doc); + if (war.exists()) { + return war; + } + return new File(new File(System.getProperty("catalina.base"), base), doc); // shouldn't occur + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ProvisioningWebappLoader.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ProvisioningWebappLoader.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ProvisioningWebappLoader.java index 1357bcc..ab6fc11 100644 --- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ProvisioningWebappLoader.java +++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/ProvisioningWebappLoader.java @@ -1,119 +1,119 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tomee.catalina; - -import org.apache.catalina.Context; -import org.apache.catalina.LifecycleException; -import org.apache.catalina.loader.VirtualWebappLoader; -import org.apache.openejb.ClassLoaderUtil; -import org.apache.openejb.classloader.ClassLoaderConfigurer; -import org.apache.openejb.classloader.CompositeClassLoaderConfigurer; -import org.apache.openejb.config.QuickJarsTxtParser; -import org.apache.openejb.loader.ProvisioningUtil; -import org.apache.openejb.loader.SystemInstance; -import org.apache.openejb.util.reflection.Reflections; - -import java.io.File; - -/** - * Usage example in META-INF/context.xml - * <p/> - * <p/> - * <Context antiJARLocking="true" > - * <Loader - * className="org.apache.tomee.catalina.ProvisioningWebappLoader" - * searchExternalFirst="true" - * virtualClasspath="mvn:commons-el:commons-el:1.0;mvn:commons-el:commons-el:1.0" - * searchVirtualFirst="true" - * /> - * </Context> - */ -public class ProvisioningWebappLoader extends VirtualWebappLoader { - public static final boolean SKIP_BACKGROUND_PROCESS = "true".equals(SystemInstance.get().getProperty("tomee.classloader.skip-background-process", "false")); - - @Override - public void backgroundProcess() { - if (SKIP_BACKGROUND_PROCESS) { - return; - } - - final ClassLoader classloader = super.getClassLoader(); - if (classloader instanceof LazyStopWebappClassLoader) { - final LazyStopWebappClassLoader lazyStopWebappClassLoader = (LazyStopWebappClassLoader) classloader; - lazyStopWebappClassLoader.restarting(); - try { - super.backgroundProcess(); - } finally { - lazyStopWebappClassLoader.restarted(); - } - } else { - super.backgroundProcess(); - } - } - - @Override - public boolean modified() { - if (SKIP_BACKGROUND_PROCESS) { - return false; - } - return super.modified(); - } - - @Override - protected void startInternal() throws LifecycleException { - // standard tomcat part - final StringBuilder builder = new StringBuilder(); - final String classpath = String.class.cast(Reflections.get(this, "virtualClasspath")); - if (classpath != null && !classpath.isEmpty()) { - for (final String s : String.class.cast(classpath).split(";")) { - builder.append(ProvisioningUtil.realLocation(s)).append(";"); - } - } - - ClassLoaderConfigurer configurer = ClassLoaderUtil.configurer(getContainer().getName()); - - // WEB-INF/jars.xml - if (Context.class.isInstance(getContainer())) { - final File war = Contexts.warPath(Context.class.cast(getContainer())); - final File jarsXml = new File(war, "WEB-INF/" + QuickJarsTxtParser.FILE_NAME); - final ClassLoaderConfigurer configurerTxt = QuickJarsTxtParser.parse(jarsXml); - if (configurerTxt != null) { - configurer = new CompositeClassLoaderConfigurer(configurer, configurerTxt); - } - } - - // clean up builder and set classpath to delegate to parent init - String cp = builder.toString(); - if (cp.endsWith(";")) { - cp = cp.substring(0, cp.length() - 1); - } - Reflections.set(this, "virtualClasspath", cp); - - LazyStopWebappClassLoader.initContext(configurer); - LazyStopWebappClassLoader.initContext(Context.class.cast(getContainer())); - try { - super.startInternal(); - } finally { - LazyStopWebappClassLoader.cleanContext(); - } - } - - @Override - public String toString() { - return "Provisioning" + super.toString(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomee.catalina; + +import org.apache.catalina.Context; +import org.apache.catalina.LifecycleException; +import org.apache.catalina.loader.VirtualWebappLoader; +import org.apache.openejb.ClassLoaderUtil; +import org.apache.openejb.classloader.ClassLoaderConfigurer; +import org.apache.openejb.classloader.CompositeClassLoaderConfigurer; +import org.apache.openejb.config.QuickJarsTxtParser; +import org.apache.openejb.loader.ProvisioningUtil; +import org.apache.openejb.loader.SystemInstance; +import org.apache.openejb.util.reflection.Reflections; + +import java.io.File; + +/** + * Usage example in META-INF/context.xml + * <p/> + * <p/> + * <Context antiJARLocking="true" > + * <Loader + * className="org.apache.tomee.catalina.ProvisioningWebappLoader" + * searchExternalFirst="true" + * virtualClasspath="mvn:commons-el:commons-el:1.0;mvn:commons-el:commons-el:1.0" + * searchVirtualFirst="true" + * /> + * </Context> + */ +public class ProvisioningWebappLoader extends VirtualWebappLoader { + public static final boolean SKIP_BACKGROUND_PROCESS = "true".equals(SystemInstance.get().getProperty("tomee.classloader.skip-background-process", "false")); + + @Override + public void backgroundProcess() { + if (SKIP_BACKGROUND_PROCESS) { + return; + } + + final ClassLoader classloader = super.getClassLoader(); + if (classloader instanceof LazyStopWebappClassLoader) { + final LazyStopWebappClassLoader lazyStopWebappClassLoader = (LazyStopWebappClassLoader) classloader; + lazyStopWebappClassLoader.restarting(); + try { + super.backgroundProcess(); + } finally { + lazyStopWebappClassLoader.restarted(); + } + } else { + super.backgroundProcess(); + } + } + + @Override + public boolean modified() { + if (SKIP_BACKGROUND_PROCESS) { + return false; + } + return super.modified(); + } + + @Override + protected void startInternal() throws LifecycleException { + // standard tomcat part + final StringBuilder builder = new StringBuilder(); + final String classpath = String.class.cast(Reflections.get(this, "virtualClasspath")); + if (classpath != null && !classpath.isEmpty()) { + for (final String s : String.class.cast(classpath).split(";")) { + builder.append(ProvisioningUtil.realLocation(s)).append(";"); + } + } + + ClassLoaderConfigurer configurer = ClassLoaderUtil.configurer(getContainer().getName()); + + // WEB-INF/jars.xml + if (Context.class.isInstance(getContainer())) { + final File war = Contexts.warPath(Context.class.cast(getContainer())); + final File jarsXml = new File(war, "WEB-INF/" + QuickJarsTxtParser.FILE_NAME); + final ClassLoaderConfigurer configurerTxt = QuickJarsTxtParser.parse(jarsXml); + if (configurerTxt != null) { + configurer = new CompositeClassLoaderConfigurer(configurer, configurerTxt); + } + } + + // clean up builder and set classpath to delegate to parent init + String cp = builder.toString(); + if (cp.endsWith(";")) { + cp = cp.substring(0, cp.length() - 1); + } + Reflections.set(this, "virtualClasspath", cp); + + LazyStopWebappClassLoader.initContext(configurer); + LazyStopWebappClassLoader.initContext(Context.class.cast(getContainer())); + try { + super.startInternal(); + } finally { + LazyStopWebappClassLoader.cleanContext(); + } + } + + @Override + public String toString() { + return "Provisioning" + super.toString(); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/bd7dbd0f/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatDeploymentLoader.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatDeploymentLoader.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatDeploymentLoader.java index 03fea68..4496e54 100644 --- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatDeploymentLoader.java +++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatDeploymentLoader.java @@ -1,43 +1,43 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tomee.catalina; - -import org.apache.catalina.core.StandardContext; -import org.apache.openejb.config.DeploymentLoader; - -/** - * @version $Id$ - */ -public class TomcatDeploymentLoader extends DeploymentLoader { - private StandardContext standardContext; - private String moduleId; - - public TomcatDeploymentLoader(final StandardContext standardContext, final String moduleId) { - this.standardContext = standardContext; - this.moduleId = moduleId; - } - - @Override - protected String getContextRoot() { - return standardContext.getPath(); - } - - @Override - protected String getModuleName() { - return moduleId; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tomee.catalina; + +import org.apache.catalina.core.StandardContext; +import org.apache.openejb.config.DeploymentLoader; + +/** + * @version $Id$ + */ +public class TomcatDeploymentLoader extends DeploymentLoader { + private StandardContext standardContext; + private String moduleId; + + public TomcatDeploymentLoader(final StandardContext standardContext, final String moduleId) { + this.standardContext = standardContext; + this.moduleId = moduleId; + } + + @Override + protected String getContextRoot() { + return standardContext.getPath(); + } + + @Override + protected String getModuleName() { + return moduleId; + } +}
