org.apache.felix.ipojo.Factory.createComponentInstance()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(15.5k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.apache.felix.ipojo.Factory.createComponentInstance()方法的一些代码示例,展示了Factory.createComponentInstance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Factory.createComponentInstance()方法的具体详情如下:
包路径:org.apache.felix.ipojo.Factory
类名称:Factory
方法名:createComponentInstance

Factory.createComponentInstance介绍

[英]Creates an instance manager (i.e. component type instance).
[中]创建实例管理器(即组件类型实例)。

代码示例

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.composite

/**
 * Create an instance manager (i.e. component type instance). This has these service interaction in the scope given in argument.
 * @param configuration : the configuration properties for this component.
 * @param serviceContext : the service context of the component.
 * @return the created instance manager.
 * @throws UnacceptableConfiguration : when the given configuration is not valid.
 * @throws MissingHandlerException : when at least one handler is missing.
 * @throws ConfigurationException : when an issue occurs during the oconfiguration of the instance.
 * @see org.apache.felix.ipojo.Factory#createComponentInstance(java.util.Dictionary, org.apache.felix.ipojo.ServiceContext)
 */
public ComponentInstance createComponentInstance(Dictionary configuration, ServiceContext serviceContext) throws UnacceptableConfiguration,
    MissingHandlerException, ConfigurationException {
  return m_delegate.createComponentInstance(configuration, serviceContext);
}

代码示例来源:origin: apache/felix

/**
 * Create an instance manager (i.e. component type instance).
 * @param configuration : the configuration properties for this component.
 * @return the created instance manager.
 * @throws UnacceptableConfiguration : when a given configuration is not valid.
 * @throws MissingHandlerException : occurs when the creation failed due to a missing handler (the factory should be invalid)
 * @throws ConfigurationException : occurs when the creation failed due to a configuration issue
 * @see org.apache.felix.ipojo.Factory#createComponentInstance(java.util.Dictionary)
 */
public ComponentInstance createComponentInstance(Dictionary configuration) throws UnacceptableConfiguration, MissingHandlerException,
    ConfigurationException {
  return m_delegate.createComponentInstance(configuration, m_context);
}

代码示例来源:origin: apache/felix

/**
 * Create an instance manager (i.e. component type instance). This has these service interaction in the scope given in argument.
 * @param configuration : the configuration properties for this component.
 * @param serviceContext : the service context of the component.
 * @return the created instance manager.
 * @throws UnacceptableConfiguration : when the given configuration is not valid.
 * @throws MissingHandlerException : when at least one handler is missing.
 * @throws ConfigurationException : when an issue occurs during the oconfiguration of the instance.
 * @see org.apache.felix.ipojo.Factory#createComponentInstance(java.util.Dictionary, org.apache.felix.ipojo.ServiceContext)
 */
public ComponentInstance createComponentInstance(Dictionary configuration, ServiceContext serviceContext) throws UnacceptableConfiguration,
    MissingHandlerException, ConfigurationException {
  return m_delegate.createComponentInstance(configuration, serviceContext);
}

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.composite

/**
 * Create an instance manager (i.e. component type instance).
 * @param configuration : the configuration properties for this component.
 * @return the created instance manager.
 * @throws UnacceptableConfiguration : when a given configuration is not valid.
 * @throws MissingHandlerException : occurs when the creation failed due to a missing handler (the factory should be invalid)
 * @throws ConfigurationException : occurs when the creation failed due to a configuration issue
 * @see org.apache.felix.ipojo.Factory#createComponentInstance(java.util.Dictionary)
 */
public ComponentInstance createComponentInstance(Dictionary configuration) throws UnacceptableConfiguration, MissingHandlerException,
    ConfigurationException {
  return m_delegate.createComponentInstance(configuration, m_context);
}

代码示例来源:origin: info.kwarc.sally4/mhw-lmh

ComponentInstance createInstance(Factory factory, String name, String path) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
    Dictionary<String, Object> configuration = new Hashtable<String, Object>();
    log.info("creating path "+path);
    log.info("creating name"+name);

    configuration.put("instance.name", name+" for lmh :"+path);
    configuration.put("rootPath", path);
    configuration.put("instanceName", name);

    return factory.createComponentInstance(configuration);
  }
}

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api

/**
 * Creates a component instance from the current type 
 * with the given configuration.
 * @param conf the configuration
 * @return the component instance object.
 * @throws UnacceptableConfiguration the configuration is not acceptable 
 * @throws MissingHandlerException the factory in invalid
 * @throws ConfigurationException the instance configuration failed
 */
public ComponentInstance createInstance(Dictionary conf) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
  ComponentInstance ci = ensureAndGetFactory().createComponentInstance(conf);
  m_instances.add(ci);
  return ci;
}

代码示例来源:origin: fr.velossity.osgi/iPOJOAdapter

/**
 * iPOJO callback to bind a new low device.
 * 
 * @param dev
 *            the disappearing device
 */
public void bindLowDevice(AdapteeDevice dev) {
  Properties props = new Properties();
  props.put("low.device", dev);
  ComponentInstance instance;
  try {
    // Create the instance
    instance = deviceFactory
        .createComponentInstance(props);
    // Store the reference to the new iPOJO instance
    highDevices.put(dev, instance);
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api

/**
 * Creates a component instance from the current type 
 * with an empty configuration.
 * @return the component instance object.
 * @throws UnacceptableConfiguration the configuration is not acceptable 
 * @throws MissingHandlerException the factory in invalid
 * @throws ConfigurationException the instance configuration failed
 */
public ComponentInstance createInstance() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
  ComponentInstance ci = ensureAndGetFactory().createComponentInstance(null); 
  m_instances.add(ci);
  return ci;
}

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.api

/**
 * Creates a component instance from the current type 
 * with the given name.
 * @param name the instance name
 * @return the component instance object.
 * @throws UnacceptableConfiguration the configuration is not acceptable 
 * @throws MissingHandlerException the factory in invalid
 * @throws ConfigurationException the instance configuration failed
 */
public ComponentInstance createInstance(String name) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
  Dictionary dict = null;
  if (name != null) {
    dict = new Properties();
    dict.put("instance.name", name);
  } 
  ComponentInstance ci = ensureAndGetFactory().createComponentInstance(dict); 
  m_instances.add(ci);
  return ci;
}

代码示例来源:origin: info.kwarc.sally4/office-base

void createInstance(Factory factory, String name, String docQueue, String env) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
  Dictionary<String, Object> configuration = new Hashtable<String, Object>();
  Dictionary<String, Object> filters = new Hashtable<String, Object>();
  filters.put("docQueue", "(docQueue="+docQueue+")");
  filters.put("theoEnv", "(environmentid="+env +")");
  configuration.put("requires.filters", filters);
  configuration.put("instance.name", name+" for doc:"+docQueue);
  ComponentInstance inst = factory.createComponentInstance(configuration);
  inst.addInstanceStateListener(new InstanceStateListener() {
    @Override
    public void stateChanged(ComponentInstance arg0, int arg1) {
      if (arg1 == ComponentInstance.INVALID) {
        arg0.dispose();
      }
    }
  });        
}

代码示例来源:origin: org.ow2.kerneos.graniteds-osgi/granite-core

@Validate
public void start() {
  try {
    if (!gravity) {
      Dictionary properties = new Hashtable();
      properties.put("id", id);
      properties.put("uri", uri);
      properties.put("context", context);
      instance = graniteBuilder.createComponentInstance(properties);
    } else {
      Dictionary properties = new Hashtable();
      properties.put("id", id);
      properties.put("uri", uri);
      properties.put("context", context);
      instance = gravityBuilder.createComponentInstance(properties);
    }
  } catch (Exception e) {
    log.error(e, "Invalid Channel configuration");
  }
}

代码示例来源:origin: org.ow2.kerneos.graniteds-osgi/granite-core

@Validate
public void start() {
  try {
    if (defaultAdapter == null) {
      Dictionary properties = new Hashtable();
      properties.put("id", id);
      properties.put("messageTypes", messageTypes);
      properties.put("class", clazz);
      instance = simpleBuilder.createComponentInstance(properties);
    } else {
      Dictionary filters = new Hashtable();
      filters.put("defaultAdapter", "(ID=" + defaultAdapter + ")");
      Dictionary properties = new Hashtable();
      properties.put("id", id);
      properties.put("messageTypes", messageTypes);
      properties.put("class", clazz);
      properties.put("requires.filters", filters);
      instance = adapterBuilder.createComponentInstance(properties);
    }
  } catch (Exception e) {
    log.error(e, "Invalid Service configuration");
  }
}

代码示例来源:origin: apache/felix

/**
 * Create an instance for the given reference. The instance is not added inside the map.
 * @param factory : the factory from which we need to create the instance.
 * @return the created component instance.
 * @throws ConfigurationException : the instance cannot be configured correctly.
 * @throws MissingHandlerException : the factory is invalid.
 * @throws UnacceptableConfiguration : the given configuration is invalid for the given factory.
 */
private ComponentInstance createInstance(Factory factory) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
  // Recreate the configuration to avoid sharing.
  Properties props = new Properties();
  Enumeration keys = m_configuration.keys();
  while (keys.hasMoreElements()) {
    String key = (String) keys.nextElement();
    props.put(key, m_configuration.get(key));
  }
  ComponentInstance instance = null;
  instance = factory.createComponentInstance(props);
  m_handler.info("Creation of a service instance " + instance.getInstanceName());
  return instance;
}

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.composite

/**
 * Create an instance for the given reference. The instance is not added inside the map.
 * @param factory : the factory from which we need to create the instance.
 * @return the created component instance.
 * @throws ConfigurationException : the instance cannot be configured correctly.
 * @throws MissingHandlerException : the factory is invalid.
 * @throws UnacceptableConfiguration : the given configuration is invalid for the given factory.
 */
private ComponentInstance createInstance(Factory factory) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
  // Recreate the configuration to avoid sharing.
  Properties props = new Properties();
  Enumeration keys = m_configuration.keys();
  while (keys.hasMoreElements()) {
    String key = (String) keys.nextElement();
    props.put(key, m_configuration.get(key));
  }
  ComponentInstance instance = null;
  instance = factory.createComponentInstance(props);
  m_handler.info("Creation of a service instance " + instance.getInstanceName());
  return instance;
}

代码示例来源:origin: info.kwarc.sally4/sally4-docmanager

public ComponentInstance create() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
  if (!filters.isEmpty()) {
    configuration.put("requires.filters", filters);
  }
  ComponentInstance inst = factory.createComponentInstance(configuration);
  inst.addInstanceStateListener(new InstanceStateListener() {
    @Override
    public void stateChanged(ComponentInstance arg0, int arg1) {
      if (arg1 == ComponentInstance.INVALID) {
        arg0.dispose();
      }
    }
  });    
  return inst;
}

代码示例来源:origin: org.ow2.kerneos/kerneos-core-server

@Override
public synchronized void addModule(Bundle bundle)
    throws Exception {
  Instance instance = new Instance();
  try {
    Module moduleConfiguration = loadKerneosModuleConfig(bundle);
    String moduleId = moduleConfiguration.getId();
    if (moduleInstances.containsKey(moduleId)) {
      throw new Exception("The Module \"" + moduleId + "\" already exists");
    }
    // Transform module information
    transformModule(moduleConfiguration, moduleId);
    Dictionary componentDictionary = new Hashtable();
    componentDictionary.put(ModuleImpl.ID, moduleId);
    componentDictionary.put(ModuleImpl.CONFIGURATION, moduleConfiguration);
    componentDictionary.put(ModuleImpl.BUNDLE, bundle.getBundleId());
    instance.setComponentInstance(moduleFactory.createComponentInstance(componentDictionary));
    moduleInstances.put(moduleId, instance);
    instance.start();
    LOGGER.debug("New Module \"" + moduleId + "\": " + moduleConfiguration);
  } catch (Exception e) {
    try {
      instance.dispose();
    } catch (IOException e2) {
      LOGGER.warn("Can't dispose Module instance", e2);
    }
    throw new Exception("Can't add Module from bundle \"" + bundle.getSymbolicName() + "\"", e);
  }
}

代码示例来源:origin: org.ow2.kerneos.graniteds-osgi/granite-core

@Validate
public void start() {
  log.debug("Start OSGiChannelGravity: " + toString());
  if (servicesConfig.findChannelById(id) == null) {
    try {
      Dictionary properties = new Hashtable();
      properties.put("URI", endPoint.getUri());
      Dictionary filters = new Hashtable();
      filters.put("context", "(ID=" + context + ")");
      properties.put("requires.filters", filters);
      servlet = servletBuilder.createComponentInstance(properties);
      servicesConfig.addChannel(this);
      started = true;
    } catch (Exception e) {
      log.error("Can't create the servlet for \"" + id + "\"");
    }
  } else {
    log.error("Channel \"" + id + "\" already registered");
  }
}

代码示例来源:origin: org.ow2.kerneos.graniteds-osgi/granite-core

@Validate
public void start() {
  log.debug("Start OSGiChannelGranite: " + toString());
  if (servicesConfig.findChannelById(id) == null) {
    try {
      Dictionary properties = new Hashtable();
      properties.put("URI", endPoint.getUri());
      Dictionary filters = new Hashtable();
      filters.put("context", "(ID=" + context + ")");
      properties.put("requires.filters", filters);
      servlet = servletBuilder.createComponentInstance(properties);
      servicesConfig.addChannel(this);
      started = true;
    } catch (Exception e) {
      log.error("Can't create the servlet for \"" + id + "\"");
    }
  } else {
    log.error("Channel \"" + id + "\" already registered");
  }
}

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.composite

/**
 * Create an instance using the given factory and the given configuration.
 *
 * @param fact : the factory name to used.
 * @param config : the configuration.
 */
private void createInstance(Factory fact, ManagedConfiguration config) {
  Dictionary conf = config.getConfiguration();
  try {
    config.setInstance(fact.createComponentInstance(conf, m_scope));
    config.setFactory(fact.getName());
    config.getInstance().addInstanceStateListener(this);
  } catch (UnacceptableConfiguration e) {
    error("A factory is available for the configuration but the configuration is not acceptable", e);
  } catch (MissingHandlerException e) {
    error("The instance creation has failed, at least one handler is missing", e);
  } catch (ConfigurationException e) {
    error("The instance creation has failed, an error during the configuration has occured", e);
  }
}

代码示例来源:origin: apache/felix

/**
 * Create an instance using the given factory and the given configuration.
 *
 * @param fact : the factory name to used.
 * @param config : the configuration.
 */
private void createInstance(Factory fact, ManagedConfiguration config) {
  Dictionary conf = config.getConfiguration();
  try {
    config.setInstance(fact.createComponentInstance(conf, m_scope));
    config.setFactory(fact.getName());
    config.getInstance().addInstanceStateListener(this);
  } catch (UnacceptableConfiguration e) {
    error("A factory is available for the configuration but the configuration is not acceptable", e);
  } catch (MissingHandlerException e) {
    error("The instance creation has failed, at least one handler is missing", e);
  } catch (ConfigurationException e) {
    error("The instance creation has failed, an error during the configuration has occured", e);
  }
}

相关文章