![]() ![]() (This is an instance of the general rule that annotations on interfacesĪre ignored.) Class vs. Interface does not apply to a class that implements the interface. We need to reconsider this issue.Īll CDI annotations are marked Component-defining annotationsĪ component-defining annotation (e.g., on aĪ component-defining annotation (e.g., on an XXX - We haven’t done a good job of applying to our annotations. ![]() Annotations of this sort should be marked with annotations will then appear in the javadoc for the class. In some cases, annotations add to the API specification of a class,Īnd contain important information that a user of the class will need The resources used by aĬlass are rarely part of the API specification of the class. annotations are used to effect the implementation of a class.įor example, the Resource annotations define resources that are.In common usage, these annotations are not involved in inheritance hierarchies so it was decided to leave them in a state of non-compliance with these rules rather than risk introducing unforeseen problems. all qualifiers are inherited, regardless of whether they are declared the EL name of the bean is inherited is not declared following component-defining annotations do have on them due to historical accident.The superclass would not know how to produce anĬDI introduces specialization, which affects inheritance. The JPA annotations and with the annotation to control how they behaveĬDI producer fields or methods are not inherited by subclasses, even if theyĪre not overridden. For example, JAX-WS and Connectors has this style is discouraged.ĮJB allows the and annotations to appear on interfaces. “disabling” the annotation by omitting it, the annotation will need anĪttribute that undoes its normal effect. Since this prevents the normal approach of In some cases, an annotation on a method will “show through” to subclasses It does say that annotations from superclasses take precedence over annotations in implemented interfaces. Santiago - The spec is mute about this case. XXX - what happens if the class implements multiple interfaces with the same method but different annotations? JAX-RS annotations from the superclass apply. If a subclass overrides a methodīut does not include any JAX-RS annotations on the method declaration, the JAX-RS defines a similar rule for annotations on methods of a superclass,Īgain violating the general rule above. Overrides all JAX-RS annotations on the corresponding interface method. On a method (other annotations are allowed), the JAX-RS annotations If the implementing class doesn’t declare any JAX-RS annotations JAX-RS allows per-method annotations on the methods of an interface. (Note that it is not possibleĪ method-level annotation on a private superclass method or field remains Overridden “shows through” and still applies. Since a class always “overrides” methods in an interface, annotations onĪ method-level annotation on a superclass method or field that is not ![]() Subclass overrides the method only annotations on the subclass In general, annotations on interfaces are ignored.Ī method-level annotation on a superclass method is ignored if the Is not overridden by a similar annotation on a subclass. It recommends that qualifiers are not declared General rulesĪ resource annotation etc.) on a superclass How their annotations behave with regard to inheritance.įor example, see the JPA and that CDI is an exception to this, and recommends that scopes and interceptor bindings are declared It also recommends that stereotypes may be depending on their intended usage. Some frameworks have defined additional annotations that specify For component-defining annotations, we don’t want theįact that a superclass is a component to cause all subclasses toīe components, so we don’t use for component-defining For resource annotations, we wantĪll such annotations to apply, so would give the wrong With an annotation, only the annotation furthest from If multiple classes in a hierarchy are annotated Note that, in general, we do not use the annotation This section describes how annotations interact with inheritance. Of course, there are exceptions, called out below. Should be designed to work to be consistent with currentĪnnotations. You can consider these to be rules about how annotationsĬurrently work, as well as rules about how new annotations The platform spec and the Common Annotations spec). Some of these duplicate what’s in the specs (in particular, This is a collection of rules for how annotations should work. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |