本文整理了Java中org.geoserver.config.util.XStreamServiceLoader
类的一些代码示例,展示了XStreamServiceLoader
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XStreamServiceLoader
类的具体详情如下:
包路径:org.geoserver.config.util.XStreamServiceLoader
类名称:XStreamServiceLoader
[英]Service loader which loads and saves a service configuration with xstream.
[中]使用xstream加载并保存服务配置的服务加载器。
代码示例来源:origin: geoserver/geoserver
public final T load(GeoServer gs, Resource directory) throws Exception {
// look for file matching classname
Resource file;
if (Resources.exists(file = directory.get(getFilename()))) {
// xstream it in
try (BufferedInputStream in = new BufferedInputStream(file.in())) {
XStreamPersister xp = xpf.createXMLPersister();
initXStreamPersister(xp, gs);
return initialize(xp.load(in, getServiceClass()));
}
} else {
// create an 'empty' object
ServiceInfo service = createServiceFromScratch(gs);
return initialize((T) service);
}
}
代码示例来源:origin: geoserver/geoserver
public void handlePostServiceChange(ServiceInfo service) {
XStreamServiceLoader loader = findServiceLoader(service);
try {
// TODO: handle workspace move, factor this class out into
// separate persister class
Resource directory =
service.getWorkspace() != null ? dir(service.getWorkspace()) : null;
loader.save(service, geoServer, directory);
} catch (Throwable t) {
throw new RuntimeException(t);
// LOGGER.log(Level.SEVERE, "Error occurred while saving configuration", t);
}
}
代码示例来源:origin: geoserver/geoserver
public final void save(T service, GeoServer gs, Resource directory) throws Exception {
String filename = getFilename();
Resource resource =
directory == null ? resourceLoader.get(filename) : directory.get(filename);
// using resource output stream makes sure we write on a temp file and them move
try (OutputStream out = resource.out()) {
XStreamPersister xp = xpf.createXMLPersister();
initXStreamPersister(xp, gs);
xp.save(service, out);
}
}
代码示例来源:origin: geoserver/geoserver
for (XStreamServiceLoader<ServiceInfo> l : loaders) {
try {
ServiceInfo s = l.load(geoServer, directory);
if (!global && s.getWorkspace() == null) continue;
+ directory
+ " with loader for "
+ l.getServiceClass(),
t);
} else {
Level.SEVERE,
"Failed to load the root service configuration with loader for "
+ l.getServiceClass(),
t);
代码示例来源:origin: geoserver/geoserver
@Override
public void initXStreamPersister(XStreamPersister xp, GeoServer gs) {
super.initXStreamPersister(xp, gs);
initXStreamPersister(xp);
}
代码示例来源:origin: geoserver/geoserver
/**
* Fills in all the bits that are normally not loaded automatically by XStream, such as empty
* collections
*
* @param info
*/
public void initializeService(ServiceInfo info) {
initialize((T) info);
}
代码示例来源:origin: org.geoserver/restconfig
XStreamServiceLoader serviceLoader = null;
for (XStreamServiceLoader<ServiceInfo> loader : loaders) {
if (loader.getFilename().equals(serviceXmlFileName)) {
serviceLoader = loader;
if (workspace != null) {
if (geoServer.getService(ws, clazz) != null) {
original = serviceLoader.load(geoServer, workspaceDir);
OwsUtils.copy(object, original, clazz);
serviceLoader.save(original, geoServer, workspaceDir);
} else {
ServiceInfo serviceInfo = (ServiceInfo) object;
original = serviceLoader.load(geoServer, root);
OwsUtils.copy(object, original, clazz);
serviceLoader.save(original, geoServer, root);
代码示例来源:origin: org.geoserver/restconfig
@Override
protected Object handleObjectGet() throws Exception {
String workspace = getAttribute("workspace");
File root = resourceLoader.find("");
if (workspace != null) {
WorkspaceInfo ws = geoServer.getCatalog().getWorkspaceByName(workspace);
if (geoServer.getService(ws, clazz) == null) {
throw new RestletException(
"Service for workspace " + workspace + " does not exist",
Status.CLIENT_ERROR_NOT_FOUND);
}
File workspaces = resourceLoader.find("workspaces");
File workspaceDir = resourceLoader.find(workspaces + "/" + ws.getName());
for (XStreamServiceLoader<ServiceInfo> loader : loaders) {
if (loader.getFilename().equals(serviceXmlFileName)) {
return loader.load(geoServer, workspaceDir);
}
}
}
if (geoServer.getService(clazz) == null) {
throw new RestletException("Service for workspace " + workspace + " does not exist",
Status.CLIENT_ERROR_NOT_FOUND);
}
for (XStreamServiceLoader<ServiceInfo> loader : loaders) {
if (loader.getFilename().equals(serviceXmlFileName)) {
return loader.load(geoServer, root);
}
}
return (ServiceInfo) geoServer.getService(clazz);
}
代码示例来源:origin: geoserver/geoserver
GeoServerExtensions.extensions(XStreamServiceLoader.class);
for (XStreamServiceLoader loader : loaders) {
if (serviceClass.equals(loader.getServiceClass())) {
T created = (T) loader.create(geoServer);
代码示例来源:origin: geoserver/geoserver
XStreamServiceLoader findServiceLoader(ServiceInfo service) {
XStreamServiceLoader loader = null;
for (XStreamServiceLoader<ServiceInfo> l : loaders) {
if (l.getServiceClass().isInstance(service)) {
loader = l;
break;
}
}
if (loader == null) {
throw new IllegalArgumentException("No loader for " + service.getName());
}
return loader;
}
代码示例来源:origin: geoserver/geoserver
@Override
public void handleServiceChange(
ServiceInfo service,
List<String> propertyNames,
List<Object> oldValues,
List<Object> newValues) {
XStreamServiceLoader loader = findServiceLoader(service);
// handle the case of a service changing workspace and move the file
int i = propertyNames.indexOf("workspace");
if (i != -1) {
// TODO: share code with GeoServerPersister
WorkspaceInfo old = (WorkspaceInfo) oldValues.get(i);
if (old != null) {
WorkspaceInfo ws = (WorkspaceInfo) newValues.get(i);
Resource f;
try {
f = dir(ws).get(loader.getFilename());
f.renameTo(dir(ws).get(loader.getFilename()));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}
代码示例来源:origin: org.geoserver/gs-wfs
@Override
public void initXStreamPersister(XStreamPersister xp, GeoServer gs) {
super.initXStreamPersister(xp, gs);
initXStreamPersister(xp);
}
代码示例来源:origin: geoserver/geoserver
@Override
protected WCSInfo initialize(WCSInfo service) {
super.initialize(service);
if (service.getExceptionFormats() == null) {
((WCSInfoImpl) service).setExceptionFormats(new ArrayList<String>());
}
if (service.getVersions().isEmpty()) {
service.getVersions().add(new Version("1.0.0"));
service.getVersions().add(new Version("1.1.1"));
}
Version v201 = new Version("2.0.1");
if (!service.getVersions().contains(v201)) {
service.getVersions().add(v201);
}
if (service.getSRS() == null) {
((WCSInfoImpl) service).setSRS(new ArrayList<String>());
}
return service;
}
}
代码示例来源:origin: geoserver/geoserver
/**
* Hook for subclasses to configure the xstream.
*
* <p>The most common use is to do some aliasing or omit some fields.
*/
protected void initXStreamPersister(XStreamPersister xp, GeoServer gs) {
xp.setGeoServer(gs);
xp.setCatalog(gs.getCatalog());
xp.getXStream().alias(filenameBase, getServiceClass());
}
代码示例来源:origin: geoserver/geoserver
public void handleServiceRemove(ServiceInfo service) {
XStreamServiceLoader loader = findServiceLoader(service);
try {
Resource dir =
service.getWorkspace() != null
? dir(service.getWorkspace())
: resourceLoader.get(Paths.BASE);
dir.get(loader.getFilename()).delete();
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
代码示例来源:origin: org.geoserver/gs-wms
@Override
protected void initXStreamPersister(XStreamPersister xp, GeoServer gs) {
super.initXStreamPersister(xp, gs);
initXStreamPersister(xp);
}
代码示例来源:origin: org.geoserver.community/gs-oseo-core
@Override
protected OSEOInfo initialize(OSEOInfo service) {
super.initialize(service);
if (!service.getVersions().contains(OSEOInfo.VERSION_1_0_0)) {
service.getVersions().add(OSEOInfo.VERSION_1_0_0);
}
return service;
}
}
代码示例来源:origin: org.geoserver/gs-gwc
@Override
public void initXStreamPersister(XStreamPersister xp, GeoServer gs) {
super.initXStreamPersister(xp, gs);
xp.getXStream().alias("wmts", WMTSInfo.class, WMTSInfoImpl.class);
}
代码示例来源:origin: org.geoserver/gs-wms
@Override
protected WMSInfo initialize(WMSInfo service) {
super.initialize(service);
final Version version_1_1_1 = WMS.VERSION_1_1_1;
final Version version_1_3_0 = WMS.VERSION_1_3_0;
if (!service.getVersions().contains(version_1_1_1)) {
service.getVersions().add(version_1_1_1);
}
if (!service.getVersions().contains(version_1_3_0)) {
service.getVersions().add(version_1_3_0);
}
if (service.getSRS() == null) {
((WMSInfoImpl) service).setSRS(new ArrayList<String>());
}
if (service.getGetFeatureInfoMimeTypes() == null) {
((WMSInfoImpl) service).setGetFeatureInfoMimeTypes(new HashSet<String>());
}
if (service.getGetMapMimeTypes() == null) {
((WMSInfoImpl) service).setGetMapMimeTypes(new HashSet<String>());
}
if (service.getInterpolation() == null) {
service.setInterpolation(WMSInterpolation.Nearest);
}
return service;
}
代码示例来源:origin: org.geoserver.community/gs-oseo-core
@Override
protected void initXStreamPersister(XStreamPersister xp, GeoServer gs) {
super.initXStreamPersister(xp, gs);
initXStreamPersister(xp);
}
内容来源于网络,如有侵权,请联系作者删除!