Solved

URLStreamHandler Help

Posted on 1997-04-02
2
531 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping1 challenge 7 73
groovy example issue 10 90
What is the latest versions eclipse neon 2 139
what is a "java.lang.System Property"   ? 20 57
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now