Skip navigation links
org.netbeans.core.network 1.15

Core Network
Friend, Private or Third Party

See: Description

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

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

ProxySelector

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?
org.netbeans.core.network.proxy.pac.PacScriptEvaluatorFactoryExportedFriend .../proxy/pac/PacScriptEvaluatorFactory.html

org.netbeans.core.network.proxy.pac.PacScriptEvaluatorExportedFriend .../proxy/pac/PacScriptEvaluator.html

org.netbeans.core.network.proxy.pac.PacHelperMethodsExportedFriend .../network/proxy/pac/PacHelperMethods.html

org.netbeans.core.network.utils.HostnameUtilsExportedFriend .../core/network/utils/HostnameUtils.html

org.netbeans.core.network.utils.IpAddressUtilsExportedFriend .../core/network/utils/IpAddressUtils.html

org.netbeans.core.network.utils.LocalAddressUtilsExportedFriend .../network/utils/LocalAddressUtils.html

org.netbeans.core.network.utils.SimpleObjCacheExportedFriend .../core/network/utils/SimpleObjCache.html

org.netbeans.core.network.proxy.pac.PacUtilsExportedFriend .../core/network/proxy/pac/PacUtils.html

org.netbeans.core.network.proxy.pac.datetime.PacUtilsDateTimeExportedFriend .../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
org.netbeans.core.network 1.15