I am working on an application with several SFSB all implementing the same interface.
To decide at runtime, whiche concrete implementation to use, I have following Factory Method:
@SuppressWarnings("rawtypes")
@Inject @Any Instance<SFSBInterface> sfsbSource;
public <T> SFSBInterface<T> initBeanForm(Class<T> clazz, Class<? extends SFSBInterface<T>> sfsbClass, Annotation... qualifiers) {
SFSBInterface<T> sfsb = sfsbSource.select(sfsbClass, qualifiers).get();
return sfsb;
}
Each concrete implementation does have a @Remove annotated method implemented. Now I have a case, where I want to remove this sfsb and get a new Instance at calling this method.
I am calling the remove method and delete all references to this object, but the instance keeps being in memory. When I now ask for an instance of this class, I am getting the same instance, for which I called the remove before.
My questions are:
- Do I run into problems, if I use this instance, for which I called the remove method?
- Is it normal that the removed instance keeps in memory?
- How can I effectively remove this instance?
- How can I obtain a real new instance of my class?
Kind regards Christian
BTW: I am using JBoss 7.1.1 and Weld