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
342 views Asked by johannes.schmidt.delaunay At
1
There are 1 answers
Related Questions in JAVA
- I need the BIRT.war that is compatible with Java 17 and Tomcat 10
- Creating global Class holder
- No method found for class java.lang.String in Kafka
- Issue edit a jtable with a pictures
- getting error when trying to launch kotlin jar file that use supabase "java.lang.NoClassDefFoundError"
- Does the && (logical AND) operator have a higher precedence than || (logical OR) operator in Java?
- Mixed color rendering in a JTable
- HTTPS configuration in Spring Boot, server returning timeout
- How to use Layout to create textfields which dont increase in size?
- Function for making the code wait in javafx
- How to create beans of the same class for multiple template parameters in Spring
- How could you print a specific String from an array with the values of an array from a double array on the same line, using iteration to print all?
- org.telegram.telegrambots.meta.exceptions.TelegramApiException: Bot token and username can't be empty
- Accessing Secret Variables in Classic Pipelines through Java app in Azure DevOps
- Postgres && statement Error in Mybatis Mapper?
Related Questions in SEAM
- Seam @Scope(ScopeType.CONVERSATION) behaves like request scoped
- Problem with CSVParser: can only iterate over an array or an instance of java.lang.iterable
- Context root automatically changing to temp folder name in JBOSS EAP 6.4
- How to deal with org.jboss.seam.security.NotLoggedInException?
- how to get a seam selection file?
- Does Wildfly 18 Supports Seam 2.3 Applications?
- Java richfaces fileUpload document.domain
- Always get an Error 404 when i try to get swagger.json
- How to merge 2 version of same very large project
- How can I prevent the default onRowClick action from being executed when clicking on an item in a table row?
- how to remove those ugly seams between patch boundaries from the texture atlas?
- Hibernate 5 persist and refresh an entity ends with this instance does not yet exist as a row in the database
- How to resolve an exception related to rest api POST request?
- What happens when I inject a Stateless Bean into a Stateful Bean?
- Resteasy in seam application is not working
Related Questions in SEAM2
- JSF1.2 seam2 websphere 8.5.5 NullPointerException
- How to navigate to different pages on the basis of query params by jsf page initialization in the corresponding controller
- Use mock service in Seam project
- How to resolve an exception related to rest api POST request?
- Resteasy in seam application is not working
- Consume Spring Boot REST service in JBOSS Seam Application
- jsf input validation inside ajax4jsf actionlistener method
- Jboss successfull event is not firing
- The class 'org.javassist.tmp.java.lang.Object_$$_javassist_seam_2' does not have the property
- reRender a rich:dataTable cell in a Seam page from another page
- Multiple @DataModelSelection setters
- Arquillian tests for an application with Seam 2.2.1 with JSF 1.2 and Richfaces 3.3.3 with managed JBoss 7.2
- Entities, JSF and abstraction
- Seam 2.3.1 Final not working in Java 1.7
- UserTransaction in wildfly 8.2.0
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?
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)
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!