diff --git a/core/src/main/java/org/elasticsearch/plugins/PluginsService.java b/core/src/main/java/org/elasticsearch/plugins/PluginsService.java index 8c765bdd22b..61303bd070a 100644 --- a/core/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/core/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -376,7 +376,7 @@ public class PluginsService extends AbstractComponent { if (pluginInfo.isJvm()) { plugin = loadPlugin(pluginInfo.getClassname(), settings); } else { - plugin = null; + plugin = new SitePlugin(pluginInfo.getName(), pluginInfo.getDescription()); } plugins.add(new Tuple<>(pluginInfo, plugin)); } catch (Throwable e) { diff --git a/core/src/main/java/org/elasticsearch/plugins/SitePlugin.java b/core/src/main/java/org/elasticsearch/plugins/SitePlugin.java new file mode 100644 index 00000000000..3158603b503 --- /dev/null +++ b/core/src/main/java/org/elasticsearch/plugins/SitePlugin.java @@ -0,0 +1,102 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.plugins; + +import org.elasticsearch.common.component.LifecycleComponent; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.settings.Settings; + +import java.io.Closeable; +import java.util.Collection; +import java.util.Collections; + +final class SitePlugin implements Plugin { + final String name; + final String description; + + SitePlugin(String name, String description) { + this.name = name; + this.description = description; + } + + @Override + public String name() { + return name; + } + + @Override + public String description() { + return description; + } + + @Override + public Collection> modules() { + return Collections.emptyList(); + } + + @Override + public Collection modules(Settings settings) { + return Collections.emptyList(); + } + + @Override + public Collection> services() { + return Collections.emptyList(); + } + + @Override + public Collection> indexModules() { + return Collections.emptyList(); + } + + @Override + public Collection indexModules(Settings settings) { + return Collections.emptyList(); + } + + @Override + public Collection> indexServices() { + return Collections.emptyList(); + } + + @Override + public Collection> shardModules() { + return Collections.emptyList(); + } + + @Override + public Collection shardModules(Settings settings) { + return Collections.emptyList(); + } + + @Override + public Collection> shardServices() { + return Collections.emptyList(); + } + + @Override + public void processModule(Module module) { + } + + @Override + public Settings additionalSettings() { + return Settings.EMPTY; + } +} diff --git a/plugins/example-site/pom.xml b/plugins/example-site/pom.xml new file mode 100644 index 00000000000..b4d9f59762c --- /dev/null +++ b/plugins/example-site/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + + org.elasticsearch.plugin + elasticsearch-plugin + 2.0.0-beta1-SNAPSHOT + + + elasticsearch-example-site + Elasticsearch Example site plugin + Demonstrates how to serve resources via elasticsearch. + + + ${project.basedir}/src/main/assemblies/plugin-assembly.xml + true + NA + false + + example + false + true + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + + org.apache.maven.plugins + maven-jar-plugin + + + default-jar + none + + + + + + + diff --git a/plugins/example-site/src/main/assemblies/plugin-assembly.xml b/plugins/example-site/src/main/assemblies/plugin-assembly.xml new file mode 100644 index 00000000000..48a0286bf43 --- /dev/null +++ b/plugins/example-site/src/main/assemblies/plugin-assembly.xml @@ -0,0 +1,23 @@ + + + plugin + + zip + + false + + + + ${project.basedir}/src/site + + + + + + + ${elasticsearch.tools.directory}/plugin-metadata/plugin-descriptor.properties + + true + + + diff --git a/plugins/example-site/src/rest-api-spec/test/example/10_basic.yaml b/plugins/example-site/src/rest-api-spec/test/example/10_basic.yaml new file mode 100644 index 00000000000..91d88f28dd1 --- /dev/null +++ b/plugins/example-site/src/rest-api-spec/test/example/10_basic.yaml @@ -0,0 +1,15 @@ +# Integration tests for Example site plugin +# +"Example site loaded": + - do: + cluster.state: {} + + # Get master node id + - set: { master_node: master } + + - do: + nodes.info: {} + + - match: { nodes.$master.plugins.0.name: example-site } + - match: { nodes.$master.plugins.0.jvm: false } + - match: { nodes.$master.plugins.0.site: true } diff --git a/plugins/example-site/src/site/_site/index.html b/plugins/example-site/src/site/_site/index.html new file mode 100644 index 00000000000..bc6343f6653 --- /dev/null +++ b/plugins/example-site/src/site/_site/index.html @@ -0,0 +1,6 @@ + + + Page title + + Page body + diff --git a/plugins/example-site/src/test/java/org/elasticsearch/example/SiteRestIT.java b/plugins/example-site/src/test/java/org/elasticsearch/example/SiteRestIT.java new file mode 100644 index 00000000000..5e6184670c3 --- /dev/null +++ b/plugins/example-site/src/test/java/org/elasticsearch/example/SiteRestIT.java @@ -0,0 +1,41 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.example; + +import com.carrotsearch.randomizedtesting.annotations.Name; +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import org.elasticsearch.test.rest.ElasticsearchRestTestCase; +import org.elasticsearch.test.rest.RestTestCandidate; +import org.elasticsearch.test.rest.parser.RestTestParseException; + +import java.io.IOException; + +public class SiteRestIT extends ElasticsearchRestTestCase { + + public SiteRestIT(@Name("yaml") RestTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws IOException, RestTestParseException { + return ElasticsearchRestTestCase.createParameters(0, 1); + } +} + diff --git a/plugins/pom.xml b/plugins/pom.xml index ad25cb91d5d..8c0e845841a 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -384,6 +384,7 @@ cloud-gce cloud-azure cloud-aws + example-site lang-python lang-javascript delete-by-query