// 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;

import com.boundary.plugin.sdk.MeasurementSinkFactory.Type;

public class PluginRunner {
	
	private String className;
	private CollectorDispatcher dispatcher;
	
	/**
	 * Default constructor
	 * @param className Class name of the plugin to load
	 */
	public PluginRunner(String className) {
		this.className = className;
		this.dispatcher = new CollectorDispatcher();
	}
	
	/**
	 * Loads the plugin class and calls its run() method.
	 */
	public void run() {
		Plugin plugin = null;
		try {
			plugin = (Plugin) Class.forName(this.className).newInstance();
			plugin.setDispatcher(dispatcher);
			plugin.loadConfiguration();
			plugin.setMeasureOutput(MeasurementSinkFactory.getInstance(Type.STDOUT));
			plugin.run();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * Entry point for running the plugin
	 * @param args Command line arguments
	 */
	public static void main(String[] args) {
		if (args.length != 1) {
			System.exit(1);
		}
		PluginRunner plugin = new PluginRunner(args[0]);
		plugin.run();
	}
}

@@ -992,24 +992,199 @@
 ;%0A%09%7D%0A%09%0A%09/**%0A
+%09 * Outputs usage to standard error%0A%09 */%0A%09private static void Usage() %7B%0A%09%09System.err.printf(%22%7B%7D %3Cclass name%3E%5Cn%22,PluginRunner.class.getTypeName());%0A%09%09System.exit(1);%0A%09%7D%0A%09%0A%09/**%0A
 %09 * Loads th
@@ -1727,16 +1727,28 @@
 != 1) %7B%0A
+%09%09%09Usage();%0A
 %09%09%09Syste

Add Error handling