You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Fairouz Fakhfakh <fa...@gmail.com> on 2012/03/20 11:34:09 UTC

create instance iPOJO

Hello,
I would like to create a dynamic instance with iPOJO.
I tried to follow this link:
http://www.scribd.com/doc/64361631/130/Instantiating-components-with-iPOJO
page 406
I try to write this method "create":

private Factory helloFactory;
private Map<String, ComponentInstance> instances =new HashMap<String,
ComponentInstance>();
*public void create(String name) *
{ Hashtable props = new Hashtable();
props.put("kind", name);
ComponentInstance instance = null;
try {
instance = helloFactory.createComponentInstance(props);

} catch (UnacceptableConfiguration e) {
 e.printStackTrace();
} catch (MissingHandlerException e) {
 e.printStackTrace();
} catch (org.apache.felix.ipojo.ConfigurationException e) {
 e.printStackTrace();
}
instances.put(name, instance);
}

But it generates this error: Exception in thread "AWT-EventQueue-0"
java.lang.NullPointerException
        at trmcs.alarm.HelpSe
rviceAlarmImpl.__create(HelpServiceAlarmImpl.java:107)
in the line:* **instance = helloFactory.createComponentInstance(props);*
So, I understand that helloFactory is null.
But, I dont' know why can I correct that to create an instance of a
component?
Thank for answering me.
Best regards,

--
Fairouz Fakhfakh

Master Student
National School of Engineers of SFAX

Research group ReDCAD
http://WWW.redcad.org <http://www.redcad.org/>