New book recommendation

2009-02-16 Thread Jerome Louvel
Hi all,
 
Following the kind advice from Tim Peierls and a few others, I've recently 
ordered the famous book from Joshua Bloch: "Effective
Java (2nd edition)" and found it to be an excellent read. 
 
 forces you to confront your Java developer habits with proven best practices. 
I initially thought that I would likely disagree with
a few recommendations but in the end I agreed with all of them. Care was taken 
to make the rules flexible based on their usage
context.
 
Of course, like the reading of "Java Concurrency in Practice" it gave me some 
additional homework to do on the Restlet API :)  I've
listed them in this new RFE:
 
"Apply 'Effective Java' rules"
http://restlet.tigris.org/issues/show_bug.cgi?id=731
 
Finally, I've added the book as a new recommendation on the Restlet site:
http://www.restlet.org/documentation/books
 
Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~   
http://www.restlet.org
Noelios Technologies ~ Co-founder ~   
http://www.noelios.com

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

Re: SpringBeanRouter enhancement

2009-02-16 Thread Rhett Sutphin
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:
>
>  
>
> 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,
>  scope="prototype" class="..."> 
>
> 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


Re: Request Session

2009-02-16 Thread Rob Heittman
The server-side session concept is not part of the REST architectural style
and makes it impossible to achieve many of the benefits of REST (for
example, being able to swap a client on the fly from server to server in a
cluster without sharing or transferring server side state).  Getting
parameters off the query string and putting them in the session sounds like
a practice that the Servlet model covers well ... I'm not sure what value
Restlet adds to this kind of design.
Still, to interoperate with some JEE code where you really need this
ability, first -- run in a JEE container using ServerServlet, and second,
use ServletCall.getRequest(restletRequest) to access the HttpServletRequest.
 From there you should be able to "talk" to the JEE Servlet API and
interoperate with the Session.

Here's a thread where somebody had a valid use case to do just that:

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

- Rob

On Mon, Feb 16, 2009 at 8:28 AM, Ruben Hernando wrote:

>
> Hi!
>
> I need some equivalent to the traditional *HttpServletRequest*.getSession(),
> because I'd have to insert some parameters into the session. *
> org.restlet.Handler.getRequest()* does'nt implement any "getSession()"
> method, so I need a way to do it.
>
> thanks

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

Request Session

2009-02-16 Thread Ruben Hernando
Hi!

I need some equivalent to the traditional HttpServletRequest.getSession(), 
because I'd have to insert some parameters into the session. 
org.restlet.Handler.getRequest() does'nt implement any "getSession()" 
method, so I need a way to do it.

thanks

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

Re: MediaType: should application/xml be compatible with application/*+xml?

2009-02-16 Thread Thierry Boileau
Hello,

I agree with you, I think it should be true. I've just fixed the svn 
repository.
Thank you for the report.

best regards,
Thierry Boileau

> Hi,
>
> As title, should mediatype application/xml be compatible with 
> application/*+xml?
>
> I thought it should be true, but In MediaType.includes method 
> (1.2-M1), it says:
>
> } else if (getSubType().startsWith("*+")
> && included.getSubType().endsWith(
> getSubType().substring(1))) {
> result = true;
> }
>
> Ans seems to me the answer is false.
>
> Which should be the correct answer?
>
> -- 
> Cheers,
> Keke
> -
> We paranoid love life

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