From 02ed7ee2fb84164399018ee82dceb08e5e9ed24f Mon Sep 17 00:00:00 2001 From: Gurkan Erdogdu Date: Wed, 2 Jan 2019 12:46:03 +0200 Subject: [PATCH] (TOMEE-2438) Centralise TomEE and OpenEJB system properties --- tomee/pom.xml | 1 + tomee/tomee-catalina/pom.xml | 5 +++ .../tomee/catalina/TomcatWebAppBuilder.java | 9 ++-- tomee/tomee-config/pom.xml | 39 +++++++++++++++++ .../tomee/config/TomEESystemConfig.java | 42 +++++++++++++++++++ 5 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 tomee/tomee-config/pom.xml create mode 100644 tomee/tomee-config/src/main/java/org/apache/tomee/config/TomEESystemConfig.java diff --git a/tomee/pom.xml b/tomee/pom.xml index 5a4182ece54..fc51282b940 100644 --- a/tomee/pom.xml +++ b/tomee/pom.xml @@ -34,6 +34,7 @@ OpenEJB :: TomEE + tomee-config tomee-loader tomee-catalina tomee-common diff --git a/tomee/tomee-catalina/pom.xml b/tomee/tomee-catalina/pom.xml index 568198b5532..510e2713ea8 100644 --- a/tomee/tomee-catalina/pom.xml +++ b/tomee/tomee-catalina/pom.xml @@ -66,6 +66,11 @@ javaee-api tomcat + + ${project.groupId} + tomee-config + ${project.version} + ${project.groupId} tomee-common diff --git a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java index 4ab532d143b..0a79755ba49 100644 --- a/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java +++ b/tomee/tomee-catalina/src/main/java/org/apache/tomee/catalina/TomcatWebAppBuilder.java @@ -132,6 +132,7 @@ import org.apache.tomee.catalina.routing.RouterValve; import org.apache.tomee.common.NamingUtil; import org.apache.tomee.common.UserTransactionFactory; +import org.apache.tomee.config.TomEESystemConfig; import org.apache.tomee.loader.TomcatHelper; import org.apache.webbeans.config.WebBeansContext; import org.apache.webbeans.spi.ContextsService; @@ -198,8 +199,6 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare public static final String DEFAULT_J2EE_SERVER = "Apache TomEE"; public static final String OPENEJB_WEBAPP_MODULE_ID = "openejb.webapp.moduleId"; - public static final String TOMEE_EAT_EXCEPTION_PROP = "tomee.eat-exception"; - public static final String TOMEE_INIT_J2EE_INFO = "tomee.init-J2EE-info"; private static final boolean FORCE_RELOADABLE = SystemInstance.get().getOptions().get("tomee.force-reloadable", false); private static final boolean SKIP_TLD = SystemInstance.get().getOptions().get("tomee.skip-tld", false); @@ -275,7 +274,7 @@ public class TomcatWebAppBuilder implements WebAppBuilder, ContextListener, Pare public TomcatWebAppBuilder() { SystemInstance.get().setComponent(WebAppBuilder.class, this); SystemInstance.get().setComponent(TomcatWebAppBuilder.class, this); - initJEEInfo = "true".equalsIgnoreCase(SystemInstance.get().getProperty(TOMEE_INIT_J2EE_INFO, "true")); + initJEEInfo = "true".equalsIgnoreCase(SystemInstance.get().getProperty(TomEESystemConfig.TOMEE_INIT_J2EE_INFO, "true")); // TODO: re-write this bit, so this becomes part of the listener, and we register this with the mbean server. @@ -1317,7 +1316,7 @@ private void startInternal(final StandardContext standardContext) { LOGGER.error("Unable to deploy collapsed ear in war " + standardContext, e); undeploy(standardContext, contextInfo); // just to force tomee to start without EE part - if (System.getProperty(TOMEE_EAT_EXCEPTION_PROP) == null) { + if (System.getProperty(TomEESystemConfig.TOMEE_EAT_EXCEPTION_PROP) == null) { final TomEERuntimeException tre = new TomEERuntimeException(e); final DeploymentExceptionManager dem = SystemInstance.get().getComponent(DeploymentExceptionManager.class); dem.saveDeploymentException(contextInfo.appInfo, tre); @@ -1459,7 +1458,7 @@ private void startInternal(final StandardContext standardContext) { standardContext.getServletContext().setAttribute(InstanceManager.class.getName(), standardContext.getInstanceManager()); } catch (final Exception e) { LOGGER.error("Error merging Java EE JNDI entries in to war " + standardContext.getPath() + ": Exception: " + e.getMessage(), e); - if (System.getProperty(TOMEE_EAT_EXCEPTION_PROP) == null) { + if (System.getProperty(TomEESystemConfig.TOMEE_EAT_EXCEPTION_PROP) == null) { final DeploymentExceptionManager dem = SystemInstance.get().getComponent(DeploymentExceptionManager.class); if (dem != null && dem.getDeploymentException(contextInfo.appInfo) != null) { if (RuntimeException.class.isInstance(e)) { diff --git a/tomee/tomee-config/pom.xml b/tomee/tomee-config/pom.xml new file mode 100644 index 00000000000..cd65d91ba4e --- /dev/null +++ b/tomee/tomee-config/pom.xml @@ -0,0 +1,39 @@ + + + + + tomee + org.apache.tomee + 8.0.0-SNAPSHOT + + 4.0.0 + + tomee-config + OpenEJB :: TomEE :: Config + + + ${project.groupId}.tomee.config + + + + + + diff --git a/tomee/tomee-config/src/main/java/org/apache/tomee/config/TomEESystemConfig.java b/tomee/tomee-config/src/main/java/org/apache/tomee/config/TomEESystemConfig.java new file mode 100644 index 00000000000..a6985e288be --- /dev/null +++ b/tomee/tomee-config/src/main/java/org/apache/tomee/config/TomEESystemConfig.java @@ -0,0 +1,42 @@ +/* + * 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.config; + +/** + * This class is responsible for providing all system properties + * used by TomEE system. + */ +public final class TomEESystemConfig { + + /** + * Not to provide public constructor. + */ + private TomEESystemConfig(){ + throw new UnsupportedOperationException("Not allowed to instantiate this class"); + } + + /** + * Eat the application deployment exception. + */ + public static final String TOMEE_EAT_EXCEPTION_PROP = "tomee.eat-exception"; + + /** + * Shows server info at startup. + */ + public static final String TOMEE_INIT_J2EE_INFO = "tomee.init-J2EE-info"; + +}