I have a question reg开发者_运维技巧arding best practices in application design using JBoss Seam. I intend to implement a Seam based application, but I want to keep the entity model loosely coupled. ( that is because I want to be able to use it in non-Java EE environment) One solution I think of, is to have additional layer of DTO's defined as Seam-components that I can use to transport information between markup and entities.But I think it's not an elegant solution.
What are the best practices to externalize the entity model in a Seam application but being able to use most of the Seam features?
In general the entities are just Java objects with properties that are annotated (JPA). So you only have worry about the JPA annotations as dependencies if you use the model in another application. This would only be one jar with declarations and no run time implications.
Or do you have any special plans for the entities in Seam, e.g. use them as entity beans (not sure of the benefits) and therefore introduce more complex dependencies?
A more clean, but also more complicated solution, would be to use interfaces for the entity definition and have concrete implementations for different applications, e.g. JPA annotated beans for Seam and unannotated beans for other applications. This can be done manually of course or with the help of a framework. I have used Eclipse EMF to generate a JPA model that is abstracted by an interface to use in other applications, but because of EMFs default way of handling bi-directional dependencies, etc. there are some caveats.
精彩评论