Jaime
"Architecture without code is empty; code without architecture is blind." [Martin Kalin]
Jaime
"Architecture without code is empty; code without architecture is blind." [Martin Kalin]
Jaime Bravo wrote:
1. DAO is a pattern and not only the artifact.
Jaime Bravo wrote:
2. On the other side, SLSB is an artifact and not the service tier, itself. So without problems, an SLSB could be in integration tier.
Jaime Bravo wrote:
But actually look up a dependency from inside the DAO class is not a good practice, because you're creating a dependency with the lookup mechanism and details about the same one. And this fact adds another responsability to the DAO class, that is: find its dependencies. So the class becomes less cohesive. For example if you change the JNDI name for the dependendy then....you know. So Dependency Injection pattern is the winner against the Service Locator pattern.
Jaime Bravo wrote:
5. "What's more, if you create DAO from SLSB, that means, client can probably skip other service tier wrapper SLSB to directly call those DAO SLSBs. " You can prevent that situation. Take a look to this code:
jianming chen wrote:
Yes, but DAO is an integration tier pattern. Based on the DAO pattern definition on Core J2EE Pattern, Use a Data Access Object (DAO) to abstract and encapsulate all access to the data source. The DAO manages the connection with the data source to obtain and store data.
jianming chen wrote:
Jaime Bravo wrote:
2. On the other side, SLSB is an artifact and not the service tier, itself. So without problems, an SLSB could be in integration tier.
I think the idea of injecting EntityManager into SB is kind of mixing business tier and integration tier. The boundary of each tier is not clear any more. The major benefits of EJB container are security, transaction management. So it's best for business tier. DAO layer should be able to site outside of EJB container. Probably you want to re-use DAO component in other project deployed outside of EJB container.
jianming chen wrote:
DAO pattern should provide unified interface for any kind of resources. It doesn't make much sense to wrap any other resource accessing code inside SLSB. Such as LDAP access, Web service client etc.
jianming chen wrote:
Jaime Bravo wrote:
But actually look up a dependency from inside the DAO class is not a good practice, because you're creating a dependency with the lookup mechanism and details about the same one. And this fact adds another responsability to the DAO class, that is: find its dependencies. So the class becomes less cohesive. For example if you change the JNDI name for the dependendy then....you know. So Dependency Injection pattern is the winner against the Service Locator pattern.
Before EJB container can specify other classed inside DI context, I'd rather use other DI provider to manage dependencies in DAO layer.
1. Do you have such a requirement?
You are adding one more dependency to your project, instead of reusing the existing dependecy on the EJB container.
Client could be the upper tier running inside same container. "Local" wouldn't avoid those clients directly access SLSB DAOs.
SCJP 5 , SCWCD 5, SCEA 5
jianming chen wrote:
1. Do you have such a requirement?
We do have requirement like this. Sometimes we want to create some sort of quick tool outside of the Web Application which requires access to the database. Or sometimes Swing application.
SCJP, SCWCD, OCMJEA, OCEEJBD, OCEJPAD, TOGAF® 9 Certified, OCEJWSD
So what you are saying Jaime, Session Bean(service) ===> Stateless Session Bean(DAO) ===> JPA ?
Is this applicable if the Session Bean(service) is Stateful ?
Is there really a need for the DAO layer at all ?
Jaime
"Architecture without code is empty; code without architecture is blind." [Martin Kalin]
SCJP, SCWCD, OCMJEA, OCEEJBD, OCEJPAD, TOGAF® 9 Certified, OCEJWSD
Jaime
"Architecture without code is empty; code without architecture is blind." [Martin Kalin]
SCJP, SCWCD, OCMJEA, OCEEJBD, OCEJPAD, TOGAF® 9 Certified, OCEJWSD
Screaming fools! It's nothing more than a tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
|