本文整理了Java中org.apache.felix.ipojo.Factory
类的一些代码示例,展示了Factory
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Factory
类的具体详情如下:
包路径:org.apache.felix.ipojo.Factory
类名称:Factory
[英]Component Type Factory Service. This service is exposed by a instance manager factory, and allows the dynamic creation of component instance.
[中]组件类型工厂服务。该服务由实例管理器工厂公开,并允许动态创建组件实例。
代码示例来源: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: org.wisdom-framework/wisdom-monitor
/**
* @return the factory name (either name of name - version).
*/
public String getName() {
if (factory.getVersion() == null) {
return factory.getName();
} else {
return factory.getName() + " - " + factory.getVersion();
}
}
代码示例来源:origin: apache/felix
public BundleContext getBundleContext() {
return m_delegate.getBundleContext();
}
代码示例来源:origin: apache/felix
/**
* Prints factories.
* @param out : output stream
*/
private void printFactories(PrintStream out) {
for (int i = 0; i < m_factories.length; i++) {
if (m_factories[i].getMissingHandlers().size() == 0) {
out.println("Factory " + m_factories[i].getName() + " (VALID)");
} else {
out.println("Factory " + m_factories[i].getName() + " (INVALID : " + m_factories[i].getMissingHandlers() + ")");
}
}
}
代码示例来源:origin: apache/felix
if (fact.getName().equals(name)) {
factory = fact;
pw.object();
pw.key("name");
pw.value(factory.getName());
pw.key("state");
pw.value(StateUtils.getFactoryState(factory.getState()));
String bundle = factory.getBundleContext().getBundle().getSymbolicName()
+ " (" + factory.getBundleContext().getBundle().getBundleId() + ")";
pw.key("bundle");
pw.value(bundle);
if (factory.getComponentDescription().getprovidedServiceSpecification().length != 0) {
pw.key("services");
pw.value(factory.getComponentDescription().getprovidedServiceSpecification());
PropertyDescription[] props = factory.getComponentDescription().getProperties();
if (props != null && props.length != 0) {
pw.key("properties");
if (! factory.getRequiredHandlers().isEmpty()) {
pw.key("requiredHandlers");
pw.value(factory.getRequiredHandlers());
if (! factory.getMissingHandlers().isEmpty()) {
pw.key("missingHandlers");
pw.value(factory.getMissingHandlers());
代码示例来源:origin: apache/felix
pw.array();
for (Factory factory : m_factories) {
String version = factory.getVersion();
String name = factory.getName();
String state = StateUtils.getFactoryState(factory.getState());
String bundle = factory.getBundleContext().getBundle().getSymbolicName()
+ " (" + factory.getBundleContext().getBundle().getBundleId() + ")";
pw.object();
pw.key("name");
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo
public String generate(final Factory factory, final List<String> reserved) throws UnacceptableConfiguration {
// Loop until we obtain a unique value (or counter overflow)
long counter = 0;
while (counter < maximum) {
String generated = m_delegate.generate(factory, reserved);
counter++;
// Verify uniqueness
if (!reserved.contains(generated)) {
return generated;
}
}
// Should never happen (except is NameGenerator composition is broken: like a delegate that
// never change its return value)
throw new UnacceptableConfiguration(format("Cannot generate unique instance name for factory %s/%s from bundle %d",
factory.getName(),
factory.getVersion(),
factory.getBundleContext().getBundle().getBundleId()));
}
}
代码示例来源: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);
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.composite
/**
* A new valid factory appears.
* @param factory : factory.
*/
public void bindFactory(Factory factory) {
boolean implicated = false;
String factName = factory.getName();
String className = factory.getComponentDescription().getClassName();
for (int i = 0; i < m_configurations.length; i++) {
if (m_configurations[i].getInstance() == null
&& (m_configurations[i].getNeededFactoryName().equals(factName)
|| m_configurations[i].getNeededFactoryName().equals(className))) {
createInstance(factory, m_configurations[i]);
implicated = true;
}
}
if (implicated && ! getValidity()) {
checkValidity();
}
}
代码示例来源:origin: apache/felix
/**
* Return the factory name.
* @return the name of the factory.
* @see org.apache.felix.ipojo.Factory#getName()
*/
public String getName() {
return m_delegate.getName();
}
代码示例来源:origin: apache/felix
/**
* Prints factory description.
* @param name : factory name
* @param out : default print stream
* @param err : error print stream (if the factory is not found)
*/
private void printFactory(String name, PrintStream out, PrintStream err) {
boolean found = false;
for (int i = 0; i < m_factories.length; i++) {
if (m_factories[i].getName().equalsIgnoreCase(name)) {
// Skip a line if already found
if (found) {
out.println();
}
out.println(m_factories[i].getDescription());
found = true;
}
}
if (! found) {
err.println("Factory " + name + " not found");
}
}
代码示例来源:origin: org.wisdom-framework/wisdom-monitor
/**
* @return the string representation of the factory state.
*/
public String getState() {
if (factory.getState() == Factory.INVALID) {
return "INVALID";
} else {
return "VALID";
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.composite
/**
* Start method.
* @see org.apache.felix.ipojo.Handler#start()
*/
public void start() {
for (int j = 0; j < m_factories.length; j++) {
String factName = m_factories[j].getName();
String className = m_factories[j].getClassName();
for (int i = 0; i < m_configurations.length; i++) {
if (m_configurations[i].getInstance() == null && (m_configurations[i].getNeededFactoryName().equals(factName) || m_configurations[i].getNeededFactoryName().equals(className))) {
createInstance(m_factories[j], m_configurations[i]);
}
}
}
checkValidity();
}
代码示例来源:origin: apache/felix
/**
* Get the component type information containing provided service, configuration properties ...
* @return the component type information.
* @see org.apache.felix.ipojo.Factory#getDescription()
*/
public Element getDescription() {
return m_delegate.getDescription();
}
代码示例来源:origin: apache/felix
public String getVersion() {
return m_delegate.getVersion();
}
代码示例来源:origin: apache/felix
public List getMissingHandlers() {
return m_delegate.getMissingHandlers();
}
代码示例来源:origin: apache/felix
public ComponentTypeDescription getComponentDescription() {
return m_delegate.getComponentDescription();
}
代码示例来源:origin: apache/felix
public String generate(final Factory factory, final List<String> reserved) throws UnacceptableConfiguration {
// Loop until we obtain a unique value (or counter overflow)
long counter = 0;
while (counter < maximum) {
String generated = m_delegate.generate(factory, reserved);
counter++;
// Verify uniqueness
if (!reserved.contains(generated)) {
return generated;
}
}
// Should never happen (except is NameGenerator composition is broken: like a delegate that
// never change its return value)
throw new UnacceptableConfiguration(format("Cannot generate unique instance name for factory %s/%s from bundle %d",
factory.getName(),
factory.getVersion(),
factory.getBundleContext().getBundle().getBundleId()));
}
}
代码示例来源: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
/**
* A new valid factory appears.
* @param factory : factory.
*/
public void bindFactory(Factory factory) {
boolean implicated = false;
String factName = factory.getName();
String className = factory.getComponentDescription().getClassName();
for (int i = 0; i < m_configurations.length; i++) {
if (m_configurations[i].getInstance() == null
&& (m_configurations[i].getNeededFactoryName().equals(factName)
|| m_configurations[i].getNeededFactoryName().equals(className))) {
createInstance(factory, m_configurations[i]);
implicated = true;
}
}
if (implicated && ! getValidity()) {
checkValidity();
}
}
内容来源于网络,如有侵权,请联系作者删除!