// Copyright 2014 Boundary, Inc.
//
// Licensed 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 com.boundary.plugin.sdk.examples;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import com.boundary.plugin.sdk.Plugin;
import com.boundary.plugin.sdk.PluginConfiguration;
import com.boundary.plugin.sdk.PluginDispatcher;
import com.boundary.plugin.sdk.PluginRunner;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class SimplePlugin implements Plugin<SimplePluginConfiguration> {

	SimplePluginConfiguration configuration;
	PluginDispatcher dispatcher;

	@Override
	public void setConfiguration(SimplePluginConfiguration configuration) {
		this.configuration = configuration;
	}
	
	@Override
	public void loadConfiguration() {
		ObjectMapper mapper = new ObjectMapper();
		try {
			SimplePluginConfiguration configuration = mapper.readValue(new File("param.json"), SimplePluginConfiguration.class);
			setConfiguration(configuration);
		} catch (JsonParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JsonMappingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Override
	public void setDispatcher(PluginDispatcher dispatcher) {
		this.dispatcher = dispatcher;
	}

	@Override
	public void run() {
		
		ArrayList<SimplePluginConfigurationItem> items = configuration.getItems();
		for(SimplePluginConfigurationItem i : items) {
			dispatcher.addCollector(new SimpleCollector(i.getName()));
		}

		dispatcher.run();
	}

	public static void main(String[] args) {
		PluginRunner plugin = new PluginRunner(
				"com.boundary.plugin.sdk.examples.SimplePlugin");
		plugin.run();
	}


}

@@ -706,16 +706,62 @@
 yList;%0A%0A
+import com.boundary.plugin.sdk.MeasureOutput;%0A
 import c
@@ -1249,16 +1249,39 @@
 patcher;
+%0A%09MeasureOutput output;
 %0A%0A%09@Over
@@ -2393,82 +2393,153 @@
 ner(
-%0A%09%09%09%09%22com.boundary.plugin.sdk.examples.SimplePlugin%22);%0A%09%09plugin.run();%0A%09%7D%0A%0A
+SimplePlugin.class.getTypeName());%0A%09%09plugin.run();%0A%09%7D%0A%0A%09@Override%0A%09public void setMeasureOutput(MeasureOutput output) %7B%0A%09%09this.output = output;%0A%09%7D
 %0A%7D%0A

Add methods to set MeasureOutput