當前位置: 首頁>>代碼示例>>Java>>正文


Java ComponentContext類代碼示例

本文整理匯總了Java中org.osgi.service.component.ComponentContext的典型用法代碼示例。如果您正苦於以下問題:Java ComponentContext類的具體用法?Java ComponentContext怎麽用?Java ComponentContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ComponentContext類屬於org.osgi.service.component包,在下文中一共展示了ComponentContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: activate

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
/**
 * Component activator
 *
 * @param componentContext The component context
 * @throws Exception
 */
@Activate
protected void activate(ComponentContext componentContext)
        throws Exception {
    session = repository.loginService(CONFIG_SERVICE, null);
    observationManager = session.getWorkspace().getObservationManager();
    // set up observation listener
    observationManager.addEventListener(
            this,
            Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_CHANGED | Event.PROPERTY_ADDED | Event.PROPERTY_REMOVED,
            APPS_ROOT,
            true /* isDeep */,
            null /* uuid */,
            null /* nodeTypeName */,
            true /* noLocal */
    );
    OSGiUtils.activate(this, componentContext);
}
 
開發者ID:DantaFramework,項目名稱:AEM,代碼行數:24,代碼來源:AEMConfigurationProviderImpl.java

示例2: modified

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Modified
public void modified(ComponentContext context) {
    Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();

    int newMessageHandlerThreadPoolSize;

    try {
        String s = get(properties, "messageHandlerThreadPoolSize");

        newMessageHandlerThreadPoolSize =
                isNullOrEmpty(s) ? messageHandlerThreadPoolSize : Integer.parseInt(s.trim());

    } catch (NumberFormatException e) {
        log.warn(e.getMessage());
        newMessageHandlerThreadPoolSize = messageHandlerThreadPoolSize;
    }

    // Any change in the following parameters implies thread pool restart
    if (newMessageHandlerThreadPoolSize != messageHandlerThreadPoolSize) {
        setMessageHandlerThreadPoolSize(newMessageHandlerThreadPoolSize);
        restartMessageHandlerThreadPool();
    }

    log.info(FORMAT, messageHandlerThreadPoolSize);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:26,代碼來源:DistributedFlowStatisticStore.java

示例3: disableIfNeeded

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
/**
 * Disable component if property "enabled" is set to false
 *
 * @param ctx component context
 */
private static void disableIfNeeded(Object obj, ComponentContext ctx) {
    OptionalComponent oc = obj.getClass().getAnnotation(OptionalComponent.class);

    if (oc == null) {
        return;
    }

    boolean enabled = PropertiesUtil.toBoolean(ctx.getProperties().get(oc.propertyName()), true);

    if (!enabled) {
        String pid = (String) ctx.getProperties().get(Constants.SERVICE_PID);
        LOG.info("disabling component {}", pid);

        // at this point this is the only way to reliably disable a component
        // it's going to show up as "unsatisfied" in Felix console.
        throw new ComponentException(format("Component %s is intentionally disabled", pid));
    }
}
 
開發者ID:DantaFramework,項目名稱:Core,代碼行數:24,代碼來源:OSGiUtils.java

示例4: modified

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Modified
public void modified(ComponentContext context) {
    if (context == null) {
        netconfReplyTimeout = DEFAULT_REPLY_TIMEOUT_SECONDS;
        log.info("No component configuration");
        return;
    }

    Dictionary<?, ?> properties = context.getProperties();

    int newNetconfReplyTimeout;
    try {
        String s = get(properties, PROP_NETCONF_REPLY_TIMEOUT);
        newNetconfReplyTimeout = isNullOrEmpty(s) ?
                netconfReplyTimeout : Integer.parseInt(s.trim());
    } catch (NumberFormatException e) {
        log.warn("Component configuration had invalid value", e);
        return;
    }

    netconfReplyTimeout = newNetconfReplyTimeout;
    log.info("Settings: {} = {}", PROP_NETCONF_REPLY_TIMEOUT, netconfReplyTimeout);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:NetconfControllerImpl.java

示例5: readComponentConfiguration

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
/**
 * Extracts properties from the component configuration context.
 *
 * @param context the component context
 */
private void readComponentConfiguration(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();

    Integer newPendingFutureTimeoutMinutes =
            Tools.getIntegerProperty(properties, "pendingFutureTimeoutMinutes");
    if (newPendingFutureTimeoutMinutes == null) {
        pendingFutureTimeoutMinutes = DEFAULT_PENDING_FUTURE_TIMEOUT_MINUTES;
        log.info("Pending future timeout is not configured, " +
                         "using current value of {}", pendingFutureTimeoutMinutes);
    } else {
        pendingFutureTimeoutMinutes = newPendingFutureTimeoutMinutes;
        log.info("Configured. Pending future timeout is configured to {}",
                 pendingFutureTimeoutMinutes);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:21,代碼來源:SimpleFlowRuleStore.java

示例6: activate

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Activate
protected void activate(ComponentContext context) {
    cfgService.registerProperties(getClass());
    providerService = providerRegistry.register(this);
    controller.addListener(listener);
    controller.addEventListener(listener);

    modified(context);

    pendingBatches = createBatchCache();

    createCollectors();

    log.info("Started with flowPollFrequency = {}, adaptiveFlowSampling = {}",
            flowPollFrequency, adaptiveFlowSampling);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:17,代碼來源:OpenFlowRuleProvider.java

示例7: deactivate

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Deactivate
public void deactivate(ComponentContext context) {

    try {
        controller.getDevices().stream().forEach(device -> {
            deviceBuilderExecutor.execute(new DeviceFactory(device, false));
        });
        deviceBuilderExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        log.error("Device builder did not terminate");
    }
    deviceBuilderExecutor.shutdownNow();
    netCfgService.unregisterConfigFactory(factory);
    netCfgService.removeListener(cfgLister);
    providerRegistry.unregister(this);
    providerService = null;
    log.info("Stopped");
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:19,代碼來源:SnmpDeviceProvider.java

示例8: activate

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Activate
protected void activate(ComponentContext context) throws IOException {
    modified(context);

    log.debug("Server starting on {}", listenPort);
    try {
        server  = NettyServerBuilder.forPort(listenPort)
                .addService(DeviceProviderRegistryRpcGrpc.bindService(new DeviceProviderRegistryServerProxy()))
                .addService(LinkProviderServiceRpcGrpc.bindService(new LinkProviderServiceServerProxy(this)))
                .build().start();
    } catch (IOException e) {
        log.error("Failed to start gRPC server", e);
        throw e;
    }

    log.info("Started on {}", listenPort);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:18,代碼來源:GrpcRemoteServiceServer.java

示例9: activate

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Activate
public void activate(ComponentContext context) {
    alarmsExecutor = Executors.newScheduledThreadPool(CORE_POOL_SIZE);
    eventHandlingExecutor =
            Executors.newFixedThreadPool(CORE_POOL_SIZE,
                                         groupedThreads("onos/pollingalarmprovider",
                                                        "device-installer-%d", log));

    providerService = providerRegistry.register(this);

    deviceService.addListener(deviceListener);
    mastershipService.addListener(mastershipListener);

    if (context == null) {
        alarmPollFrequencySeconds = DEFAULT_POLL_FREQUENCY_SECONDS;
        log.info("No component configuration");
    } else {
        Dictionary<?, ?> properties = context.getProperties();
        alarmPollFrequencySeconds = getNewPollFrequency(properties, alarmPollFrequencySeconds);
    }
    scheduledTask = schedulePolling();
    log.info("Started");
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:PollingAlarmProvider.java

示例10: readComponentConfiguration

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
/**
 * Extracts properties from the component configuration context.
 *
 * @param context the component context
 */
private void readComponentConfiguration(ComponentContext context) {
    Dictionary<?, ?> properties = context.getProperties();

    String newXosServerAddress =
            Tools.get(properties, XOS_SERVER_ADDRESS_PROPERTY_NAME);
    if (!isNullOrEmpty(newXosServerAddress)) {
        xosServerAddress = newXosServerAddress;
    }

    String newXosServerPortString =
            Tools.get(properties, XOS_SERVER_PORT_PROPERTY_NAME);
    if (!isNullOrEmpty(newXosServerPortString)) {
        xosServerPort = Integer.parseInt(newXosServerPortString);
    }

    String newXosProviderServiceString =
            Tools.get(properties, XOS_PROVIDER_SERVICE_PROPERTY_NAME);
    if (!isNullOrEmpty(newXosProviderServiceString)) {
        xosProviderService = Integer.parseInt(newXosProviderServiceString);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:27,代碼來源:OnosXosIntegrationManager.java

示例11: modified

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Modified
protected void modified(ComponentContext context) {
    log.info("Received configuration change...");
    Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
    String newIp = get(properties, "aliasIp");
    String newMask = get(properties, "aliasMask");
    String newAdapter = get(properties, "aliasAdapter");

    // Process any changes in the parameters...
    if (!Objects.equals(newIp, aliasIp) ||
            !Objects.equals(newMask, aliasMask) ||
            !Objects.equals(newAdapter, aliasAdapter)) {
        synchronized (this) {
            log.info("Reconfiguring with aliasIp={}, aliasMask={}, aliasAdapter={}, wasLeader={}",
                     newIp, newMask, newAdapter, wasLeader);
            if (wasLeader) {
                removeIpAlias(aliasIp, aliasMask, aliasAdapter);
                addIpAlias(newIp, newMask, newAdapter);
            }
            aliasIp = newIp;
            aliasMask = newMask;
            aliasAdapter = newAdapter;
        }
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:26,代碼來源:ClusterIpManager.java

示例12: activate

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Activate
protected void activate(ComponentContext context) {
    componentConfigService.registerProperties(getClass());
    modified(context);

    coreAppId = coreService.registerApplication(CoreService.CORE_APP_NAME);
    routerAppId = coreService.registerApplication(RoutingService.ROUTER_APP_ID);

    networkConfigRegistry.registerConfigFactory(mcastConfigFactory);

    networkConfigService.addListener(configListener);
    deviceService.addListener(deviceListener);
    interfaceService.addListener(internalInterfaceList);

    updateConfig();

    log.info("Started");
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:19,代碼來源:SingleSwitchFibInstaller.java

示例13: modified

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Modified
public void modified(ComponentContext context) {
    int newRate = DEFAULT_RATE;
    if (context != null) {
        Dictionary properties = context.getProperties();
        try {
            String s = get(properties, "rate");
            newRate = isNullOrEmpty(s)
                    ? rate : Integer.parseInt(s.trim());
        } catch (Exception e) {
            return;
        }
    }
    if (newRate != rate) {
        log.info("Per node rate changed to {}", newRate);
        rate = newRate;
        stopTest();
        runner.execute(this::startTest);
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:21,代碼來源:DistributedConsensusLoadTest.java

示例14: activate

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Activate
    public void activate(ComponentContext context) {
        cfgService.registerProperties(getClass());
        appId = coreService.registerApplication("org.onosproject.athena.fwd");

        packetService.addProcessor(processor, PacketProcessor.director(3));
        topologyService.addListener(topologyListener);
        readComponentConfiguration(context);
        requestIntercepts();

        log.info("Started", appId.id());
//        // for evaluation 1  -- Jinwoo Kim
//        packetIn = 0;
//        ThreadTest t = new ThreadTest();
//        t.start();
    }
 
開發者ID:shlee89,項目名稱:athena,代碼行數:17,代碼來源:ReactiveForwarding.java

示例15: activate

import org.osgi.service.component.ComponentContext; //導入依賴的package包/類
@Activate
protected void activate(final ComponentContext context) {
    String maxDimensionsValue = getProperty(MAX_DIMENSIONS_PN, context);
    String[] maxDimensionsArray = maxDimensionsValue.split("x");
    if (maxDimensionsArray.length == 2) {
        maxHeight = NumberUtils.toInt(maxDimensionsArray[0], maxHeight);
        maxWidth = NumberUtils.toInt(maxDimensionsArray[1], maxWidth);
    }
}
 
開發者ID:DantaFramework,項目名稱:AEM,代碼行數:10,代碼來源:AssetProviderServlet.java


注:本文中的org.osgi.service.component.ComponentContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。