// Path: apple-boot-core/src/main/java/com/appleframework/boot/core/Attributes.java
// public interface Attributes {
// 	
// 	public void removeAttribute(String name);
// 
// 	public void setAttribute(String name, Object attribute);
// 
// 	public Object getAttribute(String name);
// 
// 	public Enumeration<String> getAttributeNames();
// 
// 	public void clearAttributes();
// }
// 
// Path: apple-boot-core/src/main/java/com/appleframework/boot/utils/ResourceUtils.java
// public class ResourceUtils {
// 		
// 	/** classpath prefix */
// 	public static final String CLASSPATH_URL_PREFIX = "classpath:";	
// 
// 	/**
// 	 * get a ClassLoader
// 	 * @return
// 	 */
// 	public static ClassLoader getClassLoader() {
// 		ClassLoader cl = null;
// 		cl = Thread.currentThread().getContextClassLoader();		
// 		if (cl == null) {
// 			// No thread context class loader, use class loader of this class.
// 			cl = ResourceUtils.class.getClassLoader();
// 		}
// 		return cl;
// 	}
// 	
// 	/**
// 	 * get config file name as URL
// 	 * @param configFileName
// 	 * @return
// 	 * @throws Exception
// 	 */
// 	public static URL getAsUrl(String configFileName){
// 		if (configFileName.startsWith(CLASSPATH_URL_PREFIX)) {
// 			configFileName = configFileName.substring(CLASSPATH_URL_PREFIX.length());
// 		}
// 		URL url = getClassLoader().getResource(configFileName);
// 		if (url == null) {
// 			System.out.println("config file: {} cannot be found! " +  configFileName);			
// 		}
// 		return url;
// 	}
// 	
// 	/**
// 	 * get config file name as File
// 	 * 
// 	 * @param file
// 	 * @return	
// 	 */
// 	public static File getAsFile(String configFileName){
// 		URL url = getAsUrl(configFileName);
// 		if(url != null){
// 			URI uri = toURI(url);		
// 			if(uri != null){
// 				return new File(uri.getSchemeSpecificPart());
// 			}
// 		}
// 		return null;
// 	}
// 
// 	public static URI toURI(URL url) {
// 		try {
// 			return new URI(url.toString().replaceAll(" ", "%20"));
// 		} catch (URISyntaxException e) {
// 			return null;
// 		}
// 	}
// 	
// 	public static InputStream getAsStream(String name){
// 		return getClassLoader().getResourceAsStream(name);
// 	}
// 	
// 	public static boolean isExistResourceBase(String resourceBase) {
//     	String resourcePath = resourceBase.replaceAll("file:", "");
//     	File resouceBasePath = new File(resourcePath);
//     	return resouceBasePath.exists();
//     }
// }


import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.appleframework.boot.core.Attributes;
import com.appleframework.boot.utils.ResourceUtils;

package com.appleframework.boot.jetty.core;




/**
 * @author xusm(2012-11-22)
 *
 */
public class JettyAttribute implements Attributes {

	private static Logger logger = LoggerFactory.getLogger(JettyAttribute.class);

	private static final String PROPERTIES_JETTY       = "jetty.properties";
	private static final String PROPERTIES_SYSTEM      = "system.properties";
	private static final String PROPERTIES_APPLICATION = "application.properties";

	public static final String WEB_CONTEXT = "web.context";
	public static final String WEB_PORT    = "web.port";
	public static final String WEB_WEBAPP  = "web.webapp";
		
	public static final String MIN_THREADS  = "web.min.threads";
	public static final String MAX_THREADS  = "web.max.threads";
	public static final String MAX_QUEUED   = "web.max.queued";
	
	private static Properties prop = new Properties();

	static {
		try {
			load(ResourceUtils.getAsStream(PROPERTIES_JETTY));
		} catch (Exception e) {
			logger.error("error happen when loading jetty.properties file");
		}
		try {
			load(ResourceUtils.getAsStream(PROPERTIES_SYSTEM));
		} catch (Exception e) {
			logger.error("error happen when loading system.properties file");
		}
		try {

// Path: apple-boot-core/src/main/java/com/appleframework/boot/core/Attributes.java
// public interface Attributes {
// 	
// 	public void removeAttribute(String name);
// 
// 	public void setAttribute(String name, Object attribute);
// 
// 	public Object getAttribute(String name);
// 
// 	public Enumeration<String> getAttributeNames();
// 
// 	public void clearAttributes();
// }
// 
// Path: apple-boot-core/src/main/java/com/appleframework/boot/utils/ResourceUtils.java
// public class ResourceUtils {
// 		
// 	/** classpath prefix */
// 	public static final String CLASSPATH_URL_PREFIX = "classpath:";	
// 
// 	/**
// 	 * get a ClassLoader
// 	 * @return
// 	 */
// 	public static ClassLoader getClassLoader() {
// 		ClassLoader cl = null;
// 		cl = Thread.currentThread().getContextClassLoader();		
// 		if (cl == null) {
// 			// No thread context class loader, use class loader of this class.
// 			cl = ResourceUtils.class.getClassLoader();
// 		}
// 		return cl;
// 	}
// 	
// 	/**
// 	 * get config file name as URL
// 	 * @param configFileName
// 	 * @return
// 	 * @throws Exception
// 	 */
// 	public static URL getAsUrl(String configFileName){
// 		if (configFileName.startsWith(CLASSPATH_URL_PREFIX)) {
// 			configFileName = configFileName.substring(CLASSPATH_URL_PREFIX.length());
// 		}
// 		URL url = getClassLoader().getResource(configFileName);
// 		if (url == null) {
// 			System.out.println("config file: {} cannot be found! " +  configFileName);			
// 		}
// 		return url;
// 	}
// 	
// 	/**
// 	 * get config file name as File
// 	 * 
// 	 * @param file
// 	 * @return	
// 	 */
// 	public static File getAsFile(String configFileName){
// 		URL url = getAsUrl(configFileName);
// 		if(url != null){
// 			URI uri = toURI(url);		
// 			if(uri != null){
// 				return new File(uri.getSchemeSpecificPart());
// 			}
// 		}
// 		return null;
// 	}
// 
// 	public static URI toURI(URL url) {
// 		try {
// 			return new URI(url.toString().replaceAll(" ", "%20"));
// 		} catch (URISyntaxException e) {
// 			return null;
// 		}
// 	}
// 	
// 	public static InputStream getAsStream(String name){
// 		return getClassLoader().getResourceAsStream(name);
// 	}
// 	
// 	public static boolean isExistResourceBase(String resourceBase) {
//     	String resourcePath = resourceBase.replaceAll("file:", "");
//     	File resouceBasePath = new File(resourcePath);
//     	return resouceBasePath.exists();
//     }
// }


// Path: apple-boot-jetty8-original/src/main/java/com/appleframework/boot/jetty/core/JettyAttribute.java
import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.appleframework.boot.core.Attributes;
import com.appleframework.boot.utils.ResourceUtils;

package com.appleframework.boot.jetty.core;




/**
 * @author xusm(2012-11-22)
 *
 */
public class JettyAttribute implements Attributes {

	private static Logger logger = LoggerFactory.getLogger(JettyAttribute.class);

	private static final String PROPERTIES_JETTY       = "jetty.properties";
	private static final String PROPERTIES_SYSTEM      = "system.properties";
	private static final String PROPERTIES_APPLICATION = "application.properties";

	public static final String WEB_CONTEXT = "web.context";
	public static final String WEB_PORT    = "web.port";
	public static final String WEB_WEBAPP  = "web.webapp";
		
	public static final String MIN_THREADS  = "web.min.threads";
	public static final String MAX_THREADS  = "web.max.threads";
	public static final String MAX_QUEUED   = "web.max.queued";
	
	private static Properties prop = new Properties();

	static {
		try {
			load(ResourceUtils.getAsStream(PROPERTIES_JETTY));
		} catch (Exception e) {
			logger.error("error happen when loading jetty.properties file");
		}
		try {
			load(ResourceUtils.getAsStream(PROPERTIES_SYSTEM));
		} catch (Exception e) {
			logger.error("error happen when loading system.properties file");
		}
		try {

			load(ResourceUtils.getAsStream(PROPERTIES_APPLICATION));
