Erkin Kanlioglu wrote:Hi
1-) Separation of web tier from application tier is inevitable but it doesn't have to reflect on deployment.
In reality, we deploy web tier and application tier on the same jvm instance and we try to use local executions/calls instead of remote executions. So annotations are there to use and for fast development.
(Clustering between jvm instances which serve web+application)
If we ignore from the beginning these realities, so what is the point investing on these new ideas?
Note: Yes, Ideal solution could be
a) to have different jvm instances for web and application tiers
b) to use remote call between them
c) ssing different physical nodes (even more ideal) and arranging DMZ.
d) then writing Business Delegate, Service Locator
My suggestion would be...
JSP Page --> FacesServlet --> Managed Beans(Facade) --> Stateless Session Beans --> ??? --> Entity
SCJP, SCBCD, SCEA 5, MCP
How to pass SCEA 5 | 2, 3, N-tier which one should I pick? | Analysis of persistence layer from SCEA 5 perspective | Swing... why not?
Erkin Kanlioglu wrote:Hi
2) I put question marks before Entity as I believe that it would be good to use some abstraction with generics --> Yes genericDAO )
Even though JPA is domain store implementation and easy to use, it is good to have a generic DAO for all basic operation and more specific DAO implementation for getting closer to domain.
For DDD friends, from my perspective
Repository implementations sounds/smells like DAO.
Functional approach is better than object oriented approach to follow to get some information from domain.
Note: I agree that DAO should NOT be accessed/injected as SLSB. Factory which takes EntityManager as a parameter is better solution if you are not using Spring.
SCJP, SCBCD, SCEA 5, MCP
How to pass SCEA 5 | 2, 3, N-tier which one should I pick? | Analysis of persistence layer from SCEA 5 perspective | Swing... why not?
Erkin Kanlioglu wrote:
3) TO (Transfer Object)
As far as I can see, most of us discarded using TO as entities are pojo and detached entity can be used in the view tier.
still not sure it is right approach to take as every change on entity might mean change on view as well... Keeping derivative fields on the entity or
putting some even very simple logic on the view to derive a field doesnt sound good.
Duke's Bank Example on JEE is still using TO pattern.
Note: I didnt like to see that Sun's reference implementation is using SFSB heavily even though it can ben solved with SLSB.
SCJP, SCBCD, SCEA 5, MCP
How to pass SCEA 5 | 2, 3, N-tier which one should I pick? | Analysis of persistence layer from SCEA 5 perspective | Swing... why not?
Insurance Systems- Architect.
SCBCD 5, SCWCD 1.4, MCP VB 6.0
Prabu Senthyl Arumugam wrote:
2. Same with the Service locator pattern - EJB3 already has dependancy injection?
SCJP, SCBCD, SCEA 5, MCP
How to pass SCEA 5 | 2, 3, N-tier which one should I pick? | Analysis of persistence layer from SCEA 5 perspective | Swing... why not?
Insurance Systems- Architect.
SCBCD 5, SCWCD 1.4, MCP VB 6.0
Juan Pablo Crossley wrote:
Erkin Kanlioglu wrote:Hi
1-) Separation of web tier from application tier is inevitable but it doesn't have to reflect on deployment.
In reality, we deploy web tier and application tier on the same jvm instance and we try to use local executions/calls instead of remote executions. So annotations are there to use and for fast development.
(Clustering between jvm instances which serve web+application)
If we ignore from the beginning these realities, so what is the point investing on these new ideas?
Note: Yes, Ideal solution could be
a) to have different jvm instances for web and application tiers
b) to use remote call between them
c) ssing different physical nodes (even more ideal) and arranging DMZ.
d) then writing Business Delegate, Service Locator
My suggestion would be...
JSP Page --> FacesServlet --> Managed Beans(Facade) --> Stateless Session Beans --> ??? --> Entity
Hi Erkin, I like the points you are trying to discuss, and because I have thoughts on each point I will put them separately.
You're right most of the applications are deployed on a single jvm, but the experience showed me that you must take special care of the exceptions, I work to a company as an architect of a solution that is deployed in almost 100 clients around the world, and every single client has different "ideas" (to put it in a word...) in 5% of them they required us to separate the static part (html, gifs, css, etc) in a web application (apache), must of the clients does this and it's a good practice, and those clients demands that the jsps and servlets must be in a different web container (tomcat or other) arguing security and other things, and the rest (EJBs, etc) will be deployed in other server with clustering capabilities and so on. So, if I don't take care of what will be this 5% of the non-functional requirements I will be in a nightmare with those clients, because of that I must try to cover all the possible scenarios in the real life...
I must say that EJB 3 solved a lot of this things, just put the interface, and use the deployment descriptor, Service Locators, to solve the remote/local deployment problem. (business-local business-remote in the deployment descriptor it's a very good way to solve this without changing the code, but.... your design should be aware of this or you will have serious problems in the performance).
IMHO.
(I'm not an english speaker, so if something is not clear, please let me know and I could discuss it)
Juan Pablo Crossley wrote:
Erkin Kanlioglu wrote:Hi
2) I put question marks before Entity as I believe that it would be good to use some abstraction with generics --> Yes genericDAO )
Even though JPA is domain store implementation and easy to use, it is good to have a generic DAO for all basic operation and more specific DAO implementation for getting closer to domain.
For DDD friends, from my perspective
Repository implementations sounds/smells like DAO.
Functional approach is better than object oriented approach to follow to get some information from domain.
Note: I agree that DAO should NOT be accessed/injected as SLSB. Factory which takes EntityManager as a parameter is better solution if you are not using Spring.
Ok, here I go again.
I'm not really getting exactly what you meant with a GenericDAO, if you're saying an Class with generics as definition to control all the different entities in your application, I'm not sure if you could handle all the different situations with this approach,
I think the Facade pattern fits better in this problem, and will be able to do some modifications (complementary work) just before saving the entity into the persistence layer (JPA), if you don't change anything in your entities you could think some sort of abstraction using an AbstractFacade with the default methods create, edit, delete, findAll, etc in it. and you could implement some SLSB overriding the abstract (with no methods, because the main ones are defined in the abstract class) that will leave the door open if you need some sort of customization in the future. The abstract facade will have a reference to the EntityManager. That's it... simple, manageable, scalable, maintainability, etc.
Juan Pablo Crossley wrote:
Erkin Kanlioglu wrote:
3) TO (Transfer Object)
As far as I can see, most of us discarded using TO as entities are pojo and detached entity can be used in the view tier.
still not sure it is right approach to take as every change on entity might mean change on view as well... Keeping derivative fields on the entity or
putting some even very simple logic on the view to derive a field doesnt sound good.
Duke's Bank Example on JEE is still using TO pattern.
Note: I didnt like to see that Sun's reference implementation is using SFSB heavily even though it can ben solved with SLSB.
Ok, this one is "funny", when I started using EJB 3.0 as implementation I thought the same thing, POJOs=TO so... what the hell!, but the practice said something else, most of my entities (and I use a lot of them... as I mentioned before the application is HUGE and worldwide deployed, with a lot of customers on it) had relationships with other entities, because I don't want to load all the DB in a single call most of the relations are defined as lazy, when you pass the entity to the web level the deattached entity does not fill this relations if you never call them before, so the Deattached entity contain only the first level filled (and randomly some relations filled, I said "radomly" because in some cases the entity will need that relation and will be filled by the JPA) so the TO received will not suite well in most situations, on the other hand the logic behind the entity is larger than the one that the web should know, let me explain this in a simple sample:
Let's say that I have a Customer, Salary, and other relationships and I'm creating a list of customers with their salary, this means that the web should know how the customer and the salary are related to each other (and that could have different paths), so it's better to solve this in the Business layer instead of the web layer, and I will create a TO with something like:
CustomerSalaryTO {
name: String,
company: String,
income: double,
etc...
}
in this way the Web will not be attached to the logic of how the income is calculated, if I change the business layer in other to include new incomes, the web layer will be the same...
I hope this is what you were talking about, and I didn't misunderstood your point...
Erkin Kanlioglu wrote:
If I didn't misinterpret your comment above, GenericDAO is same thing with AbstractFacade. There is even a nice example on google code.
GenericDAO
Thanks again
SCJP, SCBCD, SCEA 5, MCP
How to pass SCEA 5 | 2, 3, N-tier which one should I pick? | Analysis of persistence layer from SCEA 5 perspective | Swing... why not?
Erkin Kanlioglu wrote:
Basically, we are at the same point... BTW, Have you started using Scala on your project? Good to hear that somebody convince their manager to use Scala
SCJP, SCBCD, SCEA 5, MCP
How to pass SCEA 5 | 2, 3, N-tier which one should I pick? | Analysis of persistence layer from SCEA 5 perspective | Swing... why not?
Be reasonable. You can't destroy everything. Where would you sit? How would you read a tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|