History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEADEV-13534
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Dmitry Avdeev
Reporter: Taras Tielkes
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
IDEA: Development

Support for "Resource" properties / "classpath:..." syntax

Created: 20 Jan 07 01:02   Updated: 28 Feb 07 13:08
Component/s: J2EE.Spring
Fix Version/s: Selena 6733

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 6,656
Fixed in build: 6,732
Severity: High


 Description  « Hide
For an introduction, see http://static.springframework.org/spring/docs/2.0.x/reference/resources.html
In particular, check section 4.6: Resources as dependencies

When a property/constructor argument is of type Resource, the string value assigned should be treated in a special way:
A value "classpath:some/resource/path/myTemplate.txt" should resolve to a project classpath resource.



 All   Comments   Work Log   Change History      Sort Order:
Taras Tielkes - 20 Jan 07 01:07
IDEA should also recognize Resource[] type. For instance, the project I have open right now has a bean that takes Resource[] as a constructor argument, and has a context declaration similar to:
...
    <constructor-arg>
      <list>
        <value>classpath:/definitions/small.xml</value>
        <value>classpath:/definitions/expanded.xml</value>
      </list>
    </constructor-arg>
...

Taras Tielkes - 26 Jan 07 21:39
Apart from full resolving (which would be very nice), injection of Resource properties is actually a "good code red" issue at the moment.

Dmitry Avdeev - 30 Jan 07 17:11
What code is red in your example?

Taras Tielkes - 30 Jan 07 17:27
Dmitry, here is minimal "good code red" sample (using #6667)
import org.springframework.core.io.Resource;

public class FooBar {
    public FooBar(Resource resource) {}
}
...
  <bean id="fooBar" class="foo.test.FooBar">
    <constructor-arg value="classpath:/test/config.abc"/>
  </bean>
...

Bean definition is marked with "No matching constructor found is class FooBar" warning. (Because IDEA thinks I want to assign java.lang.String type to org.springframework.core.io.Resource type?)

Spring by default registers PropertyEditors for Resource and Resource[] types to use during context parsing. These take care of conversion between String/String[] and Resource/Resource[].