EJB questions

How do I get the type of a PsiClass: Entity Bean, SLSB, SFSB, or neither of it
Currently I check for annotations which obviously is incomplete, as even in EJB3 beans may be defined in deployment descriptor.

A tougher question:
How do I check if a given interface is the local interface for a session bean?
In EJB3 the interface may not have any annotations at all (when the session bean is annotated with @Local(MyLocalInterface.class).

10 comments

Probably EjbHelper.getEjbRole() is what you need?

"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:4333350.1158834931513.JavaMail.itn@is.intellij.net...

How do I get the type of a PsiClass: Entity Bean, SLSB, SFSB, or neither
of it
Currently I check for annotations which obviously is incomplete, as even
in EJB3 beans may be defined in deployment descriptor.

>

A tougher question:
How do I check if a given interface is the local interface for a session
bean?
In EJB3 the interface may not have any annotations at all (when the
session bean is annotated with @Local(MyLocalInterface.class).



0

Thanks Peter, but for Entity beans this returns null and I don't see how I can distinguish between stateless and stateful session beans.
Any idea?

It's not that important, because it turned out that to use Seam on Session beans you need to use @Stateless/@Statefull annotations anyway.
The second part (getting the implementation from the local interface) works fine with your solution.

0

It shouldn't return null for PsiClass'es that are parts of an EJB. If it
does, then it's a bug, and I'd be grateful for reproduce steps.

When you get a EjbClassRole, you can get EnterpriseBean from it. And if it's
an instance of com.intellij.javaee.model.common.ejb.SessionBean, you may ask
it for isStateful() method, and get what you want.

"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:13712648.1158854560282.JavaMail.itn@is.intellij.net...

Thanks Peter, but for Entity beans this returns null and I don't see how I
can distinguish between stateless and stateful session beans.
Any idea?

>

It's not that important, because it turned out that to use Seam on Session
beans you need to use @Stateless/@Statefull annotations anyway.
The second part (getting the implementation from the local interface)
works fine with your solution.



0

Here's the simplest project I could think of.
When my inspection runs on build 5734 and I ask for the ejbRole of class com.acme.foobar.User I get null.



Attachment(s):
ejbRoleTest.zip
0

Oh, yes, I see. @Entity annotation means not Entity EJB, but Java EE
Persistence Entity, it's quite different and new thing. There are roles for
it, too, but they're obtained in a different way, from class
JavaeePersistenceRoleHolder.

"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:23474705.1158856678192.JavaMail.itn@is.intellij.net...

Here's the simplest project I could think of.
When my inspection runs on build 5734 and I ask for the ejbRole of class
com.acme.foobar.User I get null.



0

Thanks a lot. Sorry for the confusion - I only ever entered the Java EE domain after EJB 3 was out so I am very easy to confuse...

But then again JBoss Seam documentation and examples always talk about entity beans and always only use @Entity annotation.

Maybe I can then point out another bug here: In the simple mini exmaple I tried to add a persistence.xml descriptor (in the module settings). After that I saw the persistence.xml file in the project tree, but when I double clicked to open it, it vanished from the tree?!

Should it work if I remove the @Entity from Use class and use this descriptor instead:
com.acme.foobar.User ]]>

Currently Idea no longer recognizes the User class as Persistence Entity after that.

0

Maybe I can then point out another bug here: In the simple mini exmaple I
tried to add a persistence.xml descriptor (in the module settings). After
that I saw the persistence.xml file in the project tree, but when I double
clicked to open it, it vanished from the tree?!


Strange. We'll look at it. Is "project tree" Project View or Java EE view?

Should it work if I remove the @Entity from Use class and use this
descriptor instead:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="acmeDatabase">
<class>com.acme.foobar.User</class>
</persistence-unit>
</persistence>

>

Currently Idea no longer recognizes the User class as Persistence Entity
after that.


It shouldn't work, because the spec (xsd) says:

Class to scan for annotations. It should be annotated with either @Entity, @Embeddable or @MappedSuperclass. You can remove the annotation, if you create a mapping file ( root tag), reference it in persistence.xml ( tag), and mention your class as Entity class (]]> tag).


0

It shouldn't work, because the spec (xsd) says:


Thanks for your patience and answering all those EE newbie questions.

Strange. We'll look at it. Is "project tree" Project View or Java EE view?

"project tree".

Just checked again. The bug is easy to reproduce:
- Open the mini project I posted
- Open the "Project" tree view
- Expand the META-INF folder
- Open the settings for the module, tab "Ejb Module Settings"
- Click "Add" and "persistence.xml"
- Idea preselects the META-INF folder, click ok
- Note that the project tree view shows the persistence.xml file
- Double click

0

Hm. If I create both persistence.xml and orm.xml in the same step the double clicking on persistence.xml works, but the orm.xml vanishes...

0

http://www.jetbrains.net/jira/browse/IDEADEV-9985

"Stephen Friedrich" <no_mail@jetbrains.com> wrote in message
news:10802837.1158916654790.JavaMail.itn@is.intellij.net...

Hm. If I create both persistence.xml and orm.xml in the same step the
double clicking on persistence.xml works, but the orm.xml vanishes...



0

Please sign in to leave a comment.