Skip navigation links 1.15

Core Network
Friend, Private or Third Party

See: Description

Core Network 
Package Description
Proxy Auto-Config (PAC) script related.
Proxy Auto-Config (PAC) script related, specifically around Java support for the JavaScript helper functions dateRange(), timeRange() and weekdayRange().
NetBeans default implementation of a PAC script evaluation environment.
Utilities related to network.

The Core Network module provide ProxySelector as well as utilities related to network connections.


The role of a ProxySelector is to tell to the rest of Java which proxy to use for a given URL. There's only one ProxySelector in a given JVM. Most notably the ProxySelector is used by the URLConnection classes and even the new HTTP client in JDK9 is using it, although it allows more control over this than does the URLConnection classes. Also, the Apache HttpClient is also using the default ProxySelector if you have instructed it to use what is known in Apache HttpClient as SystemDefaultRoutePlanner.

This module provides an implementation of a ProxySelector which finds out which proxy to use by looking at preferences the user has stored. This is trivial for the case where the user has provided explicit proxy information. It is more complex for the case where the user has said "just use my system's proxy configuration" which is by the way the default in NetBeans. This requires us to go the underlying OS and try to figure out what the user's settings are. In many case case the user will not have explicit proxy setting in the OS either but will simply have "Automatically detect settings" or whatever. This makes it even more complex (see WPAD section below).

The ProxySelector is instantiated by the Startup module, but only if module Core also exists. Thus, for a minimal Platform application which only use the modules from the "Runtime Container", there will be no ProxySelector installed because module Core is not part of the Runtime Container. In this case, the standard ProxySelector in Java will then be used. This makes sense because a headless application will not have stored Preferences about proxy, etc, and will be much better off by just using the standard ProxySelector (which can be controlled by properties).

Module Core uses the Global Lookup to search for a ProxySelector, so you can register your own ProxySelector if you don't like the one provided by the Platform (i.e. this module). This will be somewhat difficult though, because in order to implement your own ProxySelector, you would need read access to the stored ProxySettings. This class is currently only exposed to friends.

Proxy Auto-Config (PAC)

Very often the proxy configuration on a corporate network is not given explictly. Instead it is given in a little JavaScript file which clients are supposed to download and execute in order to find out which proxy to use. This is known as Proxy Auto-Config (or PAC). This module provides a pluggable PAC evaluation environment based on Nashorn. However, it will gracefully degrade to any other JavaScript which may be installed in the JVM. Execution of the downloaded JavaScript code is sandboxed. (only true for Nashorn)

If you don't like the PAC evaluation environment provided by this module then you can plug in your own by registering your own PacScriptEvaluatorFactory class in the Global Lookup. If you want to build your own PAC evaluation environment then you can still make use of all the utility classes provided by this module.

Locating the PAC script (WPAD)

Normally, a Web Browser (in comparison) can locate the PAC script either explicitly, meaning the URL is directly available from the settings in the OS, or it can be located via WPAD This module currently only supports the case where URL is directly available from the settings. There's no support for WPAD.

What is New (see all changes)?

Use Cases

Custom ProxySelector
You can provide your own ProxySelector instead of the one provided by this module. You do this by registering your own ProxySelector in the Global Lookup. However, make sure you understand that the instantiation of the ProxySelector (i.e. executing its constructor) is part of the main startup path of a NetBeans application. For this reason the constructor better be fast. Defer as much work as possible to later.
Custom PAC Evaluator
You can plug in your own PAC evaluator if you are unhappy with the default one provided in this module. You do this by registering your own PacScriptEvaluatorFactory in the Global Lookup. This factory must then in turn return an instance of your custom PacScriptEvaluator.
Customizing the default PAC Evaluator
Instead of replacing all of the default PAC evaluator you can replace only its implementation of the PAC Helper Functions. However, you have to play by rules set by the default PacScriptEvaluator, namely that all the Helper Functions are implemented in Java (as opposed to JavaScript). Simply register your sub-class of PacHelperMethods in the Global Lookup and your implementation will automatically be picked up. When creating your own PacHelperMethods you may take benefit from the PAC utility functions provided by PacUtils and PacUtilsDateTime, as well as the more general ones provided by network utils package.

Exported Interfaces

This table lists all of the module exported APIs with defined stability classifications. It is generated based on answers to questions about the architecture of the module. Read them all...
Group of java interfaces
Interface NameIn/OutStabilitySpecified in What Document? .../proxy/pac/PacScriptEvaluatorFactory.html .../proxy/pac/PacScriptEvaluator.html .../network/proxy/pac/PacHelperMethods.html .../core/network/utils/HostnameUtils.html .../core/network/utils/IpAddressUtils.html .../network/utils/LocalAddressUtils.html .../core/network/utils/SimpleObjCache.html .../core/network/proxy/pac/PacUtils.html .../proxy/pac/datetime/PacUtilsDateTime.html

Implementation Details

Where are the sources for the module?

The sources for the module are in the NetBeans Mercurial repositories.

What do other modules need to do to declare a dependency on this one, in addition to or instead of a plain module dependency?

XXX no answer for deploy-dependencies

Read more about the implementation in the answers to architecture questions.

Skip navigation links 1.15