RE: Spring-loaded Restlets with Context dependencies

2009-05-17 Thread Jerome Louvel
Hi Dustin,

Thanks for reporting your solution and for the support! I'm sure it will help 
others.  

Regarding the WAR client, it is normally automatically added by the 
ServerServlet#createComponent() method, which is invoked at the end of 
SpringServerServlet#createComponent. No need to declare it anymore.

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 : Dustin N. Jenkins [mailto:dustin.jenk...@nrc-cnrc.gc.ca] 
Envoyé : vendredi 15 mai 2009 21:15
À : discuss@restlet.tigris.org
Objet : Re: Spring-loaded Restlets with Context dependencies

I solved this for the most part.  I'm using the 
org.springframework.beans.factory.config.PropertyPathFactoryBean class 
to provide a Context to my component, which is now defined in Spring:

!-- Component.  This will be loaded by the Servlet according to the 
web.xml definition of org.restlet.component --
  bean name=component class=org.restlet.ext.spring.SpringComponent
property name=defaultTarget ref=application /
property name=context ref=component.context /
property name=clientsList
  list
valuehttp/value
valuefile/value
  /list
/property
  /bean

!-- Context --
  bean name=component.context

class=org.springframework.beans.factory.config.PropertyPathFactoryBean /

I had to override the SpringServerServlet.createComponent() method to 
add a ServletWARClient to the Spring loaded component since simply 
declaring 'war' in the clientsList is not sufficient.  The 
ServletContext is required to build one of those Clients.  I need the 
WAR protocol to load my FreeMarker Templates from my WAR, as well as my 
CSS and JavaScript files.

I hope I did this in the best way possible and didn't miss something 
simple that prevented me from doing the extra work.  Maybe this will 
help someone else!

Thanks to the Restlet team for everything.  I am enjoying myself none 
the less.
Dustin





Dustin N. Jenkins wrote:
 All,

 I'm using the 1.2 (2.0) snapshot with JDK 1.6.

 All of my beans are loaded by Spring.  This is working really lovely for 
 the most part, except for any bean that relies on the Context to be 
 passed in.  How do we create ChallengeGuards, for example, in Spring, 
 when we don't have a Context to pass to it?

 I used to override the default Constructor to use a Restlet instead of a 
 Context, which would act as a Parent and I could call getContext() from 
 that bean.  That Parent bean used to be the Application, which is 
 initialized by the SpringServerServlet.  The problem is that Spring is 
 loading in all the beans first, which means the Parent's Context is 
 null, which used to be alright prior to 2.0.

 What is the solution for this problem?  Do I need to create a Spring 
 Component around my Application?  I don't use a Component now, only an 
 Application.

 Thanks!
 Dustin
   

-- 


Dustin N. Jenkins | Tel/Tél: 250.363.3101 | dustin.jenk...@nrc-cnrc.gc.ca

facsimile/télécopieur: (250) 363-0045

National Research Council Canada | 5071 West Saanich Rd, Victoria BC. 
V9E 2E7

Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria 
(C.-B) V9E 2E7

Government of Canada | Gouvernement du Canada

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

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


RE: Re: UnsupportedOperationException in DomRepresentation constructor

2009-05-17 Thread Jerome Louvel
Hi Mikis,

Thanks for reporting this, I've added a check in the code. It seems that
your JAXP parser doesn't support XInclude. The Javadocs does mention this
case. Checked in SVN trunk.

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 : webp...@tigris.org [mailto:webp...@tigris.org] 
Envoyé : mardi 5 mai 2009 09:30
À : discuss@restlet.tigris.org
Objet : RE: Re: UnsupportedOperationException in DomRepresentation
constructor

Hi Thierry

Source for the revision of the class where the problem occurred can be found
here:
http://fisheye.agilos.org/browse/~raw,r=36/Agilos/zendesk-jira-plugin/trunk/
src/main/java/org/agilos/jira/zendesk/NotificationDispatcher.java. 

The class is part of a JIRA plugin, so the full classpath is a rather
complex affair, a list of the plugin dependencies can be found here:
http://zendesk-jira-plugin.agilos.org/0.6/dependencies.html.

Note: I have in later versions of the NotificationDispatcher switched to a
javax.xml.parsers.DocumentBuilder constructed DOM document as a workaround.

/Mikis

 Hello Mikis,
 
 could you provide some sample code?
 I send you mine which works well with the org.restlet.jar of the 1.2M2 
 release (no other dependency in the classpath).
 
 best regards,
 Thierry Boileau
 
  Hi
 
  I'm try to create a DomRepresentation with the new
  DomRepresentation(MediaType) constructor in Restlet 1.2-M2.2, which
causes
  the following stacktrace: 
 
  java.lang.UnsupportedOperationException: This parser does not support
  specification null version null
  at
 
javax.xml.parsers.DocumentBuilderFactory.setXIncludeAware(DocumentBuilderFac
tory.java:590)
  at
 
org.restlet.representation.XmlRepresentation.getDocumentBuilder(XmlRepresent
ation.java:256)
  at
 
org.restlet.representation.DomRepresentation.init(DomRepresentation.java:7
6)
  .
 
  The reason for the exception is that the
  DocumentBuilderFactory.setXIncludeAware hasn't been overridden and
therefore
  uses the default implementation which throws the
  UnsupportedOperationException.
 
  Am I doing something wrong, or is this a Restlet bug?
 
  Mikis
 

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

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


RE: Creating multiple components on Tomcat

2009-05-17 Thread Jerome Louvel
Hi Tamer,

 

Could you send us a zip of your project or a subset of it reproducing the
issue?

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~  http://www.restlet.org/
http://www.restlet.org
Noelios Technologies ~ Co-founder ~  http://www.noelios.com/
http://www.noelios.com

 

 

 

De : Tamer Abuelsaad [mailto:tamere...@gmail.com] 
Envoyé : mercredi 13 mai 2009 02:22
À : discuss@restlet.tigris.org
Objet : Creating multiple components on Tomcat

 

Hi,
I have written this problem on the restlet form on Nabble, but have not
received a reply. I am in dire need of help. 
The problem thread on Nabble is:
http://n2.nabble.com/Multiple-Application-Handling-in-web.xml-td2596561.html
#a2799581

 Here is the details: 

restlet.xml 
 
?xml version=1.0? 
component xmlns=http://www.restlet.org/schemas/1.2/Component; 
  
  defaultHost 
attach uriPattern=/FirstResourceApplication/
targetClass=sample.reslet.applications.FirstResourceApplication / 
attach uriPattern=/FirstStepsApplication/
targetClass=sample.reslet.applications.FirstStepsApplication / 
  /defaultHost 
/component 


web.xml 
-- 
?xml version=1.0 encoding=UTF-8? 
web-app xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; 
xmlns=http://java.sun.com/xml/ns/javaee;
xmlns:web=http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd; 
xsi:schemaLocation=http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd; 
id=WebApp_ID version=2.5 
display-nameSampleRest/display-name 
!-- Restlet adapter -- 
servlet 
servlet-nameRestletServlet/servlet-name 
 
servlet-classorg.restlet.ext.servlet.ServerServlet/servlet-class 
/servlet 

!-- Catch all requests -- 
servlet-mapping 
servlet-nameRestletServlet/servlet-name 
url-pattern/*/url-pattern 
/servlet-mapping 
/web-app 

Error I am getting: 
 
May 5, 2009 12:28:15 PM org.apache.catalina.core.ApplicationContext log 
INFO: RestletServlet: [Noelios Restlet Engine] - Attaching restlet:
sample.reslet.applications.firstresourceapplicat...@11dba45 to URI:
/SampleRest/FirstResourceApplication/ 
May 5, 2009 12:28:15 PM org.apache.catalina.core.ApplicationContext log 
INFO: RestletServlet: [Noelios Restlet Engine] - Attaching restlet:
sample.reslet.applications.firststepsapplicat...@b03be0 to URI:
/SampleRest/FirstStepsApplication/ 
May 5, 2009 12:28:15 PM org.restlet.engine.LogFilter afterHandle 
INFO: 2009-05-05 12:28:15 0:0:0:0:0:0:0:1 - 0.0.0.0 8080 GET
/SampleRest/FirstResourceApplication/items - 404 330- 15
http://localhost:8080 http://localhost:8080/ Mozilla/4.0
(compatible; MSIE 7.0; Windows NT 5.1; iOpus-Web-Automation; .NET CLR
1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648;
.NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) - 
- 

The URL that I tried is:
http://localhost:8080/SampleRest/FirstResourceApplication/items

Please let me know if you need more information to guide me, especially if
you need java classes. 

If you have an example that shows multiple components with different URLs
(meaning different URLs and a class for each URL in the same restlet.xml) I
would appreciate it if you can share it with me. 

Thank you, I am trully grateful. 

Tamer

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

RE: No CallContext given until now when using client.post() inside a jax-rs method

2009-05-17 Thread Jerome Louvel
Hi Antonin,

I quick look at your sample code and at Restlet doesn't explain what
happens. I would suggest to prepare a small reproducible snippet and attach
it to a new defect report.

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 : webp...@tigris.org [mailto:webp...@tigris.org] 
Envoyé : mardi 12 mai 2009 19:31
À : discuss@restlet.tigris.org
Objet : No CallContext given until now when using client.post() inside a
jax-rs method

An exception is thrown when using client.post() inside a jax-rs method

Source code: 

http://pastebin.ca/1420694

without the call, the jax-rs method works fine. 

when launching the client.post() method from a main no exception is thrown. 

Stacktrace Using grizzly connector: 

http://pastebin.ca/1420620

About same stacktrace using default http connector. 

Switched from 1.2-m2 to 1.1.4, same issue. 

Not sure if it's related, but tried these : 

JaxRsApplication application = new JaxRsApplication(null);

JaxRsApplication application = new JaxRsApplication(comp.getContext());

JaxRsApplication application = new
JaxRsApplication(comp.getContext().createChildContext());

Googling gives nothing and I did not found any information on the forum. 

Any clue ?

Thank you. 

Antonin

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

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


RE: Can a filter read entity non-destructively?

2009-05-17 Thread Jerome Louvel
Hi Keith,

Did you know we have already ported those examples? Check the
org.restlet.example module for source code.

Otherwise, the getEntityAsForm() method caches the result by default, so you
could invoke it again later down the road. However, the Resource class
doesn't know about that and from its point of view, the original entity
isn't available anymore.

One way to workaround this is to replace the Request's entity with the
parsed Form:

request.setEntity(myForm.getWebRepresentation());

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 : Keith McDonald [mailto:keithmmcdon...@gmail.com] 
Envoyé : mardi 12 mai 2009 18:06
À : discuss@restlet.tigris.org
Objet : Can a filter read entity non-destructively?

To teach myself Restlet, I am trying to port the example bookmarking
application from chapter 7 of Richardson and Ruby's RESTful Web Services. 

In their example, they put before filters on their objects to check if the
user whose information is being requested matches the user whose credentials
were used to authenticate. 

It does this by looking at the user name in the entity. I tried to recreate
this functionality in Restlet by creating a subclass of Filter called
MustSpecifyUserFilter and reading the
entity by calling getEntityAsForm inside the filter's beforeHandle method,
but this causes the entity to be marked as unavailable and a 400 to be
returned before my Resource code can process it (In my Resource subclass, I
am only overriding storeRepresentation rather than handlePut).

Should I give up trying to use Filters to recreate this functionality or is
there another way such as overriding handlePut to ignore the available
attribute on the entity?

I am using Restlet 1.1.4.

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

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


RE: Dependency injection in Restlet 2.0 with Guice

2009-05-17 Thread Jerome Louvel
Sounds good Tim. Would you be interested to contribute and maintain such an 
extension to Restlet?

 

We could start by working in Restlet Incubator, using the “com.google.inject” 
package. Once “javax.inject” is available and the extension is stable, we could 
promote it as an official Restlet extension.

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~  http://www.restlet.org/ 
http://www.restlet.org
Noelios Technologies ~ Co-founder ~  http://www.noelios.com/ 
http://www.noelios.com

 

 

 

De : tpeie...@gmail.com [mailto:tpeie...@gmail.com] De la part de Tim Peierls
Envoyé : jeudi 14 mai 2009 21:53
À : discuss@restlet.tigris.org
Objet : Re: Dependency injection in Restlet 2.0 with Guice

 

On Thu, May 14, 2009 at 3:10 PM, Jerome Louvel jerome.lou...@noelios.com 
wrote:

By the way, do you think it would be technically possible to develop a similar 
integration that would leverage the recently announced javax.inject?

 http://crazybob.org/2009/05/announcing-javaxinjectinject.html 
http://crazybob.org/2009/05/announcing-javaxinjectinject.html

If so, it could be an opportunity for a new Restlet extension.

I'm sure it will be possible. I haven't worked out the details, but such an 
extension would provide an additional public interface, 
org.restlet.ext.inject.FinderFactory (better name needed?) and hooksfor 
obtaining a FinderFactory implementationthat would have to be specific to the 
injector implementation.

 

In the mean time, the nice thing about javax.inject is that you should be able 
to use com.google.inject for now and later switch your imports to javax.inject 
when the support becomes available.

 

--tim

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

RE: SiteMesh-like functionality for Restlet?

2009-05-17 Thread Jerome Louvel
Hi Rhett,

For very similar purpose, we rely on FreeMarker at Noelios and are extremely
happy with it. It is easy to define and reuse HTML layout macros.

I suggest having a look at their manual:
http://www.freemarker.org/docs/index.html

Their mailing list is also quite reactive.

Another option is Velocity for which we also have a Restlet extension.

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:r-sutp...@northwestern.edu] 
Envoyé : vendredi 15 mai 2009 16:22
À : discuss@restlet.tigris.org
Objet : SiteMesh-like functionality for Restlet?

Hi,

So far I've been using Restlet for API-only functionality -- resources  
that only have XML and/or JSON representations.  Now I'm thinking  
about using it for the HTML interface for a project.  One tool which  
I've always used to help with web GUIs is SiteMesh (
http://www.opensymphony.com/sitemesh/ 
  ), which is a filter which decorates the pages generated for  
individual views with the common elements for your site (e.g.,  
navigation), decoupling your site layout from the content of  
individual pages.

SiteMesh works very well, but unfortunately it is an actual JEE  
servlet filter and seems to rely heavily on JEE APIs.  I'm considering  
using Restlet to render the GUI for this project in order to decouple  
it from JEE, so SiteMesh is probably out.  (I haven't looked closely  
at the source to see if the JEE stuff could be factored out, but  
that's an option if there's no better way.)

I've looked around a bit, but I haven't found an equivalent that works  
with Restlet.  (I found a page about using freemarker macros to  
emulate layouts, but that's the closest I've come.)  Does anyone have  
any solutions for handling HTML layouts with Restlet that they  
particularly like?

Thanks,
Rhett

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

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


Re: Dependency injection in Restlet 2.0 with Guice

2009-05-17 Thread Tim Peierls
Yes, I'd be interested. I'd like to find out more about how Spring (and
others) will support javax.inject before going any further in code, though.
--tim

On Sun, May 17, 2009 at 12:05 PM, Jerome Louvel
jerome.lou...@noelios.comwrote:

  Sounds good Tim. Would you be interested to contribute and maintain such
 an extension to Restlet?



 We could start by working in Restlet Incubator, using the
 “com.google.inject” package. Once “javax.inject” is available and the
 extension is stable, we could promote it as an official Restlet extension.



 Best regards,
 Jerome Louvel
 --
 Restlet ~ Founder and Lead developer ~ http://www.restlet.org
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com







 *De :* tpeie...@gmail.com [mailto:tpeie...@gmail.com] *De la part de* Tim
 Peierls
 *Envoyé :* jeudi 14 mai 2009 21:53

 *À :* discuss@restlet.tigris.org
 *Objet :* Re: Dependency injection in Restlet 2.0 with Guice



 On Thu, May 14, 2009 at 3:10 PM, Jerome Louvel jerome.lou...@noelios.com
 wrote:

 By the way, do you think it would be technically possible to develop a
 similar integration that would leverage the recently announced javax.inject?

 http://crazybob.org/2009/05/announcing-javaxinjectinject.html

 If so, it could be an opportunity for a new Restlet extension.

 I'm sure it will be possible. I haven't worked out the details, but such an
 extension would provide an additional public interface,
 org.restlet.ext.inject.FinderFactory (better name needed?) and hooksfor
 obtaining a FinderFactory implementationthat would have to be specific to
 the injector implementation.



 In the mean time, the nice thing about javax.inject is that you should be
 able to use com.google.inject for now and later switch your imports to
 javax.inject when the support becomes available.



 --tim


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