Solved

URLStreamHandler Help

Posted on 1997-04-02
2
532 Views
Last Modified: 2006-11-17
I'm trying to create a custom URLStreamHandlerFactory, but also I need to change this factory at times...specifically
in individual threads.

The API reference for JDK 1.1 says the URL.SetURLStreamHandlerFactory function can only
be called once in an application.  Does this apply
to individual threads?  Or does it really mean once
in an application?  Are there any workarounds?
0
Comment
Question by:heech
2 Comments
 
LVL 1

Accepted Solution

by:
JWBito earned 100 total points
ID: 1219399
I think the decision to make the factory a write-once variable was based on the desire to make the interface as lightweight as possible.  Changing the factory on the fly would require additional synchronization and hence more processing time.

Perhaps you want to define a class (implementing URLStreamHandlerFactory) that allows a thread to register itself (with its own map scheme-to-StreamHandler).  Then when createURLStreamHandler is called on your interface, you can find what driver to use based on the thread that you're executing on.

I suppose I could elaborate if this is going in the right direction.
0
 

Author Comment

by:heech
ID: 1219400
Hmm... There is a problem...

Apparently URLStreamHandlerFactory is only called once
for each specific protocol...

My solution, I think, will be to create a URLStreamHandler,
(as well as a URLStreamHandlerFactory) which _is_ called by
different threads, and will be able to return the URLConenction
as necessary.. this takes out some of the functionality
I had hoped for..but should still be acceptable.

0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question