Java Code Examples for org.osgi.service.component.annotations.ReferenceCardinality#AT_LEAST_ONE

The following examples show how to use org.osgi.service.component.annotations.ReferenceCardinality#AT_LEAST_ONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataServiceCappDeployerServiceComponent.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Reference(
        name = "org.wso2.micro.application.deployer.handler",
        service = org.wso2.micro.application.deployer.handler.AppDeploymentHandler.class,
        cardinality = ReferenceCardinality.AT_LEAST_ONE,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetDataServiceCappDeployer")
protected void setDataServiceCappDeployer(AppDeploymentHandler appDeploymentHandler) {
    if (appDeploymentHandler instanceof DataSourceCappDeployer) {
        if (Objects.isNull(ctx)) {
            // save appDeploymentHandler
            appDepHandler = appDeploymentHandler;
        } else {
            registerDataServiceCappDeployer();
        }
    }
}
 
Example 2
Source File: MediationStatisticsComponent.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Reference(name = "synapse.registrations.service",
        service = SynapseRegistrationsService.class,
        cardinality = ReferenceCardinality.AT_LEAST_ONE,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetSynapseRegistrationsService")
protected void setSynapseRegistrationsService(SynapseRegistrationsService registrationsService) {

    ServiceRegistration synEnvSvcRegistration = registrationsService.getSynapseEnvironmentServiceRegistration();
    try {
        if (activated && compCtx != null) {
            SynapseEnvironmentService synEnvSvc = (SynapseEnvironmentService) compCtx.getBundleContext()
                    .getService(synEnvSvcRegistration.getReference());
            createStores(synEnvSvc);
        }
    } catch (Throwable t) {
        log.fatal("Error occurred at the osgi service method", t);
    }
}
 
Example 3
Source File: SwaggerDefinitionSC.java    From msf4j with Apache License 2.0 6 votes vote down vote up
@Reference(
        name = "microserviceregsitry",
        service = MicroservicesRegistry.class,
        cardinality = ReferenceCardinality.AT_LEAST_ONE,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "removeRegistry")
protected void addRegistry(MicroservicesRegistry registry, Map properties) {
    DataHolder.getInstance().addMicroserviceRegistry(properties.get(CHANNEL_ID).toString(), registry);
    Dictionary<String, String> serviceProperties = new Hashtable<>();
    serviceProperties.put(CHANNEL_ID, properties.get(CHANNEL_ID).toString());

    BundleContext bundleContext = DataHolder.getInstance().getBundleContext();
    if (bundleContext != null) {
        bundleContext.registerService(SwaggerService.class,
                new SwaggerDefinitionService(registry), serviceProperties);
    }
}
 
Example 4
Source File: StartupAdminServiceComponent.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Reference(name = "synapse.env.service",
        service = org.wso2.micro.integrator.initializer.services.SynapseEnvironmentService.class,
        cardinality = ReferenceCardinality.AT_LEAST_ONE,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetSynapseEnvironmentService")
protected void setSynapseEnvironmentService(SynapseEnvironmentService synEnvSvc) {

    synapseEnvironmentServices.put(synEnvSvc.getTenantId(), synEnvSvc);
}
 
Example 5
Source File: FolderObserver.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC)
protected void addModelParser(ModelParser modelParser) {
    parsers.add(modelParser.getExtension());

    if (activated) {
        processIgnoredFiles(modelParser.getExtension());
        readyService.markReady(new ReadyMarker(READYMARKER_TYPE, modelParser.getExtension()));
    }
}
 
Example 6
Source File: SerialPortRegistry.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Registers a {@link SerialPortProvider}.
 *
 * @param creator
 */
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC, policyOption = ReferencePolicyOption.GREEDY)
protected void registerSerialPortCreator(SerialPortProvider creator) {
    synchronized (portCreators) {
        portCreators.add(creator);
    }
}
 
Example 7
Source File: IdentityProvisionServiceComponent.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * @param entitlementService
 */
@Reference(
         name = "identity.entitlement.service", 
         service = org.wso2.carbon.identity.entitlement.EntitlementService.class, 
         cardinality = ReferenceCardinality.AT_LEAST_ONE, 
         policy = ReferencePolicy.DYNAMIC, 
         unbind = "unsetEntitlementService")
protected void setEntitlementService(EntitlementService entitlementService) {
    if (log.isDebugEnabled()) {
        log.debug("EntitlementService is set in the Application Authentication Framework bundle");
    }
    ProvisioningServiceDataHolder.getInstance().setEntitlementService(entitlementService);
}
 
Example 8
Source File: GraphqlResourceProviderFactory.java    From commerce-cif-connector with Apache License 2.0 5 votes vote down vote up
@Reference(
    service = GraphqlDataService.class,
    bind = "bindGraphqlDataService",
    unbind = "unbindGraphqlDataService",
    cardinality = ReferenceCardinality.AT_LEAST_ONE,
    policy = ReferencePolicy.DYNAMIC)
protected void bindGraphqlDataService(GraphqlDataService client, Map<?, ?> properties) {
    String identifier = client.getIdentifier();
    LOGGER.info("Registering GraphqlDataService '{}'", identifier);
    clients.put(identifier, client);
}
 
Example 9
Source File: MSF4JDeployerSC.java    From msf4j with Apache License 2.0 5 votes vote down vote up
/**
 * To deploy micro services, we need to have at least one micro service registry in the system.
 * Since microservice registry is added when microservice server is active, added the reference to wait till
 * microservices server is active.
 * Otherwise if deployer registered before at least one registry is added, Deployer will start to deploy services
 * and will fail deployment.
 */
@Reference(
        name = "microservices-regitry",
        service = MicroservicesRegistry.class,
        cardinality = ReferenceCardinality.AT_LEAST_ONE,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "removeMicroservicesRegistry"
)
protected void addMicroservicesRegitry(MicroservicesRegistry registry, Map properties) {
    log.debug("MicroservicesRegistry get registered successfully.");
    DataHolder.getInstance().addMicroserviceRegistry(properties.get(CHANNEL_ID).toString(), registry);
    StartupServiceUtils.updateServiceCache("wso2-microservices-deployer", MicroservicesRegistry.class);
}
 
Example 10
Source File: AppDeployerServiceComponent.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Receive an event about the creation of a SynapseEnvironment. If this is
 * SuperTenant we have to wait until all the other constraints are met and actual
 * initialization is done in the activate method. Otherwise we have to do the activation here.
 *
 * @param synapseEnvironmentService SynapseEnvironmentService which contains information
 *                                  about the new Synapse Instance
 */
@Reference(
        name = "synapse.env.service",
        service = org.wso2.micro.integrator.initializer.services.SynapseEnvironmentService.class,
        cardinality = ReferenceCardinality.AT_LEAST_ONE,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetSynapseEnvironmentService")
protected void setSynapseEnvironmentService(SynapseEnvironmentService synapseEnvironmentService) {
    this.synapseEnvironmentService = synapseEnvironmentService;
    DataHolder.getInstance().setSynapseEnvironmentService(this.synapseEnvironmentService);
}
 
Example 11
Source File: StartupAdminServiceComponent.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Reference(name = "synapse.registrations.service",
        service = org.wso2.micro.integrator.initializer.services.SynapseRegistrationsService.class,
        cardinality = ReferenceCardinality.AT_LEAST_ONE,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetSynapseRegistrationsService")
protected void setSynapseRegistrationsService(SynapseRegistrationsService synapseRegistrationsService) {

}
 
Example 12
Source File: TemplateResourceBundleProvider.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC, target = "(parser.type=parser.template)")
protected void addParser(Parser<RuleTemplate> parser, Map<String, String> properties) {
    super.addParser(parser, properties);
}
 
Example 13
Source File: ModuleTypeFileProviderWatcher.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC, target = "(parser.type=parser.module.type)")
@Override
public void addParser(Parser<ModuleType> parser, Map<String, String> properties) {
    super.addParser(parser, properties);
}
 
Example 14
Source File: TemplateFileProviderWatcher.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC, target = "(parser.type=parser.template)")
@Override
public void addParser(Parser<RuleTemplate> parser, Map<String, String> properties) {
    super.addParser(parser, properties);
}
 
Example 15
Source File: ModuleTypeResourceBundleProvider.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC, target = "(parser.type=parser.module.type)")
protected void addParser(Parser<ModuleType> parser, Map<String, String> properties) {
    super.addParser(parser, properties);
}
 
Example 16
Source File: IconServlet.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC)
public void addIconProvider(IconProvider iconProvider) {
    this.iconProvider.add(iconProvider);
}
 
Example 17
Source File: CommunicationManager.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC)
protected void addItemFactory(ItemFactory itemFactory) {
    itemFactories.add(itemFactory);
    calculateAcceptedTypes();
}
 
Example 18
Source File: ChannelItemProvider.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC)
protected void addItemFactory(ItemFactory itemFactory) {
    this.itemFactories.add(itemFactory);
}
 
Example 19
Source File: GenericItemProvider.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Add another instance of an {@link ItemFactory}. Used by Declarative Services.
 *
 * @param factory The {@link ItemFactory} to add.
 */
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.DYNAMIC)
public void addItemFactory(ItemFactory factory) {
    itemFactorys.add(factory);
    dispatchBindingsPerItemType(null, factory.getSupportedItemTypes());
}
 
Example 20
Source File: OAuthStoreHandlerImpl.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Static policy -- don't want to change cipher on the fly!
 * There may be multiple storage ciphers, choose the one that matches the target (done at activate)
 *
 */
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE)
protected synchronized void setStorageCipher(StorageCipher storageCipher) {
    // keep all ciphers
    allAvailableStorageCiphers.add(storageCipher);
}