views:

92

answers:

2

I'm building a framework (OSGi-like) where other parties can program a bundle for. But I want my framework to manage the QoS of the connection-requests that the other parties will do.

The easy solution would be to ask them to use (or enforce them to use - although I don't know how) a specific ConnectionRequest bundle of the framework. The problem with this approach is that they wouldn't be able to use any of their own preferred libraries that is counting on the standard Java libraries to make a connection(request).

So I wondered if there is a way in Java to catch all the requested connections, so I can add some code about my QoS handling, before its is sent of to the underlaying layer?

A: 

I hope I understand your problem correctly. What you can do is to use Java 2 Security and restrict the access to the java.net.* (or any other library), and then provide a wrapper service that provides the functionality and implements your QoS schemes to other services. These other services, though, must use your service interface and cannot use java.net.* directly anymore.

akr
You do understand the problem, but this is what I hope to avoid. Since it cripples a developers freedom to program for my framework...
Falx
A: 

You could use the ProxySelector class for 'intercepting' all connection requests, but i don't know if the api is relevant for your usage.

http://java.sun.com/j2se/1.5.0/docs/api/java/net/ProxySelector.html

Thierry