本文整理了Java中org.apache.felix.ipojo.Factory.getName()
方法的一些代码示例,展示了Factory.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Factory.getName()
方法的具体详情如下:
包路径:org.apache.felix.ipojo.Factory
类名称:Factory
方法名:getName
[英]Returns the factory name.
[中]返回工厂名称。
代码示例来源: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: org.apache.felix/org.apache.felix.ipojo.composite
/**
* 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: 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
/**
* 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
public String generate(Factory factory, List<String> reserved) throws UnacceptableConfiguration {
StringBuilder sb = new StringBuilder();
sb.append(factory.getName());
if (factory.getVersion() != null) {
sb.append("/");
sb.append(factory.getVersion());
}
sb.append("-");
sb.append(m_nextId.getAndIncrement());
return sb.toString();
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo
public String generate(Factory factory, List<String> reserved) throws UnacceptableConfiguration {
StringBuilder sb = new StringBuilder();
sb.append(factory.getName());
if (factory.getVersion() != null) {
sb.append("/");
sb.append(factory.getVersion());
}
sb.append("-");
sb.append(m_nextId.getAndIncrement());
return sb.toString();
}
}
代码示例来源: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: 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
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
/**
* 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: 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: org.apache.felix/org.apache.felix.ipojo.composite
/**
* An existing factory disappears or becomes invalid.
* @param factory : factory
*/
public void unbindFactory(Factory factory) {
boolean implicated = false;
for (int i = 0; i < m_configurations.length; i++) {
if (m_configurations[i].getInstance() != null
&& m_configurations[i].getFactory().equals(factory.getName())) {
m_configurations[i].setInstance(null);
m_configurations[i].setFactory(null);
implicated = true;
}
}
if (implicated && getValidity()) {
checkValidity();
}
}
代码示例来源:origin: apache/felix
/**
* An existing factory disappears or becomes invalid.
* @param factory : factory
*/
public void unbindFactory(Factory factory) {
boolean implicated = false;
for (int i = 0; i < m_configurations.length; i++) {
if (m_configurations[i].getInstance() != null
&& m_configurations[i].getFactory().equals(factory.getName())) {
m_configurations[i].setInstance(null);
m_configurations[i].setFactory(null);
implicated = true;
}
}
if (implicated && getValidity()) {
checkValidity();
}
}
代码示例来源: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();
}
}
代码示例来源: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: 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);
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo.composite
/**
* A new service is injected.
* This method create the sub-service instance in the composite.
* @param ref : service reference.
* @see org.apache.felix.ipojo.util.DependencyModel#onServiceArrival(org.osgi.framework.ServiceReference)
*/
public void onServiceArrival(ServiceReference ref) {
// The given factory matches.
try {
Factory fact = (Factory) getService(ref);
if (m_factories.get(ref) == null) {
ComponentInstance instance = createInstance(fact);
m_factories.put(ref, instance);
} else {
m_handler
.info("An arriving factory is already used, ignore the creation : "
+ fact.getName());
}
} catch (UnacceptableConfiguration e) {
m_handler.error("A matching factory refuses the actual configuration : " + e.getMessage());
m_handler.getCompositeManager().stop();
} catch (MissingHandlerException e) {
m_handler.error("A matching factory is no more valid : " + e.getMessage());
m_handler.getCompositeManager().stop();
} catch (ConfigurationException e) {
m_handler.error("A matching configuration is refused by the instance : " + e.getMessage());
m_handler.getCompositeManager().stop();
}
}
代码示例来源:origin: apache/felix
/**
* A new service is injected.
* This method create the sub-service instance in the composite.
* @param ref : service reference.
* @see org.apache.felix.ipojo.util.DependencyModel#onServiceArrival(org.osgi.framework.ServiceReference)
*/
public void onServiceArrival(ServiceReference ref) {
// The given factory matches.
try {
Factory fact = (Factory) getService(ref);
if (m_factories.get(ref) == null) {
ComponentInstance instance = createInstance(fact);
m_factories.put(ref, instance);
} else {
m_handler
.info("An arriving factory is already used, ignore the creation : "
+ fact.getName());
}
} catch (UnacceptableConfiguration e) {
m_handler.error("A matching factory refuses the actual configuration : " + e.getMessage());
m_handler.getCompositeManager().stop();
} catch (MissingHandlerException e) {
m_handler.error("A matching factory is no more valid : " + e.getMessage());
m_handler.getCompositeManager().stop();
} catch (ConfigurationException e) {
m_handler.error("A matching configuration is refused by the instance : " + e.getMessage());
m_handler.getCompositeManager().stop();
}
}
代码示例来源:origin: apache/felix
for (Factory factory : m_factories) {
String version = factory.getVersion();
String name = factory.getName();
内容来源于网络,如有侵权,请联系作者删除!