package org.bench4q.monitor.file.windows;

import java.io.PrintWriter;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;

import org.bench4q.monitor.model.NetworkInterfaceModel;
import org.bench4q.monitor.service.windows.NetworkInterfaceServiceWindows;
import org.bench4q.monitor.files.Write;

public class WriteNetworkInterfaceWindows extends Write {
	private NetworkInterfaceServiceWindows networkInterfaceServiceWindows;

	public WriteNetworkInterfaceWindows(PrintWriter out, int idleTime) {
		this.out = out;
		this.networkInterfaceServiceWindows = new NetworkInterfaceServiceWindows();
		this.idleTime = idleTime;
	}

	public void run() {
		try {
			JAXBContext context = JAXBContext
					.newInstance(NetworkInterfaceModel.class);
			Marshaller marshaller = context.createMarshaller();
			NetworkInterfaceModel networkInterfaceModel = networkInterfaceServiceWindows
					.getNetworkInterfaceInfo(idleTime);
			marshaller.marshal(networkInterfaceModel, out);
		} catch (Exception e) {
			System.out.println(e);
		}

	}

}
