Hi Jorge,

Normally, you shouldn't embed a Directory inside a ServerResource but
directly attach it to your SpringBeanRouter.
To not have to use the {imageId} path variable (for your file names I
guess), you can set the route's matchingMode to Template.STARTS_WITH. I'm
not sure exactly how to do it with SpringBeanRouter, but with a regular
router you would do this:

    myRouter.attach("/v1/images/",
myDirectory).setMatchingMode(Template.STARTS_WITH).

Thanks,
Jerome
--
http://restlet.com
@jlouvel <http://twitter.com/#!/jlouvel>




On Thu, May 29, 2014 at 1:48 PM, Jorge Gallardo <jorgeagalla...@gmail.com>wrote:

> Hello all,
>
> Im trying to serve static content from the filesystem but I cant. I was
> able to do it with a plain and simple Reslet application but not using
> SpringBeanRouter.
> Here is the code:
>
>
> @Component("/v1/images/{imageId}")
>
> @Scope("prototype")
>
> public class ImagesResource extends DirectoryServerResource {
>
> private String imageId;
>
> @Override
>
> public void doInit() throws ResourceException {
>
>  Directory directory = new Directory(getContext(),
>
>  "file:///path/images");
>
>  getRequestAttributes().put("org.restlet.directory", directory);
>
>  super.doInit();
>
> }
>
> }
> And here the xml mapping:
>
>  <bean id="restletComponent" class=
> "org.restlet.ext.spring.SpringComponent">
>
>  <property name="defaultTarget" ref="restletApplication" />
>
>  <property name="clientsList">
>
>  <list>
>
>   <value>CLAP</value>
>
>   <value>FILE</value>
>
>  </list>
>
>  </property>
>
> </bean>
>
> <bean id="restletApplication" class="org.restlet.ext.wadl.WadlApplication"
>
>  scope="singleton">
>
>  <property name="name" value="REST API" />
>
>  <property name="inboundRoot" ref="ServerHeaderFilter" />
>
>  <property name="encoderService.enabled" value="true" />
>
> </bean>
>
>  <bean name="springRouter" class="org.restlet.ext.spring.SpringBeanRouter"
> />
>
>
> Im facing two issues:
>
> 1- the URL mapping. If i use "/v1/images", SpringBeanRouter does not match
> it, so I went for "/v1/images/{imageId}"
>
> 2- If i dont put the Directory in the map, I get a NullPointerException.
> It looks odd, is there any other/better way of doing it?
>
> Thanks!
> --
> Jorge Gallardo
> ----------------------------------------
> jorgeagalla...@gmail.com
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3079544

Reply via email to