?
Solved

URLStreamHandler Help

Posted on 1997-04-02
2
Medium Priority
?
539 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
JWBito earned 300 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

801 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