Skip to content

Commit

Permalink
Merge pull request #25122 from avpinchuk/ejb-annotation-processing
Browse files Browse the repository at this point in the history
Fixed EJB business interface annotation processing
  • Loading branch information
arjantijms authored Aug 29, 2024
2 parents 1e81265 + 1d6de66 commit 6b44772
Showing 1 changed file with 31 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -332,6 +332,7 @@ protected HandlerProcessingResult setBusinessAndHomeInterfaces(

Remote remoteBusAnn = (Remote) ejbClass.getAnnotation(Remote.class);
boolean emptyRemoteBusAnn = false;
boolean emptyLocalBusAnn = false;
if( remoteBusAnn != null ) {
for(Class next : remoteBusAnn.value()) {
if (next.getAnnotation(Local.class) != null) {
Expand Down Expand Up @@ -364,6 +365,7 @@ protected HandlerProcessingResult setBusinessAndHomeInterfaces(
clientInterfaces.add(next);
localBusIntfs.add(next);
}
emptyLocalBusAnn = localBusIntfs.isEmpty();
}

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

if( remoteBusIntfs.contains(next)
||
localBusIntfs.contains(next)
||
ejbDesc.getRemoteBusinessClassNames().contains(nextIntfName)
||
ejbDesc.getLocalBusinessClassNames().contains(nextIntfName)){

if (remoteBusIntfs.contains(next) || localBusIntfs.contains(next)
|| ejbDesc.getRemoteBusinessClassNames().contains(nextIntfName)
|| ejbDesc.getLocalBusinessClassNames().contains(nextIntfName)) {
// Interface has already been identified as a Remote/Local
// business interface, so ignore.
continue;
}

} else if( next.getAnnotation(Local.class) != null ) {

clientInterfaces.add(next);
localBusIntfs.add(next);

} else if( next.getAnnotation(Remote.class) != null ) {
boolean isLocal = next.isAnnotationPresent(Local.class);
boolean isRemote = next.isAnnotationPresent(Remote.class);

if (isLocal || isRemote) {
if (isLocal) {
localBusIntfs.add(next);
}
if (isRemote) {
remoteBusIntfs.add(next);
}
clientInterfaces.add(next);
remoteBusIntfs.add(next);

} else {

if( (designatedInterfaceCount == 0) &&
(!ejbDesc.isLocalBean()) ) {
continue;
}

// If there's an empty @Remote annotation on the class,
// it's treated as a remote business interface. Otherwise,
// it's treated as a local business interface.
if( emptyRemoteBusAnn ) {
if (designatedInterfaceCount == 0 && !ejbDesc.isLocalBean()) {
// If there's an empty @Remote annotation on the class
// it's treated as a remote business interface.
// If there's an empty @Local annotation on the class or if
// the bean class is annotated with neither the @Local nor the
// @Remote annotation, it's treated as a local business interface.
if (emptyLocalBusAnn || emptyRemoteBusAnn) {
if (emptyRemoteBusAnn) {
remoteBusIntfs.add(next);
} else {
}
if (emptyLocalBusAnn) {
localBusIntfs.add(next);
}
clientInterfaces.add(next);

} else {

// Since the component has at least one other business
// interface, each implements clause interface that cannot
// be identified as business interface via the deployment
// descriptor or a @Remote/@Local annotation is ignored.

localBusIntfs.add(next);
}
clientInterfaces.add(next);
}
}

Expand Down

0 comments on commit 6b44772

Please sign in to comment.