Re: UrlConneciton based HTTP client tiimeouts
Hello, I'm using JDK6 and restlet 2.0m3 / 2.0m5. Yes, i have found this issue during debug. The parameters are set, but getHelper().getXXX doesn't return parameters, i've used while creating client. Instead it returns zero. My code looks like Client client = new Client(Protocol.HTTP); Context ctx = new Context(); ctx.getParameters().add(readTimeout, 5000); client.setContext(ctx); client.setConnectTimeout(5000); And regarding to some internal app limitations i can't create client with context passed as constructor argument. So it should be processed in the order i've shown above. Hi Evgeny, Looking at the code in SVN trunk, we do set the property, but only if Java 1.5: // These properties can only be used with Java 1.5 and upper // releases int majorVersionNumber = SystemUtils.getJavaMajorVersion(); int minorVersionNumber = SystemUtils.getJavaMinorVersion(); if ((majorVersionNumber 1) || ((majorVersionNumber == 1) (minorVersionNumber = 5))) { this.connection.setConnectTimeout(getHelper() .getConnectTimeout()); this.connection.setReadTimeout(getHelper().getReadTimeout()); } Which version are you using? Could you debug the Restlet code to see if it steps into this section (see org.restlet.ext.net.internal.HttpUrlConnectionCall's constructor). 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 : news [mailto:n...@ger.gmane.org] De la part de Evgeny Shepelyuk Envoyé : mercredi 7 octobre 2009 14:56 À : discuss@restlet.tigris.org Objet : UrlConneciton based HTTP client tiimeouts Hello, While trying to set connection timeouts for HTTP client based based on org.restlet.ext.net extension i've noticed that connectTimeout is not taken into acctount parameter id not set into underlying conneciton) when performing request I've used 2.0m3 and 2.0m5 versions of Restlet. -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2404882
UrlConneciton based HTTP client tiimeouts
Hello, While trying to set connection timeouts for HTTP client based based on org.restlet.ext.net extension i've noticed that connectTimeout is not taken into acctount parameter id not set into underlying conneciton) when performing request I've used 2.0m3 and 2.0m5 versions of Restlet. -- Evgeny Shepelyuk Software Architect and Developer, Soft Industry Ltd. Chernihiv, Ukraine http://www.soft-industry.com E-mail: e.shepel...@soft-industry.com tel. +(380)-462-651-415 tel. +(380)-44-229-52-83 tel. +(380)-462-675-244 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2404499
Re: logging framework for restlet
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 -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2402392
Re: Problem with SpringBeanFinder in Restlet 2.0m4
Hello, Nice to know Spring problems are fixed. But i can't undeerstand your changes in attached archive. Why it's required to point full path in reouter configuration ? Hi Evgeny, I'm happy to report that the Spring issues with ServerResource that you reported are now fixed in SVN trunk. Thanks also to Rhett for the help fixing this. Note that there was a URI issue in your Spring XML configuration file. See the updated version attached. Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -Message d'origine- De : Rhett Sutphin [mailto:rh...@detailedbalance.net] Envoyé : lundi 7 septembre 2009 07:40 À : discuss@restlet.tigris.org Objet : 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=23888 16 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=23899 14 -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=23900 72 src.zip -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=23917 44 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2399592 -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2400113
Problem with SpringBeanFinder in Restlet 2.0m4
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
ServerResource - set avaialable variants
Hello, It's not quite clear how to set available media types to my resource implemented with ServerResource. Before in init() method i didi following getVariants().add(new Variant(MediaType.TEXT_HTML)); How to handle the same with new ServerResource class ? -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2388802
Re: Auth by client's certificate
Hello, Jerome Unfortunately i dont have enought knowledge on how htis SSL things are working. So taking care of such RFE is out of my possibilities :) Hi Evgeny, I think it is a good idea to create a RFE summarizing this discussion. Do you want to take care of it? As a solution, I was thinking about passing the SSLSession as a special request attribute (org.restlet.https.sslSession for example). Then you could retrieve it in your application, call the SSLSession#invalidate() method. However, I'm less clear about the next steps and how they could be supported in a connector independent way... Maybe we should introduce some kind of façade class, like SslContextFactory abstract class that you contributed Bruno? Another case where it is necessary to interact with the lower-level connections from the upper Restlet layer is for connection tunneling via the HTTPS CONNECT method. Maybe there is a common pattern that will emerge. See related RFE: Support HTTP proxies and gateways http://restlet.tigris.org/issues/show_bug.cgi?id=207 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 : news [mailto:n...@ger.gmane.org] De la part de Evgeny Shepelyuk Envoyé : vendredi 21 août 2009 10:56 À : discuss@restlet.tigris.org Objet : Re: Auth by client's certificate Well, maybe it's reasonable to create RFE for this and try to impelment extenstion prototype ? Hi, I'm not sure. If GrizzlyServerCall is running from the same thread the SSLReadFilter is used, SSLReadFilter.doPeerCertificateChain(...), with the selection key in the GrizzlyServerCall should work. What you need ultimately is to get hold of the SSLSession (via SSLEngine or SSLSocket), invalidate this session, re-set the want/need parameter, re-start the handshake (and make sure it has completed before proceeding). I think the biggest problem, from the Restlet point of view, is that the higher level classes (Restlet/Resource/...) would need somehow to be able to get hold of the HttpServerCall to trigger this (and supporting this feature would also depend on the connector implementation). This would be something unusual compared with the rest of the architecture of the Restlet framework. I'm not sure what the rest of the community (in particular Jerome and Thierry) would think about that. I'd be happy to assist, but I'm not sure how big the modifications in the API and Restlet architecture would be. Best wishes, Bruno. Evgeny Shepelyuk wrote: Hi Thnx for this answert I have one small request Can you point to Grizzly classes how this goal can be achieved ? Hi Evgeny, Evgeny Shepelyuk wrote: Hello, I'm using Jetty as restlet HTTP engine with SSL enabled and client's certificate auth. Probabaly it's more related to Jetty but is this possible to make server only ask for certificates only for certain URL. I'm NOT USING needClientAuthentication, so certificate is not mandatory, but what i want is following - for certain resources still use HTTPS, but never let browser to ask for client's certificate. Only way i сan see now - is creating 2 HTTPS connectors and run 2 server sockets within restlet app. In principle, this can be achieved by re-negotiating the handshake. This is something that Tomcat supports if the listening socket isn't configured to want or need authentication but CLIENT-CERT is used within the webapp. As far as I know, Jetty (as a container) doesn't support it. I don't think its API supports it either. The Grizzly library has some support for this mechanism. The Restlet API doesn't support it at the moment. Currently, the client certificate is populated when the handler is set up (when the socket is connected), after that, the upper layers (Application/Resource/...) can't talk back to the socket to tell it to re-negotiate. This is not impossible, but it would require some changes in the API, in particular HttpServerCall and the way the client certificate is then passed to the request attributes. I also reported a bug about this using Glassfish/Grizzly (nothing Restlet-specific) a few months ago; I haven't tried more recently. https://grizzly.dev.java.net/issues/show_bug.cgi?id=416 This would definitely be a problem to implement this feature in Restlet if the libraries used by the connectors don't support it. A possible workaround might be to use Restlet within Tomcat and to use CLIENT-CERT for the URI patterns (defined in web.xml) that you know will want client-certificate authentication. Best wishes, Bruno. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2385222 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId
Re: Auth by client's certificate
Well, maybe it's reasonable to create RFE for this and try to impelment extenstion prototype ? Hi, I'm not sure. If GrizzlyServerCall is running from the same thread the SSLReadFilter is used, SSLReadFilter.doPeerCertificateChain(...), with the selection key in the GrizzlyServerCall should work. What you need ultimately is to get hold of the SSLSession (via SSLEngine or SSLSocket), invalidate this session, re-set the want/need parameter, re-start the handshake (and make sure it has completed before proceeding). I think the biggest problem, from the Restlet point of view, is that the higher level classes (Restlet/Resource/...) would need somehow to be able to get hold of the HttpServerCall to trigger this (and supporting this feature would also depend on the connector implementation). This would be something unusual compared with the rest of the architecture of the Restlet framework. I'm not sure what the rest of the community (in particular Jerome and Thierry) would think about that. I'd be happy to assist, but I'm not sure how big the modifications in the API and Restlet architecture would be. Best wishes, Bruno. Evgeny Shepelyuk wrote: Hi Thnx for this answert I have one small request Can you point to Grizzly classes how this goal can be achieved ? Hi Evgeny, Evgeny Shepelyuk wrote: Hello, I'm using Jetty as restlet HTTP engine with SSL enabled and client's certificate auth. Probabaly it's more related to Jetty but is this possible to make server only ask for certificates only for certain URL. I'm NOT USING needClientAuthentication, so certificate is not mandatory, but what i want is following - for certain resources still use HTTPS, but never let browser to ask for client's certificate. Only way i сan see now - is creating 2 HTTPS connectors and run 2 server sockets within restlet app. In principle, this can be achieved by re-negotiating the handshake. This is something that Tomcat supports if the listening socket isn't configured to want or need authentication but CLIENT-CERT is used within the webapp. As far as I know, Jetty (as a container) doesn't support it. I don't think its API supports it either. The Grizzly library has some support for this mechanism. The Restlet API doesn't support it at the moment. Currently, the client certificate is populated when the handler is set up (when the socket is connected), after that, the upper layers (Application/Resource/...) can't talk back to the socket to tell it to re-negotiate. This is not impossible, but it would require some changes in the API, in particular HttpServerCall and the way the client certificate is then passed to the request attributes. I also reported a bug about this using Glassfish/Grizzly (nothing Restlet-specific) a few months ago; I haven't tried more recently. https://grizzly.dev.java.net/issues/show_bug.cgi?id=416 This would definitely be a problem to implement this feature in Restlet if the libraries used by the connectors don't support it. A possible workaround might be to use Restlet within Tomcat and to use CLIENT-CERT for the URI patterns (defined in web.xml) that you know will want client-certificate authentication. Best wishes, Bruno. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2385222 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2385695 -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2385928
Retry functionality of Сlient
Hello, Is there any functionality in restlet's client that allows easy set connection retry policy ? It can be based onn timeouts, retry attempts, exception received etc. -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2386012
Re: Asynchronous tasks in RESTlet
Hello, What kind of problems do you expirience ? For example there can be few workarounds - run Grizzly container with some URL that can proces asynch tasks (grizzly has support for this) And other URL to be configured run standart servlet, that will be servlet to restlet bridge. smth like that :)) Hi, is there already support for asynchronous tasks? What I can see up to now is Issue 143: http://restlet.tigris.org/issues/show_bug.cgi?id=143 and an older thread started by Tim Peierls: http://markmail.org/message/rhldu44ynsfqm333#query:restlet% 20asynchronous+page:1+mid:ae242wcwa4wk2iye+state:results Is there some working routine by now? Or some standard work-around to handle asynchronous tasks started on the server? Regards, Tobias -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2385626
Re: Auth by client's certificate
Hi Thnx for this answert I have one small request Can you point to Grizzly classes how this goal can be achieved ? Hi Evgeny, Evgeny Shepelyuk wrote: Hello, I'm using Jetty as restlet HTTP engine with SSL enabled and client's certificate auth. Probabaly it's more related to Jetty but is this possible to make server only ask for certificates only for certain URL. I'm NOT USING needClientAuthentication, so certificate is not mandatory, but what i want is following - for certain resources still use HTTPS, but never let browser to ask for client's certificate. Only way i сan see now - is creating 2 HTTPS connectors and run 2 server sockets within restlet app. In principle, this can be achieved by re-negotiating the handshake. This is something that Tomcat supports if the listening socket isn't configured to want or need authentication but CLIENT-CERT is used within the webapp. As far as I know, Jetty (as a container) doesn't support it. I don't think its API supports it either. The Grizzly library has some support for this mechanism. The Restlet API doesn't support it at the moment. Currently, the client certificate is populated when the handler is set up (when the socket is connected), after that, the upper layers (Application/Resource/...) can't talk back to the socket to tell it to re-negotiate. This is not impossible, but it would require some changes in the API, in particular HttpServerCall and the way the client certificate is then passed to the request attributes. I also reported a bug about this using Glassfish/Grizzly (nothing Restlet-specific) a few months ago; I haven't tried more recently. https://grizzly.dev.java.net/issues/show_bug.cgi?id=416 This would definitely be a problem to implement this feature in Restlet if the libraries used by the connectors don't support it. A possible workaround might be to use Restlet within Tomcat and to use CLIENT-CERT for the URI patterns (defined in web.xml) that you know will want client-certificate authentication. Best wishes, Bruno. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2385222 -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2385290
Auth by client's certificate
Hello, I'm using Jetty as restlet HTTP engine with SSL enabled and client's certificate auth. Probabaly it's more related to Jetty but is this possible to make server only ask for certificates only for certain URL. I'm NOT USING needClientAuthentication, so certificate is not mandatory, but what i want is following - for certain resources still use HTTPS, but never let browser to ask for client's certificate. Only way i сan see now - is creating 2 HTTPS connectors and run 2 server sockets within restlet app. -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2384794
Re: Server connector parameters ignored when configuring from Spring
Hello Jerome, Which wil be restlet version containing the fix ? This will be available in 2.0 final or earlier, what about 1.1 branch ? Hi Evgeny, I've refactored the JettyServerHelper to lazy-configure the thread pool. It should now be configurable via Spring! 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 : news [mailto:n...@ger.gmane.org] De la part de Evgeny Shepelyuk Envoyé : mardi 4 août 2009 16:45 À : discuss@restlet.tigris.org Objet : Re: Server connector parameters ignored when configuring from Spring Hi One small note, Only Thread Pool size are not taken into account, Connector by itself is configured OK. Seems the reason is that thread pool settings are configured inside constuctor Hello, While developing my restlet application i faced following problem. Im using restlet 2.0m3 with Jetty server connector and configuring my server from Spring. This is snippet of XML file bean id=springComponent class=org.restlet.ext.spring.SpringComponent init-method=start property name=clientsList list valuehttp/value /list /property property name=server bean class=org.restlet.ext.spring.SpringServer id=springServer constructor-arg value=http type=java.lang.String/ constructor-arg value=4343 type=int/ property name=parameters map entry key=acceptorThreads value=20/ entry key=acceptQueueSize value=400/ entry key=maxThreads value=800/ /map /property /bean /property property name=defaultTarget ref=springRouter/ /bean The expected behaviour of passing the parameters to underlying jetty instance has not occurred. While debugging and researchign source code i found following in class JettyServerHelper method public SeriesParameter getHelpedParameters() always returns empry parameters because method getHelped() returns null. Can anyone give me a hand and explain if this is a bug or i'm configuring server connector incorrectly ? -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2384360
Re: Scalable media server in restlet - HOW TO ?
Hello Jerome, Thnx for explanation. Fortunately we accepted thread-per-request model finally :) So for now this problem is solved, In out case we also laveraged grizzly comet extension to prototype non-blocking long request processing. Hi Evgeny, Regarding the Grizzly connector, there is an existing RFE to support its configuration via properties. For now you would have to subclass it an override the configure(Controller) method: Improve Grizzly connector http://restlet.tigris.org/issues/show_bug.cgi?id=563 Now, your requirement implies that you need as many worker threads as there are clients connected because one thread would be blocked in each write(OutputStream) method... If you can't support 500 threads at the same time in your JVM or can't do load-balancing, then I don't think the current level of NIO support in Restlet will help. NIO connectors such as Grizzly and Jetty reduce the number of IO threads used so you can accept more connections that the actual number of worker threads available. But in the case of long-lived connections that doesn't help. What you are looking requires fully asynchronous processing support in Restlet which isn't available yet. See the related RFE: Support asynchronous processing http://restlet.tigris.org/issues/show_bug.cgi?id=143 Even though we did make progress in this front thanks to our GWT edition (client-side), we still have work to do to port this logic to other edition and support asynchronicity on the server-side. As a workaround, you might want to directly explore Jetty and Grizzly asynchronous features. 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 : news [mailto:n...@ger.gmane.org] De la part de Evgeny Shepelyuk Envoyé : jeudi 30 juillet 2009 16:16 À : discuss@restlet.tigris.org Objet : Scalable media server in restlet - HOW TO ? Hello, I need some advices on building scalable media server with restlet. The idea is to buld application that serves media to relative big number clients (about 500). The spec,ific features of clients' request are HTTP long-living nature. So once connected client permanently fetches content from server. Because simultaneous number of clients is high the blocking thread-per-request model is not appropriate (maybe im wrong ?). My current approach consist of following steps 1. restlet that returns HTTP OK and custom representaion (extending OutputRepresentation) 2. representation has blocking queue inside it and in write() method register that queue inside media manager to be notified about media events that should be streamed to underlying client. 3. HTTP connection should not break and be permanent - client should not reconnect after it got connected to server. 4. inside write() method of representation i'm performing blocking get from blockign queue to receive event from media manager that should be written to client's stream. So now i'm playing with jetty NIO connector paramters and can server about 200-250 requests but its no less thatn required. Can anyone give me some advice on designing the project to achieve requred scalability ? PS: I was trying to use Grizzly connector with approach described above but it was serving about 10 clients and not more. Also the Grizzly connector seems not having parameters to configure PPS: Im using restlet 2.0m3 -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2384267
Re: Server connector parameters ignored when configuring from Spring
Hello again Can anyone asnwer smth about my issue ? Hello, While developing my restlet application i faced following problem. Im using restlet 2.0m3 with Jetty server connector and configuring my server from Spring. This is snippet of XML file bean id=springComponent class=org.restlet.ext.spring.SpringComponent init-method=start property name=clientsList list valuehttp/value /list /property property name=server bean class=org.restlet.ext.spring.SpringServer id=springServer constructor-arg value=http type=java.lang.String/ constructor-arg value=4343 type=int/ property name=parameters map entry key=acceptorThreads value=20/ entry key=acceptQueueSize value=400/ entry key=maxThreads value=800/ /map /property /bean /property property name=defaultTarget ref=springRouter/ /bean The expected behaviour of passing the parameters to underlying jetty instance has not occurred. While debugging and researchign source code i found following in class JettyServerHelper method public SeriesParameter getHelpedParameters() always returns empry parameters because method getHelped() returns null. Can anyone give me a hand and explain if this is a bug or i'm configuring server connector incorrectly ? -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2379927
Server connector parameters ignored when configuring from Spring
Hello, While developing my restlet application i faced following problem. Im using restlet 2.0m3 with Jetty server connector and configuring my server from Spring. This is snippet of XML file bean id=springComponent class=org.restlet.ext.spring.SpringComponent init-method=start property name=clientsList list valuehttp/value /list /property property name=server bean class=org.restlet.ext.spring.SpringServer id=springServer constructor-arg value=http type=java.lang.String/ constructor-arg value=4343 type=int/ property name=parameters map entry key=acceptorThreads value=20/ entry key=acceptQueueSize value=400/ entry key=maxThreads value=800/ /map /property /bean /property property name=defaultTarget ref=springRouter/ /bean The expected behaviour of passing the parameters to underlying jetty instance has not occurred. While debugging and researchign source code i found following in class JettyServerHelper method public SeriesParameter getHelpedParameters() always returns empry parameters because method getHelped() returns null. Can anyone give me a hand and explain if this is a bug or i'm configuring server connector incorrectly ? -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2377285
Scalable media server in restlet - HOW TO ?
Hello, I need some advices on building scalable media server with restlet. The idea is to buld application that serves media to relative big number clients (about 500). The specific features of clients' request are HTTP long-living nature. So once connected client permanently fetches content from server. Because simultaneous number of clients is high the blocking thread-per-request model is not appropriate (maybe im wrong ?). My current approach consist of following steps 1. restlet that returns HTTP OK and custom representaion (extending OutputRepresentation) 2. representation has blocking queue inside it and in write() method register that queue inside media manager to be notified about media events that should be streamed to underlying client. 3. HTTP connection should not break and be permanent - client should not reconnect after it got connected to server. 4. inside write() method of representation i'm performing blocking get from blockign queue to receive event from media manager that should be written to client's stream. So now i'm playing with jetty NIO connector paramters and can server about 200-250 requests but its no less thatn required. Can anyone give me some advice on designing the project to achieve requred scalability ? PS: I was trying to use Grizzly connector with approach described above but it was serving about 10 clients and not more. Also the Grizzly connector seems not having parameters to configure PPS: Im using restlet 2.0m3 -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2376958
Non-blocking application architecture quesiton
Hello, I have a question regarding architecture of NIO application. My restlets are going to stream content to clients for a long time. So connection between server and client will be long living. I'm using Jetty a server connector with NIO jetty server. On restlet side i'm extending OutputRepresentation and override write method to stream contetn to underlying client. Is it true and i will get all advantages of NIO ? Or i should extend ChannelRepresentation and use Java NIO channels, byte buffers to stream content ? -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2374719
Parameters of media-type
Hello, I'm using Restlet 2.0m3 What i need is to receive following string of content-type in HTTP response. Content-type: multipart/x-mixed-replace; boundary=My boundary When i'm using code like this MediaType.valueOf(\multipart/x-mixed-replace; boundary=\My boundary\) i receive following in response Content-Type: multipart/x-mixed-replace; boundary=My boundary; boundary=My boundary Also i cant add parameter programmaticaly since parameters are unmodifiable in MediaType class. How can i solve my problem ? -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2374692
Re: Receive a multipart HTTP response
Hello ! I've tried to use commons-fileupload and it's not parsing multipart/x-mixed-replace content type. I tried both directly with commons-fileupload and with restlet extension. Commons-fileupload supports only multipart/form-data and correponding RFC 1867. All others ain't supported according to users' reviews and actually other RFCs ain't declared as suppored by commons-fileupload team. Please note again. In my case i don't upload files, i have server-side HTTP push from digital camera stream. However i was able to easily solve my problem using mimepull library from Glasshfish project. Hi Evgeny, Restlet doesnt have built-in support for multipart representation yet. This is planned however: Support composite representations http://restlet.tigris.org/issues/show_bug.cgi?id=71 However, it is possible to parse progressively with the Restlet FileUpload extension. See the related doc: http://commons.apache.org/fileupload/streaming.html Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org/ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com/ http://www.noelios.com De : Evgeny Shepelyuk [mailto:eshepel...@gmail.com] Envoyé : lundi 20 juillet 2009 23:12 À : discuss@restlet.tigris.org Objet : Re: Receive a multipart HTTP response 1. FileUpload doesn't support multipart/mixed 2. I need HTTP not XMPP 3. Seems restlet don't have any support for parsing multipart/mixed response 4. The problem can be solved with MimePull from Glasshfish or any similar library. Probably mime4j from James project. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2372849 -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2372851
Re: Receive a multipart HTTP response
Let me give more details. 1. we don't need parse multipart file upload. 2. we need to read long time multipart HTTP response item by item 3. i think FileUpload extension will work only after complete read of input stream. but in our case the request is never finished and the items should be read from stream only when available. Can someone calrify those issues and tell if im wrong ? David Bordoley wrote: Check out org.restlet.ext.fileupload. Its a representation wrapper around apache file upload that will allow you to parse multipart uploads. dave On Fri, Jul 17, 2009 at 8:02 AM, Evgeny Shepelyukeshepel...@gmail.com wrote: Hello We're about to develop application that should read data from video camera. Data from camera is sent via HTTP as single multipart _response_. My question is ift convenient and possible to use restlet to read such kind of data. Is there any possibilities not to manually read boundaries header from input stream but rather use some high-level api. Smth like reponse.getNextPart() - this return bytes of next chunk from stream. Referring to this article at StackOverflow/ http://stackoverflow.com/questions/419850/java-receive-a-multipart-http-response -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2372092 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2372127 -- View this message in context: http://n2.nabble.com/Receive-a-multipart-HTTP-response-tp3275960p3277199.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2372150
Groovy as templating engine
Hello ! Had anyone used groovy as templating engine for creating HTML content ? I'm currently developing simple class extending WriterRepresentation to use groovy template engine. But maybe there's some external project have this functionality already implemented ? -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1272075
Spring integration questions
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 :) 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. 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 -- Regards, Evgeny Shepelyuk -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1257016
Re: JSON-Lib and Restlet
Hi +1 on this queistion. Some time ago personally i asked the same question. But we still don't have impelmentaiton :) Maybe you can produce it ? In my projects i've been usign StringRepresentaion and other 'hacks' to produce output using Json-lib and not internal Restlet JSON support. I am a new user of Restlet (and quite hapy with it, too), but I found that using the JSON classes that come with it do not work well enough for me. They do serialize basic classes, but do not work on things like HashMap, or really anything nested. I checked the main JSON website to see if there were newer versions of those classes (there are), but they still do not on nested objects. JSON-Lib does work well for this, so I switched to using that. However, when I want to create a representation out of the new (JSON-Lib) JSONObject, it does not accept the type. Representation representation = new JsonRepresentation(json); The warning is: Type safety: The expression of type JSONObject needs unchecked conversion to conform to MapObject,Object The reason is because json is of type net.sf.json.JSONObject instead of org.json.JSONObject. Ultimately, the best solution is for net.sf.json.JSONObject to extend org.json.JSONObject, as is done with other JSON libraries I have tested, but I seriously doubt this is going to happen. I can fix the issue by doing this instead: Representation representation = new JsonRepresentation(json.toString()); It just seems wasteful to have a usable JSONObject, convert it to a string and then pass it to a constructor. Has anyone successfully used JSON-Lib with Restlet without resorting to a hack like this? Also, is there a reason that Restlet only works with the basic org.json.* library? I would think that JSONObject should be handled in the way logging is handled: you can use the basic built-in logging in the JDK, or use something else, like Log4J. Can this also be done with org.json.* and other JSON implementations, too? I very much would appreciate any replies / suggestions. Mike V. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1014233 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=1018641
Re: Support for log4j?
Hello Aaron. Thnx for examples One small note. I will be very appreciated if u also post ur log4j config. For access logs only :) 24.07.08 в 19:36 Aaron Crow в своём письме писал(а): Hi Evgeny, Sure, I will. First though, I'd like to say that I don't consider it the ideal solution. In my case I just want the Restlet's access logs, and if I can emulate those myself with my own logging statements, I'll be happier. That being said, here's what I did to redirect Restlet's JDK logging to slf4j and then log4j: 1) Read http://www.slf4j.org/legacy.html 2) Added the following to my pom (**verbosity warning!**): dependency groupIdorg.slf4j/groupId artifactIdslf4j-api/artifactId version1.4.3/version exclusions !-- needed to avoid endless recursion, per: http://www.slf4j.org/legacy.html -- exclusion groupIdorg.slf4j/groupId artifactIdslf4j-jdk14/artifactId /exclusion /exclusions /dependency dependency groupIdorg.slf4j/groupId artifactIdslf4j-log4j12/artifactId version1.5.2/version /dependency dependency groupIdorg.slf4j/groupId artifactIdjul-to-slf4j/artifactId version1.5.2/version /dependency dependency groupIdlog4j/groupId artifactIdlog4j/artifactId version1.2.12/version /dependency 3) Added the following to my app's main method: // needs: import org.slf4j.bridge.SLF4JBridgeHandler; SLF4JBridgeHandler.install(); I then did what you normally do to configure log4j, and saw restlet's logging go to the targets I configured in my log4j.properties file. I do see the formatting is a little awkward, but at least it's down to one line. (I never made my peace w/jul's forced multi-line logging ;-) Hope this helps! Aaron - Original Message - From: Evgeny Shepelyuk [EMAIL PROTECTED] Newsgroups: gmane.comp.java.restlet To: discuss@restlet.tigris.org Sent: Thursday, July 24, 2008 12:19 AM Subject: Re: Support for log4j? Hello Aaron ! Would u be so kind to share how u set up slf4j to be used as a bridge from restlet to log4j ? -- Best Regards Evgeny K. Shepelyuk Evgeny Shepelyuk [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello Aaron ! Would u be so kind to share how u set up slf4j to be used as a bridge from restlet to log4j ? -- Best Regards Evgeny K. Shepelyuk -- Best Regards Evgeny K. Shepelyuk
Re: Support for log4j?
Hello Aaron ! Would u be so kind to share how u set up slf4j to be used as a bridge from restlet to log4j ? -- Best Regards Evgeny K. Shepelyuk
Re: Spring Security Integration
Hi Jerome Hi Evgeny, Regarding the Google Code project, this is fine if you want to maintain it as a standalone project. However, if your plan is to contribute source code back to the Restlet project, then we will likely run into copyright/license issues (see http://www.restlet.org/community/contribute). If this is your goal, I suggest that you reconsider the need for an external code repository. I'm not planning to maintain it separately of restlet project and hope once this code will be included into restlet sources :) Idea of creating Google Code project is having free version control system to track changes and provide convenient way of accesing and browsing current sources. So it's just temporary solution comfortable to me As we already did in the past, granting SVN access to external committers for extensions code if perfectly possible if there is an ongoing contribution. See more details here: http://wiki.restlet.org/docs_1.1/g1/13-restlet/50-restlet/51-restlet.html That pages has good information. Thnx ! Regarding authentication, there are other mechanisms than login/password verification, for example certificate verification, that suggest that overriding Guard at the authenticate() level is going to be more flexible. Ok thnx. I will put modifications recently. Best regards, Jerome -- Best Regards Evgeny K. Shepelyuk
Re: Spring Security Integration
Hello Jerome ! Thnx for your feedback. Let me answer some issues before i leave :) First of all i created a project at google code. So later i can add any commiters and work with them :) the URL is http://code.google.com/p/restlet-spring-security Hi Evgeny, After having a closer look at the code, here are some comments: - It would be nice to have a base SpringGuard class that would let you set all the properties of the Guard class (unless it is already the case) Both Guards implementations directly extend org.restlet.Guard so all setters available in org.restlet.Guards are available in created Guards - It is not obvious why you need both HttpSpringSecurityGuard and ServiceSpringSecurityGuard. The first one seems more flexible It is to illustrate that restlet can leverage all features of Spring Security. Initially Spring Security has 2 possibilities - web layer security with HTTP request intercepting - service layer security with AOP-based method invocation intercepting So i implemented 2 guards to illustrate that both approaches are possible with restlet. - The challenge scheme used should be configurable as well as the realm I gonna create new constructor to be more comfortable to use. Now those parameters are configurable via setter methods. - The authentication mechanism should configurable (overriding the authenticate() method instead of the higher-level checkSecret() method). It's not a problem. Just plz explain in few words what advantages it will bring ? - Couldn't the authorization mechanism be more flexible? Filtering on the URI path doesn't see flexible enough. Other request parameters could be useful. You might want to leverage something like: http://www.restlet.org/documentation/snapshot/api/org/restlet/util/Resolver.html#createResolver(org.restlet.data.Request,%20org.restlet.data.Response) Mmm as i were working with Spring Security i never need such functionality :)) But i gonna research such possibilities and start implementing them if possible. Don't think about this too hard, especially during your vaccations! :-) Best regards, Jerome Great time for everybody here and i will be back online shortly :) Thnx -- Best Regards Evgeny K. Shepelyuk
Re: Spring Security Integration
Hello Jerome ! Thnx for paying attention to this. The project doesnt provide any testing yet and probabaly code will be changed drastically after review :) I'm going on 2 week vacations since thursday and if you have some suggestions pzl tell me now so i can think on them. I hope that place will not haу internet so i be free of development issues for some time :) So will be glad to see any critics or suggestions after i come back Thnx! Hi Evgeny, Thanks for following up on this topic. I've just moved this RFE to Restlet 1.2. Let's give this feature a try before integrating it to the Spring extension. Best regards, Jerome -- Best Regards Evgeny K. Shepelyuk
Spring Security Integration
Hello ! I've attacheed recently my draft implementation of Spring Security integration with Restlet. You can download it here http://restlet.tigris.org/issues/show_bug.cgi?id=264. The main idea is using it only with Spring. Since restlet framework has very good support it's easy to run restlet application within Spring container. The 2nd option i wanna mention is 2 different approaches that can be used for integrating Spring Security with restlet. 1st one is using AOP. You need to annotate methods with certain annoations that will make calls to those methods authentificated/autorized agains Spring Security rules 2nd approach is more common URL based. Calls to certain URLs are intercepted and verified with Spring Security classes. The configuration of Spring Security is done in comon way and doesn't require any restlet specific settings. Plz try this and tell your opinions. Any feedback will be very appreciated.
Re: Restlet + OpenID
Usually when i use ACEGI i follow their recommendations :) http://www.acegisecurity.org/standalone.html And belive that using it alone without spring will be really painful :) Hi Evgeny, My understanding is that Spring Security is a 'standalone' API that doesn't require usage of Spring IoC. It probably has special support for that, but IMO it shouldn't be mandatory. Anyone has a more precise answer? Best regards, Jerome -Message d'origine- De : news [mailto:[EMAIL PROTECTED] De la part de Evgeny Shepelyuk Envoyé : mardi 22 avril 2008 18:30 À : discuss@restlet.tigris.org Objet : Re: Restlet + OpenID Hello ! Jerome - one question about this plans ? As i realize using Spring Security means that we have to to use Restlet with Spring anyway ? I mean one should setup configuratio nand run Spring container within restlet application ? -- Best Regards Evgeny K. Shepelyuk -- Best Regards Evgeny K. Shepelyuk
Re: Restlet + OpenID
Hello ! Jerome - one question about this plans ? As i realize using Spring Security means that we have to to use Restlet with Spring anyway ? I mean one should setup configuratio nand run Spring container within restlet application ? -- Best Regards Evgeny K. Shepelyuk
Re: how to serialize a Collection with JAXB?
Stephan Koops Stephan.Koops at web.de writes: Hello, can anybody tell me how to serialize a Collection of JAXB serializable Objects? I found nothing at Google. thank you Stephan With wrapper class that has a field containing your collection. But actually its not a question for restlet user mailing list :) import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @XmlRootElement public class Cards implements Serializable { private ListInteger cards = new ArrayListInteger(); @XmlElement(name = card) public ListInteger getCards() { return cards; } public void setCards(ListInteger cards) { this.cards = cards; } }
Re: MediaType constant for text/javascript
Hi Evgeny, There seems to be quite a confusion for Javascript media types. See this blog post: http://annevankesteren.nl/2005/02/javascript-mime-type Anyway, I've added a new TEXT_JAVASCRIPT constant in SVN trunk. Just keep in mind that the MetadataService uses APPLICATION_JAVASCRIPT by default for the .js extension. Best regards, Jerome Thnx a lot! The main need was to have this constant to expose it as Variant in my Resource class, cuz Prototype JS sends this content type as one of accepted.
Re: I had finished Using Ajax in Restlet draft,pls review
cleverpig greatcleverpig at gmail.com writes: I post this draft in wiki.restlet.org--Using AJAX in Restlet:http://wiki.restlet.org/docs_1.1/g1/43-restlet/52-restlet.html I will start this tutorial with a simply example-microblog,that's a text based micro blog for demo how to using AJAX in Restlet. Demo construction: * Web client: call background service via JSON protocol in full REST way(GET/PUT/POST/DELETE). * Server side: uses db4o to work as store service provider,and expose data in RESTful way. * Server handle process: Application dispatch request to Router,Router find corresponding reource,Resource handle request and return representation. Pls make review and point out drawback. This is an example of usign prototype without proxying methods via POST. 1. HTML html lang=en head script language=javascript type=text/javascript src=./prototype.js/ script script type=text/javascript language=JavaScript function callJSON() { new Ajax.Request('/ajax', { parameters: 'name=PUT', method: 'put', putBody: PUT BODY, onComplete: function (transport) { alert(transport.responseText); } }); new Ajax.Request('/ajax', { parameters: 'name=POST', method: 'post', onComplete: function (transport) { alert(transport.responseText); } }); new Ajax.Request('/ajax', { parameters: 'name=DELETE', method: 'delete', onComplete: function (transport) { alert(transport.responseText); } }); } /script /head body class=callingcards input type=button onclick=callJSON(); value=PRESSME /body /html 2. Server starting class import org.restlet.data.*; import org.restlet.*; public class Server { public static void main(String[] args) throws Exception { Component component = new Component(); component.getServers().add(Protocol.HTTP, 8182); component.getClients().add(Protocol.FILE); Application application = new Application(component.getContext ()) { @Override public Restlet createRoot() { Router router = new Router(getContext()); router.setFinderClass(PrototypeFinder.class); router.attach(, new Directory(getContext(), file:///C:/json-restlet)); router.attach(/ajax, AjaxResource.class); return router; } }; component.getDefaultHost().attach(, application); component.start(); } } 3. Custom Finder import org.restlet.Finder; import org.restlet.Context; import org.restlet.Handler; import org.restlet.data.Request; import org.restlet.data.Response; import org.restlet.data.Parameter; import org.restlet.data.Method; public class PrototypeFinder extends Finder { public PrototypeFinder(Context context, Class? extends Handler targetClass) { super(context, targetClass); } public void handle(Request request, Response response) { Parameter p = request.getEntityAsForm().getFirst(_method); request.setMethod(null != p ? Method.valueOf(p.getValue()) : request.getMethod()); super.handle(request, response); } } 4. Resource class import org.restlet.resource.*; import org.restlet.Context; import org.restlet.ext.json.JsonRepresentation; import org.restlet.data.Request; import org.restlet.data.Response; import org.restlet.data.MediaType; import org.json.JSONObject; import org.json.JSONArray; import java.util.Arrays; public class AjaxResource extends Resource { public AjaxResource(Context context, Request request, Response response) { super(context, request, response); getVariants().add(new Variant(MediaType.TEXT_HTML)); getVariants().add(new Variant(MediaType.TEXT_PLAIN)); } public Representation represent(Variant variant) throws ResourceException { return new StringRepresentation(some data, MediaType.TEXT_ALL); } public void acceptRepresentation(Representation representation) throws ResourceException { getResponse().setEntity(new StringRepresentation(PLAIN TEXT for POST, MediaType.TEXT_PLAIN)); } public void removeRepresentations() throws ResourceException { getResponse().setEntity(new StringRepresentation(PLAIN TEXT for DELETE, MediaType.TEXT_PLAIN)); } public void storeRepresentation(Representation representation) throws ResourceException { getResponse().setEntity(new StringRepresentation(PLAIN TEXT for PUT,
MediaType constant for text/javascript
Is there any big reason not to including this Content Type to MediaType class as a constant ?
Re: I had finished Using Ajax in Restlet draft,pls review
cleverpig greatcleverpig at gmail.com writes: I post this draft in wiki.restlet.org--Using AJAX in Restlet:http://wiki.restlet.org/docs_1.1/g1/43-restlet/52-restlet.html I will start this tutorial with a simply example-microblog,that's a text based micro blog for demo how to using AJAX in Restlet. Demo construction: * Web client: call background service via JSON protocol in full REST way(GET/PUT/POST/DELETE). * Server side: uses db4o to work as store service provider,and expose data in RESTful way. * Server handle process: Application dispatch request to Router,Router find corresponding reource,Resource handle request and return representation. Pls make review and point out drawback. Just take a look at this article. Think its better for prototyped AJAX http://dobrzanski.net/2007/04/22/using-put-and-delete-methods-in-ajax-requesta- with-prototypejs Also is there no posiblity to attach some kind of router that could dispatch requests to appropriate Resource method basing on value of 'method' paramater ?
Restlet 1.1m1 + Spring = circular dependency ?
Hello ! I'm developing test applicaiton with latest 1.1 snapshot and Spring 2.5. My objective is to make restlet application be started by spring container. So everythig is started when spring container starts by using init-method. After reading some docs about new spring extension i've created following config. ?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=myRestlet class=MyRestlet/ bean id=server class=org.restlet.ext.spring.SpringServer constructor-arg value=http/ constructor-arg value=8182/ /bean bean class=org.restlet.ext.spring.SpringRouter constructor-arg ref=application/ property name=attachments map entry key=/user/{userId} value-ref=myRestlet/ /map /property /bean bean id=application class=org.restlet.ext.spring.SpringApplication constructor-arg ref=component/ /bean bean id=component class=org.restlet.ext.spring.SpringComponent init-method=start property name=server ref=server/ property name=defaultTarget ref=application/ /bean /beans Code for creating/running Spring container. public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(META-INF/spring.xml); ctx.registerShutdownHook(); ctx.refresh(); } And after runnig this i got Spring error. Sorry for long stacktrace :)) And yes im realizing that there's circular dependency. Am i wrong with my config. Could anyone help me ro reslove this issues. Thnx in advance. 2007-12-24 19:33:55.808::INFO: Logging to STDERR via org.mortbay.log.StdErrLog Exception in thread main org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.restlet.ext.spring.SpringRouter#0' defined in class path resource [META-INF/spring.xml]: Cannot resolve reference to bean 'application' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'application' defined in class path resource [META-INF/spring.xml]: Cannot resolve reference to bean 'component' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'component' defined in class path resource [META-INF/spring.xml]: Cannot resolve reference to bean 'application' while setting bean property 'defaultTarget'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'application': Requested bean is currently in creation: Is there an unresolvable circular reference? at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:274) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:447) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:957) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:869) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:514) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170) at
Re: Access log configuration
Hi Evgeny, Actually, you have to explicitly set it with like this for example: getLogService().setLoggerName(com.noelios.web.WebComponent.www); I will make a change to have a default value. Best regards, Jerome What name i should use for configiring my logger ? Thnx in advance. -- Best Regards Evgeny K. Shepelyuk Hello Jerome! Thnx for halping. After some shaman dancing access logging started to work. Will be fine if you can put smth more into tutorial about this issue :) At least the configuration of logger name and logging properties example. -- Best Regards Evgeny K. Shepelyuk
Re: Access log configuration
04.08.07 в 16:10 Jerome Louvel в своём письме писал(а): Hi Evgeny, There is indeed a hole here. The NRE provides a dedicated log handler and sends all the access log messages to the logger name of your Component class, with a www at the end (ex: com.mycompany.rest.MyComponent.www). I've attached a working example used by the Restlet.org web site. I will also update the docs on the topic. See new issue: http://restlet.tigris.org/issues/show_bug.cgi?id=343 Best regards, Jerome Hi Jerome ! Thnx for answer but the issue is still unresolved for me. What is your Component class ?? I'm not extending the component class in my application. I'm doing smth like code below in main() method of my service. Component component = new Component(); Application application = new Application(component.getContext()) { public Restlet createRoot() { Router router = new Router(getContext()); . return router; } ; application.getMetadataService().setDefaultLanguage(Language.ENGLISH); Server server = new Server(Protocol.HTTP, 8182, application); component.getServers().add(server); component.getDefaultHost().attach(, application); component.start(); What name i should use for configiring my logger ? Thnx in advance. -- Best Regards Evgeny K. Shepelyuk
Access log configuration
Hello ! Is there any step-by-step manual for configurations of access log for restlet based application. All i need so to make restlet to store access logs into certain file. I've tried to found smth in tutorial section #7 but actually it's not so useful for me :( Will be very appreciate for any help on this issue. -- Best Regards Evgeny K. Shepelyuk
Accepted language question
Hello ! I have REST service that is intended to return representaion of resources in different languages. I want it to be based on client's accepted language HTTP headers. And if client sends empty language list or list containing only unsupported languages the representaion must tbe based on default language. In my class extending org.restlet.resource.Resource I've written smth like String language = Language.ENGLISH.getName(); if (null == language) { /* obtain list of languages supported by system*/ CollectionString languages = SystemUtils.getAvailableSystemLanguages(); for (PreferenceLanguage preference : getRequest().getClientInfo().getAcceptedLanguages()) { if (languages.contains(preference.getMetadata().getName())) { language = preference.getMetadata().getName(); break; } } } But as for me this approach is not so nice as could be :) So i just wanted to ask is there're more convenient approaches for solving this problem ? -- Best Regards Evgeny K. Shepelyuk
Re: Accepted language question
Another issue i've discovered about accepted languages is following In the com.noelios.restlet.Engine class in getPreferredVariant(ClientInfo, ListVariant, Language) the quality of ALL language(*) is 0.004, but for default language of application quality is 0.001. As i understood this will cause system to get wrong variant.Because if i have variants with language equals to default they won't be choosen. For example i have 3 variants exposed by resource. All variants have same media type but different languages: en, es, pt.Default application language is en If in my browser i have fr as preferences. So final list of preferences will be smth like: {fr;1.0,en;0.001,*;0.004}. And i expect that if fr is not in list of languages the variant with en will be choosen as preffered variant. But in reality in takes 2nd variant from list (with es). Could someone clarify this issue plz.
Re: client perfomance question
Hi Jerome! Ok so if i understood correctly. I can use Client instance inside my applications (not restlet meaning of application, but just external app that contacts my RESTful service) as singleton ? I can create on instance of clietn, set my settings to it and share it to all my JSP/classes that needs to contact my RESTFul service.
Re: client perfomance question
27.06.07 в 22:03 Jerome Louvel в своём письме писал(а): Hello Jerome. The answer about pooling is clear, thxn. But this is not so much clear for me :) Inside a Restlet Application, the best is to leverage the Context.dispatcher mechanism which allows the sharing of client connectors between several applications. If you have some possibilities and free time could you describe this more detailly. Thnx in advance. Hi Evgeny, The Client instance are already thread-safe and reusable, no need to recreate them or to pool them! Inside a Restlet Application, the best is to leverage the Context.dispatcher mechanism which allows the sharing of client connectors between several applications. Best regards, Jerome -Message d'origine- De : news [mailto:[EMAIL PROTECTED] De la part de Evgeny Shepelyuk Envoyé : mercredi 27 juin 2007 14:19 À : discuss@restlet.tigris.org Objet : client perfomance question Hello! In my application i'm actively using restlet clients for communicating with my service(also restlet-based). So does it make sense to pool client instances and not create them on any request. -- Best Regards Evgeny K. Shepelyuk -- Best Regards Evgeny K. Shepelyuk
Re: client perfomance question
27.06.07 в 22:03 Jerome Louvel в своём письме писал(а): Hi Evgeny, The Client instance are already thread-safe and reusable, no need to recreate them or to pool them! Inside a Restlet Application, the best is to leverage the Context.dispatcher mechanism which allows the sharing of client connectors between several applications. Best regards, Jerome -Message d'origine- De : news [mailto:[EMAIL PROTECTED] De la part de Evgeny Shepelyuk Envoyé : mercredi 27 juin 2007 14:19 À : discuss@restlet.tigris.org Objet : client perfomance question Hello! In my application i'm actively using restlet clients for communicating with my service(also restlet-based). So does it make sense to pool client instances and not create them on any request. -- Best Regards Evgeny K. Shepelyuk Hello Jerome. Maybe i will try to describe my situation more detailly to explain what issues i'm facing. I have restlet-based serivce that exposes some XML documents. It's perfomance is tested with ab and satisfies my needs :) At client side i have some JSP that are using my service. In JSP code i'm writing smth like. Client client = new Client(Protocol.HTTP); client.getContext() Response resp = client.get(..); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(resp.getEntity().getStream(), UTF-8); And as a result i'm having huge delays for getting the XML text. I've discovered it with tests that measures delays of ccertain operation. My client uses java.net.HttpURLConnection-based connector class. Then i decided to try use simple URLConnection approach. URLConnection con = new URL().openConnection(); ((HttpURLConnection)con).setRequestMethod(GET); con.setDoOutput(true); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); XmlPullParser xpp = factory.newPullParser(); xpp.setInput(con.getInputStream(), UTF-8); And according to timing delays for getting XML reduced 4-5 times. So i'm not thinking that restlet client is workign so slow and wanted someone to advice if i'm usign Client instances incorrectly. Thnx. -- Best Regards Evgeny K. Shepelyuk
Re: Usage ox JaxbRepresentation in restlet 1.1 beta
Hi Jerome, Thnx a lot for quick improvement :) Hi Evgeny, Indeed, I forgot this question :) There is now a formattedOutput property on the JaxbRepresentation class in SVN. Set to false by default. Best regards, Jerome -Message d'origine- De : news [mailto:[EMAIL PROTECTED] De la part de Evgeny Shepelyuk Envoyé : mardi 26 juin 2007 11:38 À : discuss@restlet.tigris.org Objet : Re: Usage ox JaxbRepresentation in restlet 1.1 beta Thnx Jerome ! Working ok with my basic tests. But what about my second question :). Another issue is that JaxbRepresentaion is always procucing formatted output. But frequently it's not needed because XML is produced only for automatic parsing and formatted output increases its size. Can this be made in some configurable way ? -- Best Regards Evgeny K. Shepelyuk -- Best Regards Evgeny K. Shepelyuk
client perfomance question
Hello! In my application i'm actively using restlet clients for communicating with my service(also restlet-based). So does it make sense to pool client instances and not create them on any request. -- Best Regards Evgeny K. Shepelyuk
Re: Usage ox JaxbRepresentation in restlet 1.1 beta
Thnx Jerome ! Working ok with my basic tests. But what about my second question :). Another issue is that JaxbRepresentaion is always procucing formatted output. But frequently it's not needed because XML is produced only for automatic parsing and formatted output increases its size. Can this be made in some configurable way ? -- Best Regards Evgeny K. Shepelyuk
Re: Usage ox JaxbRepresentation in restlet 1.1 beta
21.06.07 в 23:25 Jerome Louvel в своём письме писал(а): Hi Evgeny, Could you send us the stack trace that you get? Note that the JaxbRepresentation hasn't been tested seriously yet. Best regards, Jerome 22.06.2007 10:10:30 org.restlet.ext.jaxb.JaxbRepresentation$Marshaller$1 initialValue WARNING: Problem creating Marshaller java.lang.NullPointerException at org.restlet.ext.jaxb.JaxbRepresentation$Marshaller$1.initialValue(JaxbRepresentation.java:326) at org.restlet.ext.jaxb.JaxbRepresentation$Marshaller$1.initialValue(JaxbRepresentation.java:322) at java.lang.ThreadLocal$ThreadLocalMap.getAfterMiss(ThreadLocal.java:374) at java.lang.ThreadLocal$ThreadLocalMap.get(ThreadLocal.java:347) at java.lang.ThreadLocal$ThreadLocalMap.access$000(ThreadLocal.java:225) at java.lang.ThreadLocal.get(ThreadLocal.java:127) at org.restlet.ext.jaxb.JaxbRepresentation$Marshaller.getMarshaller(JaxbRepresentation.java:416) at org.restlet.ext.jaxb.JaxbRepresentation$Marshaller.marshal(JaxbRepresentation.java:375) at org.restlet.ext.jaxb.JaxbRepresentation.write(JaxbRepresentation.java:299) at org.restlet.resource.StreamRepresentation.write(StreamRepresentation.java:58) at com.noelios.restlet.ext.grizzly.GrizzlyServerCall.writeResponseBody(GrizzlyServerCall.java:124) at com.noelios.restlet.http.HttpServerCall.sendResponse(HttpServerCall.java:316) at com.noelios.restlet.http.HttpServerConverter.commit(HttpServerConverter.java:108) at com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:95) at com.noelios.restlet.ext.grizzly.HttpParserFilter.execute(HttpParserFilter.java:77) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:77) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:56) at com.sun.grizzly.Context.call(Context.java:249) at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:132) 22.06.2007 10:10:30 org.restlet.ext.jaxb.JaxbRepresentation$Marshaller getMarshaller WARNING: Unable to locate marshaller. 22.06.2007 10:10:30 org.restlet.ext.jaxb.JaxbRepresentation$Marshaller$1 initialValue WARNING: Problem creating Marshaller java.lang.NullPointerException at org.restlet.ext.jaxb.JaxbRepresentation$Marshaller$1.initialValue(JaxbRepresentation.java:326) at org.restlet.ext.jaxb.JaxbRepresentation$Marshaller$1.initialValue(JaxbRepresentation.java:322) at java.lang.ThreadLocal$ThreadLocalMap.getAfterMiss(ThreadLocal.java:374) at java.lang.ThreadLocal$ThreadLocalMap.get(ThreadLocal.java:347) at java.lang.ThreadLocal$ThreadLocalMap.access$000(ThreadLocal.java:225) at java.lang.ThreadLocal.get(ThreadLocal.java:127) at org.restlet.ext.jaxb.JaxbRepresentation$Marshaller.getMarshaller(JaxbRepresentation.java:416) at org.restlet.ext.jaxb.JaxbRepresentation$Marshaller.marshal(JaxbRepresentation.java:375) at org.restlet.ext.jaxb.JaxbRepresentation.write(JaxbRepresentation.java:303) at org.restlet.resource.StreamRepresentation.write(StreamRepresentation.java:58) at com.noelios.restlet.ext.grizzly.GrizzlyServerCall.writeResponseBody(GrizzlyServerCall.java:124) at com.noelios.restlet.http.HttpServerCall.sendResponse(HttpServerCall.java:316) at com.noelios.restlet.http.HttpServerConverter.commit(HttpServerConverter.java:108) at com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:95) at com.noelios.restlet.ext.grizzly.HttpParserFilter.execute(HttpParserFilter.java:77) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:77) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:56) at com.sun.grizzly.Context.call(Context.java:249) at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:132) 22.06.2007 10:10:30 org.restlet.ext.jaxb.JaxbRepresentation$Marshaller getMarshaller WARNING: Unable to locate marshaller. 22.06.2007 10:10:30 com.noelios.restlet.http.HttpServerConverter commit INFO: Exception intercepted java.io.IOException: Unable to locate marshaller. at org.restlet.ext.jaxb.JaxbRepresentation.write(JaxbRepresentation.java:306) at org.restlet.resource.StreamRepresentation.write(StreamRepresentation.java:58) at com.noelios.restlet.ext.grizzly.GrizzlyServerCall.writeResponseBody(GrizzlyServerCall.java:124) at com.noelios.restlet.http.HttpServerCall.sendResponse(HttpServerCall.java:316) at com.noelios.restlet.http.HttpServerConverter.commit(HttpServerConverter.java:108) at com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:95) at com.noelios.restlet.ext.grizzly.HttpParserFilter.execute(HttpParserFilter.java:77) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:77) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:56) at
Usage ox JaxbRepresentation in restlet 1.1 beta
Hello Please can someone give the examples of usign the JaxbRepresentation. I'm using following code. new Server(Protocol.HTTP, 8182, new Restlet() { @Override public void handle(Request request, Response response) { response.setEntity(new JaxbRepresentation(MediaType.TEXT_PLAIN, mypackage, new MyObject())); } }).start(); and got exception when getting JAXBContext from map of contexts. Seems i shoud initize that map in some way. But only place where smth is pun into contexts map is getSource() method in JaxbRepresentation @Override public Source getSource() throws IOException { try { return new JAXBSource(getContext(), getObject()); } catch (JAXBException e) { throw new IOException( JAXBException while creating the JAXBSource: + e.getMessage()); } } So should i call this manually ? Or most probably i'm missing some point in this. Another issue is that JaxbRepresentaion is always procucing formatted output. But frequently it's not needed because XML is produced only for automatic parsing and formatted output increases its size. Can this be made in some configurable way ? -- Best Regards Evgeny K. Shepelyuk
XML representaion of resource (best practice)
Hi ! We're developing app using restlet framework and we have a task to return XML data to client when certain resource is accessed. Currently we're doing following public class MyResource extends Resource { public MyResource(Context context, Request request, Response response) { super(context, request, response); getVariants().add(new Variant(MediaType.TEXT_XML)); } public Representation getRepresentation(Variant variant) { Representation result = null; CollectionMyBean beans = new MyBeanManager().getBeans(); StringWriter sw = new StringWriter(); sw.write(root\n); try { Marshaller m = JAXBContext.newInstance(MyBean.class).createMarshaller(); m.setProperty(Marshaller.JAXB_FRAGMENT, true); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); for (MyBean bean : beans) { m.marshal(bean, sw); } } catch (JAXBException e) { e.printStackTrace(System.err); } sw.write(\n/root\n); return new StringRepresentation(sw.toString(), MediaType.TEXT_XML, null, CharacterSet.UTF_8); } } Is it a best practice to put XML via JAXB to string and return it as StringRepresentation. Or maybe there're more convenient way to do such task. Thnx
Re: test111
Evgeny Shepelyuk eshepelyuk at gmail.com writes: sorry plz delete this thread. stupid test results :(
test111
-- Best Regards Evgeny K. Shepelyuk
Restlet lifecycle question
Hello Sorry maybe question is obvious but was unable to find clear answer in tutorials. This code from tutorial // Creating a minimal Restlet returning Hello World Restlet restlet = new Restlet() { @Override public void handle(Request request, Response response) { response.setEntity(Hello World!, MediaType.TEXT_PLAIN); } }; // Create the HTTP server and listen on port 8182 new Server(Protocol.HTTP, 8182, restlet).start(); The instance of of anonymous class is created per each client request ? Or it is the same for all restlet server created ? Thnx
Re: Restlet lifecycle question
Jerome Louvel contact at noelios.com writes: Hi Evgeny, In this case and for all other Restlet instances, the same instance is reused across requests and even multi-threaded. No worry about performance. Best regards, Jerome Hello, So can you describe in which cases i´ll get different instances of restlet(or sublclasses) serving incomng requests. First i really worry about perfomance in this case :) Second can be synchronization issues if i use some temporary instance variables. Thnx