[jboss-user] [JBoss Seam] - Re: All injections are disinjected when used in a component

zzjb do-not-reply at jboss.com
Thu Oct 26 10:45:37 EDT 2006


Gavin,

It's my bad. The @in works fine with @unwrap. The real question is I defined some inside class and @in not work in that case. In before I defined the class in @unwrap, now I move it out.

@Scope(ScopeType.EVENT)
@Name("taskListTest")
public class TaskListTest {
	private CustomMap map;
	@In (create=true)
	private User lgactor;
	public Map getTestMap() {
		if (map == null) {
			map = new CustomMap();
			map.registerExecutionListener(new MapExcecutionListener(){
				public Object perform(Object key) {
					return lgactor.getId();
				}
			});
		}
		return map;
	}
}

public class CustomMap extends AbstractMap implements Serializable{
	private HashMap<String, Object> localMap;
	private MapExcecutionListener listener;
	
	public void registerExecutionListener(MapExcecutionListener listener) {
		this.listener = listener;
	}
	
	@Override
	public Set entrySet() {
		throw new UnsupportedOperationException();
	}
	
	@Override
    public Object get(Object key) {
		if (this.listener == null) return null;
		if (localMap == null) localMap = new HashMap<String, Object>();
		else if (localMap.containsKey(key)) return localMap.get(key);
		Object obj = listener.perform(key);
		localMap.put(key.toString(), obj);
		return  obj;
	}

}
public interface MapExcecutionListener {
	
	public Object perform(Object key);
	
}

The lgactor is null in the sample code. Could I use @in in that way? Thanks.

Zhong


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3981040#3981040

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3981040



More information about the jboss-user mailing list