I've seen two different strategies of injecting objects in Seam (in my case a DAO)
1.
@In(create="true")
private WeirdDao weirdDao;
...
@Name("weirdDao")
public class WeirdConcreteDao implements WeirdDao
2.
@In
private WeirdDao weirdDao;
...
@Name("weirdConcreteDao")
public class WeirdConcreteDao implements WeirdDao
...
components.xml
<factory auto-create="true" name="weirdDao" value="#{weirdConcreteDao}"/>
My theory is that in the second example Seam is taking care of the creation of the object and (hopefully) controls something like a pool of its instances.
Is there any oficial explanation of the pro/con of the usage of these two?
Thanks in advance!
What is the advantage of built in factory in Seam 2
341 Views Asked by johannes.schmidt.delaunay At
1
There are 1 best solutions below
Related Questions in JAVA
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in SEAM
- disabled button seems enabled
- How to load config.properties file in a Seam Application using web.xml context-param
- onChange not Firing with Richfaces
- JSF 2.1 and Seam: s:token still required
- javax.el.ELException: java.lang.IllegalArgumentException: Cannot convert .. to class java.lang.Long
- request error, status : 0 pop up with a4j:support
- Handing exceptions in Quartz thread in Seam
- Which converters Seam used by default for parameters passed to page.xml
- What is the advantage of built in factory in Seam 2
- h:commandLink inside richfaces dataTable not working properly after pressing browser back button
- Handling concurrent call to conversational components on JBoss Seam
- JBoss6 : HTTP 404 while rendering (SEAM)
- how to use a seam validator in jsf?
- Hibernate native query - char(3) column
- Class cast exception on stateful ejb
Related Questions in SEAM2
- Fully disable Weld JSF integration in Wildfly 8.2
- Different ThreadPools for Seam's @Asynchronous?
- java.lang.IllegalStateException: No phase id bound to current thread (make sure you do not have two SeamPhaseListener instances installed)
- Seam Mail with JSF 2 / MyFaces
- What is the advantage of built in factory in Seam 2
- jsf input validation inside ajax4jsf actionlistener method
- JBoss6 : HTTP 404 while rendering (SEAM)
- How to show a bold message with Seam 2 StatusMessages?
- Seam hibernate delete orphan problem
- Primefaces with Seam
- Mavenized Seam 2.3.1.Final project get FileNotFoundException while trying to access a simple view
- Manually Invoke JSF Validation in Seam Test
- How to rerender a rich:dataTable
- MyFaces CoDI - Conversations/WindowContext
- seam-2.2.2 java 8 drools update
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The advantage in terms of performance is not that much concern in this case. But the problem is rather philosophical.
Factory Pattern is a well-known Creational design pattern. In Seam, we generally use
factory methodto created the instances ofEntityorDomaintype Classes. They generally holds data and does not has any processing or business logic.For injecting the beans like Service or DAO, we generally don't use factory.
The main cause is, creation of Service or DAO type beans do not hold states or depend on any states. So why would I take the headache of writing factory method or configuration for that, where I can easily transfer the responsibility to the container.
But in case of
EntityorDomaintype beans may differ depending on states. For example, you need to create spouse bean depending on the user logged in. To do that you write a factory method to create spouse bean depending on the user. You generally do not depend on container to do that.Hope this helps!