Interface Plurl
- All Known Implementing Classes:
- PlurlImpl
URL.setURLStreamHandlerFactory(URLStreamHandlerFactory) and
 URLConnection.setContentHandlerFactory(ContentHandlerFactory). Plurl
 factories may be added and removed using the add and remove methods or using
 the plurl protocol.
 
 
 The plurl protocol allows factories to be added even
 if the installed plurl implementation is not using the same
 org.eclipse.equinox.plurl package as the factories being registered. A plurl
 implementation must handle this case by reflecting on the plurl factories
 that are added. A plurl factory can be added and removed with the plurl
 protocol like this:
 
 
 PlurlStreamHandlerFactory myStreamFactory = getStreamFactory();
 PlurlContentHandlerFactory myContentFactory = getContentFactory();
 
 ((Consumer<URLStreamHandlerFactory>) ("plurl://op/addURLStreamHandlerFactory").getContent()).accept(myStreamFactory);
 ((Consumer<ContentHandlerFactory>) ("plurl://op/addContentHandlerFactory").getContent()).accept(myContentFactory);
 ((Consumer<URLStreamHandlerFactory>) ("plurl://op/removeURLStreamHandlerFactory").getContent())
                .accept(myStreamFactory);
 ((Consumer<ContentHandlerFactory>) ("plurl://op/removeContentHandlerFactory").getContent()).accept(myContentFactory);
 
 
 The content provided by the plurl protocol is of type Consumer which
 can take either an URLStreamHandlerFactory or a
 ContentHandlerFactory depending on the operation.
 
 
 A plurl implementation delegates to the added PlurlFactory objects.
 To select which PlurlFactory to delegate the
 PlurlFactory.shouldHandle(Class) method is used.
 
 If only one factory has been added to plurl then that PlurlFactory is
 used to create the handler. Otherwise each
 PlurlFactory.shouldHandle(Class) is called for a class in the call
 stack until a factory returns true. If no factory returns true then the next
 class in the call stack is used. If no factory is found after using all
 classes in the call stack then the first factory added is selected. Once a
 factory is selected, it is used to create the requested handler. If the
 selected factory returns a null handler then no other factory is
 asked to create the handler.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe plurl protocol operation to add a ContentStreamHandlerFactorystatic final StringThe plurl protocol operation to add a URLStreamHandlerFactorystatic final StringThe value to use for theinstall(String...)method to indicate that no protocols are forbidden. for overriding by plurl handlers.static final StringThe host to use for the "plurl" protocol to indicate an operation for adding or removing factories.static final StringThe "plurl" protocol to add and remove plurl factories.static final StringAn optional plurl protocol operation to register aPlurlinstance with the current plurl protocol implementation.static final StringThe plurl protocol operation to remove a ContentStreamHandlerFactorystatic final StringThe plurl protocol operation to remove a URLStreamHandlerFactorystatic final StringAn optional plurl protocol operation to unregister aPlurlinstance with the current plurl instance set with the JVM.
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidadd(PlurlContentHandlerFactory factory) Adds aPlurlContentHandlerFactoryfrom aninstalledplurl implementation.static voidadd(PlurlStreamHandlerFactory factory) Adds aPlurlStreamHandlerFactoryto aninstalledplurl implementation.voidInstalls the plurl factories into the JVM singletons.static voidremove(PlurlContentHandlerFactory factory) Removes aPlurlContentHandlerFactoryfrom aninstalledplurl implementation.static voidremove(PlurlStreamHandlerFactory factory) Removes aPlurlStreamHandlerFactoryto aninstalledplurl implementation.voidIf this plurl instance is the primordial factory for the JVM then uninstall is a no-op and the plurl instance will remain set with the JVM for the lifetime of the JVM instance.
- 
Field Details- 
PLURL_PROTOCOLThe "plurl" protocol to add and remove plurl factories.- See Also:
 
- 
PLURL_OPThe host to use for the "plurl" protocol to indicate an operation for adding or removing factories.- See Also:
 
- 
PLURL_ADD_URL_STREAM_HANDLER_FACTORYThe plurl protocol operation to add a URLStreamHandlerFactory- See Also:
 
- 
PLURL_REMOVE_URL_STREAM_HANDLER_FACTORYThe plurl protocol operation to remove a URLStreamHandlerFactory- See Also:
 
- 
PLURL_ADD_CONTENT_HANDLER_FACTORYThe plurl protocol operation to add a ContentStreamHandlerFactory- See Also:
 
- 
PLURL_REMOVE_CONTENT_HANDLER_FACTORYThe plurl protocol operation to remove a ContentStreamHandlerFactory- See Also:
 
- 
PLURL_REGISTER_IMPLEMENTATIONAn optional plurl protocol operation to register aPlurlinstance with the current plurl protocol implementation. This is an optional operation that aPlurlimplementation may implement to allow another plurl instance to be registered as a delegate. A delegate may be used to install the delegate plurl instance when the current plurl getsuninstalled.- See Also:
 
- 
PLURL_UNREGISTER_IMPLEMENTATIONAn optional plurl protocol operation to unregister aPlurlinstance with the current plurl instance set with the JVM. This is an optional operation that aPlurlimplementation may implement to allow another plurl instance to be unregistered as a delegate.- See Also:
 
- 
PLURL_FORBID_NOTHINGThe value to use for theinstall(String...)method to indicate that no protocols are forbidden. for overriding by plurl handlers.- See Also:
 
 
- 
- 
Method Details- 
installInstalls the plurl factories into the JVM singletons. If plurl factories are already installed then this plurl instance isregisteredwith the existing plurl instance set with the JVM by using something like the following:((Consumer<Object>) ("plurl://op/plurlRegisterImplementation").getContent()).accept(this);If the plurl factories cannot be installed then anIllegalStateExceptionis thrown.If the JVM singletons are already set with other factories that are not plurl then an attempt is made to override the JVM singletons with this plurl instance. This may only be possible if the implementation is allowed to do deep reflection on the java.netpackage. If the JVM singletons are overriden then the original singleton factory instances must be used as parent factories of the plurl instance until the plurl instance isuninstalled. if overriding the JVM singletons is not possible then anIllegalStateExceptionis thrown.If the JVM singletons were not overriden then this plurl instance is considered the primordial singleton factory for the JVM. Such a plurl instance cannot be uninstalledand will live the lifetime of the JVM.When this method returns without throwing an exception then the following will be true: - The singleton
 URL.setURLStreamHandlerFactory(URLStreamHandlerFactory)is set with a plurl implementation which delegates to thePlurlStreamHandlerFactoryobjects that have beenadded.
- The singleton
 URLConnection.setContentHandlerFactory(ContentHandlerFactory)is set with a plurl implementation which delegates to thePlurlContentHandlerFactoryobjects that have beenadded.
- The plurlprotocol is available for creatingURLobjects.
- If plurl factories are already installed then this plurl implementation is registered as a delegate with the already installed plurl instance.
 - Parameters:
- forbidden- builtin JVM protocols that cannot be overridden by plurl. If no forbidden protocols are specified then the default forbidden protocols are 'jar', 'jmod', 'file', and 'jrt'. To forbid no protocols then use the value- PLURL_FORBID_NOTHING
- Throws:
- IllegalStateException- if the Plurl factories cannot be installed
 
- The singleton
 
- 
uninstallvoid uninstall()If this plurl instance is the primordial factory for the JVM then uninstall is a no-op and the plurl instance will remain set with the JVM for the lifetime of the JVM instance.If this plurl is not the primordial factory and is the current plurl set with the JVM singletons then this plurl instance must do the following: - Reset the original parent factories as the singleton factories of the JVM
- If there are any other plurl instances that got
 registeredwith this plurl instance then one of the registered plurl instances must be selected to be the next delegate plurl instance toinstall.
- If a delegate plurl instance gets installed then any existing factories
 that were added to this plurl instance must be added to the new delegate
 plurl instance and any registeredplurl instances must be registered with the new delegate plurl instance.
- This plurl instance must release all references to other factories or plurl instances.
 registeredwith the existing plurl instance set with the JVM by using something like the following:((Consumer<Object>) ("plurl://op/plurlRegisterImplementation").getContent()).accept(this);
- 
addAdds aPlurlStreamHandlerFactoryto aninstalledplurl implementation. If there is no plurl implementation installed then anIOExceptionis thrown. The plurl implementation must not hold any strong references to the factory. If the factory is garbage collected then the plurl implementation must behave as if the factory gotremoved.This is a convenience method for using the plurl protocol like this: ((Consumer<URLStreamHandlerFactory>) ("plurl://op/addURLStreamHandlerFactory").getContent()).accept(factory);- Parameters:
- factory- the PlurlStreamHandlerFactory to add
- Throws:
- IOException- if there is no plurl implementation installed or there was an error adding the factory
 
- 
removeRemoves aPlurlStreamHandlerFactoryto aninstalledplurl implementation. If there is no plurl implementation installed then anIOExceptionis thrown.This is a convenience method for using the plurl protocol like this: ((Consumer<URLStreamHandlerFactory>) ("plurl://op/removeURLStreamHandlerFactory").getContent()).accept(factory);- Parameters:
- factory- the PlurlStreamHandlerFactory to remove
- Throws:
- IOException- if there is no plurl implementation installed or there was an error removing the factory
 
- 
addAdds aPlurlContentHandlerFactoryfrom aninstalledplurl implementation. If there is no plurl implementation installed then anIOExceptionis thrown. The plurl implementation must not hold any strong references to the factory. If the factory is garbage collected then the plurl implementation must behave as if the factory gotremoved.This is a convenience method for using the plurl protocol like this: ((Consumer<ContentHandlerFactory>) ("plurl://op/addContentHandlerFactory").getContent()).accept(factory);- Parameters:
- factory- the PlurlContentHandlerFactory to add
- Throws:
- IOException- if there is no plurl implementation installed or there was an error adding the factory
 
- 
removeRemoves aPlurlContentHandlerFactoryfrom aninstalledplurl implementation. If there is no plurl implementation installed then anIOExceptionis thrown.This is a convenience method for using the plurl protocol like this: ((Consumer<ContentHandlerFactory>) ("plurl://op/removeContentHandlerFactory").getContent()).accept(factory);- Parameters:
- factory- the PlurlContentHandlerFactory to remove
- Throws:
- IOException- if there is no plurl implementation installed or there was an error removing the factory
 
 
-