本文整理匯總了Java中org.osgi.service.component.annotations.Activate類的典型用法代碼示例。如果您正苦於以下問題:Java Activate類的具體用法?Java Activate怎麽用?Java Activate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Activate類屬於org.osgi.service.component.annotations包,在下文中一共展示了Activate類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: activate
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
public void activate(ComponentContext context) {
Dictionary<String, Object> config = context.getProperties();
this.topic = (String)config.get("topic");
if (topic == null) {
throw new IllegalArgumentException("Config property topic must be present.");
}
String eventTopics = (String)config.get(EventConstants.EVENT_TOPIC);
Publisher<Event> fromEventAdmin = eventAdmin.from(eventTopics, Event.class);
toKafka = kafka.to(topic, ProducerRecord.class);
org.slf4j.MDC.put("inLogAppender", "true");
Flux.from(fromEventAdmin)
.doOnEach(event -> org.slf4j.MDC.put("inLogAppender", "true"))
//.log()
.map(event->toRecord(event))
.doOnError(ex -> LOGGER.error(ex.getMessage(), ex))
.subscribe(toKafka);
LOGGER.info("Kafka appender started. Listening on topic " + topic);
}
示例2: activate
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
void activate() throws Exception {
super.register(JacksonJaxbJsonProvider.class);
super.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);
Properties props = new Properties();
props.setProperty(JDBC_URL, "jdbc:h2:./ismPlugin");
props.setProperty(JDBC_USER, "admin");
props.setProperty(JDBC_PASSWORD, "abc12345");
DataSource ds = this.jdbcFactory.createDataSource(props);
this.em = this.resourceFactory
.getProviderFor(this.builder, singletonMap("javax.persistence.nonJtaDataSource", (Object) ds), null)
.getResource(this.txControl);
this.domainApis.init(this.em, this.txControl);
this.deviceApis.init(this.em, this.txControl);
this.securityGroupApis.init(this.em, this.txControl);
this.securityGroupInterfaceApis.init(this.em, this.txControl);
super.registerInstances(this.domainApis, this.deviceApis, this.securityGroupApis,
this.securityGroupInterfaceApis);
this.container = new ServletContainer(this);
}
開發者ID:opensecuritycontroller,項目名稱:security-mgr-sample-plugin,代碼行數:27,代碼來源:SecurityManagerServletDelegate.java
示例3: start
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
void start(Config config) throws SQLException {
// There is no way to provide generic configuration for
// a plugin, so we wire this up programatically.
Properties props = new Properties();
props.setProperty(JDBC_URL, config.db_url());
if(config.user() != null && !config.user().isEmpty()) {
props.setProperty(JDBC_USER, config.user());
props.setProperty(JDBC_PASSWORD, config._password());
}
DataSource ds = this.jdbcFactory.createDataSource(props);
this.em = this.resourceFactory.getProviderFor(this.builder,
singletonMap("javax.persistence.nonJtaDataSource", (Object)ds), null)
.getResource(this.txControl);
}
開發者ID:opensecuritycontroller,項目名稱:security-mgr-sample-plugin,代碼行數:22,代碼來源:IsmApplianceManagerApi.java
示例4: start
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
void start(BundleContext ctx) throws InterruptedException, VmidcException {
// This is not done automatically by DS as we do not want the broadcast whiteboard
// to activate another instance of this component, only people getting the runner!
this.registration = ctx.registerService(BroadcastListener.class, this, null);
try {
EntityManager em = this.dbConnectionManager.getTransactionalEntityManager();
this.dbConnectionManager.getTransactionControl().required(() -> {
OSCEntityManager<DeploymentSpec> dsEmgr = new OSCEntityManager<DeploymentSpec>(DeploymentSpec.class,
em, this.txBroadcastUtil);
List<DeploymentSpec> dsList = dsEmgr.listAll();
for (DeploymentSpec ds : dsList) {
if (ds.getVirtualSystem().getVirtualizationConnector().getVirtualizationType().isOpenstack()) {
addListener(ds);
}
}
return null;
});
} catch (ScopedWorkException ex) {
throw ex.asRuntimeException();
}
}
示例5: start
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
void start(BundleContext ctx) throws InterruptedException, VmidcException {
// This is not done automatically by DS as we do not want the broadcast whiteboard
// to activate another instance of this component, only people getting the runner!
this.registration = ctx.registerService(BroadcastListener.class, this, null);
try {
EntityManager em = this.dbConnectionManager.getTransactionalEntityManager();
this.dbConnectionManager.getTransactionControl().required(() -> {
OSCEntityManager<SecurityGroup> sgEmgr = new OSCEntityManager<SecurityGroup>(SecurityGroup.class, em, this.txBroadcastUtil);
for (SecurityGroup sg : sgEmgr.listAll()) {
if (sg.getVirtualizationConnector().getVirtualizationType().isOpenstack()) {
addListener(sg);
}
}
return null;
});
} catch (ScopedWorkException swe) {
throw swe.asRuntimeException();
}
}
示例6: start
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
void start(BundleContext ctx) {
// This is not done automatically by DS as we do not want the broadcast whiteboard
// to activate another instance of this component, only people getting the runner!
this.registration = ctx.registerService(BroadcastListener.class, this, null);
try {
EntityManager em = this.dbConnectionManager.getTransactionalEntityManager();
this.dbConnectionManager.getTransactionControl().required(() -> {
OSCEntityManager<ApplianceManagerConnector> emgr = new OSCEntityManager<ApplianceManagerConnector>(
ApplianceManagerConnector.class, em, this.txBroadcastUtil);
this.amcs.addAll(emgr.listAll());
return null;
});
this.ses.schedule(new WebSocketRunnable(), TRY_WAIT_MS, TimeUnit.MILLISECONDS);
} catch (Exception ex) {
log.error("Create DB encountered runtime exception: ", ex);
}
/*
* Server started/restarted will add all SMCs in this Map and will invoke Web Socket Client for each one
* of them.
*/
}
示例7: activate
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
void activate(BundleContext context) {
this.context = context;
if (doReplaceSslKeysAndReboot()) {
return;
}
Runnable server = () -> {
try {
startServer();
} catch (Exception e) {
log.error("startServer failed", e);
}
};
this.thread = new Thread(server, "Start-Server");
this.thread.start();
}
示例8: activate
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
private void activate() {
Map<String, CRUDBaseSubView<?, ?>> childSubViewMap = new HashMap<String, CRUDBaseSubView<?, ?>>();
childSubViewMap.put("Deployment Specification View", this.dsSubView);
childSubViewMap.put("Traffic to Policy Mapping View", this.sgiSubView);
List<ToolbarButtons> childToolbar = new ArrayList<>();
childToolbar.add(ToolbarButtons.DEPLOYMENTS);
childToolbar.add(ToolbarButtons.SECURITY_GROUP_INTERFACES);
childToolbar.add(ToolbarButtons.DELETE_CHILD);
createView("Distributed Appliances",
Arrays.asList(ToolbarButtons.ADD, ToolbarButtons.EDIT, ToolbarButtons.DELETE, ToolbarButtons.CONFORM),
false, "Virtual Systems", childToolbar, null, childSubViewMap);
}
示例9: activate
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
void activate(BundleContext ctx) {
this.base = new File("").toURI();
// Find the resolved vaadin bundle
this.vaadinResourceBundles = new BundleTracker<Bundle>(ctx, Bundle.RESOLVED |
Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING,
new BundleTrackerCustomizer<Bundle>() {
@Override
public Bundle addingBundle(Bundle bundle, BundleEvent event) {
return VAADIN_SERVER_BUNDLE.equals(bundle.getSymbolicName()) ?
bundle : null;
}
@Override
public void modifiedBundle(Bundle bundle, BundleEvent event, Bundle object) {
}
@Override
public void removedBundle(Bundle bundle, BundleEvent event, Bundle object) {
}
});
this.vaadinResourceBundles.open();
}
示例10: activate
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
void activate(BundleContext context) {
this.context = context;
context.addFrameworkListener(this.frameworkListener);
context.addBundleListener(this.bundleListener);
this.processorThread = new Thread(() -> {
this.log.log(LogService.LOG_INFO, "Deployment Installer thread starting");
debug("Deployment Install thread starting");
while (!Thread.interrupted()) {
try {
Runnable job = waitForJob();
job.run();
} catch (InterruptedException e) {
debug("Deployment Install thread interrupted");
this.log.log(LogService.LOG_INFO, "Deployment Installer thread interrupted");
break;
} catch (Exception e) {
this.log.log(LogService.LOG_ERROR, "Error processing job on Deployment Installer thread", e);
}
}
debug("Deployment Install thread terminated.");
this.log.log(LogService.LOG_INFO, "Deployment Installer thread terminated");
});
this.processorThread.start();
}
示例11: activate
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
protected void activate(BundleContext bundleContext) {
String[] classes = {
CollectionRouter.class.getName(), ItemRouter.class.getName(),
Representable.class.getName()
};
_serviceTracker = createServiceTracker(
bundleContext, CollectionResource.class, classes,
(properties, service) -> {
Class<?> modelClass = getTypeParamOrFail(
service, CollectionResource.class, 0);
properties.put(MODEL_CLASS.getName(), modelClass);
Class<?> identifierClass = getTypeParamOrFail(
service, CollectionResource.class, 1);
properties.put(
ITEM_IDENTIFIER_CLASS.getName(), identifierClass);
});
_serviceTracker.open();
}
示例12: activate
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
protected void activate(BundleContext bundleContext) {
String[] classes =
{ItemRouter.class.getName(), Representable.class.getName()};
_serviceTracker = createServiceTracker(
bundleContext, ItemResource.class, classes,
(properties, service) -> {
Class<?> modelClass = getTypeParamOrFail(
service, ItemResource.class, 0);
properties.put(MODEL_CLASS.getName(), modelClass);
Class<?> identifierClass = getTypeParamOrFail(
service, ItemResource.class, 1);
properties.put(
ITEM_IDENTIFIER_CLASS.getName(), identifierClass);
});
_serviceTracker.open();
}
示例13: activate
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
public void activate(BundleContext bundleContext) {
Application application = bundleContext.getService(_serviceReference);
Dictionary<String, Object> properties = new Hashtable<>();
String[] propertyKeys = _serviceReference.getPropertyKeys();
for (String key : propertyKeys) {
Object value = _serviceReference.getProperty(key);
properties.put(key, value);
}
properties.put("osgi.jaxrs.application.base", "/");
properties.put("osgi.jaxrs.name", ".default");
_serviceRegistration = bundleContext.registerService(
Application.class, application, properties);
}
示例14: activate
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
void activate() throws Exception {
super.register(JacksonJaxbJsonProvider.class);
super.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);
super.registerInstances(this.inspectionPortApis, this.portApis, this.inspectionHookApis);
this.container = new ServletContainer(this);
}
開發者ID:opensecuritycontroller,項目名稱:sdn-controller-nsc-plugin,代碼行數:9,代碼來源:SampleSdnServletDelegate.java
示例15: addDemoTask
import org.osgi.service.component.annotations.Activate; //導入依賴的package包/類
@Activate
public void addDemoTask() {
if (taskService.getTask(1) == null) {
Task task = new Task();
task.setId(1);
task.setTitle("Task1");
taskService.addTask(task);
}
}