diff --git a/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/PlatformVersion.java b/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/PlatformVersion.java index 79bc251e160..819e9e3db62 100644 --- a/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/PlatformVersion.java +++ b/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/PlatformVersion.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2014, 2022 IBM Corporation and others. + * Copyright (c) 2014, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -22,6 +22,7 @@ public interface PlatformVersion { // 8, http://xmlns.jcp.org/xml/ns/javaee // last javax // 9, https://jakarta.ee/xml/ns/jakartaee // jakarta EE 9 // 10, https://jakarta.ee/xml/ns/jakartaee // jakarta EE 10 + // 11, https://jakarta.ee/xml/ns/jakartaee // jakarta EE 11 String NAMESPACE_SUN_J2EE = "http://java.sun.com/xml/ns/j2ee"; String NAMESPACE_SUN_JAVAEE = "http://java.sun.com/xml/ns/javaee"; @@ -33,14 +34,16 @@ public interface PlatformVersion { String VERSION_1_4_STR = "1.4"; String VERSION_5_0_STR = "5.0"; String VERSION_6_0_STR = "6.0"; - String VERSION_7_STR = "7"; + String VERSION_7_STR = "7"; String VERSION_7_0_STR = "7.0"; String VERSION_8_0_STR = "8.0"; String VERSION_9_STR = "9"; String VERSION_9_0_STR = "9.0"; String VERSION_10_STR = "10"; String VERSION_10_0_STR = "10.0"; - + String VERSION_11_STR = "11"; + String VERSION_11_0_STR = "11.0"; + int VERSION_1_2_INT = 12; int VERSION_1_3_INT = 13; int VERSION_1_4_INT = 14; @@ -50,68 +53,73 @@ public interface PlatformVersion { int VERSION_8_0_INT = 80; int VERSION_9_0_INT = 90; int VERSION_10_0_INT = 100; + int VERSION_11_0_INT = 110; // public static String getDottedVersionText(int version) { switch ( version ) { - case 0: return null; - case 9: return "0.9"; - case 10: return "1.0"; - case 11: return "1.1"; - case 12: return "1.2"; - case 13: return "1.3"; - case 14: return "1.4"; - case 15: return "1.5"; - case 16: return "1.6"; - case 17: return "1.7"; - case 20: return "2.0"; - case 21: return "2.1"; - case 22: return "2.2"; - case 23: return "2.3"; - case 24: return "2.4"; - case 25: return "2.5"; - case 30: return "3.0"; - case 31: return "3.1"; - case 32: return "3.2"; - case 40: return "4.0"; - case 50: return "5.0"; - case 60: return "6.0"; - case 70: return "7.0"; - case 80: return "8.0"; - case 90: return "9.0"; + case 0: return null; + case 9: return "0.9"; + case 10: return "1.0"; + case 11: return "1.1"; + case 12: return "1.2"; + case 13: return "1.3"; + case 14: return "1.4"; + case 15: return "1.5"; + case 16: return "1.6"; + case 17: return "1.7"; + case 20: return "2.0"; + case 21: return "2.1"; + case 22: return "2.2"; + case 23: return "2.3"; + case 24: return "2.4"; + case 25: return "2.5"; + case 30: return "3.0"; + case 31: return "3.1"; + case 32: return "3.2"; + case 40: return "4.0"; + case 50: return "5.0"; + case 60: return "6.0"; + case 61: return "6.1"; + case 70: return "7.0"; + case 80: return "8.0"; + case 90: return "9.0"; case 100: return "10.0"; - default: throw new IllegalArgumentException("Unknown schema version [ " + version + " ]"); + case 110: return "11.0"; + default: throw new IllegalArgumentException("Unknown schema version [ " + version + " ]"); } } public static String getVersionText(int version) { switch ( version ) { - case 0: return null; - case 11: return "1.1"; - case 12: return "1.2"; - case 13: return "1.3"; - case 14: return "1.4"; - case 15: return "1.5"; - case 16: return "1.6"; - case 17: return "1.7"; - case 20: return "2.0"; - case 21: return "2.1"; - case 22: return "2.2"; - case 23: return "2.3"; - case 24: return "2.4"; - case 25: return "2.5"; - case 30: return "3.0"; - case 31: return "3.1"; - case 32: return "3.2"; - case 40: return "4"; - case 50: return "5"; - case 60: return "6"; - case 70: return "7"; - case 80: return "8"; - case 90: return "9"; + case 0: return null; + case 11: return "1.1"; + case 12: return "1.2"; + case 13: return "1.3"; + case 14: return "1.4"; + case 15: return "1.5"; + case 16: return "1.6"; + case 17: return "1.7"; + case 20: return "2.0"; + case 21: return "2.1"; + case 22: return "2.2"; + case 23: return "2.3"; + case 24: return "2.4"; + case 25: return "2.5"; + case 30: return "3.0"; + case 31: return "3.1"; + case 32: return "3.2"; + case 40: return "4"; + case 50: return "5"; + case 60: return "6"; + case 61: return "6.1"; + case 70: return "7"; + case 80: return "8"; + case 90: return "9"; case 100: return "10"; - default: throw new IllegalArgumentException("Unknown schema version [ " + version + " ]"); + case 110: return "11"; + default: throw new IllegalArgumentException("Unknown schema version [ " + version + " ]"); } - } + } } diff --git a/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ContextService.java b/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ContextService.java index 6f069536661..7a86fdddb30 100644 --- a/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ContextService.java +++ b/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ContextService.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2021,2022 IBM Corporation and others. + * Copyright (c) 2021, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -33,6 +33,11 @@ public interface ContextService extends JNDIEnvironmentRef, Describable { */ String[] getUnchanged(); + /** + * @return <qualifier> elements as a read-only list + */ + String[] getQualifiers(); + /** * @return <property> elements as a read-only list */ diff --git a/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedExecutor.java b/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedExecutor.java index fa20995368e..43dd64f1b2e 100644 --- a/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedExecutor.java +++ b/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedExecutor.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2021,2022 IBM Corporation and others. + * Copyright (c) 2021, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -17,7 +17,7 @@ /** * Represents <managed-executor>. */ -public interface ManagedExecutor extends JNDIEnvironmentRef, Describable { +public interface ManagedExecutor extends JNDIEnvironmentRef, Describable { /** * @return <context-service-ref>, or null if unspecified */ @@ -47,8 +47,25 @@ public interface ManagedExecutor extends JNDIEnvironmentRef, Describable { */ boolean isSetMaxAsync(); + /** + * @return <virtual> if specified + * @see #isSetVirutal + */ + boolean isVirtual(); + + /** + * @return true if <virtual> is specified + * @see #isVirtual + */ + boolean isSetVirtual(); + + /** + * @return <qualifier> elements as a read-only list + */ + String[] getQualifiers(); + /** * @return <property> elements as a read-only list */ - List getProperties(); + List getProperties(); } diff --git a/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedScheduledExecutor.java b/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedScheduledExecutor.java index 7ad167ff1a0..248c2639998 100644 --- a/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedScheduledExecutor.java +++ b/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedScheduledExecutor.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2021,2022 IBM Corporation and others. + * Copyright (c) 2021, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -46,7 +46,24 @@ public interface ManagedScheduledExecutor extends JNDIEnvironmentRef, Describabl * @see #getMaxAsync */ boolean isSetMaxAsync(); - + + /** + * @return <virtual> if specified + * @see #isSetVirutal + */ + boolean isVirtual(); + + /** + * @return true if <virtual> is specified + * @see #isVirtual + */ + boolean isSetVirtual(); + + /** + * @return <qualifier> elements as a read-only list + */ + String[] getQualifiers(); + /** * @return <property> elements as a read-only list */ diff --git a/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedThreadFactory.java b/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedThreadFactory.java index f1f5996ce3d..5ec8da35f20 100644 --- a/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedThreadFactory.java +++ b/dev/com.ibm.ws.javaee.dd.common/src/com/ibm/ws/javaee/dd/common/ManagedThreadFactory.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2021,2022 IBM Corporation and others. + * Copyright (c) 2021, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -34,7 +34,24 @@ public interface ManagedThreadFactory extends JNDIEnvironmentRef, Describable { * @see #getPriority */ boolean isSetPriority(); - + + /** + * @return <virtual> if specified + * @see #isSetVirutal + */ + boolean isVirtual(); + + /** + * @return true if <virtual> is specified + * @see #isVirtual + */ + boolean isSetVirtual(); + + /** + * @return <qualifier> elements as a read-only list + */ + String[] getQualifiers(); + /** * @return <property> elements as a read-only list */ diff --git a/dev/com.ibm.ws.javaee.dd/src/com/ibm/ws/javaee/dd/app/Application.java b/dev/com.ibm.ws.javaee.dd/src/com/ibm/ws/javaee/dd/app/Application.java index 41c2738931b..f7f1a2346f0 100644 --- a/dev/com.ibm.ws.javaee.dd/src/com/ibm/ws/javaee/dd/app/Application.java +++ b/dev/com.ibm.ws.javaee.dd/src/com/ibm/ws/javaee/dd/app/Application.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2011, 2022 IBM Corporation and others. + * Copyright (c) 2011, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -33,20 +33,22 @@ public interface Application extends DeploymentDescriptor, DescriptionGroup, JND int VERSION_8 = 80; int VERSION_9 = 90; int VERSION_10 = 100; + int VERSION_11 = 110; + + int[] VERSIONS = { + VERSION_1_2, VERSION_1_3, // dtd + VERSION_1_4, // sun j2ee + VERSION_5, VERSION_6, // sun javaee + VERSION_7, VERSION_8, // jcp java + VERSION_9, VERSION_10, VERSION_11 // Jakarta + }; - int [] VERSIONS = { - VERSION_1_2, VERSION_1_3, // dtd - VERSION_1_4, // sun j2ee - VERSION_5, VERSION_6, // sun javaee - VERSION_7, VERSION_8, // jcp java - VERSION_9, VERSION_10 // Jakarta - }; - String getVersion(); String getApplicationName(); boolean isSetInitializeInOrder(); + boolean isInitializeInOrder(); List getModules(); diff --git a/dev/com.ibm.ws.javaee.dd/src/com/ibm/ws/javaee/dd/web/WebApp.java b/dev/com.ibm.ws.javaee.dd/src/com/ibm/ws/javaee/dd/web/WebApp.java index 8461c0ad512..61fdd429fdd 100644 --- a/dev/com.ibm.ws.javaee.dd/src/com/ibm/ws/javaee/dd/web/WebApp.java +++ b/dev/com.ibm.ws.javaee.dd/src/com/ibm/ws/javaee/dd/web/WebApp.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2011, 2022 IBM Corporation and others. + * Copyright (c) 2011, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -24,24 +24,27 @@ public interface WebApp extends ModuleDeploymentDescriptor, DeploymentDescriptor int VERSION_2_2 = 22; int VERSION_2_3 = 23; int VERSION_2_4 = 24; - int VERSION_2_5 = 25; + int VERSION_2_5 = 25; int VERSION_3_0 = 30; int VERSION_3_1 = 31; int VERSION_4_0 = 40; // JavaEE int VERSION_5_0 = 50; // Jakarta EE 9 int VERSION_6_0 = 60; // Jakarta EE 10 - - int[] VERSIONS = { - VERSION_2_2, VERSION_2_3, - VERSION_2_4, - VERSION_2_5, VERSION_3_0, - VERSION_3_1, VERSION_4_0, - VERSION_5_0, VERSION_6_0 + int VERSION_6_1 = 61; // Jakarta EE 11 + + int[] VERSIONS = { + VERSION_2_2, VERSION_2_3, + VERSION_2_4, + VERSION_2_5, VERSION_3_0, + VERSION_3_1, VERSION_4_0, + VERSION_5_0, VERSION_6_0, + VERSION_6_1 }; String getVersion(); boolean isSetMetadataComplete(); + boolean isMetadataComplete(); @Override diff --git a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/app/ApplicationDDParser.java b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/app/ApplicationDDParser.java index 48c6ebaa243..e28bbed65c3 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/app/ApplicationDDParser.java +++ b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/app/ApplicationDDParser.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2012, 2022 IBM Corporation and others. + * Copyright (c) 2012, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -34,15 +34,16 @@ public class ApplicationDDParser extends DDParserSpec { new VersionData("8", null, NAMESPACE_JCP_JAVAEE, Application.VERSION_8, VERSION_8_0_INT), new VersionData("9", null, NAMESPACE_JAKARTA, Application.VERSION_9, VERSION_9_0_INT), - new VersionData("10", null, NAMESPACE_JAKARTA, Application.VERSION_10, VERSION_10_0_INT) + new VersionData("10", null, NAMESPACE_JAKARTA, Application.VERSION_10, VERSION_10_0_INT), + new VersionData("11", null, NAMESPACE_JAKARTA, Application.VERSION_11, VERSION_11_0_INT) }; public static int getMaxTolerated() { - return Application.VERSION_10; + return Application.VERSION_11; } public static int getMaxImplemented() { - return Application.VERSION_9; + return Application.VERSION_10; } @Override diff --git a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ContextServiceType.java b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ContextServiceType.java index 5b67caa3e79..37460c70064 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ContextServiceType.java +++ b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ContextServiceType.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2022 IBM Corporation and others. + * Copyright (c) 2022, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -20,9 +20,9 @@ import com.ibm.ws.javaee.dd.common.Description; import com.ibm.ws.javaee.dd.common.Property; import com.ibm.ws.javaee.ddmodel.DDParser; -import com.ibm.ws.javaee.ddmodel.StringType; import com.ibm.ws.javaee.ddmodel.DDParser.ParsableListImplements; import com.ibm.ws.javaee.ddmodel.DDParser.ParseException; +import com.ibm.ws.javaee.ddmodel.StringType; // // @@ -31,6 +31,7 @@ // // // +// // // // @@ -53,7 +54,7 @@ public boolean isIdAllowed() { @SuppressWarnings("unchecked") @Override public List getDescriptions() { - if ( descriptions != null ) { + if (descriptions != null) { return (List) descriptions; } else { return Collections.emptyList(); @@ -62,7 +63,7 @@ public List getDescriptions() { @Override public String[] getCleared() { - if ( cleared == null ) { + if (cleared == null) { // Per the xsd documentation, "Absent other configuration, cleared context defaults to Transaction." // However, we cannot default it here because we need to represent the state of unspecified // so that merging with annotations can be performed correctly. @@ -74,7 +75,7 @@ public String[] getCleared() { @Override public String[] getPropagated() { - if ( propagated != null ) { + if (propagated != null) { return propagated.getArray(); } else { return StringType.ListType.getEmptyArray(); @@ -83,13 +84,22 @@ public String[] getPropagated() { @Override public String[] getUnchanged() { - if ( unchanged != null ) { + if (unchanged != null) { return unchanged.getArray(); } else { return StringType.ListType.getEmptyArray(); } } - + + @Override + public String[] getQualifiers() { + if (qualifiers != null) { + return qualifiers.getArray(); + } else { + return XSDTokenType.ListType.EMPTY_ARRAY; + } + } + @Override public List getProperties() { if (properties != null) { @@ -105,6 +115,7 @@ public List getProperties() { private StringType.ListType cleared; private StringType.ListType propagated; private StringType.ListType unchanged; + private XSDTokenType.ListType qualifiers; private PropertyType.ListType properties; public ContextServiceType() { @@ -133,7 +144,7 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept cleared.add(cleared_element); return true; } - + if ("propagated".equals(localName)) { StringType propagated_element = new StringType(); parser.parse(propagated_element); @@ -152,7 +163,17 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept } unchanged.add(unchanged_element); return true; - } + } + + if ("qualifier".equals(localName)) { + XSDTokenType unchanged_element = new XSDTokenType(); + parser.parse(unchanged_element); + if (qualifiers == null) { + qualifiers = new XSDTokenType.ListType(); + } + qualifiers.add(unchanged_element); + return true; + } if ("property".equals(localName)) { PropertyType property = new PropertyType(); @@ -171,23 +192,25 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept @Override public void describeHead(DDParser.Diagnostics diag) { - if ( descriptions != null ) { - diag.describe( "description", (DescriptionType) (descriptions.get(0)) ); + if (descriptions != null) { + diag.describe("description", (DescriptionType) (descriptions.get(0))); } super.describeHead(diag); } - + @Override public void describeBody(DDParser.Diagnostics diag) { super.describeBody(diag); diag.describeIfSet("cleared", cleared); diag.describeIfSet("propagated", propagated); diag.describeIfSet("unchanged", unchanged); + diag.describeIfSet("qualifier", qualifiers); } - + @Override public void describeTail(DDParser.Diagnostics diag) { super.describeTail(diag); diag.describeIfSet("property", properties); } + } diff --git a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedExecutorType.java b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedExecutorType.java index 6be7210bb7f..3c1a2e4f8d3 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedExecutorType.java +++ b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedExecutorType.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2022 IBM Corporation and others. + * Copyright (c) 2022, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -31,6 +31,8 @@ // // // +// +// // // // @@ -47,13 +49,13 @@ public ManagedExecutorType newInstance(DDParser parser) { @SuppressWarnings("unchecked") @Override public List getDescriptions() { - if ( descriptions != null ) { + if (descriptions != null) { return (List) descriptions; } else { return Collections.emptyList(); } } - + @Override public String getContextServiceRef() { return contextServiceRef == null ? null : contextServiceRef.getValue(); @@ -87,14 +89,35 @@ public boolean isSetHungTaskThreshold() { public long getHungTaskThreshold() { return hungTaskThreshold != null ? hungTaskThreshold.getIntValue() : 0; } - + + @Override + public boolean isSetVirtual() { + return AnySimpleType.isSet(virtual); + } + + @Override + public boolean isVirtual() { + return virtual != null ? virtual.getBooleanValue() : false; + } + + @Override + public String[] getQualifiers() { + if (qualifiers != null) { + return qualifiers.getArray(); + } else { + return XSDTokenType.ListType.EMPTY_ARRAY; + } + } + // private List descriptions; private JNDINameType contextServiceRef; private XSDIntegerType maxAsync; private XSDIntegerType hungTaskThreshold; - private PropertyType.ListType properties; + private XSDBooleanType virtual; + private XSDTokenType.ListType qualifiers; + private PropertyType.ListType properties; public ManagedExecutorType() { super("name"); @@ -105,7 +128,7 @@ public ManagedExecutorType() { public boolean isIdAllowed() { return true; } - + @Override public boolean handleChild(DDParser parser, String localName) throws ParseException { if (super.handleChild(parser, localName)) { @@ -126,7 +149,7 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept parser.parse(contextServiceRef); return true; } - + if ("hung-task-threshold".equals(localName)) { XSDIntegerType hungTaskThreshold = new XSDIntegerType(); parser.parse(hungTaskThreshold); @@ -141,6 +164,23 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept return true; } + if ("virtual".equals(localName)) { + XSDBooleanType virtual = new XSDBooleanType(); + parser.parse(virtual); + this.virtual = virtual; + return true; + } + + if ("qualifier".equals(localName)) { + XSDTokenType unchanged_element = new XSDTokenType(); + parser.parse(unchanged_element); + if (qualifiers == null) { + qualifiers = new XSDTokenType.ListType(); + } + qualifiers.add(unchanged_element); + return true; + } + if ("property".equals(localName)) { PropertyType property = new PropertyType(); parser.parse(property); @@ -150,7 +190,7 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept properties.add(property); return true; } - + return false; } @@ -158,8 +198,8 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept @Override public void describeHead(DDParser.Diagnostics diag) { - if ( descriptions != null ) { - diag.describe( "description", (DescriptionType) (descriptions.get(0)) ); + if (descriptions != null) { + diag.describe("description", (DescriptionType) (descriptions.get(0))); } super.describeHead(diag); } @@ -167,14 +207,17 @@ public void describeHead(DDParser.Diagnostics diag) { @Override public void describeBody(DDParser.Diagnostics diag) { super.describeBody(diag); - diag.describe("context-service-ref", contextServiceRef); - diag.describeIfSet("hung-task-threshold", hungTaskThreshold); + diag.describe("context-service-ref", contextServiceRef); + diag.describeIfSet("hung-task-threshold", hungTaskThreshold); diag.describeIfSet("max-async", maxAsync); + diag.describeIfSet("virtual", virtual); + diag.describeIfSet("qualifier", qualifiers); } - + @Override public void describeTail(DDParser.Diagnostics diag) { super.describeTail(diag); diag.describeIfSet("property", properties); - } + } + } diff --git a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedScheduledExecutorType.java b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedScheduledExecutorType.java index 45386f739b4..33a10cbeeb4 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedScheduledExecutorType.java +++ b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedScheduledExecutorType.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2022 IBM Corporation and others. + * Copyright (c) 2022, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -31,6 +31,8 @@ // // // +// +// // // // @@ -47,13 +49,13 @@ public ManagedScheduledExecutorType newInstance(DDParser parser) { @SuppressWarnings("unchecked") @Override public List getDescriptions() { - if ( descriptions != null ) { + if (descriptions != null) { return (List) descriptions; } else { return Collections.emptyList(); } } - + @Override public String getContextServiceRef() { return contextServiceRef == null ? null : contextServiceRef.getValue(); @@ -78,7 +80,26 @@ public boolean isSetHungTaskThreshold() { public long getHungTaskThreshold() { return hungTaskThreshold != null ? hungTaskThreshold.getIntValue() : 0; } - + + @Override + public boolean isSetVirtual() { + return AnySimpleType.isSet(virtual); + } + + @Override + public boolean isVirtual() { + return virtual != null ? virtual.getBooleanValue() : false; + } + + @Override + public String[] getQualifiers() { + if (qualifiers != null) { + return qualifiers.getArray(); + } else { + return XSDTokenType.ListType.EMPTY_ARRAY; + } + } + @Override public List getProperties() { if (properties != null) { @@ -91,16 +112,18 @@ public List getProperties() { // private List descriptions; - private JNDINameType contextServiceRef; + private JNDINameType contextServiceRef; private XSDIntegerType maxAsync; private XSDIntegerType hungTaskThreshold; - private PropertyType.ListType properties; - + private XSDBooleanType virtual; + private XSDTokenType.ListType qualifiers; + private PropertyType.ListType properties; + public ManagedScheduledExecutorType() { super("name"); } - @Trivial + @Trivial @Override public boolean isIdAllowed() { return true; @@ -140,7 +163,24 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept this.maxAsync = maxAsync; return true; } - + + if ("virtual".equals(localName)) { + XSDBooleanType virtual = new XSDBooleanType(); + parser.parse(virtual); + this.virtual = virtual; + return true; + } + + if ("qualifier".equals(localName)) { + XSDTokenType unchanged_element = new XSDTokenType(); + parser.parse(unchanged_element); + if (qualifiers == null) { + qualifiers = new XSDTokenType.ListType(); + } + qualifiers.add(unchanged_element); + return true; + } + if ("property".equals(localName)) { PropertyType property = new PropertyType(); parser.parse(property); @@ -150,7 +190,7 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept properties.add(property); return true; } - + return false; } @@ -158,8 +198,8 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept @Override public void describeHead(DDParser.Diagnostics diag) { - if ( descriptions != null ) { - diag.describe( "description", (DescriptionType) (descriptions.get(0)) ); + if (descriptions != null) { + diag.describe("description", (DescriptionType) (descriptions.get(0))); } super.describeHead(diag); } @@ -167,14 +207,17 @@ public void describeHead(DDParser.Diagnostics diag) { @Override public void describeBody(DDParser.Diagnostics diag) { super.describeBody(diag); - diag.describe("context-service-ref", contextServiceRef); - diag.describeIfSet("hung-task-threshold", hungTaskThreshold); + diag.describe("context-service-ref", contextServiceRef); + diag.describeIfSet("hung-task-threshold", hungTaskThreshold); diag.describeIfSet("max-async", maxAsync); + diag.describeIfSet("virtual", virtual); + diag.describeIfSet("qualifier", qualifiers); } - + @Override public void describeTail(DDParser.Diagnostics diag) { super.describeTail(diag); diag.describeIfSet("property", properties); - } + } + } diff --git a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedThreadFactoryType.java b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedThreadFactoryType.java index 1cc9f294681..1eef315ad0f 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedThreadFactoryType.java +++ b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/ManagedThreadFactoryType.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2014 IBM Corporation and others. + * Copyright (c) 2014, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -30,6 +30,8 @@ // // // +// +// // // // @@ -46,13 +48,13 @@ public ManagedThreadFactoryType newInstance(DDParser parser) { @SuppressWarnings("unchecked") @Override public List getDescriptions() { - if ( descriptions != null ) { + if (descriptions != null) { return (List) descriptions; } else { return Collections.emptyList(); } } - + @Override public String getContextServiceRef() { return contextServiceRef == null ? null : contextServiceRef.getValue(); @@ -68,6 +70,25 @@ public boolean isSetPriority() { return AnySimpleType.isSet(priority); } + @Override + public boolean isSetVirtual() { + return AnySimpleType.isSet(virtual); + } + + @Override + public boolean isVirtual() { + return virtual != null ? virtual.getBooleanValue() : false; + } + + @Override + public String[] getQualifiers() { + if (qualifiers != null) { + return qualifiers.getArray(); + } else { + return XSDTokenType.ListType.EMPTY_ARRAY; + } + } + @Override public List getProperties() { if (properties != null) { @@ -76,14 +97,16 @@ public List getProperties() { return Collections.emptyList(); } } - + // private List descriptions; - private JNDINameType contextServiceRef; + private JNDINameType contextServiceRef; private XSDIntegerType priority; + private XSDBooleanType virtual; + private XSDTokenType.ListType qualifiers; private PropertyType.ListType properties; - + public ManagedThreadFactoryType() { super("name"); } @@ -106,7 +129,6 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept descriptions = Collections.singletonList(description); return true; } - if ("context-service-ref".equals(localName)) { if (contextServiceRef == null) { @@ -123,6 +145,23 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept return true; } + if ("virtual".equals(localName)) { + XSDBooleanType virtual = new XSDBooleanType(); + parser.parse(virtual); + this.virtual = virtual; + return true; + } + + if ("qualifier".equals(localName)) { + XSDTokenType unchanged_element = new XSDTokenType(); + parser.parse(unchanged_element); + if (qualifiers == null) { + qualifiers = new XSDTokenType.ListType(); + } + qualifiers.add(unchanged_element); + return true; + } + if ("property".equals(localName)) { PropertyType property = new PropertyType(); parser.parse(property); @@ -131,7 +170,7 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept } properties.add(property); return true; - } + } return false; } @@ -140,8 +179,8 @@ public boolean handleChild(DDParser parser, String localName) throws ParseExcept @Override public void describeHead(DDParser.Diagnostics diag) { - if ( descriptions != null ) { - diag.describe( "description", (DescriptionType) (descriptions.get(0)) ); + if (descriptions != null) { + diag.describe("description", (DescriptionType) (descriptions.get(0))); } super.describeHead(diag); } @@ -149,13 +188,16 @@ public void describeHead(DDParser.Diagnostics diag) { @Override public void describeBody(DDParser.Diagnostics diag) { super.describeBody(diag); - diag.describe("context-service-ref", contextServiceRef); + diag.describe("context-service-ref", contextServiceRef); diag.describeIfSet("priority", priority); + diag.describeIfSet("virtual", virtual); + diag.describeIfSet("qualifier", qualifiers); } - + @Override public void describeTail(DDParser.Diagnostics diag) { super.describeTail(diag); diag.describeIfSet("property", properties); } + } diff --git a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/XSDTokenType.java b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/XSDTokenType.java index de7627dcbd9..f89a0d9574a 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/XSDTokenType.java +++ b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/common/XSDTokenType.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2011 IBM Corporation and others. + * Copyright (c) 2011, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -45,6 +45,17 @@ public List getList() { } return stringList; } + + public String[] getArray() { + String[] stringArray = new String[list.size()]; + for (int i = 0; i < list.size(); i++) { + stringArray[i] = list.get(i).getValue(); + } + return stringArray; + } + + public static final String[] EMPTY_ARRAY = new String[] {}; + } @Override diff --git a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/web/WebAppDDParser.java b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/web/WebAppDDParser.java index c54f082351a..ce37a9e8aed 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/web/WebAppDDParser.java +++ b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/web/WebAppDDParser.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2014, 2022 IBM Corporation and others. + * Copyright (c) 2014, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -35,15 +35,16 @@ public class WebAppDDParser extends DDParserSpec { new VersionData("4.0", null, NAMESPACE_JCP_JAVAEE, WebApp.VERSION_4_0, VERSION_8_0_INT), new VersionData("5.0", null, NAMESPACE_JAKARTA, WebApp.VERSION_5_0, VERSION_9_0_INT), - new VersionData("6.0", null, NAMESPACE_JAKARTA, WebApp.VERSION_6_0, VERSION_10_0_INT) + new VersionData("6.0", null, NAMESPACE_JAKARTA, WebApp.VERSION_6_0, VERSION_10_0_INT), + new VersionData("6.1", null, NAMESPACE_JAKARTA, WebApp.VERSION_6_1, VERSION_11_0_INT) }; public static int getMaxTolerated() { - return WebApp.VERSION_6_0; + return WebApp.VERSION_6_1; } public static int getMaxImplemented() { - return WebApp.VERSION_5_0; + return WebApp.VERSION_6_0; } @Override diff --git a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/web/WebFragmentDDParser.java b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/web/WebFragmentDDParser.java index 9eeec9bb3fe..bf7cbea7295 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/web/WebFragmentDDParser.java +++ b/dev/com.ibm.ws.javaee.ddmodel/src/com/ibm/ws/javaee/ddmodel/web/WebFragmentDDParser.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2014, 2022 IBM Corporation and others. + * Copyright (c) 2014, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -25,15 +25,16 @@ public class WebFragmentDDParser extends DDParserSpec { new VersionData("4.0", null, NAMESPACE_JCP_JAVAEE, WebApp.VERSION_4_0, VERSION_8_0_INT), new VersionData("5.0", null, NAMESPACE_JAKARTA, WebApp.VERSION_5_0, VERSION_9_0_INT), - new VersionData("6.0", null, NAMESPACE_JAKARTA, WebApp.VERSION_6_0, VERSION_10_0_INT) + new VersionData("6.0", null, NAMESPACE_JAKARTA, WebApp.VERSION_6_0, VERSION_10_0_INT), + new VersionData("6.1", null, NAMESPACE_JAKARTA, WebApp.VERSION_6_1, VERSION_11_0_INT) }; public static int getMaxTolerated() { - return WebApp.VERSION_6_0; + return WebApp.VERSION_6_1; } public static int getMaxImplemented() { - return WebApp.VERSION_5_0; + return WebApp.VERSION_5_0; //TODO should this be updated to 6.0? } @Override diff --git a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/DDJakarta10Elements.java b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/DDJakarta10Elements.java index ea5b03f2e26..cfc178220b3 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/DDJakarta10Elements.java +++ b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/DDJakarta10Elements.java @@ -13,6 +13,7 @@ package com.ibm.ws.javaee.ddmodel; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.function.Consumer; @@ -124,11 +125,7 @@ public class DDJakarta10Elements { public static List names(String... name0) { - List names = new ArrayList(6); - for ( String name : names ) { - names.add(name); - } - return names; + return new ArrayList(Arrays.asList(name0)); } public static void withName(List names, String name, Consumer> action) { diff --git a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/DDJakarta11Elements.java b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/DDJakarta11Elements.java new file mode 100644 index 00000000000..208e5637e80 --- /dev/null +++ b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/DDJakarta11Elements.java @@ -0,0 +1,421 @@ +/******************************************************************************* + * Copyright (c) 2023 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package com.ibm.ws.javaee.ddmodel; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; + +import org.junit.Assert; + +import com.ibm.ws.javaee.dd.common.ContextService; +import com.ibm.ws.javaee.dd.common.Description; +import com.ibm.ws.javaee.dd.common.JNDIEnvironmentRefs; +import com.ibm.ws.javaee.dd.common.ManagedExecutor; +import com.ibm.ws.javaee.dd.common.ManagedScheduledExecutor; +import com.ibm.ws.javaee.dd.common.ManagedThreadFactory; +import com.ibm.ws.javaee.dd.common.Property; + +/* + * jakartaee_11.xsd - jakartaee_10.xsd + * + + + + + + + + + + + + + + + + + + + + + + + + + + +*/ +public class DDJakarta11Elements { + + public static List names(String... name0) { + return new ArrayList(Arrays.asList(name0)); + } + + public static void withName(List names, String name, Consumer> action) { + names.add(name); + try { + action.accept(names); + } finally { + names.remove(names.size() - 1); + } + } + + public static String dotNames(List names) { + int numNames = names.size(); + if (numNames == 0) { + return ""; + } + + String name0 = names.get(0); + if (numNames == 1) { + return name0; + } + + String name1 = names.get(1); + if (numNames == 2) { + return name0 + '.' + name1; + } + + String name2 = names.get(2); + if (numNames == 3) { + return name0 + '.' + name1 + '.' + name2; + } + + StringBuilder builder = new StringBuilder(); + builder.append(name0).append('.').append(name1).append('.').append(name2); + for (int nameNo = 3; nameNo < numNames; nameNo++) { + builder.append('.'); + builder.append(names.get(nameNo)); + } + return builder.toString(); + } + + public static void verify(List names, String expected, String actual) { + if (((expected == null) && (actual != null)) || + ((expected != null) && !expected.equals(actual))) { + Assert.assertEquals(dotNames(names), expected, actual); + } + } + + public static void verify(List names, int expected, int actual) { + if (expected != actual) { + Assert.assertEquals(dotNames(names), expected, actual); + } + } + + public static void verify(List names, boolean expected, boolean actual) { + if (expected != actual) { + Assert.assertEquals(dotNames(names), expected, actual); + } + } + + public static void verify( + List names, + String expectedLang, String expectedValue, + List actualDescriptions) { + + if (actualDescriptions.size() != 1) { + Assert.assertEquals( + "Descriptions should be a singleton [ " + actualDescriptions + " ] ", + 1, actualDescriptions.size()); + } + + Description actualDescription = actualDescriptions.get(0); + withName(names, "lang", + (useNames) -> verify(useNames, expectedLang, actualDescription.getLang())); + withName(names, "value", + (useNames) -> verify(useNames, expectedValue, actualDescription.getValue())); + } + + public static void verify( + List names, + String expectedName, String expectedValue, + Property actualProperty) { + + withName(names, "name", + (useNames) -> verify(useNames, expectedName, actualProperty.getName())); + withName(names, "value", + (useNames) -> verify(useNames, expectedValue, actualProperty.getValue())); + } + + public static void verifySize(List names, int expectedSize, List actualList) { + withName(names, "size", + (useNames) -> verify(useNames, expectedSize, actualList.size())); + } + + public static void verifySize(List names, int expectedSize, String[] actualList) { + withName(names, "size", + (useNames) -> verify(useNames, expectedSize, actualList.length)); + } + + public static void verifyDoubleton( + List names, + String expectedName0, String expectedValue0, + String expectedName1, String expectedValue1, + List properties) { + + verifySize(names, 2, properties); + withName(names, "[0]", + (useNames) -> verify(useNames, expectedName0, expectedValue0, properties.get(0))); + withName(names, "[1]", + (useNames) -> verify(useNames, expectedName1, expectedValue1, properties.get(1))); + } + + public static final void verify(List names, List actual, String... expected) { + verifySize(names, expected.length, actual); + + for (int elementNo = 0; elementNo < expected.length; elementNo++) { + final int finalElementNo = elementNo; // Needed by the compiler. + withName(names, "[" + elementNo + "]", + (useNames) -> verify(useNames, expected[finalElementNo], actual.get(finalElementNo))); + } + } + + public static final void verify(List names, String[] actual, String... expected) { + verifySize(names, expected.length, actual); + + for (int elementNo = 0; elementNo < expected.length; elementNo++) { + final int finalElementNo = elementNo; // Needed by the compiler. + withName(names, "[" + elementNo + "]", + (useNames) -> verify(useNames, expected[finalElementNo], actual[finalElementNo])); + } + } + + public static final String CONTEXT_SERVICE_XML = "\n" + + " CS01-desc\n" + + " CS01:name\n" + + " Application\n" + + " Security\n" + + " Transaction\n" + + " Remaining\n" + + " Other\n" + + " Application\n" + + " Security\n" + + " Remaining\n" + + " Other\n" + + " Application\n" + + " Security\n" + + " Transaction\n" + + " Remaining\n" + + " Other\n" + + " com.ibm.test.Qualifier1\n" + + " com.ibm.test.Qualifier2\n" + + " \n" + + " CS01\n" + + " CS01-value\n" + + " \n" + + " \n" + + " CS02\n" + + " CS02-value\n" + + " \n" + + "\n"; + + public static void verify(List names, ContextService contextService) { + // withName(names, "id", + // (useNames) -> verify("CS01", contextService.getID())); // Can't be accessed here. + withName(names, "description", + (useNames) -> verify(useNames, null, "CS01-desc", contextService.getDescriptions())); + + withName(names, "name", + (useNames) -> verify(useNames, "CS01:name", contextService.getName())); + withName(names, "cleared", + (useNames) -> verify(useNames, + contextService.getCleared(), + "Application", "Security", "Transaction", "Remaining", "Other")); + withName(names, "propagated", + (useNames) -> verify(useNames, + contextService.getPropagated(), + "Application", "Security", "Remaining", "Other")); + withName(names, "unchanged", + (useNames) -> verify(useNames, + contextService.getUnchanged(), + "Application", "Security", "Transaction", "Remaining", "Other")); + withName(names, "qualifier", + (useNames) -> verify(useNames, + contextService.getQualifiers(), + "com.ibm.test.Qualifier1", "com.ibm.test.Qualifier2")); + withName(names, "properties", + (useNames) -> verifyDoubleton(useNames, + "CS01", "CS01-value", "CS02", "CS02-value", + contextService.getProperties())); + } + + public static final String MANAGED_EXECUTOR_XML = "\n" + + " ME01-desc\n" + + " ME01:name\n" + + " java:comp\n" + + " 10\n" + + " 1000\n" + + " true\n" + + " com.ibm.test.Qualifier3\n" + + " \n" + + " ME01\n" + + " ME01-value\n" + + " \n" + + " \n" + + " ME02\n" + + " ME02-value\n" + + " \n" + + "\n"; + + public static void verify(List names, ManagedExecutor executor) { + // withName(names, "id", + // (useNames) -> verify("ME01", executor.getID())); // Can't be accessed here. + withName(names, "description", + (useNames) -> verify(useNames, null, "ME01-desc", executor.getDescriptions())); + withName(names, "name", + (useNames) -> verify(useNames, "ME01:name", executor.getName())); + withName(names, "contextServiceRef", + (useNames) -> verify(useNames, "java:comp", executor.getContextServiceRef())); + withName(names, "maxAsync", + (useNames) -> verify(useNames, 10, executor.getMaxAsync())); + withName(names, "hungTaskThreshold", + (useNames) -> verify(useNames, 1000, (int) executor.getHungTaskThreshold())); + withName(names, "virtual", + (useNames) -> verify(useNames, true, executor.isVirtual())); + withName(names, "qualifier", + (useNames) -> verify(useNames, + executor.getQualifiers(), + "com.ibm.test.Qualifier3")); + withName(names, "properties", + (useNames) -> verifyDoubleton(useNames, + "ME01", "ME01-value", "ME02", "ME02-value", + executor.getProperties())); + } + + public static final String MANAGED_SCHEDULED_EXECUTOR_XML = "\n" + + " MSE01-desc\n" + + " MSE01:name\n" + + " java:module\n" + + " 11\n" + + " 1100\n" + + " com.ibm.test.Qualifier4\n" + + " com.ibm.test.Qualifier5\n" + + " com.ibm.test.Qualifier6\n" + + " \n" + + " MSE01\n" + + " MSE01-value\n" + + " \n" + + " \n" + + " MSE02\n" + + " MSE02-value\n" + + " \n" + + "\n"; + + public static void verify(List names, ManagedScheduledExecutor executor) { + // withName(names, "id", + // (useNames) -> verify("MSE01", executor.getID())); // Can't be accessed here. + withName(names, "description", + (useNames) -> verify(useNames, null, "MSE01-desc", executor.getDescriptions())); + withName(names, "name", + (useNames) -> verify(useNames, "MSE01:name", executor.getName())); + withName(names, "contextServiceRef", + (useNames) -> verify(useNames, "java:module", executor.getContextServiceRef())); + withName(names, "maxAsync", + (useNames) -> verify(useNames, 11, executor.getMaxAsync())); + withName(names, "hungTaskThreshold", + (useNames) -> verify(useNames, 1100, (int) executor.getHungTaskThreshold())); + withName(names, "virtual", + (useNames) -> verify(useNames, false, executor.isVirtual())); //Default value should be false + withName(names, "qualifier", + (useNames) -> verify(useNames, + executor.getQualifiers(), + "com.ibm.test.Qualifier4", "com.ibm.test.Qualifier5", "com.ibm.test.Qualifier6")); + withName(names, "properties", + (useNames) -> verifyDoubleton(useNames, + "MSE01", "MSE01-value", "MSE02", "MSE02-value", + executor.getProperties())); + } + + public static final String MANAGED_THREAD_FACTORY_XML = "\n" + + " MTF01-desc\n" + + " MTF01:name\n" + + " java:app\n" + + " 10\n" + + " false\n" + + " \n" + + " MTF01\n" + + " MTF01-value\n" + + " \n" + + " \n" + + " MTF02\n" + + " MTF02-value\n" + + " \n" + + "\n"; + + public static void verify(List names, ManagedThreadFactory factory) { + // withName(names, "id", + // (useNames) -> verify("MTF01", factory.getID())); // Can't be accessed here. + withName(names, "description", + (useNames) -> verify(useNames, null, "MTF01-desc", factory.getDescriptions())); + withName(names, "name", + (useNames) -> verify(useNames, "MTF01:name", factory.getName())); + withName(names, "contextServiceRef", + (useNames) -> verify(useNames, "java:app", factory.getContextServiceRef())); + withName(names, "priority", + (useNames) -> verify(useNames, 10, factory.getPriority())); + withName(names, "virtual", + (useNames) -> verify(useNames, false, factory.isVirtual())); + withName(names, "qualifier", + (useNames) -> verify(useNames, + factory.getQualifiers())); //None provided + withName(names, "properties", + (useNames) -> verifyDoubleton(useNames, + "MTF01", "MTF01-value", "MTF02", "MTF02-value", + factory.getProperties())); + } + + // + + public static void verifyEE11(List names, JNDIEnvironmentRefs refs) { + List services = refs.getContextServices(); + DDJakarta11Elements.verifySize(names, 1, services); + DDJakarta11Elements.verify(names, services.get(0)); + + List executors = refs.getManagedExecutors(); + DDJakarta11Elements.verifySize(names, 1, executors); + DDJakarta11Elements.verify(names, executors.get(0)); + + List scheduledExecutors = refs.getManagedScheduledExecutors(); + DDJakarta11Elements.verifySize(names, 1, scheduledExecutors); + DDJakarta11Elements.verify(names, scheduledExecutors.get(0)); + + List factories = refs.getManagedThreadFactories(); + DDJakarta11Elements.verifySize(names, 1, factories); + DDJakarta11Elements.verify(names, factories.get(0)); + } +} diff --git a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/app/AppTest.java b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/app/AppTest.java index b6f510a8692..08c62f25688 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/app/AppTest.java +++ b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/app/AppTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2018, 2022 IBM Corporation and others. + * Copyright (c) 2018, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -15,22 +15,24 @@ import java.util.List; import org.junit.Test; + import com.ibm.ws.javaee.dd.app.Application; import com.ibm.ws.javaee.dd.common.ContextService; import com.ibm.ws.javaee.dd.common.ManagedExecutor; import com.ibm.ws.javaee.dd.common.ManagedScheduledExecutor; import com.ibm.ws.javaee.dd.common.ManagedThreadFactory; import com.ibm.ws.javaee.ddmodel.DDJakarta10Elements; +import com.ibm.ws.javaee.ddmodel.DDJakarta11Elements; public class AppTest extends AppTestBase { @Test public void testApp() throws Exception { - for ( int schemaVersion : Application.VERSIONS ) { - for ( int maxSchemaVersion : Application.VERSIONS ) { + for (int schemaVersion : Application.VERSIONS) { + for (int maxSchemaVersion : Application.VERSIONS) { // Open liberty will always parse JavaEE6 and earlier // schema versions. int effectiveMax; - if ( maxSchemaVersion < VERSION_6_0_INT ) { + if (maxSchemaVersion < VERSION_6_0_INT) { effectiveMax = VERSION_6_0_INT; } else { effectiveMax = maxSchemaVersion; @@ -38,104 +40,158 @@ public void testApp() throws Exception { String altMessage; String[] messages; - if ( schemaVersion > effectiveMax ) { - altMessage = UNPROVISIONED_DESCRIPTOR_VERSION_ALT_MESSAGE; + if (schemaVersion > effectiveMax) { + altMessage = UNPROVISIONED_DESCRIPTOR_VERSION_ALT_MESSAGE; messages = UNPROVISIONED_DESCRIPTOR_VERSION_MESSAGES; } else { altMessage = null; messages = null; } - parseApp( app(schemaVersion, appBody), maxSchemaVersion, altMessage, messages ); + parseApp(app(schemaVersion, appBody), maxSchemaVersion, altMessage, messages); } } } - // - + // Verify new elements to EE 10 cannot be used with EE 9 schema + @Test public void testEE10ContextServiceApp90() throws Exception { - parseApp( app(Application.VERSION_9, DDJakarta10Elements.CONTEXT_SERVICE_XML), - Application.VERSION_9, - "unexpected.child.element", - "CWWKC2259E", "context-service", "myEAR.ear : META-INF/application.xml" ); - } - + parseApp(app(Application.VERSION_9, DDJakarta10Elements.CONTEXT_SERVICE_XML), + Application.VERSION_9, + "unexpected.child.element", + "CWWKC2259E", "context-service", "myEAR.ear : META-INF/application.xml"); + } + @Test public void testEE10ManagedExecutorApp90() throws Exception { - parseApp( app(Application.VERSION_9, DDJakarta10Elements.MANAGED_EXECUTOR_XML), - Application.VERSION_9, - "unexpected.child.element", - "CWWKC2259E", "managed-executor", "myEAR.ear : META-INF/application.xml" ); - } + parseApp(app(Application.VERSION_9, DDJakarta10Elements.MANAGED_EXECUTOR_XML), + Application.VERSION_9, + "unexpected.child.element", + "CWWKC2259E", "managed-executor", "myEAR.ear : META-INF/application.xml"); + } @Test public void testEE10ManagedScheduledExecutorApp90() throws Exception { - parseApp( app(Application.VERSION_9, DDJakarta10Elements.MANAGED_SCHEDULED_EXECUTOR_XML), - Application.VERSION_9, - "unexpected.child.element", - "CWWKC2259E", "managed-scheduled-executor", "myEAR.ear : META-INF/application.xml" ); + parseApp(app(Application.VERSION_9, DDJakarta10Elements.MANAGED_SCHEDULED_EXECUTOR_XML), + Application.VERSION_9, + "unexpected.child.element", + "CWWKC2259E", "managed-scheduled-executor", "myEAR.ear : META-INF/application.xml"); } @Test public void testEE10ManagedThreadFactoryApp90() throws Exception { - parseApp( app(Application.VERSION_9, DDJakarta10Elements.MANAGED_THREAD_FACTORY_XML), - Application.VERSION_9, - "unexpected.child.element", - "CWWKC2259E", "managed-thread-factory", "myEAR.ear : META-INF/application.xml" ); - } + parseApp(app(Application.VERSION_9, DDJakarta10Elements.MANAGED_THREAD_FACTORY_XML), + Application.VERSION_9, + "unexpected.child.element", + "CWWKC2259E", "managed-thread-factory", "myEAR.ear : META-INF/application.xml"); + } - // + // Verify new elements to EE 10 are parsed correctly @Test public void testEE10ContextServiceApp100() throws Exception { Application app = parseApp( - app(Application.VERSION_10, DDJakarta10Elements.CONTEXT_SERVICE_XML), - Application.VERSION_10); + app(Application.VERSION_10, DDJakarta10Elements.CONTEXT_SERVICE_XML), + Application.VERSION_10); List names = DDJakarta10Elements.names("Application", "contextServices"); List services = app.getContextServices(); DDJakarta10Elements.verifySize(names, 1, services); - DDJakarta10Elements.verify(names, services.get(0)); - } - + DDJakarta10Elements.verify(names, services.get(0)); + } + @Test public void testEE10ManagedExecutorApp100() throws Exception { Application app = parseApp( - app(Application.VERSION_10, DDJakarta10Elements.MANAGED_EXECUTOR_XML), - Application.VERSION_10); + app(Application.VERSION_10, DDJakarta10Elements.MANAGED_EXECUTOR_XML), + Application.VERSION_10); List names = DDJakarta10Elements.names("Application", "managedExecutors"); List executors = app.getManagedExecutors(); DDJakarta10Elements.verifySize(names, 1, executors); - DDJakarta10Elements.verify(names, executors.get(0)); - } + DDJakarta10Elements.verify(names, executors.get(0)); + } @Test public void testEE10ManagedScheduledExecutorApp100() throws Exception { Application app = parseApp( - app(Application.VERSION_10, DDJakarta10Elements.MANAGED_SCHEDULED_EXECUTOR_XML), - Application.VERSION_10); + app(Application.VERSION_10, DDJakarta10Elements.MANAGED_SCHEDULED_EXECUTOR_XML), + Application.VERSION_10); List names = DDJakarta10Elements.names("Application", "managedScheduledExecutors"); - + List executors = app.getManagedScheduledExecutors(); DDJakarta10Elements.verifySize(names, 1, executors); - DDJakarta10Elements.verify(names, executors.get(0)); + DDJakarta10Elements.verify(names, executors.get(0)); } @Test public void testEE10ManagedThreadFactoryApp100() throws Exception { Application app = parseApp( - app(Application.VERSION_10, DDJakarta10Elements.MANAGED_THREAD_FACTORY_XML), - Application.VERSION_10); + app(Application.VERSION_10, DDJakarta10Elements.MANAGED_THREAD_FACTORY_XML), + Application.VERSION_10); + + List names = DDJakarta10Elements.names("Application", "managedThreadFactories"); + + List factories = app.getManagedThreadFactories(); + DDJakarta10Elements.verifySize(names, 1, factories); + DDJakarta10Elements.verify(names, factories.get(0)); + } + + // Verify new elements to EE 11 are parsed correctly + + @Test + public void testEE11ContextServiceApp110() throws Exception { + Application app = parseApp( + app(Application.VERSION_11, DDJakarta11Elements.CONTEXT_SERVICE_XML), + Application.VERSION_11); + + List names = DDJakarta10Elements.names("Application", "contextServices"); + + List services = app.getContextServices(); + DDJakarta10Elements.verifySize(names, 1, services); + DDJakarta10Elements.verify(names, services.get(0)); + } + + @Test + public void testEE11ManagedExecutorApp110() throws Exception { + Application app = parseApp( + app(Application.VERSION_11, DDJakarta11Elements.MANAGED_EXECUTOR_XML), + Application.VERSION_11); + + List names = DDJakarta10Elements.names("Application", "managedExecutors"); + + List executors = app.getManagedExecutors(); + DDJakarta10Elements.verifySize(names, 1, executors); + DDJakarta10Elements.verify(names, executors.get(0)); + } + + @Test + public void testEE11ManagedScheduledExecutorApp110() throws Exception { + Application app = parseApp( + app(Application.VERSION_11, DDJakarta11Elements.MANAGED_SCHEDULED_EXECUTOR_XML), + Application.VERSION_11); + + List names = DDJakarta10Elements.names("Application", "managedScheduledExecutors"); + + List executors = app.getManagedScheduledExecutors(); + DDJakarta10Elements.verifySize(names, 1, executors); + DDJakarta10Elements.verify(names, executors.get(0)); + } + + @Test + public void testEE11ManagedThreadFactoryApp110() throws Exception { + Application app = parseApp( + app(Application.VERSION_11, DDJakarta11Elements.MANAGED_THREAD_FACTORY_XML), + Application.VERSION_11); List names = DDJakarta10Elements.names("Application", "managedThreadFactories"); List factories = app.getManagedThreadFactories(); DDJakarta10Elements.verifySize(names, 1, factories); DDJakarta10Elements.verify(names, factories.get(0)); - } + } } diff --git a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/app/AppTestBase.java b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/app/AppTestBase.java index d550369aa2e..20b492c0296 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/app/AppTestBase.java +++ b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/app/AppTestBase.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2018, 2022 IBM Corporation and others. + * Copyright (c) 2018, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -26,7 +26,7 @@ protected static ApplicationAdapter createAppAdapter(int maxSchemaVersion) { mockery.mock(ServiceReference.class, "sr" + mockId++); String versionText = getDottedVersionText(maxSchemaVersion); mockery.checking(new Expectations() { - { + { allowing(versionRef).getProperty("version"); will(returnValue(versionText)); } @@ -143,6 +143,16 @@ protected static Application parseApp(String ddText, int maxSchemaVersion, Strin " id=\"Application_ID\"" + ">"; + protected static String app110Head = + ""; + protected static String appBody = "Deployment Descriptor FAT Enterprise Application\n" + @@ -193,7 +203,9 @@ protected static String app(int schemaVersion, String appBody) { } else if ( schemaVersion == VERSION_9_0_INT ) { appHead = app90Head; } else if ( schemaVersion == VERSION_10_0_INT ) { - appHead = app100Head; + appHead = app100Head; + } else if ( schemaVersion == VERSION_11_0_INT ) { + appHead = app110Head; } else { throw new IllegalArgumentException("Unknown application version [ " + schemaVersion + " ]"); } diff --git a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/web/WebAppTest.java b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/web/WebAppTest.java index 78ea38702b3..0bc0f627971 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/web/WebAppTest.java +++ b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/web/WebAppTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2013, 2022 IBM Corporation and others. + * Copyright (c) 2013, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -28,6 +28,7 @@ import com.ibm.ws.javaee.dd.web.common.AttributeValue; import com.ibm.ws.javaee.dd.web.common.CookieConfig; import com.ibm.ws.javaee.ddmodel.DDJakarta10Elements; +import com.ibm.ws.javaee.ddmodel.DDJakarta11Elements; public class WebAppTest extends WebAppTestBase { // Absolute ordering fragments. @@ -346,6 +347,60 @@ public void testEE10ManagedThreadFactoryWeb60() throws Exception { DDJakarta10Elements.verify(names, factories.get(0)); } + // + + @Test + public void testEE11ContextServiceWeb61() throws Exception { + WebApp webApp = parseWebApp( + webApp(WebApp.VERSION_6_1, DDJakarta11Elements.CONTEXT_SERVICE_XML), + WebApp.VERSION_6_1); + + List names = DDJakarta10Elements.names("WebApp", "contextServices"); + + List services = webApp.getContextServices(); + DDJakarta10Elements.verifySize(names, 1, services); + DDJakarta10Elements.verify(names, services.get(0)); + } + + @Test + public void testEE11ManagedExecutorWeb61() throws Exception { + WebApp webApp = parseWebApp( + webApp(WebApp.VERSION_6_1, DDJakarta11Elements.MANAGED_EXECUTOR_XML), + WebApp.VERSION_6_1); + + List names = DDJakarta10Elements.names("WebApp", "managedExecutors"); + + List executors = webApp.getManagedExecutors(); + DDJakarta10Elements.verifySize(names, 1, executors); + DDJakarta10Elements.verify(names, executors.get(0)); + } + + @Test + public void testEE11ManagedScheduledExecutorWeb61() throws Exception { + WebApp webApp = parseWebApp( + webApp(WebApp.VERSION_6_1, DDJakarta11Elements.MANAGED_SCHEDULED_EXECUTOR_XML), + WebApp.VERSION_6_1); + + List names = DDJakarta10Elements.names("WebApp", "managedScheduledExecutors"); + + List executors = webApp.getManagedScheduledExecutors(); + DDJakarta10Elements.verifySize(names, 1, executors); + DDJakarta10Elements.verify(names, executors.get(0)); + } + + @Test + public void testEE11ManagedThreadFactoryWeb61() throws Exception { + WebApp webApp = parseWebApp( + webApp(WebApp.VERSION_6_1, DDJakarta11Elements.MANAGED_THREAD_FACTORY_XML), + WebApp.VERSION_6_1); + + List names = DDJakarta10Elements.names("WebApp", "managedThreadFactories"); + + List factories = webApp.getManagedThreadFactories(); + DDJakarta10Elements.verifySize(names, 1, factories); + DDJakarta10Elements.verify(names, factories.get(0)); + } + public static final String COOKIE_ATTRIBUTE_PREFIX = "\n" + "\n" + "CookieConfigName_viaWebXML\n" + diff --git a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/web/WebAppTestBase.java b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/web/WebAppTestBase.java index 0309e650465..8cd3cc26a81 100644 --- a/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/web/WebAppTestBase.java +++ b/dev/com.ibm.ws.javaee.ddmodel/test/com/ibm/ws/javaee/ddmodel/web/WebAppTestBase.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2013, 2022 IBM Corporation and others. + * Copyright (c) 2013, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -156,6 +156,15 @@ protected static String webApp60Head() { ">"; } + protected static String webApp61Head() { + return ""; + } + protected static String webAppTail() { return ""; } @@ -198,8 +207,9 @@ protected static String webApp(int version, String body) { } else if ( version == WebApp.VERSION_5_0 ) { head = webApp50Head(); } else if ( version == WebApp.VERSION_6_0 ) { - head = webApp60Head(); - + head = webApp60Head(); + } else if ( version == WebApp.VERSION_6_1 ) { + head = webApp61Head(); } else { throw new IllegalArgumentException("Unexpected WebVersion [ " + version + " ]"); } diff --git a/dev/io.openliberty.concurrent.internal/bnd.bnd b/dev/io.openliberty.concurrent.internal/bnd.bnd index e408459330f..79dada82692 100644 --- a/dev/io.openliberty.concurrent.internal/bnd.bnd +++ b/dev/io.openliberty.concurrent.internal/bnd.bnd @@ -1,5 +1,5 @@ #******************************************************************************* -# Copyright (c) 2021, 2022 IBM Corporation and others. +# Copyright (c) 2021, 2023 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at @@ -67,4 +67,4 @@ instrument.classesExcludes: io/openliberty/concurrent/internal/resources/*.class com.ibm.ws.logging.core;version=latest,\ com.ibm.ws.resource;version=latest,\ com.ibm.ws.org.osgi.annotation.versioning;version=latest,\ - io.openliberty.jakarta.concurrency.3.0;version=latest \ No newline at end of file + io.openliberty.jakarta.concurrency.3.1;version=latest \ No newline at end of file diff --git a/dev/io.openliberty.concurrent.internal/resources/io/openliberty/concurrent/internal/resources/CWWKCMessages.nlsprops b/dev/io.openliberty.concurrent.internal/resources/io/openliberty/concurrent/internal/resources/CWWKCMessages.nlsprops index e7d6e080b53..47013bb4a42 100644 --- a/dev/io.openliberty.concurrent.internal/resources/io/openliberty/concurrent/internal/resources/CWWKCMessages.nlsprops +++ b/dev/io.openliberty.concurrent.internal/resources/io/openliberty/concurrent/internal/resources/CWWKCMessages.nlsprops @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2022,2023 IBM Corporation and others. +# Copyright (c) 2022, 2023 IBM Corporation and others. # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License 2.0 # which accompanies this distribution, and is available at @@ -46,7 +46,9 @@ CWWKC1204.not.serializable=CWWKC1204E: Cannot create a serializable contextual p CWWKC1204.not.serializable.explanation=Third-party thread context types are not compatible with serialization and cannot be configured to be propagated for serializable contextual proxies. CWWKC1204.not.serializable.useraction=Update the application to request a non-serializable contextual proxy or ensure that no third-party context types are configured to be propagated. - +CWWKC1205.qualifier.class.not.found=CWWKC1205E: The {0} qualifier annotation class, which is defined by a deployment descriptor, could not be loaded by the application classloader. +CWWKC1205.qualifier.class.not.found.explanation=Qualifier elements that are configured by the application.xml file or the web.xml file contain a class name that could not be loaded. +CWWKC1205.qualifier.class.not.found.useraction=Verify that the qualifier elements are configured with a fully qualified class name, and that the class is present within the application. # Messages for @Asynchronous that are shared with other bundles: diff --git a/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ContextServiceDefinitionBinding.java b/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ContextServiceDefinitionBinding.java index d786a2c53db..2c2f552c766 100644 --- a/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ContextServiceDefinitionBinding.java +++ b/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ContextServiceDefinitionBinding.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2021,2022 IBM Corporation and others. + * Copyright (c) 2021, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -45,9 +45,12 @@ public class ContextServiceDefinitionBinding extends InjectionBinding[] DEFAULT_QUALIFIERS = new Class[] {}; private String[] cleared; private boolean XMLcleared; @@ -58,12 +61,15 @@ public class ContextServiceDefinitionBinding extends InjectionBinding properties; - private final Set XMLProperties = new HashSet(); - private String[] unchanged; private boolean XMLunchanged; + private Class[] qualifiers; + private boolean XMLqualifers; + + private Map properties; + private final Set XMLProperties = new HashSet(); + public ContextServiceDefinitionBinding(String jndiName, ComponentNameSpaceConfiguration nameSpaceConfig) { super(null, nameSpaceConfig); setJndiName(jndiName); @@ -86,7 +92,8 @@ public void merge(ContextServiceDefinition annotation, Class instanceClass, M Tr.entry(this, tc, "merge", toString(annotation), instanceClass, member, (XMLcleared ? " (xml)" : " ") + "cleared: " + toString(cleared) + " << " + toString(annotation.cleared()), (XMLpropagated ? "(xml)" : " ") + "propagated: " + toString(propagated) + " << " + toString(annotation.propagated()), - (XMLunchanged ? " (xml)" : " ") + "unchanged: " + toString(unchanged) + " << " + toString(annotation.unchanged())); + (XMLunchanged ? " (xml)" : " ") + "unchanged: " + toString(unchanged) + " << " + toString(annotation.unchanged()), + (XMLqualifers ? " (xml)" : " ") + "qualifiers: " + toString(qualifiers) + " << " + toString(annotation.qualifiers())); if (member != null) { // ContextServiceDefinition is a class-level annotation only. @@ -101,15 +108,18 @@ public void merge(ContextServiceDefinition annotation, Class instanceClass, M propagated = mergeAnnotationValue(propagated == DEFAULT_PROPAGATED ? null : propagated, XMLpropagated, annotation.propagated(), KEY_PROPAGATED, DEFAULT_PROPAGATED); - properties = mergeAnnotationProperties(properties, XMLProperties, new String[] {}); // ContextServiceDefinition has no properties attribute + unchanged = mergeAnnotationValue(unchanged, XMLunchanged, annotation.unchanged(), KEY_UNCHANGED, DEFAULT_UNCHANGED); - unchanged = mergeAnnotationValue(unchanged, XMLunchanged, annotation.unchanged(), KEY_UNCHANGED, new String[0]); + qualifiers = mergeAnnotationValue(qualifiers, XMLqualifers, annotation.qualifiers(), KEY_QUALIFIERS, DEFAULT_QUALIFIERS); + + properties = mergeAnnotationProperties(properties, XMLProperties, new String[] {}); // ContextServiceDefinition has no properties attribute if (trace) Tr.exit(this, tc, "merge", new String[] { (XMLcleared ? " (xml)" : " ") + "cleared= " + toString(cleared), (XMLpropagated ? "(xml)" : " ") + "propagated= " + toString(propagated), - (XMLunchanged ? " (xml)" : " ") + "unchanged= " + toString(unchanged) + (XMLunchanged ? " (xml)" : " ") + "unchanged= " + toString(unchanged), + (XMLqualifers ? " (xml)" : " ") + "qualifiers= " + toString(qualifiers) }); } @@ -119,7 +129,8 @@ void mergeXML(ContextService csd) throws InjectionConfigurationException { Tr.entry(this, tc, "mergeXML", csd, csd.getName(), (XMLcleared ? " (xml)" : " ") + "cleared: " + toString(cleared) + " << " + toString(csd.getCleared()), (XMLpropagated ? "(xml)" : " ") + "propagated: " + toString(propagated) + " << " + toString(csd.getPropagated()), - (XMLunchanged ? " (xml)" : " ") + "unchanged: " + toString(unchanged) + " << " + toString(csd.getUnchanged())); + (XMLunchanged ? " (xml)" : " ") + "unchanged: " + toString(unchanged) + " << " + toString(csd.getUnchanged()), + (XMLqualifers ? " (xml)" : " ") + "qualifiers: " + toString(qualifiers) + " << " + toString(csd.getQualifiers())); List descriptionList = csd.getDescriptions(); @@ -146,20 +157,33 @@ void mergeXML(ContextService csd) throws InjectionConfigurationException { XMLpropagated = true; } - List csdProps = csd.getProperties(); - properties = mergeXMLProperties(properties, XMLProperties, csdProps); - String[] unchangedValues = csd.getUnchanged(); if (unchangedValues != null && unchangedValues.length > 0) { unchanged = mergeXMLValue(unchanged, unchangedValues, "unchanged", KEY_UNCHANGED, null); XMLunchanged |= true; } + String[] qualifierValues = csd.getQualifiers(); + if (qualifierValues == null || qualifierValues.length == 0) { + if (qualifiers == null) + qualifiers = DEFAULT_QUALIFIERS; + } else if (qualifierValues.length == 1 && qualifierValues[0].isEmpty()) { + qualifiers = DEFAULT_QUALIFIERS; + XMLqualifers = true; + } else { + qualifiers = mergeXMLValue(qualifiers, toQualifierClassArray(qualifierValues), "qualifier", KEY_QUALIFIERS, null); + XMLqualifers = true; + } + + List csdProps = csd.getProperties(); + properties = mergeXMLProperties(properties, XMLProperties, csdProps); + if (trace) Tr.exit(this, tc, "mergeXML", new String[] { (XMLcleared ? " (xml)" : " ") + "cleared= " + toString(cleared), (XMLpropagated ? "(xml)" : " ") + "propagated= " + toString(propagated), - (XMLunchanged ? " (xml)" : " ") + "unchanged= " + toString(unchanged) + (XMLunchanged ? " (xml)" : " ") + "unchanged= " + toString(unchanged), + (XMLqualifers ? " (xml)" : " ") + "qualifiers= " + toString(qualifiers) }); } @@ -170,8 +194,10 @@ public void mergeSaved(InjectionBinding injectionBindi mergeSavedValue(cleared, contextServiceBinding.cleared, "cleared"); mergeSavedValue(description, contextServiceBinding.description, "description"); mergeSavedValue(propagated, contextServiceBinding.propagated, "propagated"); - mergeSavedValue(properties, contextServiceBinding.properties, "properties"); mergeSavedValue(unchanged, contextServiceBinding.unchanged, "unchanged"); + mergeSavedValue(qualifiers, contextServiceBinding.qualifiers, "qualifier"); + mergeSavedValue(properties, contextServiceBinding.properties, "properties"); + } void resolve() throws InjectionException { @@ -186,6 +212,7 @@ void resolve() throws InjectionException { addOrRemoveProperty(props, KEY_DESCRIPTION, description); addOrRemoveProperty(props, KEY_PROPAGATED, propagated); addOrRemoveProperty(props, KEY_UNCHANGED, unchanged); + addOrRemoveProperty(props, KEY_QUALIFIERS, qualifiers); setObjects(null, createDefinitionReference(null, jakarta.enterprise.concurrent.ContextService.class.getName(), props)); } @@ -198,17 +225,33 @@ static final String toString(ContextServiceDefinition anno) { .append(", cleared=").append(Arrays.toString(anno.cleared())) // .append(", propagated=").append(Arrays.toString(anno.propagated())) // .append(", unchanged=").append(Arrays.toString(anno.unchanged())) // + .append(", qualifiers=").append(Arrays.toString(anno.qualifiers())) // .append(")"); return b.toString(); } @Trivial - private static final String toString(String[] list) { + private static final String toString(T[] list) { if (list == null || list.length == 0) return "Unspecified"; boolean none = true; for (int i = 0; none && i < list.length; i++) - none &= list[i] == null || list[i].length() == 0; + none &= list[i] == null || list[i].toString().isEmpty(); return none ? "None" : Arrays.toString(list); } + + @Trivial + private static final Class[] toQualifierClassArray(String[] classList) throws IllegalArgumentException { + Class[] clazzArray = new Class[classList.length]; + for (int i = 0; i < classList.length; i++) { + try { + //TODO is there a certain classloader I should be using to load this class? ApplicationClassLoader? + clazzArray[i] = Class.forName(classList[i]); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException(Tr.formatMessage(tc, "CWWKC1205.qualifier.class.not.found", classList[i]), e); + } + } + + return clazzArray; + } } diff --git a/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedExecutorDefinitionBinding.java b/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedExecutorDefinitionBinding.java index 3cbc90be5c7..b3199c468e6 100644 --- a/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedExecutorDefinitionBinding.java +++ b/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedExecutorDefinitionBinding.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2021,2022 IBM Corporation and others. + * Copyright (c) 2021, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -13,6 +13,7 @@ package io.openliberty.concurrent.internal.processor; import java.lang.reflect.Member; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -45,6 +46,11 @@ public class ManagedExecutorDefinitionBinding extends InjectionBinding[] DEFAULT_QUALIFIERS = new Class[] {}; private String contextServiceJndiName; private boolean XMLContextServiceRef; @@ -58,6 +64,12 @@ public class ManagedExecutorDefinitionBinding extends InjectionBinding[] qualifiers; + private boolean XMLqualifers; + private Map properties; private final Set XMLProperties = new HashSet(); @@ -83,7 +95,9 @@ public void merge(ManagedExecutorDefinition annotation, Class instanceClass, Tr.entry(this, tc, "merge", toString(annotation), instanceClass, member, (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef: " + contextServiceJndiName + " << " + annotation.context(), (XMLHungTaskThreshold ? "(xml)" : " ") + "hungTaskThreshold: " + hungTaskThreshold + " << " + annotation.hungTaskThreshold(), - (XMLMaxAsync ? " (xml)" : " ") + "maxAsync: " + maxAsync + " << " + annotation.maxAsync()); + (XMLMaxAsync ? " (xml)" : " ") + "maxAsync: " + maxAsync + " << " + annotation.maxAsync(), + (XMLvirtual ? " (xml)" : " ") + "virtual: " + virtual + " << " + annotation.virtual(), + (XMLqualifers ? " (xml)" : " ") + "qualifiers: " + toString(qualifiers) + " << " + toString(annotation.qualifiers())); if (member != null) { // ManagedExecutorDefinition is a class-level annotation only. @@ -94,13 +108,17 @@ public void merge(ManagedExecutorDefinition annotation, Class instanceClass, description = mergeAnnotationValue(description, XMLDescription, "", KEY_DESCRIPTION, ""); // ManagedExecutorDefinition has no description attribute hungTaskThreshold = mergeAnnotationValue(hungTaskThreshold, XMLHungTaskThreshold, annotation.hungTaskThreshold(), KEY_HUNG_TASK_THRESHOLD, -1L); maxAsync = mergeAnnotationValue(maxAsync, XMLMaxAsync, annotation.maxAsync(), KEY_MAX_ASYNC, -1); + virtual = mergeAnnotationBoolean(virtual, XMLvirtual, annotation.virtual(), KEY_VIRTUAL, DEFAULT_VIRTUAL); + qualifiers = mergeAnnotationValue(qualifiers, XMLqualifers, annotation.qualifiers(), KEY_QUALIFIERS, DEFAULT_QUALIFIERS); properties = mergeAnnotationProperties(properties, XMLProperties, new String[] {}); // ManagedExecutorDefinition has no properties attribute if (trace) Tr.exit(this, tc, "merge", new String[] { (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef= " + contextServiceJndiName, (XMLHungTaskThreshold ? "(xml)" : " ") + "hungTaskThreshold= " + hungTaskThreshold, - (XMLMaxAsync ? " (xml)" : " ") + "maxAsync= " + maxAsync + (XMLMaxAsync ? " (xml)" : " ") + "maxAsync= " + maxAsync, + (XMLvirtual ? " (xml)" : " ") + "virtual= " + virtual, + (XMLqualifers ? " (xml)" : " ") + "qualifiers= " + toString(qualifiers) }); } @@ -110,7 +128,9 @@ void mergeXML(ManagedExecutor mxd) throws InjectionConfigurationException { Tr.entry(this, tc, "mergeXML", mxd, mxd.getName(), (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef: " + contextServiceJndiName + " << " + mxd.getContextServiceRef(), (XMLHungTaskThreshold ? "(xml)" : " ") + "hungTaskThreshold: " + hungTaskThreshold + " << " + mxd.getHungTaskThreshold(), - (XMLMaxAsync ? " (xml)" : " ") + "maxAsync: " + maxAsync + " << " + mxd.getMaxAsync()); + (XMLMaxAsync ? " (xml)" : " ") + "maxAsync: " + maxAsync + " << " + mxd.getMaxAsync(), + (XMLvirtual ? " (xml)" : " ") + "virtual: " + virtual + " << " + mxd.isVirtual(), + (XMLqualifers ? " (xml)" : " ") + "qualifiers: " + toString(qualifiers) + " << " + toString(mxd.getQualifiers())); List descriptionList = mxd.getDescriptions(); @@ -135,6 +155,23 @@ void mergeXML(ManagedExecutor mxd) throws InjectionConfigurationException { XMLMaxAsync = true; } + if (mxd.isSetVirtual()) { + virtual = mergeXMLValue(virtual, mxd.isVirtual(), "virtual", KEY_VIRTUAL, null); + XMLvirtual = true; + } + + String[] qualifierValues = mxd.getQualifiers(); + if (qualifierValues == null || qualifierValues.length == 0) { + if (qualifiers == null) + qualifiers = DEFAULT_QUALIFIERS; + } else if (qualifierValues.length == 1 && qualifierValues[0].isEmpty()) { + qualifiers = DEFAULT_QUALIFIERS; + XMLqualifers = true; + } else { + qualifiers = mergeXMLValue(qualifiers, toQualifierClassArray(qualifierValues), "qualifier", KEY_QUALIFIERS, null); + XMLqualifers = true; + } + List mxdProps = mxd.getProperties(); properties = mergeXMLProperties(properties, XMLProperties, mxdProps); @@ -142,7 +179,9 @@ void mergeXML(ManagedExecutor mxd) throws InjectionConfigurationException { Tr.exit(this, tc, "mergeXML", new String[] { (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef= " + contextServiceJndiName, (XMLHungTaskThreshold ? "(xml)" : " ") + "hungTaskThreshold= " + hungTaskThreshold, - (XMLMaxAsync ? " (xml)" : " ") + "maxAsync= " + maxAsync + (XMLMaxAsync ? " (xml)" : " ") + "maxAsync= " + maxAsync, + (XMLvirtual ? " (xml)" : " ") + "virtual= " + virtual, + (XMLqualifers ? " (xml)" : " ") + "qualifiers= " + toString(qualifiers) }); } @@ -154,6 +193,8 @@ public void mergeSaved(InjectionBinding injectionBind mergeSavedValue(description, managedExecutorBinding.description, "description"); mergeSavedValue(hungTaskThreshold, managedExecutorBinding.hungTaskThreshold, "hung-task-threshold"); mergeSavedValue(maxAsync, managedExecutorBinding.maxAsync, "max-async"); + mergeSavedValue(virtual, managedExecutorBinding.virtual, "virtual"); + mergeSavedValue(qualifiers, managedExecutorBinding.qualifiers, "qualifier"); mergeSavedValue(properties, managedExecutorBinding.properties, "properties"); } @@ -169,6 +210,8 @@ void resolve() throws InjectionException { addOrRemoveProperty(props, KEY_DESCRIPTION, description); addOrRemoveProperty(props, KEY_HUNG_TASK_THRESHOLD, hungTaskThreshold); addOrRemoveProperty(props, KEY_MAX_ASYNC, maxAsync); + addOrRemoveProperty(props, KEY_VIRTUAL, virtual); + addOrRemoveProperty(props, KEY_QUALIFIERS, qualifiers); setObjects(null, createDefinitionReference(null, ManagedExecutorService.class.getName(), props)); } @@ -181,7 +224,34 @@ static final String toString(ManagedExecutorDefinition anno) { .append(", context=").append(anno.context()) // .append(", hungTaskThreshold=").append(anno.hungTaskThreshold()) // .append(", maxAsync=").append(anno.maxAsync()) // + .append(", virtual=").append(anno.virtual()) // + .append(", qualifiers=").append(Arrays.toString(anno.qualifiers())) // .append(")"); return b.toString(); } + + @Trivial + private static final String toString(T[] list) { + if (list == null || list.length == 0) + return "Unspecified"; + boolean none = true; + for (int i = 0; none && i < list.length; i++) + none &= list[i] == null || list[i].toString().isEmpty(); + return none ? "None" : Arrays.toString(list); + } + + @Trivial + private static final Class[] toQualifierClassArray(String[] classList) throws IllegalArgumentException { + Class[] clazzArray = new Class[classList.length]; + for (int i = 0; i < classList.length; i++) { + try { + //TODO is there a certain classloader I should be using to load this class? ApplicationClassLoader? + clazzArray[i] = Class.forName(classList[i]); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException(Tr.formatMessage(tc, "CWWKC1205.qualifier.class.not.found", classList[i]), e); + } + } + + return clazzArray; + } } diff --git a/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedScheduledExecutorDefinitionBinding.java b/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedScheduledExecutorDefinitionBinding.java index 5c693f7f6f0..4280023d10a 100644 --- a/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedScheduledExecutorDefinitionBinding.java +++ b/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedScheduledExecutorDefinitionBinding.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2021,2022 IBM Corporation and others. + * Copyright (c) 2021, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -13,6 +13,7 @@ package io.openliberty.concurrent.internal.processor; import java.lang.reflect.Member; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -45,6 +46,11 @@ public class ManagedScheduledExecutorDefinitionBinding extends InjectionBinding< private static final String KEY_DESCRIPTION = "description"; private static final String KEY_HUNG_TASK_THRESHOLD = "hungTaskThreshold"; private static final String KEY_MAX_ASYNC = "maxAsync"; + private static final String KEY_VIRTUAL = "virtual"; + private static final String KEY_QUALIFIERS = "qualifiers"; + + private static final boolean DEFAULT_VIRTUAL = false; + private static final Class[] DEFAULT_QUALIFIERS = new Class[] {}; private String contextServiceJndiName; private boolean XMLContextServiceRef; @@ -58,6 +64,12 @@ public class ManagedScheduledExecutorDefinitionBinding extends InjectionBinding< private Integer maxAsync; private boolean XMLMaxAsync; + private boolean virtual; + private boolean XMLvirtual; + + private Class[] qualifiers; + private boolean XMLqualifers; + private Map properties; private final Set XMLProperties = new HashSet(); @@ -83,7 +95,9 @@ public void merge(ManagedScheduledExecutorDefinition annotation, Class instan Tr.entry(this, tc, "merge", toString(annotation), instanceClass, member, (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef: " + contextServiceJndiName + " << " + annotation.context(), (XMLHungTaskThreshold ? "(xml)" : " ") + "hungTaskThreshold: " + hungTaskThreshold + " << " + annotation.hungTaskThreshold(), - (XMLMaxAsync ? " (xml)" : " ") + "maxAsync: " + maxAsync + " << " + annotation.maxAsync()); + (XMLMaxAsync ? " (xml)" : " ") + "maxAsync: " + maxAsync + " << " + annotation.maxAsync(), + (XMLvirtual ? " (xml)" : " ") + "virtual: " + virtual + " << " + annotation.virtual(), + (XMLqualifers ? " (xml)" : " ") + "qualifiers: " + toString(qualifiers) + " << " + toString(annotation.qualifiers())); if (member != null) { // ManagedScheduledExecutorDefinition is a class-level annotation only. @@ -94,13 +108,17 @@ public void merge(ManagedScheduledExecutorDefinition annotation, Class instan description = mergeAnnotationValue(description, XMLDescription, "", KEY_DESCRIPTION, ""); // ManagedScheduledExecutorDefinition has no description attribute hungTaskThreshold = mergeAnnotationValue(hungTaskThreshold, XMLHungTaskThreshold, annotation.hungTaskThreshold(), KEY_HUNG_TASK_THRESHOLD, -1L); maxAsync = mergeAnnotationValue(maxAsync, XMLMaxAsync, annotation.maxAsync(), KEY_MAX_ASYNC, -1); + virtual = mergeAnnotationBoolean(virtual, XMLvirtual, annotation.virtual(), KEY_VIRTUAL, DEFAULT_VIRTUAL); + qualifiers = mergeAnnotationValue(qualifiers, XMLqualifers, annotation.qualifiers(), KEY_QUALIFIERS, DEFAULT_QUALIFIERS); properties = mergeAnnotationProperties(properties, XMLProperties, new String[] {}); // ManagedScheduledExecutorDefinition has no properties attribute if (trace) Tr.exit(this, tc, "merge", new String[] { (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef= " + contextServiceJndiName, (XMLHungTaskThreshold ? "(xml)" : " ") + "hungTaskThreshold= " + hungTaskThreshold, - (XMLMaxAsync ? " (xml)" : " ") + "maxAsync= " + maxAsync + (XMLMaxAsync ? " (xml)" : " ") + "maxAsync= " + maxAsync, + (XMLvirtual ? " (xml)" : " ") + "virtual= " + virtual, + (XMLqualifers ? " (xml)" : " ") + "qualifiers= " + toString(qualifiers) }); } @@ -110,7 +128,9 @@ void mergeXML(ManagedScheduledExecutor mxd) throws InjectionConfigurationExcepti Tr.entry(this, tc, "mergeXML", mxd, mxd.getName(), (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef: " + contextServiceJndiName + " << " + mxd.getContextServiceRef(), (XMLHungTaskThreshold ? "(xml)" : " ") + "hungTaskThreshold: " + hungTaskThreshold + " << " + mxd.getHungTaskThreshold(), - (XMLMaxAsync ? " (xml)" : " ") + "maxAsync: " + maxAsync + " << " + mxd.getMaxAsync()); + (XMLMaxAsync ? " (xml)" : " ") + "maxAsync: " + maxAsync + " << " + mxd.getMaxAsync(), + (XMLvirtual ? " (xml)" : " ") + "virtual: " + virtual + " << " + mxd.isVirtual(), + (XMLqualifers ? " (xml)" : " ") + "qualifiers: " + toString(qualifiers) + " << " + toString(mxd.getQualifiers())); List descriptionList = mxd.getDescriptions(); @@ -135,6 +155,23 @@ void mergeXML(ManagedScheduledExecutor mxd) throws InjectionConfigurationExcepti XMLMaxAsync = true; } + if (mxd.isSetVirtual()) { + virtual = mergeXMLValue(virtual, mxd.isVirtual(), "virtual", KEY_VIRTUAL, null); + XMLvirtual = true; + } + + String[] qualifierValues = mxd.getQualifiers(); + if (qualifierValues == null || qualifierValues.length == 0) { + if (qualifiers == null) + qualifiers = DEFAULT_QUALIFIERS; + } else if (qualifierValues.length == 1 && qualifierValues[0].isEmpty()) { + qualifiers = DEFAULT_QUALIFIERS; + XMLqualifers = true; + } else { + qualifiers = mergeXMLValue(qualifiers, toQualifierClassArray(qualifierValues), "qualifier", KEY_QUALIFIERS, null); + XMLqualifers = true; + } + List mxdProps = mxd.getProperties(); properties = mergeXMLProperties(properties, XMLProperties, mxdProps); @@ -142,7 +179,9 @@ void mergeXML(ManagedScheduledExecutor mxd) throws InjectionConfigurationExcepti Tr.exit(this, tc, "mergeXML", new String[] { (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef= " + contextServiceJndiName, (XMLHungTaskThreshold ? "(xml)" : " ") + "hungTaskThreshold= " + hungTaskThreshold, - (XMLMaxAsync ? " (xml)" : " ") + "maxAsync= " + maxAsync + (XMLMaxAsync ? " (xml)" : " ") + "maxAsync= " + maxAsync, + (XMLvirtual ? " (xml)" : " ") + "virtual= " + virtual, + (XMLqualifers ? " (xml)" : " ") + "qualifiers= " + toString(qualifiers) }); } @@ -154,6 +193,8 @@ public void mergeSaved(InjectionBinding inje mergeSavedValue(description, managedScheduledExecutorBinding.description, "description"); mergeSavedValue(hungTaskThreshold, managedScheduledExecutorBinding.hungTaskThreshold, "hung-task-threshold"); mergeSavedValue(maxAsync, managedScheduledExecutorBinding.maxAsync, "max-async"); + mergeSavedValue(virtual, managedScheduledExecutorBinding.virtual, "virtual"); + mergeSavedValue(qualifiers, managedScheduledExecutorBinding.qualifiers, "qualifier"); mergeSavedValue(properties, managedScheduledExecutorBinding.properties, "properties"); } @@ -169,6 +210,8 @@ void resolve() throws InjectionException { addOrRemoveProperty(props, KEY_DESCRIPTION, description); addOrRemoveProperty(props, KEY_HUNG_TASK_THRESHOLD, hungTaskThreshold); addOrRemoveProperty(props, KEY_MAX_ASYNC, maxAsync); + addOrRemoveProperty(props, KEY_VIRTUAL, virtual); + addOrRemoveProperty(props, KEY_QUALIFIERS, qualifiers); setObjects(null, createDefinitionReference(null, ManagedScheduledExecutorService.class.getName(), props)); } @@ -181,7 +224,34 @@ static final String toString(ManagedScheduledExecutorDefinition anno) { .append(", context=").append(anno.context()) // .append(", hungTaskThreshold=").append(anno.hungTaskThreshold()) // .append(", maxAsync=").append(anno.maxAsync()) // + .append(", virtual=").append(anno.virtual()) // + .append(", qualifiers=").append(Arrays.toString(anno.qualifiers())) // .append(")"); return b.toString(); } + + @Trivial + private static final String toString(T[] list) { + if (list == null || list.length == 0) + return "Unspecified"; + boolean none = true; + for (int i = 0; none && i < list.length; i++) + none &= list[i] == null || list[i].toString().isEmpty(); + return none ? "None" : Arrays.toString(list); + } + + @Trivial + private static final Class[] toQualifierClassArray(String[] classList) throws IllegalArgumentException { + Class[] clazzArray = new Class[classList.length]; + for (int i = 0; i < classList.length; i++) { + try { + //TODO is there a certain classloader I should be using to load this class? ApplicationClassLoader? + clazzArray[i] = Class.forName(classList[i]); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException(Tr.formatMessage(tc, "CWWKC1205.qualifier.class.not.found", classList[i]), e); + } + } + + return clazzArray; + } } diff --git a/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedThreadFactoryDefinitionBinding.java b/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedThreadFactoryDefinitionBinding.java index 4a7f1fa20e6..b9842a8a519 100644 --- a/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedThreadFactoryDefinitionBinding.java +++ b/dev/io.openliberty.concurrent.internal/src/io/openliberty/concurrent/internal/processor/ManagedThreadFactoryDefinitionBinding.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2021,2022 IBM Corporation and others. + * Copyright (c) 2021, 2023 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 * * Contributors: @@ -13,6 +13,7 @@ package io.openliberty.concurrent.internal.processor; import java.lang.reflect.Member; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -43,6 +44,11 @@ public class ManagedThreadFactoryDefinitionBinding extends InjectionBinding[] DEFAULT_QUALIFIERS = new Class[] {}; private String contextServiceJndiName; private boolean XMLContextServiceRef; @@ -53,6 +59,12 @@ public class ManagedThreadFactoryDefinitionBinding extends InjectionBinding[] qualifiers; + private boolean XMLqualifers; + private Map properties; private final Set XMLProperties = new HashSet(); @@ -77,7 +89,9 @@ public void merge(ManagedThreadFactoryDefinition annotation, Class instanceCl if (trace) Tr.entry(this, tc, "merge", toString(annotation), instanceClass, member, (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef: " + contextServiceJndiName + " << " + annotation.context(), - (XMLPriority ? " (xml)" : " ") + "priority: " + priority + " << " + annotation.priority()); + (XMLPriority ? " (xml)" : " ") + "priority: " + priority + " << " + annotation.priority(), + (XMLvirtual ? " (xml)" : " ") + "virtual: " + virtual + " << " + annotation.virtual(), + (XMLqualifers ? " (xml)" : " ") + "qualifiers: " + toString(qualifiers) + " << " + toString(annotation.qualifiers())); if (member != null) { // ManagedThreadFactoryDefinition is a class-level annotation only. @@ -87,12 +101,16 @@ public void merge(ManagedThreadFactoryDefinition annotation, Class instanceCl contextServiceJndiName = mergeAnnotationValue(contextServiceJndiName, XMLContextServiceRef, annotation.context(), KEY_CONTEXT, "java:comp/DefaultContextService"); description = mergeAnnotationValue(description, XMLDescription, "", KEY_DESCRIPTION, ""); // ManagedThreadFactoryDefinition has no description attribute priority = mergeAnnotationValue(priority, XMLPriority, annotation.priority(), KEY_PRIORITY, Thread.NORM_PRIORITY); + virtual = mergeAnnotationBoolean(virtual, XMLvirtual, annotation.virtual(), KEY_VIRTUAL, DEFAULT_VIRTUAL); + qualifiers = mergeAnnotationValue(qualifiers, XMLqualifers, annotation.qualifiers(), KEY_QUALIFIERS, DEFAULT_QUALIFIERS); properties = mergeAnnotationProperties(properties, XMLProperties, new String[] {}); // ManagedThreadFactoryDefinition has no properties attribute if (trace) Tr.exit(this, tc, "merge", new String[] { (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef= " + contextServiceJndiName, - (XMLPriority ? " (xml)" : " ") + "priority= " + priority + (XMLPriority ? " (xml)" : " ") + "priority= " + priority, + (XMLvirtual ? " (xml)" : " ") + "virtual= " + virtual, + (XMLqualifers ? " (xml)" : " ") + "qualifiers= " + toString(qualifiers) }); } @@ -101,7 +119,9 @@ void mergeXML(ManagedThreadFactory mtfd) throws InjectionConfigurationException if (trace) Tr.entry(this, tc, "mergeXML", mtfd, mtfd.getName(), (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef: " + contextServiceJndiName + " << " + mtfd.getContextServiceRef(), - (XMLPriority ? " (xml)" : " ") + "priority: " + priority + " << " + mtfd.getPriority()); + (XMLPriority ? " (xml)" : " ") + "priority: " + priority + " << " + mtfd.getPriority(), + (XMLvirtual ? " (xml)" : " ") + "virtual: " + virtual + " << " + mtfd.isVirtual(), + (XMLqualifers ? " (xml)" : " ") + "qualifiers: " + toString(qualifiers) + " << " + toString(mtfd.getQualifiers())); List descriptionList = mtfd.getDescriptions(); @@ -121,13 +141,32 @@ void mergeXML(ManagedThreadFactory mtfd) throws InjectionConfigurationException XMLPriority = true; } + if (mtfd.isSetVirtual()) { + virtual = mergeXMLValue(virtual, mtfd.isVirtual(), "virtual", KEY_VIRTUAL, null); + XMLvirtual = true; + } + + String[] qualifierValues = mtfd.getQualifiers(); + if (qualifierValues == null || qualifierValues.length == 0) { + if (qualifiers == null) + qualifiers = DEFAULT_QUALIFIERS; + } else if (qualifierValues.length == 1 && qualifierValues[0].isEmpty()) { + qualifiers = DEFAULT_QUALIFIERS; + XMLqualifers = true; + } else { + qualifiers = mergeXMLValue(qualifiers, toQualifierClassArray(qualifierValues), "qualifier", KEY_QUALIFIERS, null); + XMLqualifers = true; + } + List mxdProps = mtfd.getProperties(); properties = mergeXMLProperties(properties, XMLProperties, mxdProps); if (trace) Tr.exit(this, tc, "mergeXML", new String[] { (XMLContextServiceRef ? "(xml)" : " ") + "contextServiceRef= " + contextServiceJndiName, - (XMLPriority ? " (xml)" : " ") + "priority= " + priority + (XMLPriority ? " (xml)" : " ") + "priority= " + priority, + (XMLvirtual ? " (xml)" : " ") + "virtual= " + virtual, + (XMLqualifers ? " (xml)" : " ") + "qualifiers= " + toString(qualifiers) }); } @@ -138,6 +177,8 @@ public void mergeSaved(InjectionBinding injectio mergeSavedValue(contextServiceJndiName, managedThreadFactoryBinding.contextServiceJndiName, "context-service-ref"); mergeSavedValue(description, managedThreadFactoryBinding.description, "description"); mergeSavedValue(priority, managedThreadFactoryBinding.priority, "priority"); + mergeSavedValue(virtual, managedThreadFactoryBinding.virtual, "virtual"); + mergeSavedValue(qualifiers, managedThreadFactoryBinding.qualifiers, "qualifier"); mergeSavedValue(properties, managedThreadFactoryBinding.properties, "properties"); } @@ -152,6 +193,8 @@ void resolve() throws InjectionException { addOrRemoveProperty(props, KEY_CONTEXT, contextServiceJndiName); addOrRemoveProperty(props, KEY_DESCRIPTION, description); addOrRemoveProperty(props, KEY_PRIORITY, priority); + addOrRemoveProperty(props, KEY_VIRTUAL, virtual); + addOrRemoveProperty(props, KEY_QUALIFIERS, qualifiers); setObjects(null, createDefinitionReference(null, jakarta.enterprise.concurrent.ManagedThreadFactory.class.getName(), props)); } @@ -163,7 +206,34 @@ static final String toString(ManagedThreadFactoryDefinition anno) { .append("(name=").append(anno.name()) // .append(", context=").append(anno.context()) // .append(", priority=").append(anno.priority()) // + .append(", virtual=").append(anno.virtual()) // + .append(", qualifiers=").append(Arrays.toString(anno.qualifiers())) // .append(")"); return b.toString(); } + + @Trivial + private static final String toString(T[] list) { + if (list == null || list.length == 0) + return "Unspecified"; + boolean none = true; + for (int i = 0; none && i < list.length; i++) + none &= list[i] == null || list[i].toString().isEmpty(); + return none ? "None" : Arrays.toString(list); + } + + @Trivial + private static final Class[] toQualifierClassArray(String[] classList) throws IllegalArgumentException { + Class[] clazzArray = new Class[classList.length]; + for (int i = 0; i < classList.length; i++) { + try { + //TODO is there a certain classloader I should be using to load this class? ApplicationClassLoader? + clazzArray[i] = Class.forName(classList[i]); + } catch (ClassNotFoundException e) { + throw new IllegalArgumentException(Tr.formatMessage(tc, "CWWKC1205.qualifier.class.not.found", classList[i]), e); + } + } + + return clazzArray; + } }