当前位置: 首页>>代码示例>>Java>>正文


Java Activate类代码示例

本文整理汇总了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);
}
 
开发者ID:cschneider,项目名称:reactive-components,代码行数:20,代码来源:KafkaAppender.java

示例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();
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:24,代码来源:OsDeploymentSpecNotificationRunner.java

示例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();
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:22,代码来源:OsSecurityGroupNotificationRunner.java

示例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.
     */
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:27,代码来源:WebSocketRunner.java

示例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();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:20,代码来源:Server.java

示例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);
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:17,代码来源:DistributedApplianceView.java

示例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();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:25,代码来源:UiServletContext.java

示例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();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:27,代码来源:DeploymentInstaller.java

示例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();
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:25,代码来源:CollectionResourceManager.java

示例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();
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:23,代码来源:ItemResourceManager.java

示例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);
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:21,代码来源:ApioApplicationRegistrar.java

示例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);
    }
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:10,代码来源:TasklistAdder.java


注:本文中的org.osgi.service.component.annotations.Activate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。