393303 use jetty-web.xml to explicitly add the jetty packages that need visability. This commit also sucked in some changes made to help with the documentation process (improving deployer configuration management
This commit is contained in:
parent
8186794775
commit
3683653052
|
@ -43,6 +43,16 @@
|
|||
<Set name="defaultsDescriptor"><Property name="jetty.home" default="." />/etc/webdefault.xml</Set>
|
||||
<Set name="scanInterval">1</Set>
|
||||
<Set name="extractWars">true</Set>
|
||||
<Set name="configurationManager">
|
||||
<New class="org.eclipse.jetty.deploy.PropertiesConfigurationManager">
|
||||
<!-- file of context configuration properties
|
||||
<Set name="file"><SystemProperty name="jetty.home"/>/etc/some.properties</Set>
|
||||
-->
|
||||
<!-- set a context configuration property
|
||||
<Call name="put"><Arg>name</Arg><Arg>value</Arg></Call>
|
||||
-->
|
||||
</New>
|
||||
</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
|
|
@ -21,10 +21,15 @@ package org.eclipse.jetty.deploy;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.annotation.ManagedOperation;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
|
||||
/**
|
||||
|
@ -32,42 +37,55 @@ import org.eclipse.jetty.util.resource.Resource;
|
|||
*
|
||||
* Supplies properties defined in a file.
|
||||
*/
|
||||
public class FileConfigurationManager implements ConfigurationManager
|
||||
@ManagedObject("Configure deployed webapps via properties")
|
||||
public class PropertiesConfigurationManager implements ConfigurationManager
|
||||
{
|
||||
private Resource _file;
|
||||
private Map<String,String> _map = new HashMap<String,String>();
|
||||
private String _properties;
|
||||
private final Map<String,String> _map = new HashMap<String,String>();
|
||||
|
||||
public FileConfigurationManager()
|
||||
public PropertiesConfigurationManager(String properties)
|
||||
{
|
||||
}
|
||||
|
||||
public void setFile(String filename) throws MalformedURLException, IOException
|
||||
public PropertiesConfigurationManager()
|
||||
{
|
||||
_file = Resource.newResource(filename);
|
||||
}
|
||||
|
||||
@ManagedAttribute("A file or URL of properties")
|
||||
public void setFile(String resource) throws MalformedURLException, IOException
|
||||
{
|
||||
_properties=resource;
|
||||
_map.clear();
|
||||
loadProperties(_properties);
|
||||
}
|
||||
|
||||
public String getFile()
|
||||
{
|
||||
return _properties;
|
||||
}
|
||||
|
||||
@ManagedOperation("Set a property")
|
||||
public void put(@Name("name")String name, @Name("value")String value)
|
||||
{
|
||||
_map.put(name,value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.deploy.ConfigurationManager#getProperties()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getProperties()
|
||||
{
|
||||
try
|
||||
{
|
||||
loadProperties();
|
||||
return _map;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return new HashMap<>(_map);
|
||||
}
|
||||
|
||||
private void loadProperties() throws FileNotFoundException, IOException
|
||||
private void loadProperties(String resource) throws FileNotFoundException, IOException
|
||||
{
|
||||
if (_map.isEmpty() && _file!=null)
|
||||
Resource file=Resource.newResource(resource);
|
||||
if (file!=null && file.exists())
|
||||
{
|
||||
Properties properties = new Properties();
|
||||
properties.load(_file.getInputStream());
|
||||
properties.load(file.getInputStream());
|
||||
for (Map.Entry<Object, Object> entry : properties.entrySet())
|
||||
_map.put(entry.getKey().toString(),String.valueOf(entry.getValue()));
|
||||
}
|
|
@ -50,7 +50,7 @@
|
|||
<Set name="monitoredDirName"><SystemProperty name="jetty.home" />/webapps</Set>
|
||||
<Set name="scanInterval">1</Set>
|
||||
<Set name="configurationManager">
|
||||
<New class="org.eclipse.jetty.deploy.FileConfigurationManager">
|
||||
<New class="org.eclipse.jetty.deploy.PropertiesConfigurationManager">
|
||||
<Set name="file">
|
||||
<SystemProperty name="jetty.home"/>/xml-configured-jetty.properties
|
||||
</Set>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<Set name="monitoredDirName"><SystemProperty name="jetty.home" />/webapps</Set>
|
||||
<Set name="scanInterval">1</Set>
|
||||
<Set name="configurationManager">
|
||||
<New class="org.eclipse.jetty.deploy.FileConfigurationManager">
|
||||
<New class="org.eclipse.jetty.deploy.PropertiesConfigurationManager">
|
||||
<Set name="file">
|
||||
<SystemProperty name="jetty.home"/>/xml-configured-jetty.properties
|
||||
</Set>
|
||||
|
|
|
@ -81,8 +81,6 @@ public class ClasspathPattern
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Initialize the matcher by parsing each classpath pattern in an array
|
||||
*
|
||||
* @param patterns array of classpath patterns
|
||||
*/
|
||||
private void addPatterns(String[] patterns)
|
||||
|
@ -93,7 +91,8 @@ public class ClasspathPattern
|
|||
for (String pattern : patterns)
|
||||
{
|
||||
entry = createEntry(pattern);
|
||||
if (entry != null) {
|
||||
if (entry != null)
|
||||
{
|
||||
_patterns.add(pattern);
|
||||
_entries.add(entry);
|
||||
}
|
||||
|
@ -101,6 +100,29 @@ public class ClasspathPattern
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param patterns array of classpath patterns
|
||||
*/
|
||||
private void prependPatterns(String[] patterns)
|
||||
{
|
||||
if (patterns != null)
|
||||
{
|
||||
Entry entry = null;
|
||||
int i=0;
|
||||
for (String pattern : patterns)
|
||||
{
|
||||
entry = createEntry(pattern);
|
||||
if (entry != null)
|
||||
{
|
||||
_patterns.add(i,pattern);
|
||||
_entries.add(i,entry);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Create an entry object containing information about
|
||||
|
@ -156,9 +178,24 @@ public class ClasspathPattern
|
|||
patterns.add(entries.nextToken());
|
||||
}
|
||||
|
||||
addPatterns((String[])patterns.toArray(new String[patterns.size()]));
|
||||
addPatterns(patterns.toArray(new String[patterns.size()]));
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void prependPattern(String classOrPackage)
|
||||
{
|
||||
ArrayList<String> patterns = new ArrayList<String>();
|
||||
StringTokenizer entries = new StringTokenizer(classOrPackage, ":,");
|
||||
while (entries.hasMoreTokens())
|
||||
{
|
||||
patterns.add(entries.nextToken());
|
||||
}
|
||||
|
||||
prependPatterns(patterns.toArray(new String[patterns.size()]));
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return array of classpath patterns
|
||||
|
@ -217,4 +254,5 @@ public class ClasspathPattern
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
"-org.eclipse.jetty.jndi.", // don't hide naming classes
|
||||
"-org.eclipse.jetty.jaas.", // don't hide jaas classes
|
||||
"-org.eclipse.jetty.websocket.", // WebSocket is a jetty extension
|
||||
"-org.eclipse.jetty.servlets.", // don't hide jetty servlets
|
||||
"-org.eclipse.jetty.servlet.DefaultServlet", // don't hide default servlet
|
||||
"-org.eclipse.jetty.servlet.listener.", // don't hide useful listeners
|
||||
"org.eclipse.jetty." // hide other jetty classes
|
||||
|
@ -650,12 +651,38 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
return _serverClasses.getPatterns();
|
||||
}
|
||||
|
||||
public void addServerClass(String classname)
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Add to the list of Server classes.
|
||||
* @see #setServerClasses(String[])
|
||||
* @param classOrPackage A fully qualified class name (eg com.foo.MyClass)
|
||||
* or a qualified package name ending with '.' (eg com.foo.). If the class
|
||||
* or package has '-' it is excluded from the server classes and order is thus
|
||||
* important when added system class patterns. This argument may also be a comma
|
||||
* separated list of classOrPackage patterns.
|
||||
*/
|
||||
public void addServerClass(String classOrPackage)
|
||||
{
|
||||
if (_serverClasses == null)
|
||||
loadServerClasses();
|
||||
|
||||
_serverClasses.addPattern(classname);
|
||||
_serverClasses.addPattern(classOrPackage);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Prepend to the list of Server classes.
|
||||
* @see #setServerClasses(String[])
|
||||
* @param classOrPackage A fully qualified class name (eg com.foo.MyClass)
|
||||
* or a qualified package name ending with '.' (eg com.foo.). If the class
|
||||
* or package has '-' it is excluded from the server classes and order is thus
|
||||
* important when added system class patterns. This argument may also be a comma
|
||||
* separated list of classOrPackage patterns.
|
||||
*/
|
||||
public void prependServerClass(String classOrPackage)
|
||||
{
|
||||
if (_serverClasses == null)
|
||||
loadServerClasses();
|
||||
|
||||
_serverClasses.prependPattern(classOrPackage);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -673,12 +700,38 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void addSystemClass(String classname)
|
||||
/** Add to the list of System classes.
|
||||
* @see #setSystemClasses(String[])
|
||||
* @param classOrPackage A fully qualified class name (eg com.foo.MyClass)
|
||||
* or a qualified package name ending with '.' (eg com.foo.). If the class
|
||||
* or package has '-' it is excluded from the system classes and order is thus
|
||||
* important when added system class patterns. This argument may also be a comma
|
||||
* separated list of classOrPackage patterns.
|
||||
*/
|
||||
public void addSystemClass(String classOrPackage)
|
||||
{
|
||||
if (_systemClasses == null)
|
||||
loadSystemClasses();
|
||||
|
||||
_systemClasses.addPattern(classname);
|
||||
_systemClasses.addPattern(classOrPackage);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Prepend to the list of System classes.
|
||||
* @see #setSystemClasses(String[])
|
||||
* @param classOrPackage A fully qualified class name (eg com.foo.MyClass)
|
||||
* or a qualified package name ending with '.' (eg com.foo.). If the class
|
||||
* or package has '-' it is excluded from the system classes and order is thus
|
||||
* important when added system class patterns.This argument may also be a comma
|
||||
* separated list of classOrPackage patterns.
|
||||
*/
|
||||
public void prependSystemClass(String classOrPackage)
|
||||
{
|
||||
if (_systemClasses == null)
|
||||
loadSystemClasses();
|
||||
|
||||
_systemClasses.prependPattern(classOrPackage);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -159,6 +159,7 @@
|
|||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlets</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
|
@ -169,6 +170,7 @@
|
|||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
|
|
|
@ -31,10 +31,6 @@ import javax.servlet.http.HttpServletRequestWrapper;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Test Servlet RequestDispatcher.
|
||||
*
|
||||
|
@ -43,8 +39,6 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
@SuppressWarnings("serial")
|
||||
public class DispatchServlet extends HttpServlet
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(DispatchServlet.class);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
String pageType;
|
||||
|
||||
|
@ -165,7 +159,7 @@ public class DispatchServlet extends HttpServlet
|
|||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
LOG.ignore(e);
|
||||
// getServletContext().log("ignore",e);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -53,10 +53,6 @@ import javax.servlet.http.HttpServletResponseWrapper;
|
|||
import org.eclipse.jetty.continuation.Continuation;
|
||||
import org.eclipse.jetty.continuation.ContinuationListener;
|
||||
import org.eclipse.jetty.continuation.ContinuationSupport;
|
||||
import org.eclipse.jetty.http.HttpHeader;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* Dump Servlet Request.
|
||||
|
@ -64,8 +60,6 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
@SuppressWarnings("serial")
|
||||
public class Dump extends HttpServlet
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(Dump.class);
|
||||
|
||||
boolean fixed;
|
||||
Timer _timer;
|
||||
|
||||
|
@ -162,7 +156,7 @@ public class Dump extends HttpServlet
|
|||
try
|
||||
{
|
||||
long s = Long.parseLong(request.getParameter("sleep"));
|
||||
if (request.getHeader(HttpHeader.EXPECT.asString())!=null && request.getHeader(HttpHeader.EXPECT.asString()).indexOf("102")>=0)
|
||||
if (request.getHeader("Expect")!=null && request.getHeader("Expect").indexOf("102")>=0)
|
||||
{
|
||||
Thread.sleep(s/2);
|
||||
response.sendError(102);
|
||||
|
@ -232,6 +226,7 @@ public class Dump extends HttpServlet
|
|||
|
||||
continuation.addContinuationListener(new ContinuationListener()
|
||||
{
|
||||
@Override
|
||||
public void onTimeout(Continuation continuation)
|
||||
{
|
||||
response.addHeader("Dump","onTimeout");
|
||||
|
@ -246,10 +241,11 @@ public class Dump extends HttpServlet
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOG.ignore(e);
|
||||
getServletContext().log("",e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(Continuation continuation)
|
||||
{
|
||||
response.addHeader("Dump","onComplete");
|
||||
|
@ -1004,9 +1000,9 @@ public class Dump extends HttpServlet
|
|||
{
|
||||
if (s==null)
|
||||
return "null";
|
||||
s=StringUtil.replace(s,"&","&");
|
||||
s=StringUtil.replace(s,"<","<");
|
||||
s=StringUtil.replace(s,">",">");
|
||||
s=s.replaceAll("&","&");
|
||||
s=s.replaceAll("<","<");
|
||||
s=s.replaceAll(">",">");
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,6 @@ import org.eclipse.jetty.util.log.Logger;
|
|||
*/
|
||||
public class LoginServlet extends HttpServlet
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(SecureModeServlet.class);
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException
|
||||
|
@ -63,7 +61,6 @@ public class LoginServlet extends HttpServlet
|
|||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
|
||||
{
|
||||
|
||||
response.setContentType("text/html");
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
out.println("<html>");
|
||||
|
|
|
@ -47,8 +47,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.util.FutureCallback;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.core.annotations.OnWebSocketClose;
|
||||
import org.eclipse.jetty.websocket.core.annotations.OnWebSocketConnect;
|
||||
import org.eclipse.jetty.websocket.core.annotations.OnWebSocketMessage;
|
||||
|
@ -63,8 +61,6 @@ import org.eclipse.jetty.websocket.server.WebSocketServlet;
|
|||
@SuppressWarnings("serial")
|
||||
public class WebSocketChatServlet extends WebSocketServlet implements WebSocketCreator
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebSocketChatServlet.class);
|
||||
|
||||
/** Holds active sockets to other members of the chat */
|
||||
private final List<ChatWebSocket> members = new CopyOnWriteArrayList<ChatWebSocket>();
|
||||
|
||||
|
@ -131,7 +127,7 @@ public class WebSocketChatServlet extends WebSocketServlet implements WebSocketC
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOG.warn(e);
|
||||
getServletContext().log("write failed",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ org.eclipse.jetty.servlet.WebApplicationContext object
|
|||
-->
|
||||
|
||||
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
|
||||
<Call name="prependServerClass"><Arg>-org.eclipse.jetty.util.</Arg></Call>
|
||||
<Call name="prependServerClass"><Arg>-org.eclipse.jetty.servlets.</Arg></Call>
|
||||
<Get class="org.eclipse.jetty.util.log.Log" name="rootLogger">
|
||||
<Call name="warn"><Arg>test webapp is deployed. DO NOT USE IN PRODUCTION!</Arg></Call>
|
||||
</Get>
|
||||
|
|
|
@ -165,7 +165,7 @@ public class TestServer
|
|||
server.setSendServerVersion(true);
|
||||
|
||||
WebAppContext webapp = new WebAppContext();
|
||||
webapp.setParentLoaderPriority(true);
|
||||
//webapp.setParentLoaderPriority(true);
|
||||
webapp.setResourceBase("./src/main/webapp");
|
||||
webapp.setAttribute("testAttribute","testValue");
|
||||
File sessiondir=File.createTempFile("sessions",null);
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
<Set name="configurationDir"><Property name="test.resourcesdir" default="src/test/resources"/>/webapp-contexts/RFC2616</Set>
|
||||
<Set name="scanInterval">0</Set>
|
||||
<Set name="configurationManager">
|
||||
<New class="org.eclipse.jetty.deploy.FileConfigurationManager">
|
||||
<New class="org.eclipse.jetty.deploy.PropertiesConfigurationManager">
|
||||
<Set name="file"><Property name="test.targetdir" default="target"/>/testable-jetty-server-config.properties</Set>
|
||||
</New>
|
||||
</Set>
|
||||
|
|
Loading…
Reference in New Issue