org.geoserver.config.GeoServer.getServiceByName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中org.geoserver.config.GeoServer.getServiceByName()方法的一些代码示例,展示了GeoServer.getServiceByName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeoServer.getServiceByName()方法的具体详情如下:
包路径:org.geoserver.config.GeoServer
类名称:GeoServer
方法名:getServiceByName

GeoServer.getServiceByName介绍

[英]Looks up a service by name.
[中]按名称查找服务。

代码示例

代码示例来源:origin: geoserver/geoserver

@Test
public void testRemoveWorkspaceLocalService() throws Exception {
  testAddWorkspaceLocalService();
  File dataDirRoot = getTestData().getDataDirectoryRoot();
  WorkspaceInfo ws = getCatalog().getDefaultWorkspace();
  File f = new File(dataDirRoot, "workspaces" + "/" + ws.getName() + "/service.xml");
  assertTrue(f.exists());
  Logger logger = Logging.getLogger(GeoServerImpl.class);
  Level level = logger.getLevel();
  try {
    logger.setLevel(Level.OFF);
    ServiceInfo s = geoServer.getServiceByName(ws, "foo", ServiceInfo.class);
    geoServer.remove(s);
    assertFalse(f.exists());
  } finally {
    logger.setLevel(level);
  }
}

代码示例来源:origin: geoserver/geoserver

@Before
public void removeFooService() throws IOException {
  GeoServer geoServer = getGeoServer();
  WorkspaceInfo ws = getCatalog().getDefaultWorkspace();
  ServiceInfo s = geoServer.getServiceByName(ws, "foo", ServiceInfo.class);
  if (s != null) {
    geoServer.remove(s);
  }
  File serviceFile = getDataDirectory().findFile("service.xml");
  if (serviceFile != null) {
    serviceFile.delete();
  }
}

代码示例来源:origin: org.geoserver/jms-geoserver

/**
 * get local object searching by name if name is changed (remotely), search is performed using the old one
 * 
 * @param geoServer
 * @param ev
 * @return
 */
public static ServiceInfo getLocalService(final GeoServer geoServer,
    final JMSServiceModifyEvent ev) {
  final ServiceInfo service = ev.getSource();
  if (service == null) {
    throw new IllegalArgumentException("passed service is null");
  }
  // localize service
  final ServiceInfo localObject;
  // check if name is changed
  final List<String> props = ev.getPropertyNames();
  final int index = props.indexOf("name");
  if (index != -1) {
    final List<Object> oldValues = ev.getOldValues();
    // search the Service using the old name
    localObject = geoServer.getServiceByName(oldValues.get(index).toString(),
        ServiceInfo.class);
  } else {
    localObject = geoServer.getServiceByName(service.getName(), ServiceInfo.class);
  }
  return localObject;
}

代码示例来源:origin: org.geoserver/gs-jms-geoserver

/**
 * get local object searching by name if name is changed (remotely), search is performed using the old one
 * 
 * @param geoServer
 * @param ev
 * @return
 */
public static ServiceInfo getLocalService(final GeoServer geoServer,
    final JMSServiceModifyEvent ev) {
  final ServiceInfo service = ev.getSource();
  if (service == null) {
    throw new IllegalArgumentException("passed service is null");
  }
  // localize service
  final ServiceInfo localObject;
  // check if name is changed
  final List<String> props = ev.getPropertyNames();
  final int index = props.indexOf("name");
  if (index != -1) {
    final List<Object> oldValues = ev.getOldValues();
    // search the Service using the old name
    localObject = geoServer.getServiceByName(oldValues.get(index).toString(),
        ServiceInfo.class);
  } else {
    localObject = geoServer.getServiceByName(service.getName(), ServiceInfo.class);
  }
  return localObject;
}

代码示例来源:origin: org.geoserver.community/gs-jms-geoserver

private ServiceInfo findService(String serviceName, String workspaceName) {
  if (workspaceName == null) {
    // global service
    return ModificationProxy.unwrap(
        getGeoServer().getServiceByName(serviceName, ServiceInfo.class));
  }
  // virtual service
  WorkspaceInfo workspaceInfo = getCatalog().getWorkspace(workspaceName);
  return ModificationProxy.unwrap(
      getGeoServer().getServiceByName(workspaceInfo, serviceName, ServiceInfo.class));
}

相关文章