本文整理汇总了Java中org.apache.felix.dm.Component类的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Component类属于org.apache.felix.dm包,在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureInstance
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Function that is called when configuration of the dependencies is
* required.
*
* @param c
* dependency manager Component object, used for configuring the
* dependencies exported and imported
* @param imp
* Implementation class that is being configured, needed as long
* as the same routine can configure multiple implementations
* @param containerName
* The containerName being configured, this allow also optional
* per-container different behavior if needed, usually should not
* be the case though.
*/
@Override
public void configureInstance(Component c, Object imp, String containerName) {
if (imp.equals(NetworkHandler.class)) {
c.setInterface(INeutronNetworkAware.class.getName(), null);
}
if (imp.equals(SubnetHandler.class)) {
c.setInterface(INeutronSubnetAware.class.getName(), null);
}
if (imp.equals(PortHandler.class)) {
c.setInterface(INeutronPortAware.class.getName(), null);
}
// Create service dependencies.
c.add(createServiceDependency().setService(BindingAwareBroker.class).setCallbacks("setBindingAwareBroker", "unsetBindingAwareBroker")
.setRequired(true));
}
示例2: configureInstance
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Function that is called when configuration of the dependencies
* is required.
*
* @param c dependency manager Component object, used for
* configuring the dependencies exported and imported
* @param imp Implementation class that is being configured,
* needed as long as the same routine can configure multiple
* implementations
* @param containerName The containerName being configured, this allow
* also optional per-container different behavior if needed, usually
* should not be the case though.
*/
public void configureInstance(Component c, Object imp, String containerName) {
if (imp.equals(ControllerServiceAdaptor.class)) {
/*
* Export the fact that the Component exports the IListenDataPacket and
* IControllerService interfaces
*
* First create a dictionary and put the "salListenerName" property into it
* the "salListenerName" should be unique, and we use the package name here.
*/
Dictionary<String, String> props = new Hashtable<String, String>();
props.put("salListenerName", this.getClass().getPackage().getName());
// Then set that we provide the IListenDataPacket and IControllerService interface with that property
c.setInterface(new String[] {IListenDataPacket.class.getName(),
IControllerService.class.getName()}, props);
} else if (imp.equals(OFSwitchAdaptor.class)) {
// Export the fact that we export an IOFSwitch interface
c.setInterface(IOFSwitch.class.getName(), null);
}
}
示例3: init
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Function called by the dependency manager when all the required
* dependencies are satisfied
*
*/
void init(Component c) {
Dictionary props = c.getServiceProperties();
if (props != null) {
this.containerName = (String) props.get("containerName");
logger.debug("Running containerName: {}", this.containerName);
} else {
// In the Global instance case the containerName is empty
this.containerName = "";
}
if (this.clusterService != null) {
this.coordinatorChangeListener = new ListenCoordinatorChange();
try {
this.clusterService
.listenRoleChange(this.coordinatorChangeListener);
logger.debug("Coordinator change handler registered");
} catch (ListenRoleChangeAddException ex) {
logger.error("Could not register coordinator change");
}
}
}
示例4: configureGlobalInstance
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Function that is called when configuration of the dependencies is required.
*
* @param c
* dependency manager Component object, used for configuring the
* dependencies exported and imported
* @param imp
* Implementation class that is being configured, needed as long
* as the same routine can configure multiple implementations
*/
public void configureGlobalInstance(Component c, Object imp) {
if (imp.equals(ConnectionService.class)) {
c.setInterface(
new String[] { IConnectionService.class.getName(),
IPluginOutConnectionService.class.getName() },
null);
c.add(createServiceDependency()
.setService(IPluginInConnectionService.class)
.setCallbacks("setPluginService", "unsetPluginService")
.setRequired(false));
c.add(createServiceDependency()
.setService(IConnectionListener.class)
.setCallbacks("setListener", "unsetListener")
.setRequired(false));
}
}
示例5: configureGlobalInstance
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Function that is called when configuration of the dependencies is required.
*
* @param c
* dependency manager Component object, used for configuring the
* dependencies exported and imported
* @param imp
* Implementation class that is being configured, needed as long
* as the same routine can configure multiple implementations
*/
public void configureGlobalInstance(Component c, Object imp) {
if (imp.equals(Inventory.class)) {
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("scope", "Global");
// export the service
c.setInterface(
new String[] { IPluginOutInventoryService.class.getName(),
IInventoryService.class.getName() }, props);
// Now lets add a service dependency to make sure the
// provider of service exists
c.add(createServiceDependency()
.setService(IListenInventoryUpdates.class, "(scope=Global)")
.setCallbacks("setUpdateService", "unsetUpdateService")
.setRequired(false));
c.add(createServiceDependency()
.setService(IPluginInInventoryService.class, "(scope=Global)")
.setCallbacks("setPluginService", "unsetPluginService")
.setRequired(true));
}
}
示例6: configureGlobalInstance
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Configure the dependency for a given instance Global
*
* @param c Component assigned for this instance, this will be
* what will be used for configuration
* @param imp implementation to be configured
* @param containerName container on which the configuration happens
*/
protected void configureGlobalInstance(Component c, Object imp) {
if (imp.equals(ConfigurationImpl.class)) {
Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
Set<String> propSet = new HashSet<String>();
propSet.add("config.event.save");
props.put("cachenames", propSet);
// export the service
c.setInterface(
new String[] { IConfigurationService.class.getName(),
ICacheUpdateAware.class.getName()},
props);
c.add(createServiceDependency().setService(
IClusterGlobalServices.class).setCallbacks(
"setClusterServices", "unsetClusterServices").setRequired(
true));
c.add(createServiceDependency().setService(
IConfigurationAware.class).setCallbacks(
"addConfigurationAware", "removeConfigurationAware")
.setRequired(false));
}
}
示例7: init
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Function called by the dependency manager when all the required
* dependencies are satisfied
*
*/
void init(Component c) {
allocateCaches();
retrieveCaches();
String containerName = null;
Dictionary<?, ?> props = c.getServiceProperties();
if (props != null) {
containerName = (String) props.get("containerName");
} else {
// In the Global instance case the containerName is empty
containerName = "UNKNOWN";
}
userLinksFileName = ROOT + "userTopology_" + containerName + ".conf";
registerWithOSGIConsole();
loadConfiguration();
}
示例8: configureInstance
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Function that is called when configuration of the dependencies is
* required.
*
* @param c
* dependency manager Component object, used for configuring the
* dependencies exported and imported
* @param imp
* Implementation class that is being configured, needed as long
* as the same routine can configure multiple implementations
* @param containerName
* The containerName being configured, this allow also optional
* per-container different behavior if needed, usually should not
* be the case though.
*/
public void configureInstance(Component c, Object imp, String containerName) {
if (imp.equals(StatisticsManager.class)) {
// export the service
c.setInterface(new String[] {
IStatisticsManager.class.getName(),
IReadServiceListener.class.getName(),
IListenInventoryUpdates.class.getName() }, null);
c.add(createContainerServiceDependency(containerName).setService(IReadService.class)
.setCallbacks("setReaderService", "unsetReaderService").setRequired(true));
c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
.setCallbacks("setClusterContainerService", "unsetClusterContainerService").setRequired(true));
c.add(createContainerServiceDependency(containerName).setService(IContainer.class)
.setCallbacks("setIContainer", "unsetIContainer").setRequired(true));
}
}
示例9: init
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Function called by the dependency manager when all the required
* dependencies are satisfied
*
*/
@SuppressWarnings("rawtypes")
void init(Component c) {
logger.trace("INIT called!");
Dictionary props = c.getServiceProperties();
if (props != null) {
containerName = (String) props.get("containerName");
if (containerName != null) {
isDefaultContainer = containerName.equals(GlobalConstants.DEFAULT
.toString());
}
}
nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Map<String, Property>>();
pluginOutInventoryServices = new CopyOnWriteArraySet<IPluginOutInventoryService>();
}
示例10: handleDependencies
import org.apache.felix.dm.Component; //导入依赖的package包/类
private void handleDependencies(Component component, Object service){
Dependency annotation = service.getClass().getAnnotation(Dependency.class);
if (annotation != null){
ServiceDependency serviceDependency = manager.createServiceDependency();
String filter = annotation.filter();
if (StringUtils.isNotEmpty(filter)){
serviceDependency.setService(annotation.serviceName(), filter);
} else {
serviceDependency.setService(annotation.serviceName());
}
serviceDependency.setRequired(annotation.mandatory());
String added = StringUtils.isNotEmpty(annotation.addedCallbackMethod()) ? annotation.addedCallbackMethod() : null ;
String changed = StringUtils.isNotEmpty(annotation.changedCallbackMethod()) ? annotation.changedCallbackMethod() : null ;
String removed = StringUtils.isNotEmpty(annotation.removedCallbackMethod()) ? annotation.removedCallbackMethod() : null ;
serviceDependency.setCallbacks(service, added, changed, removed);
component.add(serviceDependency);
}
}
示例11: assertAllTestSuitesAvailable
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Asserts that there are no unavailable TestSuites due to missing dependencies.
* @param monitor
*/
public void assertAllTestSuitesAvailable(TestMonitor monitor) {
Map<String, List<String>> missingTestSuitesAndDeps = new LinkedHashMap<String, List<String>>();
List<DependencyManager> managers = DependencyManager.getDependencyManagers();
for (DependencyManager manager : managers) {
for (Object componentObject : new ArrayList<Object>(manager.getComponents())) {
Component component = (Component) componentObject;
for (DependencyContext dependencyContext : ((ComponentContext)component).getDependencies()) {
if (dependencyContext.isRequired() && !dependencyContext.isAvailable()) {
String componentName = ((ComponentDeclaration) component).getName();
if (componentName.contains(TestSuite.class.getName())) {
addMissingTestSuite(missingTestSuitesAndDeps, component, dependencyContext);
}
}
}
}
}
if (!missingTestSuitesAndDeps.isEmpty()) {
reportMissingTestSuites(monitor, missingTestSuitesAndDeps);
}
}
示例12: addMissingTestSuite
import org.apache.felix.dm.Component; //导入依赖的package包/类
/**
* Add the missing testsuite and the current missing dependency
* @param missingTestSuitesAndDeps
* @param component the component
* @param dependency the current missing dependency
* @param componentName
*/
private void addMissingTestSuite(Map<String, List<String>> missingTestSuitesAndDeps, Component component, DependencyContext dependencyContext) {
TestSuite testSuite = getTestSuite(component);
String componentName;
if (testSuite != null) {
componentName = testSuite.getLabel();
} else {
//failed to retrieve actual TestSuite from the component
componentName = "Placeholder for TestSuite with missing dependencies"; //$NON-NLS-1$
}
List<String> missingDeps = missingTestSuitesAndDeps.get(componentName);
if (missingDeps == null) {
missingDeps = new ArrayList<String>();
missingTestSuitesAndDeps.put(componentName, missingDeps);
}
missingDeps.add(dependencyContext.toString());
}
示例13: init
import org.apache.felix.dm.Component; //导入依赖的package包/类
@Override
public void init(BundleContext bundleContext, DependencyManager dependencyManager) throws Exception {
Tactic tactic = new SimpleTactic();
Component component = createComponent()
.setInterface(Tactic.class.getName(), null)
.setImplementation(tactic)
.setCallbacks("init", "startTactic", "stopTactic", "destroy");
for(ServiceDependency dep : tactic.getComponents(dependencyManager)) {
component.add(dep);
}
component.add(
createServiceDependency()
.setService(ArchitectureEventController.class)
.setRequired(true)
);
component.add(
createServiceDependency()
.setService(Subscriber.class)
.setRequired(true)
);
component.add(
createServiceDependency()
.setService(Discoverer.class)
.setRequired(true)
);
component.add(
createServiceDependency()
.setService(DroneInit.class)
.setRequired(true)
);
dependencyManager.add(component);
}
示例14: configureInstance
import org.apache.felix.dm.Component; //导入依赖的package包/类
public void configureInstance(Component c, Object imp, String containerName) {
log.trace("Configuring instance");
if (imp.equals(DissectorHandler.class)) {
// Define exported and used services for DissectorHandler component.
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("salListenerName", "myDissectorHandler");
// Export IListenDataPacket interface to receive packet-in events.
c.setInterface(new String[] {IListenDataPacket.class.getName()}, props);
// Need the DataPacketService for encoding, decoding, sending data packets
c.add(createContainerServiceDependency(containerName).setService(
IDataPacketService.class).setCallbacks(
"setDataPacketService", "unsetDataPacketService")
.setRequired(true));
// Need FlowProgrammerService for programming flows
c.add(createContainerServiceDependency(containerName).setService(
IFlowProgrammerService.class).setCallbacks(
"setFlowProgrammerService", "unsetFlowProgrammerService")
.setRequired(true));
// Need SwitchManager service for enumerating ports of switch
c.add(createContainerServiceDependency(containerName).setService(
ISwitchManager.class).setCallbacks(
"setSwitchManagerService", "unsetSwitchManagerService")
.setRequired(true));
}
}
示例15: configureInstance
import org.apache.felix.dm.Component; //导入依赖的package包/类
public void configureInstance(Component c, Object imp, String containerName) {
if (imp.equals(PacketHandler.class)) {
log.trace("Configuring packet handler");
// Export IListenDataPacket interface to receive packet-in events.
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("salListenerName", "sdnmq");
c.setInterface(new String[] {IListenDataPacket.class.getName()}, props);
// Need the DataPacketService for decoding data packets
c.add(createContainerServiceDependency(containerName).setService(
IDataPacketService.class).setCallbacks(
"setDataPacketService", "unsetDataPacketService").setRequired(true));
} else if (imp.equals(PacketForwarder.class)) {
log.trace("Configuring packet forwarder");
// Need the DataPacketService for encoding and sending packets
c.add(createContainerServiceDependency(containerName).setService(
IDataPacketService.class).setCallbacks(
"setDataPacketService", "unsetDataPacketService").setRequired(true));
// Need SwitchManager service for finding nodes and node connectors
c.add(createContainerServiceDependency(containerName).setService(
ISwitchManager.class).setCallbacks(
"setSwitchManagerService", "unsetSwitchManagerService").setRequired(true));
} else if (imp.equals(FlowProgrammer.class)) {
log.trace("Configuring flow programmer");
// Need SwitchManager service for finding nodes and node connectors
c.add(createContainerServiceDependency(containerName).setService(
ISwitchManager.class).setCallbacks(
"setSwitchManagerService", "unsetSwitchManagerService").setRequired(true));
// Need FlowProgrammerService for programming flows
c.add(createContainerServiceDependency(containerName).setService(
IFlowProgrammerService.class).setCallbacks(
"setFlowProgrammerService", "unsetFlowProgrammerService").setRequired(true));
}
}