[JBoss Seam] - Object disappear
by Phantom
Good day,
Let me show you a real magic! But I don't know the secret... If you know it - please describe me! It's real problem for me...
1 Class:
| package xxx.finders;
|
| import org.jboss.seam.framework.EntityController;
| import org.jboss.seam.log.Log;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.Transactional;
| import xxx.Lecture;
|
| import java.util.List;
| import java.util.ArrayList;
|
| public class AbstractFinder<K>
| {
| private String query;
|
| private List<K> result;
|
|
| public final String getQuery()
| {
| return query;
| }
|
| public final void setQuery(String query)
| {
| this.query = query;
| }
|
| @Transactional
| public void search()
| {
| System.out.println("start search. This:"+this);
| this.result = searchResult();
| System.out.println("Cal result: "+result+" This:"+this);
| }
|
| @Transactional
| protected List<K> searchResult()
| {
| return new ArrayList<K>();
| }
|
| @Transactional
| public final List<K> getResult()
| {
| System.out.println("Start getResult. this:"+this);
| if(result==null)
| {
| System.out.println("searching"+this);
| search();
| System.out.println("Cal result: "+result+" This:"+this);
| }
| System.out.println("result: "+result+"this:"+this);
| return result;
| }
| }
|
2 class
| package xxx.finders;
|
| import xxx.testtree.Test;
|
| import java.util.List;
| import java.util.ArrayList;
|
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Scope;
| import org.jboss.seam.log.Log;
| import org.jboss.seam.ScopeType;
|
| import javax.persistence.EntityManager;
|
| @Name("testFinder")
| public class TestFinder extends AbstractFinder<Test>
| {
| @In
| private EntityManager entityManager;
|
| @Logger
| private Log log;
|
| protected List<Test> searchResult()
| {
| log.info("Invoked!!!");
| String query = getQuery();
| if(query==null || query.equals(""))
| {
| List<Test> tests = (List<Test>)entityManager.createQuery("select object(t) from Test t order by t.title").getResultList();
| log.info("Tests: "+tests);
| return tests;
| }
| else
| {
| List<Test> ret = new ArrayList<Test>();
| String sql = "select object(t) from Test t where t.title like :query order by t.title";
| ret.addAll(entityManager.createQuery(sql).setParameter("query", "%"+query+"%").getResultList());
| sql = "select object(t) from Test t, Domain d where t.domain=d and d.title like :query order by t.title";
| ret.addAll(entityManager.createQuery(sql).setParameter("query", "%"+query+"%").getResultList());
| return ret;
| }
| }
| }
|
Now the magic!
Externaly from JSF page I'm trying to get result property from 'testfinder' bean. And there I recieve null! But look to the logs:
| 2007-10-31 14:43:09,921 INFO [STDOUT] start search. This:xxx.finders.TestFinder@f09d3d
| 2007-10-31 14:43:09,921 INFO [xxx.finders.TestFinder] Invoked!!!
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.SQL] select test0_.test_id as test1_74_, test0_.title as title74_, test0_.content as content74_, test0_.author_id as author5_74_, test0_.domain_id as domain4_74_ from tests test0_ order by test0_.title
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[xxx.testtree.Test#1]
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections
| 2007-10-31 14:43:09,921 INFO [xxx.finders.TestFinder] Tests: [xxx.testtree.Test@1]
| 2007-10-31 14:43:09,921 INFO [STDOUT] Cal result: [xxx.testtree.Test@1] This:xxx.finders.TestFinder@f09d3d
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Transaction already joined
| 2007-10-31 14:43:09,921 INFO [STDOUT] Cal result: null This:xxx.finders.TestFinder@f09d3d
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Transaction already joined
| 2007-10-31 14:43:09,921 INFO [STDOUT] result: nullthis:xxx.finders.TestFinder@f09d3d
|
Most interesting (the first and the last line):
| 2007-10-31 14:43:09,921 INFO [STDOUT] Cal result: [xxx.testtree.Test@1] This:xxx.finders.TestFinder@f09d3d
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Looking for a JTA transaction to join
| 2007-10-31 14:43:09,921 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] Transaction already joined
| 2007-10-31 14:43:09,921 INFO [STDOUT] Cal result: null This:xxx.finders.TestFinder@f09d3d
|
That's mean that object disapear somewhere between method invokation! But where and why???
Please, help me!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100602#4100602
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100602
17Â years, 2Â months
[JBoss Seam] - @unwrap that manages backing beans...
by gagool
Hello, I would like to manage access to multiple instances of backing beans .
I would like something like this but working.
| @Name("perCellForm")
| public class PerCellFormBean implements PerCellForm {
|
| HashMap<Long, FormAction> cells = new HashMap<Long, FormAction>(10);
|
| @In
| private Cell currentCell;
|
| @Unwrap
| public FreeAction getCell() {
|
| if (cells.containsKey(currentCell.getId())) {
| return cells.get(currentCell.getId());
| } else {
|
| Object component = Component.getInstance("FormAction", true);
|
| cells.put(currentCell.getId(), (FormAction) component);
| return (FormAction) component;
| }
| }
|
| @Destroy
| @Remove
| public void remove() {
|
| }
| }
|
Object component = Component.getInstance("FormAction", true);
Obviously doesn't work since the component only will be created once and then just re-gotten from the conversation context.
Is it possible to do a manager such as this with seam?
I need to be able to dynamically assign multiple instances of stateful backing beans for forms.
I need seam to actually instantiate multiple instances and be able to hold references to them, how do I do that?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100601#4100601
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100601
17Â years, 2Â months
[JBoss Seam] - Interceptor not working!
by jbeaken
Hi,
I've looked through the forum and found a few posts regarding interceptors, but none seam to help me with my problem, when the annotated method is called the @AroundInvoke method is not called.
Any ideas where I'm going wrong would be greatly appreciated
The annotation :
| package com.ricall.security;
|
| import java.lang.annotation.ElementType;
| import java.lang.annotation.Retention;
| import java.lang.annotation.RetentionPolicy;
| import java.lang.annotation.Target;
| import org.jboss.seam.annotations.Interceptors;
|
| @Target(ElementType.METHOD)
| @Retention(RetentionPolicy.RUNTIME)
| @Interceptors(com.ricall.security.SecurityManager.class)
| public @interface IsAuthorised {
|
| long securityRole();
| }
The interceptor
| package com.ricall.security;
|
| import javax.interceptor.AroundInvoke;
| import javax.interceptor.InvocationContext;
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Interceptor;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Out;
| import org.jboss.seam.annotations.Scope;
| import org.jboss.seam.log.Log;
| import com.ricall.domain.security.SecurityCredentials;
| import com.ricall.domain.subsite.Subsite;
| import com.ricall.domain.user.User;
| import com.ricall.exception.RicallException;
| import com.ricall.repository.security.SecurityCredentialsRepository;
| import com.ricall.repository.subsite.SubsiteRepository;
| import com.ricall.repository.user.UserRepository;
|
| @Name("securityManagerService")
| @Scope(ScopeType.APPLICATION)
| @Interceptor
| public class SecurityManager {
|
| @AroundInvoke
| public Object authorise(InvocationContext invocation) throws Exception {
| Object[] params = invocation.getParameters();
| if (params != null) {
| for (Object obj : params) {
|
| System.out.println(obj);
| }
| }
|
| throw new RicallSecurityException("cannot do this! hands off!");
| }
| etc....
| }
|
|
The annotated method
@Create
| @IsAuthorised(securityRole = SecurityManager.isAdmin)
| @Begin(join = true)
| public void create() {
| log.debug("In @Create, beginning conversation");
| userFolderSearchCriteria = new UserFolderSearchCriteria();
| }
I've also tried annotated non @Create methods
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100599#4100599
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100599
17Â years, 2Â months
[Beginners Corner] - Re: message format in .properties file
by mars1412
well, after some other checks, it turned out, that the message string is not read corectly from the .properties file
string in .properties file:
mtr.test.param.format=string {1} currency {0,number,#.#} integer {2,number,integer} date {3,date,short}.
when I output the message string in the HTML page,
<p>#{messages['mtr.test.param.format']}</p>
it is rendered, as:
anonymous wrote : string {1} currency {0} integer {2} date {3}.
any idea why?
or can you at least tell me, where the problem is?
is this a JSF issue, or might it be a problem with (JBoss) or SEAM?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100597#4100597
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100597
17Â years, 2Â months
[JBoss Seam] - AspectJ/Jboss Seam integration ?
by jayzaw
Hi,
I am using AspectJ for verifying preconditions within a call to a service's business operation method. So, to do this I use around(), which means:
- when entering, the preconditions applying have to be verified by calling the methods. The method names of the preconditions are in a database (cached). They should be called by reflection.
- the problems I have are:
a) for using reflection, I have to be able to reference the class' name. Unfortunately, "this" - within an aspect's advice means a reference to the aspect or the advice. But not the class in which the operation currently executes.
b) the project is a JBoss Seam project. The Jboss Seam component incorporating the service is annotated to be a stateless session bean. So I wonder whether:
b1) AspectJ and Jboss Seam components will have conflicts (Seam uses annotations and maybe other technologies which might conflict with AspectJ)
b2) how to integrate AspectJ in a Jboss Seam project - when trying to create an aspect in my Jboss Seam project, it complains that this is not an AspectJ project
b3) what I should look out for when deploying the project (the aspects should be "weaved" into the code at precompile- or compile-time.
Kind regards,
Jay
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100595#4100595
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100595
17Â years, 2Â months