null
if constructor failed
+ */
+ public static synchronized ProxyAutoConfig get(String pacFile) {
+ if (file2pac.get(pacFile) == null) {
+ LOGGER.fine("Init ProxyAutoConfig for " + pacFile);
+ ProxyAutoConfig instance = null;
+ try {
+ instance = new ProxyAutoConfig(pacFile);
+ } catch (URISyntaxException ex) {
+ Logger.getLogger(ProxyAutoConfig.class.getName()).warning("Parsing " + pacFile + " to URI throws " + ex);
+ } finally {
+ file2pac.put(pacFile, instance);
+ }
+ }
+ return file2pac.get(pacFile);
+ }
+ private static final Logger LOGGER = Logger.getLogger(ProxyAutoConfig.class.getName());
+ private Invocable inv = null;
+ private final Task initTask;
+ private final URI pacURI;
+
+ private ProxyAutoConfig(final String pacURL) throws URISyntaxException {
+ assert file2pac.get(pacURL) == null : "Only once object for " + pacURL + " must exist.";
+ String normPAC = normalizePAC(pacURL);
+ pacURI = new URI(normPAC);
+ initTask = RP.post(new Runnable() {
+
+ @Override
+ public void run() {
+ initEngine();
+ }
+ });
+ }
+
+ public URI getPacURI() {
+ return pacURI;
+ }
+
+ private void initEngine() {
+ InputStream pacIS;
+ try {
+ if (pacURI.isAbsolute()) {
+ pacIS = downloadPAC(pacURI.toURL());
+ } else {
+ pacIS = null;
+ }
+ } catch (IOException ex) {
+ LOGGER.log(Level.INFO, "InputStream for " + pacURI + " throws " + ex, ex);
+ return;
+ }
+ if (pacIS == null) {
+ return ;
+ }
+ String utils = downloadUtils();
+ ScriptEngine eng;
+ try {
+ eng = evalPAC(pacIS, utils);
+ } catch (FileNotFoundException ex) {
+ LOGGER.log(Level.FINE, "While constructing ProxyAutoConfig thrown " + ex, ex);
+ return ;
+ } catch (ScriptException ex) {
+ LOGGER.log(Level.FINE, "While constructing ProxyAutoConfig thrown " + ex, ex);
+ return ;
+ } finally {
+ if (pacIS != null) {
+ try {
+ pacIS.close();
+ } catch (IOException ex) {
+ LOGGER.log(Level.FINE, "While closing PAC input stream thrown " + ex, ex);
+ }
+ }
+ }
+ assert eng != null : "JavaScri5pt engine cannot be null";
+ if (eng == null) {
+ LOGGER.log(Level.WARNING, "JavaScript engine cannot be null");
+ return ;
+ }
+ inv = (Invocable) eng;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List
+ Launcher does not provide netbeans.system_http_proxy
and
+ netbeans.system_http_non_proxy_hosts
properties anymore.
+ Proxy settings are now detected in Core Network module.
+
+This document lists changes made to the API between core/startup and core +modules. It is a friend API so it does not need to be developed compatibly, +and indeed it is not. +
+ + + +@FOOTER@
+ + +
+ The o.n.core
module finds a instance of java.net.ProxySelector
+ in the default org.openide.util.Lookup
. If some found
+ then will be registred as default ProxySelector.setDedault()
.
+
+ An implementation of this class brings a facility to reload Network
+ Proxy Settings from underlying OS.
+ The module core.network
provides a implementation
+ which may be accessible via Lookup.getDefault()
. It's not guaranteed
+ any implementation is found on all distribution.
+
+ Classes NbProxySelector
and ProxyAutoConfig
have been
+ moved to Core Network module. Now the NbProxySelector
can be accessed
+ via lookup - in CoreBridgeImpl
.
+
+This document lists changes made to the API between core/startup and core +modules. It is a friend API so it does not need to be developed compatibly, +and indeed it is not. +
+ + + +@FOOTER@
+ + +null
if constructor failed
- */
- public static synchronized ProxyAutoConfig get(String pacFile) {
- if (file2pac.get(pacFile) == null) {
- LOGGER.fine("Init ProxyAutoConfig for " + pacFile);
- ProxyAutoConfig instance = null;
- try {
- instance = new ProxyAutoConfig(pacFile);
- } catch (URISyntaxException ex) {
- Logger.getLogger(ProxyAutoConfig.class.getName()).warning("Parsing " + pacFile + " to URI throws " + ex);
- } finally {
- file2pac.put(pacFile, instance);
- }
- }
- return file2pac.get(pacFile);
- }
- private static final Logger LOGGER = Logger.getLogger(ProxyAutoConfig.class.getName());
- private Invocable inv = null;
- private final Task initTask;
- private final URI pacURI;
-
- private ProxyAutoConfig(final String pacURL) throws URISyntaxException {
- assert file2pac.get(pacURL) == null : "Only once object for " + pacURL + " must exist.";
- String normPAC = normalizePAC(pacURL);
- pacURI = new URI(normPAC);
- initTask = RP.post(new Runnable() {
-
- @Override
- public void run() {
- initEngine();
- }
- });
- }
-
- public URI getPacURI() {
- return pacURI;
- }
-
- private void initEngine() {
- InputStream pacIS;
- try {
- if (pacURI.isAbsolute()) {
- pacIS = downloadPAC(pacURI.toURL());
- } else {
- pacIS = null;
- }
- } catch (IOException ex) {
- LOGGER.log(Level.INFO, "InputStream for " + pacURI + " throws " + ex, ex);
- return;
- }
- if (pacIS == null) {
- return ;
- }
- String utils = downloadUtils();
- ScriptEngine eng;
- try {
- eng = evalPAC(pacIS, utils);
- } catch (FileNotFoundException ex) {
- LOGGER.log(Level.FINE, "While constructing ProxyAutoConfig thrown " + ex, ex);
- return ;
- } catch (ScriptException ex) {
- LOGGER.log(Level.FINE, "While constructing ProxyAutoConfig thrown " + ex, ex);
- return ;
- } finally {
- if (pacIS != null) {
- try {
- pacIS.close();
- } catch (IOException ex) {
- LOGGER.log(Level.FINE, "While closing PAC input stream thrown " + ex, ex);
- }
- }
- }
- assert eng != null : "JavaScri5pt engine cannot be null";
- if (eng == null) {
- LOGGER.log(Level.WARNING, "JavaScript engine cannot be null");
- return ;
- }
- inv = (Invocable) eng;
- }
-
- @SuppressWarnings("unchecked")
- public Listo.n.core
and core.network
.
+ * An implementation of this class brings a facility to reload Network Proxy Settings
+ * from underlying OS.
+ * The module core.network
provides a implementation which may be accessible
+ * via Lookup.getDefault()
. It's not guaranteed any implementation is found on all distribution.
+ *
+ * @since 3.40
+ */
+ public abstract static class Reloader {
+
+ /** Reloads Network Proxy Settings from underlying system.
+ *
+ */
+ public abstract void reload();
+ }
}
--- a/o.n.core/test/unit/data/pacFiles/wpad space.dat Tue Mar 26 12:16:28 2013 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-function FindProxyForURL(url, host)
-{
- // Make everything lower case.
- url = url.toLowerCase();
- host = host.toLowerCase();
- if (isPlainHostName(host)) return "DIRECT";
- return "PROXY www-proxy.us.oracle.com:80";
-};
--- a/o.n.core/test/unit/data/pacFiles/wpad.dat Tue Mar 26 12:16:28 2013 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-function FindProxyForURL(url, host)
-{
- // Make everything lower case.
- url = url.toLowerCase();
- host = host.toLowerCase();
- if (isPlainHostName(host)) return "DIRECT";
- return "PROXY www-proxy.us.oracle.com:80";
-};
--- a/o.n.core/test/unit/src/org/netbeans/core/CanProxyToLocalhostTest.java Tue Mar 26 12:16:28 2013 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.core;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.ProxySelector;
-import java.net.SocketAddress;
-import java.net.URI;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.Locale;
-import org.netbeans.junit.NbTestCase;
-import org.openide.util.NetworkSettings;
-import org.openide.util.lookup.ServiceProvider;
-
-/** Check whether we can proxy to localhost.
- */
-public class CanProxyToLocalhostTest extends NbTestCase {
- private static String USER_PROXY_HOST = "my.webcache";
- private static int USER_PROXY_PORT = 8080;
-
- private ProxySelector selector;
- private static URI TO_LOCALHOST;
- private static URI TO_NB;
- private MyPS myPS;
-
- public CanProxyToLocalhostTest (String name) {
- super (name);
- }
-
- @Override
- protected void setUp () throws Exception {
- myPS = new MyPS();
- selector = NbProxySelector.create(myPS);
- TO_LOCALHOST = new URI ("http://localhost");
- TO_NB = new URI ("http://netbeans.org");
- }
-
- public void testNoProxyForLocalhost() {
- Locale.setDefault(Locale.US);
- assertEquals ("Connect TO_LOCALHOST DIRECT.", "DIRECT", selector.select (TO_LOCALHOST).get(0).toString());
- }
- public void testProxyForLocalhost() {
- Locale.setDefault(new Locale("te", "ST"));
- assertEquals ("Connect TO_LOCALHOST provided by MyPS", "HTTP @ my.webcache:8080", selector.select (TO_LOCALHOST).get(0).toString());
- assertEquals("One call to my ps", 1, myPS.called);
- }
- public void testAlwaysProxyForNonLocalhost() {
- Locale.setDefault(Locale.US);
- assertEquals ("Connect TO_LOCALHOST DIRECT.", "HTTP @ my.webcache:8080", selector.select (TO_NB).get(0).toString());
- assertEquals("One call to my ps", 1, myPS.called);
- }
-
- private static class MyPS extends ProxySelector {
- int called;
-
- @Override
- public List