How to create an iPOJO Component at runtime 학술

See How to use iPOJO Factories

1. Find iPOJO Component Factory reference.
----
import org.apache.felix.ipojo.Factory;

public ServiceReference getComponentFactoryReference(String factoryClassName) {
  try {
    ServiceReference[] refs = bundleContext.getServiceReferences(
      Factory.class.getName(),
      "(component.class=" + factoryClassName + ")");

    if (refs == null || refs.length == 0)
      return null;

    return refs[0];
  } catch (InvalidSyntaxException e) {
  ...
  }
  return null;
}

2. Get iPOJO Component Factory.
ServiceReference factoryReference = getComponentFactoryReference(YOUR_COMPONENT_CLASS_NAME);
Factory factory = (Factory) context.getService(factoryReference);

3. Create iPOJO Component using iPOJO Component Factory.
Properties configuration = new Properties();
// additional component configuration here..
ComponentInstance instance = factory.createComponentInstance(configuration);
instance.start();

트랙백

이 글과 관련된 글 쓰기 (트랙백 보내기)
TrackbackURL : http://www.xeraph.com/tb/4915517 [도움말]

덧글

댓글 입력 영역