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
Solved

URLStreamHandler Help

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 38
MySqlDump not dumping triggers 1 43
runtime exception 2 41
Desingning Refactoring existing code 2 26
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.

809 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