Skip to content

Commit 6b44772

Browse files
authored
Merge pull request #25122 from avpinchuk/ejb-annotation-processing
Fixed EJB business interface annotation processing
2 parents 1e81265 + 1d6de66 commit 6b44772

File tree

1 file changed

+31
-34
lines changed

1 file changed

+31
-34
lines changed

appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/annotation/handlers/AbstractEjbHandler.java

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation.
33
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
44
*
55
* This program and the accompanying materials are made available under the
@@ -332,6 +332,7 @@ protected HandlerProcessingResult setBusinessAndHomeInterfaces(
332332

333333
Remote remoteBusAnn = (Remote) ejbClass.getAnnotation(Remote.class);
334334
boolean emptyRemoteBusAnn = false;
335+
boolean emptyLocalBusAnn = false;
335336
if( remoteBusAnn != null ) {
336337
for(Class next : remoteBusAnn.value()) {
337338
if (next.getAnnotation(Local.class) != null) {
@@ -364,6 +365,7 @@ protected HandlerProcessingResult setBusinessAndHomeInterfaces(
364365
clientInterfaces.add(next);
365366
localBusIntfs.add(next);
366367
}
368+
emptyLocalBusAnn = localBusIntfs.isEmpty();
367369
}
368370

369371
List<Class> imlementingInterfaces = new ArrayList<>();
@@ -393,50 +395,45 @@ protected HandlerProcessingResult setBusinessAndHomeInterfaces(
393395
for(Class next : imlementingInterfaces) {
394396
String nextIntfName = next.getName();
395397

396-
if( remoteBusIntfs.contains(next)
397-
||
398-
localBusIntfs.contains(next)
399-
||
400-
ejbDesc.getRemoteBusinessClassNames().contains(nextIntfName)
401-
||
402-
ejbDesc.getLocalBusinessClassNames().contains(nextIntfName)){
403-
398+
if (remoteBusIntfs.contains(next) || localBusIntfs.contains(next)
399+
|| ejbDesc.getRemoteBusinessClassNames().contains(nextIntfName)
400+
|| ejbDesc.getLocalBusinessClassNames().contains(nextIntfName)) {
404401
// Interface has already been identified as a Remote/Local
405402
// business interface, so ignore.
403+
continue;
404+
}
406405

407-
} else if( next.getAnnotation(Local.class) != null ) {
408-
409-
clientInterfaces.add(next);
410-
localBusIntfs.add(next);
411-
412-
} else if( next.getAnnotation(Remote.class) != null ) {
406+
boolean isLocal = next.isAnnotationPresent(Local.class);
407+
boolean isRemote = next.isAnnotationPresent(Remote.class);
413408

409+
if (isLocal || isRemote) {
410+
if (isLocal) {
411+
localBusIntfs.add(next);
412+
}
413+
if (isRemote) {
414+
remoteBusIntfs.add(next);
415+
}
414416
clientInterfaces.add(next);
415-
remoteBusIntfs.add(next);
416-
417-
} else {
418-
419-
if( (designatedInterfaceCount == 0) &&
420-
(!ejbDesc.isLocalBean()) ) {
417+
continue;
418+
}
421419

422-
// If there's an empty @Remote annotation on the class,
423-
// it's treated as a remote business interface. Otherwise,
424-
// it's treated as a local business interface.
425-
if( emptyRemoteBusAnn ) {
420+
if (designatedInterfaceCount == 0 && !ejbDesc.isLocalBean()) {
421+
// If there's an empty @Remote annotation on the class
422+
// it's treated as a remote business interface.
423+
// If there's an empty @Local annotation on the class or if
424+
// the bean class is annotated with neither the @Local nor the
425+
// @Remote annotation, it's treated as a local business interface.
426+
if (emptyLocalBusAnn || emptyRemoteBusAnn) {
427+
if (emptyRemoteBusAnn) {
426428
remoteBusIntfs.add(next);
427-
} else {
429+
}
430+
if (emptyLocalBusAnn) {
428431
localBusIntfs.add(next);
429432
}
430-
clientInterfaces.add(next);
431-
432433
} else {
433-
434-
// Since the component has at least one other business
435-
// interface, each implements clause interface that cannot
436-
// be identified as business interface via the deployment
437-
// descriptor or a @Remote/@Local annotation is ignored.
438-
434+
localBusIntfs.add(next);
439435
}
436+
clientInterfaces.add(next);
440437
}
441438
}
442439

0 commit comments

Comments
 (0)