开发者

How can I catch connection requests in my framework?

开发者 https://www.devze.com 2022-12-20 07:59 出处:网络
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 othe开发者_高级运维r parties will do.

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 othe开发者_高级运维r 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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号