aspose file tools*
The moose likes Other Application Frameworks and the fly likes Spring and EJBs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Spring and EJBs" Watch "Spring and EJBs" New topic
Author

Spring and EJBs

JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
Hi authors (and others)

According to what I see in the ToC of the book, ther's no section dedicated to EJBs.
Do you consider Spring with EJB as a non-sense or could it be an option under certain circumstances ??


/ JeanLouis<br /><i>"software development has been, is, and will remain fundamentally hard" (Grady Booch)</i><br /> <br />Take a look at <a href="http://www.epfwiki.net/wikis/openup/" target="_blank" rel="nofollow">Agile OpenUP</a> in the Eclipse community
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
I think Spring is a lighter form of EJB or in other words provides the same functionailies as EJB; need some verification from Spring gurus.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
I have not read the book but there in an article by the authors that discusses the Spring - EJB integration.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Anselm Paulinus:
I think Spring is a lighter form of EJB or in other words provides the same functionailies as EJB

Kind of, yes. Spring comes in a number of modules that provide different services/features. The bean container, transaction management, and ORM framework pretty much offer all the things EJB has to offer -- with the option of delegating from a Spring bean to an EJB if required. Spring also provides things outside the EJB realm such as an AOP framework.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
Does Spring provides declarative security like EJBs (on components and/or methods) ?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by JeanLouis Marechaux:
Does Spring provides declarative security like EJBs (on components and/or methods) ?


I found this from Spring doc
Spring also provides an access layer and abstraction layer for Enterprise JavaBeans, enabling you to reuse your existing POJOs and wrap them in Stateless Session Beans, for use in scalable failsafe web applications, that might need declarative security.


Groovy
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by JeanLouis Marechaux:
Does Spring provides declarative security like EJBs (on components and/or methods) ?

Yes, through the Acegi security framework.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Originally posted by Lasse Koskela:

Yes, through the Acegi security framework.


Thanks a lot for the link.
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
So I've got to use yet another framework.
And as far as i know, that's the same problem if I want to do JMS ...there's another framework to use, right ?

So instead of using 1 framework, EJB, which is said to be too heavyweight, I'm gonna used 10 different lightweight frameworks, from different providers...
Is this really an improvement ?
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
Originally posted by Lasse Koskela:

Yes, through the Acegi security framework.


Moreover, sounds like Acegi is not JAAS compliant.
To complex according to them....
But I,m sure I can find yet another framework which will have JAAS capabilities in addition to Acegi :roll:
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by JeanLouis Marechaux:
Is this really an improvement ?


Improvement yes , because you dont need to run inside a container anymore.
You dont need to code an enterprise bean with 2 interfaces, bean class etc.
Using them is pretty trivial. You just need to configure a acegi interceptor in your spring config file. You can specify the method names of the bean you want to secure using wild card expressions etc.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by JeanLouis Marechaux:


Moreover, sounds like Acegi is not JAAS compliant.



The faq indicates that they didnt base their framework on jaas but you do have a jaas provider and you can delegate authenticaton to jaas. Yes it does say that jaas authorization is an issue.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by JeanLouis Marechaux:
I'm gonna used 10 different lightweight frameworks, from different providers...
Is this really an improvement ?


Yes but you will end up multiple framework jar files. As per my understanding other than Spring MVC and AOP, I dont think Spring provides anything by itself. Now I dont know how restrictive the licences are for these frameworks.
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906


Improvement yes , because you dont need to run inside a container anymore.


I'm gonna start another thread on that subject, because I think I'm missing the point...


You dont need to code an enterprise bean with 2 interfaces, bean class etc.
Using them is pretty trivial. You just need to configure a acegi interceptor in your spring config file. You can specify the method names of the bean you want to secure using wild card expressions etc.


So to simplify the EJBs, I'm gonna move the java code ( 2 interfaces + bean class) into configuration files (Spring XML). WOW....
Are you guys developing EJBs using Notepad ?? Because you know IDEs now do all the job for you
[/QB]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by JeanLouis Marechaux:
So I've got to use yet another framework.
And as far as i know, that's the same problem if I want to do JMS ...there's another framework to use, right ?
Nope. JMS is part of Spring (as in "the classes are in the org.springframework.* namespace).

Originally posted by JeanLouis Marechaux:
So instead of using 1 framework, EJB, which is said to be too heavyweight, I'm gonna used 10 different lightweight frameworks, from different providers...
Is this really an improvement ?

EJB provides remoting, declarative transactions, declarative security, and componentization. Spring core and Acegi together provide all that (and more). That's not too many frameworks for me. Also, even though Spring consists of a number of "modules", it's no different from the EJB spec having Session Beans, Entity Beans and Message-Driven Beans, in my opinion.

I really do consider Spring as an improvement over EJB.

Originally posted by JeanLouis Marechaux:
So to simplify the EJBs, I'm gonna move the java code ( 2 interfaces + bean class) into configuration files (Spring XML). WOW....
Are you guys developing EJBs using Notepad ?? Because you know IDEs now do all the job for you
...and obviously that same XDoclet code generation stuff is available for Spring configuration files as well. Ok, the IDE support is still very much lacking but it shouldn't take too long for there to be enough wizards to satisfy the point-n-click types.
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
Lasse, would you consider Spring if EJB 3.0 were already available ?
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by JeanLouis Marechaux:
Lasse, would you consider Spring if EJB 3.0 were already available ?


Lasse would give his opinion. EJB 3.0 addresses persistance for pojos?
good. But as we have already discussed, we saw that Spring has a AOP, MVC and in general easier ways of doing thigs. For eg check out the Spring JdbcTemplate and see how much we can cut down on code when usign pure jdbc for persistance.
Spring will interoperate with ejb 3.0 when it is out? But I dont see how they are competing technologies. If i use Spring am not tied to EJB 3.0
Lasse will anyways confirm.
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
Based on Lasse's answerthat post, I see Spring and EJBs are competing technologies

Just like I see Spring MVC and Struts as competing technologies
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Lasse, question: Does'nt j2ee spec mandate a jta implementation ?


So to simplify the EJBs, I'm gonna move the java code ( 2 interfaces + bean class) into configuration files (Spring XML). WOW....
Are you guys developing EJBs using Notepad ?? Because you know IDEs now do all the job for you


Yes am not sure what your requirement is. If you need distributed transactions, then you need a jta implementation i guess. That could be the j2ee container / something else.

Either way, Spring does'nt care. I'm not sure what you like about a session bean. I liked declarative trans , security support. So i need to buy weblogic / websphere because i want those features for my facade?.

Spring does'nt have its own transaction implementation. But can delegate to the underlying mechanism. Sprint does not have the security implementation but delagates it to open source acegi framework. Sprint does'nt treat a pojo as inferior (as a j2ee container does) and offers those services without a container in a non intrusive manner. Given this I dont know why I would still like to have 2 interfaces and write a bean that extends another class. Yeah the IDE does it but I'm not sure if i even need it in the first place.
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
Originally posted by Karthik Guru:
Lasse, question: Does'nt j2ee spec mandate a jta implementation ?


Yes, J2EE spec requires JTA support
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Originally posted by JeanLouis Marechaux:
Based on Lasse's answerthat post, I see Spring and EJBs are competing technologies

Just like I see Spring MVC and Struts as competing technologies


Ok may be am missing something form lasse's post. But Lasse is not indicating that Spring has a solution for persistance. He is saying that Spring can work with Hibernate, jdo and may be even ejb 3.0 in the future?.
I also figure that you have partly answered your question. Yes Spring MVC competes with Struts. But it also allows you to interoperate with Struts and not use Spring for MVC at all. So its not about Spring Vs ejb 3.0 anymore because its Spring MVC vs Struts, Spring AOP vs AspectJ and so on.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by JeanLouis Marechaux:
Lasse, would you consider Spring if EJB 3.0 were already available ?
I don't know enough about EJB 3.0 to give you a definite answer. If EJB 3.0 can live up to the buzz, I might very well go with that instead.
JeanLouis Marechaux
Ranch Hand

Joined: Nov 12, 2001
Posts: 906
Ok, I misexplained myself here. Sorry.
I see Spring (the middleware part) and EJB container as competing technologies

I fully understand that Sprint is able to interoperate with EJBs (and thus EJB 3.0), but my understanding is that even if it can do it, it's a kind of non-sense 'cause Spring itself do all what EJB containers offer.

And I also fully understand that Spring is not a persistence framework, but uses Hibernate, JDO or iBatis (or EJBs).
Just like a J2EE architecture can rely on EJB + Hibernate or JDO for the persistence part

Don't get me wrong here, I'm just trying to understand what Spring offers compared to old J2EE Application servers.
So far, my understanding is that it offers everything but XA transaction support
[ February 23, 2005: Message edited by: JeanLouis Marechaux ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by JeanLouis Marechaux:
So far, my understanding is that [Spring] offers everything but XA transaction support

...and a web container to deploy Spring MVC on top of.
Rob Harrop
Author
Ranch Hand

Joined: Nov 03, 2004
Posts: 44
My thoughts on this topic are that Spring can in most cases replace EJBs altogether. However, if your application lends itself to distribution then EJBs are a good choice because they were originally designed for remote access. In this case, you can use Spring EJB support to back your EJBs with Spring services that are easier to test and manage.

This topic is covered in more detail in chapter 13 of Pro Spring.

Rob
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring and EJBs