From e0f6237f24b02a5dc09ca890d0478658cbe942e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Mon, 24 Jan 2022 13:47:09 +0100 Subject: [PATCH] Experimental commit. --- Jenkinsfile | 292 ++++++++++++------ .../com/sun/appserv/ejb/.gitkeep_empty_dir | 0 .../src/main/java/com/sun/ejb/EJBUtils.java | 50 +-- .../codegen/AsmSerializableBeanGenerator.java | 28 +- .../sun/ejb/{ => codegen}/ClassGenerator.java | 6 +- .../ejb/codegen/EjbOptionalIntfGenerator.java | 1 - .../java/com/sun/ejb/codegen/Generator.java | 9 - .../java/com/sun/ejb/codegen/InvalidBean.java | 30 -- .../ejb/codegen/Remote30WrapperGenerator.java | 2 +- .../com/sun/ejb/codegen/RemoteGenerator.java | 6 +- .../com/sun/ejb/containers/BaseContainer.java | 180 ++++++----- .../com/sun/ejb/containers/EJBHomeImpl.java | 6 +- .../containers/EJBHomeInvocationHandler.java | 27 +- .../sun/ejb/containers/EJBLocalHomeImpl.java | 11 +- .../RemoteBusinessObjectFactory.java | 29 +- .../containers/RemoteBusinessWrapperBase.java | 37 +-- .../containers/StatefulSessionContainer.java | 170 ++++++---- .../containers/StatelessSessionContainer.java | 79 +++-- .../interceptors/InterceptorManager.java | 31 +- .../timer/PersistentEJBTimerService.java | 36 ++- .../entitybean/container/EntityContainer.java | 192 ++++++++---- appserver/tests/gftest.sh | 2 +- appserver/tests/quicklook/run_test.sh | 2 +- .../weld/services/ProxyServicesImpl.java | 2 +- etc/docker/Dockerfile | 2 +- gfbuild.sh | 6 +- .../admin/rest/generator/ASMClassWriter.java | 2 +- .../enterprise/loader/ASURLClassLoader.java | 80 +++-- .../internal/api/ClassLoaderHierarchy.java | 4 +- 29 files changed, 752 insertions(+), 570 deletions(-) delete mode 100644 appserver/ejb/ejb-container/src/main/java/com/sun/appserv/ejb/.gitkeep_empty_dir rename appserver/ejb/ejb-container/src/main/java/com/sun/ejb/{ => codegen}/ClassGenerator.java (93%) delete mode 100644 appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/InvalidBean.java diff --git a/Jenkinsfile b/Jenkinsfile index 285226b953c0..39f7c9f286b8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,18 +19,27 @@ // without this, the agent could be using a pod created from a different descriptor env.label = "glassfish-ci-pod-${UUID.randomUUID().toString()}" -// list of test ids -def jobs = [ +// Docker image defined in this project in [glassfish]/etc/docker/Dockerfile +env.gfImage = "ee4jglassfish/ci:tini-jdk-11.0.10" + +def jobs_cdi_jsp = [ "cdi_all", - "ql_gf_full_profile_all", - "ql_gf_web_profile_all", "web_jsp", +] + +def jobs_ejb = [ "ejb_group_1", "ejb_group_2", "ejb_group_3", "ejb_group_embedded" ] +def jobs_quick_look = [ + "verifyPhase", + "ql_gf_full_profile_all", + "ql_gf_web_profile_all", +] + def jobs_all = [ "cdi_all", @@ -56,111 +65,120 @@ def jobs_all = [ "connector_group_4" ] -def parallelStagesMap = jobs.collectEntries { - ["${it}": generateStage(it)] +def parallelStagesMap(jobs) { + return jobs.collectEntries { + ["${it}": generateStage(it)] + } } def generateStage(job) { - return { - podTemplate(label: env.label) { - node(label) { - stage("${job}") { - container('glassfish-ci') { - // do the scm checkout - retry(10) { - sleep 60 - checkout scm - } - - // run the test - unstash 'build-bundles' - - try { - retry(3) { - timeout(time: 2, unit: 'HOURS') { - sh """ - export CLASSPATH=$WORKSPACE/glassfish6/javadb - ./appserver/tests/gftest.sh run_test ${job} - """ - } - } - } finally { - // archive what we can... - archiveArtifacts artifacts: "${job}-results.tar.gz" - junit testResults: 'results/junitreports/*.xml', allowEmptyResults: false - } - } - } + if (job == 'verifyPhase') { + return generateMvnPodTemplate(job) + } else { + return generateAntPodTemplate(job) + } +} + +def generateMvnPodTemplate(job) { + return { + podTemplate( + inheritFrom: "${env.label}", + containers: [ + containerTemplate( + name: "glassfish-build", + image: "${env.gfImage}", + resourceRequestMemory: "7Gi", + resourceRequestCpu: "2650m" + ) + ] + ) { + node(label) { + stage("${job}") { + container('glassfish-build') { + retry(5) { + sleep 1 + checkout scm + } + timeout(time: 1, unit: 'HOURS') { + sh """ + mvn clean install + """ + junit testResults: '**/*-reports/*.xml', allowEmptyResults: false } + } } + } } + } } -pipeline { - - options { - // keep at most 50 builds - buildDiscarder(logRotator(numToKeepStr: '10')) - - // preserve the stashes to allow re-running a test stage - preserveStashes() - - // issue related to default 'implicit' checkout, disable it - skipDefaultCheckout() - - // abort pipeline if previous stage is unstable - skipStagesAfterUnstable() - - // show timestamps in logs - timestamps() - - // global timeout, abort after 6 hours - timeout(time: 6, unit: 'HOURS') +def generateAntPodTemplate(job) { + return { + podTemplate( + inheritFrom: "${env.label}", + containers: [ + containerTemplate( + name: "glassfish-build", + image: "${env.gfImage}", + resourceRequestMemory: "4Gi", + resourceRequestCpu: "2650m" + ) + ] + ) { + node(label) { + stage("${job}") { + container('glassfish-build') { + retry(5) { + sleep 1 + checkout scm + } + unstash 'build-bundles' + try { + timeout(time: 1, unit: 'HOURS') { + sh """ + export CLASSPATH=$WORKSPACE/glassfish6/javadb + ./appserver/tests/gftest.sh run_test ${job} + """ + } + } finally { + archiveArtifacts artifacts: "${job}-results.tar.gz" + junit testResults: 'results/junitreports/*.xml', allowEmptyResults: false + } + } + } + } + } } +} + +pipeline { agent { kubernetes { label "${env.label}" - defaultContainer 'glassfish-ci' yaml """ apiVersion: v1 kind: Pod metadata: spec: - volumes: - - name: "jenkins-home" - emptyDir: {} - - name: maven-repo-shared-storage - persistentVolumeClaim: - claimName: glassfish-maven-repo-storage - - name: settings-xml - secret: - secretName: m2-secret-dir - items: - - key: settings.xml - path: settings.xml - - name: settings-security-xml - secret: - secretName: m2-secret-dir - items: - - key: settings-security.xml - path: settings-security.xml - - name: maven-repo-local-storage - emptyDir: {} containers: - name: jnlp - image: jenkins/jnlp-slave:alpine + image: jenkins/inbound-agent:4.11-1-alpine-jdk11 imagePullPolicy: IfNotPresent env: - name: JAVA_TOOL_OPTIONS - value: -Xmx1G + value: "-Xmx768m -Xss768k" resources: + # fixes random failure: minimum cpu usage per Pod is 200m, but request is 100m. + # affects performance on large repositories limits: - memory: "1Gi" - cpu: "1" - - name: glassfish-ci - # Docker image defined in this project in [glassfish]/etc/docker/Dockerfile - image: ee4jglassfish/ci:tini-jdk-11.0.10 + memory: "1200Mi" + cpu: "300m" + requests: + memory: "1200Mi" + cpu: "300m" + - name: glassfish-build + image: ${env.gfImage} args: - cat tty: true @@ -183,13 +201,38 @@ spec: mountPath: "/home/jenkins/.m2/repository/org/glassfish/main" env: - name: "MAVEN_OPTS" - value: "-Duser.home=/home/jenkins" + value: "-Duser.home=/home/jenkins -Xmx2500m -Xss768k -XX:+UseStringDeduplication" - name: "MVN_EXTRA" value: "--batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn" + - name: JAVA_TOOL_OPTIONS + value: "-Xmx2g -Xss768k -XX:+UseStringDeduplication" resources: limits: + memory: "12Gi" + cpu: "8000m" + requests: memory: "7Gi" - cpu: "3" + cpu: "4000m" + volumes: + - name: "jenkins-home" + emptyDir: {} + - name: maven-repo-shared-storage + persistentVolumeClaim: + claimName: glassfish-maven-repo-storage + - name: settings-xml + secret: + secretName: m2-secret-dir + items: + - key: settings.xml + path: settings.xml + - name: settings-security-xml + secret: + secretName: m2-secret-dir + items: + - key: settings-security.xml + path: settings-security.xml + - name: maven-repo-local-storage + emptyDir: {} """ } } @@ -204,7 +247,52 @@ spec: PORT_HTTPS=8181 } + options { + buildDiscarder(logRotator(numToKeepStr: '10')) + + // to allow re-running a test stage + preserveStashes() + + // issue related to default 'implicit' checkout, disable it + skipDefaultCheckout() + + // abort pipeline if previous stage is unstable + skipStagesAfterUnstable() + + // show timestamps in logs + timestamps() + + // global timeout, abort after 6 hours + timeout(time: 6, unit: 'HOURS') + } + stages { + +// stage('quickinfo') { +// agent { +// kubernetes { +// label "${env.label}" +// } +// } +// steps { +// container('glassfish-build') { +// sh ''' +// echo Maven version +// mvn -v +// echo Ant version +// ant -version +// echo User +// id +// echo Uname +// uname -a +// free -m +// df -h +// cat /proc/cpuinfo +// ''' +// } +// } +// } + stage('build') { agent { kubernetes { @@ -212,13 +300,9 @@ spec: } } steps { - container('glassfish-ci') { + container('glassfish-build') { timeout(time: 1, unit: 'HOURS') { - - // do the scm checkout checkout scm - - // do the build sh ''' echo Maven version mvn -v @@ -229,24 +313,38 @@ spec: echo Uname uname -a - bash -xe ./gfbuild.sh build_re_dev + # Until we fix ANTLR in cmp-support-sqlstore, broken in parallel builds. Just -Pfast after the fix. + mvn clean install -Pfastest,staging -T4C + ./gfbuild.sh archive_bundles + ls -la ./bundles ''' archiveArtifacts artifacts: 'bundles/*.zip' - // junit testResults: 'test-results/build-unit-tests/results/junitreports/test_results_junit.xml' stash includes: 'bundles/*', name: 'build-bundles' } } } } - stage('tests') { + stage('QuickLookTests') { + steps { + script { + parallel parallelStagesMap(jobs_quick_look) + } + } + } + stage('CDI_JSP_Tests') { steps { script { - parallel parallelStagesMap + parallel parallelStagesMap(jobs_cdi_jsp) + } + } + } + stage('EjbTests') { + steps { + script { + parallel parallelStagesMap(jobs_ejb) } } } } } - - diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/appserv/ejb/.gitkeep_empty_dir b/appserver/ejb/ejb-container/src/main/java/com/sun/appserv/ejb/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/EJBUtils.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/EJBUtils.java index 52c6ad56b3ae..b818c7eee17d 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/EJBUtils.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/EJBUtils.java @@ -443,25 +443,22 @@ private static ClassLoader getBusinessIntfClassLoader(String businessInterface) return java.security.AccessController.doPrivileged(action); } - public static void serializeObjectFields( - Object instance, - ObjectOutputStream oos) - throws IOException { + // warning: accessed by reflection (AsmSerializableBeanGenerator) + public static void serializeObjectFields(Object instance, ObjectOutputStream oos) throws IOException { serializeObjectFields(instance, oos, true); } - public static void serializeObjectFields( - Object instance, - ObjectOutputStream oos, - boolean usesSuperClass) + + // warning: accessed by reflection (AsmSerializableBeanGenerator) + public static void serializeObjectFields(Object instance, ObjectOutputStream oos, boolean usesSuperClass) throws IOException { Class clazz = (usesSuperClass)? instance.getClass().getSuperclass() : instance.getClass(); final ObjectOutputStream objOutStream = oos; // Write out list of fields eligible for serialization in sorted order. - for(Field next : getSerializationFields(clazz)) { + for (Field next : getSerializationFields(clazz)) { final Field nextField = next; final Object theInstance = instance; @@ -489,41 +486,26 @@ public java.lang.Object run() throws Exception { } objOutStream.writeObject(value); - } catch(Throwable t) { - if( _logger.isLoggable(FINE) ) { - _logger.log(FINE, "=====> failed serializing field: " + nextField + - " =====> of class: " + clazz + " =====> using: " + oos.getClass() + - " =====> serializing value of type: " + ((value == null)? null : value.getClass().getName()) + - " ===> Error: " + t); - _logger.log(FINE, "", t); + } catch (Throwable t) { + if (_logger.isLoggable(FINE)) { + _logger.log(FINE, + "Failed serializing field: " + nextField + " of " + clazz + + " using: " + oos.getClass() + " serializing value of type: " + + (value == null ? null : value.getClass().getName()) + ", cause: " + t); } - IOException ioe = new IOException(); - Throwable cause = (t instanceof InvocationTargetException) ? - ((InvocationTargetException)t).getCause() : t; - ioe.initCause( cause ); - throw ioe; + throw new IOException(t instanceof InvocationTargetException ? t.getCause() : t); } } } // note: accessed by reflection! - public static void deserializeObjectFields( - Object instance, - ObjectInputStream ois) - throws IOException { - + public static void deserializeObjectFields(Object instance, ObjectInputStream ois) throws IOException { deserializeObjectFields(instance, ois, null, true); - } // note: accessed by reflection! - public static void deserializeObjectFields( - Object instance, - ObjectInputStream ois, - Object replaceValue, - boolean usesSuperClass) - throws IOException { - + public static void deserializeObjectFields(Object instance, ObjectInputStream ois, Object replaceValue, + boolean usesSuperClass) throws IOException { Class clazz = (usesSuperClass)? instance.getClass().getSuperclass() : instance.getClass(); if( _logger.isLoggable(FINE) ) { _logger.log(FINE, "=====> Deserializing class: " + clazz); diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/AsmSerializableBeanGenerator.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/AsmSerializableBeanGenerator.java index beaa51db39fa..beaf6d93665d 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/AsmSerializableBeanGenerator.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/AsmSerializableBeanGenerator.java @@ -17,8 +17,6 @@ package com.sun.ejb.codegen; -import com.sun.ejb.ClassGenerator; - import java.io.Serializable; import java.lang.reflect.Constructor; import java.security.AccessController; @@ -40,11 +38,9 @@ public class AsmSerializableBeanGenerator { private static final int INTF_FLAGS = ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES; - private final Class baseClass; - private final String subclassName; private final ClassLoader loader; - - private Class loadedClass; + private final Class baseClass; + private final String subclassName; /** @@ -70,9 +66,8 @@ public String getSerializableSubclassName() { return subclassName; } - public Class generateSerializableSubclass() - throws Exception { + public Class generateSerializableSubclass() throws Exception { ClassWriter cw = new ClassWriter(INTF_FLAGS); //ClassVisitor tv = //(_debug) @@ -93,9 +88,9 @@ public Class generateSerializableSubclass() // JSR 299 added requirements that allow a single constructor to define // parameters injected by CDI. - Constructor[] ctors = baseClass.getConstructors(); - Constructor ctorWithParams = null; - for(Constructor ctor : ctors) { + Constructor[] ctors = baseClass.getConstructors(); + Constructor ctorWithParams = null; + for(Constructor ctor : ctors) { if(ctor.getParameterTypes().length == 0) { ctorWithParams = null; //exists the no-arg ctor, use it break; @@ -107,8 +102,8 @@ public Class generateSerializableSubclass() int numArgsToPass = 1; // default is 1 to just handle 'this' String paramTypeString = "()V"; - if( ctorWithParams != null ) { - Class[] paramTypes = ctorWithParams.getParameterTypes(); + if (ctorWithParams != null) { + Class[] paramTypes = ctorWithParams.getParameterTypes(); numArgsToPass = paramTypes.length + 1; paramTypeString = Type.getConstructorDescriptor(ctorWithParams); } @@ -118,15 +113,14 @@ public Class generateSerializableSubclass() for(int i = 0; i < numArgsToPass; i++) { ctorv.visitVarInsn(ALOAD, i); } - - ctorv.visitMethodInsn(INVOKESPECIAL, Type.getType(baseClass).getInternalName(), "", paramTypeString); + ctorv.visitMethodInsn(INVOKESPECIAL, Type.getType(baseClass).getInternalName(), "", paramTypeString, false); ctorv.visitInsn(RETURN); ctorv.visitMaxs(numArgsToPass, numArgsToPass); MethodVisitor cv = cw.visitMethod(ACC_PRIVATE, "writeObject", "(Ljava/io/ObjectOutputStream;)V", null, new String[] { "java/io/IOException" }); cv.visitVarInsn(ALOAD, 0); cv.visitVarInsn(ALOAD, 1); - cv.visitMethodInsn(INVOKESTATIC, "com/sun/ejb/EJBUtils", "serializeObjectFields", "(Ljava/lang/Object;Ljava/io/ObjectOutputStream;)V"); + cv.visitMethodInsn(INVOKESTATIC, "com/sun/ejb/EJBUtils", "serializeObjectFields", "(Ljava/lang/Object;Ljava/io/ObjectOutputStream;)V", false); cv.visitInsn(RETURN); cv.visitMaxs(2, 2); @@ -134,7 +128,7 @@ public Class generateSerializableSubclass() cv = cw.visitMethod(ACC_PRIVATE, "readObject", "(Ljava/io/ObjectInputStream;)V", null, new String[] { "java/io/IOException", "java/lang/ClassNotFoundException" }); cv.visitVarInsn(ALOAD, 0); cv.visitVarInsn(ALOAD, 1); - cv.visitMethodInsn(INVOKESTATIC, "com/sun/ejb/EJBUtils", "deserializeObjectFields", "(Ljava/lang/Object;Ljava/io/ObjectInputStream;)V"); + cv.visitMethodInsn(INVOKESTATIC, "com/sun/ejb/EJBUtils", "deserializeObjectFields", "(Ljava/lang/Object;Ljava/io/ObjectInputStream;)V", false); cv.visitInsn(RETURN); cv.visitMaxs(2, 2); diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/ClassGenerator.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/ClassGenerator.java similarity index 93% rename from appserver/ejb/ejb-container/src/main/java/com/sun/ejb/ClassGenerator.java rename to appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/ClassGenerator.java index 025edeeccb8f..6c1c20193c4c 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/ClassGenerator.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/ClassGenerator.java @@ -14,18 +14,21 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.ejb; +package com.sun.ejb.codegen; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedExceptionAction; import java.security.ProtectionDomain; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @author David Matejcek */ public final class ClassGenerator { + private static final Logger LOG = Logger.getLogger(ClassGenerator.class.getName()); private static Method defineClassMethod; private static Method defineClassMethodSM; @@ -43,6 +46,7 @@ public final class ClassGenerator { }; AccessController.doPrivileged(action); } catch (final Exception e) { + LOG.log(Level.SEVERE, "Incompatible JDK!!!", e); throw new Error("Could not initialize access to ClassLoader.defineClass method.", e); } } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/EjbOptionalIntfGenerator.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/EjbOptionalIntfGenerator.java index 25e182223c3d..862a30d27d36 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/EjbOptionalIntfGenerator.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/EjbOptionalIntfGenerator.java @@ -17,7 +17,6 @@ package com.sun.ejb.codegen; -import com.sun.ejb.ClassGenerator; import com.sun.ejb.spi.container.OptionalLocalInterfaceProvider; import com.sun.enterprise.container.common.spi.util.IndirectlySerializable; import com.sun.enterprise.container.common.spi.util.SerializableObjectFactory; diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/Generator.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/Generator.java index a96940a2d861..eee719adec06 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/Generator.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/Generator.java @@ -17,7 +17,6 @@ package com.sun.ejb.codegen; -import com.sun.ejb.ClassGenerator; import com.sun.enterprise.loader.ASURLClassLoader; import java.io.ByteArrayOutputStream; @@ -138,14 +137,6 @@ public Class generate() throws IllegalAccessException { private boolean useMethodHandles() { // The bootstrap CL used by embedded glassfish doesn't remember generated classes // Further ClassLoader.findClass calls will fail. - System.out.println( - "loader: " + loader + "\n" - + "loader.parent: " + loader.getParent() + "\n" - + "system CL: " + ClassLoader.getSystemClassLoader() + "\n" - + "platform CL: " + ClassLoader.getPlatformClassLoader() - ); - - if (loader.getParent() == null || loader.getClass() == ASURLClassLoader.class) { return false; } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/InvalidBean.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/InvalidBean.java deleted file mode 100644 index 182514892662..000000000000 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/InvalidBean.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2022 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.ejb.codegen; - -public class InvalidBean extends GeneratorException { - - private static final long serialVersionUID = -4858134858891698917L; - - /** - * Constructs the InvalidBean exception with the specified string. - */ - public InvalidBean(String message) { - super(message); - } -} diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/Remote30WrapperGenerator.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/Remote30WrapperGenerator.java index c2c977d4302b..31d610648984 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/Remote30WrapperGenerator.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/Remote30WrapperGenerator.java @@ -91,7 +91,7 @@ public Remote30WrapperGenerator(final ClassLoader loader, final String businessI try { businessInterface = loader.loadClass(businessIntfName); } catch (final ClassNotFoundException ex) { - throw new InvalidBean(localStrings.getLocalString( + throw new GeneratorException(localStrings.getLocalString( "generator.remote_interface_not_found", "Business interface " + businessIntfName + " not found ")); } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/RemoteGenerator.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/RemoteGenerator.java index 5a65ff42a34b..1dc36e51b7f2 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/RemoteGenerator.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/codegen/RemoteGenerator.java @@ -69,14 +69,14 @@ public static String getGeneratedRemoteIntfName(String businessIntf) { * * @param classLoader * @param businessIntf - * @throws InvalidBean if the businessInterface doesn't exist. + * @throws GeneratorException if the businessInterface doesn't exist. */ - public RemoteGenerator(ClassLoader classLoader, String businessIntf) throws InvalidBean { + public RemoteGenerator(ClassLoader classLoader, String businessIntf) throws GeneratorException { super(classLoader); try { businessInterface = classLoader.loadClass(businessIntf); } catch (ClassNotFoundException ex) { - throw new InvalidBean( + throw new GeneratorException( localStrings.getLocalString("generator.remote_interface_not_found", "Remote interface not found ")); } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/BaseContainer.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/BaseContainer.java index 3ea8e5c48b9f..6a59e2a9729f 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/BaseContainer.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/BaseContainer.java @@ -152,7 +152,6 @@ * subclasses provide the remaining implementation of the container functionality. * */ - public abstract class BaseContainer implements Container, EjbContainerFacade, JavaEEContainer { public enum ContainerType { STATELESS, STATEFUL, SINGLETON, MESSAGE_DRIVEN, ENTITY, READ_ONLY @@ -195,9 +194,7 @@ public enum ContainerType { protected static final Class[] NO_PARAMS = new Class[] {}; - protected Object[] logParams = null; - - protected ContainerType containerType; + protected final ContainerInfo containerInfo; // constants for EJB(Local)Home/EJB(Local)Object methods, // used in authorizeRemoteMethod and authorizeLocalMethod @@ -230,19 +227,19 @@ public enum ContainerType { protected static final String SINGLETON_BEAN_POOL_PROP = "singleton-bean-pool"; protected final ClassLoader loader; - protected Class ejbClass = null; - protected Class sfsbSerializedClass = null; - protected Method ejbPassivateMethod = null; - protected Method ejbActivateMethod = null; - protected Method ejbRemoveMethod = null; - private Method ejbTimeoutMethod = null; + protected Class ejbClass; + protected Class sfsbSerializedClass; + protected Method ejbPassivateMethod; + protected Method ejbActivateMethod; + protected Method ejbRemoveMethod; + private Method ejbTimeoutMethod; - protected Class webServiceEndpointIntf = null; + protected Class webServiceEndpointIntf; // true if exposed as a web service endpoint. - protected boolean isWebServiceEndpoint = false; + protected boolean isWebServiceEndpoint; - private boolean isTimedObject_ = false; + private boolean isTimedObject_; /***************************************** * Data members for Local views * @@ -250,15 +247,15 @@ public enum ContainerType { // True if bean has a LocalHome/Local view // OR a Local business view OR both. - protected boolean isLocal = false; + protected boolean isLocal; // True if bean exposes a local home view - protected boolean hasLocalHomeView = false; + protected boolean hasLocalHomeView; // True if bean exposes a local business view - protected boolean hasLocalBusinessView = false; + protected boolean hasLocalBusinessView; - protected boolean hasOptionalLocalBusinessView = false; + protected boolean hasOptionalLocalBusinessView; protected Class ejbGeneratedOptionalLocalBusinessIntfClass; // @@ -266,10 +263,10 @@ public enum ContainerType { // // LocalHome interface written by developer - protected Class localHomeIntf = null; + protected Class localHomeIntf; // Local interface written by developer - private Class localIntf = null; + private Class localIntf; // Client reference to ejb local home protected EJBLocalHome ejbLocalHome; @@ -284,8 +281,8 @@ public enum ContainerType { // Internal interface describing operation used to create an // instance of a local business object. (GenericEJBLocalHome) - protected Class localBusinessHomeIntf = null; - protected Class ejbOptionalLocalBusinessHomeIntf = null; + protected Class localBusinessHomeIntf; + protected Class ejbOptionalLocalBusinessHomeIntf; // Local business interface written by developer protected Set localBusinessIntfs = new HashSet(); @@ -303,7 +300,7 @@ public enum ContainerType { // Implementation of internal local business home interface. protected EJBLocalHomeImpl ejbOptionalLocalBusinessHomeImpl; - private Collection interceptors = null; + private Collection interceptors; /***************************************** * Data members for Remote views * @@ -311,23 +308,23 @@ public enum ContainerType { // True if bean has a RemoteHome/Remote view // OR a Remote business view OR both. - protected boolean isRemote = false; + protected boolean isRemote; // True if bean exposes a RemoteHome view - protected boolean hasRemoteHomeView = false; + protected boolean hasRemoteHomeView; // True if bean exposes a Remote Business view. - protected boolean hasRemoteBusinessView = false; + protected boolean hasRemoteBusinessView; // // Data members for RemoteHome/Remote view // // Home interface written by developer. - protected Class homeIntf = null; + protected Class homeIntf; // Remote interface written by developer. - protected Class remoteIntf = null; + protected Class remoteIntf; // Container implementation of EJB Home. May or may not be the same // object as ejbHome, for example in the case of dynamic proxies. @@ -344,7 +341,7 @@ public enum ContainerType { private Class ejbObjectProxyClass; // RemoteReference Factory for RemoteHome view - protected RemoteReferenceFactory remoteHomeRefFactory = null; + protected RemoteReferenceFactory remoteHomeRefFactory; // // Data members for 3.x Remote business view @@ -376,7 +373,7 @@ public enum ContainerType { // END -- Data members for Remote views // - protected EJBMetaData metadata = null; + protected EJBMetaData metadata; protected final SecurityManager securityManager; @@ -408,9 +405,9 @@ public enum ContainerType { protected InvocationInfo[] ejbIntfMethodInfo; protected Properties envProps; - protected boolean isBeanManagedTran = false; + protected boolean isBeanManagedTran; - protected boolean debugMonitorFlag = false; + protected boolean debugMonitorFlag; private static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(BaseContainer.class); @@ -425,7 +422,7 @@ public enum ContainerType { protected int containerState = CONTAINER_INITIALIZING; protected HashMap methodMonitorMap; - protected boolean monitorOn = false; + protected boolean monitorOn; protected EjbMonitoringStatsProvider ejbProbeListener; protected EjbMonitoringProbeProvider ejbProbeNotifier; @@ -435,8 +432,6 @@ public enum ContainerType { protected EjbCacheProbeProvider cacheProbeNotifier; protected EjbCacheStatsProvider cacheProbeListener; - protected ContainerInfo containerInfo; - private final String _debugDescription; //protected Agent callFlowAgent; @@ -479,10 +474,10 @@ public enum ContainerType { // Used to track whether we've done the base container cleanup (JNDI entries, etc.) // Only. Not applicable to concrete containers. - private boolean baseContainerCleanupDone = false; + private boolean baseContainerCleanupDone; // True if there is at least one asynchronous method exposed from the bean. - private boolean hasAsynchronousInvocations = false; + private boolean hasAsynchronousInvocations; // Information about a web service ejb endpoint. Used as a conduit // between webservice runtime and ejb container. Contains a Remote @@ -507,16 +502,12 @@ public enum ContainerType { */ protected BaseContainer(final ContainerType type, final EjbDescriptor ejbDesc, final ClassLoader loader, final SecurityManager sm) throws Exception { - this.containerType = type; + this.ejbDescriptor = ejbDesc; + this.loader = loader; this.securityManager = sm; + this.containerInfo = createContainerInfo(type, ejbDesc); try { - this.loader = loader; - this.ejbDescriptor = ejbDesc; - //this.callFlowAgent = ejbContainerUtilImpl.getCallFlowAgent(); - - logParams = new Object[1]; - logParams[0] = ejbDesc.getName(); invocationManager = ejbContainerUtilImpl.getInvocationManager(); injectionManager = ejbContainerUtilImpl.getInjectionManager(); namingManager = ejbContainerUtilImpl.getGlassfishNamingManager(); @@ -653,13 +644,11 @@ protected BaseContainer(final ContainerType type, final EjbDescriptor ejbDesc, f if (isStatelessSession || isSingleton) { EjbBundleDescriptorImpl bundle = ejbDescriptor.getEjbBundleDescriptor(); WebServicesDescriptor webServices = bundle.getWebServices(); - Collection endpoints = webServices.getEndpointsImplementedBy(ejbDescriptor); + Collection endpoints = webServices.getEndpointsImplementedBy(ejbDescriptor); // JSR 109 doesn't require support for a single ejb // implementing multiple port ex. if (endpoints.size() == 1) { - assertFullProfile("is a Web Service Endpoint"); - webServiceEndpointIntf = loader.loadClass(ejbDescriptor.getWebServiceEndpointInterfaceName()); isWebServiceEndpoint = true; } @@ -696,9 +685,7 @@ protected BaseContainer(final ContainerType type, final EjbDescriptor ejbDesc, f ejbClass.getName(), schd.getTimeoutMethod().getFormattedString())); } - if (_logger.isLoggable(Level.FINE)) { - _logger.log(Level.FINE, "... processing " + method); - } + _logger.log(Level.FINE, "... processing {0}", method); processEjbTimeoutMethod(method); List list = schedules.get(method); @@ -748,7 +735,7 @@ protected BaseContainer(final ContainerType type, final EjbDescriptor ejbDesc, f initEjbInterceptors(); } catch (Exception ex) { - _logger.log(Level.FINE, "Exception creating BaseContainer : [{0}]", logParams); + _logger.log(Level.FINE, "Exception creating BaseContainer : [{0}]", containerInfo); _logger.log(Level.FINE, "", ex); throw ex; } @@ -761,8 +748,8 @@ protected ProtocolManager getProtocolManager() { return protocolMgr; } - public ContainerType getContainerType() { - return containerType; + public ContainerInfo getContainerInfo() { + return this.containerInfo; } protected void doEJBHomeRemove(Object pk, Method m, boolean isLocal) throws RemoteException, RemoveException { @@ -1026,12 +1013,11 @@ public java.lang.Object run() { } }); } - java.rmi.Remote remoteRef = null; + final java.rmi.Remote remoteRef; if (generatedRemoteBusinessIntf == null) { remoteRef = remoteHomeRefFactory.createRemoteReference(instanceKey); } else { RemoteReferenceFactory remoteBusinessRefFactory = remoteBusinessIntfInfo.get(generatedRemoteBusinessIntf).referenceFactory; - remoteRef = remoteBusinessRefFactory.createRemoteReference(instanceKey); } return remoteRef; @@ -1794,7 +1780,7 @@ public void preInvoke(EjbInvocation inv) { } } catch (Exception ex) { - _logger.log(Level.FINE, "Exception while running pre-invoke : ejbName = [{0}]", logParams); + _logger.log(Level.FINE, "Exception while running pre-invoke : ejb: [{0}]", containerInfo); _logger.log(Level.FINE, "", ex); EJBException ejbEx; @@ -2433,7 +2419,7 @@ public Object getJaccEjb(EjbInvocation ejbInvocation) { // be released. } catch (EJBException e) { - _logger.log(Level.WARNING, CONTEXT_FAILURE_JACC, logParams[0]); + _logger.log(Level.WARNING, CONTEXT_FAILURE_JACC, containerInfo); _logger.log(Level.WARNING, "", e); } @@ -2956,7 +2942,7 @@ private void setHomeTargetMethodInfo(InvocationInfo invInfo, boolean isLocal) th if (initMethod != null) { invInfo.targetMethod1 = initMethod; } else { - Object[] params = { logParams[0], (isLocal ? "LocalHome" : "Home"), invInfo.method.toString() }; + Object[] params = { containerInfo, (isLocal ? "LocalHome" : "Home"), invInfo.method.toString() }; _logger.log(Level.WARNING, BEAN_CLASS_METHOD_NOT_FOUND, params); // Treat this as a warning instead of a fatal error. // That matches the behavior of the generated code. @@ -3005,7 +2991,7 @@ private void setEJBObjectTargetMethodInfo(InvocationInfo invInfo, boolean isLoca } } catch (NoSuchMethodException nsme) { - Object[] params = { logParams[0] + ":" + nsme.toString(), (isLocal ? "Local" : "Remote"), invInfo.method.toString() }; + Object[] params = { containerInfo + ":" + nsme.toString(), (isLocal ? "Local" : "Remote"), invInfo.method.toString() }; _logger.log(Level.WARNING, BEAN_CLASS_METHOD_NOT_FOUND, params); // Treat this as a warning instead of a fatal error. // That matches the behavior of the generated code. @@ -3920,7 +3906,7 @@ public java.lang.Object run() { } } catch (Exception ex) { - _logger.log(Level.FINE, "Exception during undeploy", logParams); + _logger.log(Level.FINE, "Exception during undeploy {0}", containerInfo); _logger.log(Level.FINE, "", ex); } } @@ -3928,7 +3914,7 @@ public java.lang.Object run() { try { ejbContainerUtilImpl.getComponentEnvManager().unbindFromComponentNamespace(ejbDescriptor); } catch (javax.naming.NamingException namEx) { - _logger.log(Level.FINE, "Exception during undeploy", logParams); + _logger.log(Level.FINE, "Exception during undeploy: {0}", containerInfo); _logger.log(Level.FINE, "", namEx); } @@ -4267,45 +4253,46 @@ public Object invokeBeanMethod(EjbInvocation invocation) throws Throwable { protected abstract EjbMonitoringStatsProvider getMonitoringStatsProvider(String appName, String modName, String ejbName); protected void createMonitoringRegistry() { - String appName = null; - String modName = null; - String ejbName = null; boolean isMonitorRegistryMediatorCreated = false; try { - appName = (ejbDescriptor.getApplication().isVirtual()) ? null : ejbDescriptor.getApplication().getRegistrationName(); - if (appName == null) { - modName = ejbDescriptor.getApplication().getRegistrationName(); - } else { - String archiveuri = ejbDescriptor.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri(); - modName = com.sun.enterprise.util.io.FileUtils.makeFriendlyFilename(archiveuri); - } - ejbName = ejbDescriptor.getName(); - containerInfo = new ContainerInfo(appName, modName, ejbName); - isMonitorRegistryMediatorCreated = true; - registerEjbMonitoringProbeProvider(appName, modName, ejbName); - ejbProbeListener = getMonitoringStatsProvider(appName, modName, ejbName); - ejbProbeListener.addMethods(getContainerId(), appName, modName, ejbName, getMonitoringMethodsArray()); + registerEjbMonitoringProbeProvider(); + ejbProbeListener = getMonitoringStatsProvider(containerInfo.appName, containerInfo.modName, containerInfo.ejbName); + ejbProbeListener.addMethods(getContainerId(), containerInfo.appName, containerInfo.modName, containerInfo.ejbName, getMonitoringMethodsArray()); ejbProbeListener.register(); if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, - "Created MonitoringRegistry: " + EjbMonitoringUtils.getDetailedLoggingName(appName, modName, ejbName)); + "Created MonitoringRegistry: " + EjbMonitoringUtils.getDetailedLoggingName(containerInfo.appName, containerInfo.modName, containerInfo.ejbName)); } } catch (Exception ex) { _logger.log(Level.SEVERE, COULD_NOT_CREATE_MONITORREGISTRYMEDIATOR, - new Object[] { EjbMonitoringUtils.getDetailedLoggingName(appName, modName, ejbName), ex }); + new Object[] { EjbMonitoringUtils.getDetailedLoggingName(containerInfo.appName, containerInfo.modName, containerInfo.ejbName), ex }); if (!isMonitorRegistryMediatorCreated) { - registerEjbMonitoringProbeProvider(appName, modName, ejbName); + registerEjbMonitoringProbeProvider(); } } } - private void registerEjbMonitoringProbeProvider(String appName, String modName, String ejbName) { + private static ContainerInfo createContainerInfo(final ContainerType type, final EjbDescriptor ejbDescriptor) { + final String appName = ejbDescriptor.getApplication().isVirtual() ? null + : ejbDescriptor.getApplication().getRegistrationName(); + final String modName; + if (appName == null) { + modName = ejbDescriptor.getApplication().getRegistrationName(); + } else { + String archiveuri = ejbDescriptor.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri(); + modName = com.sun.enterprise.util.io.FileUtils.makeFriendlyFilename(archiveuri); + } + return new ContainerInfo(type, appName, modName, ejbDescriptor.getName()); + } + + private void registerEjbMonitoringProbeProvider() { // Always create to avoid NPE try { ProbeProviderFactory probeFactory = ejbContainerUtilImpl.getProbeProviderFactory(); - String invokerId = EjbMonitoringUtils.getInvokerId(appName, modName, ejbName); + String invokerId = EjbMonitoringUtils.getInvokerId( + containerInfo.appName, containerInfo.modName, containerInfo.ejbName); ejbProbeNotifier = probeFactory.getProbeProvider(EjbMonitoringProbeProvider.class, invokerId); if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Got ProbeProvider: " + ejbProbeNotifier.getClass().getName()); @@ -4464,38 +4451,47 @@ private static boolean isCosNamingObject(Object obj) { } /** - * PreInvokeException is used to wrap exceptions thrown from BaseContainer.preInvoke, so it indicates that the bean's method will - * not be called. + * PreInvokeException is used to wrap exceptions thrown from BaseContainer.preInvoke, + * so it indicates that the bean's method will not be called. */ public final static class PreInvokeException extends EJBException { - + // FIXME: use e.cause, don't forget to fix all usages. Exception exception; public PreInvokeException(Exception ex) { this.exception = ex; } - } //PreInvokeException{} + } /** - * Strings for monitoring info + * Informations about this container. */ public static final class ContainerInfo { - public String appName; - public String modName; - public String ejbName; + public final String appName; + public final String modName; + public final String ejbName; + public final ContainerType type; - ContainerInfo(String appName, String modName, String ejbName) { + ContainerInfo(ContainerType type, String appName, String modName, String ejbName) { + this.type = type; this.appName = appName; this.modName = modName; this.ejbName = ejbName; } - } //ContainerInfo + + @Override + public String toString() { + return new StringBuilder(64).append(appName).append('_').append(this.modName).append('_') + .append(this.ejbName).append('(').append(this.type).append(')').toString(); + } + } private static class BeanContext { ClassLoader previousClassLoader; boolean classLoaderSwitched; } -} //BaseContainer{} + +} // BaseContainer class final class CallFlowInfoImpl implements CallFlowInfo { diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBHomeImpl.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBHomeImpl.java index f17efe905488..8efa71de1876 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBHomeImpl.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBHomeImpl.java @@ -107,6 +107,7 @@ public EJBObjectImpl createRemoteBusinessObjectImpl() * This is the implementation of the jakarta.ejb.EJBHome remove method. * @exception RemoveException on error during removal */ + @Override public final void remove(Handle handle) throws RemoteException, RemoveException { @@ -130,10 +131,11 @@ public final void remove(Handle handle) * This is the implementation of the jakarta.ejb.EJBHome remove method. * @exception RemoveException on error during removal */ + @Override public final void remove(Object primaryKey) throws RemoteException, RemoveException { - if (container.getContainerType() != BaseContainer.ContainerType.ENTITY) { + if (container.getContainerInfo().type != BaseContainer.ContainerType.ENTITY) { // Session beans dont have primary keys. EJB2.0 Section 6.6 throw new RemoveException("Invalid remove operation."); } @@ -155,6 +157,7 @@ public final void remove(Object primaryKey) /** * This is the implementation of the jakarta.ejb.EJBHome method. */ + @Override public final EJBMetaData getEJBMetaData() throws RemoteException { @@ -167,6 +170,7 @@ public final EJBMetaData getEJBMetaData() * This is the implementation of the jakarta.ejb.EJBHome getHomeHandle * method. */ + @Override public final HomeHandle getHomeHandle() throws RemoteException { diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBHomeInvocationHandler.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBHomeInvocationHandler.java index ecc02f5ffb90..918f3017aa90 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBHomeInvocationHandler.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBHomeInvocationHandler.java @@ -56,7 +56,7 @@ public class EJBHomeInvocationHandler // but only has InvocationHandler. private EJBHome proxy_; - private Class homeIntfClass_; + private final Class homeIntfClass_; // Cache reference to invocation info. There is one of these per // container. It's populated during container initialization and @@ -65,7 +65,7 @@ public class EJBHomeInvocationHandler // is created. private MethodMap invocationInfoMap_; - private EjbContainerUtil ejbContainerUtil = EjbContainerUtilImpl.getInstance(); + private final EjbContainerUtil ejbContainerUtil = EjbContainerUtilImpl.getInstance(); protected EJBHomeInvocationHandler(EjbDescriptor ejbDescriptor, @@ -93,6 +93,7 @@ public void setMethodMap(MethodMap map) { invocationInfoMap_ = map; } + @Override protected EJBHome getEJBHome() { return proxy_; } @@ -100,6 +101,7 @@ protected EJBHome getEJBHome() { /** * Called by EJBHome proxy. */ + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { @@ -119,17 +121,14 @@ public Object invoke(Object proxy, Method method, Object[] args) // proceeding. Otherwise, the context classloader could still // reflect the caller's class loader. - if( Thread.currentThread().getContextClassLoader() != - getContainer().getClassLoader() ) { - originalClassLoader = Utility.setContextClassLoader - (getContainer().getClassLoader()); + if (Thread.currentThread().getContextClassLoader() != getContainer().getClassLoader()) { + originalClassLoader = Utility.setContextClassLoader(getContainer().getClassLoader()); } Class methodClass = method.getDeclaringClass(); - if( methodClass == java.lang.Object.class ) { - return InvocationHandlerUtil.invokeJavaObjectMethod - (this, method, args); + if (methodClass == java.lang.Object.class) { + return InvocationHandlerUtil.invokeJavaObjectMethod(this, method, args); } else if (invokeSpecialEJBHomeMethod(method, methodClass, args)) { return null; } @@ -236,7 +235,7 @@ public Object invoke(Object proxy, Method method, Object[] args) inv.invocationInfo = invInfo; if( ejbObjectImpl != null && invInfo.startsWithCreate ) { - inv.ejbObject = (EJBLocalRemoteObject) ejbObjectImpl; + inv.ejbObject = ejbObjectImpl; } BaseContainer container = (BaseContainer) getContainer(); @@ -335,24 +334,24 @@ private Object invokeEJBHomeMethod(String methodName, Object[] args) try { if( methodName.equals("getEJBMetaData") ) { - methodIndex = container.EJBHome_getEJBMetaData; + methodIndex = BaseContainer.EJBHome_getEJBMetaData; container.onEjbMethodStart(methodIndex); returnValue = super.getEJBMetaData(); } else if( methodName.equals("getHomeHandle") ) { - methodIndex = container.EJBHome_getHomeHandle; + methodIndex = BaseContainer.EJBHome_getHomeHandle; container.onEjbMethodStart(methodIndex); returnValue = super.getHomeHandle(); } else if( methodName.equals("remove") ) { if( args[0] instanceof jakarta.ejb.Handle ) { - methodIndex = container.EJBHome_remove_Handle; + methodIndex = BaseContainer.EJBHome_remove_Handle; container.onEjbMethodStart(methodIndex); super.remove((jakarta.ejb.Handle)args[0]); } else { - methodIndex = container.EJBHome_remove_Pkey; + methodIndex = BaseContainer.EJBHome_remove_Pkey; container.onEjbMethodStart(methodIndex); super.remove(args[0]); } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBLocalHomeImpl.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBLocalHomeImpl.java index 905cab11ec38..071912a8d255 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBLocalHomeImpl.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/EJBLocalHomeImpl.java @@ -95,10 +95,11 @@ protected final EJBLocalObjectImpl createEJBLocalBusinessObjectImpl(String intfN /** * This is the implementation of the jakarta.ejb.EJBLocalHome remove method. */ + @Override public final void remove(Object primaryKey) throws RemoveException, EJBException { - if (container.getContainerType() != BaseContainer.ContainerType.ENTITY) { + if (container.getContainerInfo().type != BaseContainer.ContainerType.ENTITY) { // Session beans dont have primary keys. EJB2.0 Section 6.6. throw new RemoveException("Attempt to call remove(Object primaryKey) on a session bean."); } @@ -119,12 +120,11 @@ public final void remove(Object primaryKey) // This should never be thrown for local invocations, but it's // part of the removeBean signature. If for some strange // reason it happens, convert to EJBException - EJBException ejbEx =new EJBException("unexpected RemoteException"); - ejbEx.initCause(re); - throw ejbEx; + throw new EJBException("unexpected RemoteException", re); } } + @Override public SerializableObjectFactory getSerializableObjectFactory() { return new SerializableLocalHome( container.getEjbDescriptor().getUniqueId()); @@ -133,12 +133,13 @@ public SerializableObjectFactory getSerializableObjectFactory() { public static final class SerializableLocalHome implements SerializableObjectFactory { - private long ejbId; + private final long ejbId; public SerializableLocalHome(long uniqueId) { this.ejbId = uniqueId; } + @Override public Object createObject() throws IOException { diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/RemoteBusinessObjectFactory.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/RemoteBusinessObjectFactory.java index 1a12569850bc..e353d038d564 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/RemoteBusinessObjectFactory.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/RemoteBusinessObjectFactory.java @@ -30,26 +30,13 @@ public class RemoteBusinessObjectFactory implements ObjectFactory { - - - public Object getObjectInstance(Object obj, - Name name, - Context nameCtx, - Hashtable env) throws Exception - { - - InitialContext ic = new InitialContext(env); - - Reference ref = (Reference) obj; - - RefAddr refAddr = ref.get("url"); - - Object genericRemoteHomeObj = ic.lookup((String) refAddr.getContent()); - - String busInterface = ref.getClassName(); - - return EJBUtils.lookupRemote30BusinessObject(genericRemoteHomeObj, - busInterface); + @Override + public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception { + InitialContext ic = new InitialContext(env); + Reference ref = (Reference) obj; + RefAddr refAddr = ref.get("url"); + Object genericRemoteHomeObj = ic.lookup((String) refAddr.getContent()); + String busInterface = ref.getClassName(); + return EJBUtils.lookupRemote30BusinessObject(genericRemoteHomeObj, busInterface); } - } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/RemoteBusinessWrapperBase.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/RemoteBusinessWrapperBase.java index df70245698df..93437d4d69c2 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/RemoteBusinessWrapperBase.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/RemoteBusinessWrapperBase.java @@ -25,10 +25,9 @@ import com.sun.ejb.EJBUtils; -public class RemoteBusinessWrapperBase - implements java.io.Serializable { +public class RemoteBusinessWrapperBase implements java.io.Serializable { - // This is the name of the developer-written business interface. + /** This is the name of the developer-written business interface. */ private String businessInterface_; private Remote stub_; @@ -45,10 +44,12 @@ public Remote getStub() { return stub_; } + @Override public int hashCode() { return hashCode_; } + @Override public boolean equals(Object obj) { boolean result = (obj == this); //Most efficient @@ -78,51 +79,37 @@ public Object writeReplace() throws ObjectStreamException { return new RemoteBusinessWrapperBase(stub_, businessInterface_); } - private void writeObject(java.io.ObjectOutputStream oos) - throws java.io.IOException - { + private void writeObject(java.io.ObjectOutputStream oos) throws java.io.IOException { oos.writeObject(businessInterface_); oos.writeObject(stub_); } - private void readObject(ObjectInputStream ois) - throws IOException, ClassNotFoundException { + private void readObject(ObjectInputStream ois) throws IOException { try { - businessInterface_ = (String) ois.readObject(); hashCode_ = businessInterface_.hashCode(); EJBUtils.loadGeneratedRemoteBusinessClasses(businessInterface_); stub_ = (Remote) ois.readObject(); - - } catch(Exception e) { - IOException ioe = new IOException("RemoteBusinessWrapper.readObj " - + " error"); - ioe.initCause(e); - throw ioe; + } catch (Exception e) { + throw new IOException("RemoteBusinessWrapper.readObj error", e); } } - public Object readResolve() throws ObjectStreamException { + public Object readResolve() throws ObjectStreamException { try { - return EJBUtils.createRemoteBusinessObject(businessInterface_, - stub_); - } catch(Exception e) { - WriteAbortedException wae = new WriteAbortedException - ("RemoteBusinessWrapper.readResolve error", e); + return EJBUtils.createRemoteBusinessObject(businessInterface_, stub_); + } catch (Exception e) { + WriteAbortedException wae = new WriteAbortedException("RemoteBusinessWrapper.readResolve error", e); throw wae; } } - - - - } diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/StatefulSessionContainer.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/StatefulSessionContainer.java index 8927b904099f..5000e92ea12e 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/StatefulSessionContainer.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/StatefulSessionContainer.java @@ -263,8 +263,8 @@ public final class StatefulSessionContainer private final static long CONCURRENCY_NOT_ALLOWED = 0; private final static long BLOCK_INDEFINITELY = -1; - private ArrayList passivationCandidates = new ArrayList(); - private Object asyncTaskSemaphore = new Object(); + private final ArrayList passivationCandidates = new ArrayList(); + private final Object asyncTaskSemaphore = new Object(); private int asyncTaskCount = 0; @@ -278,21 +278,21 @@ public final class StatefulSessionContainer private LruSessionCache sessionBeanCache; private BackingStore backingStore; private SFSBUUIDUtil uuidGenerator; - private ArrayList scheduledTimerTasks = new ArrayList(); + private final ArrayList scheduledTimerTasks = new ArrayList(); private int statMethodReadyCount = 0; - private Level TRACE_LEVEL = Level.FINE; + private final Level TRACE_LEVEL = Level.FINE; - private String ejbName; + private final String ejbName; private boolean isHAEnabled; private int removalGracePeriodInSeconds; - private InvocationInfo postConstructInvInfo; - private InvocationInfo preDestroyInvInfo; - private InvocationInfo postActivateInvInfo; - private InvocationInfo prePassivateInvInfo; + private final InvocationInfo postConstructInvInfo; + private final InvocationInfo preDestroyInvInfo; + private final InvocationInfo postActivateInvInfo; + private final InvocationInfo prePassivateInvInfo; private StatefulSessionStoreMonitor sfsbStoreMonitor; @@ -303,7 +303,7 @@ public final class StatefulSessionContainer private Method afterBeginMethod; private Method beforeCompletionMethod; private Method afterCompletionMethod; - private boolean isPassivationCapable; + private final boolean isPassivationCapable; /* * Cache for keeping ref count for shared extended entity manager. @@ -311,10 +311,10 @@ public final class StatefulSessionContainer */ private static final Map extendedEMReferenceCountMap - = new HashMap(); + = new HashMap<>(); private static final Map eemKey2EEMMap - = new HashMap(); + = new HashMap<>(); /** * This constructor is called from the JarManager when a Jar is deployed. @@ -346,6 +346,7 @@ public StatefulSessionContainer(ContainerType conType, EjbDescriptor desc, isPassivationCapable = sfulDesc.isPassivationCapable(); } + @Override public boolean isPassivationCapable() { return isPassivationCapable; } @@ -361,6 +362,7 @@ private InvocationInfo getLifecycleCallbackInvInfo( return inv; } + @Override protected void initializeHome() throws Exception { super.initializeHome(); @@ -427,6 +429,7 @@ private void processSessionSynchMethod(Method sessionSynchMethod) java.security.AccessController.doPrivileged( new java.security.PrivilegedExceptionAction() { + @Override public java.lang.Object run() throws Exception { if( !methodAccessible.isAccessible() ) { methodAccessible.setAccessible(true); @@ -439,6 +442,7 @@ public java.lang.Object run() throws Exception { // Called before invoking a bean with no Tx or with a new Tx. // Check if the bean is associated with an unfinished tx. + @Override protected void checkUnfinishedTx(Transaction prevTx, EjbInvocation inv) { try { if ( inv.invocationInfo.isBusinessMethod && prevTx != null && @@ -488,6 +492,7 @@ protected void loadCheckpointInfo() { } } + @Override protected void registerMonitorableComponents() { registerEjbCacheProbeProvider(); super.registerMonitorableComponents(); @@ -552,6 +557,7 @@ public String getMonitorAttributeValues() { return sbuf.toString(); } + @Override protected EjbMonitoringStatsProvider getMonitoringStatsProvider( String appName, String modName, String ejbName) { StatefulSessionBeanStatsProvider statsProvider = new StatefulSessionBeanStatsProvider( @@ -578,7 +584,7 @@ public void appendStats(StringBuffer sbuf) { } **/ - private static final String convertCtxStateToString( + private static String convertCtxStateToString( SessionContextImpl sc) { switch (sc.getState()) { case PASSIVATED: @@ -595,18 +601,20 @@ private static final String convertCtxStateToString( return "UNKNOWN-STATE"; } + @Override protected boolean isIdentical(EJBObjectImpl ejbo, EJBObject other) throws RemoteException { - if (other == ejbo.getStub()) + if (other == ejbo.getStub()) { return true; - else { + } else { try { // other may be a stub for a remote object. - if (getProtocolManager().isIdentical(ejbo.getStub(), other)) + if (getProtocolManager().isIdentical(ejbo.getStub(), other)) { return true; - else + } else { return false; + } } catch (Exception ex) { _logger.log(Level.FINE, "Exception while getting stub for ejb", ex); @@ -622,6 +630,7 @@ protected boolean isIdentical(EJBObjectImpl ejbo, EJBObject other) * ejbCreate on the new bean after createEJBObject() returns. * Return the EJBObject for the bean. */ + @Override protected EJBObjectImpl createEJBObjectImpl() throws CreateException, RemoteException { try { @@ -634,9 +643,9 @@ protected EJBObjectImpl createEJBObjectImpl() _logger.log(Level.WARNING, CREATE_EJBOBJECT_EXCEPTION, new Object[]{ejbDescriptor.getName(), ex}); - if (ex instanceof EJBException) + if (ex instanceof EJBException) { throw (EJBException) ex; - else { + } else { CreateException ce = new CreateException("ERROR creating stateful SessionBean"); ce.initCause(ex); @@ -645,6 +654,7 @@ protected EJBObjectImpl createEJBObjectImpl() } } + @Override protected EJBObjectImpl createRemoteBusinessObjectImpl() throws CreateException, RemoteException { try { @@ -658,9 +668,9 @@ protected EJBObjectImpl createRemoteBusinessObjectImpl() _logger.log(Level.WARNING, CREATE_EJBOBJECT_EXCEPTION, new Object[]{ejbDescriptor.getName(), ex}); - if (ex instanceof EJBException) + if (ex instanceof EJBException) { throw (EJBException) ex; - else { + } else { CreateException ce = new CreateException("ERROR creating stateful SessionBean"); ce.initCause(ex); @@ -677,6 +687,7 @@ protected EJBObjectImpl createRemoteBusinessObjectImpl() * ejbCreate on the new bean after createEJBLocalObjectImpl() returns. * Return the EJBLocalObject for the bean. */ + @Override protected EJBLocalObjectImpl createEJBLocalObjectImpl() throws CreateException { try { @@ -693,9 +704,9 @@ protected EJBLocalObjectImpl createEJBLocalObjectImpl() _logger.log(Level.WARNING, CREATE_EJBLOCALOBJECT_EXCEPTION, new Object[]{ejbDescriptor.getName(), ex}); - if (ex instanceof EJBException) + if (ex instanceof EJBException) { throw (EJBException) ex; - else { + } else { CreateException ce = new CreateException("ERROR creating stateful SessionBean"); ce.initCause(ex); @@ -707,6 +718,7 @@ protected EJBLocalObjectImpl createEJBLocalObjectImpl() /** * Internal creation event for Local Business view of SFSB */ + @Override EJBLocalObjectImpl createEJBLocalBusinessObjectImpl(boolean localBeanView) throws CreateException { try { @@ -830,7 +842,7 @@ private void createExtendedEMs(SessionContextImpl ctx, Object sessionKey) { Set emRefs = ejbDescriptor.getEntityManagerReferenceDescriptors(); Iterator iter = emRefs.iterator(); - Set eemRefInfos = new HashSet(); + Set eemRefInfos = new HashSet<>(); while (iter.hasNext()) { EntityManagerReferenceDescriptor refDesc = iter.next(); if (refDesc.getPersistenceContextType() == @@ -898,8 +910,7 @@ private void createExtendedEMs(SessionContextImpl ctx, Object sessionKey) { private PhysicalEntityManagerWrapper findExtendedEMFromInvList(EntityManagerFactory emf) { PhysicalEntityManagerWrapper em = null; - ComponentInvocation compInv = (ComponentInvocation) - invocationManager.getCurrentInvocation(); + ComponentInvocation compInv = invocationManager.getCurrentInvocation(); if (compInv != null) { if (compInv.getInvocationType() == ComponentInvocation.ComponentInvocationType.EJB_INVOCATION) { EjbInvocation ejbInv = (EjbInvocation) compInv; @@ -915,6 +926,7 @@ private PhysicalEntityManagerWrapper findExtendedEMFromInvList(EntityManagerFact return em; } + @Override public EntityManager lookupExtendedEntityManager(EntityManagerFactory emf) { PhysicalEntityManagerWrapper physicalEntityManagerWrapper = findExtendedEMFromInvList(emf); return physicalEntityManagerWrapper == null ? null : physicalEntityManagerWrapper.getEM(); @@ -976,8 +988,9 @@ private void afterInstanceCreation(SessionContextImpl context) // called from createEJBObject and activateEJB and createEJBLocalObjectImpl private EJBLocalObjectImpl createEJBLocalObjectImpl (SessionContextImpl context) throws Exception { - if (context.getEJBLocalObjectImpl() != null) + if (context.getEJBLocalObjectImpl() != null) { return context.getEJBLocalObjectImpl(); + } // create EJBLocalObject EJBLocalObjectImpl localObjImpl = instantiateEJBLocalObjectImpl(context.getInstanceKey()); @@ -1007,8 +1020,9 @@ private void afterInstanceCreation(SessionContextImpl context) private EJBLocalObjectImpl createEJBLocalBusinessObjectImpl (SessionContextImpl context) throws Exception { - if (context.getEJBLocalBusinessObjectImpl() != null) + if (context.getEJBLocalBusinessObjectImpl() != null) { return context.getEJBLocalBusinessObjectImpl(); + } EJBLocalObjectImpl localBusinessObjImpl = instantiateEJBLocalBusinessObjectImpl(); @@ -1038,8 +1052,9 @@ private void afterInstanceCreation(SessionContextImpl context) private EJBLocalObjectImpl createOptionalEJBLocalBusinessObjectImpl (SessionContextImpl context) throws Exception { - if (context.getOptionalEJBLocalBusinessObjectImpl() != null) + if (context.getOptionalEJBLocalBusinessObjectImpl() != null) { return context.getOptionalEJBLocalBusinessObjectImpl(); + } EJBLocalObjectImpl optionalLocalBusinessObjImpl = instantiateOptionalEJBLocalBusinessObjectImpl(); @@ -1071,8 +1086,9 @@ private void afterInstanceCreation(SessionContextImpl context) private EJBObjectImpl createEJBObjectImpl(SessionContextImpl context) throws Exception { - if (context.getEJBObjectImpl() != null) + if (context.getEJBObjectImpl() != null) { return context.getEJBObjectImpl(); + } // create EJBObject and associate it with the key Object sessionKey = context.getInstanceKey(); @@ -1115,8 +1131,9 @@ private EJBObjectImpl createEJBObjectImpl(SessionContextImpl context) private EJBObjectImpl createRemoteBusinessObjectImpl (SessionContextImpl context) throws Exception { - if (context.getEJBRemoteBusinessObjectImpl() != null) + if (context.getEJBRemoteBusinessObjectImpl() != null) { return context.getEJBRemoteBusinessObjectImpl(); + } // create EJBObject EJBObjectImpl ejbBusinessObjImpl = @@ -1163,6 +1180,7 @@ private EJBObjectImpl createEJBObjectImpl(SessionContextImpl context) // Called from EJBObjectImpl.remove, EJBLocalObjectImpl.remove, // EJBHomeImpl.remove(Handle). + @Override protected void removeBean(EJBLocalRemoteObject ejbo, Method removeMethod, boolean local) throws RemoveException, EJBException { @@ -1273,12 +1291,14 @@ private void removeBean(EjbInvocation inv) * Note: EJB2.0 section 18.3.1 says that discarding an EJB * means that no methods other than finalize() should be invoked on it. */ + @Override protected void forceDestroyBean(EJBContextImpl ctx) { SessionContextImpl sc = (SessionContextImpl) ctx; synchronized (sc) { - if (sc.getState() == EJBContextImpl.BeanState.DESTROYED) + if (sc.getState() == EJBContextImpl.BeanState.DESTROYED) { return; + } // mark context as destroyed so no more invocations happen on it sc.setState(BeanState.DESTROYED); @@ -1349,7 +1369,7 @@ protected void forceDestroyBean(EJBContextImpl ctx) { // disconnect the EJBLocalObject from the context // and vice versa EJBLocalObjectImpl localObjImpl = - (EJBLocalObjectImpl) sc.getEJBLocalObjectImpl(); + sc.getEJBLocalObjectImpl(); localObjImpl.clearContext(); localObjImpl.setRemoved(true); sc.setEJBLocalObjectImpl(null); @@ -1358,14 +1378,14 @@ protected void forceDestroyBean(EJBContextImpl ctx) { // disconnect the EJBLocalObject from the context // and vice versa EJBLocalObjectImpl localBusinessObjImpl = - (EJBLocalObjectImpl) sc.getEJBLocalBusinessObjectImpl(); + sc.getEJBLocalBusinessObjectImpl(); localBusinessObjImpl.clearContext(); localBusinessObjImpl.setRemoved(true); sc.setEJBLocalBusinessObjectImpl(null); } if (hasOptionalLocalBusinessView) { EJBLocalObjectImpl optionalLocalBusinessObjImpl = - (EJBLocalObjectImpl) sc.getOptionalEJBLocalBusinessObjectImpl(); + sc.getOptionalEJBLocalBusinessObjectImpl(); optionalLocalBusinessObjImpl.clearContext(); optionalLocalBusinessObjImpl.setRemoved(true); sc.setOptionalEJBLocalBusinessObjectImpl(null); @@ -1411,6 +1431,7 @@ private void destroyExtendedEMsForContext(SessionContextImpl sc) { } } + @Override public boolean userTransactionMethodsAllowed(ComponentInvocation inv) { boolean utMethodsAllowed = false; @@ -1494,11 +1515,13 @@ private SessionContextImpl _getContextForInstance(byte[] instanceKey) { } + @Override protected EJBObjectImpl getEJBObjectImpl(byte[] instanceKey) { SessionContextImpl sc = _getContextForInstance(instanceKey); return sc.getEJBObjectImpl(); } + @Override EJBObjectImpl getEJBRemoteBusinessObjectImpl(byte[] instanceKey) { SessionContextImpl sc = _getContextForInstance(instanceKey); return sc.getEJBRemoteBusinessObjectImpl(); @@ -1508,6 +1531,7 @@ EJBObjectImpl getEJBRemoteBusinessObjectImpl(byte[] instanceKey) { * Called from EJBLocalObjectImpl.getLocalObject() while deserializing * a local object reference. */ + @Override protected EJBLocalObjectImpl getEJBLocalObjectImpl(Object sessionKey) { // Create an EJBLocalObject reference which @@ -1532,6 +1556,7 @@ protected EJBLocalObjectImpl getEJBLocalObjectImpl(Object sessionKey) { return localObjImpl; } + @Override EJBLocalObjectImpl getEJBLocalBusinessObjectImpl(Object sessionKey) { // Create an EJBLocalObject reference which @@ -1559,6 +1584,7 @@ EJBLocalObjectImpl getEJBLocalBusinessObjectImpl(Object sessionKey) { return localBusinessObjImpl; } + @Override EJBLocalObjectImpl getOptionalEJBLocalBusinessObjectImpl(Object sessionKey) { // Create an EJBLocalObject reference which @@ -1591,17 +1617,19 @@ EJBLocalObjectImpl getOptionalEJBLocalBusinessObjectImpl(Object sessionKey) { * * @throws NoSuchObjectLocalException if the object has been removed. */ + @Override protected void checkExists(EJBLocalRemoteObject ejbObj) { - if (ejbObj.isRemoved()) + if (ejbObj.isRemoved()) { throw new NoSuchObjectLocalException("Bean has been removed"); + } } - private final void logTraceInfo(EjbInvocation inv, Object key, String message) { + private void logTraceInfo(EjbInvocation inv, Object key, String message) { _logger.log(TRACE_LEVEL, traceInfoPrefix + message + " for " + inv.method.getName() + "; key: " + key); } - private final void logTraceInfo(SessionContextImpl sc, String message) { + private void logTraceInfo(SessionContextImpl sc, String message) { _logger.log(TRACE_LEVEL, traceInfoPrefix + message + " for key: " + sc.getInstanceKey() + "; " + System.identityHashCode(sc)); @@ -1611,6 +1639,7 @@ private final void logTraceInfo(SessionContextImpl sc, String message) { * Called from preInvoke which is called from the EJBObject * for local and remote invocations. */ + @Override public ComponentContext _getContext(EjbInvocation inv) { EJBLocalRemoteObject ejbo = inv.ejbObject; SessionContextImpl sc = ejbo.getContext(); @@ -1756,6 +1785,7 @@ public ComponentContext _getContext(EjbInvocation inv) { return context; } + @Override public boolean isHAEnabled() { return isHAEnabled; } @@ -1772,7 +1802,7 @@ private void doVersionCheck(EjbInvocation inv, Object sessionKey, if (ejbLRO != null) { if (clientVersion == - sfsbVersionManager.NO_VERSION) { + SFSBVersionManager.NO_VERSION) { clientVersion = ejbLRO.getSfsbClientVersion(); } @@ -1825,6 +1855,7 @@ private void handleConcurrentInvocation(boolean allowSerializedAccess, } } + @Override protected void postInvokeTx(EjbInvocation inv) throws Exception { // Intercept postInvokeTx call to perform any @Remove logic @@ -1884,6 +1915,7 @@ private boolean retainAfterRemoveMethod(EjbInvocation inv, * Called from preInvoke which is called from the EJBObject for local and * remote invocations. */ + @Override public void releaseContext(EjbInvocation inv) { SessionContextImpl sc = (SessionContextImpl) inv.context; @@ -1891,8 +1923,9 @@ public void releaseContext(EjbInvocation inv) { // any instance lock is released in the finally block. try { // check if the bean was destroyed - if (sc.getState() == BeanState.DESTROYED) + if (sc.getState() == BeanState.DESTROYED) { return; + } // we're sure that no concurrent thread can be using this // context, so no need to synchronize. @@ -1984,6 +2017,7 @@ private void releaseSFSBSerializedLock(EjbInvocation inv, SessionContextImpl sc) } + @Override protected void afterBegin(EJBContextImpl context) { // TX_BEAN_MANAGED EJBs cannot implement SessionSynchronization // Do not call afterBegin if it is a transactional lifecycle callback @@ -2025,6 +2059,7 @@ protected void afterBegin(EJBContextImpl context) { } + @Override protected void beforeCompletion(EJBContextImpl context) { // SessionSync calls on TX_BEAN_MANAGED SessionBeans // are not allowed @@ -2067,6 +2102,7 @@ protected void beforeCompletion(EJBContextImpl context) { // Called from SyncImpl.afterCompletion // May be called asynchronously during tx timeout // or on the same thread as tx.commit + @Override protected void afterCompletion(EJBContextImpl context, int status) { if (context.getState() == BeanState.DESTROYED) { return; @@ -2237,13 +2273,14 @@ private void callEjbAfterCompletion(SessionContextImpl context, boolean status) } } - public final boolean canPassivateEJB(ComponentContext context) { + public boolean canPassivateEJB(ComponentContext context) { SessionContextImpl sc = (SessionContextImpl) context; return (sc.getState() == BeanState.READY); } // called asynchronously from the Recycler - public final boolean passivateEJB(ComponentContext context) { + @Override + public boolean passivateEJB(ComponentContext context) { SessionContextImpl sc = (SessionContextImpl) context; @@ -2258,8 +2295,9 @@ public final boolean passivateEJB(ComponentContext context) { } } - if (sc.getState() == BeanState.DESTROYED) + if (sc.getState() == BeanState.DESTROYED) { return false; + } if (_logger.isLoggable(TRACE_LEVEL)) { _logger.log(TRACE_LEVEL, traceInfoPrefix + "Passivating context " @@ -2440,16 +2478,18 @@ public final boolean passivateEJB(ComponentContext context) { } - public final int getPassivationBatchCount() { + @Override + public int getPassivationBatchCount() { return this.passivationBatchCount; } - public final void setPassivationBatchCount(int count) { + public void setPassivationBatchCount(int count) { this.passivationBatchCount = count; } // called asynchronously from the Recycler - public final boolean passivateEJB(StatefulEJBContext sfsbCtx) { + @Override + public boolean passivateEJB(StatefulEJBContext sfsbCtx) { return passivateEJB((ComponentContext) sfsbCtx.getSessionContext()); } @@ -2463,6 +2503,7 @@ public long getPassiveCount() { } // called from StatefulSessionStore + @Override public void activateEJB(Object sessionKey, StatefulEJBContext sfsbCtx, Object cookie) { SessionContextImpl context = (SessionContextImpl) sfsbCtx.getSessionContext(); @@ -2640,10 +2681,12 @@ public void activateEJB(Object sessionKey, StatefulEJBContext sfsbCtx, Object co } } + @Override public byte[] serializeContext(StatefulEJBContext ctx) throws IOException { return serializeContext((SessionContextImpl)ctx.getSessionContext()); } + @Override public Object deserializeData(byte[] data) throws Exception { Object o = ejbContainerUtilImpl.getJavaEEIOUtils().deserializeObject(data, true, getClassLoader()); if (o instanceof SessionContextImpl) { @@ -2658,7 +2701,7 @@ public Object deserializeData(byte[] data) throws Exception { try (ByteArrayInputStream bis = new ByteArrayInputStream(sejb.serializedFields); ObjectInputStream ois = ejbContainerUtilImpl.getJavaEEIOUtils().createObjectInputStream(bis, true, getClassLoader());) { - ejb = ejbClass.newInstance(); + ejb = ejbClass.getDeclaredConstructor().newInstance(); EJBUtils.deserializeObjectFields(ejb, ois, o, false); ctx.setEJB(ejb); } @@ -2837,6 +2880,7 @@ protected void delistExtendedEntityManagers(ComponentContext ctx) { } } + @Override public void invokePeriodically(long delay, long periodicity, Runnable target) { java.util.Timer timer = ejbContainerUtilImpl.getTimer(); @@ -2851,14 +2895,14 @@ public void onUndeploy(StatefulEJBContext sfsbCtx) { undeploy((SessionContextImpl) sfsbCtx.getSessionContext()); } + @Override protected String[] getPre30LifecycleMethodNames() { return new String[]{ null, null, "ejbRemove", "ejbPassivate", "ejbActivate" }; } - ; - + @Override protected void doConcreteContainerShutdown(boolean appBeingUndeployed) { cancelAllTimerTasks(); @@ -3105,6 +3149,7 @@ public void undeploy(SessionContextImpl ctx) { } // CacheListener interface + @Override public void trimEvent(Object primaryKey, Object context) { boolean addTask = false; synchronized (asyncTaskSemaphore) { @@ -3144,6 +3189,7 @@ public void trimEvent(Object primaryKey, Object context) { private class ASyncPassivator implements Runnable { + @Override public void run() { final Thread currentThread = Thread.currentThread(); final ClassLoader previousClassLoader = @@ -3159,6 +3205,7 @@ public void run() { } else { java.security.AccessController.doPrivileged (new java.security.PrivilegedAction() { + @Override public java.lang.Object run() { currentThread.setContextClassLoader(myClassLoader); return null; @@ -3194,6 +3241,7 @@ public java.lang.Object run() { } else { java.security.AccessController.doPrivileged (new java.security.PrivilegedAction() { + @Override public java.lang.Object run() { currentThread.setContextClassLoader (previousClassLoader); @@ -3444,13 +3492,13 @@ public void decrementMethodReadyStat() { static class EEMRefInfoKey implements Serializable { - private String emRefName; + private final String emRefName; - private long containerID; + private final long containerID; - private Object instanceKey; + private final Object instanceKey; - private int hc; + private final int hc; EEMRefInfoKey(String en, long cid, Object ikey) { this.emRefName = en; @@ -3460,10 +3508,12 @@ static class EEMRefInfoKey this.hc = instanceKey.hashCode(); } + @Override public int hashCode() { return hc; } + @Override public boolean equals(Object obj) { boolean result = false; if (obj instanceof EEMRefInfoKey) { @@ -3477,6 +3527,7 @@ public boolean equals(Object obj) { return result; } + @Override public String toString() { return "<" + instanceKey + ":" + emRefName + ":" + containerID + ">"; } @@ -3487,11 +3538,11 @@ static class EEMRefInfo private transient int refCount = 0; - private String unitName; + private final String unitName; - private SynchronizationType synchronizationType; + private final SynchronizationType synchronizationType; - private EEMRefInfoKey eemRefInfoKey; + private final EEMRefInfoKey eemRefInfoKey; private byte[] serializedEEM; @@ -3538,6 +3589,7 @@ SynchronizationType getSynchronizationType() { } //Method of IndirectlySerializable + @Override public SerializableObjectFactory getSerializableObjectFactory() throws IOException { @@ -3560,6 +3612,7 @@ public SerializableObjectFactory getSerializableObjectFactory() } //Method of SerializableObjectFactory + @Override public Object createObject() throws IOException { @@ -3596,6 +3649,7 @@ static class SerializableEJB } //Method of IndirectlySerializable + @Override public SerializableObjectFactory getSerializableObjectFactory() throws IOException { @@ -3603,6 +3657,7 @@ public SerializableObjectFactory getSerializableObjectFactory() } //Method of SerializableObjectFactory + @Override public Object createObject() throws IOException { return this; } @@ -3619,12 +3674,14 @@ class PeriodicTask this.ejbContainerUtil = ejbContainerUtil; } + @Override public void run() { if (!task.isExecuting()) { ejbContainerUtil.addWork(task); } } + @Override public boolean cancel() { boolean cancelled = super.cancel(); @@ -3651,6 +3708,7 @@ boolean isExecuting() { } //This will be called with the correct ClassLoader + @Override public void run() { ClassLoader prevCL = Thread.currentThread().getContextClassLoader(); try { diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/StatelessSessionContainer.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/StatelessSessionContainer.java index 9df09b42b9f7..42612ed86244 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/StatelessSessionContainer.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/StatelessSessionContainer.java @@ -19,8 +19,6 @@ import java.lang.reflect.Method; import java.rmi.RemoteException; -import java.util.HashMap; -import java.util.Map; import java.util.logging.Level; import jakarta.ejb.CreateException; @@ -153,11 +151,13 @@ public boolean scanForEjbCreateMethod() { return true; } + @Override protected EjbMonitoringStatsProvider getMonitoringStatsProvider( String appName, String modName, String ejbName) { return new StatelessSessionBeanStatsProvider(this, getContainerId(), appName, modName, ejbName); } + @Override protected void initializeHome() throws Exception { @@ -234,6 +234,7 @@ protected void createBeanPool() { poolProp.poolIdleTimeoutInSeconds, loader, Boolean.parseBoolean(val)); } + @Override protected void registerMonitorableComponents() { super.registerMonitorableComponents(); @@ -245,9 +246,11 @@ protected void registerMonitorableComponents() { _logger.log(Level.FINE, "[SLSB Container] registered monitorable"); } + @Override public void onReady() { } + @Override public EJBObjectImpl createRemoteBusinessObjectImpl() throws CreateException, RemoteException { @@ -266,6 +269,7 @@ private void ejbBeanCreatedEvent() { /** * */ + @Override public EJBObjectImpl createEJBObjectImpl() throws CreateException, RemoteException { @@ -289,6 +293,7 @@ public EJBObjectImpl createEJBObjectImpl() /** * Called during client creation request through EJB LocalHome view. */ + @Override public EJBLocalObjectImpl createEJBLocalObjectImpl() throws CreateException { @@ -312,6 +317,7 @@ public EJBLocalObjectImpl createEJBLocalObjectImpl() /** * Called during internal creation of session bean */ + @Override public EJBLocalObjectImpl createEJBLocalBusinessObjectImpl(boolean localBeanView) throws CreateException { @@ -327,6 +333,7 @@ public EJBLocalObjectImpl createEJBLocalBusinessObjectImpl(boolean localBeanView // Called from EJBObjectImpl.remove, EJBLocalObjectImpl.remove, // EJBHomeImpl.remove(Handle). + @Override protected void removeBean(EJBLocalRemoteObject ejbo, Method removeMethod, boolean local) throws RemoveException, EJBException, RemoteException @@ -346,9 +353,11 @@ protected void removeBean(EJBLocalRemoteObject ejbo, Method removeMethod, * Note: EJB2.0 section 18.3.1 says that discarding an EJB * means that no methods other than finalize() should be invoked on it. */ + @Override protected void forceDestroyBean(EJBContextImpl sc) { - if ( sc.getState() == EJBContextImpl.BeanState.DESTROYED ) - return; + if ( sc.getState() == EJBContextImpl.BeanState.DESTROYED ) { + return; + } // mark context as destroyed sc.setState(EJBContextImpl.BeanState.DESTROYED); @@ -361,10 +370,12 @@ protected void forceDestroyBean(EJBContextImpl sc) { /** * Called when a remote invocation arrives for an EJB. */ + @Override protected EJBObjectImpl getEJBObjectImpl(byte[] instanceKey) { return theEJBObjectImpl; } + @Override EJBObjectImpl getEJBRemoteBusinessObjectImpl(byte[] instanceKey) { return theRemoteBusinessObjectImpl; } @@ -373,6 +384,7 @@ EJBObjectImpl getEJBRemoteBusinessObjectImpl(byte[] instanceKey) { * Called from EJBLocalObjectImpl.getLocalObject() while deserializing * a local object reference. */ + @Override protected EJBLocalObjectImpl getEJBLocalObjectImpl(Object key) { return theEJBLocalObjectImpl; } @@ -381,6 +393,7 @@ protected EJBLocalObjectImpl getEJBLocalObjectImpl(Object key) { * Called from EJBLocalObjectImpl.getLocalObject() while deserializing * a local business object reference. */ + @Override EJBLocalObjectImpl getEJBLocalBusinessObjectImpl(Object key) { return theEJBLocalBusinessObjectImpl; } @@ -389,6 +402,7 @@ EJBLocalObjectImpl getEJBLocalBusinessObjectImpl(Object key) { * Called from EJBLocalObjectImpl.getLocalObject() while deserializing * a local business object reference. */ + @Override EJBLocalObjectImpl getOptionalEJBLocalBusinessObjectImpl(Object key) { return theOptionalEJBLocalBusinessObjectImpl; } @@ -398,6 +412,7 @@ EJBLocalObjectImpl getOptionalEJBLocalBusinessObjectImpl(Object key) { * Called from preInvoke which is called from the EJBObject * for local and remote invocations. */ + @Override protected ComponentContext _getContext(EjbInvocation inv) { try { SessionContextImpl sessionCtx = @@ -409,6 +424,7 @@ protected ComponentContext _getContext(EjbInvocation inv) { } } + @Override protected EJBContextImpl _constructEJBContextImpl(Object instance) { return new SessionContextImpl(instance, this); } @@ -483,7 +499,7 @@ private SessionContextImpl createStatelessEJB() // EJBContext methods not allowed will throw exceptions context.setState(EJBContextImpl.BeanState.POOLED); } catch ( Throwable th ) { - _logger.log(Level.SEVERE, "ejb.stateless_ejbcreate_exception", logParams); + _logger.log(Level.SEVERE, "ejb.stateless_ejbcreate_exception", containerInfo); CreateException creEx = new CreateException("Could not create stateless EJB"); creEx.initCause(th); throw creEx; @@ -503,6 +519,7 @@ private void setSessionContext(Object ejb, SessionContextImpl context) } } + @Override protected void doTimerInvocationInit(EjbInvocation inv, Object primaryKey) throws Exception { // TODO I don't understand this check. What is ejbObject used for? @@ -515,6 +532,7 @@ protected void doTimerInvocationInit(EjbInvocation inv, Object primaryKey) } } + @Override public boolean userTransactionMethodsAllowed(ComponentInvocation inv) { boolean utMethodsAllowed = false; if( isBeanManagedTran ) { @@ -535,12 +553,14 @@ public boolean userTransactionMethodsAllowed(ComponentInvocation inv) { * Called from preInvoke which is called from the EJBObject * for local and remote invocations. */ + @Override public void releaseContext(EjbInvocation inv) { SessionContextImpl sc = (SessionContextImpl)inv.context; // check if the bean was destroyed - if ( sc.getState() == EJBContextImpl.BeanState.DESTROYED ) + if ( sc.getState() == EJBContextImpl.BeanState.DESTROYED ) { return; + } sc.setState(EJBContextImpl.BeanState.POOLED); @@ -552,38 +572,34 @@ public void releaseContext(EjbInvocation inv) { } + @Override protected boolean isIdentical(EJBObjectImpl ejbo, EJBObject other) throws RemoteException { if ( other == ejbo.getStub() ) { return true; - }else { - try { - // other may be a stub for a remote object. - // Although all stateless sessionbeans for a bean type - // are identical, we dont know whether other is of the - // same bean type as ejbo. - if ( getProtocolManager().isIdentical(ejbo.getStub(), other) ) - return true; - else - return false; - } catch ( Exception ex ) { - if(_logger.isLoggable(Level.SEVERE)) { - _logger.log(Level.SEVERE,"ejb.ejb_getstub_exception", - logParams); - _logger.log(Level.SEVERE,"",ex); - } - throw new RemoteException("Error during isIdentical.", ex); + } + try { + // other may be a stub for a remote object. + // Although all stateless sessionbeans for a bean type + // are identical, we dont know whether other is of the + // same bean type as ejbo. + return getProtocolManager().isIdentical(ejbo.getStub(), other); + } catch ( Exception ex ) { + if(_logger.isLoggable(Level.SEVERE)) { + _logger.log(Level.SEVERE,"ejb.ejb_getstub_exception", containerInfo); + _logger.log(Level.SEVERE,"",ex); } + throw new RemoteException("Error during isIdentical.", ex); } - } /** * Check if the given EJBObject/LocalObject has been removed. * @exception NoSuchObjectLocalException if the object has been removed. */ + @Override protected void checkExists(EJBLocalRemoteObject ejbObj) { // For stateless session beans, EJBObject/EJBLocalObj are never removed. @@ -591,16 +607,19 @@ protected void checkExists(EJBLocalRemoteObject ejbObj) } + @Override protected void afterBegin(EJBContextImpl context) { // Stateless SessionBeans cannot implement SessionSynchronization!! // EJB2.0 Spec 7.8. } + @Override protected void beforeCompletion(EJBContextImpl context) { // Stateless SessionBeans cannot implement SessionSynchronization!! // EJB2.0 Spec 7.8. } + @Override protected void afterCompletion(EJBContextImpl ctx, int status) { // Stateless SessionBeans cannot implement SessionSynchronization!! // EJB2.0 Spec 7.8. @@ -609,6 +628,7 @@ protected void afterCompletion(EJBContextImpl ctx, int status) { } // default + @Override public boolean passivateEJB(ComponentContext context) { return false; } @@ -616,15 +636,8 @@ public boolean passivateEJB(ComponentContext context) { // default public void activateEJB(Object ctx, Object instanceKey) {} -/** TODO ??? - public void appendStats(StringBuffer sbuf) { - sbuf.append("\nStatelessContainer: ") - .append("CreateCount=").append(statCreateCount).append("; ") - .append("RemoveCount=").append(statRemoveCount).append("; ") - .append("]"); - } -**/ + @Override protected void doConcreteContainerShutdown(boolean appBeingUndeployed) { try { @@ -666,6 +679,7 @@ protected class SessionContextFactory implements ObjectFactory { + @Override public Object create(Object param) { try { return createStatelessEJB(); @@ -674,6 +688,7 @@ public Object create(Object param) { } } + @Override public void destroy(Object obj) { SessionContextImpl sessionCtx = (SessionContextImpl) obj; // Note: stateless SessionBeans cannot have incomplete transactions diff --git a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/InterceptorManager.java b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/InterceptorManager.java index 306895c172bb..23b20b34b0d2 100644 --- a/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/InterceptorManager.java +++ b/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/interceptors/InterceptorManager.java @@ -62,20 +62,20 @@ public class InterceptorManager { // Set when initializing interceptors for a non-ejb private InterceptorInfo interceptorInfo; - private ClassLoader loader; + private final ClassLoader loader; - private Class beanClass; + private final Class beanClass; - private String beanClassName; + private final String beanClassName; - private Logger _logger; + private final Logger _logger; private Class[] interceptorClasses; private Class[] serializableInterceptorClasses; - private Map instanceIndexMap - = new HashMap(); + private final Map instanceIndexMap + = new HashMap<>(); private boolean interceptorsExists; @@ -88,7 +88,7 @@ public class InterceptorManager { // Optionally specified delegate to be set on SystemInterceptorProxy private Object runtimeInterceptor; - List frameworkInterceptors = new LinkedList(); + List frameworkInterceptors = new LinkedList<>(); public InterceptorManager(Logger _logger, BaseContainer container, @@ -191,7 +191,7 @@ public InterceptorManager.InterceptorChain getAroundInvokeChain( MethodDescriptor mDesc, Method beanMethod) { ArrayList interceptors = - new ArrayList(); + new ArrayList<>(); for(InterceptorDescriptor interceptor : frameworkInterceptors) { Set aroundInvokeDescs = @@ -252,7 +252,7 @@ public InterceptorManager.InterceptorChain getAroundTimeoutChain( ArrayList interceptors = - new ArrayList(); + new ArrayList<>(); for(InterceptorDescriptor interceptor : frameworkInterceptors) { @@ -279,7 +279,7 @@ public InterceptorManager.InterceptorChain getAroundTimeoutChain( List list = (ejbDesc != null) ? ejbDesc.getAroundTimeoutInterceptors(mDesc) : - new LinkedList(); + new LinkedList<>(); for (EjbInterceptor interceptor : list) { String className = interceptor.getInterceptorClassName(); @@ -475,7 +475,6 @@ private void initInterceptorClasses(Set> classes) throws Exception { serializableInterceptorClasses = new Class[size]; int index = 0; for (Class interClass : classes) { - interceptorClasses[index] = interClass; serializableInterceptorClasses[index] = interClass; instanceIndexMap.put(interClass.getName(), index); @@ -573,7 +572,7 @@ private void initEjbCallbackIndices() private void initCallbackIndices(List callbackList, CallbackType callbackType) throws Exception { - ArrayList callbacks = new ArrayList(); + ArrayList callbacks = new ArrayList<>(); int index = callbackType.ordinal(); @@ -614,7 +613,7 @@ private List createCallbackInterceptors(CallbackType eventT private List createCallbackInterceptors(CallbackType eventType, InterceptorDescriptor inter, ClassLoader classLoaderToUse) throws Exception { - List callbackList = new ArrayList(); + List callbackList = new ArrayList<>(); List orderedCallbackMethods = inter.getOrderedCallbackDescriptors(eventType, classLoaderToUse); @@ -758,7 +757,7 @@ private String getInternalErrorString(String className) { public interface AroundInvokeContext extends InvocationContext { - public Object[] getInterceptorInstances(); + Object[] getInterceptorInstances(); /** * Called from Interceptor Chain to invoke the actual bean method. @@ -768,13 +767,13 @@ public interface AroundInvokeContext extends InvocationContext { * interceptor code, so it must not be changed in order for any exception * handling logic in that code to function properly. */ - public Object invokeBeanMethod() + Object invokeBeanMethod() throws Throwable; } public interface InterceptorChain { - public Object invokeNext(int index, AroundInvokeContext invCtx) + Object invokeNext(int index, AroundInvokeContext invCtx) throws Throwable; } diff --git a/appserver/ejb/ejb-full-container/src/main/java/org/glassfish/ejb/persistent/timer/PersistentEJBTimerService.java b/appserver/ejb/ejb-full-container/src/main/java/org/glassfish/ejb/persistent/timer/PersistentEJBTimerService.java index da973f060f8d..33f1dd0a5337 100755 --- a/appserver/ejb/ejb-full-container/src/main/java/org/glassfish/ejb/persistent/timer/PersistentEJBTimerService.java +++ b/appserver/ejb/ejb-full-container/src/main/java/org/glassfish/ejb/persistent/timer/PersistentEJBTimerService.java @@ -26,7 +26,6 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -76,7 +75,7 @@ */ public class PersistentEJBTimerService extends EJBTimerService { - private TimerLocal timerLocal_; + private final TimerLocal timerLocal_; private static final Logger logger = LogDomains.getLogger(PersistentEJBTimerService.class, LogDomains.EJB_LOGGER); @@ -160,6 +159,7 @@ private void initProperties() { /** * Provide a count of timers owned by each server */ + @Override public String[] listTimers( String[] serverIds ) { String[] totalTimers = null; try { @@ -177,6 +177,7 @@ public String[] listTimers( String[] serverIds ) { /** * Take ownership of another server's timers. */ + @Override public int migrateTimers(String fromOwnerId) { String ownerIdOfThisServer = getOwnerIdOfThisServer(); @@ -276,6 +277,7 @@ public int migrateTimers(String fromOwnerId) { } //migrateTimers() + @Override public boolean isPersistent() { return true; } @@ -419,7 +421,7 @@ private Set _restoreTimers(Set timersEligibleForRestorat Map timersToRestore = new HashMap(); Set timerIdsToRemove = new HashSet(); - Set result = new HashSet(); + Set result = new HashSet<>(); for(TimerState timer: timersEligibleForRestoration) { @@ -452,7 +454,7 @@ private Set _restoreTimers(Set timersEligibleForRestorat // an entity bean. That allows us to lazily load the underlying // blob for stateless session and message-driven bean timers. Object timedObjectPrimaryKey = null; - if( container.getContainerType() == BaseContainer.ContainerType.ENTITY) { + if (container.getContainerInfo().type == BaseContainer.ContainerType.ENTITY) { timedObjectPrimaryKey = timer.getTimedObjectPrimaryKey(); } @@ -570,16 +572,13 @@ private Set _restoreTimers(Set timersEligibleForRestorat timerLocal_.remove(timerIdsToRemove); } - for(Iterator entries = timersToRestore.entrySet().iterator(); - entries.hasNext(); ) { - Map.Entry next = (Map.Entry) entries.next(); + for (Object element : timersToRestore.entrySet()) { + Map.Entry next = (Map.Entry) element; RuntimeTimerState nextTimer = (RuntimeTimerState) next.getKey(); - TimerPrimaryKey timerId = nextTimer.getTimerId(); + TimerPrimaryKey timerId = nextTimer.getTimerId(); Date expiration = (Date) next.getValue(); scheduleTask(timerId, expiration); - logger.log(Level.FINE, - "EJBTimerService.restoreTimers(), scheduling timer " + - nextTimer); + logger.log(Level.FINE, "EJBTimerService.restoreTimers(), scheduling timer " + nextTimer); } logger.log(Level.FINE, "DONE EJBTimerService.restoreTimers()"); @@ -708,14 +707,14 @@ protected Map recoverAndCreateSchedules( Map> schedules, boolean deploy) { - Map result = new HashMap(); + Map result = new HashMap<>(); TransactionManager tm = ejbContainerUtil.getTransactionManager(); try { tm.begin(); Set timers = _restoreTimers( - (Set)timerLocal_.findActiveTimersOwnedByThisServerByContainer(containerId)); + timerLocal_.findActiveTimersOwnedByThisServerByContainer(containerId)); if (timers.size() > 0) { logger.log(Level.FINE, "Found " + timers.size() + @@ -756,9 +755,10 @@ protected Map recoverAndCreateSchedules( * Called in a clustered environment to eagerly create automatic persistent timers * on the specific server instance. */ + @Override public void createSchedulesOnServer(EjbDescriptor ejbDescriptor, String server_name) { Map> schedules = - new HashMap>(); + new HashMap<>(); for (ScheduledTimerDescriptor schd : ejbDescriptor.getScheduledTimerDescriptors()) { MethodDescriptor method = schd.getTimeoutMethod(); if (method != null && schd.getPersistent()) { @@ -768,7 +768,7 @@ public void createSchedulesOnServer(EjbDescriptor ejbDescriptor, String server_n List list = schedules.get(method); if (list == null) { - list = new ArrayList(); + list = new ArrayList<>(); schedules.put(method, list); } list.add(schd); @@ -794,6 +794,7 @@ public void createSchedulesOnServer(EjbDescriptor ejbDescriptor, String server_n * Only persistent schedule based timers for the containerId that has no timers associated * with it, will be created. And no timers will be scheduled. */ + @Override public void createSchedules(long containerId, long applicationId, Map> methodDescriptorSchedules, String server_name) { TransactionManager tm = ejbContainerUtil.getTransactionManager(); @@ -894,7 +895,7 @@ protected Collection getTimerIds(long containerId, Object timed // timer cache to avoid some database access in PE/SE, or // even in EE with the appropriate consistency tradeoff. - Collection timerIdsForTimedObject = new HashSet(); + Collection timerIdsForTimedObject = new HashSet<>(); if (timedObjectPrimaryKey == null) { timerIdsForTimedObject = timerLocal_.findActiveTimerIdsByContainer(containerId); @@ -921,7 +922,7 @@ protected Collection getTimerIds(long containerId, Object timed */ @Override protected Collection getTimerIds(Collection containerIds) { - Collection timerIds = new HashSet(super.getTimerIds(containerIds)); + Collection timerIds = new HashSet<>(super.getTimerIds(containerIds)); timerIds.addAll(timerLocal_.findActiveTimerIdsByContainers(containerIds)); return timerIds; } @@ -1486,6 +1487,7 @@ private static boolean isUpgrade(String resource, EjbTimerService _ejbt, File ro success = h.executeDDLStatement( dir.getCanonicalPath() + "/ejbtimer_upgrade_", resource); ConfigSupport.apply(new SingleConfigCode() { + @Override public Object run(Property p) throws PropertyVetoException, TransactionFailure { p.setValue("true"); return null; diff --git a/appserver/persistence/entitybean-container/src/main/java/org/glassfish/persistence/ejb/entitybean/container/EntityContainer.java b/appserver/persistence/entitybean-container/src/main/java/org/glassfish/persistence/ejb/entitybean/container/EntityContainer.java index 7d8430179305..cef20a5ac6a9 100644 --- a/appserver/persistence/entitybean-container/src/main/java/org/glassfish/persistence/ejb/entitybean/container/EntityContainer.java +++ b/appserver/persistence/entitybean-container/src/main/java/org/glassfish/persistence/ejb/entitybean/container/EntityContainer.java @@ -169,7 +169,8 @@ public class EntityContainer implements CacheListener { - private ThreadLocal ejbServant = new ThreadLocal() { + private final ThreadLocal ejbServant = new ThreadLocal() { + @Override protected Object initialValue() { return null; } @@ -276,10 +277,10 @@ protected EntityContainer(ContainerType containerType, EjbDescriptor desc, Class super.createCallFlowAgent( isContainerManagedPers ? ComponentType.CMP : ComponentType.BMP); - _logger.log(Level.FINE,"[EntityContainer] Created EntityContainer: " - + logParams[0]); + _logger.log(Level.FINE,"[EntityContainer] Created EntityContainer: {0}", containerInfo); } + @Override protected void preInitialize(EjbDescriptor desc, ClassLoader loader) { EjbEntityDescriptor ed = (EjbEntityDescriptor)desc; isReentrant = ed.isReentrant(); @@ -402,6 +403,7 @@ public void cancelTimerTasks() { this.idleBeansPassivator = null; } + @Override protected InvocationInfo postProcessInvocationInfo( InvocationInfo invInfo) { Method method = invInfo.method; @@ -431,6 +433,7 @@ protected InvocationInfo postProcessInvocationInfo( /** * Called from the ContainerFactory during initialization. */ + @Override protected void initializeHome() throws Exception { @@ -452,6 +455,7 @@ protected void initializeHome() registerMonitorableComponents(); } + @Override protected void registerMonitorableComponents() { super.registerMonitorableComponents(); if (readyStore != null) { @@ -490,11 +494,13 @@ protected void registerMonitorableComponents() { _logger.log(Level.FINE, "[Entity Container] registered monitorable"); } + @Override protected EjbMonitoringStatsProvider getMonitoringStatsProvider( String appName, String modName, String ejbName) { return new EntityBeanStatsProvider(this, getContainerId(), appName, modName, ejbName); } + @Override public void onReady() { } @@ -557,6 +563,7 @@ public long getReadyCount() { /** * Implementation of BaseContainer method. This is never called. */ + @Override protected EJBObjectImpl createEJBObjectImpl() throws CreateException, RemoteException { @@ -564,6 +571,7 @@ protected EJBObjectImpl createEJBObjectImpl() "INTERNAL ERROR: EntityContainer.createEJBObject() called"); } + @Override protected EJBLocalObjectImpl createEJBLocalObjectImpl() throws CreateException { @@ -575,6 +583,7 @@ protected EJBLocalObjectImpl createEJBLocalObjectImpl() /** * Called when a remote EjbInvocation arrives for an EJB. */ + @Override protected EJBObjectImpl getEJBObjectImpl(byte[] streamKey) { // First get the primary key of the EJB Object primaryKey; @@ -592,6 +601,7 @@ protected EJBObjectImpl getEJBObjectImpl(byte[] streamKey) { * Called from EJBLocalObjectImpl.getLocalObject() while deserializing * a local object reference. */ + @Override protected EJBLocalObjectImpl getEJBLocalObjectImpl(Object key) { return internalGetEJBLocalObjectImpl(key); } @@ -600,6 +610,7 @@ protected EJBLocalObjectImpl getEJBLocalObjectImpl(Object key) { * Called from BaseContainer.preInvoke which is called from the EJBObject * for local and remote invocations, and from the EJBHome for create/find. */ + @Override protected ComponentContext _getContext(EjbInvocation inv) { if ( inv.invocationInfo.isCreateHomeFinder ) { // create*, find*, home methods @@ -614,10 +625,11 @@ protected ComponentContext _getContext(EjbInvocation inv) { // context, so no need to synchronize. context.setState(BeanState.INVOKING); - if ( inv.invocationInfo.startsWithCreate ) + if ( inv.invocationInfo.startsWithCreate ) { preCreate(inv, context); - else if ( inv.invocationInfo.startsWithFind ) + } else if ( inv.invocationInfo.startsWithFind ) { preFind(inv, context); + } context.setLastTransactionStatus(-1); @@ -632,15 +644,18 @@ else if ( inv.invocationInfo.startsWithFind ) // If we would invoke the EJB with the client's Tx, // try to get an EJB with that incomplete Tx. EntityContextImpl context = null; - if ( willInvokeWithClientTx(inv) ) + if ( willInvokeWithClientTx(inv) ) { context = getEJBWithIncompleteTx(inv); - if ( context == null ) + } + if ( context == null ) { context = getReadyEJB(inv); + } synchronized ( context ) { - if ( context.isInState(BeanState.INVOKING) && !isReentrant ) + if ( context.isInState(BeanState.INVOKING) && !isReentrant ) { throw new EJBException( "EJB is already executing another request"); + } if (context.isInState(BeanState.POOLED) || context.isInState(BeanState.DESTROYED)) { // somehow a concurrent thread must have changed state. @@ -686,12 +701,14 @@ protected boolean willInvokeWithClientTx(EjbInvocation inv) { * This is called from BaseContainer.postInvoke after * EntityContainer.preInvokeTx has been called. */ + @Override public void releaseContext(EjbInvocation inv) { EntityContextImpl context = (EntityContextImpl)inv.context; boolean decrementedCalls = false; // End of IAS 4661771 - if ( context.isInState(BeanState.DESTROYED) ) + if ( context.isInState(BeanState.DESTROYED) ) { return; + } try { if ( context.hasReentrantCall() ) { @@ -766,10 +783,11 @@ public void releaseContext(EjbInvocation inv) { context.decrementCalls(); context.setLastTransactionStatus(-1); if ( status == -1 || status == Status.STATUS_COMMITTED - || status == Status.STATUS_NO_TRANSACTION ) + || status == Status.STATUS_NO_TRANSACTION ) { addReadyEJB(context); - else + } else { passivateAndPoolEJB(context); + } } else { // biz methods and ejbCreate // The EJB is still associated with a Tx. @@ -779,8 +797,7 @@ public void releaseContext(EjbInvocation inv) { doFlush( inv ); } } catch ( Exception ex ) { - _logger.log(Level.FINE, "entitybean.container.release_context_exception", - logParams); + _logger.log(Level.FINE, "entitybean.container.release_context_exception", containerInfo); _logger.log(Level.FINE, "",ex); throw new EJBException(ex); } finally { @@ -808,12 +825,14 @@ protected void preCreate(EjbInvocation inv, EntityContextImpl context) { * is called. * Note: postCreate will not be called if ejbCreate throws an exception */ + @Override public void postCreate(EjbInvocation inv, Object primaryKey) throws CreateException { - if ( primaryKey == null ) + if ( primaryKey == null ) { throw new EJBException( "Null primary key returned by ejbCreate method"); + } if ( (isRemote) && (!inv.isLocal) ) { // remote EjbInvocation: create EJBObject @@ -845,6 +864,7 @@ public void postCreate(EjbInvocation inv, Object primaryKey) //Called from EJB(Local)HomeInvocationHandler //Note: preFind is already called from getContext + @Override protected Object invokeFindByPrimaryKey(Method method, EjbInvocation inv, Object[] args) throws Throwable @@ -854,12 +874,14 @@ protected Object invokeFindByPrimaryKey(Method method, return postFind(inv, pKeys, null); } + @Override protected void authorizeLocalGetPrimaryKey(EJBLocalRemoteObject ejbObj) throws EJBException { authorizeLocalMethod(BaseContainer.EJBLocalObject_getPrimaryKey); checkExists(ejbObj); } + @Override protected void authorizeRemoteGetPrimaryKey(EJBLocalRemoteObject ejbObj) throws RemoteException { authorizeRemoteMethod(BaseContainer.EJBObject_getPrimaryKey); @@ -890,6 +912,7 @@ protected void preFind(EjbInvocation inv, EntityContextImpl context) { /** * Called from CMP PersistentManager */ + @Override public void preSelect() throws jakarta.ejb.EJBException { // if the ejbSelect is being invoked with the client's transaction, @@ -919,6 +942,7 @@ public void preSelect() * after ejb.ejbFind**() has been called. * Note: postFind will not be called if ejbFindXXX throws an exception */ + @Override public Object postFind(EjbInvocation inv, Object primaryKeys, Object[] findParams) throws FinderException @@ -933,10 +957,11 @@ public Object postFind(EjbInvocation inv, Object primaryKeys, Object primaryKey = e.nextElement(); Object ref; if( primaryKey != null ) { - if ( inv.isLocal ) + if ( inv.isLocal ) { ref = getEJBLocalObjectForPrimaryKey(primaryKey); - else + } else { ref = getEJBObjectStub(primaryKey, null); + } objrefs.add(ref); } else { objrefs.add(null); @@ -952,10 +977,11 @@ public Object postFind(EjbInvocation inv, Object primaryKeys, Object primaryKey = it.next(); Object ref; if( primaryKey != null ) { - if ( inv.isLocal ) + if ( inv.isLocal ) { ref = getEJBLocalObjectForPrimaryKey(primaryKey); - else + } else { ref = getEJBObjectStub(primaryKey, null); + } objrefs.add(ref); } else { objrefs.add(null); @@ -964,10 +990,11 @@ public Object postFind(EjbInvocation inv, Object primaryKeys, return objrefs; } else { if( primaryKeys != null ) { - if ( inv.isLocal ) + if ( inv.isLocal ) { return getEJBLocalObjectForPrimaryKey(primaryKeys); - else + } else { return getEJBObjectStub(primaryKeys, null); + } } else { return null; } @@ -981,6 +1008,7 @@ public Object postFind(EjbInvocation inv, Object primaryKeys, * for a primary key (home.findByPrimaryKey cant be used because it may * not run in the same tx). */ + @Override public EJBObject getEJBObjectForPrimaryKey(Object pkey) { // create stub without creating EJBObject return getEJBObjectStub(pkey, null); @@ -1027,6 +1055,7 @@ public EJBObject getEJBObjectForPrimaryKey(Object pkey) { * @return The EJBLocalObject associated with the PK or null if it is cascade deleted. * */ + @Override public EJBLocalObject getEJBLocalObjectForPrimaryKey (Object pkey, EJBContext ctx) { // EntityContextImpl should always be used in conjunction with EntityContainer so we can always cast @@ -1045,8 +1074,7 @@ public EJBObject getEJBObjectForPrimaryKey(Object pkey) { ActiveTxCache activeTxCache = (current == null) ? null : (ActiveTxCache) (ejbContainerUtilImpl.getActiveTxCache(current)); if (activeTxCache != null) { - EntityContextImpl ctx2 = (EntityContextImpl) - activeTxCache.get(this, pkey); + EntityContextImpl ctx2 = activeTxCache.get(this, pkey); if ((ctx2 != null) && (ctx2.isCascadeDeleteAfterSuperEJBRemove())) { return null; @@ -1065,6 +1093,7 @@ public EJBObject getEJBObjectForPrimaryKey(Object pkey) { * for a primary key (findByPrimaryKey cant be used because it may * not run in the same tx). */ + @Override public EJBLocalObject getEJBLocalObjectForPrimaryKey(Object pkey) { EJBLocalObjectImpl localObjectImpl = internalGetEJBLocalObjectImpl(pkey); @@ -1074,6 +1103,7 @@ public EJBLocalObject getEJBLocalObjectForPrimaryKey(Object pkey) { // Called from EJBHomeImpl.remove(primaryKey), // EJBLocalHomeImpl.remove(primaryKey) + @Override protected void doEJBHomeRemove(Object primaryKey, Method removeMethod, boolean local) throws RemoveException, EJBException, RemoteException @@ -1090,6 +1120,7 @@ protected void doEJBHomeRemove(Object primaryKey, Method removeMethod, // Called from EJBObjectImpl.remove, EJBLocalObjectImpl.remove, // and removeBean above. + @Override protected void removeBean(EJBLocalRemoteObject ejbo, Method removeMethod, boolean local) throws RemoveException, EJBException, RemoteException @@ -1111,7 +1142,7 @@ protected void removeBean(EJBLocalRemoteObject ejbo, Method removeMethod, preInvoke(i); removeBean(i); } catch(Exception e) { - _logger.log(Level.SEVERE,"entitybean.container.preinvoke_exception",logParams); + _logger.log(Level.SEVERE,"entitybean.container.preinvoke_exception", containerInfo); _logger.log(Level.SEVERE,"",e); i.exception = e; } finally { @@ -1177,14 +1208,14 @@ protected void removeBean(EjbInvocation inv) cancelTimers(primaryKey); } catch ( RemoveException ex ) { if(_logger.isLoggable(Level.FINE)) { - _logger.log(Level.FINE,"entitybean.container.local_remove_exception",logParams); + _logger.log(Level.FINE,"entitybean.container.local_remove_exception", containerInfo); _logger.log(Level.FINE,"",ex); } throw ex; } catch ( Exception ex ) { if(_logger.isLoggable(Level.FINE)) { - _logger.log(Level.FINE,"entitybean.container.remove_bean_exception",logParams); + _logger.log(Level.FINE,"entitybean.container.remove_bean_exception", containerInfo); _logger.log(Level.FINE,"",ex); } throw new EJBException(ex); @@ -1219,6 +1250,7 @@ private void removeEJBObjectFromStore(Object primaryKey, boolean decrementRefCou * Remove a bean. Used by the PersistenceManager. * This is needed because the PM's remove must bypass tx/security checks. */ + @Override public void removeBeanUnchecked(EJBLocalObject localObj) { // First convert client EJBLocalObject to EJBLocalObjectImpl EJBLocalObjectImpl localObjectImpl = @@ -1231,6 +1263,7 @@ public void removeBeanUnchecked(EJBLocalObject localObj) { * Remove a bean. Used by the PersistenceManager. * This is needed because the PM's remove must bypass tx/security checks. */ + @Override public void removeBeanUnchecked(Object primaryKey) { EJBLocalRemoteObject ejbo; if ( isLocal ) { @@ -1336,6 +1369,7 @@ private void internalRemoveBeanUnchecked(EJBLocalRemoteObject localRemoteObj, * from BaseContainer.postInvokeTx, getReadyEJB, * afterBegin, beforeCompletion, passivateEJB. */ + @Override protected void forceDestroyBean(EJBContextImpl ctx) { // Something bad happened (such as a RuntimeException), // so kill the bean and let it be GC'ed @@ -1394,6 +1428,7 @@ protected void forceDestroyBean(EJBContextImpl ctx) { // Called before invoking a bean with no Tx or with a new Tx. // Check if the bean is associated with an unfinished tx. + @Override protected void checkUnfinishedTx(Transaction prevTx, EjbInvocation inv) { try { @@ -1415,6 +1450,7 @@ protected void checkUnfinishedTx(Transaction prevTx, EjbInvocation inv) { * Called before executing non-business methods of EJBLocalObject. * @exception NoSuchObjectLocalException if the object has been removed. */ + @Override protected void checkExists(EJBLocalRemoteObject ejbObj) { // Need to call ejbLoad to see if persistent state is removed. // However, the non-business methods dont have a transaction attribute. @@ -1422,12 +1458,14 @@ protected void checkExists(EJBLocalRemoteObject ejbObj) { } // Called from BaseContainer.SyncImpl + @Override protected void afterBegin(EJBContextImpl ctx) { EntityContextImpl context = (EntityContextImpl)ctx; // Note: EntityBeans are not allowed to be TX_BEAN_MANAGED - if ( context.isInState(BeanState.DESTROYED) ) + if ( context.isInState(BeanState.DESTROYED) ) { return; + } if ( !containerStateManager.isNullEJBObject(context) || !containerStateManager.isNullEJBLocalObject(context) ) { @@ -1463,6 +1501,7 @@ protected void afterBegin(EJBContextImpl ctx) { } // Called from BaseContainer.SyncImpl.beforeCompletion, postInvokeNoTx + @Override protected void beforeCompletion(EJBContextImpl ctx) { EntityContextImpl context = (EntityContextImpl)ctx; if ( context.isInState(BeanState.DESTROYED) ) { @@ -1523,6 +1562,7 @@ private void enlistResourcesAndStore(EntityContextImpl context) { // getting reply from bean). So whatever is done here *MUST* be // consistent with releaseContext, and the bean should end up in // the correct state. + @Override protected void afterCompletion(EJBContextImpl ctx, int status) { EntityContextImpl context = (EntityContextImpl)ctx; if ( context.isInState(BeanState.DESTROYED) ) { @@ -1670,6 +1710,7 @@ private final boolean isHomeFinder(Method method) { } // CacheListener interface + @Override public void trimEvent(Object primaryKey, Object context) { synchronized (asyncTaskSemaphore) { passivationCandidates.add(context); @@ -1692,6 +1733,7 @@ private class ASyncPassivator implements Runnable { + @Override public void run() { final Thread currentThread = Thread.currentThread(); final ClassLoader previousClassLoader = @@ -1706,6 +1748,7 @@ public void run() { } else { java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { + @Override public java.lang.Object run() { currentThread.setContextClassLoader(myClassLoader); return null; @@ -1743,6 +1786,7 @@ public java.lang.Object run() { } else { java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { + @Override public java.lang.Object run() { currentThread.setContextClassLoader(previousClassLoader); return null; @@ -1755,6 +1799,7 @@ public java.lang.Object run() { } // Called from AbstractCache + @Override protected boolean passivateEJB(ComponentContext ctx) { if (containerState != CONTAINER_STARTED) { return false; @@ -1779,8 +1824,9 @@ protected boolean passivateEJB(ComponentContext ctx) { boolean wasPassivated = false; // check state after locking ctx - if ( !context.isInState(BeanState.READY) ) + if ( !context.isInState(BeanState.READY) ) { return false; + } try { invocationManager.preInvoke(inv); @@ -1861,8 +1907,7 @@ protected boolean passivateEJB(ComponentContext ctx) { } return localObjImpl; } catch ( Exception ex ) { - _logger.log(Level.SEVERE,"entitybean.container.get_ejb_local_object_exception", - logParams); + _logger.log(Level.SEVERE,"entitybean.container.get_ejb_local_object_exception", containerInfo); _logger.log(Level.SEVERE,"",ex); throw new EJBException(ex); } @@ -1968,7 +2013,7 @@ private EJBObjectImpl internalGetEJBObjectImpl(Object primaryKey, return ejbObjImpl; } catch ( Exception ex ) { - _logger.log(Level.FINE, "entitybean.container.get_ejb_context_exception", logParams); + _logger.log(Level.FINE, "entitybean.container.get_ejb_context_exception", containerInfo); _logger.log(Level.FINE,"",ex); throw new EJBException(ex); } @@ -2004,8 +2049,9 @@ protected void addPooledEJB(EntityContextImpl context) { // called from addReadyEJB and afterCompletion protected void passivateAndPoolEJB(EntityContextImpl context) { - if ( context.isInState(BeanState.DESTROYED) || context.isInState(BeanState.POOLED) ) + if ( context.isInState(BeanState.DESTROYED) || context.isInState(BeanState.POOLED) ) { return; + } // if ( context.isPooled() ) { // context.isPooled(false); @@ -2214,12 +2260,14 @@ private class IdleBeansPassivator this.cache = cache; } + @Override public void run() { if (timerValid) { cache.trimExpiredEntries(Integer.MAX_VALUE); } } + @Override public boolean cancel() { cache = null; return super.cancel(); @@ -2240,6 +2288,7 @@ private static class EJBTxKey { this.pkHashCode = primaryKey.hashCode(); } + @Override public final int hashCode() { // Note: this hashcode need not be persistent across // activations of this process. @@ -2251,6 +2300,7 @@ public final int hashCode() { return pkHashCode; } + @Override public final boolean equals(Object obj) { if ( !(obj instanceof EJBTxKey) ) { return false; @@ -2345,38 +2395,34 @@ public PoolProperties(EntityContainer entityContainer) { } //PoolProperties + @Override protected boolean isIdentical(EJBObjectImpl ejbObjImpl, EJBObject other) throws RemoteException { - if ( other == ejbObjImpl.getStub() ) { + if (other == ejbObjImpl.getStub()) { return true; - } else { - try { - // EJBObject may be a remote object. - // Compare homes. See EJB2.0 spec section 9.8. - if ( !getProtocolManager().isIdentical(ejbHomeStub, - other.getEJBHome())) - return false; - - // Compare primary keys. - if (!ejbObjImpl.getPrimaryKey().equals(other.getPrimaryKey())) { - return false; - } + } + try { + // EJBObject may be a remote object. + // Compare homes. See EJB2.0 spec section 9.8. + if (!getProtocolManager().isIdentical(ejbHomeStub, other.getEJBHome())) { + return false; + } - return true; - } catch ( Exception ex ) { - _logger.log(Level.INFO, "entitybean.container.ejb_comparison_exception", - logParams); - _logger.log(Level.INFO, "", ex); - throw new RemoteException("Exception in isIdentical()", ex); + // Compare primary keys. + if (!ejbObjImpl.getPrimaryKey().equals(other.getPrimaryKey())) { + return false; } + + return true; + } catch (Exception ex) { + _logger.log(Level.INFO, "entitybean.container.ejb_comparison_exception", containerInfo); + _logger.log(Level.INFO, "", ex); + throw new RemoteException("Exception in isIdentical()", ex); } } - protected void callEJBLoad(EntityBean ejb, EntityContextImpl context, - boolean activeTx) - throws Exception - { + protected void callEJBLoad(EntityBean ejb, EntityContextImpl context, boolean activeTx) throws Exception { try { context.setInEjbLoad(true); ejb.ejbLoad(); @@ -2389,9 +2435,8 @@ protected void callEJBLoad(EntityBean ejb, EntityContextImpl context, } } - protected void callEJBStore(EntityBean ejb, EntityContextImpl context) - throws Exception - { + + protected void callEJBStore(EntityBean ejb, EntityContextImpl context) throws Exception { try { context.setInEjbStore(true); ejb.ejbStore(); @@ -2401,8 +2446,8 @@ protected void callEJBStore(EntityBean ejb, EntityContextImpl context) } } - protected void callEJBRemove(EntityBean ejb, EntityContextImpl context) - throws Exception { + + protected void callEJBRemove(EntityBean ejb, EntityContextImpl context) throws Exception { Exception exc = null; try { // TODO - check if it is needed: context.setInEjbRemove(true); @@ -2422,6 +2467,7 @@ protected void callEJBRemove(EntityBean ejb, EntityContextImpl context) } } + @Override protected void doTimerInvocationInit(EjbInvocation inv, Object primaryKey) throws Exception { if( isRemote ) { @@ -2437,6 +2483,7 @@ protected void doTimerInvocationInit(EjbInvocation inv, Object primaryKey) } } + @Override protected void doConcreteContainerShutdown(boolean appBeingUndeployed) { String ejbName = ejbDescriptor.getName(); @@ -2529,12 +2576,13 @@ protected EntityContextImpl createEntityContextInstance(EntityBean ejb, private class EntityContextFactory implements ObjectFactory { - private EntityContainer entityContainer; + private final EntityContainer entityContainer; public EntityContextFactory(EntityContainer entityContainer) { this.entityContainer = entityContainer; } + @Override public Object create(Object param) { EntityContextImpl entityCtx = null; EjbInvocation ejbInv = null; @@ -2570,6 +2618,7 @@ public Object create(Object param) { } + @Override public void destroy(Object object) { if (object == null) { //means that this is called through forceDestroyBean @@ -2752,6 +2801,7 @@ protected void removeContextFromReadyStore(Object primaryKey, readyStore.remove(primaryKey, context); } + @Override protected void addProxyInterfacesSetClass(Set proxyInterfacesSet, boolean local) { if( ejbDescriptor.getIASEjbExtraDescriptors().isIsReadOnlyBean() ) { if (local) { @@ -2763,6 +2813,7 @@ protected void addProxyInterfacesSetClass(Set proxyInterfacesSet, boolean local) } + @Override protected void doFlush( EjbInvocation inv ) { if( !inv.invocationInfo.flushEnabled || inv.exception != null ) { @@ -2863,10 +2914,12 @@ protected LocalEJBObjectCacheVictimHandler() { } //EJBObjectCacheListener interface + @Override public void handleOverflow(Object key) { doCleanup(key); } + @Override public void handleBatchOverflow(ArrayList paramKeys) { int size = paramKeys.size(); synchronized (lock) { @@ -2889,6 +2942,7 @@ public void handleBatchOverflow(ArrayList paramKeys) { } } + @Override public void run() { final Thread currentThread = Thread.currentThread(); final ClassLoader previousClassLoader = @@ -2902,6 +2956,7 @@ public void run() { } else { java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { + @Override public java.lang.Object run() { currentThread.setContextClassLoader(myClassLoader); return null; @@ -2939,6 +2994,7 @@ public java.lang.Object run() { } else { java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { + @Override public java.lang.Object run() { currentThread.setContextClassLoader(previousClassLoader); return null; @@ -2961,6 +3017,7 @@ protected class EJBObjectCacheVictimHandler protected EJBObjectCacheVictimHandler() { } + @Override protected void doCleanup(Object key) { removeEJBObjectFromStore(key, false); } @@ -2971,48 +3028,57 @@ protected void doCleanup(Object key) { class EntityCacheStatsProvider implements EjbCacheStatsProviderDelegate { - private BaseCache cache; - private int confMaxCacheSize; + private final BaseCache cache; + private final int confMaxCacheSize; EntityCacheStatsProvider(BaseCache cache, int maxCacheSize) { this.cache = cache; this.confMaxCacheSize = maxCacheSize; } + @Override public int getCacheHits() { return ((Integer) cache.getStatByName( Constants.STAT_BASECACHE_HIT_COUNT)).intValue(); } + @Override public int getCacheMisses() { return ((Integer) cache.getStatByName( Constants.STAT_BASECACHE_MISS_COUNT)).intValue(); } + @Override public int getNumBeansInCache() { return cache.getEntryCount(); } + @Override public int getNumExpiredSessionsRemoved() { return 0; } + @Override public int getNumPassivationErrors() { return totalPassivationErrors; } + @Override public int getNumPassivations() { return totalPassivations; } + @Override public int getNumPassivationSuccess() { return totalPassivations - totalPassivationErrors; } + @Override public int getMaxCacheSize() { return this.confMaxCacheSize; } + @Override public void appendStats(StringBuffer sbuf) { sbuf.append("[Cache: ") .append("Size=").append(getNumBeansInCache()).append("; ") @@ -3029,7 +3095,7 @@ public void appendStats(StringBuffer sbuf) { class ActiveTxCache { private EntityContextImpl[] buckets; - private int bucketMask; + private final int bucketMask; ActiveTxCache(int numBuckets) { this.bucketMask = numBuckets - 1; diff --git a/appserver/tests/gftest.sh b/appserver/tests/gftest.sh index 96382a053f2f..0256cc9a3073 100755 --- a/appserver/tests/gftest.sh +++ b/appserver/tests/gftest.sh @@ -49,7 +49,7 @@ if [ ! -z "${JENKINS_HOME}" ] ; then # setup the local repository # with the archived chunk from the pipeline build stage - cat ${WORKSPACE}/bundles/_maven-repo* | tar -xvz -f - --overwrite -m -p -C ${HOME}/.m2/repository + tar -xzf ${WORKSPACE}/bundles/maven-repo.tar.gz --overwrite -m -p -C ${HOME}/.m2/repository echo "Removing old glassfish directory: ${S1AS_HOME}"; rm -rf "${S1AS_HOME}"; fi diff --git a/appserver/tests/quicklook/run_test.sh b/appserver/tests/quicklook/run_test.sh index effa86efaa79..1a0b1b22523a 100755 --- a/appserver/tests/quicklook/run_test.sh +++ b/appserver/tests/quicklook/run_test.sh @@ -26,7 +26,7 @@ copy_ql_results(){ cp ${WORKSPACE}/nucleus/domains/domain1/logs/server.log* ${WORKSPACE}/results fi cp ${TEST_RUN_LOG} ${WORKSPACE}/results/ - tar -cf ${WORKSPACE}/${1}-results.tar.gz ${WORKSPACE}/results + tar -czf ${WORKSPACE}/${1}-results.tar.gz ${WORKSPACE}/results change_junit_report_class_names } diff --git a/appserver/web/weld-integration/src/main/java/org/glassfish/weld/services/ProxyServicesImpl.java b/appserver/web/weld-integration/src/main/java/org/glassfish/weld/services/ProxyServicesImpl.java index 1ccf137adc44..ab18b54793fa 100644 --- a/appserver/web/weld-integration/src/main/java/org/glassfish/weld/services/ProxyServicesImpl.java +++ b/appserver/web/weld-integration/src/main/java/org/glassfish/weld/services/ProxyServicesImpl.java @@ -17,7 +17,7 @@ package org.glassfish.weld.services; -import com.sun.ejb.ClassGenerator; +import com.sun.ejb.codegen.ClassGenerator; import java.security.AccessController; import java.security.PrivilegedAction; diff --git a/etc/docker/Dockerfile b/etc/docker/Dockerfile index 975b6a5cbc4c..d866f41f2875 100644 --- a/etc/docker/Dockerfile +++ b/etc/docker/Dockerfile @@ -56,7 +56,7 @@ ENV JAVA_HOME /usr/lib/jvm/jdk11 ENV MAVEN_HOME /usr/share/maven ENV M2_HOME /usr/share/maven ENV ANT_HOME /usr/share/ant -ENV JAVA_TOOL_OPTIONS "-Xmx2G" +ENV JAVA_TOOL_OPTIONS "-Xmx1G -Xss768k" ENV HOME /home/jenkins WORKDIR /home/jenkins diff --git a/gfbuild.sh b/gfbuild.sh index a3ac016bc637..30762b8edec3 100755 --- a/gfbuild.sh +++ b/gfbuild.sh @@ -67,7 +67,7 @@ archive_bundles(){ } dev_build(){ - mvn -U clean install -Pstaging ${MVN_EXTRA} + mvn -U clean install -Pstaging,fastest -T2C ${MVN_EXTRA} } build_re_dev(){ @@ -83,7 +83,5 @@ fi "$@" if [ ! -z "${JENKINS_HOME}" ] ; then - # archive the local repository org.glassfish.main - # the output is a tar archive split into 1MB chunks. - tar -cz -f - -C ${HOME}/.m2/repository org/glassfish/main | split -b 1m - ${WORKSPACE}/bundles/_maven-repo + tar -c --exclude='*.zip' --exclude='*/main/tests/*' --exclude='*/main/distributions/*' --exclude='*/main/extras/*' --exclude='*/main/admingui/*' --newer-mtime '1 day ago' -C ${HOME}/.m2/repository org/glassfish/main | gzip --fast > ${WORKSPACE}/bundles/maven-repo.tar.gz fi diff --git a/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/generator/ASMClassWriter.java b/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/generator/ASMClassWriter.java index c4283dff6a81..473dc3dab7b9 100644 --- a/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/generator/ASMClassWriter.java +++ b/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/generator/ASMClassWriter.java @@ -17,7 +17,7 @@ package org.glassfish.admin.rest.generator; -import com.sun.ejb.ClassGenerator; +import com.sun.ejb.codegen.ClassGenerator; import com.sun.enterprise.util.SystemPropertyConstants; import java.io.File; diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java index 65c26ece2bbd..32b6c5b33ff2 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java @@ -21,7 +21,6 @@ import com.sun.enterprise.util.i18n.StringManager; import com.sun.enterprise.security.integration.DDPermissionsLoader; import com.sun.enterprise.security.integration.PermsHolder; -import org.glassfish.api.deployment.DeploymentContext; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -41,14 +40,12 @@ import java.net.URLStreamHandler; import java.security.AccessController; import java.security.CodeSource; -import java.security.Permission; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.security.ProtectionDomain; import java.security.SecureClassLoader; import java.security.cert.Certificate; -import java.security.Permissions; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.jar.Attributes; @@ -95,10 +92,10 @@ list of url entries of this class loader. Using LinkedHashSet instead of origina private final Set urlSet = Collections.synchronizedSet(new LinkedHashSet()); /** cache of not found resources */ - private final Map notFoundResources = new ConcurrentHashMap(); + private final Map notFoundResources = new ConcurrentHashMap<>(); /** cache of not found classes */ - private final Map notFoundClasses = new ConcurrentHashMap(); + private final Map notFoundClasses = new ConcurrentHashMap<>(); /** State flag to track whether this instance has been shut off. @@ -115,15 +112,15 @@ list of url entries of this class loader. Using LinkedHashSet instead of origina private volatile String doneSnapshot; /** streams opened by this loader */ - private final Vector streams = new Vector(); + private final Vector streams = new Vector<>(); - private final ArrayList transformers = new ArrayList(1); + private final ArrayList transformers = new ArrayList<>(1); private final static StringManager sm = StringManager.getManager(ASURLClassLoader.class); //holder for declared and ee permissions - private PermsHolder permissionsHolder; + private final PermsHolder permissionsHolder; /** * Constructor. @@ -255,6 +252,7 @@ public void appendURL(File file) throws IOException { * * @param url the URL to be added to the search path of URLs */ + @Override public void addURL(URL url) { appendURL(url); } @@ -321,6 +319,7 @@ public synchronized void appendURL(URL url) { * * @return the urls of this class loader or an empty array */ + @Override public synchronized URL[] getURLs() { URL[] url = null; @@ -390,6 +389,7 @@ public synchronized void refresh() throws IOException { // } } + @Override public void addTransformer(ClassFileTransformer transformer) { transformers.add(transformer); } @@ -399,9 +399,11 @@ public void addTransformer(ClassFileTransformer transformer) { * @return a new instance of a class loader that has the same visibility * as this class loader */ + @Override public ClassLoader copy() { final ASURLClassLoader copyFrom = this; DelegatingClassLoader newCl = (DelegatingClassLoader)AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { // privileged code goes here, for example: return new DelegatingClassLoader(copyFrom); @@ -430,6 +432,7 @@ private URL findResource0(final URLEntry res, Object result = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { if (res.isJar) { @@ -482,6 +485,7 @@ public Object run() { return (URL) result; } + @Override public URL findResource(String name) { // quick quick that relies on 'doneCalled' being 'volatile' @@ -502,7 +506,7 @@ public URL findResource(String name) { // excpetion for 'urlSet', should the set be cleared while looping. // resource is in the not found list - String nf = (String) notFoundResources.get(name); + String nf = notFoundResources.get(name); if (nf != null && nf.equals(name) ) { return null; } @@ -515,7 +519,9 @@ public URL findResource(String name) { } final URL url = findResource0(u, name); - if (url != null) return url; + if (url != null) { + return url; + } } } @@ -533,6 +539,7 @@ public URL findResource(String name) { * (b) changes to contents or length of 'resourcesList' and/or 'notFoundResources' while iterating * over them, (c) thread visibility to all of the above. */ + @Override public synchronized Enumeration findResources(String name) throws IOException { if( doneCalled ) { @@ -541,16 +548,15 @@ public URL findResource(String name) { // return an empty enumeration instead of null. See issue #13096 return Collections.enumeration(Collections.EMPTY_LIST); } - List resourcesList = new ArrayList(); + List resourcesList = new ArrayList<>(); // resource is in the not found list - final String nf = (String) notFoundResources.get(name); + final String nf = notFoundResources.get(name); if (nf != null && nf.equals(name) ) { return (new Vector(resourcesList)).elements(); } - for (Iterator iter = this.urlSet.iterator(); iter.hasNext();) { - final URLEntry urlEntry = iter.next(); + for (URLEntry urlEntry : this.urlSet) { final URL url = findResource0(urlEntry, name); if (url != null) { resourcesList.add(url); @@ -577,15 +583,21 @@ public URL findResource(String name) { */ private void checkManifest(JarFile jar, File file) throws IOException { - if ( (jar == null) || (file == null) ) return; + if ( (jar == null) || (file == null) ) { + return; + } Manifest man = jar.getManifest(); - if (man == null) return; + if (man == null) { + return; + } synchronized (this) { String cp = man.getMainAttributes().getValue( Attributes.Name.CLASS_PATH); - if (cp == null) return; + if (cp == null) { + return; + } StringTokenizer st = new StringTokenizer(cp, " "); @@ -614,6 +626,7 @@ private byte[] loadClassData0(final URLEntry res, final String entryName) { Object result = AccessController.doPrivileged(new PrivilegedAction() { + @Override public Object run() { InputStream classStream = null; try { @@ -694,8 +707,9 @@ protected PermissionCollection getPermissions(CodeSource codeSource) { PermissionCollection cachedPc = permissionsHolder.getCachedPerms(codeSource); - if (cachedPc != null) + if (cachedPc != null) { return cachedPc; + } return permissionsHolder.getPermissions( codeSource, super.getPermissions(codeSource)); @@ -709,6 +723,7 @@ protected PermissionCollection getPermissions(CodeSource codeSource) { CAUTION: this method might be overriden, and subclasses must be cautious (also) about thread safety. */ + @Override protected Class findClass(String name) throws ClassNotFoundException { ClassData classData = findClassData(name); // Instruments the classes if the profiler's enabled @@ -799,7 +814,7 @@ protected synchronized ClassData findClassData(String name) throws ClassNotFound throw new ClassNotFoundException(name); } - String nf = (String) notFoundClasses.get(name); + String nf = notFoundClasses.get(name); if (nf != null && nf.equals(name) ) { throw new ClassNotFoundException(name); } @@ -814,9 +829,9 @@ protected synchronized ClassData findClassData(String name) throws ClassNotFound byte[] result = loadClassData0(u, entryName); if (result != null) { - if (System.getSecurityManager() == null) + if (System.getSecurityManager() == null) { return new ClassData(result, u.pd); - else { + } else { //recreate the pd to include the declared permissions CodeSource cs = u.pd.getCodeSource(); PermissionCollection pc = this.getPermissions(cs); @@ -874,6 +889,7 @@ protected String getClassLoaderName() { * * @return a string representation of this class loader */ + @Override public String toString() { StringBuffer buffer = new StringBuffer(); @@ -894,6 +910,7 @@ public String toString() { return buffer.toString(); } + @Override public InputStream getResourceAsStream(final String name) { InputStream stream = super.getResourceAsStream(name); /* @@ -946,6 +963,7 @@ public ProtectedJarFile(File file) throws IOException { * 6. java.util.zip.ZipFile.close() * I */ + @Override public void close() { // do nothing } @@ -962,6 +980,7 @@ public void reallyClose() throws IOException { /** * @see java.lang.Object#finalize() */ + @Override @Deprecated(since = "6.1.0", forRemoval = true) protected void finalize() throws IOException { try { @@ -1013,7 +1032,7 @@ void init() throws IOException { zip = new ProtectedJarFile(file); } - table = new Hashtable(); + table = new Hashtable<>(); // cacheItems(); } catch (URISyntaxException use) { IOException ioe= new IOException(); @@ -1027,8 +1046,8 @@ private void fillTable(File f, Hashtable t, String parent) throws IOException { String localName = (parent.equals("")) ? "" : parent + "/"; File[] children = f.listFiles(); - for (int i = 0; i < children.length; i++) { - processFile(children[i], t, localName); + for (File child : children) { + processFile(child, t, localName); } } @@ -1116,6 +1135,7 @@ private File privilegedCheckForFile(final String targetPath) { */ try { File result = (File) AccessController.doPrivileged(new PrivilegedExceptionAction() { + @Override public Object run() throws Exception { File targetFile = new File(file, targetPath); @@ -1150,6 +1170,7 @@ public void setProtectionDomain (ClassLoader ejbClassLoader, Certificate[] signe } } + @Override public String toString() { return "URLEntry : " + source.toString(); } @@ -1160,6 +1181,7 @@ public String toString() { * @param obj URLEntry to compare against * @return true if both entry has equal URL */ + @Override public boolean equals(Object obj) { boolean tf = false; @@ -1185,6 +1207,7 @@ public boolean equals(Object obj) { /** * Since equals is overridden, we need to override hashCode as well. */ + @Override public int hashCode() { try { return source.toURI().hashCode(); @@ -1255,6 +1278,7 @@ protected SentinelInputStream(final InputStream in) { /** * Closes underlying input stream. */ + @Override public void close() throws IOException { _close(); } @@ -1266,6 +1290,7 @@ public void close() throws IOException { * 'closed' is 'volatile', but it's a race condition to check it and how this code * relates to _close() is unclear. */ + @Override protected void finalize() throws Throwable { if (!closed && this.in != null){ try { @@ -1332,6 +1357,7 @@ public InternalJarURLConnection(URL url, URLEntry res, String name) /** * @see java.net.JarURLConnection#getJarFile() */ + @Override public JarFile getJarFile() throws IOException { return mRes.zip; } @@ -1339,6 +1365,7 @@ public JarFile getJarFile() throws IOException { /** * @see java.net.URLConnection#connect() */ + @Override public void connect() throws IOException { // Nothing } @@ -1346,6 +1373,7 @@ public void connect() throws IOException { /** * @see java.net.URLConnection#getInputStream() */ + @Override public InputStream getInputStream() throws IOException { // When there is no entry name specified (this can happen for url like jar:file:///tmp/foo.jar!/), // we must throw an IOException as that's the behavior of JarURLConnection as well. @@ -1387,6 +1415,7 @@ public InternalURLStreamHandler(URLEntry res, String name) { /** * @see java.net.URLStreamHandler#openConnection(java.net.URL) */ + @Override protected URLConnection openConnection(final URL u) throws IOException { String path = u.getPath(); int separator = path.lastIndexOf('!'); @@ -1490,6 +1519,7 @@ private static final class DelegatingClassLoader extends SecureClassLoader { * This method uses the delegate to use class bytes and then defines * the class using this class loader */ + @Override protected Class findClass(String name) throws ClassNotFoundException { ClassData classData = delegate.findClassData(name); // Define package information if necessary @@ -1531,10 +1561,12 @@ protected Class findClass(String name) throws ClassNotFoundException { } } + @Override protected URL findResource(String name) { return delegate.findResource(name); } + @Override protected Enumeration findResources(String name) throws IOException { return delegate.findResources(name); } diff --git a/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/ClassLoaderHierarchy.java b/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/ClassLoaderHierarchy.java index 52736ce688ce..f312c78f7767 100644 --- a/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/ClassLoaderHierarchy.java +++ b/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/ClassLoaderHierarchy.java @@ -26,7 +26,7 @@ import com.sun.enterprise.module.ResolveError; /** - * This class is responsible foe creation of class loader hierarchy + * This class is responsible for creation of class loader hierarchy * of an application. * * @author Sanjeeb.Sahoo@Sun.COM @@ -132,7 +132,7 @@ DelegatingClassLoader.ClassFinder getAppLibClassFinder(List libURIs) * @return class loader capable of loading public APIs identified by the deployers * @throws com.sun.enterprise.module.ResolveError if one of the deployer's public API module is not found. */ - public ClassLoader createApplicationParentCL(ClassLoader parent, DeploymentContext context) + ClassLoader createApplicationParentCL(ClassLoader parent, DeploymentContext context) throws ResolveError; }