PluginInfo to implement Writeable rather than Streamable
This commit is contained in:
parent
555db744f1
commit
84b8c9de19
|
@ -47,13 +47,13 @@ public class PluginsAndModules implements Writeable, ToXContent {
|
|||
int pluginsSize = in.readInt();
|
||||
List<PluginInfo> plugins = new ArrayList<>(pluginsSize);
|
||||
for (int i = 0; i < pluginsSize; i++) {
|
||||
plugins.add(PluginInfo.readFromStream(in));
|
||||
plugins.add(new PluginInfo(in));
|
||||
}
|
||||
this.plugins = Collections.unmodifiableList(plugins);
|
||||
int modulesSize = in.readInt();
|
||||
List<PluginInfo> modules = new ArrayList<>(modulesSize);
|
||||
for (int i = 0; i < modulesSize; i++) {
|
||||
modules.add(PluginInfo.readFromStream(in));
|
||||
modules.add(new PluginInfo(in));
|
||||
}
|
||||
this.modules = Collections.unmodifiableList(modules);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.elasticsearch.Version;
|
|||
import org.elasticsearch.bootstrap.JarHell;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
|
@ -32,7 +32,7 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
|
||||
public class PluginInfo implements Streamable, ToXContent {
|
||||
public class PluginInfo implements Writeable, ToXContent {
|
||||
|
||||
public static final String ES_PLUGIN_PROPERTIES = "plugin-descriptor.properties";
|
||||
public static final String ES_PLUGIN_POLICY = "plugin-security.policy";
|
||||
|
@ -45,13 +45,10 @@ public class PluginInfo implements Streamable, ToXContent {
|
|||
static final String CLASSNAME = "classname";
|
||||
}
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String version;
|
||||
private String classname;
|
||||
|
||||
public PluginInfo() {
|
||||
}
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String version;
|
||||
private final String classname;
|
||||
|
||||
/**
|
||||
* Information about plugins
|
||||
|
@ -67,6 +64,21 @@ public class PluginInfo implements Streamable, ToXContent {
|
|||
this.classname = classname;
|
||||
}
|
||||
|
||||
public PluginInfo(StreamInput in) throws IOException {
|
||||
this.name = in.readString();
|
||||
this.description = in.readString();
|
||||
this.version = in.readString();
|
||||
this.classname = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(name);
|
||||
out.writeString(description);
|
||||
out.writeString(version);
|
||||
out.writeString(classname);
|
||||
}
|
||||
|
||||
/** reads (and validates) plugin metadata descriptor file */
|
||||
public static PluginInfo readFromProperties(Path dir) throws IOException {
|
||||
Path descriptor = dir.resolve(ES_PLUGIN_PROPERTIES);
|
||||
|
@ -138,28 +150,6 @@ public class PluginInfo implements Streamable, ToXContent {
|
|||
return version;
|
||||
}
|
||||
|
||||
public static PluginInfo readFromStream(StreamInput in) throws IOException {
|
||||
PluginInfo info = new PluginInfo();
|
||||
info.readFrom(in);
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
this.name = in.readString();
|
||||
this.description = in.readString();
|
||||
this.version = in.readString();
|
||||
this.classname = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
out.writeString(name);
|
||||
out.writeString(description);
|
||||
out.writeString(version);
|
||||
out.writeString(classname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject();
|
||||
|
|
Loading…
Reference in New Issue