Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] New WildFly EE platform #1765

Merged
merged 5 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions etc/el-testjee.wildfly.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -16,7 +16,7 @@
server.name=jboss

#Server type/major version (value is specified by cargo-maven2-plugin).
server.containerId=wildfly17x
server.containerId=wildfly27x

#Hostname to which server binds. Used by testing client (EJB client) too.
server.host=localhost
Expand All @@ -40,14 +40,14 @@ server.pwd=adminadmin
server.initialCtxFactory=org.wildfly.naming.client.WildFlyInitialContextFactory

#EclipseLink specific property/hint to identify server family.
server.platform=JBoss
server.platform.class=jboss-platform
server.platform=WildFly
server.platform.class=wildfly-platform

#JEE server client library. There are Maven artifact properties. Use Maven Central to find right values.
jee.client.groupId=org.wildfly
jee.client.artifactId=wildfly-ejb-client-bom
#In case of WildFly this property is used as a substitution property in eclipselink-wildfly-module.xsl file.
jee.client.version=18.0.0.Final
jee.client.version=27.0.0.Final

#Server binaries location.
#Just binaries are needed. cargo-maven2-plugin during maven build/tests configures server/server domain automatically in .../target/cargo directory.
Expand All @@ -56,7 +56,7 @@ jee.client.version=18.0.0.Final
#cargo.container.installation.home=/usr/local/javaApplications/wildfly-15.0.1.Final
#false - Maven will download and unpack JEE server to the "${user.home}/.eclipselinktests" directory automatically.
skip.jee.server.installation=false
cargo.container.installation.home=${user.home}/.eclipselinktests/wildfly-18.0.0.Final
cargo.container.installation.home=${user.home}/.eclipselinktests/27.0.0.Final

#Part of JNDI name (suffix) used by generic JPA test client. This JNDI points to the testing EJBs deployed to the server.
#Most test using only first value, but in some cases other JNDIs EJBs are used too.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/

// Contributors:
// Oracle - initial API and implementation
package org.eclipse.persistence.testing.tests.sessionsxml;

import org.eclipse.persistence.platform.server.wildfly.WildFlyPlatform;
import org.eclipse.persistence.sessions.DatabaseSession;
import org.eclipse.persistence.sessions.factories.SessionManager;
import org.eclipse.persistence.sessions.factories.XMLSessionConfigLoader;
import org.eclipse.persistence.testing.framework.AutoVerifyTestCase;
import org.eclipse.persistence.testing.framework.TestErrorException;


/**
* Tests server platform tag for WildFly.
*
* @version 1.0
*/
public class SessionsXMLSchemaWildFlyPlatformTest extends AutoVerifyTestCase {
Exception m_exceptionCaught;
DatabaseSession m_employeeSession;

public SessionsXMLSchemaWildFlyPlatformTest() {
setDescription("Tests loading a WildFly platform from the schema.");
}

@Override
public void reset() {
if ((m_employeeSession != null) && m_employeeSession.isConnected()) {
m_employeeSession.logout();
SessionManager.getManager().getSessions().remove(m_employeeSession);
m_employeeSession = null;
}
}

@Override
protected void setup() {
m_exceptionCaught = null;
}

@Override
public void test() {
try {
XMLSessionConfigLoader loader = new XMLSessionConfigLoader("org/eclipse/persistence/testing/models/sessionsxml/XMLSchemaSessionWildFlyPlatform.xml");

m_employeeSession = (DatabaseSession)SessionManager.getManager().getSession(loader, "EmployeeSessionWildFly", getClass().getClassLoader(), false, true);
} catch (Exception e) {
m_exceptionCaught = e;
}
}

@Override
protected void verify() {
if (m_exceptionCaught != null) {
throw new TestErrorException("Loading of the session failed: " + m_exceptionCaught);
}

if (m_employeeSession == null) {
throw new TestErrorException("Loaded session was null");
}

if (!(m_employeeSession.getServerPlatform() instanceof WildFlyPlatform)) {
throw new TestErrorException("The loaded server platform was not the correct type.");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -76,6 +76,7 @@ public TestSuite getSessionXMLSchemaTestSuite() {
suite.addTest(new SessionsXMLSchemaWeblogicPlatformTest());
suite.addTest(new SessionsXMLSchemaLoggingOptionsTest());
suite.addTest(new SessionsXMLSchemaJBossPlatformTest());
suite.addTest(new SessionsXMLSchemaWildFlyPlatformTest());
suite.addTest(new SessionManagerGetMultipleSessionsTest());
suite.addTest(new FailoverLoginSettingsTest());

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="US-ASCII"?>
<!--

Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0,
or the Eclipse Distribution License v. 1.0 which is available at
http://www.eclipse.org/org/documents/edl-v10.php.

SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause

-->

<sessions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file://xsd/eclipselink_sessions_1.0.xsd" version="0">
<session xsi:type="database-session">
<name>EmployeeSessionWildFly</name>
<server-platform xsi:type="wildfly-platform"/>
<primary-project xsi:type="class">org.eclipse.persistence.testing.models.employee.relational.EmployeeProject</primary-project>
<login xsi:type="database-login">
<user-name>@dbUser@</user-name>
<password>@dbPassword@</password>
<driver-class>@driverClass@</driver-class>
<connection-url>@dbURL@</connection-url>
</login>
</session>
</sessions>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class TargetServer {
public static final String WebLogic_12 = "WebLogic_12";
public static final String JBoss = "JBoss";
public static final String SAPNetWeaver_7_1 = "NetWeaver_7_1";
public static final String WildFly = "WildFly";

public static final String DEFAULT = None;
}
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ protected static class TargetServerProp extends Prop {
{TargetServer.WebLogic_10, pcg + "wls.WebLogic_10_Platform"},
{TargetServer.WebLogic_12, pcg + "wls.WebLogic_12_Platform"},
{TargetServer.JBoss, pcg + "jboss.JBossPlatform"},
{TargetServer.SAPNetWeaver_7_1, pcg + "sap.SAPNetWeaver_7_1_Platform"}
{TargetServer.SAPNetWeaver_7_1, pcg + "sap.SAPNetWeaver_7_1_Platform"},
{TargetServer.WildFly, pcg + "wildfly.WildFlyPlatform"}
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.eclipse.persistence.internal.sessions.factories.model.platform.WebSphere_5_0_PlatformConfig;
import org.eclipse.persistence.internal.sessions.factories.model.platform.WebSphere_5_1_PlatformConfig;
import org.eclipse.persistence.internal.sessions.factories.model.platform.WebSphere_6_0_PlatformConfig;
import org.eclipse.persistence.internal.sessions.factories.model.platform.WildFlyPlatformConfig;
import org.eclipse.persistence.internal.sessions.factories.model.pool.ConnectionPolicyConfig;
import org.eclipse.persistence.internal.sessions.factories.model.pool.ConnectionPoolConfig;
import org.eclipse.persistence.internal.sessions.factories.model.pool.PoolsConfig;
Expand Down Expand Up @@ -226,6 +227,7 @@ public XMLSessionConfigProject() {
addDescriptor(buildServerPlatformConfigDescriptorFor(WebSphere_6_0_PlatformConfig.class));
addDescriptor(buildServerPlatformConfigDescriptorFor(JBossPlatformConfig.class));
addDescriptor(buildServerPlatformConfigDescriptorFor(NetWeaver_7_1_PlatformConfig.class));
addDescriptor(buildServerPlatformConfigDescriptorFor(WildFlyPlatformConfig.class));

// Set the namespaces on all descriptors.
NamespaceResolver namespaceResolver = new NamespaceResolver();
Expand Down Expand Up @@ -1200,6 +1202,7 @@ public ClassDescriptor buildServerPlatformConfigDescriptor() {
descriptor.getInheritancePolicy().addClassIndicator(WebSphere_5_1_PlatformConfig.class, "websphere-51-platform");
descriptor.getInheritancePolicy().addClassIndicator(WebSphere_6_0_PlatformConfig.class, "websphere-60-platform");
descriptor.getInheritancePolicy().addClassIndicator(JBossPlatformConfig.class, "jboss-platform");
descriptor.getInheritancePolicy().addClassIndicator(WildFlyPlatformConfig.class, "wildfly-platform");
descriptor.getInheritancePolicy().addClassIndicator(NetWeaver_7_1_PlatformConfig.class, "netweaver-71-platform");


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/

// Contributors:
// Oracle - initial API and implementation
package org.eclipse.persistence.internal.sessions.factories.model.platform;

/**
* INTERNAL:
*/
public class WildFlyPlatformConfig extends ServerPlatformConfig {
public WildFlyPlatformConfig() {
super("org.eclipse.persistence.platform.server.wildfly.WildFlyPlatform");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/

// Contributors:
// Oracle - initial API and implementation
package org.eclipse.persistence.platform.server.wildfly;

import jakarta.persistence.spi.PersistenceUnitInfo;
import org.eclipse.persistence.internal.helper.JPAClassLoaderHolder;
import org.eclipse.persistence.logging.AbstractSessionLog;
import org.eclipse.persistence.platform.server.JMXEnabledPlatform;
import org.eclipse.persistence.platform.server.JMXServerPlatformBase;
import org.eclipse.persistence.services.wildfly.MBeanWildFlyRuntimeServices;
import org.eclipse.persistence.sessions.DatabaseSession;
import org.eclipse.persistence.sessions.ExternalTransactionController;
import org.eclipse.persistence.transaction.wildfly.WildFlyTransactionController;
import org.eclipse.persistence.transaction.wildfly.WildFlyTransactionController11;

/**
* PUBLIC:
*
* This is the concrete subclass responsible for representing WildFly-specific server behavior.
*
* This platform overrides:
*
* getExternalTransactionControllerClass(): to use an WildFly-specific controller class
*
*/
public class WildFlyPlatform extends JMXServerPlatformBase implements JMXEnabledPlatform {

/**
* The following constants and attributes are used to determine the module and application name
* to satisfy the requirements for 248746 where we provide an identifier pair for JMX sessions.
* Each application can have several modules.
* 1) Application name - the persistence unit associated with the session (a 1-1 relationship)
* 2) Module name - the ejb or war jar name (there is a 1-many relationship for module:session(s))
*/
static {
/** Override by subclass: Search String in application server ClassLoader for the application:persistence_unit name */
APP_SERVER_CLASSLOADER_APPLICATION_PU_SEARCH_STRING_PREFIX = "/deploy/";
/** Override by subclass: Search String in application server session for ejb modules */
APP_SERVER_CLASSLOADER_MODULE_EJB_SEARCH_STRING_PREFIX = ".jar/";
/** Override by subclass: Search String in application server session for war modules */
APP_SERVER_CLASSLOADER_MODULE_WAR_SEARCH_STRING_PREFIX = ".war/";
APP_SERVER_CLASSLOADER_APPLICATION_PU_SEARCH_STRING_POSTFIX = "/}";
APP_SERVER_CLASSLOADER_MODULE_EJB_WAR_SEARCH_STRING_POSTFIX = "postfix,match~not;required^";
}

/**
* INTERNAL:
* Default Constructor: All behavior for the default constructor is inherited
*/
public WildFlyPlatform(DatabaseSession newDatabaseSession) {
super(newDatabaseSession);
this.enableRuntimeServices();
// Create the JMX MBean specific to this platform for later registration
this.prepareServerSpecificServicesMBean();
}

@Override
public boolean isRuntimeServicesEnabledDefault() {
return true;
}

/**
* INTERNAL: getExternalTransactionControllerClass(): Answer the class of external transaction controller to use
* for WildFly. This is read-only.
*
* @return Class externalTransactionControllerClass
*
* @see org.eclipse.persistence.transaction.JTATransactionController
* @see org.eclipse.persistence.platform.server.ServerPlatformBase#isJTAEnabled()
* @see org.eclipse.persistence.platform.server.ServerPlatformBase#disableJTA()
* @see org.eclipse.persistence.platform.server.ServerPlatformBase#initializeExternalTransactionController()
*/
@Override
public Class<? extends ExternalTransactionController> getExternalTransactionControllerClass() {
if (externalTransactionControllerClass == null){
externalTransactionControllerClass = isJTA11()
? WildFlyTransactionController11.class : WildFlyTransactionController.class;
}
return externalTransactionControllerClass;
}

/**
* INTERNAL:
* JIRA EJBTHREE-572 requires that we use the real classLoader in place of the getNewTempClassLoader().
* The override code should stay in place until the UCL3 loader does not throw a NPE on loadClass()
*
* @param puInfo - the persistence unit info
* @return ClassLoaderHolder - a composite object containing the classLoader and the flag
* that is true if the classLoader returned is temporary
*
* @see JPAClassLoaderHolder
*/
@Override
public JPAClassLoaderHolder getNewTempClassLoader(PersistenceUnitInfo puInfo) {
// Bug 6460732: Use real classLoader instead of getNewTempClassLoader for now to avoid a WildFly NPE on loadClass()
ClassLoader realClassLoader = puInfo.getClassLoader();
AbstractSessionLog.getLog().log(AbstractSessionLog.WARNING, "persistence_unit_processor_wildfly_temp_classloader_bypassed",//
puInfo.getPersistenceUnitName(), realClassLoader);
return new JPAClassLoaderHolder(realClassLoader, false);
}

/**
* INTERNAL:
* prepareServerSpecificServicesMBean(): Server specific implementation of the
* creation and deployment of the JMX MBean to provide runtime services for the
* databaseSession.
*
* Default is to do nothing.
* Implementing platform classes must override this function and supply
* the server specific MBean instance for later registration by calling it in the constructor.
*
* @see #isRuntimeServicesEnabled()
* @see #disableRuntimeServices()
* @see #registerMBean()
*/
@Override
public void prepareServerSpecificServicesMBean() {
// No check for an existing cached MBean - we will replace it if it exists
if(getDatabaseSession() != null && shouldRegisterRuntimeBean) {
this.setRuntimeServicesMBean(new MBeanWildFlyRuntimeServices(getDatabaseSession()));
}
}

/**
* INTERNAL:
* serverSpecificRegisterMBean(): Server specific implementation of the
* creation and deployment of the JMX MBean to provide runtime services for my
* databaseSession.
*
* @see #isRuntimeServicesEnabled()
* @see #disableRuntimeServices()
* @see #registerMBean()
*/
@Override
public void serverSpecificRegisterMBean() {
super.serverSpecificRegisterMBean();
// get and cache module and application name during registration
initializeApplicationNameAndModuleName();
}

}