You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2016/08/01 15:49:59 UTC

[41/51] [partial] incubator-juneau git commit: Merge changes from GitHub repo.

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/ConfigResource.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/ConfigResource.java b/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/ConfigResource.java
deleted file mode 100755
index 5aa0049..0000000
--- a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/ConfigResource.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Licensed Materials - Property of IBM
- * � Copyright IBM Corporation 2014, 2015. All Rights Reserved.
- *
- *  The source code for this program is not published or otherwise
- *  divested of its trade secrets, irrespective of what has been
- *  deposited with the U.S. Copyright Office.
- *******************************************************************************/
-package com.ibm.juno.microservice.resources;
-
-import static com.ibm.juno.core.html.HtmlDocSerializerProperties.*;
-import static javax.servlet.http.HttpServletResponse.*;
-import static com.ibm.juno.server.annotation.VarCategory.*;
-
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Map;
-
-import com.ibm.juno.core.ObjectMap;
-import com.ibm.juno.core.ini.*;
-import com.ibm.juno.microservice.Resource;
-import com.ibm.juno.server.*;
-import com.ibm.juno.server.annotation.*;
-
-/**
- * Shows contents of the microservice configuration file.
- */
-@RestResource(
-	path="/config",
-	label="Configuration",
-	description="Contents of configuration file.",
-	properties={
-		@Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS',edit:'$R{servletURI}/edit'}"),
-	}
-)
-public class ConfigResource extends Resource {
-	private static final long serialVersionUID = 1L;
-
-	/** 
-	 * [GET /] - Show contents of config file.
-	 *  
-	 * @return The config file.  
-	 * @throws Exception 
-	 */
-	@RestMethod(name="GET", path="/", description="Show contents of config file.")
-	public ConfigFile getConfigContents() throws Exception {
-		return getConfig();
-	}
-
-	/** 
-	 * [GET /edit] - Show config file edit page. 
-	 * 
-	 * @param req The HTTP request.
-	 * @return The config file as a reader resource.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="GET", path="/edit", description="Show config file edit page.")
-	public ReaderResource getConfigEditPage(RestRequest req) throws Exception {
-		// Note that we don't want variables in the config file to be resolved,
-		// so we need to escape any $ characters we see.
-		req.setAttribute("contents", getConfig().toString().replaceAll("\\$", "\\\\\\$"));
-		return req.getReaderResource("ConfigEdit.html", true);
-	}
-
-	/** 
-	 * [GET /{section}] - Show config file section.
-	 *  
-	 * @param section The section name. 
-	 * @return The config file section.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="GET", path="/{section}",
-		description="Show config file section.",
-		input={
-			@Var(category=ATTR, name="section", description="Section name.")
-		}
-	)
-	public ObjectMap getConfigSection(@Attr("section") String section) throws Exception {
-		return getSection(section);
-	}
-
-	/** 
-	 * [GET /{section}/{key}] - Show config file entry. 
-	 * 
-	 * @param section The section name. 
-	 * @param key The section key.
-	 * @return The value of the config file entry.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="GET", path="/{section}/{key}",
-		description="Show config file entry.",
-		input={
-			@Var(category=ATTR, name="section", description="Section name."),
-			@Var(category=ATTR, name="key", description="Entry name.")
-		}
-	)
-	public String getConfigEntry(@Attr("section") String section, @Attr("key") String key) throws Exception {
-		return getSection(section).getString(key);
-	}
-
-	/** 
-	 * [POST /] - Sets contents of config file from a FORM post. 
-	 * 
-	 * @param contents The new contents of the config file.
-	 * @return The new config file contents.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="POST", path="/",
-		description="Sets contents of config file from a FORM post.",
-		input={
-			@Var(category=PARAM, name="contents", description="New contents in INI file format.")
-		}
-	)
-	public ConfigFile setConfigContentsFormPost(@Param("contents") String contents) throws Exception {
-		return setConfigContents(new StringReader(contents));
-	}
-
-	/** 
-	 * [PUT /] - Sets contents of config file. 
-	 * 
-	 * @param contents The new contents of the config file. 
-	 * @return The new config file contents.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="PUT", path="/",
-		description="Sets contents of config file.",
-		input={
-			@Var(category=CONTENT, description="New contents in INI file format.")
-		}
-	)
-	public ConfigFile setConfigContents(@Content Reader contents) throws Exception {
-		ConfigFile cf2 = ConfigMgr.DEFAULT.create().load(contents);
-		return getConfig().merge(cf2).save();
-	}
-
-	/** 
-	 * [PUT /{section}] - Add or overwrite a config file section. 
-	 * 
-	 * @param section The section name. 
-	 * @param contents The new contents of the config file section.
-	 * @return The new section.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="PUT", path="/{section}",
-		description="Add or overwrite a config file section.",
-		input={
-			@Var(category=ATTR, name="section", description="Section name."),
-			@Var(category=CONTENT, description="New contents for section as a simple map with string keys and values.")
-		}
-	)
-	public ObjectMap setConfigSection(@Attr("section") String section, @Content Map<String,String> contents) throws Exception {
-		getConfig().setSection(section, contents);
-		return getSection(section);
-	}
-
-	/** 
-	 * [PUT /{section}/{key}] - Add or overwrite a config file entry. 
-	 * 
-	 * @param section The section name. 
-	 * @param key The section key.
-	 * @param value The new value.
-	 * @return The new value.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="PUT", path="/{section}/{key}",
-		description="Add or overwrite a config file entry.",
-		input={
-			@Var(category=ATTR, name="section", description="Section name."),
-			@Var(category=ATTR, name="key", description="Entry name."),
-			@Var(category=CONTENT, description="New value as a string.")
-		}
-	)
-	public String setConfigSection(@Attr("section") String section, @Attr("key") String key, @Content String value) throws Exception {
-		getConfig().put(section, key, value, false);
-		return getSection(section).getString(key);
-	}
-
-	private ObjectMap getSection(String name) {
-		ObjectMap m = getConfig().getSectionMap(name);
-		if (m == null)
-			throw new RestException(SC_NOT_FOUND, "Section not found.");
-		return m;
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/DirectoryResource.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/DirectoryResource.java b/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/DirectoryResource.java
deleted file mode 100755
index 961827d..0000000
--- a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/DirectoryResource.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*******************************************************************************
- * Licensed Materials - Property of IBM
- * � Copyright IBM Corporation 2015. All Rights Reserved.
- *
- *  The source code for this program is not published or otherwise
- *  divested of its trade secrets, irrespective of what has been
- *  deposited with the U.S. Copyright Office.
- *******************************************************************************/
-package com.ibm.juno.microservice.resources;
-
-import static com.ibm.juno.core.html.HtmlDocSerializerProperties.*;
-import static com.ibm.juno.core.html.HtmlSerializerProperties.*;
-import static com.ibm.juno.server.RestServletProperties.*;
-import static java.util.logging.Level.*;
-import static javax.servlet.http.HttpServletResponse.*;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import java.util.logging.*;
-
-import javax.servlet.*;
-
-import com.ibm.juno.core.*;
-import com.ibm.juno.core.annotation.BeanProperty;
-import com.ibm.juno.core.filters.DateFilter;
-import com.ibm.juno.core.utils.*;
-import com.ibm.juno.microservice.*;
-import com.ibm.juno.server.*;
-import com.ibm.juno.server.annotation.*;
-import com.ibm.juno.server.converters.*;
-
-/**
- * REST resource that allows access to a file system directory.
- * <p>
- * 	The root directory is specified in one of two ways:
- * </p>
- * <ul>
- * 	<li>Specifying the location via a <l>DirectoryResource.rootDir</l> property.
- * 	<li>Overriding the {@link #getRootDir()} method.
- * </ul>
- * <p>
- * 	Read/write access control is handled through the following properties:
- * </p>
- * <ul>
- * 	<li><l>DirectoryResource.allowViews</l> - If <jk>true</jk>, allows view and download access to files.
- * 	<li><l>DirectoryResource.allowPuts</l> - If <jk>true</jk>, allows files to be created or overwritten.
- * 	<li><l>DirectoryResource.allowDeletes</l> - If <jk>true</jk>, allows files to be deleted.
- * </ul>
- * <p>
- * 	Access can also be controlled by overriding the {@link #checkAccess(RestRequest)} method.
- * </p>
- */
-@RestResource(
-	label="File System Explorer",
-	description="Contents of $A{path}",
-	messages="nls/DirectoryResource",
-	properties={
-		@Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
-		@Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'?method=OPTIONS',source:'$R{servletParentURI}/source?classes=(com.ibm.juno.server.samples.DirectoryResource)'}"),
-		@Property(name=REST_allowMethodParam, value="*"),
-		@Property(name="DirectoryResource.rootDir", value=""),
-		@Property(name="DirectoryResource.allowViews", value="false"),
-		@Property(name="DirectoryResource.allowDeletes", value="false"),
-		@Property(name="DirectoryResource.allowPuts", value="false")
-	}
-)
-public class DirectoryResource extends Resource {
-	private static final long serialVersionUID = 1L;
-
-	private File rootDir;     // The root directory
-
-	// Settings enabled through servlet init parameters
-	private boolean allowDeletes, allowPuts, allowViews;
-
-	private static Logger logger = Logger.getLogger(DirectoryResource.class.getName());
-
-	@Override /* Servlet */
-	public void init() throws ServletException {
-		ObjectMap p = getProperties();
-		rootDir = new File(p.getString("DirectoryResource.rootDir"));
-		allowViews = p.getBoolean("DirectoryResource.allowViews", false);
-		allowDeletes = p.getBoolean("DirectoryResource.allowDeletes", false);
-		allowPuts = p.getBoolean("DirectoryResource.allowPuts", false);
-	}
-
-	/** 
-	 * Returns the root directory defined by the 'rootDir' init parameter.
-	 * Subclasses can override this method to provide their own root directory. 
-	 * @return The root directory. 
-	 */
-	protected File getRootDir() {
-		if (rootDir == null) {
-			rootDir = new File(getProperties().getString("rootDir"));
-			if (! rootDir.exists())
-				if (! rootDir.mkdirs())
-					throw new RuntimeException("Could not create root dir");
-		}
-		return rootDir;
-	}
-
-	/** 
-	 * [GET /*]
-	 *  On directories, returns a directory listing.
-	 *  On files, returns information about the file.
-	 *  
-	 * @param req - The HTTP request.
-	 * @return Either a FileResource or list of FileResources depending on whether it's a 
-	 * 	file or directory.
-	 * @throws Exception - If file could not be read or access was not granted.
-	 */
-	@RestMethod(name="GET", path="/*", 
-		description="On directories, returns a directory listing.\nOn files, returns information about the file.",
-		converters={Queryable.class}
-	)
-	public Object doGet(RestRequest req) throws Exception {
-		checkAccess(req);
-
-		String pathInfo = req.getPathInfo();
-		File f = pathInfo == null ? rootDir : new File(rootDir.getAbsolutePath() + pathInfo);
-
-		if (!f.exists())
-			throw new RestException(SC_NOT_FOUND, "File not found");
-
-		req.setAttribute("path", f.getAbsolutePath());
-
-		if (f.isDirectory()) {
-			List<FileResource> l = new LinkedList<FileResource>();
-			for (File fc : f.listFiles()) {
-				URL fUrl = new URL(req.getRequestURL().append("/").append(fc.getName()).toString());
-				l.add(new FileResource(fc, fUrl));
-			}
-			return l;
-		}
-
-		return new FileResource(f, new URL(req.getRequestURL().toString()));
-	}
-
-	/** 
-	 * [DELETE /*]
-	 *  Delete a file on the file system.
-	 *  
-	 * @param req - The HTTP request.
-	 * @return The message <js>"File deleted"</js> if successful.
-	 * @throws Exception - If file could not be read or access was not granted.
-	 */
-	@RestMethod(name="DELETE", path="/*",
-		description="Delete a file on the file system."
-	)
-	public Object doDelete(RestRequest req) throws Exception {
-		checkAccess(req);
-
-		File f = new File(rootDir.getAbsolutePath() + req.getPathInfo());
-		deleteFile(f);
-
-		if (req.getHeader("Accept").contains("text/html"))
-			return new Redirect();
-		return "File deleted";
-	}
-
-	/** 
-	 * [PUT /*]
-	 * Add or overwrite a file on the file system.
-	 *  
-	 * @param req - The HTTP request.
-	 * @return The message <js>"File added"</js> if successful.
-	 * @throws Exception - If file could not be read or access was not granted.
-	 */
-	@RestMethod(name="PUT", path="/*", 
-		description="Add or overwrite a file on the file system."
-	)
-	public Object doPut(RestRequest req) throws Exception {
-		checkAccess(req);
-
-		File f = new File(rootDir.getAbsolutePath() + req.getPathInfo());
-		String parentSubPath = f.getParentFile().getAbsolutePath().substring(rootDir.getAbsolutePath().length());
-		BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(f));
-		IOPipe.create(req.getInputStream(), bos).closeOut().run();
-		if (req.getContentType().contains("html"))
-			return new Redirect(parentSubPath);
-		return "File added";
-	}
-
-	/** 
-	 * [VIEW /*]
-	 * 	View the contents of a file.
-	 * 	Applies to files only.
-	 *  
-	 * @param req - The HTTP request.
-	 * @param res - The HTTP response.
-	 * @return A Reader containing the contents of the file.
-	 * @throws Exception - If file could not be read or access was not granted.
-	 */
-	@RestMethod(name="VIEW", path="/*",
-		description="View the contents of a file.\nApplies to files only."
-	)
-	public Reader doView(RestRequest req, RestResponse res) throws Exception {
-		checkAccess(req);
-
-		File f = new File(rootDir.getAbsolutePath() + req.getPathInfo());
-
-		if (!f.exists())
-			throw new RestException(SC_NOT_FOUND, "File not found");
-
-		if (f.isDirectory())
-			throw new RestException(SC_METHOD_NOT_ALLOWED, "VIEW not available on directories");
-
-		res.setContentType("text/plain");
-		return new FileReader(f);
-	}
-	
-	/** 
-	 * [DOWNLOAD /*]
-	 * 	Download the contents of a file.
-	 * 	Applies to files only.
-	 *  
-	 * @param req - The HTTP request.
-	 * @param res - The HTTP response.
-	 * @return A Reader containing the contents of the file.
-	 * @throws Exception - If file could not be read or access was not granted.
-	 */
-	@RestMethod(name="DOWNLOAD", path="/*",
-		description="Download the contents of a file.\nApplies to files only."
-	)
-	public Reader doDownload(RestRequest req, RestResponse res) throws Exception {
-		checkAccess(req);
-
-		File f = new File(rootDir.getAbsolutePath() + req.getPathInfo());
-
-		if (!f.exists())
-			throw new RestException(SC_NOT_FOUND, "File not found");
-
-		if (f.isDirectory())
-			throw new RestException(SC_METHOD_NOT_ALLOWED, "DOWNLOAD not available on directories");
-
-		res.setContentType("application");
-		return new FileReader(f);
-	}
-	
-	/**
-	 * Verify that the specified request is allowed.
-	 * Subclasses can override this method to provide customized behavior.
-	 * Method should throw a {@link RestException} if the request should be disallowed.
-	 * 
-	 * @param req The HTTP request.
-	 */
-	protected void checkAccess(RestRequest req) {
-		String method = req.getMethod();
-		if (method.equals("VIEW") && ! allowViews)
-			throw new RestException(SC_METHOD_NOT_ALLOWED, "VIEW not enabled");
-		if (method.equals("PUT") && ! allowPuts)
-			throw new RestException(SC_METHOD_NOT_ALLOWED, "PUT not enabled");
-		if (method.equals("DELETE") && ! allowDeletes)
-			throw new RestException(SC_METHOD_NOT_ALLOWED, "DELETE not enabled");
-		if (method.equals("DOWNLOAD") && ! allowViews)
-			throw new RestException(SC_METHOD_NOT_ALLOWED, "DOWNLOAD not enabled");
-	}
-
-	/** File POJO */
-	public class FileResource {
-		private File f;
-		private URL url;
-
-		/** 
-		 * Constructor.
-		 * @param f - The file.
-		 * @param url - The URL of the file resource. 
-		 */
-		public FileResource(File f, URL url) {
-			this.f = f;
-			this.url = url;
-		}
-
-		// Bean property getters
-
-		/**
-		 * @return The URL of the file resource.
-		 */
-		public URL getUrl() {
-			return url;
-		}
-
-		/**
-		 * @return The file type.
-		 */
-		public String getType() {
-			return (f.isDirectory() ? "dir" : "file");
-		}
-
-		/**
-		 * @return The file name.
-		 */
-		public String getName() {
-			return f.getName();
-		}
-
-		/**
-		 * @return The file size.
-		 */
-		public long getSize() {
-			return f.length();
-		}
-
-		/**
-		 * @return The file last modified timestamp.
-		 */
-		@BeanProperty(filter=DateFilter.ISO8601DTP.class)
-		public Date getLastModified() {
-			return new Date(f.lastModified());
-		}
-
-		/**
-		 * @return A hyperlink to view the contents of the file.
-		 * @throws Exception If access is not allowed.
-		 */
-		public URL getView() throws Exception {
-			if (allowViews && f.canRead() && ! f.isDirectory())
-				return new URL(url + "?method=VIEW");
-			return null;
-		}
-
-		/**
-		 * @return A hyperlink to download the contents of the file.
-		 * @throws Exception If access is not allowed.
-		 */
-		public URL getDownload() throws Exception {
-			if (allowViews && f.canRead() && ! f.isDirectory())
-				return new URL(url + "?method=DOWNLOAD");
-			return null;
-		}
-
-		/**
-		 * @return A hyperlink to delete the file.
-		 * @throws Exception If access is not allowed.
-		 */
-		public URL getDelete() throws Exception {
-			if (allowDeletes && f.canWrite())
-				return new URL(url + "?method=DELETE");
-			return null;
-		}
-	}
-
-	/** Utility method */
-	private void deleteFile(File f) {
-		try {
-			if (f.isDirectory())
-				for (File fc : f.listFiles())
-					deleteFile(fc);
-			f.delete();
-		} catch (Exception e) {
-			logger.log(WARNING, "Cannot delete file '" + f.getAbsolutePath() + "'", e);
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogEntryFormatter.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogEntryFormatter.java b/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogEntryFormatter.java
deleted file mode 100755
index dc612ad..0000000
--- a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogEntryFormatter.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Licensed Materials - Property of IBM
- * � Copyright IBM Corporation 2015. All Rights Reserved.
- *
- * The source code for this program is not published or otherwise
- * divested of its trade secrets, irrespective of what has been
- * deposited with the U.S. Copyright Office.
- *******************************************************************************/
-package com.ibm.juno.microservice.resources;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Formatter;
-import java.util.logging.LogRecord;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import com.ibm.juno.core.utils.StringUtils;
-
-/**
- * Log entry formatter.
- * <p>
- * 	Uses three simple parameter for configuring log entry formats:
- * 	<ul>
- * 		<li><code>dateFormat</code> - A {@link SimpleDateFormat} string describing the format for dates.
- * 		<li><code>format</code> - A string with <code>{...}</code> replacement variables representing predefined fields.
- * 		<li><code>useStackTraceHashes</code> - A setting that causes duplicate stack traces to be replaced with 8-character hash strings.
- * 	</ul>
- * <p>
- * 	This class converts the format strings into a regular expression that can be used to parse the resulting log file.
- *
- * @author jbognar
- */
-public class LogEntryFormatter extends Formatter {
-
-	private ConcurrentHashMap<String,AtomicInteger> hashes;
-	private DateFormat df;
-	private String format;
-	private Pattern rePattern;
-	private Map<String,Integer> fieldIndexes;
-
-	/**
-	 * Create a new formatter.
-	 * 
-	 * @param format The log entry format.  e.g. <js>"[{date} {level}] {msg}%n"</js>
-	 * 	The string can contain any of the following variables:
-	 * 		<ol>
-	 * 			<li><js>"{date}"</js> - The date, formatted per <js>"Logging/dateFormat"</js>.
-	 * 			<li><js>"{class}"</js> - The class name.
-	 * 			<li><js>"{method}"</js> - The method name.
-	 * 			<li><js>"{logger}"</js> - The logger name.
-	 * 			<li><js>"{level}"</js> - The log level name.
-	 * 			<li><js>"{msg}"</js> - The log message.
-	 * 			<li><js>"{threadid}"</js> - The thread ID.
-	 * 			<li><js>"{exception}"</js> - The localized exception message.
-	 *		</ol>
-	 * @param dateFormat The {@link SimpleDateFormat} format to use for dates.  e.g. <js>"yyyy.MM.dd hh:mm:ss"</js>.
-	 * @param useStackTraceHashes If <jk>true</jk>, only print unique stack traces once and then refer to them by a
-	 * 	simple 8 character hash identifier.
-	 */
-	public LogEntryFormatter(String format, String dateFormat, boolean useStackTraceHashes) {
-		this.df = new SimpleDateFormat(dateFormat);
-		if (useStackTraceHashes)
-			hashes = new ConcurrentHashMap<String,AtomicInteger>();
-
-		fieldIndexes = new HashMap<String,Integer>();
-
-		format = format
-			.replaceAll("\\{date\\}", "%1\\$s")
-			.replaceAll("\\{class\\}", "%2\\$s")
-			.replaceAll("\\{method\\}", "%3\\$s")
-			.replaceAll("\\{logger\\}", "%4\\$s")
-			.replaceAll("\\{level\\}", "%5\\$s")
-			.replaceAll("\\{msg\\}", "%6\\$s")
-			.replaceAll("\\{threadid\\}", "%7\\$s")
-			.replaceAll("\\{exception\\}", "%8\\$s");
-
-		this.format = format;
-
-		// Construct a regular expression to match this log entry.
-		int index = 1;
-		StringBuilder re = new StringBuilder();
-		int S1 = 1; // Looking for %
-		int S2 = 2; // Found %, looking for number.
-		int S3 = 3; // Found number, looking for $.
-		int S4 = 4; // Found $, looking for s.
-		int state = 1;
-		int i1 = 0;
-		for (int i = 0; i < format.length(); i++) {
-			char c = format.charAt(i);
-			if (state == S1) {
-				if (c == '%')
-					state = S2;
-				else {
-					if (! (Character.isLetterOrDigit(c) || Character.isWhitespace(c)))
-						re.append('\\');
-					re.append(c);
-				}
-			} else if (state == S2) {
-				if (Character.isDigit(c)) {
-					i1 = i;
-					state = S3;
-				} else {
-					re.append("\\%").append(c);
-					state = S1;
-				}
-			} else if (state == S3) {
-				if (c == '$') {
-					state = S4;
-				} else {
-					re.append("\\%").append(format.substring(i1, i));
-					state = S1;
-				}
-			} else if (state == S4) {
-				if (c == 's') {
-					int group = Integer.parseInt(format.substring(i1, i-1));
-					switch (group) {
-						case 1:
-							fieldIndexes.put("date", index++);
-							re.append("(" + dateFormat.replaceAll("[mHhsSdMy]", "\\\\d").replaceAll("\\.", "\\\\.") + ")");
-							break;
-						case 2:
-							fieldIndexes.put("class", index++);
-							re.append("([\\p{javaJavaIdentifierPart}\\.]+)");
-							break;
-						case 3:
-							fieldIndexes.put("method", index++);
-							re.append("([\\p{javaJavaIdentifierPart}\\.]+)");
-							break;
-						case 4:
-							fieldIndexes.put("logger", index++);
-							re.append("([\\w\\d\\.\\_]+)");
-							break;
-						case 5:
-							fieldIndexes.put("level", index++);
-							re.append("(SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST)");
-							break;
-						case 6:
-							fieldIndexes.put("msg", index++);
-							re.append("(.*)");
-							break;
-						case 7:
-							fieldIndexes.put("threadid", index++);
-							re.append("(\\\\d+)");
-							break;
-						case 8:
-							fieldIndexes.put("exception", index++);
-							re.append("(.*)");
-							break;
-					}
-				} else {
-					re.append("\\%").append(format.substring(i1, i));
-				}
-				state = S1;
-			}
-		}
-
-		// The log parser
-		String sre = re.toString();
-		if (sre.endsWith("\\%n"))
-			sre = sre.substring(0, sre.length()-3);
-
-		// Replace instances of %n.
-		sre = sre.replaceAll("\\\\%n", "\\\\n");
-
-		rePattern = Pattern.compile(sre);
-		fieldIndexes = Collections.unmodifiableMap(fieldIndexes);
-	}
-
-	/**
-	 * Returns the regular expression pattern used for matching log entries.
-	 * 
-	 * @return The regular expression pattern used for matching log entries.
-	 */
-	public Pattern getLogEntryPattern() {
-		return rePattern;
-	}
-
-	/**
-	 * Returns the {@link DateFormat} used for matching dates.
-	 * 
-	 * @return The {@link DateFormat} used for matching dates.
-	 */
-	public DateFormat getDateFormat() {
-		return df;
-	}
-
-	/**
-	 * Given a matcher that has matched the pattern specified by {@link #getLogEntryPattern()},
-	 * returns the field value from the match.
-	 * 
-	 * @param fieldName The field name.  Possible values are:
-	 * 	<ul>
-	 * 		<li><js>"date"</js>
-	 * 		<li><js>"class"</js>
-	 * 		<li><js>"method"</js>
-	 * 		<li><js>"logger"</js>
-	 * 		<li><js>"level"</js>
-	 * 		<li><js>"msg"</js>
-	 * 		<li><js>"threadid"</js>
-	 * 		<li><js>"exception"</js>
-	 *	</ul>
-	 * @param m The matcher. 
-	 * @return The field value, or <jk>null</jk> if the specified field does not exist.
-	 */
-	public String getField(String fieldName, Matcher m) {
-		Integer i = fieldIndexes.get(fieldName);
-		return (i == null ? null : m.group(i));
-	}
-
-	@Override /* Formatter */
-	public String format(LogRecord r) {
-		String msg = formatMessage(r);
-		Throwable t = r.getThrown();
-		String hash = null;
-		int c = 0;
-		if (hashes != null && t != null) {
-			hash = hashCode(t);
-			hashes.putIfAbsent(hash, new AtomicInteger(0));
-			c = hashes.get(hash).incrementAndGet();
-			if (c == 1) {
-				msg = '[' + hash + '.' + c + "] " + msg;
-			} else {
-				msg = '[' + hash + '.' + c + "] " + msg + ", " + t.getLocalizedMessage();
-				t = null;
-			}
-		}
-		String s = String.format(format,
-			df.format(new Date(r.getMillis())),
-			r.getSourceClassName(),
-			r.getSourceMethodName(),
-			r.getLoggerName(),
-			r.getLevel(),
-			msg,
-			r.getThreadID(),
-			r.getThrown() == null ? "" : r.getThrown().getMessage());
-		if (t != null)
-			s += String.format("%n%s", StringUtils.getStackTrace(r.getThrown()));
-		return s;
-	}
-
-	private String hashCode(Throwable t) {
-		int i = 0;
-		while (t != null) {
-			for (StackTraceElement e : t.getStackTrace())
-				i ^= e.hashCode();
-			t = t.getCause();
-		}
-		return Integer.toHexString(i);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogParser.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogParser.java b/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogParser.java
deleted file mode 100755
index f5b969b..0000000
--- a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogParser.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Licensed Materials - Property of IBM
- * � Copyright IBM Corporation 2014, 2015. All Rights Reserved.
- *
- * Note to U.S. Government Users Restricted Rights:
- * Use, duplication or disclosure restricted by GSA ADP Schedule
- * Contract with IBM Corp.
- *******************************************************************************/
-package com.ibm.juno.microservice.resources;
-
-import java.io.*;
-import java.nio.charset.*;
-import java.text.*;
-import java.util.*;
-import java.util.regex.*;
-
-
-/**
- * Utility class for reading log files.
- * <p>
- * Provides the capability of returning splices of log files based on dates and filtering based
- * on thread and logger names.
- */
-public class LogParser implements Iterable<LogParser.Entry>, Iterator<LogParser.Entry> {
-	private BufferedReader br;
-	private LogEntryFormatter formatter;
-	private Date start, end;
-	private Set<String> loggerFilter, severityFilter;
-	private String threadFilter;
-	private Entry next;
-
-	/**
-	 * Constructor.
-	 * 
-	 * @param formatter The log entry formatter. 
-	 * @param f The log file.
-	 * @param start Don't return rows before this date.  If <jk>null</jk>, start from the beginning of the file.
-	 * @param end Don't return rows after this date.  If <jk>null</jk>, go to the end of the file.
-	 * @param thread Only return log entries with this thread name.
-	 * @param loggers Only return log entries produced by these loggers (simple class names).
-	 * @param severity Only return log entries with the specified severity.
-	 * @throws IOException
-	 */
-	public LogParser(LogEntryFormatter formatter, File f, Date start, Date end, String thread, String[] loggers, String[] severity) throws IOException {
-		br = new BufferedReader(new InputStreamReader(new FileInputStream(f), Charset.defaultCharset()));
-		this.formatter = formatter;
-		this.start = start;
-		this.end = end;
-		this.threadFilter = thread;
-		if (loggers != null)
-			this.loggerFilter = new HashSet<String>(Arrays.asList(loggers));
-		if (severity != null)
-			this.severityFilter = new HashSet<String>(Arrays.asList(severity));
-
-		// Find the first line.
-		String line;
-		while (next == null && (line = br.readLine()) != null) {
-			Entry e = new Entry(line);
-			if (e.matches())
-				next = e;
-		}
-	}
-
-	@Override /* Iterator */
-	public boolean hasNext() {
-		return next != null;
-	}
-
-	@Override /* Iterator */
-	public Entry next() {
-		Entry current = next;
-		Entry prev = next;
-		try {
-			next = null;
-			String line = null;
-			while (next == null && (line = br.readLine()) != null) {
-				Entry e = new Entry(line);
-				if (e.isRecord) {
-					if (e.matches())
-						next = e;
-					prev = null;
- 				} else {
-					if (prev != null)
-						prev.addText(e.line);
-				}
-			}
-		} catch (IOException e) {
-			throw new RuntimeException(e);
-		}
-		return current;
-	}
-
-	@Override /* Iterator */
-	public void remove() {
-		throw new NoSuchMethodError();
-	}
-
-	@Override /* Iterable */
-	public Iterator<Entry> iterator() {
-		return this;
-	}
-
-	/**
-	 * Closes the underlying reader.
-	 * 
-	 * @throws IOException 
-	 */
-	public void close() throws IOException {
-		br.close();
-	}
-
-	/**
-	 * Serializes the contents of the parsed log file to the specified writer
-	 * and then closes the underlying reader.
-	 * 
-	 * @param w The writer to write the log file to. 
-	 * @throws IOException 
-	 */
-	public void writeTo(Writer w) throws IOException {
-		try {
-			if (! hasNext())
-				w.append("[EMPTY]"); //$NON-NLS-1$
-			else for (LogParser.Entry le : this)
-				le.append(w);
-		} finally {
-			close();
-		}
-	}
-
-	/**
-	 * Represents a single line from the log file.
-	 */
-	@SuppressWarnings("javadoc")
-	public class Entry {
-		public Date date;
-		public String severity, logger;
-		protected String line, text;
-		protected String thread;
-		protected List<String> additionalText;
-		protected boolean isRecord;
-
-		Entry(String line) throws IOException {
-			try {
-				this.line = line;
-				Matcher m = formatter.getLogEntryPattern().matcher(line);
-				if (m.matches()) {
-					isRecord = true;
-					String s = formatter.getField("date", m);
-					if (s != null)
-						date = formatter.getDateFormat().parse(s);
-					thread = formatter.getField("thread", m);
-					severity = formatter.getField("level", m);
-					logger = formatter.getField("logger", m);
-					text = formatter.getField("msg", m);
-					if (logger != null && logger.indexOf('.') > -1)
-						logger = logger.substring(logger.lastIndexOf('.')+1);
-				}
-			} catch (ParseException e) {
-				throw new IOException(e);
-			}
-		}
-
-		private void addText(String t) {
-			if (additionalText == null)
-				additionalText = new LinkedList<String>();
-			additionalText.add(t);
-		}
-
-		public String getText() {
-			if (additionalText == null)
-				return text;
-			int i = text.length();
-			for (String s : additionalText)
-				i += s.length() + 1;
-			StringBuilder sb = new StringBuilder(i);
-			sb.append(text);
-			for (String s : additionalText)
-				sb.append('\n').append(s);
-			return sb.toString();
-		}
-
-		public String getThread() {
-			return thread;
-		}
-
-		public Writer appendHtml(Writer w) throws IOException {
-			w.append(toHtml(line)).append("<br>"); //$NON-NLS-1$
-			if (additionalText != null)
-				for (String t : additionalText)
-					w.append(toHtml(t)).append("<br>"); //$NON-NLS-1$
-			return w;
-		}
-
-		protected Writer append(Writer w) throws IOException {
-			w.append(line).append('\n');
-			if (additionalText != null)
-				for (String t : additionalText)
-					w.append(t).append('\n');
-			return w;
-		}
-
-		private boolean matches() {
-			if (! isRecord)
-				return false;
-			if (start != null && date.before(start))
-				return false;
-			if (end != null && date.after(end))
-				return false;
-			if (threadFilter != null && ! threadFilter.equals(thread))
-				return false;
-			if (loggerFilter != null && ! loggerFilter.contains(logger))
-				return false;
-			if (severityFilter != null && ! severityFilter.contains(severity))
-				return false;
-			return true;
-		}
-	}
-
-	private String toHtml(String s) {
-		if (s.indexOf('<') != -1)
-			return s.replaceAll("<", "&lt;");  //$NON-NLS-1$//$NON-NLS-2$
-		return s;
-	}
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogsResource.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogsResource.java b/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogsResource.java
deleted file mode 100755
index 8c1a252..0000000
--- a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/LogsResource.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*******************************************************************************
- * Licensed Materials - Property of IBM
- * � Copyright IBM Corporation 2015. All Rights Reserved.
- *
- *  The source code for this program is not published or otherwise
- *  divested of its trade secrets, irrespective of what has been
- *  deposited with the U.S. Copyright Office.
- *******************************************************************************/
-package com.ibm.juno.microservice.resources;
-
-import static com.ibm.juno.core.html.HtmlDocSerializerProperties.*;
-import static com.ibm.juno.core.html.HtmlSerializerProperties.*;
-import static com.ibm.juno.server.RestServletProperties.*;
-import static javax.servlet.http.HttpServletResponse.*;
-
-import java.io.*;
-import java.net.*;
-import java.nio.charset.*;
-import java.util.*;
-
-import com.ibm.juno.core.*;
-import com.ibm.juno.core.annotation.*;
-import com.ibm.juno.core.dto.*;
-import com.ibm.juno.core.filters.*;
-import com.ibm.juno.core.ini.ConfigFile;
-import com.ibm.juno.core.utils.StringUtils;
-import com.ibm.juno.microservice.Resource;
-import com.ibm.juno.server.*;
-import com.ibm.juno.server.annotation.*;
-import com.ibm.juno.server.annotation.Properties;
-import com.ibm.juno.server.converters.Queryable;
-
-/**
- * REST resource for viewing and accessing log files.
- */
-@RestResource(
-	path="/logs",
-	label="Log files",
-	description="Log files from this service",
-	properties={
-		@Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
-		@Property(name=REST_allowMethodParam, value="true")
-	},
-	filters={
-		IteratorFilter.class,       // Allows Iterators and Iterables to be serialized.
-		DateFilter.ISO8601DT.class  // Serialize Date objects as ISO8601 strings.
-	}
-)
-@SuppressWarnings("nls")
-public class LogsResource extends Resource {
-	private static final long serialVersionUID = 1L;
-
-	private ConfigFile cf = getConfig();
-
-	private File logDir = new File(cf.getString("Logging/logDir", "."));
-	private LogEntryFormatter leFormatter = new LogEntryFormatter(
-		cf.getString("Logging/format", "[{date} {level}] {msg}%n"),
-		cf.getString("Logging/dateFormat", "yyyy.MM.dd hh:mm:ss"),
-		cf.getBoolean("Logging/useStackTraceHashes")
-	);
-
-	private final FileFilter filter = new FileFilter() {
-		@Override /* FileFilter */
-		public boolean accept(File f) {
-			return f.isDirectory() || f.getName().endsWith(".log");
-		}
-	};
-
-	/** 
-	 * [GET /*] - Get file details or directory listing. 
-	 * 
-	 * @param req The HTTP request
-	 * @param properties The writable properties for setting the descriptions.
-	 * @param path The log file path.
-	 * @return The log file.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="GET", path="/*", rc={200,404})
-	public Object getFileOrDirectory(RestRequest req, @Properties ObjectMap properties, @PathRemainder String path) throws Exception {
-
-		File f = getFile(path);
-
-		if (f.isDirectory()) {
-			Set<FileResource> l = new TreeSet<FileResource>(new FileResourceComparator());
-			for (File fc : f.listFiles(filter)) {
-				URL fUrl = new URL(req.getTrimmedRequestURL().append('/').append(fc.getName()).toString());
-				l.add(new FileResource(fc, fUrl));
-			}
-			properties.put(HTMLDOC_description, "Contents of " + f.getAbsolutePath());
-			return l;
-		}
-
-		properties.put(HTMLDOC_description, "File details on " + f.getAbsolutePath());
-		return new FileResource(f, new URL(req.getTrimmedRequestURL().toString()));
-	}
-
-	/**
-	 * [VIEW /*] - Retrieve the contents of a log file.
-	 * 
-	 * @param req The HTTP request.
-	 * @param res The HTTP response.
-	 * @param path The log file path.
-	 * @param properties The writable properties for setting the descriptions.
-	 * @param highlight If <code>true</code>, add color highlighting based on severity.
-	 * @param start Optional start timestamp.  Don't print lines logged before the specified timestamp.  Example:  "&start=2014-01-23 11:25:47".
-	 * @param end Optional end timestamp.  Don't print lines logged after the specified timestamp.  Example:  "&end=2014-01-23 11:25:47".
-	 * @param thread Optional thread name filter.  Only show log entries with the specified thread name.  Example: "&thread=pool-33-thread-1".
-	 * @param loggers Optional logger filter.  Only show log entries if they were produced by one of the specified loggers (simple class name).  Example: "&loggers=(LinkIndexService,LinkIndexRestService)".
-	 * @param severity Optional severity filter.  Only show log entries with the specified severity.  Example: "&severity=(ERROR,WARN)".
-	 * @throws Exception 
-	 */
-	@RestMethod(name="VIEW", path="/*", rc={200,404})
-	@SuppressWarnings("nls")
-	public void viewFile(RestRequest req, RestResponse res, @PathRemainder String path, @Properties ObjectMap properties, @Param("highlight") boolean highlight, @Param("start") String start, @Param("end") String end, @Param("thread") String thread, @Param("loggers") String[] loggers, @Param("severity") String[] severity) throws Exception {
-
-		File f = getFile(path);
-		if (f.isDirectory())
-			throw new RestException(SC_METHOD_NOT_ALLOWED, "View not available on directories");
-
-		Date startDate = StringUtils.parseISO8601Date(start), endDate = StringUtils.parseISO8601Date(end);
-
-		if (! highlight) {
-			Object o = getReader(f, startDate, endDate, thread, loggers, severity);
-			res.setContentType("text/plain");
-			if (o instanceof Reader)
-				res.setOutput(o);
-			else {
-				LogParser p = (LogParser)o;
-				Writer w = res.getNegotiatedWriter();
-				try {
-					p.writeTo(w);
-				} finally {
-					w.flush();
-					w.close();
-				}
-			}
-			return;
-		}
-
-		res.setContentType("text/html");
-		PrintWriter w = res.getNegotiatedWriter();
-		try {
-			w.println("<html><body style='font-family:monospace;font-size:8pt;white-space:pre;'>");
-			LogParser lp = getLogParser(f, startDate, endDate, thread, loggers, severity);
-			try {
-				if (! lp.hasNext())
-					w.append("<span style='color:gray'>[EMPTY]</span>");
-				else for (LogParser.Entry le : lp) {
-					char s = le.severity.charAt(0);
-					String color = "black";
-					//SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST
-					if (s == 'I')
-						color = "#006400";
-					else if (s == 'W')
-						color = "#CC8400";
-					else if (s == 'E' || s == 'S')
-						color = "#DD0000";
-					else if (s == 'D' || s == 'F' || s == 'T')
-						color = "#000064";
-					w.append("<span style='color:").append(color).append("'>");
-					le.appendHtml(w).append("</span>");
-				}
-				w.append("</body></html>");
-			} finally {
-				lp.close();
-			}
-		} finally {
-			w.close();
-		}
-	}
-
-	/**
-	 * [VIEW /*] - Retrieve the contents of a log file as parsed entries.
-	 * 
-	 * @param req The HTTP request. 
-	 * @param path The log file path.
-	 * @param start Optional start timestamp.  Don't print lines logged before the specified timestamp.  Example:  "&start=2014-01-23 11:25:47".
-	 * @param end Optional end timestamp.  Don't print lines logged after the specified timestamp.  Example:  "&end=2014-01-23 11:25:47".
-	 * @param thread Optional thread name filter.  Only show log entries with the specified thread name.  Example: "&thread=pool-33-thread-1".
-	 * @param loggers Optional logger filter.  Only show log entries if they were produced by one of the specified loggers (simple class name).  Example: "&loggers=(LinkIndexService,LinkIndexRestService)".
-	 * @param severity Optional severity filter.  Only show log entries with the specified severity.  Example: "&severity=(ERROR,WARN)".
-	 * @return The parsed contents of the log file.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="PARSE", path="/*", converters=Queryable.class, rc={200,404})
-	public LogParser viewParsedEntries(RestRequest req, @PathRemainder String path, @Param("start") String start, @Param("end") String end, @Param("thread") String thread, @Param("loggers") String[] loggers, @Param("severity") String[] severity) throws Exception {
-
-		File f = getFile(path);
-		Date startDate = StringUtils.parseISO8601Date(start), endDate = StringUtils.parseISO8601Date(end);
-
-		if (f.isDirectory())
-			throw new RestException(SC_METHOD_NOT_ALLOWED, "View not available on directories");
-
-		return getLogParser(f, startDate, endDate, thread, loggers, severity);
-	}
-
-	/**
-	 * [DOWNLOAD /*] - Download file.
-	 * 
-	 * @param res The HTTP response. 
-	 * @param path The log file path. 
-	 * @return The contents of the log file.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="DOWNLOAD", path="/*", rc={200,404})
-	public Object downloadFile(RestResponse res, @PathRemainder String path) throws Exception {
-
-		File f = getFile(path);
-
-		if (f.isDirectory())
-			throw new RestException(SC_METHOD_NOT_ALLOWED, "Download not available on directories");
-
-		res.setContentType("application/octet-stream"); //$NON-NLS-1$
-		res.setContentLength((int)f.length());
-		return new FileInputStream(f);
-	}
-
-	/** 
-	 * [DELETE /*] - Delete a file. 
-	 * 
-	 * @param path The log file path. 
-	 * @return A redirect object to the root.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="DELETE", path="/*", rc={200,404})
-	public Object deleteFile(@PathRemainder String path) throws Exception {
-
-		File f = getFile(path);
-
-		if (f.isDirectory())
-			throw new RestException(SC_BAD_REQUEST, "Delete not available on directories.");
-
-		if (f.canWrite())
-			if (! f.delete())
-				throw new RestException(SC_FORBIDDEN, "Could not delete file.");
-
-		return new Redirect(path + "/.."); //$NON-NLS-1$
-	}
-
-	private static BufferedReader getReader(File f) throws IOException {
-		return new BufferedReader(new InputStreamReader(new FileInputStream(f), Charset.defaultCharset()));
-	}
-
-	private File getFile(String path) {
-		if (path != null && path.indexOf("..") != -1)
-			throw new RestException(SC_NOT_FOUND, "File not found.");
-		File f = (path == null ? logDir : new File(logDir.getAbsolutePath() + '/' + path));
-		if (filter.accept(f))
-			return f;
-		throw new RestException(SC_NOT_FOUND, "File not found.");
-	}
-
-	/**
-	 * File bean.
-	 */
-	@SuppressWarnings("javadoc")
-	public static class FileResource {
-		private File f;
-		public String type;
-		public Object name;
-		public Long size;
-		@BeanProperty(filter=DateFilter.Medium.class) public Date lastModified;
-		public URL view, highlighted, parsed, download, delete;
-
-		public FileResource(File f, URL url) throws IOException {
-			this.f = f;
-			this.type = (f.isDirectory() ? "dir" : "file");
-			this.name = f.isDirectory() ? new Link(f.getName(), url.toString()) : f.getName();
-			this.size = f.isDirectory() ? null : f.length();
-			this.lastModified = new Date(f.lastModified());
-			if (f.canRead() && ! f.isDirectory()) {
-				this.view = new URL(url + "?method=VIEW");
-				this.highlighted = new URL(url + "?method=VIEW&highlight=true");
-				this.parsed = new URL(url + "?method=PARSE");
-				this.download = new URL(url + "?method=DOWNLOAD");
-				this.delete = new URL(url + "?method=DELETE");
-			}
-		}
-	}
-
-	private static class FileResourceComparator implements Comparator<FileResource>, Serializable {
-		private static final long serialVersionUID = 1L;
-		@Override /* Comparator */
-		public int compare(FileResource o1, FileResource o2) {
-			int c = o1.type.compareTo(o2.type);
-			return c != 0 ? c : o1.f.getName().compareTo(o2.f.getName());
-		}
-	}
-
-	private Object getReader(File f, final Date start, final Date end, final String thread, final String[] loggers, final String[] severity) throws IOException {
-		if (start == null && end == null && thread == null && loggers == null)
-			return getReader(f);
-		return getLogParser(f, start, end, thread, loggers, severity);
-	}
-
-	private LogParser getLogParser(File f, final Date start, final Date end, final String thread, final String[] loggers, final String[] severity) throws IOException {
-		return new LogParser(leFormatter, f, start, end, thread, loggers, severity);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/SampleRootResource.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/SampleRootResource.java b/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/SampleRootResource.java
deleted file mode 100755
index 8c60073..0000000
--- a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/SampleRootResource.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Licensed Materials - Property of IBM
- * � Copyright IBM Corporation 2015. All Rights Reserved.
- *
- *  The source code for this program is not published or otherwise
- *  divested of its trade secrets, irrespective of what has been
- *  deposited with the U.S. Copyright Office.
- *******************************************************************************/
-package com.ibm.juno.microservice.resources;
-
-import com.ibm.juno.microservice.ResourceGroup;
-import com.ibm.juno.server.annotation.RestResource;
-
-/**
- * Sample root REST resource.
- * 
- * @author James Bognar (jbognar@us.ibm.com)
- */
-@RestResource(
-	path="/",
-	label="Sample Root Resource",
-	description="This is a sample router page",
-	children={ConfigResource.class,LogsResource.class}
-)
-public class SampleRootResource extends ResourceGroup {
-	private static final long serialVersionUID = 1L;
-}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/ShutdownResource.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/ShutdownResource.java b/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/ShutdownResource.java
deleted file mode 100755
index e36d51c..0000000
--- a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/ShutdownResource.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Licensed Materials - Property of IBM
- * � Copyright IBM Corporation 2015. All Rights Reserved.
- * 
- * Note to U.S. Government Users Restricted Rights:
- * Use, duplication or disclosure restricted by GSA ADP Schedule
- * Contract with IBM Corp. 
- *******************************************************************************/
-package com.ibm.juno.microservice.resources;
-
-import com.ibm.juno.microservice.Resource;
-import com.ibm.juno.server.annotation.RestMethod;
-import com.ibm.juno.server.annotation.RestResource;
-
-/**
- * Provides the capability to shut down this REST microservice through a REST call.
- */
-@RestResource(
-	path="/shutdown",
-	label="Shut down this resource"
-)
-public class ShutdownResource extends Resource {
-	
-	private static final long serialVersionUID = 1L;
-
-	/** 
-	 * [GET /] - Shutdown this resource. 
-	 * 
-	 * @return The string <js>"OK"</js>.
-	 * @throws Exception 
-	 */
-	@RestMethod(name="GET", path="/", description="Show contents of config file.")
-	public String shutdown() throws Exception {
-		new Thread(
-			new Runnable() {
-				@Override /* Runnable */
-				public void run() {
-					try {
-						Thread.sleep(1000);
-					System.exit(0);
-					} catch (InterruptedException e) {
-						e.printStackTrace();
-					}
-				}
-			}
-		).start();
-		return "OK";
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/package.html
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/package.html b/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/package.html
deleted file mode 100755
index 770c4f5..0000000
--- a/com.ibm.team.juno.microservice/src/com/ibm/juno/microservice/resources/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!DOCTYPE HTML>
-<!--
-    Licensed Materials - Property of IBM
-    (c) Copyright IBM Corporation 2015. All Rights Reserved.
-   
-    Note to U.S. Government Users Restricted Rights:  
-    Use, duplication or disclosure restricted by GSA ADP Schedule 
-    Contract with IBM Corp. 
- -->
-<html>
-<head>
-	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-	<style type="text/css">
-		/* For viewing in Page Designer */
-		@IMPORT url("../javadoc.css");
-		body { 
-			margin: 20px; 
-		}	
-	</style>
-</head>
-<body>
-<p>Predefined Microservice Resources</p>
-</body>
-</html>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/Microservice.java b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
new file mode 100755
index 0000000..55fcead
--- /dev/null
+++ b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/Microservice.java
@@ -0,0 +1,495 @@
+/***************************************************************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ ***************************************************************************************************************************/
+package org.apache.juneau.microservice;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import java.util.jar.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.ini.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.svl.*;
+import org.apache.juneau.svl.vars.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * Parent class for all microservices.
+ * <p>
+ * A microservice defines a simple API for starting and stopping simple Java services
+ * 	contained in executable jars.
+ * <p>
+ * The general command for invoking these services is...
+ * <p class='bcode'>
+ * 	java -jar mymicroservice.jar [mymicroservice.cfg]
+ * </p>
+ * <p>
+ * Your microservice class must be specified as the <jk>Main-Class</jk> entry in
+ * 	the manifest file of your microservice jar file.
+ *
+ * <h6 class='topic'>Microservice Configuration</h6>
+ *
+ * This class defines the following method for accessing configuration for your microservice:
+ * <p>
+ * <ul class='spaced-list'>
+ * 	<li>{@link #getArgs()} - The command-line arguments passed to the jar file.
+ * 	<li>{@link #getConfig()} - An external INI-style configuration file.
+ * 	<li>{@link #getManifest()} - The manifest file for the main jar file.
+ * </ul>
+ *
+ * <h6 class='topic'>Entrypoint Method</h6>
+ *
+ * Subclasses must implement a static void main method as the entry point for the microservice.
+ * Typically, this method will simply consist of the following...
+ * <p>
+ * <p class='bcode'>
+ * 	<jk>public static void</jk> main(String[] args) <jk>throws</jk> Exception {
+ * 		<jk>new</jk> MyMicroservice(args).start();
+ * 	}
+ * </p>
+ *
+ * <h6 class='topic'>Lifecycle Methods</h6>
+ *
+ * Subclasses must implement the following lifecycle methods:
+ * <p>
+ * <ul class='spaced-list'>
+ * 	<li>{@link #start()} - Gets executed during startup.
+ * 	<li>{@link #stop()} - Gets executed when 'exit' is typed in the console or an external shutdown signal is received.
+ * 	<li>{@link #kill()} - Can be used to forcibly shut down the service.  Doesn't get called during normal operation.
+ * </ul>
+ *
+ * <h6 class='topic'>Lifecycle Listener Methods</h6>
+ *
+ * Subclasses can optionally implement the following event listener methods:
+ * <p>
+ * <ul class='spaced-list'>
+ * 	<li>{@link #onStart()} - Gets executed before {@link #start()}.
+ * 	<li>{@link #onStop()} - Gets executed before {@link #stop()}.
+ * 	<li>{@link #onConfigSave(ConfigFile)} - Gets executed after a config file has been saved.
+ * 	<li>{@link #onConfigChange(ConfigFile, Set)} - Gets executed after a config file has been modified.
+ * </ul>
+ *
+ * <h6 class='topic'>Other Methods</h6>
+ *
+ * Subclasses can optionally override the following methods to provide customized behavior:
+ * <p>
+ * <ul class='spaced-list'>
+ * 	<li>{@link #createVarResolver()} - Creates the {@link VarResolver} used to resolve variables in the config file returned by {@link #getConfig()}.
+ * </ul>
+ *
+ * @author james.bognar@salesforce.com
+ */
+public abstract class Microservice {
+
+	private static Args args;
+	private static ConfigFile cf;
+	private static ManifestFile mf;
+
+	/**
+	 * Constructor.
+	 *
+	 * @param args2 Command line arguments.
+	 * @throws Exception
+	 */
+	protected Microservice(String[] args2) throws Exception {
+		Microservice.args = new Args(args2);
+
+		// --------------------------------------------------------------------------------
+		// Try to get the manifest file.
+		// --------------------------------------------------------------------------------
+		Manifest m = new Manifest();
+
+		// If running within an eclipse workspace, need to get it from the file system.
+		File f = new File("META-INF/MANIFEST.MF");
+		if (f.exists()) {
+			try {
+				m.read(new FileInputStream(f));
+			} catch (IOException e) {
+				System.err.println("Problem detected in MANIFEST.MF.  Contents below:\n" + IOUtils.read(f));
+				throw e;
+			}
+		} else {
+			// Otherwise, read from manifest file in the jar file containing the main class.
+			URLClassLoader cl = (URLClassLoader)getClass().getClassLoader();
+			URL url = cl.findResource("META-INF/MANIFEST.MF");
+			if (url != null) {
+				try {
+					m.read(url.openStream());
+				} catch (IOException e) {
+					System.err.println("Problem detected in MANIFEST.MF.  Contents below:\n" + IOUtils.read(url.openStream()));
+					throw e;
+				}
+			}
+		}
+		mf = new ManifestFile(m);
+
+		// --------------------------------------------------------------------------------
+		// Find config file.
+		// Can either be passed in as first parameter, or we discover it using
+		// the 'sun.java.command' system property.
+		// --------------------------------------------------------------------------------
+		String cFile = null;
+		if (args.hasArg(0))
+			cFile = args.getArg(0);
+		else if (mf.containsKey("Main-ConfigFile"))
+			cFile = mf.getString("Main-ConfigFile");
+		else {
+			String cmd = System.getProperty("sun.java.command", "not_found").split("\\s+")[0];
+			if (cmd.endsWith(".jar"))
+				cFile = cmd.replace(".jar", ".cfg");
+		}
+
+		if (cFile == null) {
+			System.err.println("Running class ["+getClass().getSimpleName()+"] without a config file.");
+			cf = ConfigMgr.DEFAULT.create();
+		} else {
+			System.out.println("Running class ["+getClass().getSimpleName()+"] using config file ["+cFile+"]");
+			System.setProperty("juneau.configFile", cFile);
+			cf = ConfigMgr.DEFAULT.get(cFile).getResolving(createVarResolver());
+		}
+
+		// --------------------------------------------------------------------------------
+		// Set system properties.
+		// --------------------------------------------------------------------------------
+		Set<String> spKeys = cf.getSectionKeys("SystemProperties");
+		if (spKeys != null)
+			for (String key : spKeys)
+				System.setProperty(key, cf.get("SystemProperties", key));
+
+		// --------------------------------------------------------------------------------
+		// Add a config file change listener.
+		// --------------------------------------------------------------------------------
+		cf.addListener(new ConfigFileListener() {
+			@Override /* ConfigFileListener */
+			public void onSave(ConfigFile cf) {
+				onConfigSave(cf);
+			}
+			@Override /* ConfigFileListener */
+			public void onChange(ConfigFile cf, Set<String> changes) {
+				onConfigChange(cf, changes);
+			}
+		});
+
+		// --------------------------------------------------------------------------------
+		// Add exit listeners.
+		// --------------------------------------------------------------------------------
+		new Thread() {
+			@Override /* Thread */
+			public void run() {
+				Console c = System.console();
+				if (c == null)
+					System.out.println("No available console.");
+				else {
+					while (true) {
+						String l = c.readLine("\nEnter 'exit' to exit.\n");
+						if (l == null || l.equals("exit")) {
+							Microservice.this.stop();
+							break;
+						}
+					}
+				}
+			}
+		}.start();
+		Runtime.getRuntime().addShutdownHook(
+			new Thread() {
+				@Override /* Thread */
+				public void run() {
+					Microservice.this.stop();
+				}
+			}
+		);
+	}
+
+	/**
+	 * Creates the {@link VarResolver} used to resolve variables in the
+	 * config file returned by {@link #getConfig()}.
+	 * <p>
+	 * The default implementation resolves the following variables:
+	 * <ul>
+	 * 	<li><code>$S{key}</code>, <code>$S{key,default}</code> - System properties.
+	 * 	<li><code>$E{key}</code>, <code>$E{key,default}</code> - Environment variables.
+	 * 	<li><code>$C{key}</code>, <code>$C{key,default}</code> - Config file entries.
+	 * 	<li><code>$MF{key}</code>, <code>$MF{key,default}</code> - Manifest file entries.
+	 * 	<li><code>$ARG{key}</code>, <code>$ARG{key,default}</code> - Command-line arguments.
+	 * </ul>
+	 * <p>
+	 * Subclasses can override this method to provide their own variables.
+	 * <dl>
+	 * 	<dt>Examples:</dt>
+	 * 	<dd>
+	 * 		<p class='bcode'>
+	 * 	<jd>/**
+	 * 	 * Augment default var resolver with a custom $B{...} variable that simply wraps strings inside square brackets.
+	 * 	 * /</jd>
+	 * 	<ja>@Override</ja> <jc>// Microservice</jc>
+	 * 	<jk>protected</jk> StringVarResolver createVarResolver() {
+	 * 		<jk>return super</jk>.createVarResolver()
+	 * 			.addVar(<js>"B"</js>,
+	 * 				<jk>new</jk> StringVarWithDefault() {
+	 * 					<ja>@Override</ja> <jc>// StringVar</jc>
+	 * 					<jk>public</jk> String resolve(String varVal) {
+	 * 						<jk>return</jk> <js>'['</js> + varVal + <js>']'</js>;
+	 * 					}
+	 * 				}
+	 * 			);
+	 * 	}
+	 * 		</p>
+	 * 		<p class='bcode'>
+	 * 	<cc># Example config file</cc>
+	 * 	<cs>[MySection]</cs>
+	 * 	<ck>myEntry</ck> = $B{foo}
+	 * 		</p>
+	 * 		<p class='bcode'>
+	 * 	<jc>// Example java code</jc>
+	 * 	String myentry = getConfig().getString(<js>"MySection/myEntry"</js>); <jc>// == "[foo]"</js>
+	 * 		</p>
+	 * 	</dd>
+	 * </dl>
+	 *
+	 * @return A new {@link VarResolver}.
+	 */
+	protected VarResolver createVarResolver() {
+		return new VarResolver()
+			.addVars(SystemPropertiesVar.class, EnvVariablesVar.class, ConfigFileVar.class, ManifestFileVar.class, ArgsVar.class)
+			.setContextObject(ConfigFileVar.SESSION_config, cf)
+			.setContextObject(ManifestFileVar.SESSION_manifest, mf)
+			.setContextObject(ArgsVar.SESSION_args, args);
+	}
+
+	/**
+	 * Returns the command-line arguments passed into the application.
+	 * <p>
+	 * This method can be called from the class constructor.
+	 * <p>
+	 * See {@link Args} for details on using this method.
+	 *
+	 * @return The command-line arguments passed into the application.
+	 */
+	protected static Args getArgs() {
+		return args;
+	}
+
+	/**
+	 * Overrides the value returned by {@link #getArgs()}.
+	 *
+	 * @param args The new arguments.
+	 * @return This object (for method chaining).
+	 */
+	protected Microservice setArgs(String[] args) {
+		Microservice.args = new Args(args);
+		return this;
+	}
+
+	/**
+	 * Returns the external INI-style configuration file that can be used to configure your microservice.
+	 * <p>
+	 * The config file location is determined in the following order:
+	 * <ol class='spaced-list'>
+	 * 	<li>The first argument passed to the microservice jar.
+	 * 	<li>The <code>Main-ConfigFile</code> entry in the microservice jar manifest file.
+	 * 	<li>The name of the microservice jar with a <js>".cfg"</js> suffix (e.g. <js>"mymicroservice.jar"</js>-&gt;<js>"mymicroservice.cfg"</js>).
+	 * </ol>
+	 * <p>
+	 * If all methods for locating the config file fail, then this method returns <jk>null</jk>.
+	 * <p>
+	 * Subclasses can set their own config file by calling the {@link #setConfig(ConfigFile)} method.
+	 * <p>
+	 * String variables defined by {@link #createVarResolver()} are automatically resolved when using this method.
+	 * <p>
+	 * This method can be called from the class constructor.
+	 * <dl>
+	 * 	<dt>Examples:</dt>
+	 * 	<dd>
+	 * 		<p class='bcode'>
+	 * 	<cc>#--------------------------</cc>
+	 * 	<cc># My section</cc>
+	 * 	<cc>#--------------------------</cc>
+	 * 	<cs>[MySection]</cs>
+	 *
+	 * 	<cc># An integer</cc>
+	 * 	<ck>anInt</ck> = 1
+	 *
+	 * 	<cc># A boolean</cc>
+	 * 	<ck>aBoolean</ck> = true
+	 *
+	 * 	<cc># An int array</cc>
+	 * 	<ck>anIntArray</ck> = 1,2,3
+	 *
+	 * 	<cc># A POJO that can be converted from a String</cc>
+	 * 	<ck>aURL</ck> = http://foo
+	 *
+	 * 	<cc># A POJO that can be converted from JSON</cc>
+	 * 	<ck>aBean</ck> = {foo:'bar',baz:123}
+	 *
+	 * 	<cc># A system property</cc>
+	 * 	<ck>locale</ck> = $S{java.locale, en_US}
+	 *
+	 * 	<cc># An environment variable</cc>
+	 * 	<ck>path</ck> = $E{PATH, unknown}
+	 *
+	 * 	<cc># A manifest file entry</cc>
+	 * 	<ck>mainClass</ck> = $MF{Main-Class}
+	 *
+	 * 	<cc># Another value in this config file</cc>
+	 * 	<ck>sameAsAnInt</ck> = $C{MySection/anInt}
+	 *
+	 * 	<cc># A command-line argument in the form "myarg=foo"</cc>
+	 * 	<ck>myArg</ck> = $ARG{myarg}
+	 *
+	 * 	<cc># The first command-line argument</cc>
+	 * 	<ck>firstArg</ck> = $ARG{0}
+	 *
+	 * 	<cc># Look for system property, or env var if that doesn't exist, or command-line arg if that doesn't exist.</cc>
+	 * 	<ck>nested</ck> = $S{mySystemProperty,$E{MY_ENV_VAR,$ARG{0}}}
+	 *
+	 * 	<cc># A POJO with embedded variables</cc>
+	 * 	<ck>aBean2</ck> = {foo:'$ARG{0}',baz:$C{MySection/anInt}}
+	 *
+	 * 		</p>
+	 * 		<p class='bcode'>
+	 * 	<jc>// Java code for accessing config entries above.</jc>
+	 * 	ConfigFile cf = getConfig();
+	 *
+	 * 	<jk>int</jk> anInt = cf.getInt(<js>"MySection/anInt"</js>);
+	 * 	<jk>boolean</jk> aBoolean = cf.getBoolean(<js>"MySection/aBoolean"</js>);
+	 * 	<jk>int</jk>[] anIntArray = cf.getObject(<jk>int</jk>[].<jk>class</jk>, <js>"MySection/anIntArray"</js>);
+	 * 	URL aURL = cf.getObject(URL.<jk>class</jk>, <js>"MySection/aURL"</js>);
+	 * 	MyBean aBean = cf.getObject(MyBean.<jk>class</jk>, <js>"MySection/aBean"</js>);
+	 * 	Locale locale = cf.getObject(Locale.<jk>class</jk>, <js>"MySection/locale"</js>);
+	 * 	String path = cf.getString(<js>"MySection/path"</js>);
+	 * 	String mainClass = cf.getString(<js>"MySection/mainClass"</js>);
+	 * 	<jk>int</jk> sameAsAnInt = cf.getInt(<js>"MySection/sameAsAnInt"</js>);
+	 * 	String myArg = cf.getString(<js>"MySection/myArg"</js>);
+	 * 	String firstArg = cf.getString(<js>"MySection/firstArg"</js>);
+	 * 		</p>
+	 * 	</dd>
+	 * </dl>
+	 *
+	 * @return The config file for this application, or <jk>null</jk> if no config file is configured.
+	 */
+	protected static ConfigFile getConfig() {
+		return cf;
+	}
+
+	/**
+	 * Overrides the value returned by {@link #getConfig()}.
+	 *
+	 * @param cf The config file for this application, or <jk>null</jk> if no config file is configured.
+	 * @return This object (for method chaining).
+	 */
+	protected Microservice setConfig(ConfigFile cf) {
+		Microservice.cf = cf;
+		return this;
+	}
+
+	/**
+	 * Returns the main jar manifest file contents as a simple {@link ObjectMap}.
+	 * <p>
+	 * This map consists of the contents of {@link Manifest#getMainAttributes()} with the keys
+	 * 	and entries converted to simple strings.
+	 * <p>
+	 * This method can be called from the class constructor.
+	 * <dl>
+	 * 	<dt>Examples:</dt>
+	 * 	<dd>
+	 * 		<p class='bcode'>
+	 * 	<jc>// Get Main-Class from manifest file.</jc>
+	 * 	String mainClass = Microservice.<jsm>getManifest</jsm>().getString(<js>"Main-Class"</js>, <js>"unknown"</js>);
+	 *
+	 * 	<jc>// Get Rest-Resources from manifest file.</jc>
+	 * 	String[] restResources = Microservice.<jsm>getManifest</jsm>().getStringArray(<js>"Rest-Resources"</js>);
+	 * 		</p>
+	 * 	</dd>
+	 * </dl>
+	 *
+	 * @return The manifest file from the main jar, or <jk>null</jk> if the manifest file could not be retrieved.
+	 */
+	protected static ManifestFile getManifest() {
+		return mf;
+	}
+
+	//--------------------------------------------------------------------------------
+	// Abstract lifecycle methods.
+	//--------------------------------------------------------------------------------
+
+	/**
+	 * Start this application.
+	 * <p>
+	 * Default implementation simply calls {@link #onStart()}.
+	 * <p>
+	 * Overridden methods MUST call this method FIRST so that the {@link #onStart()} method is called.
+	 *
+	 * @throws Exception
+	 */
+	protected void start() throws Exception {
+		onStart();
+	}
+
+	/**
+	 * Stop this application.
+	 * <p>
+	 * Default implementation simply calls {@link #onStop()}.
+	 * <p>
+	 * Overridden methods MUST call this method LAST so that the {@link #onStop()} method is called.
+	 */
+	protected void stop() {
+		onStop();
+	}
+
+	/**
+	 * Kill the JVM by calling <code>System.exit(2);</code>.
+	 */
+	protected void kill() {
+		// This triggers the shutdown hook.
+		System.exit(2);
+	}
+
+	//--------------------------------------------------------------------------------
+	// Lifecycle listener methods.
+	// Subclasses can override these methods to run code on certain events.
+	//--------------------------------------------------------------------------------
+
+	/**
+	 * Called at the beginning of the {@link #start()} call.
+	 * <p>
+	 * Subclasses can override this method to hook into the lifecycle of this application.
+	 */
+	protected void onStart() {}
+
+	/**
+	 * Called at the end of the {@link #stop()} call.
+	 * <p>
+	 * Subclasses can override this method to hook into the lifecycle of this application.
+	 */
+	protected void onStop() {}
+
+	/**
+	 * Called if the {@link ConfigFile#save()} is called on the config file.
+	 * <p>
+	 * Subclasses can override this method to listen for config file changes.
+	 *
+	 * @param cf The config file.
+	 */
+	protected void onConfigSave(ConfigFile cf) {}
+
+	/**
+	 * Called if one or more changes occur in the config file.
+	 * <p>
+	 * Subclasses can override this method to listen for config file changes.
+	 *
+	 * @param cf The config file.
+	 * @param changes The list of keys in the config file being changed.
+	 */
+	protected void onConfigChange(ConfigFile cf, Set<String> changes) {}
+}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/Resource.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/Resource.java b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/Resource.java
new file mode 100755
index 0000000..ccfc967
--- /dev/null
+++ b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/Resource.java
@@ -0,0 +1,63 @@
+/***************************************************************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ ***************************************************************************************************************************/
+package org.apache.juneau.microservice;
+
+import static org.apache.juneau.html.HtmlDocSerializerContext.*;
+
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+import org.apache.juneau.svl.*;
+import org.apache.juneau.svl.vars.*;
+
+/**
+ * Superclass for all REST resources.
+ * <p>
+ * In additional to the functionality of the {@link RestServletDefault} group,
+ * augments the {@link #createVarResolver()} method with the following additional variable types:
+ * <ul class='spaced-list'>
+ * 	<li><code class='snippet'>$ARG{...}</code> - Command line arguments pulled from {@link Microservice#getArgs()}.<br>
+ * 		<h6 class='figure'>Example:</h6>
+ * 		<p class='bcode'>
+ * 			String firstArg = request.getVarResolver().resolve(<js>"$ARG{0}"</js>);  <jc>// First argument.</jc>
+ * 			String namedArg = request.getVarResolver().resolve(<js>"$ARG{myarg}"</js>);  <jc>// Named argument (e.g. "myarg=foo"). </jc>
+ * 		</p>
+ * 	<li><code class='snippet'>$MF{...}</code> - Manifest file entries pulled from {@link Microservice#getManifest()}.<br>
+ * 		<h6 class='figure'>Example:</h6>
+ * 		<p class='bcode'>
+ * 			String mainClass = request.getVarResolver().resolve(<js>"$MF{Main-Class}"</js>);  <jc>// Main class. </jc>
+ * 		</p>
+ * </ul>
+ *
+ * @author James Bognar (james.bognar@salesforce.com)
+ */
+@SuppressWarnings("serial")
+@RestResource(
+	properties={
+		@Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS'}")
+	},
+	config="$S{juneau.configFile}",
+	stylesheet="$C{REST/stylesheet,styles/juneau.css}"
+)
+public abstract class Resource extends RestServletDefault {
+
+	/**
+	 * Adds $ARG and $MF variables to variable resolver defined on {@link RestServlet#createVarResolver()}.
+	 */
+	@Override
+	protected VarResolver createVarResolver() {
+		return super.createVarResolver()
+			.addVars(ArgsVar.class, ManifestFileVar.class)
+			.setContextObject(ArgsVar.SESSION_args, Microservice.getArgs())
+			.setContextObject(ManifestFileVar.SESSION_manifest, Microservice.getManifest());
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/ResourceGroup.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/ResourceGroup.java b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/ResourceGroup.java
new file mode 100755
index 0000000..c6e0d6b
--- /dev/null
+++ b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/ResourceGroup.java
@@ -0,0 +1,64 @@
+/***************************************************************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ ***************************************************************************************************************************/
+package org.apache.juneau.microservice;
+
+import static org.apache.juneau.html.HtmlDocSerializerContext.*;
+
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+import org.apache.juneau.svl.*;
+import org.apache.juneau.svl.vars.*;
+
+/**
+ * Superclass for all REST resource groups.
+ * <p>
+ * In additional to the functionality of the {@link RestServletGroupDefault} group,
+ * augments the {@link #createVarResolver()} method with the following additional variable types:
+ * <ul class='spaced-list'>
+ * 	<li><jk>$ARG{...}</jk> - Command line arguments.<br>
+ * 		Resolves values from {@link Microservice#getArgs()}.<br>
+ * 		<h6>Example:</h6>
+ * 		<p class='bcode'>
+ * 			String firstArg = request.getVarResolver().resolve(<js>"$ARG{0}"</js>);  <jc>// First argument.</jc>
+ * 			String namedArg = request.getVarResolver().resolve(<js>"$ARG{myarg}"</js>);  <jc>// Named argument (e.g. "myarg=foo"). </jc>
+ * 		</p>
+ * 	<li><jk>$MF{...}</jk> - Manifest file entries.
+ * 		<h6>Example:</h6>
+ * 		<p class='bcode'>
+ * 			String mainClass = request.getVarResolver().resolve(<js>"$MF{Main-Class}"</js>);  <jc>// Main class. </jc>
+ * 		</p>
+ * </ul>
+ *
+ * @author James Bognar (james.bognar@salesforce.com)
+ */
+@SuppressWarnings("serial")
+@RestResource(
+	properties={
+		@Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS'}"),
+	},
+	config="$S{juneau.configFile}",
+	stylesheet="$C{REST/stylesheet,styles/juneau.css}"
+)
+public abstract class ResourceGroup extends RestServletGroupDefault {
+
+	/**
+	 * Adds $ARG and $MF variables to variable resolver defined on {@link RestServlet#createVarResolver()}.
+	 */
+	@Override
+	protected VarResolver createVarResolver() {
+		return super.createVarResolver()
+			.addVars(ArgsVar.class, ManifestFileVar.class)
+			.setContextObject(ArgsVar.SESSION_args, Microservice.getArgs())
+			.setContextObject(ManifestFileVar.SESSION_manifest, Microservice.getManifest());
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/30947fd7/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/ResourceJena.java
----------------------------------------------------------------------
diff --git a/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/ResourceJena.java b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/ResourceJena.java
new file mode 100755
index 0000000..43cf2c6
--- /dev/null
+++ b/com.ibm.team.juno.microservice/src/main/java/org/apache/juneau/microservice/ResourceJena.java
@@ -0,0 +1,33 @@
+/***************************************************************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations under the License.
+ ***************************************************************************************************************************/
+package org.apache.juneau.microservice;
+
+import static org.apache.juneau.html.HtmlDocSerializerContext.*;
+
+import org.apache.juneau.server.annotation.*;
+import org.apache.juneau.server.jena.*;
+
+/**
+ * Superclass for all REST resources with RDF support.
+ *
+ * @author James Bognar (james.bognar@salesforce.com)
+ */
+@SuppressWarnings("serial")
+@RestResource(
+	properties={
+		@Property(name=HTMLDOC_links, value="{up:'$R{requestParentURI}',options:'$R{servletURI}?method=OPTIONS'}")
+	},
+	config="$S{juneau.configFile}",
+	stylesheet="$C{REST/stylesheet,styles/juneau.css}"
+)
+public abstract class ResourceJena extends RestServletJenaDefault {}