Re: Problem with Spring Extension
Hi Paul, On Jun 26, 2011, at 10:24 PM, Paul Morris wrote: I'm getting the error below. I'm using both the Servlet and the Spring extensions. I figure it must be an XML config file issue so I'm including my web.xml and the two bean container files. The web.xml and the idservlet-servlet.xml are both in the WEB-INF folder and the applicationContext.xml is in the src folder. Using JEE 2.1 M5. SEVERE: Allocate exception for servlet idservlet org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'root' is defined From the javadoc for RestletFrameworkServlet[1]: 'All requests to this servlet will be delegated to a single top-level restlet loaded from the Spring application context. By default, this servlet looks for a bean named root. You can override that by passing in the targetRestletBeanName parameter.' You don't have a bean named root and you didn't specify an alternative. Rhett [1]: http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/spring/RestletFrameworkServlet.html at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:509) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1041) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:273) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1044) at org.restlet.ext.spring.RestletFrameworkServlet.getTargetRestlet(RestletFrameworkServlet.java:141) at org.restlet.ext.spring.RestletFrameworkServlet.initFrameworkServlet(RestletFrameworkServlet.java:163) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:308) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) at javax.servlet.GenericServlet.init(GenericServlet.java:160) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1189) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:813) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2777981idservlet-servlet.xmlweb.xmlapplicationContext.xml -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2777986
Re: Restlet and Spring - Engine and Component
Hi Paul, On Jun 21, 2011, at 6:54 PM, Paul Morris wrote: Can somebody give me a hint as to how to use spring bean injection to do the following within the Component? Here is the functionality I need to achieve within my applicationContext.xml: Engine.getInstance().getRegisteredAuthenticators().add(new AuthenticatorHelper()); I do this by making the helper self-register via the InitializingBean interface. Example: https://github.com/NUBIC/psc-mirror/blob/trunk/web/src/main/java/edu/northwestern/bioinformatics/studycalendar/restlets/PscAuthenticatorHelper.java Rhett This is as far as I've gotten in the beans xml: bean id=component class=org.restlet.ext.spring.SpringComponent property name=name value=APIUS Identity component / property name=description value=Authentication and authorization. Session management. / property name=owner value=apius.org / property name=author value=Paul Morris / property name=client value=http / property name=defaultHost ref=defaultHost / /bean bean id=defaultHost class=org.restlet.ext.spring.SpringHost constructor-arg ref=component / property name=defaultAttachment ref=proxyApplication / /bean bean id=componentChildContext class=org.restlet.Context lookup-method name=createChildContext bean=component.context / /bean bean id=proxyApplication class=org.restlet.Application constructor-arg ref=componentChildContext / property name=name value=OpenAM Proxy Application/ property name=description value=Proxy between the APIUS session API and the OpenAM RESTful API / property name=owner value=apius.org / property name=author value=Paul Morris / property name=inboundRoot bean class=org.restlet.ext.spring.SpringRouter constructor-arg ref=componentChildContext / property name=attachments map entry key=/session value=org.apius.identity.openam.session.SessionProxyImpl / entry key=/session/attributes value=org.apius.identity.openam.session.SessionAttributesImpl / /map /property /bean /property /bean bean id=engine class=org.restlet.engine.Engine /bean -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2771784 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2772127
Re: Using Spring and Servlet extensions together
Hi Paul, On Jun 21, 2011, at 9:09 PM, Paul Morris wrote: Would someone be able to post (or point me to) a simple example using Spring and Servlet extensions? Specifically I want to use Restlet as the main container. I'm having trouble figuring out how the web.xml file should look because all the examples I've found load the Component in the main method (JSE) rather than load it as a servlet in the web.xml (JEE). Thanks. Take a look at RestletFrameworkServlet: http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/spring/RestletFrameworkServlet.html Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2772105 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2772129
Re: Custom Challenge Scheme
Hi Paul, As Sebastian responded, part of the solution is to match up the ChallengeScheme name with what Restlet expects. The other part is to register your helper as being both for client-side and server-side. I'm not sure why this is, but Restlet[1] always looks for a client-side helper during parseResponse. Rhett [1]: At least in 2.0; I haven't looked at 2.1. On Jun 2, 2011, at 5:59 PM, Paul Morris wrote: Having problems implementing a custom challenge scheme with an AuthenticatorHelper. I've read the documentation but I am still receiving this WARNING in the logs: WARNING: Couldn't find any helper support the HTTP_MYSCHEME challenge scheme. This is what I'm doing code-wise... public class MyAuthenticatorHelper extends org.restlet.engine.security.AuthenticatorHelper { public static final ChallengeScheme MYSCHEME = new ChallengeScheme( MYSCHEME, MYSCHEME, A custom challenge authentication scheme.); public MyAuthenticatorHelper() { super(MYSCHEME, false, true); } @Override public void formatRawRequest(ChallengeWriter cw, ChallengeRequest cr, Response response, SeriesParameter httpHeaders) throws IOException { if (cr.getRealm() != null) cw.appendQuotedChallengeParameter(realm, cr.getRealm()); } @Override public void parseResponse(ChallengeResponse cr, Request request, SeriesParameter httpHeaders) { cr.setRawValue(request.getChallengeResponse().getRawValue().replaceFirst(token=, )); } } Then to the Component I am adding this line: Engine.getInstance().getRegisteredAuthenticators().add(new MyAuthenticatorHelper()); Why isn't it seeing ny helper? -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756279 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756760
Re: 2.0 series snapshots
Hi Thierry, On Dec 8, 2010, at 3:57 AM, Thierry Boileau wrote: Hello Rhett, the snapshot has been reactivated last week. It contains recent snapshots. Having said that, it misses the artifacts tagged with the date. I check that. Are you sure they are being published? It seems like the last dated one is the same as the SNAPSHOT. $ curl http://maven.restlet.org/org/restlet/jee/org.restlet/2.0-SNAPSHOT/org.restlet-2.0-SNAPSHOT.jar.md5 67329eaa98a718dc29aa7c2b79f0a50c $ curl http://maven.restlet.org/org/restlet/jee/org.restlet/2.0-SNAPSHOT/org.restlet-2.0-20101107.204753-7087.jar.md5 67329eaa98a718dc29aa7c2b79f0a50c Thanks for looking into this. Rhett Best regards, Thierry Boileau -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2688719 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2688817
Re: 2.0 series snapshots
Hi Theirry, On Dec 8, 2010, at 1:30 PM, Thierry Boileau wrote: Hello Rhett, there are actually the same, the last dated is a copy of the snapshot. We firstly published only the -SNAPSHOT artifacts. Then, some asked for the dated ones for reasons that I don't clearly remember for now. Thus, we decided to published both of them. Does it sound irregular? No, not irregular. I probably misunderstood your original message -- I thought you were saying that only the -SNAPSHOT ones were being updated, not the dated ones. It seems to me that neither of them are -- the last dated snapshot is from November 7 and the -SNAPSHOT is identical to it. I think the idea of the dated snapshots is to have reproducible builds, even if you aren't depending on an official release. Rhett Best regards, Thierry Boileau ps : the date corresponds to the last modification of the svn repository. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2688858 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2688861
2.0 series snapshots
Hi, There are a couple of recent bugfixes in the 2.0 line that I'd like to incorporate into my application. However it looks like the snapshots for 2.0 stopped in early November[1]. Was this intentional? Also: is there an expected release date for 2.0.4? It's not in the roadmap[2]. Thanks, Rhett [1]: The latest one is from November 7: http://maven.restlet.org/org/restlet/jee/org.restlet/2.0-SNAPSHOT/org.restlet-2.0-20101107.204753-7087.jar [2]: http://www.restlet.org/about/roadmap -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2688283
Re: Spring configuration and MatchingMode for the router
Hi Jean-Christophe, On May 10, 2010, at 6:22 PM, Jean-Christophe Malapert wrote: Hello, I am new in Spring configuration. I managed to configure my whole application using Spring. Nevertheless, I do not know how to set the equivalent of setMatchingMode(Template.MODE_STARTS_WITH) in Spring configuration. In other words, what is the equivalent of the following code in Spring configuration ? router.attach(/search/, new RedirectorFtp(getContext(),ftp://193.190.231.123/,6)).setMatchingMode(Template.MODE_STARTS_WITH); Could you help me please ? This isn't supported. If you need fine-grained control over your routes, please configure them in code. If this is a feature you'd like to add to Restlet, feel free to submit a patch. Rhett J-Christophe -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2608736
Re: Dynamic resource classes
Hi Tariq, On Feb 27, 2010, at 8:53 AM, webp...@tigris.org wrote: Hello Rhett, Thanks for the reply! What I would like to do is to create many application class instances at runtime through some internal trigger...which can be done using: attach(String pathTemplate, Restlet target) and to delete I use: detach(Restlet target) no problem here. but for resource class instances I can only route applications to them using: attach(String pathTemplate, Class? targetClass) Meaning, I would have to use the same resource class instance for all the applications that route to it. I want to clarify something here, just in case: each request will be served by a separate resource instance. You are correct that they will all be the same class, though. Although what I want to do is to have different resource instances that differ in how they are initialized. Okay, it sounds like you do need a custom Finder. Internally, when you call attach(path, class), the base Router creates a Finder Restlet for that class and attaches it like any other Restlet. You can change the kind of Finder used by overriding Router#createFinder. Or you can provide your own custom attach methods in your Router subclass that do what you want. (You can look at the Spring extension for examples of this -- SpringBeanRouter and SpringBeanFinder.) Rhett I hope I have illustrated this properly. Many thanks, Tariq Hi Tariq, On Feb 26, 2010, at 5:33 AM, webp...@tigris.org wrote: I would like to know why instances of resource classes cannot be dynamically created at runtime like the application class. Resources _are_ instantiated dynamically at runtime -- one instance per request (assuming that the request gets routed to a Resource). The Restlet which handles this instantiation is is the Finder. You can use a custom Router subclass to use a different Finder implementation if the default behavior doesn't work for you. Can you give an example of what you're trying to do? Rhett The idea is that I would like to initialize the resource class instance depending on different data that is acquired during runtime, and hence handle interactions differently. An alternative to this is to just handle the requests at the application without the use of the resource class. But I would like to use the resource class so that I could automatically generate WADLs using the respective extension class(es). Many thanks, Tariq -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2452502 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2452885 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2452920
Re: Dynamic resource classes
Hi Tariq, On Feb 26, 2010, at 5:33 AM, webp...@tigris.org wrote: I would like to know why instances of resource classes cannot be dynamically created at runtime like the application class. Resources _are_ instantiated dynamically at runtime -- one instance per request (assuming that the request gets routed to a Resource). The Restlet which handles this instantiation is is the Finder. You can use a custom Router subclass to use a different Finder implementation if the default behavior doesn't work for you. Can you give an example of what you're trying to do? Rhett The idea is that I would like to initialize the resource class instance depending on different data that is acquired during runtime, and hence handle interactions differently. An alternative to this is to just handle the requests at the application without the use of the resource class. But I would like to use the resource class so that I could automatically generate WADLs using the respective extension class(es). Many thanks, Tariq -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2452502 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2452702
Re: RESTful batch operations
Hi Erick, On Feb 2, 2010, at 10:21 AM, Erick Fleming wrote: This is more of a REST question, but is anyone using Restlet to handle batch operations? For example: given the following resource: /api/blog/1/posts. I would like to make client-side changes, then update them on one call. I realize this is very SOAP like, but was wonder how Restlet users are handling these sorts of Use Cases. If you want to update the whole collection of posts, it's RESTful to allow PUT to /api/blog/1/posts. PUT semantics are I want the resource to reflect the representation I'm giving you here exactly. If you want to update only some of the posts (and you don't want to re- send the ones you aren't modifying to avoid, say, concurrent modification problems), one model is to define a subset resource. Something like: /api/blog/1/posts?subset=3,4,8,11 or maybe /api/blog/1/posts/subset/3;4;8;11 this resource would represent just the posts with IDs 3, 4, 8, and 11. GET would return a collection containing just those items and PUT would accept new representations for just those items, leaving the other posts alone. This kind of violates HATEOAS (since the client needs to know how to generate the subset URI), but I think it's an acceptable tradeoff. There's also the proposed HTTP PATCH method. I don't know the status of that. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2444225
Re: including restlet in a maven project
Hi Marc, On Jan 19, 2010, at 3:13 PM, Marc Limotte wrote: I need to use restlet in a project which is managed by Maven2. I'm not too familiar with Maven, but I think I need a POM file for restlet, and I don't see one in the maven central repository. Is there a repo available with restlet (2.0-r6) in it? Alternatively, I thought I could add it to my local repo. I found this script (below) in the restlet mailing list archives, but it's quite old and seems to depend on POM files coming with the restlet distribution (under lib/poms), and there is no such directory in the dist that I downloaded. What's the easiest way to do this? http://www.restlet.org/downloads/maven Rhett Marc -Message d'origine- De : news [EMAIL PROTECTED] De la part de Vincent Envoyé : jeudi 18 janvier 2007 20:36 À : discuss@restlet.tigris.org Objet : Script to install a Restlet distribution into a maven2 repository Hi all, I use this bash script to upgrade my local maven2 repository each time a new version of Restlet comes up. Some of you might find it useful. -Vincent. #!/bin/bash # # This script installs a Restlet disrtribution into a local (filesystem) # maven2 repository. # # Usage: restlet2mvn.bsh path to Restlet distribution path to local maven repository # if [ $# -le 1 ]; then echo Usage: restlet2mvn.bsh path to Restlet distribution path to local maven repository exit 1; fi RESTLET_DIST=$1 MAVEN_REPOSITORY=$2 MVN=mvn if [ ! -e $RESTLET_DIST ] then echo Restlet distribution not found: $RESTLET_DIST exit 1; fi if [ ! -e $MVN_REPO ] then echo Maven repository not found: $MVN_REPO exit 1; fi LIB_DIR=$RESTLET_DIST/lib POMS_DIR=$RESTLET_DIST/lib/poms poms=`ls $POMS_DIR/*.pom` for pom in $poms do # restlet/lib/poms/foo.pom - restlet/lib/foo.jar jar=`echo $pom | sed s/.pom$/.jar/g | sed s/poms\\\///g` if [ -e $jar ] then # Extract the group, artifact id, and version number from the POM: # We assume that the first groupId, artifactId, version tags found in the pom # contain the module's group id, artifact id, and version #. # This will break if the pom contains commented out tags: # groupIdfoo.groupId # !-- artifactIdbar/artifactId -- # artifactIdbar/artifactId # versio1.0/version group=` grep --regexp 'groupId.*/groupId' --max-count=1 $pom | sed 's/[[:space:]]*[^]*[[:space:]]*//g' ` artifact=` grep --regexp 'artifactId.*/artifactId' --max-count=1 $pom | sed 's/[[:space:]]*[^]*[[:space:]]*//g' ` version=` grep --regexp 'version.*/version' --max-count=1 $pom | sed 's/[[:space:]]*[^]*[[:space:]]*//g' ` # Now deploy the module $MVN deploy:deploy-file -DgroupId=$group \ -DgeneratePom=false \ -DpomFile=$pom \ -DartifactId=$artifact \ -Dversion=$version \ -Dpackaging=jar \ -Dfile=$jar \ -DrepositoryId=local-repository \ -Durl=file://$MAVEN_REPOSITORY fi done exit -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2440449
Re: Basic HTTP Auth without Guards?
Hi, On Jan 18, 2010, at 6:09 AM, mkhatib wrote: I am trying to implement web services that will be used on an iPhone client. I need the user to authenticate and then make sure he is authorized before executing an action. I am using Spring 2.5.6 along with Restlet 1.1.7. bean name=restletRouter class=org.restlet.ext.spring.SpringRouter bean id=app class=org.restlet.Application What is the root property for the app bean? It should be the guard. Rhett bean id=restletServer class=org.restlet.ext.spring.SpringServer bean id=restletComponent class=org.restlet.ext.spring.SpringComponent bean name=secretResolver class=ps.exalt.iywave.server.api.security.CustomAuth scope=singleton/ bean name=guard class=ps.exalt.iywave.server.api.security.CustomGaurd scope=singleton property name=next ref=restletRouter/ property name=secretResolver ref=secretResolver/ /bean The problem is it is not asking for authentication, is there anything I am missing? -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2439985
Re: Modeling button presses that invoke server side actions via REST
Hi, Tim's idea is a good one. You might also consider having a review queue resource to which you POST widgets that are ready to be reviewed. GET on this resource would be a natural way to expose the widgets that are ready for review to the reviewers. Rhett On Jan 13, 2010, at 3:47 PM, Tim Peierls wrote: It sounds like you have one URI for two distinct resources: the contents of widget 123 and the submission status of widget 123. Why not just use two URIs? /myapp/widget/123 // for the contents of widget 123 /myapp/widget/123/status // for the status of widget 123 --tim On Wed, Jan 13, 2010 at 4:32 PM, kevinpauli ke...@thepaulis.com wrote: Hi, I'm embarking on a new web app and have chosen RESTlet. Now it is time to begin designing the interactions, and something sorta basic about REST has me stumped. I am trying to figure out the best way to mediate the impedance mismatch between REST and OO without falling down the slippery slope of RPC. Let me give a (contrived) example. Widgets can be created, modified, and then submitted for review. To modify a widget with the id of 123, the user does a PUT to /myapp/widget/123 and the new form data. The restlet repackages all the form data as a POJO and hands it off to the logic layer for validation and subsequent persistence, invoking WidgetManager.update(widgetPojo). To submit a widget for review, the user clicks a button, which also does a PUT to /myapp/widget/123, but now the form data just has has one field, a status of submitted (I don't send all the form data again, just the field I want to change). However, now the restlet needs to invoke a different business object, WidgetStateManager.updateState(123, submitted), which is going to do some other specialized processing in addition to updating the state. So, in an attempt to be RESTful, I've modeled both the widget updates and the submit for review action as PUTs to the same URL, /myapp/widget/123. So now, in my restlet, I need to figure out what a particular PUT request means in terms of the business functions, and therefore which business function(s) to invoke. But how can I reliably determine which function to invoke merely by inspecting the values in the form data? It is SOOO tempting to pass an action field along with the form data, with a value like update or submit for review in the PUT! Then my restlet could do a switch based on that value. But that of course is not RESTful and is nothing more than dressed up RPC. It just doesn't seem safe or scalable to infer what button was clicked just by examining the form data with a bunch of if-then-elses in the restlet. I can imagine dozens of different actions that could be taken on a widget, and therefore dozens of if-then-elses. What am I missing here? My gut tells me I haven't modeled my resources correctly, or I'm missing a particular resource abstraction that would help. -- View this message in context: http://n2.nabble.com/Modeling-button-presses-that-invoke-server-side-actions-via-REST-tp4375243p4375243.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2437165 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2437187
RE: Restlet and Spring bean scope in v2.0m
Anyone have any experience in scoping Spring beans using Session or Singleton? I'm extending ServerResource and I am wondering how concurrency is handled since none of the annotated methods are synchronized. Resource instances are not intended to be thread-safe. You should use prototype scope for spring-managed resources. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2434607
Re: SpringServerServlet 404 - newb
Hi, On Dec 29, 2009, at 1:22 PM, webp...@tigris.org wrote: I'm new to Restlet and I'm getting 404 errors, so I'm guessing the SpringServerServlet isn't being invoked in Tomcat 6. I'm trying out the Spring extension in Restlet 2.0-M6. See attachment's web.xml and spring-beans.xml. I think something basic is wrong, but not sure what. Thx.spring-beans.xmlweb.xml What URL are you invoking that's giving you 404? With this configuration, you've defined one: /restlet/exampleResource . Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2434608
Re: How to REST in SpringFramework
Hi, On Dec 31, 2009, at 1:59 PM, gozfidan wrote: Hi, I am new to REST and trying to integrate with my Spring application. I have done some searching bu got stuck. I have changed the web.xml and add RestletServlet-servlet.xml but not sure how to implement Resource? web.xml servlet servlet-nameRestletServlet/servlet-name servlet-classorg.restlet.ext.spring.RestletFrameworkServlet/servlet-class /servlet RestletServlet-servlet.xml ?xml version=1.0 encoding=UTF-8? beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd; bean id=root class=org.restlet.ext.spring.SpringRouter property name=attachments map entry key=/poll bean class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=pollSystemResource / /bean /entry /map /property /bean bean id=pollSystemResource class=com.smartcrop.webapp.service.PollSystemResource autowire=byName/ /beans and I have this PollSystemResource if I extend it with SpringResource I get an error for [cannot find symbol constructor SpringResource()] You don't want to use SpringResource here. From the javadoc: Spring Resource based on a Restlet Representation. DON'T GET CONFUSED, Spring's notion of Resource is different from Restlet's one, actually it's closer to Restlet's Representations. Base PollSystemResource on org.restlet.resource.Resource (under 1.1) or org.restlet.resource.ServerResource (under 2.0). Rhett If my steps are correct, how do I implement my Resources thanks. -- View this message in context: http://n2.nabble.com/How-to-REST-in-SpringFramework-tp4237720p4237720.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2434026 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2434609
Re: Supporting multiple types of authorization for a given route
Hi David, On Dec 5, 2009, at 3:47 PM, David Bordoley wrote: I was wondering if anyone had experience offering multiple types of authorization (HTTP BASIC, HTTP DIGEST, OAUTH, etc.) for a given route using Restlet. It isn't immediately apparent to me what the best way to do this is using the ChallengeAuthenticator class. Also what is the status of the 1.1 OAUTH extension? Will it be reintroduced in the 2.0 cycle? Thanks, In Restlet 1.1, I did this using my own Guard subclass: https://ncisvn.nci.nih.gov/svn/psc/trunk/web/src/main/java/edu/northwestern/bioinformatics/studycalendar/restlets/PscGuard.java This code supports both HTTP Basic and an application-specific scheme called psc_token. I haven't tried to update this for Restlet 2.0 yet. My understanding is that the security infrastructure is substantially different. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427885
Re: restlet with open session in view for hibernate
Hi kiwi, On Dec 3, 2009, at 11:10 AM, kiwionly wrote: hi, Infact my servlet is working correctly in servlet container for restlet, i not using spring MVC, and not running in servlet container (so web.xml is not working anymore), instead I running inside Netty. hence, that the problem arise, maybe i need to lookup how to configure the server instead. Perhaps you could write a Restlet Filter which invokes the Spring OSIV interceptor. Rhett regards, kiwi On Thu, Dec 3, 2009 at 11:46 PM, Dustin N. Jenkins dustin.jenk...@nrc-cnrc.gc.ca wrote: Hello, I currently use the Hibernate/Spring Open Session In View model too with FreeMarker and it works perfectly. Can you post your web.xml? Is it setup properly? Dustin kiwionly wrote: hi, I had create an web application that using restlet to replace serlvet (for Resource that no need any session). my web app basically is using spring + hibernate + velocity template (with restlet extension for velocity template) however, i had encounter LazyInitializeException, as my servlet had an Inteceptor for hibernate session. But it don't have any OSIV for reslet. hence the exception come. (spring close the session before complete render the page). do restlet plan to support a use case for this ? or do anyone have find a solution ? any idea ? regards, kiwionly -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2426617 -- 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=2426730 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427065
Re: CAS authentication in Restlet server
Hi Arjohn, On Dec 2, 2009, at 12:34 PM, Arjohn Kampman wrote: Hi Rhett, others, Thanks for your suggestion. Since I'm fairly new to the subject, I hope you (and others) can help me a bit to get things clear. If I understand you correctly, you are suggesting to use a CAS proxy ticket as an authentication token. However, such a token can only be sent once to a CAS server for verification. This very much looks like a problem for (preemptive) authentication in consecutive requests. Or am I overlooking something? That's correct. When the client application is using proxy tickets for authentication, it needs to get a new proxy ticket from the CAS server for each request. This was intentional in the design of CAS. Rhett Regards, Arjohn Rhett Sutphin wrote: If I were adding support for just CAS, I would define a new challenge scheme (call it something like cas_proxy_ticket) and define a Guard and AuthenticationHelper pair which handle this scheme. This would mean that a client would need to acquire a proxy ticket and then include it in the HTTP request as the Authentication header, something like Authentication: cas_proxy_ticket PT-123456789 Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2426434 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2426475
Re: watch http request
Hi Michael, This is a discuss topic, so I'm moving it there. On Nov 7, 2009, at 9:24 AM, Michael Strupp wrote: Hello community I'm writing a java Rest Client with restlet, to call a .NET Webservice. To debug my application, it would be nice to watch the http request my client sends to the server. What i need is a simple method witch shows me for example something like that: GET /infotext.html HTTP/1.1 Host: www.example.net or this: POST /wiki/Spezial:Search HTTP/1.1 Host: de.wikipedia.org Content-Type: application/x-www-form-urlencoded Content-Length: 24 search=Katzengo=Artikel Is there a way to do this? One way would be to use Apache HTTP Client connector and use its (Apache HTTP Client's) wire logger: http://hc.apache.org/httpclient-3.x/logging.html Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2415771
Re: CAS authentication in Restlet server
Hi Arjohn, On Nov 7, 2009, at 4:31 AM, Arjohn Kampman wrote: I'm planning to integrate CAS (proxy) authentication in my Restlet- based server. Has anyone worked on this before? Any suggestions on how to best implement this? I have done this for my Restlet-based API. I can point you to the code[1], but since the application is a redistributable webapp which supports several authentication plugins, the implementation is probably more indirect than you need. Also, please note that my experience is with Restlet 1.1 only so far -- I haven't tried to update this application to 2.0. If I were adding support for just CAS, I would define a new challenge scheme (call it something like cas_proxy_ticket) and define a Guard and AuthenticationHelper pair which handle this scheme. This would mean that a client would need to acquire a proxy ticket and then include it in the HTTP request as the Authentication header, something like Authentication: cas_proxy_ticket PT-123456789 Rhett [1]: https://ncisvn.nci.nih.gov/svn/psc/trunk/web/src/main/java/edu/northwestern/bioinformatics/studycalendar/restlets/PscGuard.java and https://ncisvn.nci.nih.gov/svn/psc/trunk/web/src/main/java/edu/northwestern/bioinformatics/studycalendar/restlets/PscAuthenticationHelper.java are the Restlet-specific parts. https://ncisvn.nci.nih.gov/svn/psc/trunk/authentication/cas-plugin/src/main/java/edu/northwestern/bioinformatics/studycalendar/security/plugin/cas/CasAuthenticationSystem.java is the plugin for CAS. CAS: http://www.jasig.org/cas Regards, Arjohn -- Arjohn Kampman, Senior Software Engineer Aduna - Semantic Power www.aduna-software.com -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2415378 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2415839
Re: CLAP - restlet-jee-2.0snapshot
Hi, On Oct 20, 2009, at 10:46 AM, webp...@tigris.org wrote: Hi, is anyone there to help? Thanks! Dear All, I am using the restlet-jee-2.0snapshot, jdk5.0 on Tomcat 5.5. I have an application.properties file: WEB-INF/classes/application.properties But I keep getting the following error: java.lang.IllegalArgumentException: Cannot access to the configuration file: clap://system/WEB-INF/classes/ application.properties I haven't used CLAP myself, but I have a guess: if you're running in Tomcat, the classpath will include WEB-INF/classes. That means that resources (in the java sense) that you want to load need to be expressed relative to that directory; i.e., clap://system/ application.properties. Rhett It seems that I am not working properly with the classloader, CLAP. I have tried most ways, clap://thread/.., clap://class...but no luck so far. Here below is the code: Thanks, Sinoea [code] public class DirectoryServletApplication extends Application { /** Freemarker configuration object. */ private Configuration fmc; public static void main(String[] args) throws Exception { // Create a component Component component = new Component(); component.getServers().add(Protocol.HTTP, 8182); component.getClients().add(Protocol.FILE); component.getClients().add(Protocol.CLAP); component.getClients().add(Protocol.HTTP); DirectoryServletApplication application = new DirectoryServletApplication(component.getContext()); // Attach the application to the component and start it component.getDefaultHost().attach(, application); component.start(); } public DirectoryServletApplication(Context context) throws IOException { super(context); getConnectorService().getClientProtocols().add(Protocol.FILE); getConnectorService().getClientProtocols().add(Protocol.CLAP); getConnectorService().getClientProtocols().add(Protocol.HTTP); // Look for the configuration file in the classpath (Here is the PROBLEM) Properties properties = getProperties(clap://system/WEB-INF/ classes/application.properties); System.out.println(properties.get(web.root.path)); try { this.fmc = new Configuration(); final File templateDir = new File(C:\\Program Files\ \Apache Software Foundation\\Tomcat 5.5\\webapps\\directory\\ROOT\ \WEB-INF\\template); this.fmc.setDirectoryForTemplateLoading(templateDir); } catch (Exception e) { getLogger().severe(Unable to configure FreeMarker.); e.printStackTrace(); } } @Override public synchronized Restlet createInboundRoot() { // Create a router Restlet that routes each call to a // new instance of HelloWorldResource. Router router = new Router(getContext()); // Defines only one route router.attachDefault(HomePage.class); router.attach(/contactus, ContactUs.class); return router; } /** * Returns the freemarker configuration object. * * @return the freemarker configuration object. */ public Configuration getFmc() { return this.fmc; } /** * Returns a Properties instance loaded from the given URI. * * @param propertiesUri *The URI of the properties file. * @return A Properties instance loaded from the given URI. * @throws IOException */ public static Properties getProperties(String propertiesUri) throws IOException { Reference reference = new Reference(propertiesUri); Response response = new Client(reference.getSchemeProtocol()).get(reference); if (!(response.getStatus().isSuccess() response.isEntityAvailable())) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(Cannot access to the configuration file: \); stringBuilder.append(propertiesUri); stringBuilder.append(\); throw new IllegalArgumentException(stringBuilder.toString()); } Properties properties = new Properties(); properties.load(response.getEntity().getStream()); return properties; } } [/code] [code] ?xml version=1.0 encoding=UTF-8? web-app id=directory version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd display-namedirectory/display-name !-- Application class name -- context-param param-nameorg.restlet.application/param-name param-valueexample.DirectoryServletApplication/param-value /context-param context-param param-nameorg.restlet.clients/param-name param-valueHTTP HTTPS CLAP FILE/param-value
Re: Retrieving Login in a resource
Hi Fabian, On Oct 19, 2009, at 6:14 AM, Fabian Mandelbaum wrote: I guess he's using md5 on the client to avoid transmitting the password in clear (its md5 hash is transmitted instead). As a side effect, this approach may even remove the need for https with basic auth Maybe not the most secure idea but it would work... It obscures the user's password-as-entered, but it isn't secure. It changes the password for the service from X to md5(X) -- any attacker who sniffs a single request can still impersonate the user. Rhett On Mon, Oct 19, 2009 at 8:23 AM, Jerome Louvel jerome.lou...@noelios.com wrote: Hi Laurent, On the client side, I'm not sure why you need to apply MD5 on your password. On the server side, you can just call ServerResource#getChallengeResponse().getIdentifier() and getSecret () to retrieve the values sent by the client. 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 : Laurent Garrigues [mailto:laur...@speedinfo.fr] Envoyé : mercredi 14 octobre 2009 17:03 À : discuss@restlet.tigris.org Objet : Retrieving Login in a resource hello, I have an application using 'guards' to protect the access of my resources. My guards work well using TestResolver and SecretVerifier. The login and the password are transmitted by the client using a BASIC https authentification : --- /* URI */ ClientResource itemsResource = new ClientResource(https://localhost:8283/json/MDC/create-commande;); /*Protocole,login and password */ String login=LOGIN; String password = PASSWORD; password=new Md5().getMd5(password); itemsResource.setChallengeResponse (ChallengeScheme.HTTP_BASIC,login,password ); -- Basically, I would like to retrieve the login sent by the client and process it in my resource given that I cannot use session or cookies. Thanks in advance for your help. best regards. Laurent Garrigues -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=24075 76 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2408904 -- Fabián Mandelbaum IS Engineer -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2408912 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2408922
Re: Retrieving Login in a resource
Hi Fabian, On Oct 19, 2009, at 7:28 AM, Fabian Mandelbaum wrote: Yes indeed. That's why I said 'not the most secure' OTOH, the attacker needs to know that the piece of text is the md5 hash... or he just has to try it given 'well known practices' (like md5-hashing passwords ;)) I don't want to be too harsh here, but I want to make sure this is clear: in terms of controlling access to your resources, HTTP Basic with username+password is exactly as secure as HTTP Basic with username +md5(password). The attacker does not need to know anything about the password in order to compromise the system -- just what credentials the system accepts on the wire. Any pre-processing the client does to the user-entered password is irrelevant. Keep in mind that the thing you are trying to secure is the resource, not the password. Rhett Thanks for the answer On Mon, Oct 19, 2009 at 9:03 AM, Rhett Sutphin rh...@detailedbalance.net wrote: Hi Fabian, On Oct 19, 2009, at 6:14 AM, Fabian Mandelbaum wrote: I guess he's using md5 on the client to avoid transmitting the password in clear (its md5 hash is transmitted instead). As a side effect, this approach may even remove the need for https with basic auth Maybe not the most secure idea but it would work... It obscures the user's password-as-entered, but it isn't secure. It changes the password for the service from X to md5(X) -- any attacker who sniffs a single request can still impersonate the user. Rhett On Mon, Oct 19, 2009 at 8:23 AM, Jerome Louvel jerome.lou...@noelios.com wrote: Hi Laurent, On the client side, I'm not sure why you need to apply MD5 on your password. On the server side, you can just call ServerResource#getChallengeResponse().getIdentifier() and getSecret () to retrieve the values sent by the client. 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 : Laurent Garrigues [mailto:laur...@speedinfo.fr] Envoyé : mercredi 14 octobre 2009 17:03 À : discuss@restlet.tigris.org Objet : Retrieving Login in a resource hello, I have an application using 'guards' to protect the access of my resources. My guards work well using TestResolver and SecretVerifier. The login and the password are transmitted by the client using a BASIC https authentification : --- /* URI */ ClientResource itemsResource = new ClientResource(https://localhost:8283/json/MDC/create-commande;); /*Protocole,login and password */ String login=LOGIN; String password = PASSWORD; password=new Md5().getMd5(password); itemsResource.setChallengeResponse (ChallengeScheme.HTTP_BASIC,login,password ); -- Basically, I would like to retrieve the login sent by the client and process it in my resource given that I cannot use session or cookies. Thanks in advance for your help. best regards. Laurent Garrigues -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=24075 76 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2408904 -- Fabián Mandelbaum IS Engineer -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2408912 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2408922 -- Fabián Mandelbaum IS Engineer -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2408931 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2408964
Re: Unable to inject Protoype beans into a singleton bean via value-ref for a Spring Router
Hi Infinity, On Oct 5, 2009, at 9:58 AM, infinity wrote: Looking at the code in SpringRouter.setAttachments(), it looks like the default implementation can not handle prototype spring beans. SpringRouter can't directly handle spring-configured resource instances. You want either SpringBeanRouter or SpringRouter + SpringBeanFinders. Rhett if (value instanceof Restlet) { router.attach(key, (Restlet) value); } else if (value instanceof Class) { router.attach(key, (Class?) value); } else if (value instanceof String) { resourceClass = Engine.loadClass((String) value); if (org.restlet.resource.Resource.class .isAssignableFrom(resourceClass)) { router.attach(key, resourceClass); } else if (org.restlet.resource.ServerResource.class .isAssignableFrom(resourceClass)) { router.attach(key, resourceClass); } else { router .getLogger().warning(Unknown class found in the mappings. Only subclasses of org.restlet.resource.Resource and ServerResource are allowed.); } } So, I get a warning since the value returned here is an instance of ServerResource. I think this should be a bug or clearly documented as not being able to handle spring prototype beans for BaseServer Resources unless I'm missing something here Pritam wrote: I'm using Restlet spring ext to configure routers bean id=virtualHost class=org.restlet.ext.spring.SpringHost constructor-arg ref=component / property name=attachments map entry key=/ws value-ref=wsRouter / /map /property /bean bean id=wsRouter class=org.restlet.ext.spring.SpringRouter property name=attachments map entry key=/contact/{operation} value-ref=contact / /map /property /bean bean id=contact class=com.xxx.ContactData scope=prototype / contact bean is not being injected in the SpringRouter if I use a value-ref for some reason. Is this because the bean is a prototype? Strangely, value-ref works for VirtualHost where wsRouter is injected, but it's a singleton bean. Using value instead works too entry key=/contact/{operation} value=com.xxx.ContactData / Any suggestions? -- View this message in context: http://n2.nabble.com/Unable-to-inject-Protoype-beans-into-a-singleton-bean-via-value-ref-for-a-Spring-Router-tp3756435p3769372.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2403696 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2403783
Re: Unable to setup SpringBeanRouter configure
Hi Infinity, On Oct 5, 2009, at 10:03 AM, infinity wrote: I'm trying to setup a SpringBeanRouter as per the javadocs since I cannot use SpringRouter if I use spring prototype beans for attachements acc to this http://n2.nabble.com/Unable-to-inject-Protoype-beans-into-a-singleton-bean-via-value-ref-for-a-Spring-Router-td3756435.html#a3756435 issue . Is there something wrong with the following configuration? ?xml version=1.0 encoding=UTF-8? beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:util=http://www.springframework.org/schema/util; xsi:schemaLocation=http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd; !-- Components -- bean name=component id=component class=org.restlet.ext.spring.SpringComponent property name=clientsList list valueHTTP, HTTPS/value /list /property property name=hosts list ref bean=virtualHost / /list /property /bean !-- Virtual Hosts -- bean id=virtualHost class=org.restlet.ext.spring.SpringHost constructor-arg ref=component / property name=attachments map entry key=/ value-ref=router / /map /property /bean !-- Routers -- bean name=router class=org.restlet.ext.spring.SpringBeanRouter/ !-- Resources -- bean name=/ws/contact/{operation} class=com.xx.rest.resource.ContactData scope=prototype autowire=byName/ bean name=/mock/1/data/Contact/{userId} class=com.xxx.mock.resource.ContactData scope=prototype autowire=byName/ The server loads fine but none of Server Resources are invoked. There is no stacktrace either. Pl suggest. What sort of server are you using? How are you loading the beans from this context and attaching them to the server? Rhett /beans -- View this message in context: http://n2.nabble.com/Unable-to-setup-SpringBeanRouter-configure-tp3769405p3769405.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2403701 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2403785
Re: Unable to setup SpringBeanRouter configure
Hi Infinity, On Oct 5, 2009, at 11:25 AM, infinity wrote: Rhett, Spring context loaded in web.xml (tomcat) via context params !-- Restlet support (default servlet) -- servlet servlet-namerestletServlet/servlet-name servlet-classorg.restlet.ext.spring.SpringServerServlet/servlet- class /servlet servlet-mapping servlet-namerestletServlet/servlet-name url-pattern/ws/*/url-pattern url-pattern/mock/*/url-pattern /servlet-mapping This mapping combined with the URIs in your resource beans means that your server should respond to http://servername:port/ws/ws/contact/{operation} http://servername:port/ws/mock/1/data/Contact/{userId} http://servername:port/mock/ws/contact/{operation} http://servername:port/mock/mock/1/data/Contact/{userId} I'm guessing that's not what you want. Router attachment URIs (whether you use SpringRouter, SpringBeanRouter, or something else) are relative to the attachment point of the router. Rhett !-- Configuration parameters -- context-param description Comma separated list of Spring context configuration files. /description param-namecontextConfigLocation/param-name param-value /WEB-INF/spring/spring-core.xml, /WEB-INF/spring/spring-mail.xml, /WEB-INF/spring/spring-restlet.xml, /param-value /context-param context-param description Spring bean name that inherits from Component. It is used to instantiate and attach the described component, contained applications and connectors (Used by org.restlet.ext.spring.SpringServerServlet) /description param-nameorg.restlet.component/param-name param-value component /param-value /context-param Btw, I corrected the virtual host configuration from the parent post. pl refer the same. Rhett Sutphin wrote: Hi Infinity, On Oct 5, 2009, at 10:03 AM, infinity wrote: I'm trying to setup a SpringBeanRouter as per the javadocs since I cannot use SpringRouter if I use spring prototype beans for attachements acc to this http://n2.nabble.com/Unable-to-inject-Protoype-beans-into-a-singleton-bean-via-value-ref-for-a-Spring-Router-td3756435.html#a3756435 issue . Is there something wrong with the following configuration? ?xml version=1.0 encoding=UTF-8? beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:util=http://www.springframework.org/schema/util; xsi:schemaLocation=http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd; !-- Components -- bean name=component id=component class=org.restlet.ext.spring.SpringComponent property name=clientsList list valueHTTP, HTTPS/value /list /property property name=hosts list ref bean=virtualHost / /list /property /bean !-- Virtual Hosts -- bean id=virtualHost class=org.restlet.ext.spring.SpringHost constructor-arg ref=component / property name=attachments map entry key=/ value-ref=router / /map /property /bean !-- Routers -- bean name=router class=org.restlet.ext.spring.SpringBeanRouter/ !-- Resources -- bean name=/ws/contact/{operation} class=com.xx.rest.resource.ContactData scope=prototype autowire=byName/ bean name=/mock/1/data/Contact/{userId} class=com.xxx.mock.resource.ContactData scope=prototype autowire=byName/ The server loads fine but none of Server Resources are invoked. There is no stacktrace either. Pl suggest. What sort of server are you using? How are you loading the beans from this context and attaching them to the server? Rhett /beans -- View this message in context: http://n2.nabble.com/Unable-to-setup-SpringBeanRouter-configure-tp3769405p3769405.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2403701 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2403785 -- View this message in context: http://n2.nabble.com/Unable-to-setup-SpringBeanRouter-confiiguration-with-VirtualHost-tp3769405p3769937.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2403797 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2403803
Re: logging framework for restlet
Hi Jerome, On Sep 30, 2009, at 5:23 AM, Jerome Louvel wrote: Beside the simplicity of requiring a single JAR (important), This is a reasonable concern -- if you used SLF4J in restlet core, you'd go from 1 JAR to (at least) 3 JARs (restlet, slf4j-api, and an slf4j implementation). However, I wonder how many restlet users actually only use the core. Have you ever done a survey? the size concern (minor indeed), the licensing aspect (with a multi-license scheme for Restlet), SLF4J is MIT licensed: http://slf4j.org/license.html . the 'zero dependency rule' is also helpful when we support Restlet editions like GWT/GAE or Android where an external dependency might not work seamlessly (not sure about SLF4J though). I haven't tried using SLF4J in any of those environments (though I found evidence that it will work on GAE[1]), but the core SLF4J code is really, really simple. [1]: http://stronglytypedblog.blogspot.com/2009/04/wicket-on-google-app-engine.html If performance through JULI+SLF4J is really bad, maybe you chould look at a direct bridge from JULI to the logging framework you selected? The performance issue that Arjohn brought up is on the JUL side, not on the SLF4J side. Another option would be for Restlet to provide a simple pluggable logging mechanism that would use JULI API for levels, logger, etc. and JULI 'engine' as the default implementation. But the implementation could be replaced through dynamic detection of SLF4J for example. Would that be a better solution? Dynamic detection sounds a lot like Jakarta commons-logging. JCL introduces all sorts of classloading issues -- JCL is the problem that SLF4J was designed to solve. A restlet-provided dynamic detection solution would have to be carefully designed to be OSGi compatible as well. If the concern is efficiency (and meaning no offense to you, Jerome), it seems unlikely that a restlet-provided bridge from JULI to SLF4J is going to be faster than the one provided by SLF4J itself. Rhett BTW, I've updated the related RFE: Facilitate support of alternative log mechanisms http://restlet.tigris.org/issues/show_bug.cgi?id=179 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 : Arjohn Kampman [mailto:arjohn.kamp...@aduna-software.com] Envoyé : vendredi 18 septembre 2009 19:13 À : discuss@restlet.tigris.org Objet : Re: logging framework for restlet Rhett Sutphin wrote: Hi Arjohn, On Sep 18, 2009, at 10:31 AM, Arjohn Kampman wrote: I was wondering if you ever considered to use a logging framework such as slf4j instead of using java util logging directly. This can make integration of restlet in applications that don't use JUL a lot easier. I'd be in favor of this, too, but the core team is dedicated zero dependencies in the core of the framework. Here's a discussion from last March: http://markmail.org/search/?q=restlet%20slf4j#query:restlet%20slf4j +page:1+mid:spk4x55pegqktg2y+state:results Guess this has had some attention before. Thanks for the pointer. Reading through Jerome's comments: There is also a bridge from JUL to sl4j (http://www.x4juli.org/) that you could leverage. x4juli actually works the other way around: it implements the slf4j APIs so you can use it as a logger in the slf4j framework. There is a jul-to-slf4j bridge available from slf4j.org, but that is said to add considerable overhead to the logging: Consequently, j.u.l. to SLF4J translation can seriously impact on the cost of disabled logging statements (60 fold increase) and a measurable impact on enabled log statements (20% overall increase). -- http://slf4j.org/legacy.html A main design constraint that we have is zero external dependency for the Restlet API/Engine beside the JRE. It is good for compactness, facility of deployment Good arguments, I would say. and also because we don't want to force our users to use one logging mechanism over another. Now here's the funny thing: based on the exact(!) same argument, we actually decided to switch from jul to slf4j. Getting jul to bridge to slf4j seems to be non-trivial task, while the reverse is as simple as adding the appropriate jar-file to your classpath. So the main question now seems to be: is this sufficient reason to add a small (30kb) external dependency to restlet? -- Arjohn -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=23965 48 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2401976 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2402111
Re: Still getting No target class was defined for this finder
Hi Norton, Please don't post the same message multiple times on different lists. Can you try 2.0M5 and see if it resolves the issue for you? Rhett On Sep 28, 2009, at 9:28 AM, norton borf wrote: Hi, I am running the 2.0 JEE Jars from the unstable URL at (http://www.restlet .org/downloads/2.0/restlet-jee-2.0snapshot.zip) and am getting this error still today. I've been working on trying to get this working all day and am about to throw in the towel. I tried the earlier poster's suggestions for a fix using the targetClass solution, but then I cannot inject beans into my UserResource. I also get this simular error using the SpringBeanRouter method further below Error: Message ID No target class was defined for this finder Complete Message org.restlet.ext.spring.SpringFinder$$EnhancerByCGLIB$$aa c352c...@5e0f81b1 --- my config --- bean id=router class=org.restlet.ext.spring.SpringRouter constructor-arg ref=feedbackRestApp / property name=attachments map entry key=/users bean class=org.restlet.ext.spring.Sprin gFinder lookup-method name=createResource bean=userResource/ /bean /entry entry key=/users/{email} bean class=org.restlet.ext.spring.Sprin gFinder lookup-method name=createResource bean=userResource/ /bean /entry /map /property /bean bean id=userResource autowire=byName scope=prototype class=com.my.package.rest.v1.resou rce.UserResource property name=userService ref=userService/ /bean Also was getting a simular error using the SpringBeanRouter below: --- THIS BELOW CONFIG WORKS AS EXPECTED; - bean id=router class=org.restlet.ext.spring.SpringRouter constructor-arg ref=myRestApp / property name=attachments map entry key=/dog value=com.my.p ackage.rest.v1.resource.UserResource / /map /property /bean --- THIS BELOW CONFIG FAILS WITH: No target class was defined for this finder org.restlet.ext.spring.springbeanfin...@47696dad - bean name=router class=org.restlet.ext.spring.Sprin gBeanRouter/ bean name=/dog id=userResource autowire=byName scope=prototype class=com.my.package.rest.v1.resou rce.UserResource/ -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2401247 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2401380
Re: Trying to build Restlet from source, error?
Hi Norton, I don't have a solution for you, but I can verify that I'm seeing a similar failure on OS X 10.6 with Java 1.6.0_15: build: [fmpp] fichier /Users/rsutphin/java/restlet/svn/trunk/build/ project.xml [fmpp] fichier /Users/rsutphin/java/restlet/svn/trunk/modules [fmpp] fichier /Users/rsutphin/java/restlet/svn/trunk/libraries [fmpp] Missing library.xml file inside: /Users/rsutphin/java/ restlet/svn/trunk/build/../libraries/com.sun.rowset_1.0 [fmpp] Missing library.xml file inside: /Users/rsutphin/java/ restlet/svn/trunk/build/../libraries/org.mortbay.jetty_4.2 [fmpp] Missing library dependency: xdb for module xdb [fmpp] - Executing: edition.properties [fmpp] - Executing: libraries.properties [fmpp] - Executing: modules.properties [fmpp] Summary: 3 exe. + 0 xml. + 0 cop. = 3 succ.; 0 warn.; 0 failed [fmpp] fichier /Users/rsutphin/java/restlet/svn/trunk/build/ project.xml [fmpp] fichier /Users/rsutphin/java/restlet/svn/trunk/modules [fmpp] fichier /Users/rsutphin/java/restlet/svn/trunk/libraries [fmpp] Missing library.xml file inside: /Users/rsutphin/java/ restlet/svn/trunk/build/../libraries/com.sun.rowset_1.0 [fmpp] Missing library.xml file inside: /Users/rsutphin/java/ restlet/svn/trunk/build/../libraries/org.mortbay.jetty_4.2 [fmpp] Missing library dependency: xdb for module xdb [fmpp] - Executing: dependencies.txt [fmpp] Error [fmpp] Task aborted: FMPP processing session failed. [fmpp] Caused by: java.lang.NullPointerException [fmpp] Summary: 0 exe. + 0 xml. + 0 cop. = 0 succ.; 0 warn.; 1 failed BUILD FAILED /Users/rsutphin/java/restlet/svn/trunk/build/build.xml:204: The following error occurred while executing this line: /Users/rsutphin/java/restlet/svn/trunk/build/build.xml:84: FMPP processing session failed. Caused by: java.lang.NullPointerException This is the tail end of the output -- I can provide more context if necessary. It is failing the same way on OS X 10.5 with Java 1.5.0_20. Rhett On Sep 24, 2009, at 5:32 PM, norton borf wrote: Hi, I just checked out the Restlet trunk from SVN and am trying to build the project by just running ant from the build/ directory. I get the following errors regarding a missing library dependency. I am using ant 1.7 on OS-X with Java 1.6. The script eventually gets a null pointer along with more warnings about this missing dependancy. Pointers? generate-poms: [fmpp] fichier /Users/lowbowow/Documents/workspace-3.5/restlet- trunk/build/project.xml [fmpp] fichier /Users/lowbowow/Documents/workspace-3.5/restlet- trunk/modules [fmpp] fichier /Users/lowbowow/Documents/workspace-3.5/restlet- trunk/libraries [fmpp] Missing library.xml file inside: /Users/lowbowow/ Documents/workspace-3.5/restlet-trunk/build/../libraries/ com.sun.rowset_1.0 [fmpp] Missing library.xml file inside: /Users/lowbowow/ Documents/workspace-3.5/restlet-trunk/build/../libraries/ org.mortbay.jetty_4.2 [fmpp] Missing library dependency: xdb for module xdb [fmpp] File processed. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2400019 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2400268
Re: Problem with SpringBeanFinder in Restlet 2.0m4
Hi Norton, On Sep 25, 2009, at 11:36 AM, norton borf wrote: Thanks for posting that. I just updated to the latest jars in the snapshot you referenced. My project includes org.restlet.jar and org.restlet.spring.jar in my WAR file, however it is reporting the following on startup. I looked at the org.restlet.spring.jar contents and it does not include this servlet. Which jar should I be referencing instead? Did you download the JEE edition? SpringServerServlet is not included in the JSE edition. I see it in lib/org.restlet.ext.spring.jar in restlet-jee-2.0snapshot.zip. Rhett exception javax.servlet.ServletException: PWC1397: Wrapper cannot find servlet class org.restlet.ext.spring.SpringServerServlet or a class it depends on root cause java.lang.ClassNotFoundException: org.restlet.ext.spring.SpringServerServlet Hi there, As a workaround, there is a new snapshot available including the Spring fixes: http://www.restlet.org/downloads/unstable 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=4447dsMessageId=2400317 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2400325
Re: SVN repository location
Hi Sanjay, On Sep 24, 2009, at 1:33 PM, Sanjay Acharya wrote: What is the location of the SVN repo for restlet? http://www.google.com/search?q=what+is+the+location+of+the+svn+repo+for+restlet Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2399889
Re: how to Router.attach() a resource object
Hi Anonymous, On Sep 21, 2009, at 4:03 PM, webp...@tigris.org wrote: hi, I am trying to do: {{{ final Router router = new Router(); router.attach(/about, new DirectToTemplateResource (about.xml).getClass()); router.attach(/contact, new DirectToTemplateResource (contact.xml)); }}} DirectToTemplateResource will return StringRepresentation of HTML according to some template passed in the constructor. But since Router tries to instantiate DirectToTemplateResource() using default constructor (which does not exist), I can't make it happen. I am sure I'm not using Restlet properly. What am I misunderstanding? Restlet resources are not singletons -- a new instance is created to handle each request. As a way around, I could do: {{{ router.attach(/about, AboutResource.class); router.attach(/contact, ContactResource.class); }}} But I need to create many similar classes. I also tried to extend Restlet (or Application) because router.attach takes Restlet instance. Is it safe for me to override Restlet.handle() method? So, my code would look like: {{{ router.attach(/about, new RenderTemplateRestlet(about.xml)); router.attach(/contact, new RenderTemplateRestlet(contact.xml)); }}} where RenderTemplateRestlet will have handle() method overloaded properly. This is one solution, but you lose out on a lot of Restlet's usefulness if you go this route. What's a best way to do what I'm trying to do? Two options: 1) Since in your example the template filename seems to be based on the URL, you could modify DirectToTemplateResource to infer the template to use based on the request information. 2) If you do need to be explicit about the template filename (i.e., if the template filename isn't always directly related to the URL), you can extend org.restlet.Finder. Depending on which version of restlet you're using, you'll need to either override #createTarget (1.1) or #create (2.0) to create instances of your resource. Then you'll wire up instances of your new finder to the router. See the Finder javadoc for more info. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2397825
Re: logging framework for restlet
Hi Arjohn, On Sep 18, 2009, at 10:31 AM, Arjohn Kampman wrote: I was wondering if you ever considered to use a logging framework such as slf4j instead of using java util logging directly. This can make integration of restlet in applications that don't use JUL a lot easier. I'd be in favor of this, too, but the core team is dedicated zero dependencies in the core of the framework. Here's a discussion from last March: http://markmail.org/search/?q=restlet%20slf4j#query:restlet%20slf4j +page:1+mid:spk4x55pegqktg2y+state:results Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2396499
Re: logging framework for restlet
Hi Tal, On Sep 18, 2009, at 10:57 AM, Tal Liron wrote: I use slf4j in my Restlet applications with much success. It will likely not be added to Restlet's distribution, but there's no reason why you can't do it on your own. Perhaps someone can write a recipe for how to do this on the Restlet wiki? No, I'm not volunteering myself. :) There already is one, way down at the bottom of the page Jerome linked to in that other thread: http://wiki.restlet.org/docs_1.2/13-restlet/48-restlet/101-restlet.html I have had no joy getting this to work in Tomcat (I tried putting it in a ServletContextListener), but I also haven't tried very hard. Rhett -Tal On 09/18/2009 10:37 AM, Rhett Sutphin wrote: Hi Arjohn, On Sep 18, 2009, at 10:31 AM, Arjohn Kampman wrote: I was wondering if you ever considered to use a logging framework such as slf4j instead of using java util logging directly. This can make integration of restlet in applications that don't use JUL a lot easier. I'd be in favor of this, too, but the core team is dedicated zero dependencies in the core of the framework. Here's a discussion from last March: http://markmail.org/search/?q=restlet%20slf4j#query:restlet%20slf4j +page:1+mid:spk4x55pegqktg2y+state:results Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2396499 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2396501 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2396505
Re: Resource Cleanup
Hi Matt, On Sep 17, 2009, at 9:14 AM, webp...@tigris.org wrote: I am using a router and the attach method (attach(uri pattern,class extends Resource) for my application. My question is: when I'm finished with the resource (and I know I no longer need it), what do I do to clean up? Is it as simple as calling router.detach? or must I also delete the resource somehow so that garbage collection can reclaim that memory? Restlet creates a new instance of your resource class for each request. It will go out of scope and be eligible for garbage collection after the request is complete. If you are talking about having the resource class itself garbage collected, then I think that calling detach would be sufficient from the restlet perspective. (Whether or not the class will actually be eligible for collection at that point depends on the environment in which you're running.) I've never tried that myself, though. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2396121
Re: spring context - webapplication context in restlet 2
Hi Rahul, On Sep 15, 2009, at 8:54 AM, Rahul Juneja wrote: Rhett, I tried the following things in ServerResource File. anyways thats ok but i have a question about why Restlet doesn't expose the Servlet context which is one of the attributes added to the context of the application. org.restlet.ext.servlet.ServletContext ? Do you mean why doesn't Restlet expose the ServletContext in the ServerResource API? Because that would create a dependency in Restlet core on a JEE class. Restlet core is designed to run without JEE. Rhett Thanks, Rahul On Mon, Sep 14, 2009 at 5:39 PM, Rhett Sutphin rh...@detailedbalance.net wrote: Hi Rahul, On Sep 13, 2009, at 11:39 AM, Rahul Juneja wrote: I wanted to get some spring injected beans in my resource file. and i have looked at the integration with spring in other ways but i would not be very interested in that as i want to keep spring separate from restlet. Also i am aware of the concern that this way my application will be tied to Servlet api. but i think i am fine with that as i will be running on tomcat only. I looked at SpringServerServlet and tried calling getWebApplicationContext() or getServletContext() but in both the cases i am getting exception. I did not do anything else. except calling this method from the resource file. Is there any other steps i need to follow to get the springContext or webappllication context to get the beans from the spring. getServletContext() inside a servlet is provided by the JEE API. If that's throwing an exception, you have a non-restlet-related problem. I'm not so familiar with SpringServerServlet, but it appears that it is loading the spring application context from the standard (for spring) JEE location. Are you loading the application context using ContextLoaderListener? You might also try out RestletFrameworkServlet. It allows you to configure restlet in approximately the same way you configure Spring MVC. Again, though, if you can't invoke getServletContext() from inside a servlet, none of these solutions are going to work for you. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2394793 -- Rahul Juneja Phone : (631) 681-9996 Fax : (206) 339-9047 http://techlabs.thoughtclicks.com http://finance.thoughtclicks.com --- The thing always happens that you really believe in; and the belief in a thing makes it happen. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2395203
Re: Spring Integration with Restlet 2.0m4
Hi Rahul, There's a known bug with SpringFinder in 2.0M4. It will hopefully be fixed in the next milestone. http://restlet.tigris.org/issues/show_bug.cgi?id=892 Rhett On Sep 12, 2009, at 5:42 PM, Rahul Juneja wrote: Here is my scenario. I am trying to inject some service in my ServerResource class and its just not injecting the service. The steps I have performed are as follows. util:map id=resourceMap entry key=/request bean id=configurationFinder class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=requestResouce/ /bean /entry /util:map bean id=requestResouce class=com.thoughtclicks.requestResource scope=prototype property name=service ref=serviceBean / /bean Where serviceBean is already defined in the config file. also Resource class is a simple Class extending ServerResource and having a property called service with a public getter and setter of the property. My application class is simple extending the Application class from org.restlet.Application with the following code : @Override public Restlet createRoot() { Router router = new Router(getContext()); SpringContext springContext = new SpringContext(getContext()); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader (springContext); xmlReader.loadBeanDefinitions(new ClassPathResource(resource/ appContext.xml)); springContext.refresh(); MapString, Finder resourceMap = (MapString, Finder) springContext.getBean(resourceMap); for (String key : resourceMap.keySet()) { router.attach(key, resourceMap.get(key)); } return router; } Not sure what is wrong as my service is returning null for some reason and when i see the logs i don;t see my injection methods being called. Any clues or pointers to this is highly appreciated. Thanks, Rahul -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2394329
Re: Problem with SpringBeanFinder in Restlet 2.0m4
Hi Evgeny, Thanks for the test code. This is now in the issue tracker here: http://restlet.tigris.org/issues/show_bug.cgi?id=892 Rhett On Sep 2, 2009, at 2:41 AM, Evgeny Shepelyuk wrote: Hi ! Here goes test project Hi Evgeny, Someone else had this problem, but I think we thought it was fixed in 2.0M4. I'll can take a look at it in the next few days. Can you file a bug? Thanks, Rhett On Aug 31, 2009, at 5:00 AM, Evgeny Shepelyuk wrote: Hello, I'm migrating application from 1.1 branch to 2.0 and have problems with SpringBeanFinder. Is it usable in 2.0 branch ? While debugging i've discovered that check is performsed against targetClass property. This happen in superclass Finder. But this shouldn't be taken into account. The same code worked OK in 1.1 branch. Let me put snippet of XML to illustrate. TransactionResource extends ServerResource. bean id=transactionResource class=com.si.prydbay.billing.restlet.TransactionResource scope=prototype property name=transactionService ref=transactionService/ property name=transactionsHtml value=classpath:transactions.html/ property name=tokenService ref=tokenService/ /bean bean id=merchantRouter class=org.restlet.ext.spring.SpringRouter property name=attachments map entry key=/transactions/{transactionId} bean class=org.restlet.ext.spring.SpringBeanFinder property name=beanName value=transactionResource/ /bean /entry /map /property /bean -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2388816 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2389914 -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2390072 src.zip -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2391744
Re: Problem with SpringBeanFinder in Restlet 2.0m4
Hi Evgeny, Someone else had this problem, but I think we thought it was fixed in 2.0M4. I'll can take a look at it in the next few days. Can you file a bug? Thanks, Rhett On Aug 31, 2009, at 5:00 AM, Evgeny Shepelyuk wrote: Hello, I'm migrating application from 1.1 branch to 2.0 and have problems with SpringBeanFinder. Is it usable in 2.0 branch ? While debugging i've discovered that check is performsed against targetClass property. This happen in superclass Finder. But this shouldn't be taken into account. The same code worked OK in 1.1 branch. Let me put snippet of XML to illustrate. TransactionResource extends ServerResource. bean id=transactionResource class=com.si.prydbay.billing.restlet.TransactionResource scope=prototype property name=transactionService ref=transactionService/ property name=transactionsHtml value=classpath:transactions.html/ property name=tokenService ref=tokenService/ /bean bean id=merchantRouter class=org.restlet.ext.spring.SpringRouter property name=attachments map entry key=/transactions/{transactionId} bean class=org.restlet.ext.spring.SpringBeanFinder property name=beanName value=transactionResource/ /bean /entry /map /property /bean -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2388816 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2389914
Re: OSGi vs. Service Provider patterns
Hi, On Aug 11, 2009, at 10:42 AM, Rob Heittman wrote: At one point I was given to understand that Equinox was the only OSGi framework that yet understood fragments. I'd be worried about going the fragment route if that's still true. But if KF and Felix and friends now grok fragments (or will soon), I think that would be a lovely way to repackage all the Restlet stuff for my purposes too. My experience with Felix is that it supports fragments, but the support is delicate. See: https://issues.apache.org/jira/browse/FELIX-29 . Rhett On Tue, Aug 11, 2009 at 11:23 AM, David Fogel carrotsa...@gmail.com wrote: 2) I prefer, and currently use via a custom build, the bundle _fragment_ approach for restlet extensions. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2382594
Re: Spring Intergation. Spring managed resources
Hi, On Aug 4, 2009, at 7:19 AM, webp...@tigris.org wrote: I'm using Spring and Restlet 1.2m2. Actually I have tow stupid ServerResources who never interact with the rest of the app. But now I have to write a ServerResource who want a Service and, of course, I want to inject it with Spring but I'm unable to found any integration samples for using Spring managed resources. Actually I have the following Spring config : -- 8 --- bean id=manager class=web.services.rest.impl.restlet.RestManager property name=/property property name=resourceMappings map entry key=/form value=web.services.rest.impl.restlet.resources.FormsResource / entry key=/form/{id} value=web.services.rest.impl.restlet.resources.FormResource / entry key=/search/{object} value=web.services.rest.impl.restlet.resources.SearchResource / /map /property /bean bean id=searchService class=domain.services.search.SearchServiceImpl / -- 8 --- And I want to pass searchService trought the constructor of / search/{object} resource. There are several ways to do this. Look through the Javadoc for the spring extension and find the one that suits you best: http://www.restlet.org/documentation/2.0/jse/ext/org/restlet/ext/spring/package-summary.html In particular, you'll probably want to take a look at SpringBeanRouter and SpringRouter. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2380994
Re: JAX RS exceptions with illegal QueryParameter
Hi Nicolas, On Aug 6, 2009, at 4:29 PM, Nicolas Rinaudo wrote: Yes, you're absolutely right, that's in the JAX RS specifications. I was just wondering whether RESTlet had an extension to the basic specifications that allowed more control over what error code was used (an @Error(400) annotation, for example). The different for the user, if we're talking about a web user, is slim at best. An error occurred but that's not really his problem, the UI should have sheltered him from such basic syntax errors. For the developer writing a client application, however, it can save a lot of time. Knowing precisely why your implementation fails is always preferable in my opinion than just having a generic failed error. FWIW, I agree with you here. In the situation you described in the original e-mail, I'd use either 400 or 422 with a message describing the problem. I don't use JAX-RS, though, so I can't help you on your technical question. Rhett I'm oversimplifying things here, but that's the difference between throwing a NumberFormatException and a generic Exception. Apologies if I'm taking the debate too far, I'm aware that RESTlet is following the specifications to the letter and am not complaining about that at all. To be honest, I should have asked that question to the JAX RS design group but couldn't find any public forum and thought that since Jérome Louvel sits at that comity and is working on the implementation of the specifications that I'm using, this would be the next best place to voice my questions... Regards, Nicolas -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2381083 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2381095
Re: getting the button from a Form
Hi Marc, On Jul 15, 2009, at 4:45 AM, Marc Lerma wrote: hello everyone, In my application, I need to get the id of a form button when managing a POST call on a given resource. this is my form i'm posting to my resource: form name=login method=post action=/iwf-rest-client/login Name:br input type=text name=iwf.user_name cols=55 rows=10/ textareabr Password:br input type=text name=iwf.user_password size=55 value= input type=button name=submitButton value=Submit onclick=document.forms['login'].submit() The onclick handler here is why you aren't getting the submitButton=Submit value in the posted representation. Use input type=submit name=submitButton value=Submit instead. Rhett /form and I'm getting it as follows: @Post public Representation sendForm(Representation entity) { Form form = new Form(entity); //get the names of the form fields Set String names = form.getNames(); ... } I'm being able to get all the field names but the button one, and I definitely need it. is there any means by which I can get the button name ('submitButton')??? thanks in advance! -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2371432 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2371499
Re: The best way to integrate servlets with restlets
Hi Tamer, I think this is more of a discuss topic, so I'm moving it there. On Jun 30, 2009, at 9:13 AM, tameremil wrote: Hello, I am currently working on an application where I have to provide a rich web client as well as a REST API. I chose to use RESTLET for my REST API. Now when it comes to the web interface, I have two choices: 1. either infest my application with countless javascript code (which would call the REST API then render) [Side note: don't reject JavaScript out of hand. With an appropriate toolkit to patch over the inter-browser messiness (I like jQuery and YUI) and good unit tests, a dynamic, JS-based UI could be your best bet.] 2. use servlets and jsps. I chose to stay away from javascript as much as possible and rely on servlets and jsps to render web UI. However, now I am facing a dilema. In order to call the REST API from my servlets I am using the RESTLET CLIENT, this approach has proved to be inefficient. Every time I make a call I have to parse the returned JSON and go through pain to extract API call response. It sounds like you have (conceptually) a single server which provides both an HTML-based web GUI and a JSON API. If that's so, that's a common case. You can use Restlet for both representations -- in fact, this sort of thing is one of the things the RESTful architecture style excels at. The idea is that you implement the same Resources, with the same associated logic, but allow them to return different Representations based on what the client requests. This concept is Content Negotiation and Restlet supports it. I'd suggest reading the O'Reilly RESTful Web Services book for more info. One caveat is that I don't think you can use JSP to render a Restlet Representation. You can use FreeMarker, though, which is similar (some would say better). I read about the Servlet Convertor, but I am not sure how I can use it here. I am not concerned about tight integration between Servlets and Restlets as long as I can have my RESTLETs not depend on my servlets (but I do not care about the opposite). The Servlet Convertor is to allow you to serve your Restlet application via a Servlet container. My Questions: 1. What is the best way to integrate my servlet with the RESTLETs? 2. Is there a way for me to pass java objects from the restlet to the servlet? This way in the servlet I can extract java objects and not rely on re-assembling the JSON or XML contained in the Response Representation? For a new application (and assuming I understand what you're trying to do), I'd suggest using content negotation in Restlet and not using Servlet/JSP at all. If you really don't want to do that, or if you already have a large investment in JSP-based views, I'd extract the business logic into a separate layer and make it available to both your servlets and your restlets. Rhett Please let me know if my question is not clear. I am in a tough bind and would appreciate any and all help. Thank you, Tamer -- View this message in context: http://n2.nabble.com/The-best-way-to-integrate-servlets-with-restlets-tp3182669p3182669.html Sent from the Restlet Code mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=7458dsMessageId=2366718 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2366777
Re: Mysterious message in client
Hi Rick, On Jun 24, 2009, at 4:59 PM, Rick wrote: Hi, I've written the client for my web serv ice program. This client is also in Java. Whenever I invoke the client through my shell script, it gives me the following message: [code] [mybox:/var/]$ ./validate.sh Jun 24, 2009 9:49:55 PM com.noelios.restlet.http.StreamClientHelper start INFO: Starting the HTTP client Jun 24, 2009 9:49:55 PM com.noelios.restlet.http.HttpClientCall getResponseEntity INFO: The length of the message body is unknown. The entity must be handled carefully and consumed entirely in order to surely release the connection. [mybox:/var/]$ [/code] Can I ignore this message or is it some problem with the code? How can I skip the message without ignoring through log4j properties? If you control the service, I believe you can avoid this by making sure that it includes an accurate Content-Length header in the response. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2365373
Re: Hierarchical URI routing w/ Spring
Hi, On Jun 24, 2009, at 11:40 AM, webp...@tigris.org wrote: I have a hierarchy of container type objects that I want to be able to use. ex: /branch/{branch_id}/ /branch/{branch_id}/branch/{branch_id}/ /branch/{branch_id}/branch/{branch_id}/branch/{branch_id}/ etc. This structure can be arbitrarily deep, and each branch can have other items attached. Please correct me if I'm wrong, but I think routes like these aren't going to work -- {branch_id} is defined multiple times. At best you're only going to get one of the values in the request attributes. ex: /branch/{branch_id}/ /branch/{branch_id}/branch/{branch_id}/leaves/{leaf_id}/ /branch/{branch_id}/branch/{branch_id}/buds/{bud_id}/ etc. I want to be able to configure this using the Spring integration. I have this: bean name=root class=org.restlet.ext.spring.SpringRouter constructor-arg ref=application / property name=attachments map entry key=/branch/{branch_id} value=com.example.api.resource.BranchResource/ entry key=/branch/{branch_id}/leaves/{leaf_id}/ value=com.example.api.resource.LeafResource/ entry key=/branch/{branch_id}/buds/{bud_id}/ value=com.example.api.resource.budResource/ /map /property /bean !-- Spring Application -- bean id=application class=org.restlet.Application property name=name value=exampleAPI/property /bean which handles the root cases, but does not handle nested branches. Is there a way to construct the URI patterns to look at this arbitrarily deep hierarchy, but still get teh correct leaf and bud resources? You can do this. It's legal for the routed values to be other routers. To configure that with Spring, you need to build the attachment map using either bean refs or nested bean definitions for the subrouters. (This is in contrast to the implicit String-to- Resource conversion that you're using for the resources in the example. It's fine to continue to use that for resources, though.) Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2365422
Re: Response for a 405 can't be parsed by SAX
Hi Stephan, On Jun 13, 2009, at 3:45 PM, Stephan Koops wrote: Hi Rhett, Hello Everyone, I had a question about the 405 response message returned by Restlet 1.1.1. When I try a parse the XML response, I get the following: [Fatal Error] :8:3: The element type br must be terminated by the matching end-tag /br. The entire response: html head titleStatus page/title /head body h3The method specified in the request is not allowed for the resource identified by the request URI/h3pYou can get technical details a href=http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.6 here/a.br Please continue your visit at our a href=/home page/a. /p /body /html I'm sure I can edit the response before it gets out of my service, but I thought this might be something useful to bring up. Thanks for any insight. SAX can't parse it because it's HTML, not XML. (br alone is valid HTML.) You should be able to determine whether it is HTML or XML in your client by examining the content type header. Is restlet not setting that header correctly? If you want to provide XML-formatted error responses, I believe you'll have to implement them yourself. But it is a problem, if Restlet would return br/ instead od br ? Than it is also correct XML (and XHTML?) I wouldn't have a problem with that. At the same time, though, I don't see why you'd need to parse it as XML. The message is basically just translating from the error code into English. Since the error code is already part of the response, doesn't it make more sense to skip parsing the body if there's an error and the service you're talking to doesn't define special error bodies? After all, if the representation being requested were JSON (or PNG, or PDF, etc.), you'd get this same response body back with the error (by default). It's not Restlet's job to provide error bodies that are parseable as the same content type as a success would be. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2361892
Re: Response for a 405 can't be parsed by SAX
Hi John, On Jun 12, 2009, at 10:10 AM, John Prystash wrote: Hello Everyone, I had a question about the 405 response message returned by Restlet 1.1.1. When I try a parse the XML response, I get the following: [Fatal Error] :8:3: The element type br must be terminated by the matching end-tag /br. The entire response: html head titleStatus page/title /head body h3The method specified in the request is not allowed for the resource identified by the request URI/h3pYou can get technical details a href=http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.6 here/a.br Please continue your visit at our a href=/home page/a. /p /body /html I'm sure I can edit the response before it gets out of my service, but I thought this might be something useful to bring up. Thanks for any insight. SAX can't parse it because it's HTML, not XML. (br alone is valid HTML.) You should be able to determine whether it is HTML or XML in your client by examining the content type header. Is restlet not setting that header correctly? If you want to provide XML-formatted error responses, I believe you'll have to implement them yourself. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2361683
Re: Weird exception using Spring integration
Hi Stephane, This error means that the entity has already been read by the time your resource starts executing. This might happen in a filter, for example. AFAIK, the SpringBeanRouter (and its various helpers) do not touch the entity. Rhett On May 13, 2009, at 9:17 AM, Stephane Nicoll wrote: Any idea? Thanks, Stéphane On Sat, May 9, 2009 at 5:21 PM, Stephane Nicoll stephane.nic...@gmail.com wrote: Hi, We move recently to the Spring integration (SpringBeanRouter and RestletFrameworkServlet). Since then, we have a resource that does not behave properly (and not on all environments) The Web form cannot be parsed as no fresh content is available. If this entity has been already read once, caching of the entity is required And the stacktrace is: java.lang.IllegalStateException: The Web form cannot be parsed as no fresh content is available. If this entity has been already read once, caching of the entity is required at com.noelios.restlet.util.FormUtils.parse(FormUtils.java: 243) at com.noelios.restlet.Engine.parse(Engine.java:978) at org.restlet.data.Form.init(Form.java:84) at org.restlet.data.Form.init(Form.java:133) at org.restlet.data.Message.getEntityAsForm(Message.java:193) at com .erdas .rsp .babel .service .rest.resource.service.ServicesResource.init(ServicesResource.java:64) at org.restlet.ext.spring.SpringFinder.createTarget(SpringFinder.java: 133) at org.restlet.ext.spring.SpringFinder.createTarget(SpringFinder.java:68) at org.restlet.Finder.findTarget(Finder.java:240) at org.restlet.Finder.handle(Finder.java:329) at org.restlet.Filter.doHandle(Filter.java:150) at org.restlet.Filter.handle(Filter.java:195) at org.restlet.Router.handle(Router.java:504) at org.restlet.Filter.doHandle(Filter.java:150) at org.restlet.Filter.handle(Filter.java:195) at org.restlet.Filter.doHandle(Filter.java:150) This exception is thrown when we call the getEntityAsForm on the resource. Any idea? We're using restlet 1.1.4, Linux, JDK6, Spring 2.5.6 Thanks, Stéphane -- Large Systems Suck: This rule is 100% transitive. If you build one, you suck -- S.Yegge -- Large Systems Suck: This rule is 100% transitive. If you build one, you suck -- S.Yegge -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2244510
Re: SpringBean router not discovering any routes
Hi, Thanks for the offer. Detecting restlets has also been added to SpringBeanRouter for version 1.2. Rhett On Apr 25, 2009, at 7:21 AM, Stephane Nicoll stephane.nic...@gmail.com wrote: That did the trick, thanks. I have also extended the SpringBeanRouter to detect and deploy restlets as well. The implementation is rather stupid but I'd be happy to contribute it back. Thanks, Stéphane -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1910678 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1945999
Re: SpringBean router not discovering any routes
Paul's correct -- in 1.1, SpringBeanRouter only looks at the aliases. Spring doesn't consider the name to be an alias unless there's also an id. In 1.2, SpringBeanRouter will consider the bean's primary identifier in addition to the aliases. Rhett On Apr 24, 2009, at 10:07 AM, Paul Austin wrote: Give you bean an id in addition to the name. I think there was a bug in the 1.1.x series which required there to be an id. bean name=/services id=services Paul On Fri, Apr 24, 2009 at 1:43 AM, Stephane Nicoll stephane.nic...@gmail.com wrote: Hi, I am trying to use the spring based config in 1.1.4 with Spring 2.5.6 and I just can't get it working. My Application adds additional filters, one of them being my main router as a SpringBeanRouter class. I have a set of resources and restlet defined in the same application context file and I can see through the debugger they are loaded and discovered by the Spring Bean router. In the 'postProcessBeanFactory' method of the SpringBeanRouter, the resolveUri always returns null because the aliases returned by the factory is an empty String. I honestly don't get it! Here's is one entry in my spring config file bean name=/services autowire=byName scope=prototype class=com.foo.service.ServicesResource property name=context ref=restletContext/ /bean - Any idea? Is the autowire byName mandatory? Is there a sample somewhere? Thanks, Stéphane -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1888396 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1894008
Re: Guards through Spring
Hi Dustin, I'm using Restlet 1.2 with the SpringBeanRouter, but I've noticed that it only picks up those URLs that are tied to a Resource, and not a Guard. Would it be appropriate to simply override the postProcessBeanFactory() method to look for Guards too? Would this be considered a bug/issue or is there another way of attaching Guards through Spring? I'd consider that an issue. Can you file a bug? It would be fairly straightforward to extend SpringBeanRouter to handle attaching Guards (and Filters, and any other Restlets) in a similar way to how it handles Resources. Note that, since SpringBeanRouter can only handle attaching things to itself, if you have multiple Resources behind your Guard, you'll have to figure out some other way to set up those routes. Rhett On Apr 15, 2009, at 12:46 PM, Dustin N. Jenkins wrote: I'm using Restlet 1.2 with the SpringBeanRouter, but I've noticed that it only picks up those URLs that are tied to a Resource, and not a Guard. Would it be appropriate to simply override the postProcessBeanFactory() method to look for Guards too? Would this be considered a bug/issue or is there another way of attaching Guards through Spring? 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=1730566 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1730917
Re: Spring restlet configuration
Hi, On Apr 13, 2009, at 5:06 PM, webp...@tigris.org wrote: Forgot to attach the app log, the line INFO: Routes: /sample/ locations it's added by me and actually checks that the router used by the application contains a route for /sample/locations, the request is for /sample/locaions but still getting a 404 [INFO] Started Jetty Server 13-abr-2009 23:52:41 com.yoolab.geolocalization.restlet.GeolocalizationApplication createRoot INFO: Routes: 2 13-abr-2009 23:52:41 com.yoolab.geolocalization.restlet.GeolocalizationApplication createRoot INFO: Routes: /sample/locations 2009-04-13 23:52:41.957:/sample:INFO: SpringServerServlet: [Noelios Restlet Engine] - Attaching application: com.yoolab.geolocalization.restlet.Geoloca lizationapplicat...@17f5b38e to URI: /sample 13-abr-2009 23:52:41 com.noelios.restlet.LogFilter afterHandle INFO: 2009-04-1323:52:41127.0.0.1 - 127.0.0.1 8080 GET /sample/locations - 404 330 - 0 http://localhost:8080 Mozilla/5.0 (Windows; U; Windows NT 6.0; es- ES; rv:1.9.0.8) G ecko/2009032609 Firefox/3.0.8 (.NET CLR 3.5.30729) - A guess: from the log it appears that your Application is mounted at / sample. If you have a route within that application that is attached to /sample/location, I think that the effective URI for that resource would be /sample/sample/location. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1710877
Re: SpringBeanRouter
Hi Jim, On Apr 14, 2009, at 1:57 AM, Jim Alateras wrote: Rhett, Thanks for the quick turnaround and suggestions On 14/04/2009, at 2:19 PM, Rhett Sutphin wrote: Hi Jim, On Apr 13, 2009, at 7:56 PM, Jim Alateras wrote: I am currently using s custom class to attach routes to a router but am now looking at using the SpringBeanRouter but have a couple of questions. 1. In the example below if i also want to support the a query string would i change the bean name to /studies?{query} You should set the bean name to whatever you were formerly passing to Router#attach. At the moment my custom class does something like this router.attach(/resource?{query}, this.resourceMap.get(uri)) .getTemplate().getVariables().put(query, new Variable( Variable.TYPE_URI_QUERY, , false, false)); will this still work? Ah, I'm not familiar with that sort of construction. I'm not sure if it would work, though my guess is no. Can you try it and see? If it doesn't work, could you open an issue? Thanks, Rhett 2. How do i specify a default route for the router. This isn't directly supported at the moment. The easiest thing to do right now is to subclass SpringBeanRouter and override postProcessBeanFactory something like this: @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) { super.postProcessBeanFactory(factory); this.attachDefault(createFinder(theDefaultResourceBeanName)) } excellent Rhett beans .. bean name=router class=org.restlet.ext.spring.BeanNameRouter/ bean name=/studies id=studiesResource autowire=byName scope=prototype class=edu.northwestern.myapp.StudiesResource /beans cheers /jima -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1699583 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1702638 cheers /jima -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1704873 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1710897
Re: SpringBeanRouter
Hi Jim, On Apr 13, 2009, at 7:56 PM, Jim Alateras wrote: I am currently using s custom class to attach routes to a router but am now looking at using the SpringBeanRouter but have a couple of questions. 1. In the example below if i also want to support the a query string would i change the bean name to /studies?{query} You should set the bean name to whatever you were formerly passing to Router#attach. 2. How do i specify a default route for the router. This isn't directly supported at the moment. The easiest thing to do right now is to subclass SpringBeanRouter and override postProcessBeanFactory something like this: @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) { super.postProcessBeanFactory(factory); this.attachDefault(createFinder(theDefaultResourceBeanName)) } Rhett beans .. bean name=router class=org.restlet.ext.spring.BeanNameRouter/ bean name=/studies id=studiesResource autowire=byName scope=prototype class=edu.northwestern.myapp.StudiesResource /beans cheers /jima -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1699583 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1702638
Re: [1.1.3] Tomcat + RestletFrameworkServlet mapping SpringBeanRouter to /
Hi Paul, On Apr 8, 2009, at 10:18 AM, Paul Austin wrote: Jerome, Here is an implementation which extends SpringBeanRouter, it could easily be integrated into the super class. Thanks for the suggestion. I've added something similar in SpringBeanRouter in trunk r4711, but I only added an attachments property (a la SpringRouter). Reasoning: I don't think that setAttachment makes sense as a bean property, since it is actually adding another attachment instead of replacing anything. Restlet's main Router class also has the concept of a default restlet. The semantics in Router are a bit different than what you have here (its default is the restlet that receives all requests that don't map to something else, not the top-level resource -- depending on the routing mode these might be different things), so I left it out. You should still be able to map the top-level route using the attachments property like so: property name=attachments map entry key=valuetopLevelResource/value/entry /map /property I haven't tried this, though, so if it doesn't work please let me know. (We can come up with a different property name if necessary.) Thanks again, Rhett import java.util.Map; import java.util.Map.Entry; import org.restlet.Finder; import org.restlet.ext.spring.SpringBeanRouter; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; public class SpringRouter extends SpringBeanRouter implements BeanFactoryAware { private BeanFactory beanFactory; public void setAttachment(String uriPattern, String beanName) { Finder finder = createFinder(beanFactory, beanName); attach(uriPattern, finder); } public void setAttachments(MapString, String attachments) { for (EntryString, String attachment : attachments.entrySet()) { String uriPattern = attachment.getKey(); String beanName = attachment.getValue(); setAttachment(uriPattern, beanName); } } public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; } public void setDefaultAttachment(String beanName) { String uriPattern = ; setAttachment(uriPattern, beanName); } } Paul On Wed, Apr 8, 2009 at 4:12 AM, Jerome Louvel jerome.lou...@noelios.com wrote: Paul, The problem is that the URI without the trailing slash isn't equivalent to the one with it. It's true that in many cases, people assume it is equivalent but it doesn't have to. Also, relative URIs can be expressed in the same way if the ends with a slash or not, leading to further routing issues. The only way we found to clean that is to force the client to redirect itself to the URI with a slash. However, it isn't something we should do automatically. BTW, there is a related RFE: Improve matching of directory URIs http://restlet.tigris.org/issues/show_bug.cgi?id=532 Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com De : Paul Austin [mailto:mail-li...@revolsys.com] Envoyé : mardi 7 avril 2009 21:58 À : discuss@restlet.tigris.org Objet : Re: [1.1.3] Tomcat + RestletFrameworkServlet mapping SpringBeanRouter to / Here is a class which fixes the issue. Probably a better solution would be to change the Route class so that if the remainingPart is it sets it to / before doing the regex matching. On a related note is it possible to force exact matching so that say /apps would be mapped but not /apps/xyz? public class RootSpringBeanRouter extends SpringBeanRouter { @Override public void handle(Request request, Response response) { Reference resourceRef = request.getResourceRef(); if (resourceRef.getRemainingPart().equals()) { resourceRef.addSegment(); } super.handle(request, response); } } On Tue, Apr 7, 2009 at 12:27 PM, Paul Austin mail- li...@revolsys.com wrote: In my project I am deploying an application as a war file. The root of the web application /* is mapped to the RestletFrameworkServlet so that all handling is performed by Restlet. servlet servlet-namebpf/servlet-name servlet- classcom.noelios.restlet.ext.spring.RestletFrameworkServlet/ servlet-class /servlet servlet-mapping servlet-namebpf/servlet-name url-pattern/*/url-pattern /servlet-mapping The root restlet is a SpringBeanRouter and I have a mapping for / to a resource as shown below. bean id=root class=org.restlet.ext.spring.SpringBeanRouter / bean name=/ id=rootResource scope=prototype class=myResourceClass / The war is deployed to /ws on my server. If I access /ws I get an Restlet status page error saying The server has not found anything matching the request URI but if I use /ws/ it works correctly. I tried mapping to to see if that
Re: Media types specified as a query parameter
Hi Fabio, On Apr 7, 2009, at 4:18 AM, Fabio Mancinelli wrote: Hi everybody, I would like to use query parameters in order to specify the media type to be sent to the client. Tunneling and metadata services should do the trick. However I cannot achieve this. I called in createRoot() of the JaxRsApplication (I am the using JAX- RS extension) getTunnelService().setEnabled(true); getTunnelService().setExtensionsTunnel(true); I think you want to use TunnelService's query tunnel instead of extensions tunnel. You may also need to set the mediaTypeParameter property (I'm not sure if there's a default). Rhett getMetadataService().addCommonExtensions() getMetadataService().setEnabled(true) and request some URI using: ?media=json ?media=application/json ?accept=application/json but it doesn't seem to work. Any hint? Thanks, Fabio -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1574220 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1577048
Re: Resource factories
Hi Kyrre, On Apr 7, 2009, at 9:28 AM, Kyrre Kristiansen wrote: Hello, all. *rant alert* I came over this discussion, and wanted to share my experiences with creating resources. I started playing around with restlet before it became 1.0, and am generally very, very pleased with it. One of the things I use it for is my own prototype environment, where I can throw together some quite impressive applications in a matter of hours.. After creating a whole host of different resource types, I started seeing some quite distinct patterns in my resources, at least the simplest ones. This resulted in using Generics on my resources, where I created a class, ListResourceT extends Referrable (where Referrable is an interface, with one method, getId() ). I already have a generic DAO implementation based on the Referrable interface. In addition, I created a ResourceConfigT extends Referrable that I could pull off all the things I need for the ListResource (including the DAO, that's why it's parametrized), as well as a FormBuilderT extends BaseObject interface for building my objects based on a Form. All this leads to ListResource being a concrete class that relies solely on one object, the config, and that works with any resource that represents a Referrable subtype and is a top-level list resource. This, however, is where my trouble starts. Because at run-time, the system cannot differentiate between a ListResourceFoo.class and a ListResourceBar.class due to type erasure. At the moment I have to subclass ListResource for each type I am using it for, but hopefully making a parametrized Finder class that can then be attached to a Router, will solve my troubles. Has anyonw tried this? This isn't specific to Restlet, but the way I handle this feature of generics is to define a method like this: public abstract class ListResourceT extends Referrable extends Resource { // ... public abstract ClassT referrableType(); // ... } If you wanted to do it in a way that doesn't require subclassing, you could do public class ListResourceT extends Referrable extends Resource { public ListResource(/* whatever parameters */, ClassT type) { // ... this.type = type; } public ClassT referrableType() { return this.type; } } Rhett I have, BTW, also a solution for SingleResourceT extends Referrable, but this is not used as much as my ListResource, so I didn't describe this. The big, unsolved task is to make the resources and interfaces available for more complex resource hierarchies where you have to check for the existence of a parent resource before you allow creation and modification of a child resource. Twenty or so more resource types under the belt, and I might get there ;-) *end rant* Kyrre Kristiansen --- On Thu, 26/3/09, Jerome Louvel jerome.lou...@noelios.com wrote: From: Jerome Louvel jerome.lou...@noelios.com Subject: RE: Resource factories To: discuss@restlet.tigris.org Date: Thursday, 26 March, 2009, 1:20 PM Hi all, I've just found time to read this thread and enjoyed it very much. It's hard to find the best balance between so much points of views and ways to deal with instantiations, wiring of objects, etc. so it's nice to hear that the current design has more advantages than drawbacks. As Tal mentioned, we are redesigning the Resource API to support client-side resources and focused use of annotations. I didn't intend to change the way resources are instantiated though. But, if we can adjust the new design to accommodate more use cases, I would be interested to explore. Currently, we are working on Restlet 1.2 M2 which will give you a chance to play with the new resource API and provide feed-back. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com De : Tal Liron [mailto:tal.li...@threecrickets.com] Envoyé : jeudi 26 mars 2009 08:49 À : discuss@restlet.tigris.org Objet : Re: Resource factories Thanks to all who replied on this. After a discussion on the code list, it became clear that the Restlety solution to configuring resources is to use the Context. The Context has a ConcurrentMap of attributes, described as so: This is a convenient mean[s] to provide common objects to all the Restlets and Resources composing an Application. So, that's it! The nice thing about contexts, too, is that they pass through restlets along the way. So, even if you configure your Application context in a certain way, you can apply filters or whatnot along the way to adapt the configuration. For example, a DebuggingFilter might enable all the configuration aspects that have to do with debugging. It's then easy to add/remove such a filter, even on-the-fly,
Re: Restlet 1.1.3 + Spring + servlet resource is being re-used
Hi Paul, On Apr 6, 2009, at 11:45 AM, Paul Austin wrote: I am using the RestletFrameworkServlet with the SpringBeanRouter to serve up resources. The resource in question will return a static file within a web application. I noticed that the images on a web page served by this resource return the incorrect image. So added a log statement in the init method and in the represent method. This debug prints out the instance of the resource and the image being requested. As you can see from below the same resource instance is being used multiple times (@99bc71) and in the last few you can see that there is a threading issue as two requests overlap and the request for the blu_top.gif image is actually returning the crumbs.gif image. According to the docs resources are not shared so don't have to be thread safe (i.e. can contain state). Does restlet re-use the same resource instance for multiple requests in the same thread? What happens if the browser uses a persistent HTTP connection? Do you have your application context set up to use scope=prototype for your Resource beans? If you don't, Spring will default to creating them as singletons, which would explain the behavior you see here. Rhett com.revolsys.restlet.staticwarresou...@e9df24:http://localhost:8080/ws/css/bcgov.css com.revolsys.restlet.staticwarresou...@38e7bb:http://localhost:8080/ws/scripts/ws.js com.revolsys.restlet.staticwarresou...@e9df24:/css/bcgov.css com.revolsys.restlet.staticwarresou...@38e7bb:/scripts/ws.js com.revolsys.restlet.staticwarresou...@99bc71:http://localhost:8080/ws/images/bc_sun_logo_horiz.gif com.revolsys.restlet.staticwarresou...@99bc71:/images/ bc_sun_logo_horiz.gif com.revolsys.restlet.staticwarresou...@99bc71:http://localhost:8080/ws/images/icon_help.gif com.revolsys.restlet.staticwarresou...@99bc71:/images/icon_help.gif com.revolsys.restlet.staticwarresou...@99bc71:http://localhost:8080/ws/images/left_blue_arrow.gif com.revolsys.restlet.staticwarresou...@99bc71:/images/ left_blue_arrow.gif com.revolsys.restlet.staticwarresou...@99bc71:http://localhost:8080/ws/images/nav_grey_bottom.gif com.revolsys.restlet.staticwarresou...@99bc71:/images/ nav_grey_bottom.gif com.revolsys.restlet.staticwarresou...@99bc71:http://localhost:8080/ws/images/blue_top.gif com.revolsys.restlet.staticwarresou...@99bc71:http://localhost:8080/ws/images/crumbs.gif com.revolsys.restlet.staticwarresou...@99bc71:/images/crumbs.gif com.revolsys.restlet.staticwarresou...@99bc71:/images/crumbs.gif Paul Austin President/CEO Revolution Systems Inc. +1 (604) 288-4304 x201 www.revolsys.com -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1563062
Re: Loading Spring Beans
Hi Dustin, Another option you could consider (if you haven't already) is using RestletFrameworkServlet and SpringBeanRouter to configure your application. This allows you to use IoC to configure your Resource instances, obviating the need to access the ApplicationContext directly most of the time. (If you do still need to access the ApplicationContext directly, you can always have the Resource that needs it implement ApplicationContextAware.) Rhett On Apr 3, 2009, at 9:35 AM, Dustin N. Jenkins wrote: Thanks very much Jerome! We do have other Servlet applications that are outside my control unfortunately. Dustin Jerome Louvel wrote: Hi Dustin, After looking at the code, there has been changes related to context in 1.2, to better isolate Components from Applications that affect you. I suggest that you enter an issue report in our tracker so we can have a closer look at this an see how we could support that again. Alternatively, you could initialize Spring from within Restlet itself to bypass this issue, unless you have other pure Servlet applications. 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é : mercredi 1 avril 2009 21:45 À : discuss@restlet.tigris.org Objet : Loading Spring Beans Hello! I'm using JDK 1.6 with Tomcat 6.0 on Fedora Core 8. I'm upgrading to Restlet 1.2, and I used to create a BeanUtil class that would load my Spring 1.2.9 beans by casting getContext() to a ServletContextAdapter, then obtaining the ServletContext from there to use the WebApplicationContextUtils class in Spring to obtain a bean by name. I'm only loading my Services and DAOs from Spring. In Restlet 1.2, I can no longer cast it. Is there an easier way to obtain the ServletContext, or, better yet, to load beans using the Spring extension? 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=1532829 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1533176
Re: Restlet 1.2 M2 released
On Apr 2, 2009, at 11:11 AM, Stephan Koops wrote: Jonathan Hall schrieb: Shame you can't have @Get(MediaType.TEXT_HTML). I don't know. Would it work to change MediaType from class to an enum? That could work, but I'm not sure This would sacrifice the ability to create new MediaTypes in applications which use the framework. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1520788
Re: Resource factories
Hi Tal, On Mar 23, 2009, at 1:06 PM, Tal Liron wrote: Thanks, Tim. This is a reasonable workaround -- creating a factory where one isn't there. And Guice adds some elegance to your solution. Another solution is simply to rewrite Finder entirely to use factories. This isn't hard. But it also goes against Restlet's current design. I don't think that subclassing Finder to be more factory-like goes against Restlet's design. The default finder is a very simple sort of Resource factory -- one that is capable of instantiating objects and nothing else. Other Finders use different mechanisms -- e.g., SpringBeanFinder gets Resource instances from a Spring ApplicationContext or BeanFactory. Rhett One of the very nice things about Restlet, which sets it apart from mere JAX-RS, is that it provides a complete container for RESTful applications. You can connect multiple Application instances to multiple Components, all running together (and possibly interacting). But, I'm wondering aloud if this particular aspect of the architecture can support this ambition or come in its way. -Tal Tim Peierls wrote: I tried to solve this problem in a limited way, using Guice, and wrote about it here: http://tembrel.blogspot.com/2008/07/resource-dependency-injection-in.html Maybe some of this could adapted for your purposes. --tim -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1391507
Re: Resource factories
Hi Dave, On Mar 23, 2009, at 3:08 PM, David Bordoley wrote: Out of curiosity is there a reason why Resource isn't implemented as a subclass of Restlet? It seams like there is a lot of overhead in initializing a new Resource on every request especially when a lot of salient features such as what methods,variants, etc that are supported tend to static for a give route to that resource. I'm not sure what the original design rationale was. Having used frameworks which use per-request request-handling objects (Restlet, Rails) and ones which use singleton request-handling objects (Spring MVC, Struts), I find that I prefer the programming model allowed by the former. In a singleton-based system, no per-request state can be stored in the object. All state has to be passed between methods using parameters. This results in either large, monolithic methods (hard to read, test, and extend) or reasonably-sized methods with a large number of parameters (hard to read and extend). In an object- per-request system, the request/response state is encapsulated in an object instance, so everything's much cleaner. (It goes without saying that you are also less likely to create hard-to-track-down shared-state-related bugs.) Rhett Thanks, Dave On Mon, Mar 23, 2009 at 11:46 AM, Rob Heittman rob.heitt...@solertium.com wrote: I'd be careful of judgement-words like bad practices since this implies some universal level of harm in all cases. I think the current Finder design is simplistic, flexible, and easy to implement. I think there is also room for a more structured base implementation that exposes some advantages for more complex resource object hierarchies. I don't think these are mutually exclusive. On Mon, Mar 23, 2009 at 2:34 PM, Tal Liron tal.li...@threecrickets.com wrote: Good point, Rhett. Well, let me put it this way -- do you think the current Finder design encourages bad practices for Restlet users? -Tal -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1392294 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1394862
Re: Integrating WADL and Spring
Hi David, On Mar 6, 2009, at 4:10 PM, David Bordoley wrote: On Fri, Mar 6, 2009 at 11:32 AM, Rhett Sutphin rh...@detailedbalance.net wrote: This would be an RFE (at least, I'm not aware of any way to get it to work currently). I'm curious about how you would tie the resources in your application context to the WADL. Would you add a custom attribute for the spring bean id? Is there a WADL feature which would help with this? I'm not that familiar with it. Rhett Hi, The current way WADL works in Restlet is to require implementors to specify the class of the resource you want to map a WADL resource to using the resource's id attribute. You then pass the the WADL xml as a constructor argument to a WadlComponent or WadlApplication. You can see an example of this in org.restlet.test.YahooSearch.wadl (omitting the details in the example below): application resources base=http://api.search.yahoo.com/NewsSearchService/V1/; resource id=org.restlet.test.NewsSearchResource path=newsSearch /resource /resources /application It would be cool if you could do something similar but instead of passing a Resource class (and be stuck using the default constructor etc.), instead use a Spring Bean id as the resource id in WADL, and have restlet use spring to wire all the resources together, thus getting all the benefits of IOC, while also being able to more explicitly state your resource interface in a standard method. Anyway i can open an RFE if necessary, but I wanted to ask on the list first. This is a good idea. I think the implementation might be more generic than just spring support, so I went ahead and entered the RFE against the WADL component: http://restlet.tigris.org/issues/show_bug.cgi?id=756 Thanks, Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1286420
Re: Integrating WADL and Spring
Hi Dave, On Mar 6, 2009, at 1:08 PM, David Bordoley wrote: I've been playing around with Restlet for some projects I'm working on and have really enjoyed the platform. I'm wondering if there is a way to define your service in a WADL document but still use Spring to configure all your applications Resources, etc. In the abstract what I would like to do is is define a WADL but instead of using ID's which map to Java classes, map them to Spring bean ids, essentially use WADL as a replacement for SpringRouter. Any suggestions? Is this an RFE? This would be an RFE (at least, I'm not aware of any way to get it to work currently). I'm curious about how you would tie the resources in your application context to the WADL. Would you add a custom attribute for the spring bean id? Is there a WADL feature which would help with this? I'm not that familiar with it. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1278642
Re: Spring integration questions
Hi Evgeny, On Mar 2, 2009, at 11:01 AM, Evgeny Shepelyuk wrote: Hello ! There's some questions are raised again when trying to start up restlet project with Spring. During development i do have some deep feeling that restlet has not much robust Spring integration. Especially in cases similar to mine, when one wants Sprign to be a caontainer and instantianor of all restlet classes. 1. why SpringBeanFinder uses BeanFactory instead of ApplicationContext According to Spring 2.5 docs Short version: use an ApplicationContext unless you have a really good reason for not doing so. For those of you that are looking for slightly more depth as to the 'but why' of the above recommendation, keep reading. . Versions of Spring 2.0 and above make heavy use of the BeanPostProcessor extension point (to effect proxying and suchlike), and if you are using just a plain BeanFactory then a fair amount of support such as transactions and AOP will not take effect (at least not without some extra steps on your part), which could be confusing because nothing will actually be wrong with the configuration. They even provide compatibility matrix for this :) SpringBeanFinder ...Router were originally based on Spring 2.0, so they use BeanFactory. In Restlet 1.2, SpringBeanRouter has been updated to pass the application context to the finders it creates, if an application context is available. It makes sense to use the same mechanism for SpringBeanFinder directly. New issue: http://restlet.tigris.org/issues/show_bug.cgi?id=751 2. Why whole Spring configuration can not be done in SpringRouter style, e.g. configure via map of /URL - restlet/resource. Now, IMO, its not really straighforward how to configure restlet and resources with SpringRouter/SpringBeanRouter. Seems in cases of restlet one needs to use one classs in case of restlet - other. According to code of SpringRouter it totally ignores the case when i want use Resource configured in Spring (with dependencies etc). I think its can bea easy achieved by making SpringRouter to implement ApplicationContextAware and by adding some logic to analyze all cases. My suggestion would be to use SpringBeanRouter if you want Spring- managed resource beans, unless you need to map multiple routes to the same resource. A static map with refs (such as that used by SpringRouter) wouldn't work for spring-managed resources, since they need to be non-singletons. You could write your own map-based router that uses ApplicationContextAware (as you suggest) and attaches SpringBeanFinders for each bean name / URL pattern pattern pair. I don't think that modifying SpringRouter to achieve this is the right way to go -- it would make SpringRouter complex and branching in a way that isn't justified by the amount of code that would be shared between the variants. If you do write your own router, I'm sure Jerome would be willing to consider adding it to the spring extension. Well sorry for lot of text probabaly not well written :) Will be appreciate for any response. Maybe i havent found related open issues in issue tracking or in case you need any help on better spring integration or idea i will be glad to help Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1263762
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=4447dsMessageId=1169062 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1171440
Re: Mime type filtering.
Hi, On Feb 6, 2009, at 2:55 PM, Rob Heittman wrote: If you are using the Accept: header in your client ... and using the Restlet Resource model on the server ... just write your responding code in your override of represent(Variant variant). if(variant.getMediaType().equals([the MediaType you speak])){ // do stuff; } else { // return the error status; } What Rob's saying will work for sure. You don't even have to handle the 406 yourself -- if you extend Resource and override represent(Variant), Restlet will automatically send the 406 if the represent method returns null. Rhett On Feb 6, 2009, at 2:55 PM, Rob Heittman wrote: Hi Dave! (Shout out from fop-dev back in the day) If you are using the Accept: header in your client ... and using the Restlet Resource model on the server ... just write your responding code in your override of represent(Variant variant). if(variant.getMediaType().equals([the MediaType you speak])){ // do stuff; } else { // return the error status; } I just spotted this example blog that does pretty much what you want: http://www.2048bits.com/2008/06/creating-simple-web-service-with.html On Fri, Feb 6, 2009 at 6:42 AM, Dave Pawson dave.paw...@gmail.com wrote: I want to do a GET, specifying that I can accept application/xml+atom as a mime type. At the server end; Unless this is specified (in the header I think - my knowledge of http isn't very strong) I want the server to reject the GET (error code 406 seems right). Even if no mime type is specified, I will still refuse the GET. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1114757
Re: Auto-Attachment of Resources to Router
Hi Jean-Philippe, Your Application bean isn't connected to the router. Since you are not using a custom Application, you could just remove the Application bean and make the router the root (either by naming it root or by setting the targetRestletBeanName parameter for RestletFrameworkServlet to router). RestletFrameworkServlet will automatically instantiate a default Application. If you do want to create your own application instance (e.g., because you decide later that you want a custom version), you need to attach the router as the root of the Application: bean id=root class=pkg.CustomApplication property name=root ref=router/ /bean Rhett On Jan 22, 2009, at 5:18 PM, Jean-Philippe Steinmetz wrote: Oh I like the idea of that... i've tried setting it up but now i'm getting the following error: Jan 22, 2009 3:16:58 PM org.restlet.Filter doHandle WARNING: A filter was executed without a next Restlet attached to it. Here is my web.xml: web-app display-nameWeb Service/display-name !-- Restlet Adapter -- servlet servlet-namewebservices/servlet-name servlet- classcom.noelios.restlet.ext.spring.RestletFrameworkServlet/ servlet-class load-on-startup1/load-on-startup /servlet !-- Let Restlet capture all requests -- servlet-mapping servlet-namewebservices/servlet-name url-pattern/*/url-pattern /servlet-mapping /web-app And here is my applicationContext ?xml version=1.0 encoding=UTF-8? beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:util=http://www.springframework.org/schema/util; xsi:schemaLocation= http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd !-- Restlet Setup -- bean id=root class=org.restlet.Application/ bean name=router class=org.restlet.ext.spring.SpringBeanRouter/ !-- Restlet - Resource Definitions -- bean name=/assets id=assetsResource autowire=byName scope=prototype class=com.trilogy.engine.webservice.restlets.AssetsResource property name=assetDao ref=assetDao/ /bean bean name=/assets/{id} id=assetResource autowire=byName scope=prototype class=com.trilogy.engine.webservice.restlets.AssetResource property name=assetDao ref=assetDao/ /bean bean name=/bodyparts id=bodyPartsResource autowire=byName scope=prototype class=com.trilogy.engine.webservice.restlets.BodyPartsResource property name=bodyPartsDao ref=assetDao/ /bean bean name=/bodyparts/{id} id=bodyPartResource autowire=byName scope=prototype class=com.trilogy.engine.webservice.restlets.BodyPartsResource property name=bodyPartsDao ref=assetDao/ /bean /beans Any ideas what could be wrong? Jean-Philippe On Wed, Jan 21, 2009 at 11:13 PM, Rhett Sutphin rh...@detailedbalance.net wrote: Hi Jean-Philippe, On Jan 21, 2009, at 1:07 PM, Jean-Philippe Steinmetz wrote: Quick question about attaching URI patterns and resource classes to the router. Is there a way to make this happen more automagically with annotations or some other mechanism? Adding each one by hand will get unwieldy and requires touching the main Application class every time I want to add a new resource. I see there is some work with this with JAX-RS but I wasn't sure if this was included in restlet or not. Since you are already using Spring, you might consider using SpringBeanRouter: http://www.restlet.org:8080/documentation/1.1/ext/org/restlet/ext/spring/SpringBeanRouter.html It allows you to define URI templates in your application context. It also allows you to do Spring DI on the resource instances. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1042895 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1045059
Re: Auto-Attachment of Resources to Router
Hi Jean-Philippe, On Jan 21, 2009, at 1:07 PM, Jean-Philippe Steinmetz wrote: Quick question about attaching URI patterns and resource classes to the router. Is there a way to make this happen more automagically with annotations or some other mechanism? Adding each one by hand will get unwieldy and requires touching the main Application class every time I want to add a new resource. I see there is some work with this with JAX-RS but I wasn't sure if this was included in restlet or not. Since you are already using Spring, you might consider using SpringBeanRouter: http://www.restlet.org:8080/documentation/1.1/ext/org/restlet/ext/spring/SpringBeanRouter.html It allows you to define URI templates in your application context. It also allows you to do Spring DI on the resource instances. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1042895
Re: Returning data after PUT/POST
If you are both suggesting using POST to add an entry why use PUT then? It seems to make PUT somewhat irrelevant unless performing an update. PUT is useful for updates. It's also useful when the client determines the resource's URL. This latter case is pretty common -- some systems don't expose their internal IDs in the URI, but rather use an identifier which is shared between the client and the server. In that case, the client already knows what the URI will be, even before it is added to the system. E.g., in the main application I work on, one of the central concepts is a study template. Studies have an externally assigned identifier which is defined before either the server or the client has anything to do with the template, and can never change. We use that assigned identifier in the URIs. This has the benefit of making the URIs easier to read and allowing clients to not have to distinguish between creates and updates. The way you define a list below would require some extra processing that I don't necessarily do when working with serialization. I don't want to speak for Donald, but I think he was just providing an example representation to make his suggestions more concrete. You should tune your representation to the requirements of your application, of course. Rhett On Jan 21, 2009, at 12:56 PM, Jean-Philippe Steinmetz wrote: Thanks for all the help. If you are both suggesting using POST to add an entry why use PUT then? It seems to make PUT somewhat irrelevant unless performing an update. I'm going to have to do some rethinking. I'm mainly using this rest service for passing serialized objects back and forth between the service and clients. I had originally imagined that the difference between the cars and car was merely that car returned a single full car object (serialized of course) while cars returned an array or list (also full objects) but I can see where you'd think otherwise. The way you define a list below would require some extra processing that I don't necessarily do when working with serialization. Has anyone else come across this kind of a scenario? Jean-Philippe? On Tue, Jan 20, 2009 at 6:45 PM, Donald S Strong donald.str...@transport.vic.gov.au wrote: Hi Jean-Philippe, If I want to add a resource named car I perform a PUT on a url like http://localhost/myapp/car/ instead of http://localhost/myapp/car/15. I agree with Rhett, use POST and then GET. POST http://localhost/myapp/car creates the car object with a new ID and redirects to the URI GET http://localhost/myapp/car/15 returns the car object with ID 15 I've also noticed that to return a list of some data such as car the typical method is to implement a second resource cars. Perhaps its a matter of taste but I would think it would be simpler for the client user to assume if you do not enter an ID or other search parameter into the URI then it implies a catch all. Would not this be simpler? What are the realistic benefits to actually creating another resource cars? A single car and a list of cars are logicaly different resources; the structures they return are quite different. A list of cars will probably contain many URIs, each refering to a single car. eg. cars bodystyle=coupe car name=Bob's car refid=/myapp/car/15 / car name=Bert's car refid=/myapp/car/16 / car name=Ernie's car refid=/myapp/car/132 / /cars You may have other resources that also refer to the car URIs. GET http://localhost/myapp/vehicles returns a list of all bike, car and truck objects. Lastly, is there a standard way to simplify creating resources so that performing GET on http://localhost/myapp/car/bodystyle/coupe doesn't require implementing a separate resource from http://localhost/myapp/car? Instead the /bodystyle/coupe part of the URI just becomes a search parameter of the car resource? You can use the same resource implementation if it takes parameters. Theoretically these are different resources, but in practice they can use the same implementation class. GET http://localhost/myapp/cars returns a list of all car objects GET http://localhost/myapp/cars?bodystyle=coupe returns all car objects with body style coupe GET http://localhost/myapp/cars?color=blue returns all blue car objects Regards Donald. ** Any personal or sensitive information contained in this email and attachments must be handled in accordance with the Victorian Information Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988 (Commonwealth), as applicable. This email, including all attachments, is confidential. If you are not the intended recipient, you must not disclose, distribute, copy or use the information contained in this email or attachments. Any confidentiality or privilege is not waived
OT: Re: RESTlet + Spring
dependency groupIdmysql/groupId artifactIdmysql-connector-java/artifactId version5.1.6/version /dependency !-- Spring -- dependency groupIdorg.springframework/groupId artifactIdspring-core/artifactId version2.5.6/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-context/artifactId version2.5.6/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-hibernate3/artifactId version2.0.8/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-jpa/artifactId version2.0.8/version /dependency dependency groupIdorg.springframework/groupId artifactIdspring-web/artifactId version2.5.6/version /dependency !-- Logging -- dependency groupIdch.qos.logback/groupId artifactIdlogback-classic/artifactId version0.9.11/version /dependency dependency groupIdorg.slf4j/groupId artifactIdslf4j-api/artifactId version1.5.3/version /dependency !-- Unit Testing -- dependency groupIdjunit/groupId artifactIdjunit/artifactId version3.8.1/version scopetest/scope /dependency /dependencies build plugins plugin groupIdorg.codehaus.mojo/groupId artifactIdtomcat-maven-plugin/artifactId configuration serverLocalTomcat/server /configuration /plugin plugin artifactIdmaven-compiler-plugin/artifactId configuration source1.5/source target1.5/target optimizetrue/optimize /configuration /plugin /plugins /build repositories repository idjboss/id urlhttp://repository.jboss.com/maven2/url releases enabledtrue/enabled /releases snapshots enabledfalse/enabled /snapshots /repository repository idjboss-snapshot/id urlhttp://repository.jboss.org/maven2/url releases enabledtrue/enabled /releases snapshots enabledtrue/enabled /snapshots /repository repository idrestlet/id urlhttp://maven.restlet.org/url /repository /repositories /project On Tue, Jan 20, 2009 at 12:34 PM, Rhett Sutphin rh...@detailedbalance.net wrote: Hi Jean-Philippe, At first glance, the error seems to be a generic spring error -- that one of the wired dependencies is of the wrong type. Looking at your XML, I wonder if it is failing here: property name=persistenceUnitManager value=persistenceUnitManager/ property name=jpaVendorAdapter value=jpaVendor/ I think those should be ref instead of value. I haven't seen this particular error before, though, so I'm not sure. If it's not that, would you please let us know what versions of Spring and Restlet you are using? Rhett On Jan 20, 2009, at 1:04 PM, Jean-Philippe Steinmetz wrote: Hi All, I'm working on integrating restlet and spring for use in a web app to be run under Tomcat. After reading up on the Spring extension (thank you Jerome) I have decided to go the restlet as the main controller route. This is due to the fact that Spring is only being used as a Dao implementation layer. I came across the com.noelios.restlet.ext.spring.RestletFrameworkServlet class. Based on its description it would appear this is what I should use to properly set things up. Unfortunately I am getting crash errors when I try and access my restlet app from a browser. I am hoping someone may be able to shed some light on the situation. The error I am getting is: java.lang.IllegalArgumentException: Value does not implement specified type org.springframework.util.Assert.isTrue(Assert.java:65) org .springframework .beans .factory .support .DefaultListableBeanFactory .registerResolvableDependency(DefaultListableBeanFactory.java:325) org.springframework.web.context.support.WebApplicationContextUtils.registerWebApplicationScopes (WebApplicationContextUtils.java:129) org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.postProcessBeanFactory (AbstractRefreshableWebApplicationContext.java:143) org .springframework .context .support .AbstractApplicationContext.refresh(AbstractApplicationContext.java: 359) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext (FrameworkServlet.java:332) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext (FrameworkServlet.java:266) org .springframework .web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java: 236) org .springframework
Re: RESTlet + Spring
Hi Jean-Philippe, At first glance, the error seems to be a generic spring error -- that one of the wired dependencies is of the wrong type. Looking at your XML, I wonder if it is failing here: property name=persistenceUnitManager value=persistenceUnitManager/ property name=jpaVendorAdapter value=jpaVendor/ I think those should be ref instead of value. I haven't seen this particular error before, though, so I'm not sure. If it's not that, would you please let us know what versions of Spring and Restlet you are using? Rhett On Jan 20, 2009, at 1:04 PM, Jean-Philippe Steinmetz wrote: Hi All, I'm working on integrating restlet and spring for use in a web app to be run under Tomcat. After reading up on the Spring extension (thank you Jerome) I have decided to go the restlet as the main controller route. This is due to the fact that Spring is only being used as a Dao implementation layer. I came across the com.noelios.restlet.ext.spring.RestletFrameworkServlet class. Based on its description it would appear this is what I should use to properly set things up. Unfortunately I am getting crash errors when I try and access my restlet app from a browser. I am hoping someone may be able to shed some light on the situation. The error I am getting is: java.lang.IllegalArgumentException: Value does not implement specified type org.springframework.util.Assert.isTrue(Assert.java:65) org .springframework .beans .factory .support .DefaultListableBeanFactory .registerResolvableDependency(DefaultListableBeanFactory.java:325) org.springframework.web.context.support.WebApplicationContextUtils.registerWebApplicationScopes (WebApplicationContextUtils.java:129) org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.postProcessBeanFactory (AbstractRefreshableWebApplicationContext.java:143) org .springframework .context .support .AbstractApplicationContext.refresh(AbstractApplicationContext.java: 359) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext (FrameworkServlet.java:332) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext (FrameworkServlet.java:266) org .springframework .web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java: 236) org .springframework .web.servlet.HttpServletBean.init(HttpServletBean.java:126) javax.servlet.GenericServlet.init(GenericServlet.java:212) org .apache .catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java: 286) org .apache .coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:857) org.apache.coyote.http11.Http11AprProtocol $Http11ConnectionHandler.process(Http11AprProtocol.java:565) org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java: 1509) java.lang.Thread.run(Unknown Source) Here is what my web.xml file looks like: !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; web-app display-nameWeb Service/display-name context-param param-nameorg.restlet.application/param-name param-valuewebservice.RestApplication/param-value /context-param !-- Restlet Adapter -- servlet servlet-namewebservices/servlet-name servlet- classcom.noelios.restlet.ext.spring.RestletFrameworkServlet/ servlet-class load-on-startup1/load-on-startup /servlet !-- Let Restlet capture all requests -- servlet-mapping servlet-namewebservices/servlet-name url-pattern/*/url-pattern /servlet-mapping /web-app I also have a webservices-servlet.xml file for Spring bean definition. It looks like: ?xml version=1.0 encoding=UTF-8? beans xmlns=http://www.springframework.org/schema/beans; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xmlns:util=http://www.springframework.org/schema/util; xsi:schemaLocation= http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd bean id=root class=webservice.RestApplication / !-- Data Source -- bean id=dataSource class=com.mchange.v2.c3p0.ComboPooledDataSource destroy-method=close property name=driverClass value=com.mysql.jdbc.Driver / property name=jdbcUrl value=jdbc:mysql://localhost: 3306 / property name=username value=kfpws_user / property name=password value= / property name=initialPoolSize value=3/ property name=minPoolSize value=3/ property name=maxPoolSize value=50/
Re: Returning data after PUT/POST
Hi Jean-Philippe, Based on the way i've currently constructed my app this may not be possible. If I want to add a resource named car I perform a PUT on a url like http://localhost/myapp/car/ instead of http://localhost/myapp/car/15 . This is because I do not want the client to be responsible for managing identifiers (that is what the persistence layer is for). I think Jerome's suggestion will work more favorably here. If you want to add an object to a collection, the proper verb to use is POST. For the case you're taking about, the RESTful HTTP way is to implement a flow like this: Client: POST http://localhost/myapp/car/ [data] Server: 201 Created Location: http://localhost/myapp/car/15 Client: GET http://localhost/myapp/car/15 (if desired) Although perhaps there is a better way to handle this type of transaction? I've also noticed that to return a list of some data such as car the typical method is to implement a second resource cars. Perhaps its a matter of taste but I would think it would be simpler for the client user to assume if you do not enter an ID or other search parameter into the URI then it implies a catch all. GET http://localhost/myapp/car/ returns a list of all car objects GET http://localhost/myapp/car/15 returns the car object with ID 15 GET http://localhost/myapp/car/bodystyle/coupe returns all car objects with body style coupe I think the typical thing to do would be to have cars in the URL in all these cases, not to have a second cars resource. So long as you're consistent it probably doesn't matter. Lastly, is there a standard way to simplify creating resources so that performing GET on http://localhost/myapp/car/bodystyle/coupe doesn't require implementing a separate resource from http://localhost/myapp/car? Instead the /bodystyle/coupe part of the URI just becomes a search parameter of the car resource? I don't know if it's the best way, but you can route multiple URI templates to the same resource class. The URI template parameters will be added to the request by the framework. Plus, the default router match mode will match /myapp/car to /myapp/car/{key}/{value} with key=null and value=null. You may not even need to map multiple templates. Rhett On Jan 20, 2009, at 12:47 PM, Jean-Philippe Steinmetz wrote: Based on the way i've currently constructed my app this may not be possible. If I want to add a resource named car I perform a PUT on a url like http://localhost/myapp/car/ instead of http://localhost/myapp/car/15 . This is because I do not want the client to be responsible for managing identifiers (that is what the persistence layer is for). I think Jerome's suggestion will work more favorably here. Although perhaps there is a better way to handle this type of transaction? I've also noticed that to return a list of some data such as car the typical method is to implement a second resource cars. Perhaps its a matter of taste but I would think it would be simpler for the client user to assume if you do not enter an ID or other search parameter into the URI then it implies a catch all. For example, GET http://localhost/myapp/car/ returns a list of all car objects GET http://localhost/myapp/car/15 returns the car object with ID 15 GET http://localhost/myapp/car/bodystyle/coupe returns all car objects with body style coupe Would not this be simpler? What are the realistic benefits to actually creating another resource cars? Lastly, is there a standard way to simplify creating resources so that performing GET on http://localhost/myapp/car/bodystyle/coupe doesn't require implementing a separate resource from http://localhost/myapp/car? Instead the /bodystyle/coupe part of the URI just becomes a search parameter of the car resource? Jean-Philippe On Fri, Jan 16, 2009 at 12:24 AM, Karel Vervaeke ka...@outerthought.org wrote: I'm not sure if this will help you, but in case of a PUT, you already know the url, issuing a GET to the same url should (by your implementation) return the same entity body you presented in the PUT. If you want to retrieve a 'more informative' representation (i.e. including the 'internal' id), you could add a query parameter to the url. Alternatively (more appropriate in case of a POST) you can return a 201 Created status code [1] (with Location headers and url's in the entity body) or a 202 Accepted status code [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2 HTH, Karel On Fri, Jan 16, 2009 at 2:37 AM, Jean-Philippe Steinmetz caskate...@gmail.com wrote: Hello everyone, I'm currently working on my first restlet application and have one big question. Typically when I want to persist some data I will not know certain information about it (i.e. the ID of the data). Instead of creating the object and searching for it I usually design my
Re: Patch to parameterize port numbers in JUnit tests
For Spring it should be possible to inject the static value into the bean property. I don't remember the exact syntax, but we can figure this out. You can configure a PropertyPlaceholderConfigurer into the application context: http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.html It resolves placeholders from either system properties or a configured property file / inline list. Rhett On Jan 14, 2009, at 1:59 PM, Jerome Louvel wrote: Hi Raif, That sounds like a useful thing to do. I was trying to apply the patch but got issues with the paths of the patched files. Could you try to use SVN instead to generate it, starting at the root of the SVN trunk instead? For Spring it should be possible to inject the static value into the bean property. I don't remember the exact syntax, but we can figure this out. Any Spring wizard listening? 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 : Raif S. Naffah [mailto:tig...@naffah-raif.name] Envoye : samedi 10 janvier 2009 07:48 A : discuss@restlet.tigris.org Objet : Patch to parameterize port numbers in JUnit tests hello there, the JUnit tests (in org.restlet.test) have hard-wired port numbers which may not suit every developer's environment. this patch introduces a new property in the main build.xml, and injects at as a system environment variable. when more than one port is required, the property value is used as a base; i.e. second port number is valueOf(property) + 1, etc. the only test i was not able to parametrize was the Spring test (and its .xml file). cheers; rsn -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1024775 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1024919
Re: SpringBeanRouter issues
However, I'm not sure however about injecting the SpringBeanFinder because we need one instance per target resource bean... This could be achieved by injecting the bean name (instead of an instance) and then using the application context to retrieve instances as needed. That said, I much prefer the current style -- it allows you to change the finder type by subclassing SpringBeanRouter and overriding createFinder -- especially since you're going to have to modify the prototype finders anyway (to give them the resource bean name). Rhett On Jan 13, 2009, at 4:00 PM, Jerome Louvel wrote: Hi Daniel, Thanks for sharing your experience and for the enhancement suggestion. I've just made the SpringBeanRouter implement ApplicationContextAware, using the context received to instantiate the finders. Changes are checked in SVN trunk. However, I'm not sure however about injecting the SpringBeanFinder because we need one instance per target resource bean... Could you test the next snapshot and let me know if it work fine? Best regards, Jérôme Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -Message d'origine- De : Daniel Woo [mailto:daniely...@hotmail.com] Envoyé : vendredi 9 janvier 2009 17:26 À : discuss@restlet.tigris.org Objet : *SPAM(1.8)* RE: Re: SpringBeanRouter issues one more thing, if you want to intercept MyResource.represent(Variant), that won't work with Spring AOP (jdk proxy or cglib). Because this method is called by Resource.handleGet() You have to intercept Resource.handleGet()/Put()/Post()/Delete(), or use static waver like aspectJ. I think you can make SpringBeanRouter implement ApplicationContextAware. I made it this way, the AOP interceptor successfully executed. I changed very little to your SpringBeanRouter and SpringBeanFinder: SpringBeanRouter: make it ApplicationContextAware, and holds an ApplicationContext. Each time createFinder() will pass that app context to SpringBeanFinder. SpringBeanFinder:now the constructor accepts an application context instead of a beanFactory. Moreover, you actually can also make the beanFinder ApplicationContextAware, in that way, you don't have to hard code new SpringBeanFinder(appContext, beanName) anymore, you can even inject SpringBeanFinder to SpringBeanRouter, hence the SpringBeanFinder can be replaced by subclass written by the end user. What do you think? It's at least useful to me because this solves my transaction and security issue with Spring. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1014009 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1022914 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1023023
Re: SpringBeanRouter issues
Hi, On Jan 8, 2009, at 10:14 AM, postmas...@tigris.org wrote: Hi guys, Thanks for your hard work on Restlet with Spring integration, I am able to integrate them according to the wiki, however I found two issues I used SpringServerServlet to load the Application from spring context configuration file appcontext.xml, and the root router is an instance of org.restlet.ext.spring.SpringBeanRouter which is injected by the Spring container into the Application. Hence Application.createRoot() returns the injected SpringBeanRouter as root router. So far, everything works but 1. Each resource bean must have an explicit ID, otherwise bean lookup will fail. This is not a big deal, I can provide an ID for each resource bean. Let look at the next issue which is a little complex. 2. Transaction interceptor can not intercept the bean managed restlet resources, my JPA transaction manager and interceptor works pretty good with DAO and other tiers but just can not work with resource beans. I haven't run into this because I tend to isolate any logic that needs to be transactional in a single call in the service layer. However, I can't think of a reason why it couldn't be made to work. Can you be more explicit about just can not work? How are you trying to get it to work? What's the evidence that it is not working? I took a look at the source code and found that the SpringBeanRouter uses the following code to create a bean finder: protected Finder createFinder(BeanFactory beanFactory, String beanName) { return new SpringBeanFinder(beanFactory, beanName); } I am worrying about the beanFactory passed in is not a subclass of ApplicationContext, the major difference between beanFactory and AppContext is beanFactory does not support AOP. Is that the reason my transaction interceptor can not work? If the way you are loading resource configuration results in a plain BeanFactory, then sure. But if your resources and the router are defined and loaded as part of your Application Context, then beanFactory will be the actual application context. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1012021
Re: securing Restlet
Hi Stephan, On Dec 22, 2008, at 3:20 AM, Stephan Koops wrote: Ho Rhett, but doesn't the current Guard implementation obviate the need for both sessions and cookies, and yet provide us with basic authentication? if yes, then a solution for providing customizable form-based login could be to extend its capabilities to allow declaring and re-directing to a resource URI to use when the credentials are missing. does this make sense? No, that won't work. The reason why basic auth works without prompting after the first request is that the browser caches the credentials and repeats the Authorization header with every subsequent request. This is possible because basic authentication is part of the HTTP spec. There's no form-based equivalent of it. right. and that's because in form-based authentication what would've been a 401 status code response never makes it to the Browser. yes? I suppose that's one way to put it. The key thing is that there's no spec for form-based authentication, so there's no browser awareness of it, so there's no way to get an Authorization header with form-based auth. That means the existing Guard implementation can't be trivially modified to work with forms. There is a way, but HTML and HTTP is not enough: You need JavaScript to send a XMLHttpRequest. But you can't use http state 401 for return, because the browser should prompt (search for 401 on http://www.w3.org/TR/XMLHttpRequest/) for the users credentials, and that is, what we don't want. So we hae to use another HTTP state for it (I've implemented it with the undefined state 491 some month ago). But this way requires enabled JavaScript in the users browser and support for the XMLHttpRequest object. If I understand you correctly, you are suggesting using an XMLHttpRequest in order to send a request with an Authorization header to perform the login. That gets around the problem of using Guard to do the initial authentication, but how do you prevent the user from being prompted on every request? It seems like you'd still need some sort of client-side state and a way to interpret it on the server. Or do I misunderstand what you are suggesting? Do have a writeup of the XMLHttpRequest-based protocol you are using? Thanks, Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=989934
Re: securing Restlet
Hi Stephan, On Dec 22, 2008, at 12:02 PM, Stephan Koops wrote: Hi Rhett, There is a way, but HTML and HTTP is not enough: You need JavaScript to send a XMLHttpRequest. But you can't use http state 401 for return, because the browser should prompt (search for 401 on http://www.w3.org/TR/XMLHttpRequest/) for the users credentials, and that is, what we don't want. So we hae to use another HTTP state for it (I've implemented it with the undefined state 491 some month ago). But this way requires enabled JavaScript in the users browser and support for the XMLHttpRequest object. If I understand you correctly, you are suggesting using an XMLHttpRequest in order to send a request with an Authorization header to perform the login. That gets around the problem of using Guard to do the initial authentication, but how do you prevent the user from being prompted on every request? It seems like you'd still need some sort of client-side state and a way to interpret it on the server. If you give the credentials to the browser, the browser saves them in memory and send it for every request to the same realm on the server, until the browser is closed. So you don't need to re-enter them. This is client state, as you said, but client state is allowed in REST. Only application state in the server is forbidden. Or do I misunderstand what you are suggesting? Do have a writeup of the XMLHttpRequest-based protocol you are using? I only set the credentials with the methods for it into the XMLHttpRequest. Oh, so when you pass credentials using XmlHttpRequest, the browser automatically caches them? That's cool. I didn't know that worked. I guess this has the same downside as normal browser-based authentication, then -- it's impossible to log out without quitting the browser. Thanks, Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=990013
Re: securing Restlet
On Dec 20, 2008, at 6:49 PM, Raif S. Naffah wrote: On Sunday 21 December 2008 09:05:46 Rhett Sutphin wrote: On Dec 20, 2008, at 3:34 PM, Raif S. Naffah wrote: hello Stephan, On Sunday 21 December 2008 00:41:48 Stephan Koops wrote: Hi Raif, Another possibility to not require the browser login prompt is to use an AJAX reqeust and set the credentials in it. I've implemented this, but I needed a new return status for it, because if the server returns 401 (authentication required / invald) to the client, then the browser would open a login prompt. If needed, a could attach it to issue 505 It is also good, if it is allowed to have multiple authentication mechanims allowed for one resource, e.g. with cookies as descibed above for browsers and with a HTML authentiction for software clients, which requesting e.g. XML or JSON. correct me if i'm wrong but if the aim of the Authentication is to assert who are you then your identity should be the same whatever Authentication mechanism was used. in that respect _one_ Authentication mechanism should be enough. on the other hand, what are you allowed to do (incl. what type of Representation for a requested Resource) is the domain of Authorization. in that respect one (of potentially several conditions, incl. for example the time-of-day) for authorizing a type of Representation could be the grade of the Authentication mechanism used to establish your identity; i.e. an Authentication mechanism based on a personal X. 509 Certificate has a higher grade than one based on non-encrypted user-name and password. what could be gained though from having an aggregation/ compounded style of user-credentials gathering mechanisms would be to increase the trust in the established identity. e.g. i would have more confidence in your identity if i can check your credentials from two separate sources; as a consequence i can then authorize you to do more. Here I was not precise enough: I meant alternative authentication mechanisms, not both must be passed. If I use a software client (web service), than basic or digest is fine, but if the client is a browser, than the cookie based may be better, because it allows corporate design: I think, a reason for not using REST styled web apps in the commercial is, that authentication in corporate design is more difficult than with Servlets: If the developer says to the manager: We have two alternatives: One allows corporated design to be used easily, and the other options has problems with it, what would he say? Right, he will say: Use the options which allows it. i see what you mean but just to clarify: Cookies per se are not an authentication mechanismbut a technique to maintain a state which could be used to claim previous alleged successful authentication. Right, I fully agree with you; that was my idea. even then, i see two problems with Cookies: (a) users can have their Browsers reject them, Yes, I know. That is really a problem. and (b) they contradict the REST principle (see section 6.3.4.2 of R. Fielding dissertation http://roy.gbiv.com/pubs/dissertation/evaluation.htm). You are right, that cookies produces problems, if they contain application state, e.g. to match a Servlet session. But IMO it is not a problem, if you only save, that the user is logged in and it's user name (perhaps secured by an additional crypto hash or something like that). i agree with you that allowing Restlet users/developers to plug-in their own customized log-in form where user credentials can be obtained will be a selling point. this i think can be achieved by implementing in Restlet something similar to what the Servlet specs' login- config and auth- method elements provide. And how do a Servlet Container check the authentication? It could only set a cookie or use a session and save it in the session. No we have back the cookies, or - worse - a session. but doesn't the current Guard implementation obviate the need for both sessions and cookies, and yet provide us with basic authentication? if yes, then a solution for providing customizable form-based login could be to extend its capabilities to allow declaring and re-directing to a resource URI to use when the credentials are missing. does this make sense? No, that won't work. The reason why basic auth works without prompting after the first request is that the browser caches the credentials and repeats the Authorization header with every subsequent request. This is possible because basic authentication is part of the HTTP spec. There's no form-based equivalent of it. right. and that's because in form-based authentication what would've been a 401 status code response never makes it to the Browser. yes? I suppose that's one way to put it. The key thing is that there's no spec for form-based authentication, so there's no browser awareness
Re: securing Restlet
On Dec 20, 2008, at 3:34 PM, Raif S. Naffah wrote: hello Stephan, On Sunday 21 December 2008 00:41:48 Stephan Koops wrote: Hi Raif, Another possibility to not require the browser login prompt is to use an AJAX reqeust and set the credentials in it. I've implemented this, but I needed a new return status for it, because if the server returns 401 (authentication required / invald) to the client, then the browser would open a login prompt. If needed, a could attach it to issue 505 It is also good, if it is allowed to have multiple authentication mechanims allowed for one resource, e.g. with cookies as descibed above for browsers and with a HTML authentiction for software clients, which requesting e.g. XML or JSON. correct me if i'm wrong but if the aim of the Authentication is to assert who are you then your identity should be the same whatever Authentication mechanism was used. in that respect _one_ Authentication mechanism should be enough. on the other hand, what are you allowed to do (incl. what type of Representation for a requested Resource) is the domain of Authorization. in that respect one (of potentially several conditions, incl. for example the time-of-day) for authorizing a type of Representation could be the grade of the Authentication mechanism used to establish your identity; i.e. an Authentication mechanism based on a personal X. 509 Certificate has a higher grade than one based on non-encrypted user-name and password. what could be gained though from having an aggregation/ compounded style of user-credentials gathering mechanisms would be to increase the trust in the established identity. e.g. i would have more confidence in your identity if i can check your credentials from two separate sources; as a consequence i can then authorize you to do more. Here I was not precise enough: I meant alternative authentication mechanisms, not both must be passed. If I use a software client (web service), than basic or digest is fine, but if the client is a browser, than the cookie based may be better, because it allows corporate design: I think, a reason for not using REST styled web apps in the commercial is, that authentication in corporate design is more difficult than with Servlets: If the developer says to the manager: We have two alternatives: One allows corporated design to be used easily, and the other options has problems with it, what would he say? Right, he will say: Use the options which allows it. i see what you mean but just to clarify: Cookies per se are not an authentication mechanismbut a technique to maintain a state which could be used to claim previous alleged successful authentication. Right, I fully agree with you; that was my idea. even then, i see two problems with Cookies: (a) users can have their Browsers reject them, Yes, I know. That is really a problem. and (b) they contradict the REST principle (see section 6.3.4.2 of R. Fielding dissertation http://roy.gbiv.com/pubs/dissertation/evaluation.htm). You are right, that cookies produces problems, if they contain application state, e.g. to match a Servlet session. But IMO it is not a problem, if you only save, that the user is logged in and it's user name (perhaps secured by an additional crypto hash or something like that). i agree with you that allowing Restlet users/developers to plug-in their own customized log-in form where user credentials can be obtained will be a selling point. this i think can be achieved by implementing in Restlet something similar to what the Servlet specs' login- config and auth- method elements provide. And how do a Servlet Container check the authentication? It could only set a cookie or use a session and save it in the session. No we have back the cookies, or - worse - a session. but doesn't the current Guard implementation obviate the need for both sessions and cookies, and yet provide us with basic authentication? if yes, then a solution for providing customizable form-based login could be to extend its capabilities to allow declaring and re-directing to a resource URI to use when the credentials are missing. does this make sense? No, that won't work. The reason why basic auth works without prompting after the first request is that the browser caches the credentials and repeats the Authorization header with every subsequent request. This is possible because basic authentication is part of the HTTP spec. There's no form-based equivalent of it. If you want to allow form-based logins, you have to have some sort of state. If you want to make the state entirely client side (as the REST style suggests), you'll have to design it very carefully to avoid spoofing and/or replay attacks. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=988535
Re: java.lang.AbstractMethodError: org.restlet.util.Engine.fireContextChanged
Hi Ian, You need to upgrade the com.noelios.restlet dependencies to 1.1.1, too. Rhett On Dec 1, 2008, at 11:58 AM, Ian Clarke wrote: Hi Thierry, Just checked, the file com.noelios.restlet-1.0.11.jar is in my classpath (put there by Maven). com.noelios.restlet.ext.httpclient-1.0.11.jar is also there. Not sure quite what you mean about the context, but here is the code that seems to cause the error: @BeforeClass public void beforeClass() { client = new Client(Protocol.HTTP); client.getContext().getParameters().add(converter, com.noelios.restlet.http.HttpClientConverter); client.getContext().getParameters().add(connectionManagerTimeout, 100); urlPrefix = http://127.0.0.1:; + LISTEN_PORT + /; } Hope that is helpful, let me know if there is anything else I can tell you. Ian. On Mon, Dec 1, 2008 at 3:18 AM, Thierry Boileau [EMAIL PROTECTED] wrote: Hello Ian, it looks the com.noelios.restlet.jar is not in the classpath. Can you check it? Can you give more details about your context? Best regards, Thierry Boileau -- Restlet ~ Core developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com Just upgraded to Restlet 1.1.1 (using Maven), and I'm seeing the following error when I attempt to call a unit test that worked previously, any ideas? :- Caused by: java.lang.AbstractMethodError: org.restlet.util.Engine.fireContextChanged(Lorg/restlet/ Restlet;Lorg/restlet/Context;)V at org.restlet.Restlet.init(Restlet.java:90) at org.restlet.Connector.init(Connector.java:83) at org.restlet.Client.init(Client.java:82) at org.restlet.Client.init(Client.java:101) at org.restlet.Client.init(Client.java:121) -- Ian Clarke CEO, Uprizer Labs Email: [EMAIL PROTECTED] Ph: +1 512 422 3588 Fax: +1 512 276 6674
Re: use of Finder class
Hi, On Nov 17, 2008, at 12:47 AM, Gan123 wrote: i am new to restlet, just started exploring on this. please tell me the use of Finder class in restlet. how is it different from Router class? Finders and Routers are both types of Restlets. A Router maps from a URI to some (singleton) Restlet. A Finder is a Restlet which instantiates (non-singleton) Resource instances to handle incoming requests. To put it another way*, a Router points to a Finder and a Finder points to a Resource. Rhett *This is a simplification -- a Router can point to any kind of Restlet, not just Finders.
Re: Spring configuration example using com.noelios.restlet.ext.spring package
Hi Mark, You might also consider using SpringBeanRouter. If you only have one URI mapping per resource, it allows your URIs to be mapped directly in the bean definitions. Your example would be like this using SpringBeanRouter (note: not tested): !-- server bean as before -- bean name=router class=org.restlet.ext.spring.SpringBeanRouter/ bean name=/account/register id=registerResource class=com.mspetrovic.server.restlet.RegisterResource scope=prototype/ bean name=/account/login id=loginResource class=com.mspetrovic.server.restlet.LoginResource scope=prototype/ bean name=/account/confirm/{confirmationKey} id=confirmationResource class=com.mspetrovic.server.restlet.AccountConfirmationResource scope=prototype/ bean name=/callsign/bind id=bindCallsignResource class=com.mspetrovic.server.restlet.BindCallsignResource scope=prototype/ bean name=/license/lookup/{callsign} id=lookupLicenseResource class=com.mspetrovic.server.restlet.LookupCallsignResource scope=prototype/ bean name=/log/{logname} id=createLogResource class=com.mspetrovic.server.restlet.LogResource scope=prototype/ bean name=/log/export/{logname} id=exportLogResource class=com.mspetrovic.server.restlet.LogExportResource scope=prototype/ bean name=/qso/{logname}/{range} id=qsoResource class=com.mspetrovic.server.restlet.QSOResource scope=prototype/ Rhett On Oct 17, 2008, at 9:10 AM, Mark Petrovic wrote: I'm posting my take on the Spring config detailed on the wiki. Previously I had been using a subclass of Application, with multiple invocations of router.attach() (per the FirstResource app) to get routing done to specific restlets. Hope this helps someone out there get over the hump. In your main() method, get the bean server and do a server.start() on it as one would normally do with a Component: bean id=server class=org.restlet.ext.spring.SpringComponent property name=server bean class=org.restlet.ext.spring.SpringServer constructor-arg value=HTTP / constructor-arg value=8182 / /bean /property property name=defaultTarget ref=router / /bean bean id=router class=org.restlet.ext.spring.SpringRouter property name=attachments map entry key=/account/register bean class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=registerResource / /bean /entry entry key=/account/login bean class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=loginResource / /bean /entry entry key=/account/confirm/{confirmationKey} bean class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=confirmationResource / /bean /entry entry key=/callsign/bind bean class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=bindCallsignResource / /bean /entry entry key=/license/lookup/{callsign} bean class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=lookupLicenseResource / /bean /entry entry key=/log/{logname} bean class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=createLogResource / /bean /entry entry key=/log/export/{logname} bean class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=exportLogResource / /bean /entry entry key=/qso/{logname} bean class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=qsoResource / /bean /entry entry key=/qso/{logname}/{range} bean class=org.restlet.ext.spring.SpringFinder lookup-method name=createResource bean=qsoResource / /bean /entry /map /property /bean bean id=registerResource class=com.mspetrovic.server.restlet.RegisterResource scope=prototype/ bean id=loginResource class=com.mspetrovic.server.restlet.LoginResource scope=prototype/ bean id=confirmationResource class=com.mspetrovic.server.restlet.AccountConfirmationResource scope=prototype/ bean id=bindCallsignResource class=com.mspetrovic.server.restlet.BindCallsignResource scope=prototype/ bean id=lookupLicenseResource
Re: Guards and authentication mechanisms
Hi Bruno, This general idea is good. I have one small objection, though: HTTP allows multiple challenges per 401 response. This means you might want to have a guard with parallel authentication checks. For this reason, I don't think that subclassing Guard per authentication scheme (basic, digest, etc.) is appropriate. Rhett On May 28, 2008, at 4:35 PM, Bruno Harbulot wrote: Hi all, Following the discussion on the authentication scheme a few days ago, I've been looking at - Access to connector authentication http://restlet.tigris.org/issues/show_bug.cgi?id=503 - Add notion of realm http://restlet.tigris.org/issues/show_bug.cgi?id=504 - Add support for Guards based password files encrypted by htpasswd http://restlet.tigris.org/issues/show_bug.cgi?id=485 I've also been looking a bit more generally at Guards, and this raised a few questions/observations/suggestions, which I suppose could be part of this discussion. I get the impression that a few things in the Guard API are there for historical reasons (I suppose the first implementation of Guard only supported HTTP BASIC). I'm trying to think of a Guard class that would be sufficiently abstract to model various types of authentication, not only HTTP BASIC/DIGEST, but also SSL client-certificates, SPNEGO Kerberos, Shibboleth and perhaps forms. I'm just not sure that the notions of Realm (i.e. BASIC/DIGEST realms), Secrets (known Map), SecretResolver, DomainURI and Nonce all belong there. What I mean is that perhaps there should be subclasses of Guard per authentication mechanism. In contrast, the solution suggested to issue 485 (htpasswd) is a subclass, and perhaps there should be the notion of a authentication- provider instead. Similarly, I'm not familiar with the OAuth Guard, but I get the impression it doesn't make much use of Realm, Secrets, etc. For example, in Apache Httpd, it's possible to configure mod_auth_basic [1][2] with several authentication providers used in to authenticate the user, for example file (htpasswd) or ldap. There's also a mechanism that In one of the machines I've set up, I've used something where it's possible to fake the SSL client certificate as a username in the file. (It's thus possible to have cert-based authentication and LDAP username/password as a fallback mechanism.) There would need to be at least two categories of password-based providers: the ones from which the secret can be extracted (required for DIGEST) and the others. It's just a vague suggestion, but there could be something like this: * AuthProvider (abstract?) * SslAuthProvider extends AuthProvider (checking the subject DN or perhaps other things) * PasswordAuthProvider extends AuthProvider (of which the secret itself can't be obtained) - checkPassword(String username, char[] password): boolean * ExtractablePasswordAuthProvider extends PasswordAuthProvider (one that can reveal the secret as well) - getPassword(String username): char[] There could be more concrete implementations: * PasswordMapAuthProvider extends ExtractablePasswordAuthProvider (more or less the same as the current secret map). * LdapAuthProvider extends PasswordAuthProvider (which checks the password against an existing LDAP server) * HtpasswdAuthProvider extends PasswordAuthProvider (which checks the password from a file as described in issue 485) * JdbcAuthProvider extends ExtractablePasswordAuthProvider (which would get the password from a database) Then, perhaps a (more) abstract Guard and then classes like these: * HttpBasicGuard extends Guard (constructed or somehow provided with a PasswordAuthProvider, it doesn't actually need to check against a known secret) * HttpDigestGuard extends Guard (constructed or somehow provider with an ExtractablePasswordAuthProvider, since it would need to know the password) These Guards could also take a list of providers rather than a single one, perhaps to have a fallback solution. All this being said, this wouldn't cover the case I was mentioning earlier of SSL-cert falling back to HTTP BASIC/LDAP, so I'd need to think a bit more about this. In addition, perhaps the AuthProviders could be used in relation to the Realms, etc. They could provide a suitable instance of Principal (e.g. LdapPrincipal, KerberosPrincipal, ... when JAAS is used). There's clearly some overlap between this notion of authentication- providers (similar to Apache Httpd) and the notion of realms (as in Tomcat or Jetty). This would clearly require a bit more thoughts, but does the general idea seem sensible? Best wishes, Bruno. [1] http://httpd.apache.org/docs/2.2/mod/mod_auth_basic.html [2] http://httpd.apache.org/docs/2.2/mod/mod_authnz_ldap.html
Re: PUT requires an entity
Hi Jim, On May 8, 2008, at 11:22 PM, Jim Alateras wrote: I've noticed that if i do a PUT to a resource with an empty entity I get a BAD_REQUEST status code. Is it part of the HTTP spec that the PUT must contain a non-null entity. We had a discussion of this a few months back. The conclusion was that the spec might be a little vague, but most implementations consider this an error. Here's the thread: http://restlet.tigris.org/servlets/ReadMsg?listName=discussmsgNo=3902 Rhett
Re: Credentials sent via Apache HttpClient not getting retrieved by Restlet Custom Guard classes
On Apr 30, 2008, at 2:18 PM, Surjendu wrote: I tried that..But i still get the credentials as null..Is there any other way to figure out whether the credentials are reaching the server. I'm a fan of wireshark for isolating client/server interaction problems: http://www.wireshark.org/ You could also try communicating with the server using a different client -- curl, for instance. Rhett
Re: Guarding all Resources using one Guard
Hi Surjendu, On Apr 21, 2008, at 11:55 AM, Surjendu wrote: Hi Barrie Thanks for ur response. But the sample codebase Jerome suggested does not work. I did the following which did not work Router router = new Router(getContext()); router.attach(/domain/{domainname}, DomainResource.class); Guard guard = new SamePageGuard(getContext(),ChallengeScheme.HTTP_BASIC); guard.setNext(router); return router; You probably want to return the guard here. Rhett
Re: Authentication Helper/Guard help
Hi Barrie, How are your restlets wired up? It sounds like the guard is not in the chain that leads to the UserResource. Rhett On Apr 6, 2008, at 4:02 PM, Barrie Selack wrote: I can't seem to get an automatic checking of authentication happening for my resource. Maybe I do not understand it correctly. I've built my SharedSecretHelper, and SharedSecretGuard. In my SharedSecretHelper my constructor is: public HttpSharedSecretHelper() { super(SharedSecretGuard.SCHEME, false, true); } But when a request comes in, it gets to my UserResource. If I check it in my UserResource I can get the headers and parse them. But it seems this sould be happening outside of my Resource. So can you tell me if my thinking is correct, or if the Resource is still responsible for doing the checking. Or am I missing how a Resource is associated with my SharedSecretHelper? Regards, Barrie Selack
Re: Authentication Helper/Guard help
Hi Barrie, That's what I believe as well... except I'm not sure how to do the wiring in the UserResource. You don't wire in the resource -- you create a chain of restlets that leads to the resource. Take a look at section 9 of the tutorial. http://www.restlet.org/documentation/1.1/tutorial Rhett On Apr 6, 2008, at 4:18 PM, Barrie Selack wrote: Rhett, That's what I believe as well... except I'm not sure how to do the wiring in the UserResource. Does the UserResource need to define something, or do I need to make a call to force the check of the authentication for it to happen? Regards, Barrie (guess I'll have to write a short Wiki how to once I have this working...) From: Rhett Sutphin [EMAIL PROTECTED] On Behalf Of Rhett Sutphin [EMAIL PROTECTED] Sent: Sunday, April 06, 2008 5:09 PM To: discuss@restlet.tigris.org Subject: Re: Authentication Helper/Guard help Hi Barrie, How are your restlets wired up? It sounds like the guard is not in the chain that leads to the UserResource. Rhett On Apr 6, 2008, at 4:02 PM, Barrie Selack wrote: I can't seem to get an automatic checking of authentication happening for my resource. Maybe I do not understand it correctly. I've built my SharedSecretHelper, and SharedSecretGuard. In my SharedSecretHelper my constructor is: public HttpSharedSecretHelper() { super(SharedSecretGuard.SCHEME, false, true); } But when a request comes in, it gets to my UserResource. If I check it in my UserResource I can get the headers and parse them. But it seems this sould be happening outside of my Resource. So can you tell me if my thinking is correct, or if the Resource is still responsible for doing the checking. Or am I missing how a Resource is associated with my SharedSecretHelper? Regards, Barrie Selack Disclaimer: This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify us immediately by e-mail and delete the original message. This e-mail expresses views only of the sender, which are not to be attributed to Rite Aid Corporation and may not be copied or distributed without this statement.
Re: Authentication Helper/Guard help
Hi Barrie, Restlet is the base class for all the stateless request handling aspects of the framework, including Router and Guard. Resource is the base class for the stateful handling of a single request. The configured restlets determine which Resource winds up handling a particular request, based on the URI, the headers, etc. Restlets may also respond to requests themselves (e.g., a Guard will respond with 401 status if authentication is required). The specific ordering of the restlets is going to depend on your particular situation. If you want to secure everything with the same Guard, it might go like this (pseudocode): Guard g = new Guard(...) Router r = new Router(...) r.attach(...) // etc. g.setNext(r) Or if you want to only secure some things, you might do it like this: Router top = new Router(...) top.attach(/insecure, InsecureResource.class) Guard g = new Guard(...) Router secureRouter = new Router(...) secureRouter.attach(/a, SecureResource.class) g.setNext(secureRouter) top.attach(/secure, g) If it's still unclear, take a look at the API documentation for Restlet and its subclasses. HTH, Rhett On Apr 6, 2008, at 5:46 PM, Barrie Selack wrote: Rhett, Thanks. I've been through all the examples and tutorials. But I'm lost on the relationship of Restlet, Router, Resource, Guard, etc. The tutorial attaches Guards to a Restlet, but I'm attaching Resources to a Route (which is also show later in the tutorials, but not in the context of a Guard). Maybe I have the concept mixed up. Can a Resource be secured by an Authentication method? The tutorial doesn't seem to show that. Am am mixing the wrong components to get to my solution? So i guess the questions is... where am I having the disconnect (in my mind) of how the pieces fit together. Regards, Barrie From: Rhett Sutphin [EMAIL PROTECTED] On Behalf Of Rhett Sutphin [EMAIL PROTECTED] Sent: Sunday, April 06, 2008 5:33 PM To: discuss@restlet.tigris.org Subject: Re: Authentication Helper/Guard help Hi Barrie, That's what I believe as well... except I'm not sure how to do the wiring in the UserResource. You don't wire in the resource -- you create a chain of restlets that leads to the resource. Take a look at section 9 of the tutorial. http://www.restlet.org/documentation/1.1/tutorial Rhett On Apr 6, 2008, at 4:18 PM, Barrie Selack wrote: Rhett, That's what I believe as well... except I'm not sure how to do the wiring in the UserResource. Does the UserResource need to define something, or do I need to make a call to force the check of the authentication for it to happen? Regards, Barrie (guess I'll have to write a short Wiki how to once I have this working...) From: Rhett Sutphin [EMAIL PROTECTED] On Behalf Of Rhett Sutphin [EMAIL PROTECTED] Sent: Sunday, April 06, 2008 5:09 PM To: discuss@restlet.tigris.org Subject: Re: Authentication Helper/Guard help Hi Barrie, How are your restlets wired up? It sounds like the guard is not in the chain that leads to the UserResource. Rhett On Apr 6, 2008, at 4:02 PM, Barrie Selack wrote: I can't seem to get an automatic checking of authentication happening for my resource. Maybe I do not understand it correctly. I've built my SharedSecretHelper, and SharedSecretGuard. In my SharedSecretHelper my constructor is: public HttpSharedSecretHelper() { super(SharedSecretGuard.SCHEME, false, true); } But when a request comes in, it gets to my UserResource. If I check it in my UserResource I can get the headers and parse them. But it seems this sould be happening outside of my Resource. So can you tell me if my thinking is correct, or if the Resource is still responsible for doing the checking. Or am I missing how a Resource is associated with my SharedSecretHelper? Regards, Barrie Selack Disclaimer: This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify us immediately by e-mail and delete the original message. This e-mail expresses views only of the sender, which are not to be attributed to Rite Aid Corporation and may not be copied or distributed without this statement. Disclaimer: This e-mail message is intended only for the personal use of the recipient(s) named above. If you are not an intended recipient, you may not review, copy or distribute this message. If you have received this communication in error, please notify us immediately by e-mail and delete the original message. This e-mail expresses views only of the sender, which are not to be attributed to Rite Aid Corporation and may not be copied or distributed without this statement.
Re: integrating restlet with the spring DispatcherServlet
Hi Michael, On Apr 1, 2008, at 10:50 AM, Michael Böckling wrote: I have trouble to figure out how to integrate it with the org.springframework.web.servlet.DispatcherServlet. I use that for some SOAP web services (using the xfire exporter), but now I want to attach a restlet using json. I was not able to find a example on how to do that! I want to use the DispatcherServlet, so the SpringServer is not an option. Using the ext.servlet.ServerServlet won't work as well, since that would bypass the DispatcherServlet too (and I can't get to the WebApplicationContext from there). Since 1.1-M2, there's RestletFrameworkServlet in the com.noelios.restlet.ext.spring extension: http://www.restlet.org/documentation/1.1/ext/com/noelios/restlet/ext/spring/RestletFrameworkServlet.html As it's name indicates, it extends spring's FrameworkServlet, just like DispatcherServlet. It gives access to the WebApplicationContext in the same way. Rhett
Re: bug in the spring SpringBeanRouter
On Apr 1, 2008, at 3:20 PM, Michael Böckling wrote: After lots of debugging, it seems wildcards don't work in the SpringBeanRouter, since the * is improperly escaped. I haven't tried using *. SpringBeanRouter is taking the bean name and passing it directly to attach. I'm not aware of anything Spring does specially with *, but there could be. Can you provide a reproduceable test case? The SpringBeanRouter also does not work when placed in the [servlet-name]-servlet.xml, it must be placed in the main applicationContext.xml. SpringBeanRouter is a Spring BeanFactoryPostProcessor. It will operate on all the Resources defined in the same context as it, so it has to go in the application context where your resources are defined. For me, this is [servlet-name]-servlet.xml. If you define your resources elsewhere, your SpringBeanRouter will have to go in the same place. If you want to put them in different places, you can use a regular Router and SpringBeanFinder. Rhett
Re: Spring + Restlet + Tomcat
Hi Stephen, On Mar 20, 2008, at 10:27 AM, Stephen Mc Namara wrote: I'm trying without much success to bootstrap a new project using both Spring (2.5) and restlet(1.1-M2). The plan goes something like this; * Restlet resources on the front end which interact with a service layer. The service layer contains some business logic but mostly passes off calls to a bunch of back end legacy systems. The goal is to expose those back end systems as a uniform set of RESTful web services. * I want to use Spring primarily for IoC, Aspects and JMX ease of use. Plus being able to fairly easily add thread pools to my back end adapters is appealing; all the usual Spring container arguments. * I can't use the Restlet HTTP server and in all likelihood the corporate powers will make us deploy on WebSphere for production but for now I'm trying to deploy Spting+Restlet as a WAR inside Tomcat. I've read all I can find on the restlet site, the faq, the wiki and this list about the various integration options but none are working. It seems there were some previous integration strategies and some newer options. Various googling has produced a confusing list of alternate approaches and I have to say the restlet docs need a major boost. This is at least partially my fault. I promised documentation for how to use RestletFrameworkServlet and SpringBeanRouter/Finder, but have not delivered them yet. I'd like to use Spring to inject the service layer into my Resources; and in general to use its IoC injection across all the beans. Having restlet config (router config, URL mapping etc) exposed (and manageable) by Spring is nice. This is how I use it today. I'd really appreciate if anyone has a complete end-to-end working example of spring+restlet in tomcat with either approach, or if you can spot a problem with the config shown above. If you'd like an end-to-end working application of moderate complexity, you can look at Patient Study Calendar (PSC): https://svn.bioinformatics.northwestern.edu/studycalendar/trunk/ It is the open source clinical research app I developed the aforementioned adapter classes for. It is primarily a Spring-MVC webapp, with Spring IoC connecting all the layers. The RESTful API was added after most of the application functionality was in place, so it is somewhat similar to your situation. In particular, I think you'll want to look at https://svn.bioinformatics.northwestern.edu/studycalendar/trunk/src/main/webapp/WEB-INF/restful-api-servlet.xml which is the spring configuration file for the RestletFrameworkServlet (using SpringBeanRouter) and https://svn.bioinformatics.northwestern.edu/studycalendar/trunk/src/main/java/edu/northwestern/bioinformatics/studycalendar/restlets/ which contains all the Resource implementations. PSC's not as clean as an example written specifically for demonstration, but hopefully it can get the point across for now. Rhett
Re: restlet + spring --- managed resources
Hi Brian, On Mar 7, 2008, at 9:50 AM, Brian Donnovan wrote: Rhett Sutphin rhett at detailedbalance.net writes: Hi Brian, On Mar 6, 2008, at 10:04 AM, Brian Donnovan wrote: thanks for the hint, i will try it that way! just one thing, i looked at the springresource class and it seems to not have much in common with the original resource class. the great thing of the resource class were the hooks for get,put,post,delete actions and the automatic trigger mechanism of the right method when a request comes in. that approach doesn´t seem to exist in the springresource, right ? As it says in the docs, do not get confused, Spring's notion of Resource is different from Restlet's one, actually it's closer to Restlet's Representations. SpringResource is a mapping from Restlet's Representation concept to _Spring's_ Resource concept. You can use regular Restlet Resource instances with Spring, so there's not a specialized subclass. You didn't say what version of Restlet you're playing with, but 1.1- M2 introduces several new spring integration modes. If you are trying to add Restlet-based code to an existing spring-backed servlet application, take a look at http://www.restlet.org/documentation/1.1/ext/com/noelios/restlet/ext/spring/Rest letFrameworkServlet.html which lets you configure a restlet-based servlet just like a Spring- MVC-based one. You might also consider using http://www.restlet.org/documentation/1.1/ext/org/restlet/ext/spring/SpringBeanRo uter.html which allows you to use spring bean names to automatically map resource implementations to URIs without manually creating finders. There isn't any documentation for these classes other than the javadoc (more coming soon). Feel free to ask questions if you run into trouble. Rhett thanks a lot for your help, i like the way the springbeanrouter works, that way i can use my resources and dependency injection along with them. but i actually faced two problems, i don´t know if i configured it wrong... 1. i get a circular reference when using the following configuration bean id=application class=com.peopleseek.web.rest.PeopleSeekApplication constructor-arg ref=component / property name=root ref=router / /bean bean id=component class=org.restlet.ext.spring.SpringComponent property name=defaultTarget ref=application / property name=server ref=server / /bean how else can i attach the application as the defaulttarget ? I'm not sure about this one. I don't use Component Application in my app, but it does look like you're using them in accordance with the documentation. 2. using the springbeanrouter i was facing another problem, i added some variants in the constructor of my resource, but the springbeanrouter calls the init-method Of the resource class after creating the bean resource and sets the variants to null. so is there another way of adding variants to the resource than on overwriting the getVariants method ? The way I handle this is to do internal configuration of the resource, including setting variants, in the init method. For example: @Override public void init(Context context, Request request, Response response) { super.init(context, request, response); setReadable(true); setModifiable(false); getVariants().add(new Variant(MediaType.TEXT_XML)); } I only use Spring XML to inject beans (services, DAOs, etc.) that are configured with Spring. Rhett
Re: restlet + spring --- managed resources
Hi Brian, On Mar 6, 2008, at 10:04 AM, Brian Donnovan wrote: thanks for the hint, i will try it that way! just one thing, i looked at the springresource class and it seems to not have much in common with the original resource class. the great thing of the resource class were the hooks for get,put,post,delete actions and the automatic trigger mechanism of the right method when a request comes in. that approach doesn´t seem to exist in the springresource, right ? As it says in the docs, do not get confused, Spring's notion of Resource is different from Restlet's one, actually it's closer to Restlet's Representations. SpringResource is a mapping from Restlet's Representation concept to _Spring's_ Resource concept. You can use regular Restlet Resource instances with Spring, so there's not a specialized subclass. You didn't say what version of Restlet you're playing with, but 1.1-M2 introduces several new spring integration modes. If you are trying to add Restlet-based code to an existing spring-backed servlet application, take a look at http://www.restlet.org/documentation/1.1/ext/com/noelios/restlet/ext/spring/RestletFrameworkServlet.html which lets you configure a restlet-based servlet just like a Spring- MVC-based one. You might also consider using http://www.restlet.org/documentation/1.1/ext/org/restlet/ext/spring/SpringBeanRouter.html which allows you to use spring bean names to automatically map resource implementations to URIs without manually creating finders. There isn't any documentation for these classes other than the javadoc (more coming soon). Feel free to ask questions if you run into trouble. Rhett
Re: Authentication: multiple challenges?
Hi Jerome, On Mar 5, 2008, at 3:41 AM, Jerome Louvel wrote: You are correct. This could be a good enhancement for 1.2. Do you want to enter a RFE in our issue tracker? Done: http://restlet.tigris.org/issues/show_bug.cgi?id=457 . Rhett
Re: Authentication Header
Hi, On Mar 4, 2008, at 9:59 AM, Jahid wrote: On server side, I am trying to set a header which will look like this ABC realm=, challenge- container=salkfadfo823w9283oinfskefn2398wenfdsk; Can anyone tell me how can I achieve that? Here I want to mention that, I dont/can't change the challenge format. So, don't ask me to do that :), also i want the challenge to go on server side as WWW-Authenticate header with a status code 201. I'm not sure (I haven't tried it yet myself), but I think that you create a ChallengeRequest object and set it in the Response. In 1.1- M2, it seems like one way to do this would be by extending Guard and overriding the challenge method. If you are using the reference engine implementation (NRE), you could also implement com.noelios.restlet.authentication.AuthenticationHelper and register your implementation using Engine#registerAuthentication. N.b.: like I said before, I haven't tried any of this myself yet. I just happen to be looking into implementing a custom authentication scheme today. Rhett