Bug 241210 - Should be possible to filter HttpService instance
Summary: Should be possible to filter HttpService instance
Status: ASSIGNED
Alias: None
Product: RAP
Classification: RT
Component: Workbench (show other bugs)
Version: 1.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 377414
Blocks:
  Show dependency tree
 
Reported: 2008-07-17 05:14 EDT by Gunnar Wagenknecht CLA
Modified: 2012-11-06 17:08 EST (History)
4 users (show)

See Also:


Attachments
Patch to add HttpServiceSelector to branding extension point (10.12 KB, patch)
2008-07-17 05:14 EDT, Gunnar Wagenknecht CLA
no flags Details | Diff
Patch for ResourceManagerFactory to register with all available HttpService instances (12.08 KB, patch)
2008-07-18 04:24 EDT, Gunnar Wagenknecht CLA
no flags Details | Diff
Patch for ResourceManagerFactory to register with all available HttpService instances (6.38 KB, patch)
2008-07-18 04:27 EDT, Gunnar Wagenknecht CLA
no flags Details | Diff
Patch for org.eclipse.rap.ui.workbench (29.06 KB, patch)
2008-10-16 10:49 EDT, Gunnar Wagenknecht CLA
no flags Details | Diff
HttpService selector patch (38.28 KB, patch)
2011-02-08 04:43 EST, Gunnar Wagenknecht CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gunnar Wagenknecht CLA 2008-07-17 05:14:55 EDT
Created attachment 107710 [details]
Patch to add HttpServiceSelector to branding extension point

Currently RAP registers with all available HttpService instances. However, it would be nice if someone can filter the service instance. For example, a secure admin application should only bind to a secure HttpService instance listening on a different (non-public) port.

The implementation in the attached patch proposes to add this via the branding extension point.
Comment 1 Gunnar Wagenknecht CLA 2008-07-17 05:15:58 EDT
Note, this mimics the feature available in the Euqinox HTTP registry extension points.
Comment 2 Gunnar Wagenknecht CLA 2008-07-18 04:24:14 EDT
Created attachment 107802 [details]
Patch for ResourceManagerFactory to register with all available HttpService instances

This patch adds support for ResourceManagerFactory to register with all available HttpService instances. Ideally, it would be great to limit the registration to only the service instance an application is registered with. However, I haven't spent enough time to investigate this approach.
Comment 3 Gunnar Wagenknecht CLA 2008-07-18 04:27:49 EDT
Created attachment 107803 [details]
Patch for ResourceManagerFactory to register with all available HttpService instances

updated patch to remove formatting changes
Comment 4 Gunnar Wagenknecht CLA 2008-10-16 10:49:17 EDT
Created attachment 115256 [details]
Patch for org.eclipse.rap.ui.workbench

I've updated the patch to the current head.
Comment 5 Gunnar Wagenknecht CLA 2009-08-18 08:01:16 EDT
It seems that this request does not have enough priorities to be accepted within RAP. My question now is, how should the right solution look like?

Ideally, I'd be happy to disable the default HttpService registration completely and just have a RAP Servlet that I register myself with any HttpService I like. The RAP Servlet could allow to only start a specific application.

I manged to register my own instance of RequestHandler with any HttpService instance of my choice. However, the interaction with resources (ResourceManager) is still problematic. The current OSGi implementation only works with one HttpService. It seems that some rework is necessary to refactor the ResourceManager to support multiple independent applications.

Are there any plans to rework RAP (maybe as part of e4)?
Comment 6 Benjamin Muskalla CLA 2009-08-20 10:29:30 EDT
Gunnar, we'll take a look at this these days. Sorry for the long delay. As you already mentioned, it's not one of the high prio items on our list but we see the need to act in this case.
Comment 7 Gunnar Wagenknecht CLA 2009-08-21 03:23:51 EDT
(In reply to comment #6)
> Gunnar, we'll take a look at this these days. Sorry for the long delay. As you
> already mentioned, it's not one of the high prio items on our list but we see
> the need to act in this case.

I'd be happy to work with you on this issue. As I mentioned, there are several possibilities. We just need to discuss what the best option might be...
Comment 8 Ralf Sternberg CLA 2010-11-15 04:50:15 EST
Gunnar, sorry for delaying this issue. I've set it to P2 to remember to address it for the upcoming release. Will look at your patches and come back to you for discussion.
Comment 9 Gunnar Wagenknecht CLA 2011-01-31 02:55:20 EST
Ralf, I've opend bug 335811 which explains our dilemma. We'd like to run our RAP based Admin UI on one port and also provide a HttpService for downstream consumers on another (configurable) port (eg. 8080). We'd like our RAP admin UI to be available on one port only. This port should also not expose other RAP applications except ours.
Comment 10 Ralf Sternberg CLA 2011-02-05 16:25:54 EST
Hi Gunnar, does this patch work for you already? Or do you see other problems that also keep you from using RAP in this scenario right now?

And, do you know of any other project that allow specify service filters in an extension point? If we decide to make it a sub-element for the branding EP, it would be good to follow an established pattern if there is one...
Comment 11 Gunnar Wagenknecht CLA 2011-02-08 04:43:33 EST
Created attachment 188501 [details]
HttpService selector patch

That's the patch that I'm using currently. It should apply against today's HEAD cleanly.

The concept of the HttpService selector is borrowed from the Equinox HttpService Registry. If you look at the filters/resources/servlets extension points they all use this context in order to limit the registration to a specific service.
Comment 12 Gunnar Wagenknecht CLA 2011-02-08 04:46:04 EST
(In reply to comment #11)
> Created attachment 188501 [details]
> HttpService selector patch

The patch also supports a "default" filter. By setting a system property (eg. in config.ini) it's possible to prevent registration of RAP applications with specific (eg. "internal") HttpService instances. This could be used to prevent registrations of RAP applications with the Eclipse help system HttpService.
Comment 13 Gunnar Wagenknecht CLA 2011-02-19 04:22:29 EST
After some further discussion with Ralf it looks like there are some low hanging fruits as well as some necessary major refactorings long-term in order to support multiple RAP instances (RWT engines) within a single OSGi framework with many HttpService instance.

Some (random) notes from the discussion below:
- Ralf opened bug 337100 for resource manager simplifications (low hanging fruit)
- allowing multiple RWT engines is the best way to go but likely too risky for 1.4 (given we are past M5 already)
- this patch works with a single RWT engine
- the filter API introduced in the patch should be internal/provisional
(it's likely to change with multiple RWT engines because this affects other areas)
Comment 14 Ralf Sternberg CLA 2011-03-08 10:23:49 EST
Gunnar, I implemented experimental and unofficial support for filtering HttpServices. With the resolution of bug 337787, it should now be possible to run a separate RWT engine for every HttpService. However, I don't have the environment to evaluate this at the moment. Could you give this implementation a spin with Gyrex?

I'd also be interested in a simple setup with two HttpServices. If you could come up with a snippet or a bundle that starts two services programmatically, that would be interesting.

For the implementation, I mostly followed your approach of adding an additional element to a branding extension. Unlike your patch, I kept the name "filter" intead of "selector" to avoid having two different names for the same concept. I also left out the string parameter to keep the solution simple. So for now, your can only use a class that implements Filter.
Comment 15 Gunnar Wagenknecht CLA 2011-03-12 08:46:18 EST
(In reply to comment #14)
> Gunnar, I implemented experimental and unofficial support for filtering
> HttpServices. With the resolution of bug 337787, it should now be possible to
> run a separate RWT engine for every HttpService. However, I don't have the
> environment to evaluate this at the moment. Could you give this implementation
> a spin with Gyrex?

Works like a charm.

> I'd also be interested in a simple setup with two HttpServices. If you could
> come up with a snippet or a bundle that starts two services programmatically,
> that would be interesting.

You can have a look at the activator of our admin bundle which starts an embedded Jetty HttpService.
http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.gyrex/admin/bundles/org.eclipse.gyrex.admin.ui/src/org/eclipse/gyrex/admin/ui/internal/AdminUiActivator.java?view=markup&revision=1.3&root=Technology_Project

The relevant API is org.eclipse.equinox.http.jetty.JettyConfigurator.

----
final Dictionary<String, Object> settings = new Hashtable<String, Object>(3);
settings.put(JettyConstants.OTHER_INFO, "my-custom-identifier-for-the-filter");
settings.put(JettyConstants.HTTP_ENABLED, Boolean.TRUE);
settings.put(JettyConstants.HTTP_PORT, 1234);

JettyConfigurator.startServer("my-server", settings);
----

Later on you can create a filter like this:
"(&(objectClass=org.osgi.service.http.HttpService)(other.info=my-custom-identifier-for-the-filter))"
Comment 16 Ralf Sternberg CLA 2011-03-14 10:00:04 EDT
Thanks for the snippet! I could successfully start a second Jetty / HTTP Service. That's very helpful for testing.

Since running multiple RWT engines is still a new feature, we should give it some time to stabilize before we open up API. I'd suggest that we head for an API for filters in the next release.
Comment 17 Gunnar Wagenknecht CLA 2011-03-14 12:17:18 EDT
One thing I noticed is the missing option to select a default service. Once you have multiple instances it might be desirable to bind non-filtered RAP extensions to a "default" service.
Comment 18 Ralf Sternberg CLA 2011-05-14 16:28:59 EDT
We'll have to come up with a public API in 1.5.
Comment 19 Gunnar Wagenknecht CLA 2012-05-14 03:32:32 EDT
FYI. Thanks to the new Application API in RAP 1.5 M7 I no longer require this. Thus, I'll remove bug 335811 from the "blocks" list. However, I think it's still worthwhile to allow applications to not be registered on all available HttpService instances.
Comment 20 Ralf Sternberg CLA 2012-05-15 15:57:04 EDT
Thanks for letting us know, Gunnar! I'll keep the solution in place now anyway because we're already approaching RCs and the code does not hurt. Since it's hidden API, we might remove it later.
Comment 21 Ralf Sternberg CLA 2012-05-15 16:04:43 EDT
Since we can only have one workbench instance at a time, any solution for bug 377414 that allows to restrict the workbench to start at a certain port or HttpService would also resolve this bug.