http://git-wip-us.apache.org/repos/asf/tomee/blob/3069db0b/tomee/build.xml ---------------------------------------------------------------------- diff --git a/tomee/build.xml b/tomee/build.xml index eff1327..c660e7c 100644 --- a/tomee/build.xml +++ b/tomee/build.xml @@ -1,46 +1,46 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - 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. ---> -<project name="dev-helper" default="web"> - - <target name="web"> - <copy verbose="true" todir="apache-tomee/target/apache-tomee-webprofile-7.0.0-SNAPSHOT/webapps/tomee"> - <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.js"/> - <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.css"/> - <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.html"/> - </copy> - </target> - - <target name="rs"> - <copy verbose="true" todir="apache-tomee/target/apache-tomee-jaxrs-7.0.0-SNAPSHOT/webapps/tomee"> - <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.js"/> - <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.css"/> - <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.html"/> - </copy> - </target> - - <target name="plus"> - <copy verbose="true" todir="apache-tomee/target/apache-tomee-plus-7.0.0-SNAPSHOT/webapps/tomee"> - <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.js"/> - <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.css"/> - <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.html"/> - </copy> - </target> - -</project> - +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. +--> +<project name="dev-helper" default="web"> + + <target name="web"> + <copy verbose="true" todir="apache-tomee/target/apache-tomee-webprofile-7.0.0-SNAPSHOT/webapps/tomee"> + <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.js"/> + <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.css"/> + <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.html"/> + </copy> + </target> + + <target name="rs"> + <copy verbose="true" todir="apache-tomee/target/apache-tomee-jaxrs-7.0.0-SNAPSHOT/webapps/tomee"> + <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.js"/> + <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.css"/> + <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.html"/> + </copy> + </target> + + <target name="plus"> + <copy verbose="true" todir="apache-tomee/target/apache-tomee-plus-7.0.0-SNAPSHOT/webapps/tomee"> + <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.js"/> + <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.css"/> + <fileset dir="tomee-webapp/src/main/webapp" includes="**/*.html"/> + </copy> + </target> + +</project> +
http://git-wip-us.apache.org/repos/asf/tomee/blob/3069db0b/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 2ca6ac6..2208d91 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,165 +1,165 @@ -/* - * 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; -import java.io.IOException; - -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()) { - try { - return extracted.getCanonicalFile(); - } catch (final IOException e) { - return extracted; - } - } - } - try { - return file.getCanonicalFile(); - } catch (final IOException e) { - 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(); - } - - String baseName = null; - 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 { - baseName = new ContextName(path, standardContext.getWebappVersion()).getBaseName(); - docBase = new File(baseName); - } - } - - if (!docBase.exists() && baseName != null) { // for old compatibility, will be removed soon - if (Host.class.isInstance(container)) { - final File file = new File(Host.class.cast(container).getAppBaseFile(), baseName); - if (file.exists()) { - return file; - } - } - 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) { - final String base = System.getProperty(Globals.CATALINA_BASE_PROP); - if( base == null ) { - final StandardEngine eng = (StandardEngine) standardContext.getParent().getParent(); - return eng.getCatalinaBase(); - } - 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; +import java.io.IOException; + +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()) { + try { + return extracted.getCanonicalFile(); + } catch (final IOException e) { + return extracted; + } + } + } + try { + return file.getCanonicalFile(); + } catch (final IOException e) { + 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(); + } + + String baseName = null; + 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 { + baseName = new ContextName(path, standardContext.getWebappVersion()).getBaseName(); + docBase = new File(baseName); + } + } + + if (!docBase.exists() && baseName != null) { // for old compatibility, will be removed soon + if (Host.class.isInstance(container)) { + final File file = new File(Host.class.cast(container).getAppBaseFile(), baseName); + if (file.exists()) { + return file; + } + } + 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) { + final String base = System.getProperty(Globals.CATALINA_BASE_PROP); + if( base == null ) { + final StandardEngine eng = (StandardEngine) standardContext.getParent().getParent(); + return eng.getCatalinaBase(); + } + 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/3069db0b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java index eee2d2a..2308db0 100644 --- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java +++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomEEWebappLoader.java @@ -1,121 +1,121 @@ -/* - * 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.WebappLoader; -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.SystemInstance; - -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 TomEEWebappLoader extends WebappLoader { - public static final boolean SKIP_BACKGROUND_PROCESS = "true".equals(SystemInstance.get().getProperty("tomee.classloader.skip-background-process", "false")); - - private volatile ClassLoader loader; - - @Override - public void backgroundProcess() { - if (SKIP_BACKGROUND_PROCESS) { - return; - } - - final ClassLoader classloader = super.getClassLoader(); - if (classloader instanceof TomEEWebappClassLoader) { - final TomEEWebappClassLoader tomEEWebappClassLoader = (TomEEWebappClassLoader) classloader; - tomEEWebappClassLoader.restarting(); - try { - super.backgroundProcess(); - } finally { - tomEEWebappClassLoader.restarted(); - } - } else { - super.backgroundProcess(); - } - } - - @Override - public boolean modified() { - return !SKIP_BACKGROUND_PROCESS && super.modified(); - } - - @Override - protected void stopInternal() throws LifecycleException { - loader = getClassLoader(); - super.stopInternal(); - } - - public void clearLoader() { - loader = null; - } - - public ClassLoader internalLoader() { - return loader; - } - - @Override - protected void startInternal() throws LifecycleException { - if (getClassLoader() != null) { - final TomEEWebappClassLoader webappClassLoader = TomEEWebappClassLoader.class.cast(getClassLoader()); - if (webappClassLoader.isStopped()) { - webappClassLoader.internalStop(); - } - } - - final Context context = getContext(); - - ClassLoaderConfigurer configurer = ClassLoaderUtil.configurer(context.getName()); - - // WEB-INF/jars.xml - final File war = Contexts.warPath(Context.class.cast(context)); - 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); - } - - TomEEWebappClassLoader.initContext(configurer); - TomEEWebappClassLoader.initContext(context); - try { - super.startInternal(); - } finally { - TomEEWebappClassLoader.cleanContext(); - } - } - - @Override - public String toString() { - return "TomEE" + 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.WebappLoader; +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.SystemInstance; + +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 TomEEWebappLoader extends WebappLoader { + public static final boolean SKIP_BACKGROUND_PROCESS = "true".equals(SystemInstance.get().getProperty("tomee.classloader.skip-background-process", "false")); + + private volatile ClassLoader loader; + + @Override + public void backgroundProcess() { + if (SKIP_BACKGROUND_PROCESS) { + return; + } + + final ClassLoader classloader = super.getClassLoader(); + if (classloader instanceof TomEEWebappClassLoader) { + final TomEEWebappClassLoader tomEEWebappClassLoader = (TomEEWebappClassLoader) classloader; + tomEEWebappClassLoader.restarting(); + try { + super.backgroundProcess(); + } finally { + tomEEWebappClassLoader.restarted(); + } + } else { + super.backgroundProcess(); + } + } + + @Override + public boolean modified() { + return !SKIP_BACKGROUND_PROCESS && super.modified(); + } + + @Override + protected void stopInternal() throws LifecycleException { + loader = getClassLoader(); + super.stopInternal(); + } + + public void clearLoader() { + loader = null; + } + + public ClassLoader internalLoader() { + return loader; + } + + @Override + protected void startInternal() throws LifecycleException { + if (getClassLoader() != null) { + final TomEEWebappClassLoader webappClassLoader = TomEEWebappClassLoader.class.cast(getClassLoader()); + if (webappClassLoader.isStopped()) { + webappClassLoader.internalStop(); + } + } + + final Context context = getContext(); + + ClassLoaderConfigurer configurer = ClassLoaderUtil.configurer(context.getName()); + + // WEB-INF/jars.xml + final File war = Contexts.warPath(Context.class.cast(context)); + 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); + } + + TomEEWebappClassLoader.initContext(configurer); + TomEEWebappClassLoader.initContext(context); + try { + super.startInternal(); + } finally { + TomEEWebappClassLoader.cleanContext(); + } + } + + @Override + public String toString() { + return "TomEE" + super.toString(); + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/3069db0b/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; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/3069db0b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java index 1720f9f..a2c8d06 100644 --- a/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java +++ b/tomee/tomee-embedded/src/main/java/org/apache/tomee/embedded/Main.java @@ -1,134 +1,134 @@ -/** - * 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.embedded; - -import java.io.File; -import java.util.Set; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; -import org.apache.commons.cli.PosixParser; -import org.apache.openejb.loader.ProvisioningUtil; - -import static org.apache.openejb.loader.JarLocation.jarLocation; - -public class Main { - public static final String PORT = "port"; - public static final String SHUTDOWN = "shutdown"; - public static final String PATH = "path"; - public static final String CONTEXT = "context"; - public static final String DIRECTORY = "directory"; - public static final String DOC_BASE = "doc-base"; - public static final String AS_WAR = "as-war"; - - public static void main(final String[] args) { - final CommandLineParser parser = new PosixParser(); - final Options options = createOptions(); - - // parse command line - final CommandLine line; - try { - line = parser.parse(options, args, true); - } catch (final ParseException exp) { - new HelpFormatter().printHelp("java -jar tomee-embedded-user.jar", options); - return; - } - - // run TomEE - try { - final Container container = new Container(createConfiguration(line)); - final String[] contexts; - if (line.hasOption(CONTEXT)) { - contexts = line.getOptionValues(CONTEXT); - } else { - contexts = null; - } - - boolean autoWar = true; - int i = 0; - if (line.hasOption(PATH)) { - for (final String path : line.getOptionValues(PATH)) { - final Set<String> locations = ProvisioningUtil.realLocation(path); - for (final String location : locations) { - final File file = new File(location); - if (!file.exists()) { - System.err.println(file.getAbsolutePath() + " does not exist, skipping"); - continue; - } - - String name = file.getName().replaceAll("\\.[A-Za-z]+$", ""); - if (contexts != null) { - name = contexts[i++]; - } - container.deploy(name, file, true); - } - } - autoWar = false; - } - if (line.hasOption(AS_WAR)) { - container.deployClasspathAsWebApp(contexts == null || i == contexts.length ? "" : contexts[i], - line.hasOption(DOC_BASE) ? new File(line.getOptionValue(DOC_BASE)) : null); - autoWar = false; - } - if (autoWar) { // nothing deployed check if we are a war and deploy ourself then - final File me = jarLocation(Main.class); - if (me.getName().endsWith(".war")) { - container.deploy(contexts == null || i == contexts.length ? "" : contexts[i], me); - } - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - try { - container.stop(); - } catch (final Exception e) { - e.printStackTrace(); // just log the exception - } - } - }); - container.await(); - } catch (final Exception e) { - e.printStackTrace(); - } - } - - private static Options createOptions() { - final Options options = new Options(); - options.addOption(null, PATH, true, ""); - options.addOption(null, CONTEXT, true, "Context name for applications (same order than paths)"); - options.addOption("p", PORT, true, "TomEE http port"); - options.addOption("s", SHUTDOWN, true, "TomEE shutdown port"); - options.addOption("d", DIRECTORY, true, "TomEE directory"); - options.addOption("c", AS_WAR, false, "deploy classpath as war"); - options.addOption("b", DOC_BASE, true, "when deploy classpath as war, the doc base"); - return options; - } - - private static Configuration createConfiguration(final CommandLine args) { - final Configuration config = new Configuration(); - config.setDir(System.getProperty("java.io.tmpdir")); - config.setHttpPort(Integer.parseInt(args.getOptionValue(PORT, "8080"))); - config.setStopPort(Integer.parseInt(args.getOptionValue(SHUTDOWN, "8005"))); - config.setDir(args.getOptionValue(DIRECTORY, new File(new File("."), "apache-tomee").getAbsolutePath())); - return config; - } - -} +/** + * 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.embedded; + +import java.io.File; +import java.util.Set; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.ParseException; +import org.apache.commons.cli.PosixParser; +import org.apache.openejb.loader.ProvisioningUtil; + +import static org.apache.openejb.loader.JarLocation.jarLocation; + +public class Main { + public static final String PORT = "port"; + public static final String SHUTDOWN = "shutdown"; + public static final String PATH = "path"; + public static final String CONTEXT = "context"; + public static final String DIRECTORY = "directory"; + public static final String DOC_BASE = "doc-base"; + public static final String AS_WAR = "as-war"; + + public static void main(final String[] args) { + final CommandLineParser parser = new PosixParser(); + final Options options = createOptions(); + + // parse command line + final CommandLine line; + try { + line = parser.parse(options, args, true); + } catch (final ParseException exp) { + new HelpFormatter().printHelp("java -jar tomee-embedded-user.jar", options); + return; + } + + // run TomEE + try { + final Container container = new Container(createConfiguration(line)); + final String[] contexts; + if (line.hasOption(CONTEXT)) { + contexts = line.getOptionValues(CONTEXT); + } else { + contexts = null; + } + + boolean autoWar = true; + int i = 0; + if (line.hasOption(PATH)) { + for (final String path : line.getOptionValues(PATH)) { + final Set<String> locations = ProvisioningUtil.realLocation(path); + for (final String location : locations) { + final File file = new File(location); + if (!file.exists()) { + System.err.println(file.getAbsolutePath() + " does not exist, skipping"); + continue; + } + + String name = file.getName().replaceAll("\\.[A-Za-z]+$", ""); + if (contexts != null) { + name = contexts[i++]; + } + container.deploy(name, file, true); + } + } + autoWar = false; + } + if (line.hasOption(AS_WAR)) { + container.deployClasspathAsWebApp(contexts == null || i == contexts.length ? "" : contexts[i], + line.hasOption(DOC_BASE) ? new File(line.getOptionValue(DOC_BASE)) : null); + autoWar = false; + } + if (autoWar) { // nothing deployed check if we are a war and deploy ourself then + final File me = jarLocation(Main.class); + if (me.getName().endsWith(".war")) { + container.deploy(contexts == null || i == contexts.length ? "" : contexts[i], me); + } + } + + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + try { + container.stop(); + } catch (final Exception e) { + e.printStackTrace(); // just log the exception + } + } + }); + container.await(); + } catch (final Exception e) { + e.printStackTrace(); + } + } + + private static Options createOptions() { + final Options options = new Options(); + options.addOption(null, PATH, true, ""); + options.addOption(null, CONTEXT, true, "Context name for applications (same order than paths)"); + options.addOption("p", PORT, true, "TomEE http port"); + options.addOption("s", SHUTDOWN, true, "TomEE shutdown port"); + options.addOption("d", DIRECTORY, true, "TomEE directory"); + options.addOption("c", AS_WAR, false, "deploy classpath as war"); + options.addOption("b", DOC_BASE, true, "when deploy classpath as war, the doc base"); + return options; + } + + private static Configuration createConfiguration(final CommandLine args) { + final Configuration config = new Configuration(); + config.setDir(System.getProperty("java.io.tmpdir")); + config.setHttpPort(Integer.parseInt(args.getOptionValue(PORT, "8080"))); + config.setStopPort(Integer.parseInt(args.getOptionValue(SHUTDOWN, "8005"))); + config.setDir(args.getOptionValue(DIRECTORY, new File(new File("."), "apache-tomee").getAbsolutePath())); + return config; + } + +} http://git-wip-us.apache.org/repos/asf/tomee/blob/3069db0b/tomee/tomee-embedded/src/main/resources/org/apache/tomee/configs/catalina.policy ---------------------------------------------------------------------- diff --git a/tomee/tomee-embedded/src/main/resources/org/apache/tomee/configs/catalina.policy b/tomee/tomee-embedded/src/main/resources/org/apache/tomee/configs/catalina.policy index 1d8fcef..f5a4247 100644 --- a/tomee/tomee-embedded/src/main/resources/org/apache/tomee/configs/catalina.policy +++ b/tomee/tomee-embedded/src/main/resources/org/apache/tomee/configs/catalina.policy @@ -1,241 +1,241 @@ -// 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. - -// ============================================================================ -// catalina.policy - Security Policy Permissions for Tomcat 7 -// -// This file contains a default set of security policies to be enforced (by the -// JVM) when Catalina is executed with the "-security" option. In addition -// to the permissions granted here, the following additional permissions are -// granted specific to each web application: -// -// * Read access to its document root directory -// * Read, write and delete access to its working directory -// -// $Id: catalina.policy 1079755 2011-03-09 11:38:38Z markt $ -// ============================================================================ - - -// ========== SYSTEM CODE PERMISSIONS ========================================= - - -// These permissions apply to javac -grant codeBase "file:${java.home}/lib/-" { - permission java.security.AllPermission; -}; - -// These permissions apply to all shared system extensions -grant codeBase "file:${java.home}/jre/lib/ext/-" { - permission java.security.AllPermission; -}; - -// These permissions apply to javac when ${java.home] points at $JAVA_HOME/jre -grant codeBase "file:${java.home}/../lib/-" { - permission java.security.AllPermission; -}; - -// These permissions apply to all shared system extensions when -// ${java.home} points at $JAVA_HOME/jre -grant codeBase "file:${java.home}/lib/ext/-" { - permission java.security.AllPermission; -}; - - -// ========== CATALINA CODE PERMISSIONS ======================================= - - -// These permissions apply to the daemon code -grant codeBase "file:${catalina.home}/bin/commons-daemon.jar" { - permission java.security.AllPermission; -}; - -// These permissions apply to the logging API -// Note: If tomcat-juli.jar is in ${catalina.base} and not in ${catalina.home}, -// update this section accordingly. -// grant codeBase "file:${catalina.base}/bin/tomcat-juli.jar" {..} -grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" { - permission java.io.FilePermission - "${java.home}${file.separator}lib${file.separator}logging.properties", "read"; - - permission java.io.FilePermission - "${catalina.base}${file.separator}conf${file.separator}logging.properties", "read"; - permission java.io.FilePermission - "${catalina.base}${file.separator}logs", "read, write"; - permission java.io.FilePermission - "${catalina.base}${file.separator}logs${file.separator}*", "read, write"; - - permission java.lang.RuntimePermission "shutdownHooks"; - permission java.lang.RuntimePermission "getClassLoader"; - permission java.lang.RuntimePermission "setContextClassLoader"; - - permission java.util.logging.LoggingPermission "control"; - - permission java.util.PropertyPermission "java.util.logging.config.class", "read"; - permission java.util.PropertyPermission "java.util.logging.config.file", "read"; - permission java.util.PropertyPermission "catalina.base", "read"; - - // Note: To enable per context logging configuration, permit read access to - // the appropriate file. Be sure that the logging configuration is - // secure before enabling such access. - // E.g. for the examples web application: - // permission java.io.FilePermission "${catalina.base}${file.separator} - // webapps${file.separator}examples${file.separator}WEB-INF - // ${file.separator}classes${file.separator}logging.properties", "read"; -}; - -// These permissions apply to the server startup code -grant codeBase "file:${catalina.home}/bin/bootstrap.jar" { - permission java.security.AllPermission; -}; - -// These permissions apply to the servlet API classes -// and those that are shared across all class loaders -// located in the "lib" directory -grant codeBase "file:${catalina.home}/lib/-" { - permission java.security.AllPermission; -}; - - -// If using a per instance lib directory, i.e. ${catalina.base}/lib, -// then the following permission will need to be uncommented -// grant codeBase "file:${catalina.base}/lib/-" { -// permission java.security.AllPermission; -// }; - - -// ========== WEB APPLICATION PERMISSIONS ===================================== - - -// These permissions are granted by default to all web applications -// In addition, a web application will be given a read FilePermission -// and JndiPermission for all files and directories in its document root. -grant { - // Required for JNDI lookup of named JDBC DataSource's and - // javamail named MimePart DataSource used to send mail - permission java.util.PropertyPermission "java.home", "read"; - permission java.util.PropertyPermission "java.naming.*", "read"; - permission java.util.PropertyPermission "javax.sql.*", "read"; - - // OS Specific properties to allow read access - permission java.util.PropertyPermission "os.name", "read"; - permission java.util.PropertyPermission "os.version", "read"; - permission java.util.PropertyPermission "os.arch", "read"; - permission java.util.PropertyPermission "file.separator", "read"; - permission java.util.PropertyPermission "path.separator", "read"; - permission java.util.PropertyPermission "line.separator", "read"; - - // JVM properties to allow read access - permission java.util.PropertyPermission "java.version", "read"; - permission java.util.PropertyPermission "java.vendor", "read"; - permission java.util.PropertyPermission "java.vendor.url", "read"; - permission java.util.PropertyPermission "java.class.version", "read"; - permission java.util.PropertyPermission "java.specification.version", "read"; - permission java.util.PropertyPermission "java.specification.vendor", "read"; - permission java.util.PropertyPermission "java.specification.name", "read"; - - permission java.util.PropertyPermission "java.vm.specification.version", "read"; - permission java.util.PropertyPermission "java.vm.specification.vendor", "read"; - permission java.util.PropertyPermission "java.vm.specification.name", "read"; - permission java.util.PropertyPermission "java.vm.version", "read"; - permission java.util.PropertyPermission "java.vm.vendor", "read"; - permission java.util.PropertyPermission "java.vm.name", "read"; - - // Required for OpenJMX - permission java.lang.RuntimePermission "getAttribute"; - - // Allow read of JAXP compliant XML parser debug - permission java.util.PropertyPermission "jaxp.debug", "read"; - - // All JSPs need to be able to read this package - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat"; - - // Precompiled JSPs need access to these packages. - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.el"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.runtime"; - permission java.lang.RuntimePermission - "accessClassInPackage.org.apache.jasper.runtime.*"; - - // Precompiled JSPs need access to these system properties. - permission java.util.PropertyPermission - "org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "read"; - permission java.util.PropertyPermission - "org.apache.el.parser.COERCE_TO_ZERO", "read"; - - // The cookie code needs these. - permission java.util.PropertyPermission - "org.apache.catalina.STRICT_SERVLET_COMPLIANCE", "read"; - permission java.util.PropertyPermission - "org.apache.tomcat.util.http.ServerCookie.STRICT_NAMING", "read"; - permission java.util.PropertyPermission - "org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR", "read"; - - // Applications using Comet need to be able to access this package - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.comet"; -}; - - -// The Manager application needs access to the following packages to support the -// session display functionality. These settings support the following -// configurations: -// - default CATALINA_HOME == CATALINA_BASE -// - CATALINA_HOME != CATALINA_BASE, per instance Manager in CATALINA_BASE -// - CATALINA_HOME != CATALINA_BASE, shared Manager in CATALINA_HOME -grant codeBase "file:${catalina.base}/webapps/manager/-" { - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; -}; -grant codeBase "file:${catalina.home}/webapps/manager/-" { - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; - permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; -}; - -// You can assign additional permissions to particular web applications by -// adding additional "grant" entries here, based on the code base for that -// application, /WEB-INF/classes/, or /WEB-INF/lib/ jar files. -// -// Different permissions can be granted to JSP pages, classes loaded from -// the /WEB-INF/classes/ directory, all jar files in the /WEB-INF/lib/ -// directory, or even to individual jar files in the /WEB-INF/lib/ directory. -// -// For instance, assume that the standard "examples" application -// included a JDBC driver that needed to establish a network connection to the -// corresponding database and used the scrape taglib to get the weather from -// the NOAA web server. You might create a "grant" entries like this: -// -// The permissions granted to the context root directory apply to JSP pages. -// grant codeBase "file:${catalina.base}/webapps/examples/-" { -// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect"; -// permission java.net.SocketPermission "*.noaa.gov:80", "connect"; -// }; -// -// The permissions granted to the context WEB-INF/classes directory -// grant codeBase "file:${catalina.base}/webapps/examples/WEB-INF/classes/-" { -// }; -// -// The permission granted to your JDBC driver -// grant codeBase "jar:file:${catalina.base}/webapps/examples/WEB-INF/lib/driver.jar!/-" { -// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect"; -// }; -// The permission granted to the scrape taglib -// grant codeBase "jar:file:${catalina.base}/webapps/examples/WEB-INF/lib/scrape.jar!/-" { -// permission java.net.SocketPermission "*.noaa.gov:80", "connect"; -// }; - +// 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. + +// ============================================================================ +// catalina.policy - Security Policy Permissions for Tomcat 7 +// +// This file contains a default set of security policies to be enforced (by the +// JVM) when Catalina is executed with the "-security" option. In addition +// to the permissions granted here, the following additional permissions are +// granted specific to each web application: +// +// * Read access to its document root directory +// * Read, write and delete access to its working directory +// +// $Id: catalina.policy 1079755 2011-03-09 11:38:38Z markt $ +// ============================================================================ + + +// ========== SYSTEM CODE PERMISSIONS ========================================= + + +// These permissions apply to javac +grant codeBase "file:${java.home}/lib/-" { + permission java.security.AllPermission; +}; + +// These permissions apply to all shared system extensions +grant codeBase "file:${java.home}/jre/lib/ext/-" { + permission java.security.AllPermission; +}; + +// These permissions apply to javac when ${java.home] points at $JAVA_HOME/jre +grant codeBase "file:${java.home}/../lib/-" { + permission java.security.AllPermission; +}; + +// These permissions apply to all shared system extensions when +// ${java.home} points at $JAVA_HOME/jre +grant codeBase "file:${java.home}/lib/ext/-" { + permission java.security.AllPermission; +}; + + +// ========== CATALINA CODE PERMISSIONS ======================================= + + +// These permissions apply to the daemon code +grant codeBase "file:${catalina.home}/bin/commons-daemon.jar" { + permission java.security.AllPermission; +}; + +// These permissions apply to the logging API +// Note: If tomcat-juli.jar is in ${catalina.base} and not in ${catalina.home}, +// update this section accordingly. +// grant codeBase "file:${catalina.base}/bin/tomcat-juli.jar" {..} +grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" { + permission java.io.FilePermission + "${java.home}${file.separator}lib${file.separator}logging.properties", "read"; + + permission java.io.FilePermission + "${catalina.base}${file.separator}conf${file.separator}logging.properties", "read"; + permission java.io.FilePermission + "${catalina.base}${file.separator}logs", "read, write"; + permission java.io.FilePermission + "${catalina.base}${file.separator}logs${file.separator}*", "read, write"; + + permission java.lang.RuntimePermission "shutdownHooks"; + permission java.lang.RuntimePermission "getClassLoader"; + permission java.lang.RuntimePermission "setContextClassLoader"; + + permission java.util.logging.LoggingPermission "control"; + + permission java.util.PropertyPermission "java.util.logging.config.class", "read"; + permission java.util.PropertyPermission "java.util.logging.config.file", "read"; + permission java.util.PropertyPermission "catalina.base", "read"; + + // Note: To enable per context logging configuration, permit read access to + // the appropriate file. Be sure that the logging configuration is + // secure before enabling such access. + // E.g. for the examples web application: + // permission java.io.FilePermission "${catalina.base}${file.separator} + // webapps${file.separator}examples${file.separator}WEB-INF + // ${file.separator}classes${file.separator}logging.properties", "read"; +}; + +// These permissions apply to the server startup code +grant codeBase "file:${catalina.home}/bin/bootstrap.jar" { + permission java.security.AllPermission; +}; + +// These permissions apply to the servlet API classes +// and those that are shared across all class loaders +// located in the "lib" directory +grant codeBase "file:${catalina.home}/lib/-" { + permission java.security.AllPermission; +}; + + +// If using a per instance lib directory, i.e. ${catalina.base}/lib, +// then the following permission will need to be uncommented +// grant codeBase "file:${catalina.base}/lib/-" { +// permission java.security.AllPermission; +// }; + + +// ========== WEB APPLICATION PERMISSIONS ===================================== + + +// These permissions are granted by default to all web applications +// In addition, a web application will be given a read FilePermission +// and JndiPermission for all files and directories in its document root. +grant { + // Required for JNDI lookup of named JDBC DataSource's and + // javamail named MimePart DataSource used to send mail + permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.naming.*", "read"; + permission java.util.PropertyPermission "javax.sql.*", "read"; + + // OS Specific properties to allow read access + permission java.util.PropertyPermission "os.name", "read"; + permission java.util.PropertyPermission "os.version", "read"; + permission java.util.PropertyPermission "os.arch", "read"; + permission java.util.PropertyPermission "file.separator", "read"; + permission java.util.PropertyPermission "path.separator", "read"; + permission java.util.PropertyPermission "line.separator", "read"; + + // JVM properties to allow read access + permission java.util.PropertyPermission "java.version", "read"; + permission java.util.PropertyPermission "java.vendor", "read"; + permission java.util.PropertyPermission "java.vendor.url", "read"; + permission java.util.PropertyPermission "java.class.version", "read"; + permission java.util.PropertyPermission "java.specification.version", "read"; + permission java.util.PropertyPermission "java.specification.vendor", "read"; + permission java.util.PropertyPermission "java.specification.name", "read"; + + permission java.util.PropertyPermission "java.vm.specification.version", "read"; + permission java.util.PropertyPermission "java.vm.specification.vendor", "read"; + permission java.util.PropertyPermission "java.vm.specification.name", "read"; + permission java.util.PropertyPermission "java.vm.version", "read"; + permission java.util.PropertyPermission "java.vm.vendor", "read"; + permission java.util.PropertyPermission "java.vm.name", "read"; + + // Required for OpenJMX + permission java.lang.RuntimePermission "getAttribute"; + + // Allow read of JAXP compliant XML parser debug + permission java.util.PropertyPermission "jaxp.debug", "read"; + + // All JSPs need to be able to read this package + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat"; + + // Precompiled JSPs need access to these packages. + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.el"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.runtime"; + permission java.lang.RuntimePermission + "accessClassInPackage.org.apache.jasper.runtime.*"; + + // Precompiled JSPs need access to these system properties. + permission java.util.PropertyPermission + "org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "read"; + permission java.util.PropertyPermission + "org.apache.el.parser.COERCE_TO_ZERO", "read"; + + // The cookie code needs these. + permission java.util.PropertyPermission + "org.apache.catalina.STRICT_SERVLET_COMPLIANCE", "read"; + permission java.util.PropertyPermission + "org.apache.tomcat.util.http.ServerCookie.STRICT_NAMING", "read"; + permission java.util.PropertyPermission + "org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR", "read"; + + // Applications using Comet need to be able to access this package + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.comet"; +}; + + +// The Manager application needs access to the following packages to support the +// session display functionality. These settings support the following +// configurations: +// - default CATALINA_HOME == CATALINA_BASE +// - CATALINA_HOME != CATALINA_BASE, per instance Manager in CATALINA_BASE +// - CATALINA_HOME != CATALINA_BASE, shared Manager in CATALINA_HOME +grant codeBase "file:${catalina.base}/webapps/manager/-" { + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; +}; +grant codeBase "file:${catalina.home}/webapps/manager/-" { + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; +}; + +// You can assign additional permissions to particular web applications by +// adding additional "grant" entries here, based on the code base for that +// application, /WEB-INF/classes/, or /WEB-INF/lib/ jar files. +// +// Different permissions can be granted to JSP pages, classes loaded from +// the /WEB-INF/classes/ directory, all jar files in the /WEB-INF/lib/ +// directory, or even to individual jar files in the /WEB-INF/lib/ directory. +// +// For instance, assume that the standard "examples" application +// included a JDBC driver that needed to establish a network connection to the +// corresponding database and used the scrape taglib to get the weather from +// the NOAA web server. You might create a "grant" entries like this: +// +// The permissions granted to the context root directory apply to JSP pages. +// grant codeBase "file:${catalina.base}/webapps/examples/-" { +// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect"; +// permission java.net.SocketPermission "*.noaa.gov:80", "connect"; +// }; +// +// The permissions granted to the context WEB-INF/classes directory +// grant codeBase "file:${catalina.base}/webapps/examples/WEB-INF/classes/-" { +// }; +// +// The permission granted to your JDBC driver +// grant codeBase "jar:file:${catalina.base}/webapps/examples/WEB-INF/lib/driver.jar!/-" { +// permission java.net.SocketPermission "dbhost.mycompany.com:5432", "connect"; +// }; +// The permission granted to the scrape taglib +// grant codeBase "jar:file:${catalina.base}/webapps/examples/WEB-INF/lib/scrape.jar!/-" { +// permission java.net.SocketPermission "*.noaa.gov:80", "connect"; +// }; + http://git-wip-us.apache.org/repos/asf/tomee/blob/3069db0b/tomee/tomee-embedded/src/main/resources/org/apache/tomee/configs/catalina.properties ---------------------------------------------------------------------- diff --git a/tomee/tomee-embedded/src/main/resources/org/apache/tomee/configs/catalina.properties b/tomee/tomee-embedded/src/main/resources/org/apache/tomee/configs/catalina.properties index 5089043..ff86449 100644 --- a/tomee/tomee-embedded/src/main/resources/org/apache/tomee/configs/catalina.properties +++ b/tomee/tomee-embedded/src/main/resources/org/apache/tomee/configs/catalina.properties @@ -1,122 +1,122 @@ -# 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. - -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageAccess unless the -# corresponding RuntimePermission ("accessClassInPackage."+package) has -# been granted. -package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper. -# -# List of comma-separated packages that start with or equal this string -# will cause a security exception to be thrown when -# passed to checkPackageDefinition unless the -# corresponding RuntimePermission ("defineClassInPackage."+package) has -# been granted. -# -# by default, no packages are restricted for definition, and none of -# the class loaders supplied with the JDK call checkPackageDefinition. -# -package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper. - -# -# -# List of comma-separated paths defining the contents of the "common" -# classloader. Prefixes should be used to define what is the repository type. -# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. -# If left as blank,the JVM system loader will be used as Catalina's "common" -# loader. -# Examples: -# "foo": Add this folder as a class repository -# "foo/*.jar": Add all the JARs of the specified folder as class -# repositories -# "foo/bar.jar": Add bar.jar as a class repository -common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar - -# -# List of comma-separated paths defining the contents of the "server" -# classloader. Prefixes should be used to define what is the repository type. -# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. -# If left as blank, the "common" loader will be used as Catalina's "server" -# loader. -# Examples: -# "foo": Add this folder as a class repository -# "foo/*.jar": Add all the JARs of the specified folder as class -# repositories -# "foo/bar.jar": Add bar.jar as a class repository -server.loader= - -# -# List of comma-separated paths defining the contents of the "shared" -# classloader. Prefixes should be used to define what is the repository type. -# Path may be relative to the CATALINA_BASE path or absolute. If left as blank, -# the "common" loader will be used as Catalina's "shared" loader. -# Examples: -# "foo": Add this folder as a class repository -# "foo/*.jar": Add all the JARs of the specified folder as class -# repositories -# "foo/bar.jar": Add bar.jar as a class repository -# Please note that for single jars, e.g. bar.jar, you need the URL form -# starting with file:. -shared.loader= - -# List of JAR files that should not be scanned for configuration information -# such as web fragments, TLD files etc. It must be a comma separated list of -# JAR file names. -# The JARs listed below include: -# - Tomcat Bootstrap JARs -# - Tomcat API JARs -# - Catalina JARs -# - Jasper JARs -# - Tomcat JARs -# - Common non-Tomcat JARs -# - Sun JDK JARs -# - Apple JDK JARs -tomcat.util.scan.DefaultJarScanner.jarsToSkip=\ -bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\ -annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,\ -catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-tribes.jar,\ -jasper.jar,jasper-el.jar,ecj-*.jar,\ -tomcat-api.jar,tomcat-util.jar,tomcat-coyote.jar,tomcat-dbcp.jar,\ -tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\ -commons-beanutils*.jar,commons-collections*.jar,commons-dbcp*.jar,\ -commons-digester*.jar,commons-fileupload*.jar,commons-logging*.jar,\ -commons-pool*.jar,\ -bcprov-*.jar,\ -ant.jar,jmx.jar,jmx-tools.jar,\ -xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\ -dnsns.jar,ldapsec.jar,localedata.jar,sunjce_provider.jar,sunpkcs11.jar,tools.jar,\ -apple_provider.jar,AppleScriptEngine.jar,CoreAudio.jar,dns_sd.jar,\ -j3daudio.jar,j3dcore.jar,j3dutils.jar,jai_core.jar,jai_codec.jar,\ -mlibwrapper_jai.jar,MRJToolkit.jar,vecmath.jar,\ -hsqldb-*,openejb-core-*,xbean-*,derby*,mbean-annotation-*,\ -javassit*,commons-*,swizzle-stream-*,serp-*,geronimo-javamail-*,geronimo-mail-*,\ -openejb-jee-*,openejb-core-*,openejb-loader-*,openejb-api-*,openejb-derby*,\ -openwebbeans-ejb-*,openwebbeans-impl-*,\ -bval-*,\ -tomee-loader-*,openejb-javaagent-*,openejb-ejbd-*,scannotation-*,openejb-server-*,\ -openjpa-*,quartz-*,openejb-http-*,kahadb-* - -# -# String cache configuration. -tomcat.util.buf.StringCache.byte.enabled=true -#tomcat.util.buf.StringCache.char.enabled=true -#tomcat.util.buf.StringCache.trainThreshold=500000 -#tomcat.util.buf.StringCache.cacheSize=5000 - -http.port=${tomcatHttpPort} -shutdown.port=${tomcatShutdownPort} +# 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. + +# +# List of comma-separated packages that start with or equal this string +# will cause a security exception to be thrown when +# passed to checkPackageAccess unless the +# corresponding RuntimePermission ("accessClassInPackage."+package) has +# been granted. +package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper. +# +# List of comma-separated packages that start with or equal this string +# will cause a security exception to be thrown when +# passed to checkPackageDefinition unless the +# corresponding RuntimePermission ("defineClassInPackage."+package) has +# been granted. +# +# by default, no packages are restricted for definition, and none of +# the class loaders supplied with the JDK call checkPackageDefinition. +# +package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper. + +# +# +# List of comma-separated paths defining the contents of the "common" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. +# If left as blank,the JVM system loader will be used as Catalina's "common" +# loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar + +# +# List of comma-separated paths defining the contents of the "server" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. +# If left as blank, the "common" loader will be used as Catalina's "server" +# loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +server.loader= + +# +# List of comma-separated paths defining the contents of the "shared" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_BASE path or absolute. If left as blank, +# the "common" loader will be used as Catalina's "shared" loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +# Please note that for single jars, e.g. bar.jar, you need the URL form +# starting with file:. +shared.loader= + +# List of JAR files that should not be scanned for configuration information +# such as web fragments, TLD files etc. It must be a comma separated list of +# JAR file names. +# The JARs listed below include: +# - Tomcat Bootstrap JARs +# - Tomcat API JARs +# - Catalina JARs +# - Jasper JARs +# - Tomcat JARs +# - Common non-Tomcat JARs +# - Sun JDK JARs +# - Apple JDK JARs +tomcat.util.scan.DefaultJarScanner.jarsToSkip=\ +bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\ +annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,\ +catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-tribes.jar,\ +jasper.jar,jasper-el.jar,ecj-*.jar,\ +tomcat-api.jar,tomcat-util.jar,tomcat-coyote.jar,tomcat-dbcp.jar,\ +tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\ +commons-beanutils*.jar,commons-collections*.jar,commons-dbcp*.jar,\ +commons-digester*.jar,commons-fileupload*.jar,commons-logging*.jar,\ +commons-pool*.jar,\ +bcprov-*.jar,\ +ant.jar,jmx.jar,jmx-tools.jar,\ +xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\ +dnsns.jar,ldapsec.jar,localedata.jar,sunjce_provider.jar,sunpkcs11.jar,tools.jar,\ +apple_provider.jar,AppleScriptEngine.jar,CoreAudio.jar,dns_sd.jar,\ +j3daudio.jar,j3dcore.jar,j3dutils.jar,jai_core.jar,jai_codec.jar,\ +mlibwrapper_jai.jar,MRJToolkit.jar,vecmath.jar,\ +hsqldb-*,openejb-core-*,xbean-*,derby*,mbean-annotation-*,\ +javassit*,commons-*,swizzle-stream-*,serp-*,geronimo-javamail-*,geronimo-mail-*,\ +openejb-jee-*,openejb-core-*,openejb-loader-*,openejb-api-*,openejb-derby*,\ +openwebbeans-ejb-*,openwebbeans-impl-*,\ +bval-*,\ +tomee-loader-*,openejb-javaagent-*,openejb-ejbd-*,scannotation-*,openejb-server-*,\ +openjpa-*,quartz-*,openejb-http-*,kahadb-* + +# +# String cache configuration. +tomcat.util.buf.StringCache.byte.enabled=true +#tomcat.util.buf.StringCache.char.enabled=true +#tomcat.util.buf.StringCache.trainThreshold=500000 +#tomcat.util.buf.StringCache.cacheSize=5000 + +http.port=${tomcatHttpPort} +shutdown.port=${tomcatShutdownPort} shutdown.command=${tomcatShutdownCommand} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tomee/blob/3069db0b/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/ABean.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/ABean.java b/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/ABean.java index abbc097..8f828b9 100644 --- a/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/ABean.java +++ b/tomee/tomee-embedded/src/test/java/org/apache/tomee/embedded/ABean.java @@ -1,26 +1,26 @@ -/** - * 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.embedded; - -import javax.ejb.Singleton; - -@Singleton -public class ABean { - public String embedded() { - return "ok"; - } -} +/** + * 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.embedded; + +import javax.ejb.Singleton; + +@Singleton +public class ABean { + public String embedded() { + return "ok"; + } +} http://git-wip-us.apache.org/repos/asf/tomee/blob/3069db0b/tomee/tomee-embedded/src/test/resources/META-INF/beans.xml ---------------------------------------------------------------------- diff --git a/tomee/tomee-embedded/src/test/resources/META-INF/beans.xml b/tomee/tomee-embedded/src/test/resources/META-INF/beans.xml index e0d7a63..b1514dd 100644 --- a/tomee/tomee-embedded/src/test/resources/META-INF/beans.xml +++ b/tomee/tomee-embedded/src/test/resources/META-INF/beans.xml @@ -1,19 +1,19 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - 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. ---> -<beans /> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. +--> +<beans />
