Skip to content

Commit

Permalink
Merge pull request #7020 from matthiasblaesing/jakarta_fini
Browse files Browse the repository at this point in the history
Final changes for JakartaEE adjustments
  • Loading branch information
matthiasblaesing authored Feb 24, 2024
2 parents a77e2fd + 410e94e commit 4da78ff
Show file tree
Hide file tree
Showing 38 changed files with 57 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,57 @@
*
* @author Sanjeeb.Sahoo@Sun.COM
*/
// @todo: Support JakartaEE
public interface EJBAPIAnnotations {
String ASYNCHRONOUS = "javax.ejb.Asynchronous"; //NOI18N
String ASYNCHRONOUS_JAKARTA = "jakarta.ejb.Asynchronous"; //NOI18N

String REMOTE = "javax.ejb.Remote"; //NOI18N
String REMOTE_JAKARTA = "jakarta.ejb.Remote"; //NOI18N
String LOCAL = "javax.ejb.Local"; //NOI18N
String LOCAL_JAKARTA = "jakarta.ejb.Local"; //NOI18N

String STATELESS = "javax.ejb.Stateless"; // NOI18N
String STATELESS_JAKARTA = "jakarta.ejb.Stateless"; // NOI18N

String STATEFUL = "javax.ejb.Stateful"; // NOI18N
String STATEFUL_JAKARTA = "jakarta.ejb.Stateful"; // NOI18N
String INIT = "javax.ejb.Init"; // NOI18N
String INIT_JAKARTA = "jakarta.ejb.Init"; // NOI18N
String REMOVE = "javax.ejb.Remove"; // NOI18N
String REMOVE_JAKARTA = "jakarta.ejb.Remove"; // NOI18N

String MESSAGE_DRIVEN = "javax.ejb.MessageDriven"; // NOI18N
String MESSAGE_DRIVEN_JAKARTA = "jakarta.ejb.MessageDriven"; // NOI18N
String ACTIVATION_CONFIG_PROPERTY = "javax.ejb.ActivationConfigProperty"; // NOI18N
String ACTIVATION_CONFIG_PROPERTY_JAKARTA = "javaxjakartaejb.ActivationConfigProperty"; // NOI18N

String REMOTE_HOME = "javax.ejb.RemoteHome"; //NOI18N
String REMOTE_HOME_JAKARTA = "jakarta.ejb.RemoteHome"; //NOI18N
String LOCAL_HOME = "javax.ejb.LocalHome"; //NOI18N
String LOCAL_HOME_JAKARTA = "jakarta.ejb.LocalHome"; //NOI18N

String TRANSACTION_MANAGEMENT = "javax.ejb.TransactionManagement"; //NOI18N
String TRANSACTION_MANAGEMENT_JAKARTA = "jakarta.ejb.TransactionManagement"; //NOI18N

//value attribute in annotations with single attribute
String VALUE = "value"; //NOI18N

String WEB_SERVICE = "javax.jws.WebService"; //NOI18N
String WEB_SERVICE_JAKARTA = "jakarta.jws.WebService"; //NOI18N
// TODO: Add other ones here including enum types
String LOCAL_BEAN = "javax.ejb.LocalBean";
String LOCAL_BEAN_JAKARTA = "jakarta.ejb.LocalBean";

String POST_CONSTRUCT = "javax.annotation.PostConstruct";
String POST_CONSTRUCT_JAKARTA = "jakarta.annotation.PostConstruct";
String AROUND_INVOKE = "javax.interceptor.AroundInvoke";
String AROUND_INVOKE_JAKARTA = "jakarta.interceptor.AroundInvoke";

String SCHEDULE = "javax.ejb.Schedule"; //NOI18N
String SCHEDULE_JAKARTA = "jakarta.ejb.Schedule"; //NOI18N
// @Schedule parameter for persistent timer
String PERSISTENT = "persistent"; //NOI18N

String SESSION_SYNCHRONIZATION = "javax.ejb.SessionSynchronization"; //NOI18N
String SESSION_SYNCHRONIZATION_JAKARTA = "jakarta.ejb.SessionSynchronization"; //NOI18N
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
*
* @author Martin Fousek <marfous@netbeans.org>
*/
// @todo: Support JakartaEE
@Hint(displayName = "#AnnotationPostContruct.display.name",
description = "#AnnotationPostContruct.description",
id = "o.n.m.j2ee.ejbverification.AnnotationPostContruct",
Expand Down Expand Up @@ -133,7 +132,8 @@ private static boolean isEjbInterceptor(CompilationInfo info, ExecutableElement
String paramType = parameter.asType().toString();
TypeElement element = info.getElements().getTypeElement(paramType);
if (element != null) { //NOI18N
if (JavaUtils.isTypeOf(info, element, "javax.interceptor.InvocationContext")) { //NOI18N
if (JavaUtils.isTypeOf(info, element, "javax.interceptor.InvocationContext") //NOI18N
|| JavaUtils.isTypeOf(info, element, "jakarta.interceptor.InvocationContext")) { //NOI18N
return true;
}
}
Expand All @@ -159,7 +159,8 @@ private static boolean throwsCheckedException(CompilationInfo info, List<? exten
private static boolean isEligibleMethod(ExecutableElement method) {
boolean knownClasses = HintsUtils.isContainingKnownClasses(method);
for (AnnotationMirror am : method.getAnnotationMirrors()) {
if (EJBAPIAnnotations.POST_CONSTRUCT.equals(am.getAnnotationType().asElement().toString())
if ((EJBAPIAnnotations.POST_CONSTRUCT.equals(am.getAnnotationType().asElement().toString())
|| EJBAPIAnnotations.POST_CONSTRUCT_JAKARTA.equals(am.getAnnotationType().asElement().toString()))
&& knownClasses) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"AsynchronousMethodInvocation.description=Checks usage of @Asynchronous. Tests whether it's used within supported project and interface type.",
"AsynchronousMethodInvocation.err.asynchronous.in.ejb31=Asynchronous method invocation is not allowed in project targeting JavaEE 6 Lite profile"
})
// @todo: Support JakartaEE
public final class AsynchronousMethodInvocation {

private AsynchronousMethodInvocation() { }
Expand Down Expand Up @@ -97,7 +96,9 @@ public static Collection<ErrorDescription> run(HintContext hintContext) {
private static boolean isAsynchronousAnnotated(ExecutableElement method) {
boolean knownClasses = HintsUtils.isContainingKnownClasses(method);
for (AnnotationMirror am : method.getAnnotationMirrors()) {
if (EJBAPIAnnotations.ASYNCHRONOUS.equals(am.getAnnotationType().asElement().toString()) && knownClasses) {
if ((EJBAPIAnnotations.ASYNCHRONOUS.equals(am.getAnnotationType().asElement().toString())
|| EJBAPIAnnotations.ASYNCHRONOUS_JAKARTA.equals(am.getAnnotationType().asElement().toString()))
&& knownClasses) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public static Collection<ErrorDescription> run(HintContext hintContext) {
Collection<String> businessInterFaces = new ArrayList<>();

processAnnotation(businessInterFaces, ctx.getClazz(), EJBAPIAnnotations.LOCAL);
processAnnotation(businessInterFaces, ctx.getClazz(), EJBAPIAnnotations.LOCAL_JAKARTA);
processAnnotation(businessInterFaces, ctx.getClazz(), EJBAPIAnnotations.REMOTE);
processAnnotation(businessInterFaces, ctx.getClazz(), EJBAPIAnnotations.REMOTE_JAKARTA);

if (businessInterFaces.size() > 0) {
Collection<String> implementedInterfaces = new TreeSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,16 @@ public static Collection<ErrorDescription> run(HintContext hintContext) {
int intfCount = ctx.getEjbData().getBusinessLocal().length + ctx.getEjbData().getBusinessRemote().length;
localInterfaces = new ArrayList<TypeElement>(resolveClasses(hintContext.getInfo(), ctx.getEjbData().getBusinessLocal()));
remoteInterfaces = new ArrayList<TypeElement>(resolveClasses(hintContext.getInfo(), ctx.getEjbData().getBusinessRemote()));
if (intfCount == 0 || JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.LOCAL_BEAN)) {
if (intfCount == 0
|| JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.LOCAL_BEAN)
|| JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.LOCAL_BEAN_JAKARTA)) {
return null;
}
}
// if an EJB is annotated with "@javax.jws.WebService"
// then no business interface is needed, see issue #147512
if (JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.WEB_SERVICE)) {
if (JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.WEB_SERVICE)
|| JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.WEB_SERVICE_JAKARTA)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public static Collection<ErrorDescription> run(HintContext hintContext) {
final List<ErrorDescription> problems = new ArrayList<>();
final EJBProblemContext ctx = HintsUtils.getOrCacheContext(hintContext);
if (ctx != null && ctx.getEjb() instanceof Session) {
if (JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.LOCAL)) {
if (JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.LOCAL)
|| JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.LOCAL_JAKARTA)) {
if (ctx.getEjbData().getBusinessLocal().length == 0) {
ErrorDescription err = HintsUtils.createProblem(
ctx.getClazz(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public static Collection<ErrorDescription> run(HintContext hintContext) {
if ((ee6lite || ee7lite || ee9lite) && nonEeFullServer(platform)) {
for (Element element : ctx.getClazz().getEnclosedElements()) {
for (AnnotationMirror annm : element.getAnnotationMirrors()) {
if (EJBAPIAnnotations.SCHEDULE.equals(annm.getAnnotationType().toString())) {
if (EJBAPIAnnotations.SCHEDULE_JAKARTA.equals(annm.getAnnotationType().toString())
|| EJBAPIAnnotations.SCHEDULE.equals(annm.getAnnotationType().toString())) {
if (ee6lite) {
problems.add(HintsUtils.createProblem(element, hintContext.getInfo(),
Bundle.PersistentTimerInEjbLite_err_timer_in_ee6lite(), Severity.ERROR));
Expand Down Expand Up @@ -179,7 +180,10 @@ public void run(WorkingCopy copy) throws Exception {
}

public void fixTimerAnnotation(WorkingCopy copy) {
TypeElement scheduleAnnotation = copy.getElements().getTypeElement(EJBAPIAnnotations.SCHEDULE);
TypeElement scheduleAnnotation = copy.getElements().getTypeElement(EJBAPIAnnotations.SCHEDULE_JAKARTA);
if(scheduleAnnotation == null) {
scheduleAnnotation = copy.getElements().getTypeElement(EJBAPIAnnotations.SCHEDULE);
}
ModifiersTree modifiers = ((MethodTree) copy.getTrees().getPath(methodElement.resolve(copy)).getLeaf()).getModifiers();
TreeMaker tm = copy.getTreeMaker();
for (AnnotationTree at : modifiers.getAnnotations()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public static Collection<ErrorDescription> run(HintContext hintContext) {
final List<ErrorDescription> problems = new ArrayList<>();
final EJBProblemContext ctx = HintsUtils.getOrCacheContext(hintContext);
if (ctx != null && ctx.getEjb() instanceof Session) {
if (JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.REMOTE)) {
if (JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.REMOTE)
|| JavaUtils.hasAnnotation(ctx.getClazz(), EJBAPIAnnotations.REMOTE_JAKARTA)) {
if (ctx.getEjbData().getBusinessRemote().length == 0) {
ErrorDescription err = HintsUtils.createProblem(
ctx.getClazz(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public static Collection<ErrorDescription> run(HintContext hintContext) {
}
for (TypeMirror iface : ctx.getClazz().getInterfaces()) {
String ifaceName = JavaUtils.extractClassNameFromType(iface);
if (EJBAPIAnnotations.SESSION_SYNCHRONIZATION.equals(ifaceName)) {
if (EJBAPIAnnotations.SESSION_SYNCHRONIZATION.equals(ifaceName)
|| EJBAPIAnnotations.SESSION_SYNCHRONIZATION_JAKARTA.equals(ifaceName)) {
ErrorDescription err = HintsUtils.createProblem(ctx.getClazz(), hintContext.getInfo(), Bundle.SessionSynchImplementedBySFSBOnly_err());
problems.add(err);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public static Collection<ErrorDescription> run(HintContext hintContext) {
return Collections.emptyList();
}

AnnotationMirror annRemote = JavaUtils.findAnnotation(ctx.getClazz(), EJBAPIAnnotations.REMOTE);
AnnotationMirror annRemote = JavaUtils.findAnnotation(ctx.getClazz(), EJBAPIAnnotations.REMOTE_JAKARTA);
if(annRemote == null) {
annRemote = JavaUtils.findAnnotation(ctx.getClazz(), EJBAPIAnnotations.REMOTE);
}
if (annRemote != null && JavaUtils.getAnnotationAttrValue(annRemote, EJBAPIAnnotations.VALUE) != null) {
ErrorDescription err = HintsUtils.createProblem(
ctx.getClazz(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ public static Collection<ErrorDescription> run(HintContext hintContext) {
return null;
}
AnnotationMirror annWebService = JavaUtils.findAnnotation(ctx.getClazz(),
EJBAPIAnnotations.WEB_SERVICE);
EJBAPIAnnotations.WEB_SERVICE_JAKARTA);
if(annWebService == null) {
annWebService = JavaUtils.findAnnotation(ctx.getClazz(), EJBAPIAnnotations.WEB_SERVICE);
}

if (annWebService != null) {
ClassTree classTree = hintContext.getInfo().getTrees().getTree(ctx.getClazz());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class InterceptorGenerator implements CodeGenerator {
private static final Logger LOG = Logger.getLogger(
InterceptorGenerator.class.getName() );

private static final String INTERCEPTOR = "javax.interceptor.Interceptor"; // NOI18N
private static final String INTERCEPTOR = "jakarta.interceptor.Interceptor"; // NOI18N

InterceptorGenerator( String bindingName, FileObject bindingFileObject ) {
myBindingName = bindingName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ the unrestricted set of bean types of a bean.
ERR_NonStaticInnerType=Non-static inner class cannot be managed bean or \
superclass of managed bean.
WARN_QualifiedElementExtension=The element is not managed bean: it has \
qualifiers but implements javax.enterprise.inject.spi.Extension.
qualifiers but implements jakarta.enterprise.inject.spi.Extension.
WARN_QualifierAbstractClass=The element is not managed bean: it has \
qualifiers but has abstract modifier.
WARN_QualifierNoCtorClass=The element is not managed bean: it has \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected String getUsageLogMessage() {
*/
@Override
protected String getTemplate() {
return "Templates/CDI/Interceptor.java";
return "Templates/CDI_JakartaEE/Interceptor.java";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected String getUsageLogMessage() {
*/
@Override
protected String getTemplate() {
return "Templates/CDI/Qualifier.java"; // NOI18N
return "Templates/CDI_JakartaEE/Qualifier.java"; // NOI18N
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.interceptor.InterceptorBinding;
import jakarta.interceptor.InterceptorBinding;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
public class InterceptorFactory implements Factory {

static final String INTERCEPTOR_BINDING = "InterceptorBinding"; // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
class InterceptorGenerator implements CodeGenerator {

private static final Logger LOG = Logger.getLogger(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
public final class AnnotationUtil {

public static final String ANY = "javax.enterprise.inject.Any"; // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
public class ManagedBeansAnalizer implements ClassAnalyzer {

private static final String EXTENSION = "javax.enterprise.inject.spi.Extension"; //NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
public class CreateQualifier implements ErrorRule<Void> {

private static final String INJECT_ANNOTATION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
public class AnnotationObjectProvider implements ObjectProvider<BindingQualifier> {

private static final String SPECILIZES_ANNOTATION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
class BeansFilter extends Filter<TypeElement> {

static BeansFilter get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
class EnableBeansFilter {

static final String DECORATOR = "javax.decorator.Decorator"; // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
abstract class EventInjectionPointLogic extends ParameterInjectionPointLogic {

public static final String EVENT_INTERFACE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
/**
* @author ads
*/
// @todo: Support JakartaEE
abstract class FieldInjectionPointLogic {

static final String PRODUCER_ANNOTATION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
class InterceptorBindingChecker extends RuntimeAnnotationChecker {

static final String INTERCEPTOR_BINDING = "javax.interceptor.InterceptorBinding"; // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
class InterceptorObject extends PersistentObject implements Refreshable {

static final String INTERCEPTOR = "javax.interceptor.Interceptor"; // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
class MemberBindingFilter<T extends Element> extends Filter<T> {

private static final String NON_BINDING_MEMBER_ANNOTATION =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
abstract class ParameterInjectionPointLogic extends FieldInjectionPointLogic
implements WebBeansModelProvider
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
class ScopeChecker extends RuntimeAnnotationChecker {

static String SCOPE = "javax.inject.Scope"; // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
public class StereotypeChecker extends RuntimeAnnotationChecker {

static final String STEREOTYPE = "javax.enterprise.inject.Stereotype"; //NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
public class InterceptorsResultImpl implements InterceptorsResult {

static final String INTERCEPTORS = "javax.interceptor.Interceptors"; // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
* @author ads
*
*/
// @todo: Support JakartaEE
public class ResultImpl extends BaseResult implements DependencyInjectionResult.ResolutionResult {

private static final String ALTERNATIVE =
Expand Down
Loading

0 comments on commit 4da78ff

Please sign in to comment.