Hi Rhett, It looks like a good/simple enhancement to me as well. I would suggest to directly update SVN trunk in this case?
If you copy & paste the code snippet, we need Daniel to send a signed JCA... As it is quite straightforward, I would suggest coding the logic yourself again from scratch. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -----Message d'origine----- De : Rhett Sutphin [mailto:rh...@detailedbalance.net] Envoye : lundi 16 fevrier 2009 16:37 A : discuss@restlet.tigris.org Objet : Re: SpringBeanRouter enhancement Hi Daniel, This is a reasonable fix. Can you open a ticket in the issue tracker? If you'd care to submit a patch with unit tests, that would be even better. Thanks, Rhett On Feb 16, 2009, at 12:50 AM, Daniel Woo wrote: > Hi guys, > > The SpringBeanRouter.resolveUri() method in 1.1.1 has a potential > problem, if you specify restlet in Spring configuration file without > an id like this way: > > <bean name="/product-folders" scope="prototype" class="..."> </bean> > > Your BeanFinder will never be attached the URI "/product-folders". > The reason is that the resolveUri() method tries to get name and > other aliases from id, see the code below > > protected String resolveUri(String resourceName, > ConfigurableListableBeanFactory factory) { > for (final String alias : factory.getAliases(resourceName)) { > if (alias.startsWith("/")) { > return alias; > } > } > > return null; > } > > if you don't specify and ID in the Spring configuration file > factory.getAliases(resourceName) will return null when the passed in > resourceName is actually the bean name. > To workaround this, you have to specify an ID for each restlet, eg, > <bean id="_product-folders" name="/product-folders" > scope="prototype" class="..."> </bean> > > Note, the id cannot be the same as the name because XML id cannot > contain characters in URI like "/" or "{id}". Also, it's troublesome > to specify id for each bean. So, how can I just simply specify name > without IDs? > > I made it by changing resolveUri as below > > protected String resolveUri(String resourceName, > ApplicationContext factory) { > String aliasName = null; > if (resourceName.startsWith("/")) { > aliasName = resourceName; > } else { > for (final String alias : > factory.getAliases(resourceName)) { > if (alias.startsWith("/")) { > aliasName = alias; > break; > } > } > } > logger.debug("resolveUri: alias=" + aliasName); > return aliasName; > } > > I first check resourceName, if you don't specify an ID, bean name > will be passed in as resourceName, in this case, just return the > beanName if it starts with a slash. > If you specify an ID, bean id will be passed in, then getAliases() > will return the beanName of that id. it's done. > > Tested with 1.1.1 > > What do you guys think? > > Regards, > Daniel > > ------------------------------------------------------ > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1169062 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1171440 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1186265