本文整理汇总了Java中org.wso2.carbon.context.RegistryType类的典型用法代码示例。如果您正苦于以下问题:Java RegistryType类的具体用法?Java RegistryType怎么用?Java RegistryType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegistryType类属于org.wso2.carbon.context包,在下文中一共展示了RegistryType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createRegistryService
import org.wso2.carbon.context.RegistryType; //导入依赖的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: renameAppPermissionPathNode
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
/**
* Rename the registry path node name for a deleted Service provider role.
*
* @param oldName
* @param newName
* @throws IdentityApplicationManagementException
*/
public static void renameAppPermissionPathNode(String oldName, String newName)
throws IdentityApplicationManagementException {
List<ApplicationPermission> loadPermissions = loadPermissions(oldName);
String newApplicationNode = ApplicationMgtUtil.getApplicationPermissionPath() + PATH_CONSTANT + oldName;
Registry tenantGovReg = CarbonContext.getThreadLocalCarbonContext().getRegistry(
RegistryType.USER_GOVERNANCE);
//creating new application node
try {
for (ApplicationPermission applicationPermission : loadPermissions) {
tenantGovReg.delete(newApplicationNode + PATH_CONSTANT + applicationPermission.getValue());
}
tenantGovReg.delete(newApplicationNode);
Collection permissionNode = tenantGovReg.newCollection();
permissionNode.setProperty("name", newName);
newApplicationNode = ApplicationMgtUtil.getApplicationPermissionPath() + PATH_CONSTANT + newName;
ApplicationMgtUtil.applicationNode = newApplicationNode;
tenantGovReg.put(newApplicationNode, permissionNode);
addPermission(loadPermissions.toArray(new ApplicationPermission[loadPermissions.size()]), tenantGovReg);
} catch (RegistryException e) {
throw new IdentityApplicationManagementException("Error while renaming permission node "
+ oldName + "to " + newName, e);
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:32,代码来源:ApplicationMgtUtil.java
示例3: deletePermissions
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
/**
* Delete the resource
*
* @param applicationName
* @throws IdentityApplicationManagementException
*/
public static void deletePermissions(String applicationName) throws IdentityApplicationManagementException {
String applicationNode = getApplicationPermissionPath() + PATH_CONSTANT + applicationName;
Registry tenantGovReg = CarbonContext.getThreadLocalCarbonContext().getRegistry(
RegistryType.USER_GOVERNANCE);
try {
boolean exist = tenantGovReg.resourceExists(applicationNode);
if (exist) {
tenantGovReg.delete(applicationNode);
}
} catch (RegistryException e) {
throw new IdentityApplicationManagementException("Error while storing permissions", e);
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:ApplicationMgtUtil.java
示例4: getResourceStream
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
@Override
public InputStream getResourceStream(String name) throws ResourceNotFoundException {
try {
Registry registry =
CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_CONFIGURATION);
if (registry == null) {
throw new IllegalStateException("No valid registry instance is attached to the current carbon context");
}
if (!registry.resourceExists(EMAIL_CONFIG_BASE_LOCATION + "/" + name)) {
throw new ResourceNotFoundException("Resource '" + name + "' does not exist");
}
org.wso2.carbon.registry.api.Resource resource =
registry.get(EMAIL_CONFIG_BASE_LOCATION + "/" + name);
resource.setMediaType("text/plain");
return resource.getContentStream();
} catch (RegistryException e) {
throw new ResourceNotFoundException("Error occurred while retrieving resource", e);
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:20,代码来源:RegistryBasedResourceLoader.java
示例5: write
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
@Override
public void write(String outPath, InputStream in) throws MLOutputAdapterException {
if (in == null || outPath == null) {
throw new MLOutputAdapterException(String.format(
"Null argument values detected. Input stream: %s Out Path: %s", in, outPath));
}
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
IOUtils.copy(in, byteArrayOutputStream);
byte[] array = byteArrayOutputStream.toByteArray();
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
Registry registry = carbonContext.getRegistry(RegistryType.SYSTEM_GOVERNANCE);
Resource resource = registry.newResource();
resource.setContent(array);
registry.put(outPath, resource);
} catch (RegistryException | IOException e) {
throw new MLOutputAdapterException(
String.format("Failed to save the model to registry %s: %s", outPath, e), e);
}
}
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:24,代码来源:RegistryOutputAdapter.java
示例6: getServiceProviderConfig
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
/**
* Returns the configured service provider configurations. The
* configurations are taken from the user registry or from the
* sso-idp-config.xml configuration file. In Stratos deployment the
* configurations are read from the sso-idp-config.xml file.
*
* @param authnReqDTO
* @return
* @throws IdentityException
*/
private SAMLSSOServiceProviderDO getServiceProviderConfig(SAMLSSOAuthnReqDTO authnReqDTO)
throws IdentityException {
try {
SSOServiceProviderConfigManager stratosIdpConfigManager = SSOServiceProviderConfigManager
.getInstance();
SAMLSSOServiceProviderDO ssoIdpConfigs = stratosIdpConfigManager
.getServiceProvider(authnReqDTO.getIssuer());
if (ssoIdpConfigs == null) {
IdentityPersistenceManager persistenceManager = IdentityPersistenceManager
.getPersistanceManager();
Registry registry = (Registry) PrivilegedCarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_CONFIGURATION);
ssoIdpConfigs = persistenceManager.getServiceProvider(registry,
authnReqDTO.getIssuer());
authnReqDTO.setStratosDeployment(false); // not stratos
} else {
authnReqDTO.setStratosDeployment(true); // stratos deployment
}
return ssoIdpConfigs;
} catch (Exception e) {
throw IdentityException.error("Error while reading Service Provider configurations", e);
}
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:33,代码来源:IdPInitSSOAuthnRequestProcessor.java
示例7: getServiceProviderConfig
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
/**
* Returns the configured service provider configurations. The
* configurations are taken from the user registry or from the
* sso-idp-config.xml configuration file. In Stratos deployment the
* configurations are read from the sso-idp-config.xml file.
*
* @param authnReqDTO
* @return
* @throws IdentityException
*/
private SAMLSSOServiceProviderDO getServiceProviderConfig(SAMLSSOAuthnReqDTO authnReqDTO)
throws IdentityException {
try {
SSOServiceProviderConfigManager stratosIdpConfigManager = SSOServiceProviderConfigManager
.getInstance();
SAMLSSOServiceProviderDO ssoIdpConfigs = stratosIdpConfigManager
.getServiceProvider(authnReqDTO.getIssuer());
if (ssoIdpConfigs == null) {
IdentityTenantUtil.initializeRegistry(PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getTenantId(), PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain());
IdentityPersistenceManager persistenceManager = IdentityPersistenceManager.getPersistanceManager();
Registry registry = (Registry) PrivilegedCarbonContext.getThreadLocalCarbonContext().getRegistry
(RegistryType.SYSTEM_CONFIGURATION);
ssoIdpConfigs = persistenceManager.getServiceProvider(registry, authnReqDTO.getIssuer());
authnReqDTO.setStratosDeployment(false); // not stratos
} else {
authnReqDTO.setStratosDeployment(true); // stratos deployment
}
return ssoIdpConfigs;
} catch (Exception e) {
throw IdentityException.error("Error while reading Service Provider configurations", e);
}
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:34,代码来源:SPInitSSOAuthnRequestProcessor.java
示例8: initServiceClient
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
private ServiceClient initServiceClient(String epr, int notificationType,
AxisConfiguration axisConf) throws Exception {
ConfigurationContext cfgCtx = ConfigHolder.getInstance().getClientConfigurationContext();
ServiceClient serviceClient = new ServiceClient(cfgCtx, null);
serviceClient.setTargetEPR(new EndpointReference(epr));
if (notificationType == DiscoveryConstants.NOTIFICATION_TYPE_HELLO) {
serviceClient.getOptions().setAction(DiscoveryConstants.WS_DISCOVERY_HELLO_ACTION);
} else {
serviceClient.getOptions().setAction(DiscoveryConstants.WS_DISCOVERY_BYE_ACTION);
}
serviceClient.engageModule("addressing");
Registry registry = (Registry)PrivilegedCarbonContext.getThreadLocalCarbonContext().getRegistry(
RegistryType.SYSTEM_CONFIGURATION);
Policy policy = DiscoveryMgtUtils.getClientSecurityPolicy(registry);
if (policy != null) {
serviceClient.engageModule("rampart");
serviceClient.getOptions().setProperty(
DiscoveryConstants.KEY_RAMPART_POLICY, policy);
}
return serviceClient;
}
开发者ID:wso2,项目名称:carbon-commons,代码行数:26,代码来源:MessageSender.java
示例9: clearMetadata
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
private static void clearMetadata(String applicationId) throws RestAPIException {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
String resourcePath = METADATA_REG_PATH + applicationId;
Registry registry = (UserRegistry) PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getRegistry(RegistryType.SYSTEM_GOVERNANCE);
try {
registry.beginTransaction();
if (registry.resourceExists(resourcePath)) {
registry.delete(resourcePath);
log.info(String.format("Application metadata removed: [application-id] %s", applicationId));
}
registry.commitTransaction();
} catch (RegistryException e) {
try {
registry.rollbackTransaction();
} catch (RegistryException e1) {
log.error("Could not rollback transaction", e1);
}
throw new RestAPIException(
String.format("Application metadata removed: [application-id] %s", applicationId), e);
}
}
开发者ID:apache,项目名称:stratos,代码行数:27,代码来源:StratosApiV41Utils.java
示例10: persistConfig
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
@Override
public void persistConfig(String policyEditorType, String xmlConfig) throws PolicyEditorException {
super.persistConfig(policyEditorType, xmlConfig);
Registry registry = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE);
try {
Resource resource = registry.newResource();
resource.setContent(xmlConfig);
String path = null;
if (EntitlementConstants.PolicyEditor.BASIC.equals(policyEditorType)) {
path = EntitlementConstants.ENTITLEMENT_POLICY_BASIC_EDITOR_CONFIG_FILE_REGISTRY_PATH;
} else if (EntitlementConstants.PolicyEditor.STANDARD.equals(policyEditorType)) {
path = EntitlementConstants.ENTITLEMENT_POLICY_STANDARD_EDITOR_CONFIG_FILE_REGISTRY_PATH;
} else if (EntitlementConstants.PolicyEditor.RBAC.equals(policyEditorType)) {
path = EntitlementConstants.ENTITLEMENT_POLICY_RBAC_EDITOR_CONFIG_FILE_REGISTRY_PATH;
} else if (EntitlementConstants.PolicyEditor.SET.equals(policyEditorType)) {
path = EntitlementConstants.ENTITLEMENT_POLICY_SET_EDITOR_CONFIG_FILE_REGISTRY_PATH;
} else {
//default
path = EntitlementConstants.ENTITLEMENT_POLICY_BASIC_EDITOR_CONFIG_FILE_REGISTRY_PATH;
}
registry.put(path, resource);
} catch (RegistryException e) {
throw new PolicyEditorException("Error while persisting policy editor config");
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:28,代码来源:RegistryPersistenceManager.java
示例11: removeServiceProviderConfiguration
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
@Override
public void removeServiceProviderConfiguration(String issuer) throws IdentityApplicationManagementException {
try {
IdentityPersistenceManager persistenceManager = IdentityPersistenceManager.getPersistanceManager();
Registry configSystemRegistry = (Registry) PrivilegedCarbonContext.getThreadLocalCarbonContext().
getRegistry(RegistryType.SYSTEM_CONFIGURATION);
persistenceManager.removeServiceProvider(configSystemRegistry, issuer);
} catch (IdentityException e) {
log.error("Erro while deleting the issuer", e);
throw new IdentityApplicationManagementException("Error while deleting SAML issuer " + e.getMessage());
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:13,代码来源:SAMLApplicationDAOImpl.java
示例12: deleteUser
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
public void deleteUser(String userName) throws UserAdminException {
try {
getUserAdminProxy().deleteUser(userName,
CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.USER_CONFIGURATION));
} catch (UserAdminException e) {
throw e;
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:12,代码来源:UserAdmin.java
示例13: RegistryBasedLicenseManager
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
public RegistryBasedLicenseManager() {
Registry registry = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE);
if (registry == null) {
throw new IllegalArgumentException("Registry instance retrieved is null. Hence, " +
"'Registry based license manager cannot be initialized'");
}
try {
this.artifactManager = GenericArtifactManagerFactory.getTenantAwareGovernanceArtifactManager(registry);
} catch (LicenseManagementException e) {
throw new IllegalStateException("Failed to initialize generic artifact manager bound to " +
"Registry based license manager", e);
}
}
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:14,代码来源:RegistryBasedLicenseManager.java
示例14: init
import org.wso2.carbon.context.RegistryType; //导入依赖的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
示例15: read
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
@Override
public InputStream read(String path) throws MLInputAdapterException {
try {
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
Registry registry = carbonContext.getRegistry(RegistryType.SYSTEM_GOVERNANCE);
Resource resource = registry.get(path);
byte[] readArray = (byte[]) resource.getContent();
ByteArrayInputStream bis = new ByteArrayInputStream(readArray);
return bis;
} catch (RegistryException e) {
throw new MLInputAdapterException(String.format("Failed to read the model from uri %s: %s", path, e), e);
}
}
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:14,代码来源:RegistryInputAdapter.java
示例16: readOMElementFromRegistry
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
private static OMElement readOMElementFromRegistry(String registryLocation) {
OMElement serviceElement = null;
Registry registry;
String location;
if (registryLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_CONF_REG)) {
registry = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_CONFIGURATION);
location = registryLocation.substring(registryLocation.indexOf(
UnifiedEndpointConstants.VIRTUAL_CONF_REG) +
UnifiedEndpointConstants.VIRTUAL_CONF_REG.length());
serviceElement = loadOMElement(registry, location);
} else if (registryLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_GOV_REG)) {
registry = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE);
location = registryLocation.substring(registryLocation.indexOf(
UnifiedEndpointConstants.VIRTUAL_GOV_REG) +
UnifiedEndpointConstants.VIRTUAL_GOV_REG.length());
serviceElement = loadOMElement(registry, location);
} else if (registryLocation.startsWith(UnifiedEndpointConstants.VIRTUAL_REG)) {
registry = CarbonContext.getThreadLocalCarbonContext().getRegistry(RegistryType.LOCAL_REPOSITORY);
location = registryLocation.substring(registryLocation.indexOf(
UnifiedEndpointConstants.VIRTUAL_REG) +
UnifiedEndpointConstants.VIRTUAL_REG.length());
serviceElement = loadOMElement(registry, location);
} else {
String errMsg = "Invalid service.xml file location: " + registryLocation;
log.warn(errMsg);
}
return serviceElement;
}
开发者ID:wso2,项目名称:carbon-business-process,代码行数:31,代码来源:ServiceConfigurationUtil.java
示例17: saveDASconfigInfo
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
/**
* Save DAS configuration details (received from PC), in config registry
*
* @param dasConfigDetailsJSONString Details of analytics configuration with WSO2 DAS as a JSON string
* @throws RegistryException Throws RegistryException if error occurred in accessing registry
* @throws IOException Throws IOException if an error occurred in hadling json content
*/
private void saveDASconfigInfo(String dasConfigDetailsJSONString) throws RegistryException, IOException {
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
Registry configRegistry = carbonContext.getRegistry(RegistryType.SYSTEM_CONFIGURATION);
ObjectMapper objectMapper = new ObjectMapper();
JsonNode dasConfigDetailsJOb = objectMapper.readTree(dasConfigDetailsJSONString);
String processDefinitionId = dasConfigDetailsJOb.get(AnalyticsPublisherConstants.PROCESS_DEFINITION_ID)
.textValue();
//create a new resource (text file) to keep process variables
Resource procVariableJsonResource = configRegistry.newResource();
procVariableJsonResource.setContent(dasConfigDetailsJSONString);
procVariableJsonResource.setMediaType(MediaType.APPLICATION_JSON);
configRegistry.put(AnalyticsPublisherConstants.REG_PATH_BPMN_ANALYTICS + processDefinitionId + "/"
+ AnalyticsPublisherConstants.ANALYTICS_CONFIG_FILE_NAME, procVariableJsonResource);
}
开发者ID:wso2,项目名称:carbon-business-process,代码行数:22,代码来源:PublishProcessVariablesService.java
示例18: deleteDASConfigInfo
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
/**
* Delete DAS configuration details (received from PC), from config registry
*
* @param processDefinitionIdJSONString JSON string contains process definition id
* @throws RegistryException Throws RegistryException if error occurred in accessing registry
* @throws IOException Throws IOException if an error occurred in hadling json content
*/
private void deleteDASConfigInfo(String processDefinitionIdJSONString) throws RegistryException, IOException {
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
Registry configRegistry = carbonContext.getRegistry(RegistryType.SYSTEM_CONFIGURATION);
ObjectMapper objectMapper = new ObjectMapper();
JsonNode dasConfigDetailsJOb = objectMapper.readTree(processDefinitionIdJSONString);
String processDefinitionId = dasConfigDetailsJOb.get(AnalyticsPublisherConstants.PROCESS_DEFINITION_ID)
.textValue();
configRegistry.delete(AnalyticsPublisherConstants.REG_PATH_BPMN_ANALYTICS + processDefinitionId + "/"
+ AnalyticsPublisherConstants.ANALYTICS_CONFIG_FILE_NAME);
}
开发者ID:wso2,项目名称:carbon-business-process,代码行数:20,代码来源:PublishProcessVariablesService.java
示例19: testHandlerList
import org.wso2.carbon.context.RegistryType; //导入依赖的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
示例20: isServiceDiscoveryEnabled
import org.wso2.carbon.context.RegistryType; //导入依赖的package包/类
/**
* Check whether service discovery is enabled in the configuration. This method first checks
* whether the DiscoveryConstants.DISCOVERY_PROXY parameter is set in the given AxisConfiguration.
* If not it checks whether service discovery status is set to 'true' in the configuration
* registry. If discovery is enabled in the registry configuration, this method will also
* add the corresponding parameter to AxisConfiguration.
*
* @param axisConfig AxisConfiguration
* @return service discovery status
* @throws RegistryException if an error occurs while accessing the registry
*/
public static boolean isServiceDiscoveryEnabled(AxisConfiguration axisConfig) throws RegistryException {
Parameter parameter = getDiscoveryParam(axisConfig);
if (parameter != null) {
return true;
}
String path = DISCOVERY_CONFIG_ROOT + DISCOVERY_PUBLISHER_CONFIG;
Registry registry = PrivilegedCarbonContext.getThreadLocalCarbonContext().
getRegistry(RegistryType.SYSTEM_CONFIGURATION);
if (registry.resourceExists(path)) {
Resource publisherConfig = registry.get(path);
String status = publisherConfig.getProperty(DISCOVERY_PUBLISHER_STATUS);
publisherConfig.discard();
boolean enabled = JavaUtils.isTrueExplicitly(status);
if (enabled) {
String discoveryProxyURL = getDiscoveryProxyURL(registry);
try {
Parameter discoveryProxyParam =
ParameterUtil.createParameter(DiscoveryConstants.DISCOVERY_PROXY,
discoveryProxyURL);
axisConfig.addParameter(discoveryProxyParam);
} catch (AxisFault axisFault) {
axisFault.printStackTrace(); //TODO
}
}
return enabled;
}
return false;
}
开发者ID:wso2,项目名称:carbon-commons,代码行数:44,代码来源:DiscoveryMgtUtils.java
注:本文中的org.wso2.carbon.context.RegistryType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论