Download presentation
Presentation is loading. Please wait.
Published byChad Mathews Modified over 9 years ago
1
Agoracast: Design and Tools Review David Wallace Croft Senior Java Architect CroftSoft Inc http://croftsoft.com/ Talk-Java/Drink-Java Las Colinas, Texas 2001-10-25
2
Outline Agoracast Demonstration Network News Transfer Protocol Consumer-to-Peer Displaying HTML in Java HTML as a Swing Alternative Launching a Browser from Java Java Web Start Jakarta Ant Customizing Javadoc Reusable Code Libraries Model/View/Controller Composite View Review Decoupling View Components Resources
3
Agoracast Demonstration
4
Network News Transfer Protocol Client Posts to Newsgroup Server Newsgroup Server Shares with Neighbors Messages Previously Received Ignored Completely Decentralized World Wide Broadcast with Single Post Eliminates Need for Web Servers Message Propagation Relatively Slow Multicast Publish-and-Subscribe Java Message Service (JMS) API Java APIs for XML Messaging (JAXM)
5
Consumer-to-Peer Auction sites are Consumer-to-Consumer (C2C) Auction sites provide middleman services Middlemen charge middleman fees Consumer-to-Peer (C2P) removes middleman Peer software performs middleman functionality Decentralization promotes competition Data broadcast to all via public medium Shared data requires standard format Shared data requires standard semantics World Wide Exchange (WWX)
6
Displaying HTML in Java public static JEditorPane createHtmlPane ( URL initialPage, HyperlinkListener hyperlinkListener ) throws IOException ////////////////////////////////////////////////////////////////////// { JEditorPane jEditorPane = new JEditorPane ( initialPage ); jEditorPane.setEditable ( false ); jEditorPane.setCaretPosition ( 0 ); if ( hyperlinkListener != null ) { jEditorPane.addHyperlinkListener ( hyperlinkListener ); } return jEditorPane; }
7
HTML as a Swing Alternative With Swing, you can Display an HTML file and Use HyperlinkListener to get mouse clicks. HTML as a Java app GUI scripting language? Possible advantages: HTML easier and quicker than Swing Use Web Designers to create the GUI Mix online and offline components Refresh “static” HTML immediately
8
Launching a Browser from Java javax.jnlp.BasicService.showDocument public boolean showDocument(java.net.URL url) Directs a browser on the client to show the given URL. This will typically replace the page currently being viewed in a browser with the given URL, or cause a browser to be launched that will show the given URL. Parameters: url - an URL giving the location of the document. A relative URL will be relative to the codebase. Returns: true if the request succeded, otherwise false
9
Java Web Start Java Network Launch Protocol (JNLP) Free Installer Automatic Code Updating Windows, Linux, Solaris Open Source Implementations Macintosh Forthcoming?
10
Jakarta Ant <jar jarfile="agoracast.jar" basedir="jar" manifest="bld/agoracast/manifest.txt"/>
11
Customizing Javadoc <property name="javadoc_bottom" value="${amazon} <center>CroftSoft Javadoc (${TODAY_ISO}) © ${YEAR} <a target=\"_blank\" href=\"http://croftsoft.com/\" >CroftSoft Inc</a>." /> CroftSoft Javadoc (2001-10-12) © 2001 CroftSoft Inc. <javadoc author ="${javadoc_author}" bottom ="${javadoc_bottom}" classpath ="${javadoc_classpath}" destdir ="${javadoc_destdir_core}" doctitle ="${ad2}The CroftSoft Java Core Library"...
12
Reusable Code Libraries Application-specific vs. Reusable Code Projects without Reusable Code Libraries Cut-and-Paste Libraries are your Knowledge Store Libraries make you Faster over Time Code that is Reused is Code that is Debugged Build your Library While Building Your Apps If it is Reusable, Separate it Immediately Javadoc Your Reusable Code Meet Weekly to Review a Library Component E-mail Broadcast Additions to the Library Update Your Reusable Code Javadoc Nightly
13
Model/View/Controller Model: the application object (data & behaviors) View: its screen presentation Controller: controls reaction to user input MVC decoupling for flexibility and reuse Example: Model and multiple Views Example: Controller Replacement (Strategy) Decoupled using the Observer design pattern a.k.a. Publish/Subscribe or Subscribe/Notify Changes to Model generate Events Events drive Views to reload and refresh
14
Composite View Review Composite View: composed of nested Views Each component View has common superclass Each component View has common methods Method calls traverse component hierarchy public void java.awt.Component.paintAll(Graphics g) Paints this component and all of its subcomponents. Communication solely via superclass methods
15
Decoupling View Components Custom Views are often Composite Views Parent constructor instantiates children Maintains subclass references to children Serves as Controller for children Children need reference to parent/Controller Reference passed as a constructor argument Interface reference promotes child class reuse public interface EventListener { public void hearEvent ( Object event ); }
16
Resources Agoracast http://agoracast.com/ Croftsoft Code Library http://croftsoft.com/library/code/ Launching a Browser from Java http://croftsoft.com/library/tutorials/browser/ Java Web Start http://java.sun.com/products/javawebstart/ Jakarta Ant http://jakarta.apache.org/ant/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.