package de.dbis.acis.cloud.Tethys;

import java.util.ResourceBundle;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import com.wordnik.swagger.config.ConfigFactory;
import com.wordnik.swagger.config.ScannerFactory;
import com.wordnik.swagger.config.SwaggerConfig;
import com.wordnik.swagger.jaxrs.config.DefaultJaxrsScanner;
import com.wordnik.swagger.jaxrs.reader.DefaultJaxrsApiReader;
import com.wordnik.swagger.reader.ClassReaders;

@WebListener
public class SwaggerJaxrsListener implements ServletContextListener {

	ResourceBundle swaggerResourceBundle = ResourceBundle.getBundle("swagger");

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		System.out.println("Swagger starts...");
		SwaggerConfig swaggerConfig = new SwaggerConfig();
		ConfigFactory.setConfig(swaggerConfig);
		swaggerConfig.setBasePath(
				"http://"+swaggerResourceBundle.getString("swaggerWebApplicationHost")
				+":"		+swaggerResourceBundle.getString("swaggerWebApplicationPort")
				+"/"		+swaggerResourceBundle.getString("swaggerWebApplicationName")
		);
		swaggerConfig.setApiVersion("1.0.0");
		ScannerFactory.setScanner(new DefaultJaxrsScanner());
		ClassReaders.setReader(new DefaultJaxrsApiReader());
		System.out.println("Swagger started!");
		System.out.println("");
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {
		System.out.println("Swagger destroyed");
	}

}

@@ -517,16 +517,167 @@
 aders;%0A%0A
+/**%0A * This WebListener configures the Swagger part of this Web Application.%0A * Swagger helps exploring our API easily via a dynamic web frontend.%0A */%0A
 @WebList
@@ -752,16 +752,78 @@
 ener %7B%0A%0A
+%09//Gets the swagger configuration from the swagger.properties%0A
 %09Resourc

Update SwaggerJaxrsListener.java