Changeset 23

Show
Ignore:
Timestamp:
10/21/05 00:52:48 (5 years ago)
Author:
dsandler
Message:

Minimal Swing GUI wrapped around the proxy.

$ java -cp ftproxy.jar net.feedtree.proxyapp.gui.AppGUI -N -V

Might make this the default class for ftproxy.jar, and create a "ftproxy"
shell script which invokes proxyapp.WebProxyClient? instead.

Lots of stuff to fix, including making the hyperlink functional with
JEditorPane.

This feature tracked by ticket #21.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • feedtree/trunk/src/net/feedtree/core/client/Client.java

    r1 r23  
    2929    public static int           PASTRY_PROTOCOL = DistPastryNodeFactory.PROTOCOL_SOCKET; 
    3030     
     31    protected static InetSocketAddress g_localNodeAddress = null; 
     32 
     33    public static InetSocketAddress getLocalNodeAddress() {  
     34        return g_localNodeAddress;  
     35    } 
     36 
    3137    // ------------------------------------------------------------ 
    3238    // members 
     
    3642    protected Responder     m_responder = null; 
    3743    protected Map           m_topics = Collections.synchronizedMap(new HashMap()); 
    38  
    3944 
    4045    public String       getInstance() { return PASTRY_APP_NAME; } 
     
    249254                    InetAddress natAddr = NAT.findNatAddress( 
    250255                            port, bootSocketList, pastryEnv); 
    251                     InetSocketAddress localNodeAddress = null; 
     256                    g_localNodeAddress = null; 
    252257                    if (natAddr != null) 
    253                         localNodeAddress = new InetSocketAddress(natAddr, port); 
     258                        g_localNodeAddress = new InetSocketAddress(natAddr, port); 
    254259                 
    255260                    Logger.global.fine("[Contacting bootstrap host " 
     
    258263                    node = factory.newNode( 
    259264                        factory.getNodeHandle(bootSocketList[0]), 
    260                         localNodeAddress); 
     265                        g_localNodeAddress); 
    261266                } catch (java.io.StreamCorruptedException exc) { 
    262267                    Logger.global.severe("Stream corruption error while finding bootstrap.  Sleeping and trying again."); 
  • feedtree/trunk/src/net/feedtree/proxyapp/WebProxyClient.java

    r22 r23  
    6363    static String FEEDTREE_SCRIBE_FEED_MIME = "application/atom+xml"; 
    6464 
     65    public static boolean HEADLESS = true; 
    6566     
    6667    static final String VERSION_STRING = "0.2"; 
    6768    static final String USER_AGENT = "feedtree.Proxy/" + VERSION_STRING; 
    6869 
    69     static WebProxyClient global = null; 
     70    public static WebProxyClient global = null; 
    7071 
    7172    static Properties g_buildProperties; 
     
    7778 
    7879    protected int m_proxyPort; 
     80    protected int m_webPort; 
    7981    protected int m_overloadFactor; 
    8082    protected boolean m_appendEntryInfo = true; 
     
    463465        } 
    464466 
    465         protected String duration(long millis) { 
    466             long time = millis / 1000; 
    467             StringBuffer s = new StringBuffer(); 
    468             if (time > 86400) { 
    469                 long days = time / 86400; 
    470                 if (days > 0) { 
    471                     time = time - 86400 * days; 
    472                     s.append(days); 
    473                     s.append("d"); 
    474                 } 
    475             } 
    476             long hours = 0; 
    477             long minutes = 0; 
    478             if (time > 3600) { 
    479                 hours = time / 3600; 
    480                 time = time - 3600 * hours; 
    481             } 
    482             if (time > 60) { 
    483                 minutes = time / 60; 
    484                 time = time - 60 * minutes; 
    485             } 
    486             if (hours > 0) { 
    487                 s.append(hours); 
    488                 s.append("h"); 
    489             } 
    490             if (minutes > 0) { 
    491                 if (minutes < 10) s.append("0"); 
    492                 s.append(minutes); 
    493                 s.append("m"); 
    494             } 
    495             if (time > 0 || millis < 1000 || s.equals("")) { 
    496                 if (time < 10 && millis > 10000) s.append("0"); 
    497                 s.append(time); 
    498                 s.append("s"); 
    499             } 
    500             return s.toString(); 
    501         } 
    502467         
    503468        protected void printStatusPage(PrintWriter output, WebInterfaceHandler handler) { 
     
    512477            String proxyInterface = host + ":" + m_proxyPort; 
    513478            String nodeInfo = "Node: " + m_node.toString() + "\nId: " + m_node.getId().toStringFull(); 
    514             String uptime = duration(new Date().getTime() - m_startDate.getTime()); 
     479            String uptime = TimeUtils.duration(new Date().getTime() - m_startDate.getTime()); 
    515480            output.write("<div id=\"serverinfo\"><table>" 
    516481                + "<tr><th align=right>Web interface:</th><td>" + webInterface + "</td></tr>" 
     
    629594                    + feed.getUri()  
    630595                        + "\" alt=\"[event log for feed]\" /></a>&nbsp;"  
    631                         + duration(feed.getTtl())  
     596                        + TimeUtils.duration(feed.getTtl())  
    632597                    + "</td>" 
    633598 
     
    903868        } 
    904869    } 
     870     
     871    public long getUptime() { 
     872        return new Date().getTime() - m_startDate.getTime(); 
     873    } 
     874    public String getUptimeString() { 
     875        return TimeUtils.duration(getUptime()); 
     876    } 
     877     
     878    public String getWebInterfaceURL() { 
     879        //Socket sock = handler.getSocket(); 
     880        //String host = sock.getLocalAddress().toString().substring(1); 
     881        //return "http://" + host + ":" + sock.getLocalPort(); 
     882        return "http://localhost:" + m_webPort; 
     883    } 
     884     
     885    public int getProxyPort() { return m_proxyPort; } 
    905886 
    906887    protected class ReportSource implements Reporter.IReportSource { 
     
    946927         
    947928        m_proxyPort = proxyPort; 
     929        m_webPort = webPort; 
    948930        m_startDate = new Date(); 
    949931         
     
    12121194       
    12131195        // Disable use of graphics accelerator for Sparklines 
    1214         System.setProperty("java.awt.headless", "true"); 
     1196        if (HEADLESS)  
     1197            System.setProperty("java.awt.headless", "true"); 
    12151198         
    12161199        // Circumvent broken aspects of the Apple JVM