355162 Allow creating an empty resource collection
This commit is contained in:
parent
64605e9129
commit
0720ba9c04
|
@ -29,6 +29,7 @@ jetty-7.5.0.RC0 - 15 August 2011
|
||||||
+ 354204 Charset encodings property file not used
|
+ 354204 Charset encodings property file not used
|
||||||
+ 354397 RewriteRegexRule handles special characters in regex group
|
+ 354397 RewriteRegexRule handles special characters in regex group
|
||||||
+ 354466 Typo in example config of jetty-plus.xml
|
+ 354466 Typo in example config of jetty-plus.xml
|
||||||
|
+ 355162 Allow creating an empty resource collection
|
||||||
|
|
||||||
jetty-7.4.4.v20110707 - 07 July 2011
|
jetty-7.4.4.v20110707 - 07 July 2011
|
||||||
+ 308851 Converted all jetty-client module tests to JUnit 4
|
+ 308851 Converted all jetty-client module tests to JUnit 4
|
||||||
|
|
|
@ -39,9 +39,25 @@ import org.eclipse.jetty.util.URIUtil;
|
||||||
*/
|
*/
|
||||||
public class ResourceCollection extends Resource
|
public class ResourceCollection extends Resource
|
||||||
{
|
{
|
||||||
private final Resource[] _resources;
|
private Resource[] _resources;
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* Instantiates an empty resource collection.
|
||||||
|
*
|
||||||
|
* This constructor is used when configuring jetty-maven-plugin.
|
||||||
|
*/
|
||||||
|
public ResourceCollection()
|
||||||
|
{
|
||||||
|
_resources = new Resource[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* Instantiates a new resource collection.
|
||||||
|
*
|
||||||
|
* @param resources the resources to be added to collection
|
||||||
|
*/
|
||||||
public ResourceCollection(Resource... resources)
|
public ResourceCollection(Resource... resources)
|
||||||
{
|
{
|
||||||
List<Resource> list = new ArrayList<Resource>();
|
List<Resource> list = new ArrayList<Resource>();
|
||||||
|
@ -67,6 +83,11 @@ public class ResourceCollection extends Resource
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* Instantiates a new resource collection.
|
||||||
|
*
|
||||||
|
* @param resources the resource strings to be added to collection
|
||||||
|
*/
|
||||||
public ResourceCollection(String[] resources)
|
public ResourceCollection(String[] resources)
|
||||||
{
|
{
|
||||||
_resources = new Resource[resources.length];
|
_resources = new Resource[resources.length];
|
||||||
|
@ -90,12 +111,55 @@ public class ResourceCollection extends Resource
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* Instantiates a new resource collection.
|
||||||
|
*
|
||||||
|
* @param csvResources the string containing comma-separated resource strings
|
||||||
|
*/
|
||||||
public ResourceCollection(String csvResources)
|
public ResourceCollection(String csvResources)
|
||||||
|
{
|
||||||
|
setResourcesAsCSV(csvResources);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* Retrieves the resource collection's resources.
|
||||||
|
*
|
||||||
|
* @return the resource array
|
||||||
|
*/
|
||||||
|
public Resource[] getResources()
|
||||||
|
{
|
||||||
|
return _resources;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* Sets the resource collection's resources.
|
||||||
|
*
|
||||||
|
* @param resources the new resource array
|
||||||
|
*/
|
||||||
|
public void setResources(Resource[] resources)
|
||||||
|
{
|
||||||
|
_resources = resources != null ? resources : new Resource[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/**
|
||||||
|
* Sets the resources as string of comma-separated values.
|
||||||
|
* This method should be used when configuring jetty-maven-plugin.
|
||||||
|
*
|
||||||
|
* @param csvResources the comma-separated string containing
|
||||||
|
* one or more resource strings.
|
||||||
|
*/
|
||||||
|
public void setResourcesAsCSV(String csvResources)
|
||||||
{
|
{
|
||||||
StringTokenizer tokenizer = new StringTokenizer(csvResources, ",;");
|
StringTokenizer tokenizer = new StringTokenizer(csvResources, ",;");
|
||||||
int len = tokenizer.countTokens();
|
int len = tokenizer.countTokens();
|
||||||
if(len==0)
|
if(len==0)
|
||||||
throw new IllegalArgumentException("arg *resources* must be one or more resources.");
|
{
|
||||||
|
throw new IllegalArgumentException("ResourceCollection@setResourcesAsCSV(String) " +
|
||||||
|
" argument must be a string containing one or more comma-separated resource strings.");
|
||||||
|
}
|
||||||
|
|
||||||
_resources = new Resource[len];
|
_resources = new Resource[len];
|
||||||
try
|
try
|
||||||
|
@ -113,23 +177,6 @@ public class ResourceCollection extends Resource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return the resource array
|
|
||||||
*/
|
|
||||||
public Resource[] getResources()
|
|
||||||
{
|
|
||||||
return _resources;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
@Deprecated
|
|
||||||
public void setResources(Resource[] resources)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("ResourceCollection@setResources(Resource[])");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @param path The path segment to add
|
* @param path The path segment to add
|
||||||
|
|
Loading…
Reference in New Issue