當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。