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

The following examples show how to use org.osgi.service.component.annotations.ReferenceCardinality. These examples are extracted from open source projects. 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
@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 Project: micro-integrator   Source File: TasksDSComponent.java    License: Apache License 2.0 6 votes vote down vote up
@Reference(name = "org.wso2.carbon.ndatasource",
           service = DataSourceService.class,
           cardinality = ReferenceCardinality.MANDATORY,
           policy = ReferencePolicy.DYNAMIC,
           unbind = "unsetDatasourceHandlerService")
protected void setDatasourceHandlerService(DataSourceService dataSourceService) {
    this.dataSourceService = dataSourceService;
}
 
Example 3
@Reference(
        name = "configuration.context.service",
        service = ConfigurationContextService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetConfigurationContextService"
)
protected void setConfigurationContextService(ConfigurationContextService configurationContextService) {

    /*
     * ConfigurationManagerComponent checks for the database column, 'CREATED_TIME' in the IDN_CONFIG_RESOURCE
     * table. Database connection creation requires in this task depends on the ConfigurationContextService.
     * This reference will ensure that the ConfigurationContextService is activated before the
     * ConfigurationManagerComponent is activated.
     */
    log.debug("ConfigurationContextService Instance registered.");
}
 
Example 4
@Reference(
         name = "event.handler", 
         service = org.wso2.carbon.identity.event.handler.AbstractEventHandler.class, 
         cardinality = ReferenceCardinality.MULTIPLE, 
         policy = ReferencePolicy.DYNAMIC, 
         unbind = "unRegisterEventHandler")
protected void registerEventHandler(AbstractEventHandler eventHandler) {
    String handlerName = eventHandler.getName();
    try {
        eventHandler.init(IdentityEventConfigBuilder.getInstance().getModuleConfigurations(handlerName));
    } catch (IdentityEventException | IdentityRuntimeException e) {
        log.warn("Properties for " + handlerName + " is not configured. This event handler will not be activated");
    }
    eventHandlerList.add(eventHandler);
    MessageHandlerComparator messageHandlerComparator = new MessageHandlerComparator(null);
    Collections.sort(eventHandlerList, messageHandlerComparator);
}
 
Example 5
@Reference(
         name = "registry.service", 
         service = RegistryService.class,
         cardinality = ReferenceCardinality.MANDATORY, 
         policy = ReferencePolicy.DYNAMIC, 
         unbind = "unsetRegistryService")
protected void setRegistryService(RegistryService registryService) {
    try {
        ClaimManagementServiceDataHolder.getInstance().setRegistryService(registryService);
    } catch (Throwable e) {
        log.error("Failed to get a reference to the Registry Service.", e);
    }
    if (log.isDebugEnabled()) {
        log.debug("RegistryService set in Claim Management bundle");
    }
}
 
Example 6
@Reference(
        name = "identity.request.factory",
        service = HttpIdentityRequestFactory.class,
        cardinality = ReferenceCardinality.MULTIPLE,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "removeHttpIdentityRequestFactory"
)
protected void addHttpIdentityRequestFactory(HttpIdentityRequestFactory factory) {

    FrameworkServiceDataHolder.getInstance().getHttpIdentityRequestFactories().add(factory);
    Collections.sort(FrameworkServiceDataHolder.getInstance().getHttpIdentityRequestFactories(),
            new HandlerComparator());
    Collections.reverse(FrameworkServiceDataHolder.getInstance().getHttpIdentityRequestFactories());
    if (log.isDebugEnabled()) {
        log.debug("Added HttpIdentityRequestFactory : " + factory.getName());
    }
}
 
Example 7
@Reference(
        name = "identity.response.factory",
        service = HttpIdentityResponseFactory.class,
        cardinality = ReferenceCardinality.MULTIPLE,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "removeHttpIdentityResponseFactory"
)
protected void addHttpIdentityResponseFactory(HttpIdentityResponseFactory factory) {

    FrameworkServiceDataHolder.getInstance().getHttpIdentityResponseFactories().add(factory);
    Collections.sort(FrameworkServiceDataHolder.getInstance().getHttpIdentityResponseFactories(),
            new HandlerComparator());
    Collections.reverse(FrameworkServiceDataHolder.getInstance().getHttpIdentityResponseFactories());
    if (log.isDebugEnabled()) {
        log.debug("Added HttpIdentityResponseFactory : " + factory.getName());
    }
}
 
Example 8
@Reference(
        name = "registry.service",
        service = RegistryService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetRegistryService"
)
protected void setRegistryService(RegistryService registryService) {
    if (log.isDebugEnabled()) {
        log.debug("Setting the RegistryService");
    }
    this.registryService = registryService;
    SecurityServiceHolder.setRegistryService(registryService);
}
 
Example 9
@Reference(
        name = "identityCoreInitializedEventService",
        service = IdentityCoreInitializedEvent.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetIdentityCoreInitializedEventService"
)

protected void setIdentityCoreInitializedEventService(IdentityCoreInitializedEvent identityCoreInitializedEvent) {
  /* reference IdentityCoreInitializedEvent service to guarantee that this component will wait until identity core
     is started */
}
 
Example 10
Source Project: micro-integrator   Source File: DataServicesDSComponent.java    License: Apache License 2.0 5 votes vote down vote up
@Reference(
        name = "datasources.service",
        service = org.wso2.micro.integrator.ndatasource.core.DataSourceService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetDataSourceService")
protected void setDataSourceService(DataSourceService dataSourceService) {
    if (log.isDebugEnabled()) {
        log.debug("Setting the Data Sources Service");
    }
    DataServicesDSComponent.dataSourceService = dataSourceService;
}
 
Example 11
Source Project: micro-integrator   Source File: DataServicesDSComponent.java    License: Apache License 2.0 5 votes vote down vote up
@Reference(
        name = "secret.callback.handler.service",
        service = org.wso2.carbon.securevault.SecretCallbackHandlerService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetSecretCallbackHandlerService")
protected void setSecretCallbackHandlerService(
        SecretCallbackHandlerService secretCallbackHandlerService) {
    if (log.isDebugEnabled()) {
        log.debug("SecretCallbackHandlerService acquired");
    }
    DataServicesDSComponent.secretCallbackHandlerService = secretCallbackHandlerService;

}
 
Example 12
@Reference(
         name = "user.realmservice.default", 
         service = org.wso2.carbon.user.core.service.RealmService.class, 
         cardinality = ReferenceCardinality.MANDATORY, 
         policy = ReferencePolicy.DYNAMIC, 
         unbind = "unsetRealmService")
protected void setRealmService(RealmService realmService) {
    if (log.isDebugEnabled()) {
        log.info("Setting the Realm Service");
    }
    UserRegistrationDSComponent.realmService = realmService;
}
 
Example 13
/**
 * @param rlmService
 */
@Reference(
        name = "user.realmservice.default",
        service = RealmService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetRealmService"
)
protected void setRealmService(RealmService rlmService) {
    IdpMgtServiceComponentHolder.getInstance().setRealmService(rlmService);
}
 
Example 14
Source Project: micro-integrator   Source File: CryptoImplComponent.java    License: Apache License 2.0 5 votes vote down vote up
@Reference(name = "externalCryptoProvider",
        service = ExternalCryptoProvider.class,
        cardinality = ReferenceCardinality.MULTIPLE,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetExternalCryptoProvider")
public void setExternalCryptoProvider(ExternalCryptoProvider externalCryptoProvider) {

    this.defaultCryptoService.registerExternalCryptoProvider(externalCryptoProvider);
    if (log.isDebugEnabled()) {
        log.debug(String.format("'%s' has been injected as an external crypto provider.",
                                externalCryptoProvider.getClass().getCanonicalName()));
    }
}
 
Example 15
Source Project: openhab-core   Source File: UpnpDiscoveryService.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
protected void addUpnpDiscoveryParticipant(UpnpDiscoveryParticipant participant) {
    this.participants.add(participant);

    if (upnpService != null) {
        Collection<RemoteDevice> devices = upnpService.getRegistry().getRemoteDevices();
        for (RemoteDevice device : devices) {
            DiscoveryResult result = participant.createResult(device);
            if (result != null) {
                thingDiscovered(result);
            }
        }
    }
}
 
Example 16
Source Project: micro-integrator   Source File: NtaskService.java    License: Apache License 2.0 5 votes vote down vote up
@Reference(
        name = "config.context.service",
        service = Axis2ConfigurationContextService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetConfigurationContextService")
protected void setConfigurationContextService(Axis2ConfigurationContextService contextService) {

    if (logger.isDebugEnabled()) {
        logger.debug("Setting Configuration Context Service [" + contextService + "]");
    }
    NtaskService.ccServiceInstance = contextService;
    updateAndCleanupObservers();
}
 
Example 17
@Reference(name = "config.context.service",
        service = Axis2ConfigurationContextService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetConfigurationContextService")
protected void setConfigurationContextService(Axis2ConfigurationContextService contextService) {

    MessageFlowDataPublisherDataHolder.getInstance().setContextService(contextService);
}
 
Example 18
@Reference(name = "synapse.env.service",
        service = SynapseEnvironmentService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetSynapseEnvironmentService")
protected void setSynapseEnvironmentService(SynapseEnvironmentService synapseEnvironmentService) {

    if (log.isDebugEnabled()) {
        log.debug("SynapseEnvironmentService bound to the mediation tracer initialization");
    }
    synapseEnvServices.put(synapseEnvironmentService.getTenantId(), synapseEnvironmentService);
}
 
Example 19
@Reference(
        name = "user.realmservice.default",
        service = RealmService.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetRealmService"
)
protected void setRealmService(RealmService realmService) {

    UserStoreCountDataHolder.getInstance().setRealmService(realmService);
    if (log.isDebugEnabled()) {
        log.debug("RealmService is set in the User Store Count bundle");
    }
}
 
Example 20
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
public void addActionProvider(AnnotatedActions actionProvider, Map<String, Object> properties) {
    Collection<ModuleInformation> moduleInformations = helper.parseAnnotations(actionProvider);

    String configName = getConfigNameFromService(properties);

    for (ModuleInformation mi : moduleInformations) {
        mi.setConfigName(configName);

        ModuleType oldType = null;
        if (moduleInformation.containsKey(mi.getUID())) {
            oldType = helper.buildModuleType(mi.getUID(), moduleInformation);
            Set<ModuleInformation> availableModuleConfigs = moduleInformation.get(mi.getUID());
            availableModuleConfigs.add(mi);
        } else {
            Set<ModuleInformation> configs = ConcurrentHashMap.newKeySet();
            configs.add(mi);
            moduleInformation.put(mi.getUID(), configs);
        }

        ModuleType mt = helper.buildModuleType(mi.getUID(), moduleInformation);
        if (mt != null) {
            for (ProviderChangeListener<ModuleType> l : changeListeners) {
                if (oldType != null) {
                    l.updated(this, oldType, mt);
                } else {
                    l.added(this, mt);
                }
            }
        }
    }
}
 
Example 21
@Reference(
         name = "org.wso2.carbon.identity.workflow.mgt.listener.workflowexecutorlistner", 
         service = org.wso2.carbon.identity.workflow.mgt.listener.WorkflowExecutorManagerListener.class, 
         cardinality = ReferenceCardinality.MULTIPLE, 
         policy = ReferencePolicy.DYNAMIC, 
         unbind = "unsetWorkflowExecutorListener")
protected void setWorkflowExecutorListener(WorkflowExecutorManagerListener workflowListener) {
    WorkflowServiceDataHolder.getInstance().getExecutorListenerList().add(workflowListener);
}
 
Example 22
@Reference(
         name = "http.service", 
         service = org.osgi.service.http.HttpService.class, 
         cardinality = ReferenceCardinality.MANDATORY, 
         policy = ReferencePolicy.DYNAMIC, 
         unbind = "unsetHttpService")
protected void setHttpService(HttpService httpService) {
    setHttpServiceInstance(httpService);
}
 
Example 23
@Reference(
         name = "identityCoreInitializedEventService", 
         service = org.wso2.carbon.identity.core.util.IdentityCoreInitializedEvent.class, 
         cardinality = ReferenceCardinality.MANDATORY, 
         policy = ReferencePolicy.DYNAMIC, 
         unbind = "unsetIdentityCoreInitializedEventService")
protected void setIdentityCoreInitializedEventService(IdentityCoreInitializedEvent identityCoreInitializedEvent) {
/* reference IdentityCoreInitializedEvent service to guarantee that this component will wait until identity core
     is started */
}
 
Example 24
@Reference(
         name = "identityCoreInitializedEventService", 
         service = org.wso2.carbon.identity.core.util.IdentityCoreInitializedEvent.class, 
         cardinality = ReferenceCardinality.MANDATORY, 
         policy = ReferencePolicy.DYNAMIC, 
         unbind = "unsetIdentityCoreInitializedEventService")
protected void setIdentityCoreInitializedEventService(IdentityCoreInitializedEvent identityCoreInitializedEvent) {
/* reference IdentityCoreInitializedEvent service to guarantee that this component will wait until identity core
     is started */
}
 
Example 25
@Reference(
        name = "consent.mgt.service",
        service = ConsentManager.class,
        cardinality = ReferenceCardinality.MANDATORY,
        policy = ReferencePolicy.DYNAMIC,
        unbind = "unsetConsentMgtService"
)
protected void setConsentMgtService(ConsentManager consentManager) {

    ApplicationManagementServiceComponentHolder.getInstance().setConsentManager(consentManager);
}
 
Example 26
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
protected void addInboxAutoApprovePredicate(InboxAutoApprovePredicate inboxAutoApprovePredicate) {
    inboxAutoApprovePredicates.add(inboxAutoApprovePredicate);
    for (DiscoveryResult result : inbox.getAll()) {
        if (DiscoveryResultFlag.NEW.equals(result.getFlag()) && inboxAutoApprovePredicate.test(result)) {
            inbox.approve(result.getThingUID(), result.getLabel());
        }
    }
}
 
Example 27
Source Project: micro-integrator   Source File: ServiceBusInitializer.java    License: Apache License 2.0 5 votes vote down vote up
@Reference(name = "org.wso2.carbon.ndatasource",
           service = DataSourceService.class,
           cardinality = ReferenceCardinality.MANDATORY,
           policy = ReferencePolicy.DYNAMIC,
           unbind = "unsetDatasourceHandlerService")
protected void setDatasourceHandlerService(DataSourceService dataSourceService) {
    this.dataSourceService = dataSourceService;
}
 
Example 28
Source Project: openhab-core   Source File: ItemRegistryImpl.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC)
protected void setItemStateConverter(ItemStateConverter itemStateConverter) {
    this.itemStateConverter = itemStateConverter;
    for (Item item : getItems()) {
        ((GenericItem) item).setItemStateConverter(itemStateConverter);
    }
}
 
Example 29
Source Project: osgi.iot.contest.sdk   Source File: TrackControllerImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
public void addSignalController(SignalSegmentController c, Map<String, Object> properties) {
    int id = (Integer) properties.get(SegmentController.CONTROLLER_ID);
    signals.put(id, c);

    Optional<String> segment = getSegment(id);

    if (segment.isPresent()) {
        Color color = c.getSignal() ;
        info("initialise signal<{}> to {}", segment.get(), color);
        trackManager.signal(segment.get(), color);
    }
}
 
Example 30
@SuppressWarnings({ "rawtypes" })
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC, target = "(provider.type=bundle)")
protected void addProvider(Provider provider) {
    if (provider instanceof AbstractResourceBundleProvider) {
        addAbstractResourceBundleProvider((AbstractResourceBundleProvider) provider);
    }
}