// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IConnection.java
// public interface IConnection {
// 
// 	public void setConfig(Object object);
// 	
// 	
// 	public void connect() throws Exception;
// 	public void disconnect() throws Exception;
// 	
// 	public void setListener(IConnectionListener listener);
// 	public Object send(Object object) throws Exception;
// 	
// }
// 
// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IConnectionListener.java
// public interface IConnectionListener {
// 
// 	public void receive(Object object) throws Exception;
// }
// 
// Path: AutoSIM-Rest/src/com/automatski/autosim/rest/config/AutoSIMConnectionConfig.java
// public class AutoSIMConnectionConfig {
// 
// 	public String name;
// 	public String url;
// 	public String username;
// 	public String password;
// 	
// 	public String connectorClassName;
// }


import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import com.automatski.autosim.environments.IConnection;
import com.automatski.autosim.environments.IConnectionListener;
import com.automatski.autosim.rest.config.AutoSIMConnectionConfig;
/*
 *  AutoSIM - Internet of Things Simulator
 *  Copyright (C) 2014, Aditya Yadav <aditya@automatski.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.automatski.autosim.rest;



public class SampleRestConnection implements IConnection {

	private AutoSIMConnectionConfig config = null;
	private IConnectionListener listener = null;
	
	@Override
	public void connect() throws Exception {
		//nothing to do
	}

	@Override
	public void disconnect() throws Exception {
		//nothing to do
		
	}

	@Override
	public Object send(Object arg0) throws Exception {
		DefaultHttpClient httpClient = new DefaultHttpClient();
		HttpPost postRequest = new HttpPost(config.url);

		StringEntity input = new StringEntity((String) arg0);
		input.setContentType("application/json");
		postRequest.setEntity(input);

		HttpResponse response = httpClient.execute(postRequest);
		response.getEntity().consumeContent();
		// return nothing. we are as of now not interested in the response
		return null;
	}

	@Override
	public void setConfig(Object arg0) {
		config = (AutoSIMConnectionConfig) arg0;
		
	}

	@Override
// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IConnection.java
// public interface IConnection {
// 
// 	public void setConfig(Object object);
// 	
// 	
// 	public void connect() throws Exception;
// 	public void disconnect() throws Exception;
// 	
// 	public void setListener(IConnectionListener listener);
// 	public Object send(Object object) throws Exception;
// 	
// }
// 
// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IConnectionListener.java
// public interface IConnectionListener {
// 
// 	public void receive(Object object) throws Exception;
// }
// 
// Path: AutoSIM-Rest/src/com/automatski/autosim/rest/config/AutoSIMConnectionConfig.java
// public class AutoSIMConnectionConfig {
// 
// 	public String name;
// 	public String url;
// 	public String username;
// 	public String password;
// 	
// 	public String connectorClassName;
// }


// Path: AutoSIM-Rest/src/com/automatski/autosim/rest/SampleRestConnection.java
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import com.automatski.autosim.environments.IConnection;
import com.automatski.autosim.environments.IConnectionListener;
import com.automatski.autosim.rest.config.AutoSIMConnectionConfig;

/*
 *  AutoSIM - Internet of Things Simulator
 *  Copyright (C) 2014, Aditya Yadav <aditya@automatski.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.automatski.autosim.rest;



public class SampleRestConnection implements IConnection {

	private AutoSIMConnectionConfig config = null;
	private IConnectionListener listener = null;
	
	@Override
	public void connect() throws Exception {
		//nothing to do
	}

	@Override
	public void disconnect() throws Exception {
		//nothing to do
		
	}

	@Override
	public Object send(Object arg0) throws Exception {
		DefaultHttpClient httpClient = new DefaultHttpClient();
		HttpPost postRequest = new HttpPost(config.url);

		StringEntity input = new StringEntity((String) arg0);
		input.setContentType("application/json");
		postRequest.setEntity(input);

		HttpResponse response = httpClient.execute(postRequest);
		response.getEntity().consumeContent();
		// return nothing. we are as of now not interested in the response
		return null;
	}

	@Override
	public void setConfig(Object arg0) {
		config = (AutoSIMConnectionConfig) arg0;
		
	}

	@Override
	public void setListener(IConnectionListener listener) {