Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-deploy')
-rw-r--r--jetty-deploy/src/main/config/etc/jetty-deploy.xml10
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/PropertiesConfigurationManager.java (renamed from jetty-deploy/src/main/java/org/eclipse/jetty/deploy/FileConfigurationManager.java)56
-rw-r--r--jetty-deploy/src/test/resources/binding-test-contexts-1.xml2
-rw-r--r--jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml2
4 files changed, 49 insertions, 21 deletions
diff --git a/jetty-deploy/src/main/config/etc/jetty-deploy.xml b/jetty-deploy/src/main/config/etc/jetty-deploy.xml
index 5316b500dd..9b42604d6d 100644
--- a/jetty-deploy/src/main/config/etc/jetty-deploy.xml
+++ b/jetty-deploy/src/main/config/etc/jetty-deploy.xml
@@ -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>
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/FileConfigurationManager.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/PropertiesConfigurationManager.java
index 076dafe93f..8cb5c344e8 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/FileConfigurationManager.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/PropertiesConfigurationManager.java
@@ -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 PropertiesConfigurationManager()
{
}
- public void setFile(String filename) throws MalformedURLException, IOException
+ @ManagedAttribute("A file or URL of properties")
+ public void setFile(String resource) throws MalformedURLException, IOException
{
- _file = Resource.newResource(filename);
+ _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
- {
- if (_map.isEmpty() && _file!=null)
+ private void loadProperties(String resource) throws FileNotFoundException, IOException
+ {
+ 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()));
}
diff --git a/jetty-deploy/src/test/resources/binding-test-contexts-1.xml b/jetty-deploy/src/test/resources/binding-test-contexts-1.xml
index 1614056f43..37f5292ff2 100644
--- a/jetty-deploy/src/test/resources/binding-test-contexts-1.xml
+++ b/jetty-deploy/src/test/resources/binding-test-contexts-1.xml
@@ -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>
diff --git a/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml b/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml
index acf69585ff..ba38daef80 100644
--- a/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml
+++ b/jetty-deploy/src/test/resources/jetty-deploymgr-contexts.xml
@@ -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>

Back to the top