Author: slotia
Date: 2009-04-01 10:19:30 -0700 (Wed, 01 Apr 2009)
New Revision: 16376

Added:
   core3/io-api/trunk/src/main/java/org/cytoscape/io/util/CyProxyRegistry.java
   core3/io-api/trunk/src/main/java/org/cytoscape/io/util/CyProxySelector.java
Log:
Added CyProxyRegistry and CyProxySelector


Added: 
core3/io-api/trunk/src/main/java/org/cytoscape/io/util/CyProxyRegistry.java
===================================================================
--- core3/io-api/trunk/src/main/java/org/cytoscape/io/util/CyProxyRegistry.java 
2009-03-31 21:44:54 UTC (rev 16375)
+++ core3/io-api/trunk/src/main/java/org/cytoscape/io/util/CyProxyRegistry.java 
2009-04-01 17:19:30 UTC (rev 16376)
@@ -0,0 +1,27 @@
+package org.cytoscape.io.util;
+
+import java.net.Proxy;
+
+/**
+ * For registering <code>Proxy</code>s; this interface
+ * should only be used by those who set proxy
+ * settings.
+ *
+ * @author Pasteur
+ */
+public interface CyProxyRegistry extends CyProxySelector
+{
+       /**
+        * Registers a <code>Proxy</code>.
+        *
+        * @param scheme If <code>URI</code>'s <code>getScheme()</code>
+        * matches the given <code>scheme</code>, the
+        * <code>selector</code> method returns the provided <code>proxy</code>.
+        *
+        * @param proxy The <code>Proxy</code> to be specified for the given
+        * <code>scheme</code>. If a <code>Proxy</code> is already specified for
+        * the given <code>scheme</code>, this will override the 
<code>Proxy</code>
+        * with the given one.
+        */
+       public void register(String scheme, Proxy proxy);
+}

Added: 
core3/io-api/trunk/src/main/java/org/cytoscape/io/util/CyProxySelector.java
===================================================================
--- core3/io-api/trunk/src/main/java/org/cytoscape/io/util/CyProxySelector.java 
2009-03-31 21:44:54 UTC (rev 16375)
+++ core3/io-api/trunk/src/main/java/org/cytoscape/io/util/CyProxySelector.java 
2009-04-01 17:19:30 UTC (rev 16376)
@@ -0,0 +1,56 @@
+package org.cytoscape.io.util;
+
+import java.util.List;
+import java.net.URI;
+import java.net.Proxy;
+
+/**
+ * Selects an appropriate <code>Proxy</code> for a given <code>URI</code>; this
+ * interface should be used by anyone who needs to open connections to the 
Internet
+ * through <code>Socket</code>s or <code>URI</code>s,
+ * <i>not</i> <code>CyProxyRegistry</code>.
+ *
+ * <p><b>Regarding <code>java.net.ProxySelector</code></b>. Since Java 5,
+ * Java has the class <code>ProxySelector</code>, which returns a 
<code>List</code>
+ * of appropriate <code>Proxy</code>s for a given <code>URI</code>. There are 
several
+ * reasons why one should use this interface instead:</p>
+ *
+ * <p><ul>
+ *
+ * <li><code>ProxySelector</code> returns a <code>List</code> of 
<code>Proxy</code>s.
+ * One must determine which <code>Proxy</code> in the <code>List</code>
+ * is the best. However, <code>CyProxySelector</code> returns only one 
<code>Proxy</code>,
+ * so one does not need to decide the best <code>Proxy</code>.</li>
+ *
+ * <li><code>ProxySelector</code> allows public access to the method
+ * <code>connectFailed</code>, while classes that implement 
<code>CyProxySelector</code>
+ * do not.</li>
+ *
+ * <li>One can use Spring Dynamic Modules for a <code>CyProxySelector</code>. 
This
+ * is more flexible than <code>ProxySelector</code>, which only allows one 
default
+ * <code>ProxySelector</code> for the entire JVM.</li>
+ *
+ * </ul></p>
+ *
+ * <p>Classes that do implement this interface may choose to set themselves as 
the default
+ * <code>ProxySelector</code>. Such a <code>ProxySelector</code> should have 
this behavior:</p>
+ *
+ * <p><ul>
+ *
+ * <li><code>select</code> should return a <code>List</code> containing the 
single
+ * <code>Proxy</code> returned by <code>CyProxySelector</code>'s 
<code>select</code>.</li>
+ *
+ * <li><code>connectFailed</code> should inform the user that the proxy 
settings are invalid.</li>
+ * </ul></p>
+ *
+ * @author Pasteur
+ */
+public interface CyProxySelector
+{
+       /**
+        * Selects an appropriate <code>Proxy</code> for a given 
<code>URI</code>.
+        * If an appropriate <code>Proxy</code> cannot be found, this method 
returns
+        * <code>Proxy.NO_PROXY</code> to represent direct connections.
+        */
+       public Proxy select(URI uri);
+}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to