org.wso2.carbon.utils.ConfigurationContextService Java Examples
The following examples show how to use
org.wso2.carbon.utils.ConfigurationContextService.
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: AbstractApi.java From attic-stratos with Apache License 2.0 | 6 votes |
protected ConfigurationContext getConfigContext() { // If a tenant has been set, then try to get the ConfigurationContext of that tenant PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext.getOSGiService(ConfigurationContextService.class); ConfigurationContext mainConfigContext = configurationContextService.getServerConfigContext(); String domain = carbonContext.getTenantDomain(); if (domain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(domain)) { return TenantAxisUtils.getTenantConfigurationContext(domain, mainConfigContext); } else if (carbonContext.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) { return mainConfigContext; } else { throw new UnsupportedOperationException("Tenant domain unidentified. " + "Upstream code needs to identify & set the tenant domain & tenant ID. " + " The TenantDomain SOAP header could be set by the clients or " + "tenant authentication should be carried out."); } }
Example #2
Source File: DeviceManagerUtil.java From carbon-device-mgt with Apache License 2.0 | 6 votes |
public static String getServerBaseHttpsUrl() { String hostName = "localhost"; try { hostName = NetworkUtils.getMgtHostName(); } catch (Exception ignored) { } String mgtConsoleTransport = CarbonUtils.getManagementTransport(); ConfigurationContextService configContextService = DeviceManagementDataHolder.getInstance().getConfigurationContextService(); int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); int httpsProxyPort = CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), mgtConsoleTransport); if (httpsProxyPort > 0) { port = httpsProxyPort; } return "https://" + hostName + ":" + port; }
Example #3
Source File: ServiceUtils.java From product-private-paas with Apache License 2.0 | 6 votes |
private static ConfigurationContext getConfigContext() { // If a tenant has been set, then try to get the ConfigurationContext of that tenant PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext .getOSGiService(ConfigurationContextService.class); ConfigurationContext mainConfigContext = configurationContextService.getServerConfigContext(); String domain = carbonContext.getTenantDomain(); if (domain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(domain)) { return TenantAxisUtils.getTenantConfigurationContext(domain, mainConfigContext); } else if (carbonContext.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) { return mainConfigContext; } else { throw new UnsupportedOperationException("Tenant domain unidentified. " + "Upstream code needs to identify & set the tenant domain & tenant ID. " + " The TenantDomain SOAP header could be set by the clients or " + "tenant authentication should be carried out."); } }
Example #4
Source File: TestUtils.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * To initialize the (@link {@link ConfigurationContextService}} for testing. * * @return initialized configuration context service. */ public static ConfigurationContextService initConfigurationContextService(boolean initAPIMConfigurationService) { ConfigurationContextService configurationContextService = Mockito.mock(ConfigurationContextService.class); ConfigurationContext configurationContext = Mockito.mock(ConfigurationContext.class); AxisConfiguration axisConfiguration = Mockito.mock(AxisConfiguration.class); Mockito.doReturn(axisConfiguration).when(configurationContext).getAxisConfiguration(); TransportInDescription transportInDescription = Mockito.mock(TransportInDescription.class); Mockito.doReturn(transportInDescription).when(axisConfiguration).getTransportIn(Mockito.anyString()); Mockito.doReturn(configurationContext).when(configurationContextService).getServerConfigContext(); if (initAPIMConfigurationService) { APIManagerConfigurationService apiManagerConfigurationService = Mockito .mock(APIManagerConfigurationService.class); APIManagerConfiguration apiManagerConfiguration = Mockito.mock(APIManagerConfiguration.class); Mockito.doReturn("true").when(apiManagerConfiguration).getFirstProperty(APIConstants.ENABLE_MTLS_FOR_APIS); Mockito.doReturn(apiManagerConfiguration).when(apiManagerConfigurationService).getAPIManagerConfiguration(); ServiceReferenceHolder.getInstance().setAPIManagerConfigurationService(apiManagerConfigurationService); } ServiceReferenceHolder.setContextService(configurationContextService); System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon"); System.setProperty("javax.net.ssl.trustStore", "."); return configurationContextService; }
Example #5
Source File: AbstractAdmin.java From product-private-paas with Apache License 2.0 | 6 votes |
protected ConfigurationContext getConfigContext() { // If a tenant has been set, then try to get the ConfigurationContext of that tenant PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); ConfigurationContextService configurationContextService = (ConfigurationContextService) carbonContext .getOSGiService(ConfigurationContextService.class); ConfigurationContext mainConfigContext = configurationContextService.getServerConfigContext(); String domain = carbonContext.getTenantDomain(); if (domain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(domain)) { return TenantAxisUtils.getTenantConfigurationContext(domain, mainConfigContext); } else if (carbonContext.getTenantId() == MultitenantConstants.SUPER_TENANT_ID) { return mainConfigContext; } else { throw new UnsupportedOperationException("Tenant domain unidentified. " + "Upstream code needs to identify & set the tenant domain & tenant ID. " + " The TenantDomain SOAP header could be set by the clients or " + "tenant authentication should be carried out."); } }
Example #6
Source File: TenantLoadMessageSenderTest.java From carbon-apimgt with Apache License 2.0 | 6 votes |
@Test public void testGetClusteringAgent() { PowerMockito.mockStatic(ServiceReferenceHolder.class); ConfigurationContextService configurationContextService = PowerMockito.mock(ConfigurationContextService.class); PowerMockito.when(ServiceReferenceHolder.getContextService()).thenReturn(configurationContextService); ConfigurationContext serverConfigContext = PowerMockito.mock(ConfigurationContext.class); PowerMockito.when(ServiceReferenceHolder.getContextService().getServerConfigContext()) .thenReturn(serverConfigContext); AxisConfiguration axisConfiguration = PowerMockito.mock(AxisConfiguration.class); PowerMockito.when(ServiceReferenceHolder.getContextService().getServerConfigContext().getAxisConfiguration()) .thenReturn(axisConfiguration); ClusteringAgent clusteringAgent = PowerMockito.mock(ClusteringAgent.class); PowerMockito.when(ServiceReferenceHolder.getContextService().getServerConfigContext().getAxisConfiguration() .getClusteringAgent()).thenReturn(clusteringAgent); tenantLoadMessageSender.getClusteringAgent(); }
Example #7
Source File: ConfigurationManagerComponent.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
@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 #8
Source File: DeploymentSynchronizerComponent.java From carbon-commons with Apache License 2.0 | 5 votes |
protected void unsetConfigurationContextService(ConfigurationContextService service) { if (log.isDebugEnabled()) { log.debug("Deployment synchronizer component unbound from the " + "configuration context service"); } ServiceReferenceHolder.setConfigurationContextService(null); }
Example #9
Source File: ServiceReferenceHolderTestCase.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testServiceReferenceHolder() { ServiceReferenceHolder serviceReferenceHolder = ServiceReferenceHolder.getInstance(); Assert.assertTrue(serviceReferenceHolder instanceof ServiceReferenceHolder); serviceReferenceHolder.getThrottleDataHolder(); ThrottleDataHolder throttleDataHolder = Mockito.mock(ThrottleDataHolder.class); serviceReferenceHolder.setThrottleDataHolder(throttleDataHolder); ConfigurationContextService cfgCtxService = Mockito.mock(ConfigurationContextService.class); serviceReferenceHolder.setConfigurationContextService(cfgCtxService); cfgCtxService = serviceReferenceHolder.getConfigurationContextService(); Assert.assertNotNull(cfgCtxService); APIManagerConfigurationService apiManagerConfigurationService = Mockito.mock(APIManagerConfigurationService.class); serviceReferenceHolder.setAPIManagerConfigurationService(apiManagerConfigurationService); apiManagerConfigurationService = serviceReferenceHolder.getApiManagerConfigurationService(); Assert.assertNotNull(apiManagerConfigurationService); Assert.assertNull(serviceReferenceHolder.getAPIManagerConfiguration()); Assert.assertNull(serviceReferenceHolder.getServerConfigurationContext()); ThrottleProperties throttleProperties = Mockito.mock(ThrottleProperties.class); serviceReferenceHolder.setThrottleProperties(throttleProperties); Assert.assertNotNull(serviceReferenceHolder.getThrottleProperties()); }
Example #10
Source File: VirtualHostClusterServiceComponent.java From carbon-commons with Apache License 2.0 | 5 votes |
@Reference( name = "config.context.service", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService ccService) { ConfigurationContext serverCtx = ccService.getServerConfigContext(); AxisConfiguration serverConfig = serverCtx.getAxisConfiguration(); LocalTransportReceiver.CONFIG_CONTEXT = new ConfigurationContext(serverConfig); LocalTransportReceiver.CONFIG_CONTEXT.setServicePath("services"); LocalTransportReceiver.CONFIG_CONTEXT.setContextRoot("local:/"); DataHolder.getInstance().setConfigurationContextService(ccService); }
Example #11
Source File: ApplicationMgtUIServiceComponent.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
@Reference( name = "config.context.service", service = ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService" ) protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { ApplicationMgtServiceComponentHolder.getInstance().setConfigurationContextService(configurationContextService); if (log.isDebugEnabled()) { log.debug("ConfigurationContextService Instance was set."); } }
Example #12
Source File: APIManagerComponent.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Reference( name = "config.context.service", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService contextService) { ServiceReferenceHolder.setContextService(contextService); }
Example #13
Source File: TestUtils.java From carbon-apimgt with Apache License 2.0 | 5 votes |
public static ServiceReferenceHolder getServiceReferenceHolder() { PowerMockito.mockStatic(ServiceReferenceHolder.class); ServiceReferenceHolder sh = PowerMockito.mock(ServiceReferenceHolder.class); PowerMockito.when(ServiceReferenceHolder.getInstance()).thenReturn(sh); ConfigurationContextService configurationContextService = initConfigurationContextService(false); PowerMockito.when(ServiceReferenceHolder.getContextService()).thenReturn(configurationContextService); return sh; }
Example #14
Source File: ThriftAuthenticationServiceComponent.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
@Reference( name = "configuration.context", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContext") protected void setConfigurationContext(ConfigurationContextService configurationContext) { this.configurationContext = configurationContext; }
Example #15
Source File: ApplicationManagementServiceComponent.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
@Reference( name = "configuration.context.service", service = ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService" ) protected void setConfigurationContextService(ConfigurationContextService configContextService) { if (log.isDebugEnabled()) { log.debug("Setting the Configuration Context Service"); } ApplicationManagementServiceComponentHolder.getInstance().setConfigContextService(configContextService); }
Example #16
Source File: WSEventBrokerDS.java From carbon-commons with Apache License 2.0 | 5 votes |
@Reference( name = "configurationcontext.service", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { WSEventBrokerHolder.getInstance().registerConfigurationContextService(configurationContextService); }
Example #17
Source File: UrlMapperServerComponent.java From carbon-commons with Apache License 2.0 | 5 votes |
@Reference( name = "config.context.service", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService contextService) { DataHolder.getInstance().setServerConfigContext(contextService.getServerConfigContext()); }
Example #18
Source File: SecurityMgtServiceComponent.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
protected void unsetConfigurationContextService(ConfigurationContextService contextService) { if (log.isDebugEnabled()) { log.debug("Unsetting the ConfigurationContext"); } this.configContextService = null; SecurityServiceHolder.setConfigurationContextService(contextService); }
Example #19
Source File: UserStoreConfigComponent.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
@Reference( name = "config.context.service", service = ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService" ) protected void setConfigurationContextService(ConfigurationContextService contextService) { if (log.isDebugEnabled()) { log.info("Setting the ConfigurationContextService"); } }
Example #20
Source File: IdentitySTSMgtServiceComponent.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * @param contextService */ protected void unsetConfigurationContextService(ConfigurationContextService contextService) { if (log.isDebugEnabled()) { log.info("ConfigurationContextService unset in Identity STS Mgt bundle"); } this.configContext = null; }
Example #21
Source File: SSOHostObjectServiceComponent.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Reference( name = "config.context.service", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configCtxtService) { SSOHostObjectDataHolder.getInstance().setConfigurationContextService(configCtxtService); }
Example #22
Source File: APIHandlerServiceComponent.java From carbon-apimgt with Apache License 2.0 | 5 votes |
protected void unsetConfigurationContextService(ConfigurationContextService cfgCtxService) { if (log.isDebugEnabled()) { log.debug("Configuration context service unbound from the API handlers"); } ServiceReferenceHolder.getInstance().setConfigurationContextService(null); }
Example #23
Source File: HostObjectComponentTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Test public void testUnsetConfigurationContextService() { AxisConfiguration axisConfiguration = new AxisConfiguration(); ConfigurationContextService configurationContextService = Mockito.mock(ConfigurationContextService.class); hostObjectComponent.unsetConfigurationContextService(configurationContextService); // Nothing to assert }
Example #24
Source File: EmailVerificationServiceComponent.java From carbon-commons with Apache License 2.0 | 5 votes |
@Reference( name = "configuration.context.service", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { log.debug("Recieving ConfigurationContext Service"); this.configurationContextService = configurationContextService; }
Example #25
Source File: TasksDSComponent.java From carbon-commons with Apache License 2.0 | 5 votes |
@Reference( name = "config.context.service", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configCtxService) { TasksDSComponent.configCtxService = configCtxService; }
Example #26
Source File: EventBrokerBuilderDS.java From carbon-commons with Apache License 2.0 | 5 votes |
@Reference( name = "configurationcontext.service", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { EventBrokerHolder.getInstance().registerConfigurationContextService(configurationContextService); }
Example #27
Source File: StatisticsServiceComponent.java From carbon-commons with Apache License 2.0 | 5 votes |
@Reference( name = "config.context.service", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService contextService) { this.configContext = contextService.getServerConfigContext(); }
Example #28
Source File: OIDCAuthenticatorUIDSComponent.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Reference( name = "config.context.service", service = org.wso2.carbon.utils.ConfigurationContextService.class, cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC, unbind = "unsetConfigurationContextService") protected void setConfigurationContextService(ConfigurationContextService configCtxtService) { OIDCAuthFEDataHolder.getInstance().setConfigurationContextService(configCtxtService); }
Example #29
Source File: UrlPrinterServiceComponent.java From carbon-device-mgt with Apache License 2.0 | 5 votes |
protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { if (log.isDebugEnabled()) { log.debug("Setting ConfigurationContextService"); } UrlPrinterDataHolder.getInstance().setConfigurationContextService(configurationContextService); }
Example #30
Source File: DataHolder.java From carbon-commons with Apache License 2.0 | 4 votes |
public ConfigurationContextService getConfigurationContextService() { return this.configurationContextService; }