Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4594b51

Browse files
committed
Java: add missing QLDoc for EJB.qll
1 parent 3a82090 commit 4594b51

1 file changed

Lines changed: 122 additions & 3 deletions

File tree

  • java/ql/src/semmle/code/java/frameworks/javaee/ejb

java/ql/src/semmle/code/java/frameworks/javaee/ejb/EJB.qll

Lines changed: 122 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** Provides classes and predicates for working with Enterprise Java Beans. */
2+
13
import java
24
import EJBJarXML
35

@@ -322,32 +324,49 @@ class LocalAnnotatedBusinessInterface extends AnnotatedBusinessInterface {
322324
* Init and create methods for session beans.
323325
*/
324326

327+
/**
328+
* A `@javax.ejb.Init` annotation.
329+
*/
325330
class InitAnnotation extends Annotation {
326331
InitAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Init") }
327332
}
328333

334+
/**
335+
* A method annotated with a `@javax.ejb.Init` annotation
336+
* that is declared in or inherited by a session EJB.
337+
*/
329338
class EjbAnnotatedInitMethod extends Method {
330339
EjbAnnotatedInitMethod() {
331340
this.getAnAnnotation() instanceof InitAnnotation and
332341
exists(SessionEJB ejb | ejb.inherits(this))
333342
}
334343
}
335344

345+
/**
346+
* A method whose name starts with `ejbCreate` that is
347+
* declared in or inherited by a session EJB.
348+
*/
336349
class EjbCreateMethod extends Method {
337350
EjbCreateMethod() {
338351
this.getName().matches("ejbCreate%") and
339352
exists(SessionEJB ejb | ejb.inherits(this))
340353
}
341354

355+
/** Gets the suffix of the method name without the `ejbCreate` prefix. */
342356
string getMethodSuffix() { result = this.getName().substring(9, this.getName().length()) }
343357
}
344358

359+
/**
360+
* A method whose name starts with `create` that is
361+
* declared in or inherited by a legacy EJB home interface.
362+
*/
345363
class EjbInterfaceCreateMethod extends Method {
346364
EjbInterfaceCreateMethod() {
347365
this.getName().matches("create%") and
348366
exists(LegacyEjbHomeInterface i | i.inherits(this))
349367
}
350368

369+
/** Gets the suffix of the method name without the `create` prefix. */
351370
string getMethodSuffix() { result = this.getName().substring(6, this.getName().length()) }
352371
}
353372

@@ -398,6 +417,10 @@ class XmlSpecifiedRemoteInterface extends LegacyEjbRemoteInterface {
398417
)
399418
}
400419

420+
/**
421+
* Gets a session EJB specified in the XML deployment descriptor
422+
* for this legacy EJB remote interface.
423+
*/
401424
SessionEJB getAnEJB() {
402425
exists(EjbJarXMLFile f, EjbJarSessionElement se |
403426
se = f.getASessionElement() and
@@ -423,6 +446,7 @@ class AnnotatedRemoteHomeInterface extends LegacyEjbRemoteHomeInterface {
423446
/** Gets an EJB to which this interface belongs. */
424447
SessionEJB getAnEJB() { result.getAnAnnotation().(RemoteHomeAnnotation).getANamedType() = this }
425448

449+
/** Gets a remote interface associated with this legacy remote home interface. */
426450
Interface getAnAssociatedRemoteInterface() { result = getACreateMethod().getReturnType() }
427451
}
428452

@@ -486,6 +510,7 @@ class AnnotatedLocalHomeInterface extends LegacyEjbLocalHomeInterface {
486510
/** Gets an EJB to which this interface belongs. */
487511
SessionEJB getAnEJB() { result.getAnAnnotation().(LocalHomeAnnotation).getANamedType() = this }
488512

513+
/** Gets a local interface associated with this legacy local home interface. */
489514
Interface getAnAssociatedLocalInterface() { result = getACreateMethod().getReturnType() }
490515
}
491516

@@ -535,6 +560,7 @@ class RemoteInterface extends Interface {
535560
*/
536561
Method getARemoteMethod() { this.inherits(result) }
537562

563+
/** Gets a remote method implementation for this remote interface. */
538564
Method getARemoteMethodImplementation() {
539565
result = getARemoteMethodImplementationChecked() or
540566
result = getARemoteMethodImplementationUnchecked()
@@ -716,127 +742,209 @@ Type inheritsMatchingCreateMethodExceptThrows(StatefulSessionEJB ejb, EjbInterfa
716742
* Annotations in the `javax.ejb package`.
717743
*/
718744

745+
/**
746+
* A `@javax.ejb.AccessTimeout` annotation.
747+
*/
719748
class AccessTimeoutAnnotation extends Annotation {
720749
AccessTimeoutAnnotation() { this.getType().hasQualifiedName("javax.ejb", "AccessTimeout") }
721750
}
722751

752+
/**
753+
* A `@javax.ejb.ActivationConfigProperty` annotation.
754+
*/
723755
class ActivationConfigPropertyAnnotation extends Annotation {
724756
ActivationConfigPropertyAnnotation() {
725757
this.getType().hasQualifiedName("javax.ejb", "ActivationConfigProperty")
726758
}
727759
}
728760

761+
/**
762+
* A `@javax.ejb.AfterBegin` annotation.
763+
*/
729764
class AfterBeginAnnotation extends Annotation {
730765
AfterBeginAnnotation() { this.getType().hasQualifiedName("javax.ejb", "AfterBegin") }
731766
}
732767

768+
/**
769+
* A `@javax.ejb.AfterCompletion` annotation.
770+
*/
733771
class AfterCompletionAnnotation extends Annotation {
734772
AfterCompletionAnnotation() { this.getType().hasQualifiedName("javax.ejb", "AfterCompletion") }
735773
}
736774

775+
/**
776+
* A `@javax.ejb.ApplicationException` annotation.
777+
*/
737778
class ApplicationExceptionAnnotation extends Annotation {
738779
ApplicationExceptionAnnotation() {
739780
this.getType().hasQualifiedName("javax.ejb", "ApplicationException")
740781
}
741782
}
742783

784+
/**
785+
* A `@javax.ejb.Asynchronous` annotation.
786+
*/
743787
class AsynchronousAnnotation extends Annotation {
744788
AsynchronousAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Asynchronous") }
745789
}
746790

791+
/**
792+
* A `@javax.ejb.BeforeCompletion` annotation.
793+
*/
747794
class BeforeCompletionAnnotation extends Annotation {
748795
BeforeCompletionAnnotation() { this.getType().hasQualifiedName("javax.ejb", "BeforeCompletion") }
749796
}
750797

798+
/**
799+
* A `@javax.ejb.ConcurrencyManagement` annotation.
800+
*/
751801
class ConcurrencyManagementAnnotation extends Annotation {
752802
ConcurrencyManagementAnnotation() {
753803
this.getType().hasQualifiedName("javax.ejb", "ConcurrencyManagement")
754804
}
755805
}
756806

807+
/**
808+
* A `@javax.ejb.DependsOn` annotation.
809+
*/
757810
class DependsOnAnnotation extends Annotation {
758811
DependsOnAnnotation() { this.getType().hasQualifiedName("javax.ejb", "DependsOn") }
759812
}
760813

814+
/**
815+
* A `@javax.ejb.EJB` annotation.
816+
*/
761817
class EJBAnnotation extends Annotation {
762818
EJBAnnotation() { this.getType().hasQualifiedName("javax.ejb", "EJB") }
763819
}
764820

821+
/**
822+
* A `@javax.ejb.EJBs` annotation.
823+
*/
765824
class EJBsAnnotation extends Annotation {
766825
EJBsAnnotation() { this.getType().hasQualifiedName("javax.ejb", "EJBs") }
767826
}
768827

769-
// See above for `@Init`, `@Local`.
828+
/**
829+
* A `@javax.ejb.LocalBean` annotation.
830+
*/
770831
class LocalBeanAnnotation extends Annotation {
771832
LocalBeanAnnotation() { this.getType().hasQualifiedName("javax.ejb", "LocalBean") }
772833
}
773834

774-
// See above for `@LocalHome`.
835+
/**
836+
* A `@javax.ejb.Lock` annotation.
837+
*/
775838
class LockAnnotation extends Annotation {
776839
LockAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Lock") }
777840
}
778841

842+
/**
843+
* A `@javax.ejb.MessageDriven` annotation.
844+
*/
779845
class MessageDrivenAnnotation extends Annotation {
780846
MessageDrivenAnnotation() { this.getType().hasQualifiedName("javax.ejb", "MessageDriven") }
781847
}
782848

849+
/**
850+
* A `@javax.ejb.PostActivate` annotation.
851+
*/
783852
class PostActivateAnnotation extends Annotation {
784853
PostActivateAnnotation() { this.getType().hasQualifiedName("javax.ejb", "PostActivate") }
785854
}
786855

856+
/**
857+
* A `@javax.ejb.PrePassivate` annotation.
858+
*/
787859
class PrePassivateAnnotation extends Annotation {
788860
PrePassivateAnnotation() { this.getType().hasQualifiedName("javax.ejb", "PrePassivate") }
789861
}
790862

791-
// See above for `@Remote`, `@RemoteHome`.
863+
/**
864+
* A `@javax.ejb.Remove` annotation.
865+
*/
792866
class RemoveAnnotation extends Annotation {
793867
RemoveAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Remove") }
794868
}
795869

870+
/**
871+
* A `@javax.ejb.Schedule` annotation.
872+
*/
796873
class ScheduleAnnotation extends Annotation {
797874
ScheduleAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Schedule") }
798875
}
799876

877+
/**
878+
* A `@javax.ejb.Schedules` annotation.
879+
*/
800880
class SchedulesAnnotation extends Annotation {
801881
SchedulesAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Schedules") }
802882
}
803883

884+
/**
885+
* A `@javax.ejb.Singleton` annotation.
886+
*/
804887
class SingletonAnnotation extends Annotation {
805888
SingletonAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Singleton") }
806889
}
807890

891+
/**
892+
* A `@javax.ejb.Startup` annotation.
893+
*/
808894
class StartupAnnotation extends Annotation {
809895
StartupAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Startup") }
810896
}
811897

898+
/**
899+
* A `@javax.ejb.Stateful` annotation.
900+
*/
812901
class StatefulAnnotation extends Annotation {
813902
StatefulAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Stateful") }
814903
}
815904

905+
/**
906+
* A `@javax.ejb.StatefulTimeout` annotation.
907+
*/
816908
class StatefulTimeoutAnnotation extends Annotation {
817909
StatefulTimeoutAnnotation() { this.getType().hasQualifiedName("javax.ejb", "StatefulTimeout") }
818910
}
819911

912+
/**
913+
* A `@javax.ejb.Stateless` annotation.
914+
*/
820915
class StatelessAnnotation extends Annotation {
821916
StatelessAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Stateless") }
822917
}
823918

919+
/**
920+
* A `@javax.ejb.Timeout` annotation.
921+
*/
824922
class TimeoutAnnotation extends Annotation {
825923
TimeoutAnnotation() { this.getType().hasQualifiedName("javax.ejb", "Timeout") }
826924
}
827925

926+
/**
927+
* A `@javax.ejb.TransactionAttribute` annotation.
928+
*/
828929
class TransactionAttributeAnnotation extends Annotation {
829930
TransactionAttributeAnnotation() {
830931
this.getType().hasQualifiedName("javax.ejb", "TransactionAttribute")
831932
}
832933
}
833934

935+
/**
936+
* A `@javax.ejb.TransactionManagement` annotation.
937+
*/
834938
class TransactionManagementAnnotation extends Annotation {
835939
TransactionManagementAnnotation() {
836940
this.getType().hasQualifiedName("javax.ejb", "TransactionManagement")
837941
}
838942
}
839943

944+
/**
945+
* A `@javax.ejb.TransactionAttribute` annotation with the
946+
* transaction attribute type set to `REQUIRED`.
947+
*/
840948
class RequiredTransactionAttributeAnnotation extends TransactionAttributeAnnotation {
841949
RequiredTransactionAttributeAnnotation() {
842950
exists(FieldRead fr |
@@ -847,6 +955,10 @@ class RequiredTransactionAttributeAnnotation extends TransactionAttributeAnnotat
847955
}
848956
}
849957

958+
/**
959+
* A `@javax.ejb.TransactionAttribute` annotation with the
960+
* transaction attribute type set to `REQUIRES_NEW`.
961+
*/
850962
class RequiresNewTransactionAttributeAnnotation extends TransactionAttributeAnnotation {
851963
RequiresNewTransactionAttributeAnnotation() {
852964
exists(FieldRead fr |
@@ -861,6 +973,9 @@ class RequiresNewTransactionAttributeAnnotation extends TransactionAttributeAnno
861973
* Convenience methods.
862974
*/
863975

976+
/**
977+
* Gets the innermost `@javax.ejb.TransactionAttribute` annotation for method `m`.
978+
*/
864979
TransactionAttributeAnnotation getInnermostTransactionAttributeAnnotation(Method m) {
865980
// A `TransactionAttribute` annotation can either be on the method itself,
866981
// in which case it supersedes any such annotation on the declaring class...
@@ -876,6 +991,10 @@ TransactionAttributeAnnotation getInnermostTransactionAttributeAnnotation(Method
876991
* Methods in the `javax.ejb package`.
877992
*/
878993

994+
/**
995+
* A method named `setRollbackOnly` declared on the
996+
* interface `javax.ejb.EJBContext` or a subtype thereof.
997+
*/
879998
class SetRollbackOnlyMethod extends Method {
880999
SetRollbackOnlyMethod() {
8811000
this.getDeclaringType().getASupertype*().hasQualifiedName("javax.ejb", "EJBContext") and

0 commit comments

Comments
 (0)