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=4447&dsMessageId=1263762
RE: GWT Restlet Callback
I figured out how to do this using the following and ran into another api problem that was easy to fix with source. I posted an earlier message about a problem I was having doing incremental updates when developing with GWT that are a problem with innerclasses. For some reason doing incremental code updates for a class where you are changing code logic but not altering the class schema is a problem with inner classes. When developing with GWT you want to minimize the amount of build/deploy when you are working on code. Incremental compiles is very important for productivity. Basically, I want the class that is calling a REST method to be the callback listener. A couple problems. The first is being able to stuff a unique name in the request so that when you get the callback to can get the name from the original calling method and execute the appropriate callback logic. When you make multiple REST calls in a single class sharing one callback method you need this. I solved this by adding this to my RestHelper class request.getAttributes().put(CALLBACK_ID, callbackID); to store a unique string based on the calling method. Then in the onEvent method I have String id = (String)request.getAttributes().get(RESTHelper.CALLBACK_ID); which allows me to handle the response with the proper code. Then next major problem is that Callback in Rest is defined as an Abstract class when it should be an interface. I pulled the source into my project and changed to an interface and added another abstract class called RestCallback that implements the interface so that you can still do inner class version of a callback and override the onEvent method. The only core Rest code that appears to need a Callback class to override is HttpClientConverter. I have solved my problem for the short term but in the event you have any code refactoring coming up it would be nice to see Callback become an interface or leave Callback as an abstract class that extends CallbackInterface and change all the calling methods to use CallbackInterface. This way it won't break code for those using the library Thanks Scooter Willis -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1263101
GWT Restlet Callback
I wanted to say a quick thanks for an excellent API/toolkit. I had no trouble getting XML data via REST calls integrated into our GWT application. Not a big fan of innerclasses but they are convenient given the examples of defining the callback class for a particular REST call. The problem I am having is doing incremental updates in debug mode where the inner classes create more than one class file to be updated which 9 times out of 10 causes the incremental update to fail. This really makes coding slow going because of the time it takes to tweak code and start a new debug instance with GWT. I am looking for a way to set an unique ID in either the client call that I can then retrieve from the request or response object. This way I would make the calling class a Callback listener and can then process multiple call backs in one method and avoid the inner class problem of doing incremental updates. I could append something to the URL and then parse but my assumption is that an easier/cleaner way already exists since you can internally map a Rest call to a particular callback class to use. If you have an easy way to do this can you email a response to hwil...@scripps.edu? Thanks Scooter Willis -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1262605
Re: Restlet 1.1.3
Hello Donald, at this time distributions don't contain the build script. I've created an issue for that point: http://restlet.tigris.org/issues/show_bug.cgi?id=750 best regards, Thierry Boileau > Thanks Thierry, > > I have that source but unfortunately it does not include the ant build > script. > The readme states that the souce is provided so that developers can > associate class files with source files while debugging. > > I suspect that whatever builds the zip file only includes some file > patterns and that does not include build.xml. > There may be other files associated with the build of which I am unaware. > > Regards > Donald. > > > > > Thierry Boileau >noelios.com> To >discuss@restlet.tigris.org > 27/02/09 07:24 PM cc > >Subject > Please respond to Re: Restlet 1.1.3 > discuss > tigris.org> > > > > > > > > Hello Donald, > > >Is it possible to make a download of Restlet 1.1.3 available that > includes all the source code? > Well, if you download the zip file or the installer for Windows (from > this page http://www.restlet.org/downloads/), you get all the sources in > the "src" directory. > > best regards, > Thierry Boileau > >> Hi Thierry, >> >> Is it possible to make a download of Restlet 1.1.3 available that >> > includes > >> all the source code? >> I have been unable to connect to the SVN site from work. >> I cannot (or don't know how to) set up a proxy for the svn client we are >> using. >> I would like the source because we are using a backport of Restlet to JDK >> 1.4. >> We are currently using Restlet 1.1.1 which we have backported ourselves. >> >> Thanks >> 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 or lost because this email has been sent to you >> > in > >> error. If you have received it in error, please let us know by reply >> email, delete it from your system and destroy any copies. >> ** >> >> -- >> >> > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1236155 > > >> > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1237474 > > > > > > ** > 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 or lost because this email has been sent to you in > error. If you have received it in error, please let us know by reply > email, delete it from your system and destroy any copies. > ** > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1259365 > > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1262266
Re: Embedding hierarchy of differing depths in URIs
Hello, it is more a matter of URI design that compliance to REST principles. If there is a real hierarchy, well, it seems correct. Do all URIs identify the same kind of resource, the same concept? If so, you can proceed as follow: Route route = router.attach("/{hierarchy}/{data}", ); Template template = route.getTemplate(); template.getVariables().put("hierarchy", new Variable(Variable.TYPE_ALL)); In this case, the "hierarchy" variable gets the whole hierarchy and let the "data" variable get the last segment (variable catch segments by default ). Then, in your Restlet or Resource, you can have access to the content of "hierarchy" and "data" variables : System.out.println("hierarchy " + request.getAttributes().get("hierarchy")); System.out.println("data " + request.getAttributes().get("data")); I hope this will help you. Best regards, Thierry Boileau > There are hierarchies which i need to expose. > E.g. foo.com/1/2/3/data > foo.com/5/6/data > foo.com/5/7/8/9/data > foo.com/0/10/11/12/13/14/15/data > > Different hierarchies are of differing depths which can be known only at > runtime. Also there are numerous hierarchies. > > My first question is whether this is conforming to the REST architecture > principles. If yes, then, how can i configure my router in such a scenario. > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1259856 > > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1262095
RE: POST/PUT requests take more than 2 seconds
Hi again, I'm working on this project again (after more than one month of interruption). I'm now using: - Restlet 1.1.3 - curl 7.16.3 - RESTClient 2.3 - the same sample code as Avi (see link to his message below) Here are the results with curl: > time curl -X POST -d @test.txt http://localhost:3000/ Test real0m0.008s user0m0.003s sys 0m0.003s > time curl -0 -X POST -d @test.txt http://localhost:3000/ Test real0m0.009s user0m0.004s sys 0m0.003s So, no problem with curl, as previously mentioned. Now, with RESTClient (HTTP 1.0): "Response received in 7 ms". With RESTClient (HTTP 1.1): "Response received in 2003 ms". That was my problem. It's perfectly reproducible. RESTClient uses HTTP 1.1 by default, which I previously hadn't realized. I don't know why curl doesn't have the same problem, though. At that point, I don't know if it's a bug in RESTClient or in Restlet. What do you think? Thanks, Olivier > I actually have the same problem as Avi here: > > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=930917 > > Almost the same configuration, Mac OS 10.5.6. Internal HTTP server. > > When handling POST/PUT requests, the Entity.getText() method takes 2 seconds > to return a string. > > Is there any solution to this problem, other than not using the internal HTTP > server? > > Thanks, > Olivier -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1261669
Re: Transformer -- dynamic use
Hi, by the way, you can also define a unique Resource for the main reason that there is no need to make a distinction based on the format. Both HTML and XML representations vehicle the same data and represent the same concept, ie resource. That is to say : * Have a single resource router.attach("/{device}/filelist", FilelistResource.class); * This resource defines the supported formats, for example in the constructor: getVariants().add(new Variant(MediaType.TEXT_XML); getVariants().add(new Variant(MediaType.TEXT_HTML); * Then, just implements the method FilelistResource#represent(Variant variant) where variant is one of the defined variant, and is computed according to client's preferences. You can have a look at the tutorial => http://www.restlet.org/documentation/1.1/firstResource And at the tunnel service for several ways to update client's preferences => http://www.restlet.org/documentation/1.1/api/org/restlet/service/TunnelService.html best regards, Thierry Boileau > Hi -- > > I have a router in my createRoot method which looks like: > router.attach("/{device}/{format}/filelist", > FilelistResource.class); > > The goal is to either return a file listing in one of many formats depending > on how {format} is set (html,xml) for right now. In my Resource constructor > I set the MediaType to either TEXT_XML or TEXT_HTML. > > In my represent method I branch based on the type of representation I need to > return. I select the filelist in an xml format, immediately returning it in > a DomRepresentation if xml. My trouble is using the transformer to generate > output using my xslt and xml. > > my represent logic looks like this for the html generation: > > // get xml doc containing file list to show > DomRepresentation xmlRepresentation = getFileListXML(); > > // need to transform to html > DomRepresentation xsltRepresentation = > new DomRepresentation(MediaType.TEXT_XML); > > // get a factory to build a document > DocumentBuilderFactory factory = > DocumentBuilderFactory.newInstance(); > factory.setNamespaceAware(true); > > // create a new document builder > DocumentBuilder docBldr = > factory.newDocumentBuilder(); > Document xsltDoc = xsltRepresentation.getDocument(); > > //xsltRepresentation.setDocument(xsltDoc); > // read in the xsl document > xsltDoc = docBldr.parse("index.xsl"); > > > // create a transformer Transformer transformer = > new Transformer(Transformer.MODE_RESPONSE, >xsltRepresentation); > transformer.setResultMediaType(MediaType.TEXT_HTML); > //DomRepresentation htmlRepresentation = > return transformer.transform(xmlRepresentation); > > > The output error is as follows > --- > [Fatal Error] :1:55: Premature end of file. > ERROR: 'Premature end of file.' > FATAL ERROR: 'Could not compile stylesheet' > > > Thanks for any help.. I've been stuck on this for quite sometime and dug just > about everywhere to find a way to use the transformer class. > > Thanks > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1249166 > > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1262030
Re: Transformer -- dynamic use
Hi, could you try with another kind of representations (not DomRepresentation) such as FileRepresentation or StringRepresentation for both XML and XSLT files? Representation xmlRepresentation = new FileRepresentation("/path/to/file.xml", MediaType.TEXT_XML)); Representation xsltRepresentation = new FileRepresentation("/path/to/file.xsl", MediaType.TEXT_XML)); Representation htmlRepresentation = new TransformRepresentation(xmlRepresentation, xsltRepresentation); htmlRepresentation.write(System.out); best regards, Thierry Boileau > Hi -- > > I have a router in my createRoot method which looks like: > router.attach("/{device}/{format}/filelist", > FilelistResource.class); > > The goal is to either return a file listing in one of many formats depending > on how {format} is set (html,xml) for right now. In my Resource constructor > I set the MediaType to either TEXT_XML or TEXT_HTML. > > In my represent method I branch based on the type of representation I need to > return. I select the filelist in an xml format, immediately returning it in > a DomRepresentation if xml. My trouble is using the transformer to generate > output using my xslt and xml. > > my represent logic looks like this for the html generation: > > // get xml doc containing file list to show > DomRepresentation xmlRepresentation = getFileListXML(); > > // need to transform to html > DomRepresentation xsltRepresentation = > new DomRepresentation(MediaType.TEXT_XML); > > // get a factory to build a document > DocumentBuilderFactory factory = > DocumentBuilderFactory.newInstance(); > factory.setNamespaceAware(true); > > // create a new document builder > DocumentBuilder docBldr = > factory.newDocumentBuilder(); > Document xsltDoc = xsltRepresentation.getDocument(); > > //xsltRepresentation.setDocument(xsltDoc); > // read in the xsl document > xsltDoc = docBldr.parse("index.xsl"); > > > // create a transformer Transformer transformer = > new Transformer(Transformer.MODE_RESPONSE, >xsltRepresentation); > transformer.setResultMediaType(MediaType.TEXT_HTML); > //DomRepresentation htmlRepresentation = > return transformer.transform(xmlRepresentation); > > > The output error is as follows > --- > [Fatal Error] :1:55: Premature end of file. > ERROR: 'Premature end of file.' > FATAL ERROR: 'Could not compile stylesheet' > > > Thanks for any help.. I've been stuck on this for quite sometime and dug just > about everywhere to find a way to use the transformer class. > > Thanks > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1249166 > > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1262008
Re: Transformer -- dynamic use
Hi mbutner, sounds to me that your XML file is corrupt. Do you checked this? best regards Stephan mbut...@gmail.com schrieb: > Hi -- > > I have a router in my createRoot method which looks like: > router.attach("/{device}/{format}/filelist", > FilelistResource.class); > > The goal is to either return a file listing in one of many formats depending > on how {format} is set (html,xml) for right now. In my Resource constructor > I set the MediaType to either TEXT_XML or TEXT_HTML. > > In my represent method I branch based on the type of representation I need to > return. I select the filelist in an xml format, immediately returning it in > a DomRepresentation if xml. My trouble is using the transformer to generate > output using my xslt and xml. > > my represent logic looks like this for the html generation: > > // get xml doc containing file list to show > DomRepresentation xmlRepresentation = getFileListXML(); > > // need to transform to html > DomRepresentation xsltRepresentation = > new DomRepresentation(MediaType.TEXT_XML); > > // get a factory to build a document > DocumentBuilderFactory factory = > DocumentBuilderFactory.newInstance(); > factory.setNamespaceAware(true); > > // create a new document builder > DocumentBuilder docBldr = > factory.newDocumentBuilder(); > Document xsltDoc = xsltRepresentation.getDocument(); > > //xsltRepresentation.setDocument(xsltDoc); > // read in the xsl document > xsltDoc = docBldr.parse("index.xsl"); > > > // create a transformer Transformer transformer = > new Transformer(Transformer.MODE_RESPONSE, >xsltRepresentation); > transformer.setResultMediaType(MediaType.TEXT_HTML); > //DomRepresentation htmlRepresentation = > return transformer.transform(xmlRepresentation); > > > The output error is as follows > --- > [Fatal Error] :1:55: Premature end of file. > ERROR: 'Premature end of file.' > FATAL ERROR: 'Could not compile stylesheet' > > > Thanks for any help.. I've been stuck on this for quite sometime and dug just > about everywhere to find a way to use the transformer class. > > Thanks -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1261603
Re: Bad paths returned in the Content-Location header from Directories using the File protocol?
Hi David, the fix is available in the svn repository. Best regards, Thierry Boileau > Hello David > > Thanks for the reports, this is a bug. A new RFC has been entered : > http://restlet.tigris.org/issues/show_bug.cgi?id=749 > > best regards, > Thierry Boileau > > >> Hi Thierry- >> >> Thanks for the fix! It appears to work correctly on the svn head. >> >> We're seeing another problem with Content-Location response headers, this >> time with the CLAP protocol. >> >> We get back response headers like this: >> >> HTTP/1.1 200 The request has succeeded >> ... >> Content-Location: clap://thread/META-INF/MANIFEST.MF >> >> >> notice that the Content-Location value has the "clap://thread/" on it >> instead of, for example, "http://location:8080/.."; >> >> This seems like a bug! >> >> thanks, >> -Dave Fogel >> >> -- >> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1258092 >> >> >> > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1260896 > > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1261057
Re: Bad paths returned in the Content-Location header from Directories using the File protocol?
Hello David Thanks for the reports, this is a bug. A new RFC has been entered : http://restlet.tigris.org/issues/show_bug.cgi?id=749 best regards, Thierry Boileau > Hi Thierry- > > Thanks for the fix! It appears to work correctly on the svn head. > > We're seeing another problem with Content-Location response headers, this > time with the CLAP protocol. > > We get back response headers like this: > > HTTP/1.1 200 The request has succeeded > ... > Content-Location: clap://thread/META-INF/MANIFEST.MF > > > notice that the Content-Location value has the "clap://thread/" on it instead > of, for example, "http://location:8080/.."; > > This seems like a bug! > > thanks, > -Dave Fogel > > -- > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1258092 > > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1260896
Re: Patch: OSGi dependency in fileupload
Hello Rob, thanks for the patches, it is now available in the svn repository. best regards, Thierry Boileau > Another one: dbcp depends on pool.impl at runtime: > > Index: META-INF/MANIFEST.MF > === > --- META-INF/MANIFEST.MF (revision 4318) > +++ META-INF/MANIFEST.MF (working copy) > @@ -25,4 +25,5 @@ > javax.sql", > org.apache.commons.jocl;uses:="org.xml.sax,org.xml.sax.helpers" > Bundle-RequiredExecutionEnvironment: J2SE-1.5 > -Import-Package: org.apache.commons.pool > +Import-Package: org.apache.commons.pool, > + org.apache.commons.pool.impl > -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1260499
Embedding hierarchy of differing depths in URIs
There are hierarchies which i need to expose. E.g. foo.com/1/2/3/data foo.com/5/6/data foo.com/5/7/8/9/data foo.com/0/10/11/12/13/14/15/data Different hierarchies are of differing depths which can be known only at runtime. Also there are numerous hierarchies. My first question is whether this is conforming to the REST architecture principles. If yes, then, how can i configure my router in such a scenario. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1259856