# ES Plugin add to Node server programmatically

**URL:** <https://discuss.elastic.co/t/es-plugin-add-to-node-server-programmatically/37616>\
**Category:** Elasticsearch\
**Created:** [December 19, 2015, 7:48am UTC](https://discuss.elastic.co/t/es-plugin-add-to-node-server-programmatically/37616 "2015-12-19T07:48:47Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 20, 2015, 9:47am UTC](https://discuss.elastic.co/t/es-plugin-add-to-node-server-programmatically/37616/6 "2015-12-20T09:47:46Z")

</div>

This is because of the collections API of Java where generic types are not reified, they are not available at runtime .

In ES 2.1.1, use something like

```auto
public class MockNode extends Node {

    public MockNode(Settings settings, List<Class<? extends Plugin>> classpathPlugins) {
        super(InternalSettingsPreparer.prepareEnvironment(settings, null), Version.CURRENT, classpathPlugins);
    }

    public MockNode(Settings settings, Class<? extends Plugin> classpathPlugin) {
        this(settings, list(classpathPlugin));
    }
    
    private static List<Class<? extends Plugin>> list(Class<? extends Plugin> classpathPlugin) {
        List<Class<? extends Plugin>> list = new ArrayList<>();
        list.add(classpathPlugin);
        return list;
    }

}

```

---

_[View the full topic](https://discuss.elastic.co/t/es-plugin-add-to-node-server-programmatically/37616)._
