Implementing the storage configuration class |
After implementing the extended json storage method, you also need to implement a configuration class for specifying the json storage configuration, including the disk storage location. When you use the extended json storage method in iServer, you can specify this configuration class to make the extension take effect. iServer provides a custom storage extension configuration interface CustomSecurityInfoStorageSetting, which can be used to customize the storage configuration class.
The extended form is such as:
public class JsonStorageSetting extends CustomSecurityInfoStorageSetting{ ... }
To specify the expansion type and json storage location, it needs to achieve two parameters:
public JsonStorageSetting() { super(); this.type = SecurityInfoStorageType.CUSTOM; }
public JsonStorageSetting(JsonStorageSetting jsonStorageSetting) { super(jsonStorageSetting); this.outputDirectory = jsonStorageSetting.outputDirectory; } @Override public SecurityInfoStorageSetting copy() { return new JsonStorageSetting(this); }
The complete extension sample code is as follows:
package com.supermap.server.config; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; public class JsonStorageSetting extends CustomSecurityInfoStorageSetting { private static final long serialVersionUID = 1L; public String outputDirectory; public JsonStorageSetting() { super(); this.type = SecurityInfoStorageType.CUSTOM; } public JsonStorageSetting(JsonStorageSetting jsonStorageSetting) { super(jsonStorageSetting); this.outputDirectory = jsonStorageSetting.outputDirectory; } @Override public boolean equals(Object objToEqual) { if (objToEqual == null) { return false; } if (!(objToEqual instanceof JsonStorageSetting)) { return false; } JsonStorageSetting obj = (JsonStorageSetting) objToEqual; EqualsBuilder builder = new EqualsBuilder(); builder.append(this.outputDirectory, obj.outputDirectory); return builder.isEquals(); } @Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder().appendSuper(super.hashCode()).append(this.outputDirectory); return builder.toHashCode(); } @Override public SecurityInfoStorageSetting copy() { return new JsonStorageSetting(this); } }