Hi John,
thanks for the sample code. I think that you can have a single Router
among all applications, under the restriction that each of them expose a
set of distinct URI templates.
A consequence of this choice is that the Router can have a context
attribute distinct to the one of the current application. If you want to
customize each application's context, this can be a problem.
Best regards,
Thierry Boileau
> I assume that some code will help you to see want i want to do :
>
> In my main class :
>
> ...
> component.getDefaultHost().attach(new MainApplication());
> component.getDefaultHost().attach(new StatsApplication());
> ...
>
> component.start();
>
> In MainApplication :
>
> class MainApplication extends org.restlet.Application {
>
>
> public synchronized Restlet createInboundRoot() {
> Router router = new Router(getContext());
> router.attach("/someresource",SomeResource.class);
> }
> }
>
> In StatsApplication :
>
> class StatsApplication extends org.restlet.Application {
>
>
> public synchronized Restlet createInboundRoot() {
> Router router = new Router(getContext());
> router.attach("/stats",StatsResource.class);
> }
> }
>
>
> What i want is to be able to access to those url :
>
> http://host/someresource -> route to the resource named "SomeResource"
> attached to the router in MainApplication
> http://host/stats -> route to the resource named "StatsResource"
> attached to the router in StatsApplication
>
> Thanks for your help.
>
> Le 3 févr. 10 à 12:30, Thierry Boileau a écrit :
>
>
>> Hi,
>>
>> If I understand well, you want one request to be handled by a set of
>> resources, each of them declared in distinct application.
>> In this case, I just wonder which resource will send the response back
>> to the client.
>>
>> Best regards,
>> THierry Boileau
>>
>>
>>> Thanks for your quick answer.
>>>
>>> As a workaround, can i share a same router instance among multiple
>>> applications ?
>>>
>>> The basic idea is to have multiple standalone applications that can
>>> interact with the complete uri.
>>>
>>>
>>>
>>>> Hello john,
>>>>
>>>> I'm afraid this is not possible. Instances of VirtualHost and Router
>>>> classes (such as the component's default host) delegate requests to
>>>> handlers according to the current request's URI. Thus, your
>>>> requirement
>>>> can't be addressed this way. Is it possible for you to have only
>>>> application?
>>>>
>>>> Best regards,
>>>> Thierry Boileau
>>>>
>>>>
>>>>
>>>>> Hello,
>>>>>
>>>>> I am using Restlet 2.0
>>>>> I am trying to associate two application to the default host with
>>>>> the same URI pattern :
>>>>>
>>>>> getDefaultHost().attach("",new FirstApplication()));
>>>>> getDefaultHost().attach("",new SecondApplication()));
>>>>>
>>>>> Each application return a Router in the overriden
>>>>> createInboundRoot method.
>>>>>
>>>>> When i launch the server (using component.start()).
>>>>> Only the first application is working. URIs from the second
>>>>> applications are not matched ...
>>>>>
>>>>> How to have multiple application sharing the same basePath ?
>>>>>
>>>>> ------------------------------------------------------
>>>>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2444228
>>>>>
>>>>>
>>>>>
>>>>>
>>> ------------------------------------------------------
>>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2444399
>>>
>>>
>>>
>> ------------------------------------------------------
>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2444423
>>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2444446
>
>
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2444466