当前位置: 首页>>代码示例>>Java>>正文


Java OSGiDataHolder类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:CarbonBasedTestListener.java

示例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);
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:34,代码来源:BaseExtensionsTest.java

示例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);
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:33,代码来源:BaseAPIPublisherTest.java

示例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();
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:31,代码来源:HandlerManagementServiceTest.java


注:本文中的org.wso2.carbon.context.internal.OSGiDataHolder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。