0

我正在尝试获取资源路径 /_system/governance/trunk/services 中的服务列表。所以最初我试图使用注册表 api 获取资源。我尝试了两种方式。一种方法是

         `CarbonContext cCtx = CarbonContext.getCurrentContext();

          Registry registry = cCtx.getRegistry(RegistryType.SYSTEM_CONFIGURATION);
          String registryType = request.getParameter("registryType");
          if(registryType != null) {
          registry = cCtx.getRegistry(RegistryType.valueOf(registryType));
          }
          String resourcePath = "/_system/governance/trunk/services";
          try{
      if(registry.resourceExits(resourcePath)){
        Resource resource = registry.get(resourcePath);
      }
      }catch(Exception e){
       out.print(e.getMessage());
      }` 

使用 ServiceManager 的另一种方法,我在初始化 ServiceManager 的第一步失败

            'CarbonContext cCtx = CarbonContext.getCurrentContext();

             Registry registry = cCtx.getRegistry(RegistryType.SYSTEM_CONFIGURATION);
             String registryType = request.getParameter("registryType");
             if(registryType != null) {
                   registry = cCtx.getRegistry(RegistryType.valueOf(registryType));
               out.print(" Registry got Initialised ! ");
             }
        java.util.List<Resource> result = new java.util.ArrayList<Resource>();
        String resourcePath = "/_system/governance/trunk/services";
        ServiceManager serviceManager = new ServiceManager(registry);'   

那么我需要做什么来获取 index.jsp 中所有服务的列表并且我正在使用二进制代码?

4

2 回答 2

0

就我而言,我在 Identity Server 4.1.0 中工作。我在以下路径中的管理控制台(Web 前端)中添加了一个资源在注册表中:/_system/local/repository 该资源称为 apacheInfo。在资源中,我添加了一个带有
key = com.xxx.identity.Apache
value = www.domain.com:8998
我的代码的属性:

CarbonContext cCtx = CarbonContext.getCurrentContext();
//this implies the path /_system/local/
Registry registry = cCtx.getRegistry(RegistryType.LOCAL_REPOSITORY);
Resource resource;
String apacheUrl;
            try {
                resource = registry.get("repository/apacheInfo");
                apacheUrl = resource.getProperty("com.xxx.identity.Apache");
            } catch (RegistryException e) {
                LOG.error("RegistryException looking up path repository/apacheInfo", e);
            }

我从未在 WSO2 文档中找到示例,但我看到了这段对话:
http://wso2-oxygen-tank.10903.n7.nabble.com/Generic-Resource-Registry-Management-in-App-Factory-td79279。 html
然后我了解了他们阅读存储库的方式...希望这会有所帮助

于 2013-08-07T15:53:17.167 回答
0

您应该使用治理注册表来初始化 ServiceManager。

ServiceManager serviceManager = new ServiceManager(governanceRegistry);

服务[] 服务 = serviceManager.getAllServices();

[1] http://docs.wso2.org/wiki/display/Governance453/Services+with+Governance+API

-阿吉特

于 2013-05-24T17:08:14.513 回答