本文整理汇总了Java中org.wso2.carbon.context.internal.OSGiDataHolder类的典型用法代码示例。如果您正苦于以下问题:Java OSGiDataHolder类的具体用法?Java OSGiDataHolder怎么用?Java OSGiDataHolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OSGiDataHolder类属于org.wso2.carbon.context.internal包,在下文中一共展示了OSGiDataHolder类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRegistryService
import org.wso2.carbon.context.internal.OSGiDataHolder; //导入依赖的package包/类
private void createRegistryService(Class realClass, WithRegistry withRegistry) {
try {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(withRegistry.tenantDomain());
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(withRegistry.tenantId());
RegistryContext registryContext = RegistryContext.getBaseInstance(IdentityTenantUtil.getRealmService());
DataSource dataSource = MockInitialContextFactory
.initializeDatasource(REG_DB_JNDI_NAME, realClass, new String[] { REG_DB_SQL_FILE });
registryContext.setDataAccessManager(new JDBCDataAccessManager(dataSource));
RegistryService registryService = new EmbeddedRegistryService(registryContext);
OSGiDataHolder.getInstance().setRegistryService(registryService);
PrivilegedCarbonContext.getThreadLocalCarbonContext()
.setRegistry(RegistryType.USER_GOVERNANCE, registryService.getRegistry());
Class[] singletonClasses = withRegistry.injectToSingletons();
injectSingletonVariables(registryService, RegistryService.class, singletonClasses);
} catch (RegistryException e) {
log.error("Error creating the registry.", e);
}
}
示例2: init
import org.wso2.carbon.context.internal.OSGiDataHolder; //导入依赖的package包/类
@BeforeSuite
public void init() throws RegistryException, IOException {
ClassLoader classLoader = getClass().getClassLoader();
URL resourceUrl = classLoader.getResource(Utils.DEVICE_TYPE_FOLDER + "license.rxt");
String rxt = null;
File carbonHome;
if (resourceUrl != null) {
rxt = FileUtil.readFileToString(resourceUrl.getFile());
}
resourceUrl = classLoader.getResource("carbon-home");
if (resourceUrl != null) {
carbonHome = new File(resourceUrl.getFile());
System.setProperty("carbon.home", carbonHome.getAbsolutePath());
}
PrivilegedCarbonContext.getThreadLocalCarbonContext()
.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID);
RegistryService registryService = Utils.getRegistryService();
OSGiDataHolder.getInstance().setRegistryService(registryService);
UserRegistry systemRegistry =
registryService.getRegistry(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
GovernanceArtifactConfiguration configuration = getGovernanceArtifactConfiguration(rxt);
List<GovernanceArtifactConfiguration> configurations = new ArrayList<>();
configurations.add(configuration);
GovernanceUtils.loadGovernanceArtifacts(systemRegistry, configurations);
Registry governanceSystemRegistry = registryService.getConfigSystemRegistry();
DeviceTypeExtensionDataHolder.getInstance().setRegistryService(registryService);
PrivilegedCarbonContext.getThreadLocalCarbonContext()
.setRegistry(RegistryType.SYSTEM_CONFIGURATION, governanceSystemRegistry);
}
示例3: initServices
import org.wso2.carbon.context.internal.OSGiDataHolder; //导入依赖的package包/类
private void initServices() throws NoSuchFieldException, IllegalAccessException,
JWTClientException, UserStoreException, RegistryException {
IntegrationClientService integrationClientService = Mockito.mock(IntegrationClientServiceImpl.class,
Mockito.CALLS_REAL_METHODS);
APIPublisherDataHolder.getInstance().setIntegrationClientService(integrationClientService);
PublisherClient publisherClient = Mockito.mock(PublisherClient.class, Mockito.CALLS_REAL_METHODS);
doReturn(publisherClient).when(integrationClientService).getPublisherClient();
APIsApi api = new MockApi();
Field field = PublisherClient.class.getDeclaredField("api");
field.setAccessible(true);
field.set(publisherClient, api);
AccessTokenInfo accessTokenInfo = new AccessTokenInfo();
final String REQUIRED_SCOPE =
"apim:api_create apim:api_view apim:api_publish apim:subscribe apim:tier_view apim:tier_manage " +
"apim:subscription_view apim:subscription_block";
accessTokenInfo.setScopes(REQUIRED_SCOPE);
JWTClientManagerService jwtClientManagerService = Mockito.mock(JWTClientManagerServiceImpl.class,
Mockito.CALLS_REAL_METHODS);
JWTClient jwtClient = Mockito.mock(JWTClient.class, Mockito.CALLS_REAL_METHODS);
doReturn(accessTokenInfo).when(jwtClient).getAccessToken(Mockito.anyString(), Mockito.anyString(),
Mockito.anyString(), Mockito.anyString());
doReturn(jwtClient).when(jwtClientManagerService).getJWTClient();
APIIntegrationClientDataHolder.getInstance().setJwtClientManagerService(jwtClientManagerService);
RegistryService registryService = this.getRegistryService();
OSGiDataHolder.getInstance().setRegistryService(registryService);
JWTClientExtensionDataHolder.getInstance().setRegistryService(registryService);
}
示例4: testHandlerList
import org.wso2.carbon.context.internal.OSGiDataHolder; //导入依赖的package包/类
@Test
public void testHandlerList() throws Exception {
String handlerName= "org.wso2.carbon.registry.extensions.handlers.ServiceMediaTypeHandler";
String updatedHandlerName = "org.wso2.carbon.registry.extensions.handlers.DeleteSubscriptionHandler";
try {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(-1234, true);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername("admin");
PrivilegedCarbonContext.getThreadLocalCarbonContext().setRegistry(RegistryType.SYSTEM_CONFIGURATION,
configRegistry);
OSGiDataHolder holder = OSGiDataHolder.getInstance();
holder.setRegistryService(ctx.getEmbeddedRegistryService());
HandlerManagementService managementService = new HandlerManagementService();
managementService.createHandler(handlerConfiguration);
String[] handlerList = managementService.getHandlerList();
Assert.assertArrayEquals(new String[]{handlerName}, handlerList);
Assert.assertEquals(handlerConfiguration, managementService.getHandlerConfiguration(handlerName));
Assert.assertTrue(managementService.updateHandler(handlerName, updateHandlerConfig));
handlerList = managementService.getHandlerList();
Assert.assertArrayEquals(new String[]{updatedHandlerName}, handlerList);
Assert.assertTrue(managementService.deleteHandler(updatedHandlerName));
handlerList = managementService.getHandlerList();
Assert.assertArrayEquals(null, handlerList);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}