Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 331245

Summary: No argument constructor and setter methods removed from ResourceCollection
Product: [RT] Jetty Reporter: Nils Breunese <nils>
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: jetty-inbox, owen+findbugs, sdavids
Version: 7.2.1   
Target Milestone: 7.1.x   
Hardware: All   
OS: All   
Whiteboard:

Description Nils Breunese CLA 2010-11-26 16:11:05 EST
Build Identifier: 

Between Jetty 7.2.0.v20101020 and 7.2.1.v20101111 the org.eclipse.jetty.util.resource.ResourceCollection class apparently lost its no argument constructor and setter methods.

The API docs confirm this:

http://download.eclipse.org/jetty/7.2.0.v20101020/apidocs/org/eclipse/jetty/util/resource/ResourceCollection.html
http://download.eclipse.org/jetty/7.2.1.v20101111/apidocs/org/eclipse/jetty/util/resource/ResourceCollection.html

Diff of the API:

----
-ResourceCollection()
-ResourceCollection(Resource[] resources)
+ResourceCollection(Resource... resources)
-void setResources(Resource[] resources) 
-void setResources(String csvResources) 
-void setResources(String[] resources) 
-void setResourcesAsCSV(String csvResources)
----

The missing no argument constructor and setter methods cause the following block of Maven pom.xml to fail in one of my projects using jetty-maven-plugin when trying to upgrade to Jetty 7.2.1.v20101111:

----
<baseResource implementation="org.eclipse.jetty.util.resource.ResourceCollection">
  <resourcesAsCSV>
    /path/to/profile-specific-dir,
    /path/to/another-dir
  </resourcesAsCSV>
</baseResource>
----

I wouldn't mind changing this block of XML, but since the no argument constructor and setter methods have been removed I have no idea how to change my code. If anyone else does, I'd be happy to hear about that.

Also I think such an API change should not happen in a minor release update.

Reproducible: Always
Comment 1 Greg Wilkins CLA 2010-11-26 17:04:34 EST
Nils,

my bad.  Should not have changed that.

I was concerned that resources instances should be immutable and fixed it with my 7.1 to 7.2 mind set still working.

Now that I have broken it, I rather not simply revert back (unless there are many other uses of it).

I'll research that maven XML syntax and see if it can call a static factory method rather than a setter.
Comment 2 Greg Wilkins CLA 2010-12-01 12:09:20 EST
I'm adding a convenience method on the jetty maven plugin so that you can now do:

            <resourceBases>
              <resourceBase>/tmp</resourceBase>
              <resourceBase>/home/gregw</resourceBase>
            </resourceBases>

and not have to create a resource collection directly.

r6280

will be in next release.
Comment 3 Nils Breunese CLA 2010-12-01 13:10:14 EST
So the setter method that accept a list of resources will stay gone? I have a bunch of resource paths that are shared between a couple of Maven profiles, so I store those paths in a property and currently use this with Jetty 7.2.0:

----
<resourcesAsCSV>
  /path/to/profile/specific/dir,
  ${commonResources>
<resourcesAsCSV>
----

This doesn't work with Jetty 7.2.1 since the setter methods have disappeared and I also don't see how I can get something similar to work with your new proposed method.
Comment 4 Greg Wilkins CLA 2010-12-01 13:33:02 EST
I'd like to keep the setter methods gone.  It was bad to remove them in a point release, but the reason for their removal is valid - Resources should be immutable.

I'll modify the convenience method so it will also look for CSV within each value, so you will be able to do:

            <resourceBases>
              <resourceBase>/tmp</resourceBase>
              <resourceBase>${some-csv-list}</resourceBase>
            </resourceBases>

Will that work for you?
Comment 5 Nils Breunese CLA 2010-12-01 13:38:23 EST
Yes, great, that would certainly work for me.

I'm not sure if the naming of the elements still makes sense in that case (multiple resource bases in a single resourceBase element). If you're going to support CSV anyway I'd expect something like:

----
<resourceBases>/tmp,${some-csv-list}</resourceBases>
----
Comment 6 Nils Breunese CLA 2011-01-05 08:47:27 EST
I see 7.2.2.v20101205 was released last month. Any news on progress of providing a new way of setting the resource paths from Maven configuration for scanning? Or will we need to stick with 7.2.0.v20101020 since that is the last version which has the setResourcesAsCSV method on the ResourceCollection class?
Comment 7 Sebastian Davids CLA 2011-02-09 10:22:14 EST
Please document the changes AND the working solution(s) on:

http://docs.codehaus.org/display/JETTY/Multiple+WebApp+Source+Directory