gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r21081 - gnunet-java/doc


From: gnunet
Subject: [GNUnet-SVN] r21081 - gnunet-java/doc
Date: Sun, 22 Apr 2012 22:27:53 +0200

Author: dold
Date: 2012-04-22 22:27:53 +0200 (Sun, 22 Apr 2012)
New Revision: 21081

Removed:
   gnunet-java/doc/gnunet-exercise.tex
Log:
deleted old draft of the tutorial


Deleted: gnunet-java/doc/gnunet-exercise.tex
===================================================================
--- gnunet-java/doc/gnunet-exercise.tex 2012-04-22 20:18:29 UTC (rev 21080)
+++ gnunet-java/doc/gnunet-exercise.tex 2012-04-22 20:27:53 UTC (rev 21081)
@@ -1,219 +0,0 @@
-\documentclass[10pt]{article}
-\usepackage[ansinew]{inputenc}
-\usepackage{makeidx,amsmath,amssymb,exscale,multicol,epsfig,graphics,verbatim,ulem}
-\usepackage{epsfig,geometry,url,listings}
-\geometry{headsep=3ex,hscale=0.9}
-\usepackage{hyperref}
-\hypersetup{
-  pdftitle={gnunet-java tutorial},
-  pdfsubject={gnunet-java},
-  pdfauthor={Florian Dold <address@hidden>},
-  pdfkeywords={gnunet,java},
-  colorlinks=true,
-  urlcolor=blue
-}
-
-\title{Introduction to gnunet-java}
-\author{Florian Dold}
-\date{}
-
-\begin{document}
-
-\maketitle
-
-
-\section{Prerequisites}
-This tutorial assumes that you have gnunet$\geq$0.9.2 installed on your system.
-Instructions on how to do this can be found at 
\url{https://gnunet.org/installation}.
-
-TODO: remark about ./configure --enable-javaports / port configuration
-
-Make sure that the default gnunet services are running by typing
-\begin{lstlisting}
-gnunet-arm -I
-\end{lstlisting}
-on your command line.
-
-\section{Installing gnunet-java}
-Check out the latest version of gnunet-java with
-\lstset{language=bash}
-\begin{lstlisting}
-svn checkout https://gnunet.org/svn/gnunet-java/
-\end{lstlisting}
-as well as the template directory for extensions with
-\begin{lstlisting}
-svn checkout https://gnunet.org/svn/gnunet-java-ext/
-\end{lstlisting}
-
-
-\section{First Steps}
-Programs to communicate with gnunet are located unter the bin/ directory. You 
can add this directory to your path,
-otherwise you have to prefix every command with this directory.
-
-To test if everything is working, try to run the program gnunet-nse. This 
should show you the estimated current size
-of the network.
-
-\subsection{Project Layout}
-src contains the source code of gnunet-java, test contains test cases, bin 
contains wrappers arround main classes,
-tools contain scripts used for development.
-
-gnunet-java-ext has a similar structure.
-
-
-\section{Creating an extension}
-create a copy of gnunet-java-ext and rename it to gnunet-java-hellognunet.
-
-\subsection{configuring your extension}
-describe the classpath config file, the shell wrapper
-
-\section{A simple gnunet-java program}
-\lstset{language=java}
-\begin{lstlisting}
-public class HelloGnunet {
-    public static void main(String[] args) {
-            new Program(args) {
-                public void run() {
-                    System.out.println("Hello, gnunet");
-                }
-            }.start();
-}
-\end{lstlisting}
-
-The Program class takes care of parsing command line arguments (thus it's 
constructur gets the args array passed)
-and loading the gnunet configuration files (accessed by 
Program.getConfiguration())
-(talk about scheduler/asynchronous stuff)
-
-\subsection{Adding and using command line arguments}
-Command line options are added by annotating members of your 
org.gnunet.util.Program-subclass
-with the address@hidden
-
-Let's start with an example:
-
-\lstset{language=java}
-\begin{lstlisting}
-new Program(args) {
-    @Option(
-        shortname = "n",
-        longname = "name",
-        action = OptionAction.STORE_STRING,
-        description = "the name of the person you want to greet")
-    String name;
-[...]
-}
-\end{lstlisting}
-
-The command line program can now be called with -nXXX or --name=XXX.
-Inside of the run-method, the class member 'name' will then be initialized 
with the passed argument,
-or null if the option has not been passed.
-
-The address@hidden annotation can not only be used with Strings, but also with 
booleans and numbers.
-
-(reference the java docs)
-
-By default, the following arguments are available on the command line
-
-(table comes here)
-
-You can change the about text and the version by subclassing the getVersion / 
getAboutTest methods in your Program subclass.
-
-
-\subsection{Using an existing service API}
-In this section we will use the gnunet statistics api to track how often the 
HelloGnunet program
-has been run.
-\subsubsection{Establishing a connection to the statistics service}
-
-\begin{lstlisting}
-Statistics statistics = new Statistics(cfg);
-\end{lstlisting}
-
-establishes a connection to the statistics service. As with most API calls in 
gnunet-java, this operation is asynchronous.
-This is one of the main reasons why you have to wrap your program in the run 
method: Once all your asynchronous calls are
-made, the run method returns, and gnunet-java hast to keep the system running 
until all work has been done.
-
-\begin{lstlisting}
-statistics.set(RelativeTime.SECOND, "gnunet-java-ext-hello", "has said hello", 
1,
-    new SetCompleted() {
-        @Override
-        public void onCompleted() {
-            System.out.println("done.");
-        }
-
-        @Override
-        public void onTimeout() {
-            System.out.println("timeout while setting");
-        }});
-\end{lstlisting}
-
-
-\section {Overview of useful APIs}
-statistics
-
-dht
-* explain dht-put and dht-get / one example
-
-core
-* explain API, maybe refer to example code
-
-
-\section{Creating a new gnunet-java service}
-
-\subsection{Defining new Messages}
-All gnunet services have a common communication protocol.
-Every message consists of a header (with the message size and the message 
type), and a body.
-
-You can define a new type of Message in gnunet-java by annotating a class with 
how
-to represent its members in binary format.
-
-Additionaly, you have to register your new message type with gnunet-java, 
giving it a unique id.
-
-\begin{lstlisting}
address@hidden(4242)
-public class HelloWorldMessage implements GnunetMessage.Body {
-    @UInt8
-    public int age;
-    @ZeroTerminatedString;
-    public String name;
-}
-\end{lstlisting}
-Todo: explain the above
-
-
-Other useful annotations are:
-...
-
-
-Running the msgtypes-tool:
-
-\subsection{Implementing the Service}
-Similarily to Program.run, Service.run is the entry point of every gnunet-java 
service.
-It's members can be annotated with the same command line parsing options as in 
Program.
-
-The first difference is that every Service has at least one server, waiting on 
new clients to connect.
-When implementing a Service, you have to specify the kind of messages you are 
interested in.
-
-The basic skeleton for a Service looks like this:
-
-\subsubsection{Talking back to a client}
-explain Client.this.notifyTransmitReady(...)
-
-\subsection{Creating the configuration file}
-For every service ther is a configuration file that specifies
-over which port the service is reachable. Other options in the configuration 
can be used to
-configure the service without touching the code or implementing your own 
configuration.
-
-[provide example config file here]
-
-\subsection{Using arm to start the service}
-
-\section{Communicating with a Service directly}
-\subsection{Using the client API}
-\subsubsection{Creating a new Client}
-\begin{lstlisting}
-Client = new Client("hello-world-service", getConfiguration());
-\end{lstlisting}
-establishes a connection with the service named "hello-world-service". The 
necessary information (e.g. the right TCP/IP port) for connecting
-to the service is is looked up under the section [hello-world-service] in the 
configuration.
-
-
-
-\end{document}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]