package io.warp10.plugins.quantum;

import io.warp10.warp.sdk.AbstractWarp10Plugin;

import java.lang.reflect.Method;
import java.util.Properties;

public class QuantumPlugin extends AbstractWarp10Plugin implements Runnable {

  private static final String QUANTUM_MAIN_CLASS = "io.warp10.quantum.Main";
  private static final String CONF_QUANTUM_HOST = "quantum.host";
  private static final String CONF_QUANTUM_PORT = "quantum.port";

  private Properties properties = null;

  @Override
  public void init(Properties properties) {
    String host = properties.getProperty(CONF_QUANTUM_HOST);
    String port = properties.getProperty(CONF_QUANTUM_PORT);

    this.properties = properties;

    Thread t = new Thread(this);
    t.setDaemon(true);
    t.setName("[QuantumPlugin " + host + ":" + port + "]");
    t.start();
  }

  @Override
  public void run() {

    try {
      Class<?> cls = this.getClass().getClassLoader().loadClass(QUANTUM_MAIN_CLASS);
      Object main = cls.newInstance();
      Method meth = cls.getMethod("init", Properties.class);
      meth.invoke(main, this.properties);

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

@@ -1,8 +1,623 @@
+//%0A//   Copyright 2016  Cityzen Data%0A//%0A//   Licensed under the Apache License, Version 2.0 (the %22License%22);%0A//   you may not use this file except in compliance with the License.%0A//   You may obtain a copy of the License at%0A//%0A//     http://www.apache.org/licenses/LICENSE-2.0%0A//%0A//   Unless required by applicable law or agreed to in writing, software%0A//   distributed under the License is distributed on an %22AS IS%22 BASIS,%0A//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A//   See the License for the specific language governing permissions and%0A//   limitations under the License.%0A//%0A%0A
 package 

add Copyright