Sunday, October 24, 2010

The Wedding Dance Mount And Blade Mod

Awareness

yet I am reading the Hagakure and I paused to think of a written prima pagine,
una frase mi rimase in mente ovvero "quando un Samurai è sempre pronto a morire padroneggia la via"
questo si può mettere in pratica anche nella vita, in tutte le cose, essere consapevoli della "morte" non della morte materiale ma del fine di qualcosa, come la fine del lavoro, di un affetto, una fine prevede un inizio nuovo.....questo serve molto per apprendere per imparare, ma vivendo con la continua consapevolezza che da un momento all'altro si può perdere tutto, ecco questo nell'era moderna padroneggia la via.

Essere consapevoli di ciò che accade intorno a te....respirare a fondo prima di prendere la decisione e non farsi mai trovare impreparate....padroneggiando la via....padroneggerai la tua mind ....

Thursday, October 21, 2010

Vba Pokemon Silber Cheats

Dear readers

in the evening I'm planning to find time to write on my blog
I bring you knowledge of where I work

work PUNTORADIO a local radio station if you want to know more about the Piedmont

FB please go here and
our site here
Twitter here

news to tell you .... I have many thoughts and little to share with you now I thank you for


Sejbei

Wednesday, October 20, 2010

Camossatellite 40cm Dome Coverage

THANKS .... The garden is still cultivated

I wanted to thank you for your trust and your patience, every couple of days will update the blog, because for every beginning there is an end and every end is a beginning

Tuesday, October 19, 2010

Free Playsets Blueprint

API - API

Le classi per lavorare su pattern in Java sono:

  • Pattern e Matcher e String.split per lavorare su stringhe;
  • Formatter e Scanner per lavorare su stream.
Quando si cerca un determinato pattern all'interno di una stringa si possono usare le regular expression; per usarle si crea un Pattern con l'espressione da cercare, e poi si cerca su un testo:
    Pattern p = Pattern.compile("o."); // the expression
    Matcher m = p.matcher("ciao mondo"); // the source
   while (m.find ()) {System.out.println
(m.start () + "" + m.end () + "\u0026lt; , "+ m.group () + ">");
}
print
3 5 \u0026lt;or>
6 8 \u0026lt;ON>
methods Matcher.start () returns the current position in Matcher (Where the match was found today), Matcher.end () returns the final position, and Matcher.group () returns the entire contents . The method Matcher.group () also allows you to choose the subgroup sought in the case of more complex regular expressions, look at the following example:
Pattern p = Pattern.compile (" (.) (or )(.)"); / / the expression
Matcher m = p.matcher ("hello world"), / / \u200b\u200bthe source
; while (m.find ())
{System.out.println (m.start () + "" + m.end () + "\u0026lt;" + m.group (1) + "- "+ m.group (2) +" - "+ m.group (3) +} ">");
returns:
\u0026lt;a-o-2 5> 5 8
\u0026lt;m-o-n>
because the expression (.) (o) (.) finds all locations where we have an 'o' surrounded by two characters, and then divide the result into three groups, from which 'a', 'o', '' in ' hello ".

The next step is to use wildcards, we have the following:
  • \\ d - is the digits, ie digits 0-9
  • \\ w - the word is, that the characters (letters (from 'a' and 'z') and (between 'A' and 'Z') and (between 0 and 9) or '_')
  • \\ s - is the space ('', '\\ n', '\\ r', '\\ t')
or we can use the '[' and ']' to encompass the range of characters, For example \\ d is equal to [0-9] and \\ W is equal to [a-zA-Z0-9_] we can use quantifiers to indicate how many elements we look for: if we use '+' indicates (at least) if we use '*' indicates (between zero and infinity) and if we use '?' index (zero or one) if we use [^ abc] indicate (all except 'a', 'b' or 'c') if we show we can use any character '.', then if we do not greedy search we use '*?' instead of '*' and '? +' instead of '+', the difference between greedy and greedy search is that the larger the match, while not looking the least greedy, an example is
Pattern greedy : .* xx
Pattern not greedy: .*? Xx
String: yyxxxyxx
the greedy match (greedy) as a result of " yyxxxyxx ", while the match is not to be greedy as a result yyxx and xyxx

How Matcher even Scanner allows you to search, working on Stream (or File or String):
; Scanner s = new Scanner ("hello world");
String token;
    do {
        token = s.findInLine("(.)(o)(.)");
        System.out.println("found <" + token + ">");
    } while (token != null);

Scanner normalmente viene utilizzato per fare il " tokenizing "; l'alternativa is to use String.split () , while we see how to do this and then with Scanner:
String [] str = "hello world are very happy." split (". or .)
for (String s: str)
System.out.println (s + "-");
that returns us
- - - - o - - happy -
As we get la stessa funzione dello scanner, abbiamo spesso una funzionalità non richiesta: lui esegue il tokenizing di tutta la stringa prima di darci un output; quando questo non è il comportamento desiderato basta utilizzare lo Scanner (che funziona anche su Stream e File, e restituisce tipo primitivi):
    Scanner s = new Scanner("ciao 123 cmondo true sdada");
    while(s.hasNext()) {
    if (s.hasNextInt())
        System.out.print("Intero(" + s.nextInt() + "); ");
    else if (s.hasNextBoolean())
        System.out.print("Boolean(" + s.nextBoolean() + "); ");
    else
        System.out.print(s.next() + "; ");
    }
returns:
hello, Whole (123); cmondo; Boolean (true); Sdad;

We finally Formatter object that provides methods printf and format that behave like this:
...

The code is here

Straw Bale Construction Forum

Pattern - File

In Java we have two types of approaches to the files: consider them as entities (ie files and directories) or treated as content (ie Writer and Reader).

file management as an entity is exclusively via the File object, its allow manufacturers to refer to physical paths (existing or not) and its methods enable you to read directories, create empty files or directories, delete files or directories (empty), rename file or directory: File f =

new File ("folder"), / / \u200b\u200bpoint to a file on the file system
if (! f.exists ())
f.mkdir () / / create the directory

innerFile File = new File (f, "file.txt");
     innerFile.createNewFile();

     f.delete(); //non funziona, ritorna false
     if (f.isDirectory() && f.listFiles().length > 0)   innerFile.renameTo(new File("." + File.separatorChar + "test.txt"));

     f.delete () / / now works

in this example we see how to create a directory ( mkdir () ), an empty file ( createNewFile () ) how to delete a file or empty directory ( delete () ), and as you rename (or move) the files and directories ( renameTo (File f) ) as we check whether a file or directory exists already ( exists () ), if the file is a file or directory ( isFile () and isDirectory () ), and how to get all the files in a directory ( listFiles () or list () ).
These indicators are all methods that are used for the examination, and usually in real life.

classes on writing and reading of the file contents are divided into Writer / OutputStream and Reader / InputStream; the difference between Writer and OutputStream is that it works on characters while working on the second byte.
important to remember that System.in is an InputStream, and is a System.out PrintWriter;
For certification does not need to know the Stream , but are required if you want to use the console and you do not want to use the Console class.

classes we use are:
FileWriter (accepts a File or a String) and provides methods write (), flush (), close () .
BufferedWriter (Writer accepts a) and provides as FileWriter plus newLine ().
PrintWriter (takes File, String, Writer and OutputStream) and provides the methods also FileWriter and format () , printf () , print () , println () .
FileReader (accepts a File or a String) and provides read () .
BufferedReader (accepts a Reader) and provides read () and readLine () ;

Una classe che può essere utile conoscere (non per la certificazione, ma per se stessi) è InputStreamReader ; questa classe è un Reader , e accetta un InputStream ; in pratica fa da ponte tra i due sistemi e permette di usare BufferedReader su oggetti InputStream (che sono quasi tutti quelli restituiti dai flussi: System.in, Socket, Servlet, ...).

La lettura (da file, da flusso, da console) si può ottenere usando:

BufferedReader brF = new BufferedReader(new FileReader("nomefile.txt"));
BufferedReader brs = new BufferedReader (new InputStreamReader (socket.getInputStream ())); / / socket is here for example, does not exist in the context
BufferedReader brc = new BufferedReader (new InputStreamReader (System.IO in));
so you can use brF.readLine () ; since readLine returns null when the flow ends, you can use the construct common
String res;
while ((res = brF.readLine ())! = null) {/ * Do something with res * /}
Writing (anywhere, or on file in append mode) is obtained using:
PrintWriter PWF = new PrintWriter ("filename.txt ");
PrintWriter pwFA = new PrintWriter (new FileWriter (" filename.txt ", true));
pws = new PrintWriter PrintWriter (socket.getOutputStream ()) ; / / socket is here for example, does not exist in the context
then you write using pwF.println ("hello world "); or pwF.format ("% d that has value? ", 123);
is important to remember that if you close the stream and especially if you are not the flush () after wrote you may not actually send the data.
Using Console allows you to use keyboard and monitor for output, and in some cases you do not have a Console (see Using Eclipse) and in that case you must implement the code by hand to read from keyboard, otherwise we can use code like the following:
System.Console Console c = ();
if (c! = null) {
System.out.println ("Give me your username:");
; c.readLine username = String ();
System.out.println ("Now give me the password:");
char [] pw = c.readPassword ();
System.out.println ("Your username is" + username);
System. out.print ("Your password");
for (char ch: pw)
; c.format ("% c", ch);
c.format ("\\ n");
}
dealing read a line from the keyboard, read a password (using the characters because strings are immutable in Java, and would not be wise to use an immutable object in a pool and to store a password) and then use the format method whereas, using the syntax that is also found in C ( printf ) allows you to print formatted strings.

Finally we have Java classes that handle the serialization. An object is said
Serializable if it implements the interface Serializable . The usefulness stems from the fact that you can write that instance as a stream of bytes, and you can send via Stream, or write to files, or embed it on a database, the classes we use are:
DataInputStream / DataOutputStream - provide methods to read and write primitive data strings or UTF;
FileInputStream / FileOutputStream - provide ways to access files as a stream of bytes (and not stream of characters);
ObjectInputStream / ObjectOutputStream - allow you to read and write primitive data and objects,

Here are some examples of these objects:

System.out.println ("Enter a number between 1 and 100");
DataInputStream dis = new DataInputStream (System.in);
dis.readInt int value = ();
System.out.println (value);
example trarvi of code that could mislead, since readInt () does not behave as we might think, does not take a line, converts it to an integer and returns, but rather the law of 4 bytes and returns an integer value with those bytes, this code might be as an application, then we must learn the logic required;


Grandpa class implements Serializable {
public String name;}

.. .
Grandpa Grandpa n = new ();
n.nome = "foo";
new ObjectOutputStream (new FileOutputStream ("date. txt ")). writeObject (n);
...

Grandpa writes the instance of the specified file "data.txt" in binary format, to get back the data you should do the reverse:
n = (Grandfather) new ObjectInputStream (new FileInputStream ("data.txt")). readObject ();

Serialization is a process complex and cumbersome for the system, since each object must be serialized for every variable, until you have only primitive types.
The following code throws exception java.io.NotSerializableException on line writeObject
NonnoNonSerializabile class implements Serializable {
     public String nome;
        public Object surname;
    }
...
    NonnoNonSerializabile n = new NonnoNonSerializabile();
    n.nome = "pippo";
    n.surname = new Object();
    new ObjectOutputStream(new FileOutputStream("data.txt")).writeObject(n);
...
I problemi con la serializzazione iniziano quando non abbiamo modo di rendere tutte le classi serializzabili; in quel caso possiamo solo rendere transient il campo colpevole, e implementare a mano il codice:
    private void writeObject(ObjectOutputStream os) {
        // codice per salvare il soprannome del nonno
    }
    private void readObject(ObjectInputStream is) {
        // codice per leggere il soprannome e memorizzarlo sul nonno
    }
così si risolve il problema delle classi non Serializable;

Dettagli importanti sulla serializzazione sono:
  • le variabili statiche non vengono mai serializzate.
  • se in una gerarchia di classi una classe non è serializabile, quando si restores the object will be calling the constructor of that class (and all the fathers);
  • not serialize objects must be marked transient (or receive an exception)
  • serialize arrays are, but must also be their content
The code examples shown here are

Lice Auctions Fredericton

API - API

Java APIs on Strings are

  • String StringBuffer StringBuilder
String
String a = "abc", / / \u200b\u200bcreates "abc" in the pool
String b = new String ("abc") / / creates a String variable heap, and "abc" in the pool
The second method creates a variable in more, better first.

methods you need to know for the certification are:
  1. charAt () - Returns the character at the given, "hello world". CharAt (2) returns 'a';
  2. concat () - equivalent to the operator "+"
  3. equalsIgnoreCase () - equivalent to toUpperCase (). equals (obj.toUpperCase ());
  4. length () - returns the length of the string
  5. replace () - Replaces a character in string
  6. with another substring () - returns a substring starting at the (start) until (end-1)
  7. toLowerCase () - returns a string with all lowercase characters
  8. toString () - returns the string ;
  9. toUpperCase () - returns a string with all uppercase characters
  10. trim () - returns a string with no spaces neither before nor after (ie remove all '\\ n', '', '\\ r')
StringBuilder
The only difference between StringBuffer and StringBuilder is che il secondo è stato introdotto per risolvere l'eccessiva pesantezza dello StringBuffer in contesti in cui la gestione dei Thread deve essere fatta esternamente; StringBuffer infatti è sincronizzato internamente, mentre StringBuilder non lo è (e quindi è più veloce).
Mostriamo subito un caso in cui la sincronizzazione interna non funziona:
1 - StringBuffer sb = new StringBuffer();
2 - sb.append("ciao");
3 - sb.append(" ");
4 - sb.append("mondo");
se avviamo due Thread e il primo esegue riga 1 e 2, poi la jvm lo blocca e avvia il secondo, che esegue 1,2,3,4, ci ritroviamo con la stringa "ciaociao mondo mondo" , sicuramente differente da ciò che volevamo noi; per questo motivo dobbiamo gestire la sincronizzazione esternamente, e possiamo evitare di usare lo StringBuffer , che è più pesante dello StringBuilder .

Metodi da conoscere per la certificazione:
  • append(String s) - accoda la stringa s al nostro buffer e restituisce il buffer
  • delete(int start, int end) - cancella una parte del testo (da posizione start a posizione end - 1 )
  • insert (int offset, String s) - inserts the string s position offset
  • reverse () - reverses the string
  • toString () - returns value as a string
The StringBu ** er and are often used by the String concatenation methods, certification examination will find many codes in the form:
String a = "hello world". toUpperCase () + "!!!"
StringBuilder sb = new StringBuilder (). Append ("hello"). Append (""). Append ("world"). Reverse ();
E' quindi importante capire come funziona, cioè che partendo da sinistra verso destra vengono eseguiti tutti i metodi, e viene restituito solo il valore finale.

Altre cosa importante da ricordare è che le stringhe sono immutabili e gli StringBuffer/Builder no; quindi le domande trabocchetto:
String a = "ciao";
System.out.println(a.concat(" mondo"));
System.out.println(a.concat("!!!"));
richiederanno attenzione, perché gli output sono "ciao mondo" e " ciao!!!" ;

Brazilian Wax Pic Before After

Strings - Dates and numbers

The part relating to dates and numbers of API in Java (for certification Programmer) covers the following classes:

  • Date
  • Calendar
  • Local
  • DateFormat
  • NumberFormat
these we can add the use of TimeZone for personal knowledge.

We recognize the potential and capabilities of each class:


Date
The Date class is almost completely deprecata; viene utilizzata per fare da tramite tra Calendar e DateFormat; non usatela mai direttamente (se i metodi sono deprecati un motivo ci sarà).
Calendar
Calendar si ottiene tramite Factory Method  (Calendar.getInstance(););
I metodi per ottenerla permettono di indicare un Locale , una TimeZone o entrambe; importante notare come il Locale non sia più modificabile in seguito, laddove esiste il metodo setTimeZone(..) per modificare la TimeZone .
Facile fare confusione per via di questi two objects and trying to better understand how they work:
Local:
indicates the location data for information such as first day of the week , number of weeks in and so forth does not affect in any way Calendar time zone;
TimeZone:
The timezone is used internally by the following methods:
  • get
  • September (...) (...)
If we execute The following code
Calendar it = Calendar.getInstance (TimeZone.getTimeZone ("Europe / Rome"));
us Calendar = Calendar.getInstance (TimeZone.getTimeZone ("America / Los_Angeles"));
System.out.println (it.get (Calendar.HOUR_OF_DAY));
System.out.println ( us.get (Calendar.HOUR_OF_DAY));
get
23
14
get because the method is affected by timezone. If instead eseguissimo
Calendar it = Calendar.getInstance (TimeZone.getTimeZone ("Europe / Rome"));
us Calendar = Calendar.getInstance (TimeZone.getTimeZone ("America / Los_Angeles"));
System.out.println (it.getTime ());
System.out.println (us . getTime ());
would get
Tue Oct 19 23:51:28 EDT 2010
Tue Oct 19 23:51:28 EDT 2010
this shows how get and September are affected by timezone, while getTime () not.

Calendar of important methods are:
  • September and get
  • add
  • roll
All four methods have the signature: add (int field, int amount) , where field indicates the type of field to work with, and amount the value of change, for example:
it.add (Calendar.DAY_OF_MONTH, 1);
System.out.println (it.getTime ());
it. add (Calendar.MONTH, 1);
System.out.println (it.getTime ());
it.add (Calendar.YEAR, 1);
System.out.println (it.getTime ());
and related:
Wed Oct 20 00:11:12 EDT 2010
Thu Oct 21 00:11:12 EDT 2010
Sun November 21 00:11:12 CET 2010
Mon November 21 00:11:12 CET 2011

method setLenient (boolean) makes the calculations more relaxed, so we
Calendar now = Calendar.getInstance (); now. set (2010, 12, 32); now.setLenient (false) System.out.println (now.get (Calendar.DAY_OF_MONTH)); / / exception java.lang.IllegalArgumentException: MONTH now.setLenient (true) ; System.out.println (now.get (Calendar.DAY_OF_MONTH)) / / correct


Local
indicates a specific geographical area, with values \u200b\u200bof their language, has two constructors main
  • Local (String language);
  • Local (String language, String country);
and there are also constant for each defined language and County system, the space is used to identify a place, and with Format allows you to display localized data (in the correct format, not with different values). The static method
Locale.getAvailableLocales () can get all defined on the local machine.
DateFormat
has three forms of Factory Method, depending on what you want to be given: date, time, date and time, we see directly the most complete of the three:
DateFormat df = DateFormat.getDateTimeInstance (DATESTYLE int, int timeStyle, Local aLocale)
the DateFormat is obtained at the site indicated, and shows more or less information (depending on style), we see in action:
Date d = Calendar.getInstance (). getTime ();
DateFormat dfS = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.ITALY);
DateFormat dfD = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, Locale.ITALY);
DateFormat dfL = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.ITALY);
DateFormat dfF = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, Locale.ITALY);
System.out.println(dfS.format(d));
System.out.println (dfD.format (d));
System.out.println (dfL.format (d));
System.out.println (dfF.format (d));
and its results:
20/10/10 00:03
20-Oct 2010 00:03:02
October 20, 2010 00:03:02 EDT
Wednesday, October 20, 2010 12:03:02 BST
as we see, are all shown at the site, we try to run one on a different local:
DateFormat = dfLUSA DateFormat.getDateTimeInstance (DateFormat.LONG, DateFormat.LONG, Locale.US)
System.out.println (dfLUSA.format (d));
and result:
October 20, 2010 12:04:57 AM EDT

Thus we see that the room varies only the type of data display, even if we change the time value, just use the TimeZone, just as with the Calendar:
DateFormat dfLUSA DateFormat.getDateTimeInstance = (DateFormat.LONG, DateFormat.LONG, Locale.US)
System.out.println (dfLUSA.format (d));
dfLUSA.setTimeZone (TimeZone.getTimeZone (" America / Los_Angeles "));
System.out.println (dfLUSA.format (d));
and Results:
October 20, 2010 12:07:05 AM EDT
October 19, 2010 3:07:05 PM PDT

The reverse logic applies to the method DateFormat.Parse (String), which takes a string and returns a Date associated, we see some examples:
DateFormat DateFormat.getDateTimeInstance dfs = (DateFormat.SHORT, DateFormat.SHORT, Locale.ITALY)
dfS.parse ds = Date ("20/10/10 12:11" ) / / returns a valid Date
Date dfS.parse ds2 = ("Wed Oct 20 00:13:55 EDT 2010") / / throw exception java.text.ParseException: Unparseable dates "Wed Oct 20 00:13:55 PDT 2010"
Pay attention to:
dfLUSA.parse (October 19, 2010 3:16:12 PM PDT ") / / correct
dfL.parse (October 19, 2010 3:16:12 PM PDT ") / / exception
since October is not recognized in the local Italian.
A utility method is setLenient (true) that makes parsing more relaxed, if we try to parse the date 40/12/2010 we get
NumberFormat
N umberFormat formatting includes three categories:
  • Numbers
NumberFormat = nFit NumberFormat.getNumberInstance (Locale.ITALY)
NumberFormat NFuse NumberFormat.getNumberInstance = (Locale.US)
NumberFormat = nfJA NumberFormat.getNumberInstance (Locale.JAPAN)
System.out.println (nfIT.format (12345.67890));
System.out.println (nfUS.format (12345.67890));
System.out.println (nfJA.format (12345.67890));
12,345.679 12,345.679
12,345.679
V ediamo now that the differences relate to the character of the thousands and decimal
  • Currencies
number format nfIT = NumberFormat.getCurrencyInstance (Locale.ITALY);
number format nfUS = NumberFormat.getCurrencyInstance (Locale.US);
number format nfJA NumberFormat.getCurrencyInstance = (Locale . JAPAN);
System.out.println (nfIT.format (12345.67890));
System.out.println (nfUS.format (12345.67890));
System.out.println ( nfJA.format (12345.67890));

€ 12,345.68
$ 12,345.68
? 12.346
Here we have two new features: the symbol of currency changes (and in the case of Japan we did not on the system), and in some cases we can not have decimal values \u200b\u200b(as in Italy, when we had the Lira)
  • Percentages
NumberFormat = nFit NumberFormat.getPercentInstance (Locale.ITALY) NumberFormat = NumberFormat.getPercentInstance NFuse (Locale.US)
NumberFormat = nfJA NumberFormat.getPercentInstance (Locale.JAPAN)
System.out.println (nfIT.format (12345.67890));
System.out.println (nfUS.format (12345.67890));
System.out.println (nfJA.format (12345.67890));
1,234,568% 1,234,568% 1,234,568%
The changes are equal to those numbers;

Even if the numbers we have a method NumberFormat.Parse (String) which follows the same logic DateFormat.Parse (String)

The code of these examples is contained in a single java file

Dunebuggyblueprints.com

Design Pattern: Factory Method Design Pattern

Factory Method
The Factory Method is a creational pattern, used for the instantiation of resources from a single access point, the best resource to start using it and look wikipedia.

The basic logic of the Factory Method is to provide an interface for creating an object.
Let's create a simple Factory, we start with our product:

class Product {
public String name;}

then with our interface that returns a product:
public interface Factory
{public abstract Product getProdotto ();
}
and finally the real class that actually produces the product:
FactoryImpl public class Factory implements {public
getProdotto Product () {
return new Product ();}
}

A customer who wants to use our will on the one subject a Server Factory and call the method getProdotto () to get a real instance.

The real code is here

Mount&blade Instruction Manuel

- Command

Design Pattern: Command
A First Look at wikipedia can tell us much of this pattern.

objects bearing the pattern are:

  • Subject Command - characterized by having a type and parameters to carry
  • Subject CommandType - a type associated with, usually implemented through enumeration.
The object is created (for example, associating the listener to a button) and sent to a system via Stream, the external system uses it directly without having to interpret numeric strings or held constant.

Good use of patterns is in the command handler in the client-server systems.


And here also sample code on the pattern

Kate Playground Sets Forum

RMI

The main documentation to know the RMI is: Oracle Java Tutorial

The main problems in the use of Socket for communication between client and server are related to:
  1. You must establish a port on which the Server listens (and the Client somehow has to know).
  2. It should establish a protocol between the two systems (and the implementation is left entirely to the programmer).
  3. There is no logic of object-oriented programming: the reasons for sending data (primitive or string), if you want to implement an object-oriented programming (see Using the Command Design Pattern is to be encoded manually.
  4. not exist controls to compile time, Client and Server are left to themselves in the management of a kind.
RMI (Remote Method Invocation) was established as a top layer based on Socket to provide programmers the ability to work in "objects" on remote systems.
The main drawback of MRI is related to the overhead implicit in its use:
  • To make transparent the communication must go through Java classes generated by (so-called stubs , which slows performance.
classes and interfaces used for MRI are:

Let's see how you actually use:

RMI system from the standpoint Server
first step to do is to define an interface defining what we can do on our Server object: public interface
OurServerObject extends Remote {
public boolean isInsideServer () throws RemoteException ;
public Date getDate () throws RemoteException;}

important point to remember is that our interfaces must be Remote and that any method defined must be able to launch RemoteException; this exception (type checked) can happen if:

  • Server is not active, unreachable, or communication with the client is finished
  • errors occurred during the marshaling of parameters or return values \u200b\u200b
This creates a class (real, not abstract) that will be used on the Server, and implement our interfaccia:
public class  OurServerObjectImpl  extends  UnicastRemoteObject implements OurServerObject  {
    public OurServerObjectImpl()  throws RemoteException  {
    }

    public boolean isInsideServer()  throws RemoteException {
        return true;
    }
    public Date getDate()   throws RemoteException {
        return Calendar.getInstance().getTime();
    }
}
Importante il costruttore vuoto perché verrà utilizzato nella creazione dell'oggetto (e deve poter lanciare l'eccezione RemoteException ); la nostra classe verrà utilizzata per creare l'oggetto remoto che i Client utilizzeranno;
Creiamo infine una istanza di Server che si occuperà di avviare il registro RMI e di registrare il nostro oggetto:
public class  Server  {
    public static void main(String [] args) throws RemoteException, MalformedURLException {
        java.rmi.registry.LocateRegistry.createRegistry(1099); //porta di default

        OurServerObjectImpl obj = new OurServerObjectImpl();
        
        //registra l'oggetto nel registro
Naming.rebind (OurFirstObject ", obj);}
}
Class Server will be launched command line will create our object, place it in the RMI registry and then ... waiting for the system will free the resources (and therefore will not be completed successfully!)
RMI system in terms of Client
A client can be any computer (remote or not) that is considered in a separate JVM; requirements to be able to use our remote system:

  1. know the address of the machine (such as IP or hostname)
  2. STOP!
As you can see, use a remote object is virtually nothing, we see a real class how to access the server object: public class Client
{public static void main (String [] args) throws MalformedURLException , RemoteException, NotBoundException {
System.out.println ("I get a reference to the server");

/ / get reference
OurServerObject obj = (OurServerObject) Naming.lookup (OurFirstObject ");

System.out.println (" We are in a server? -> "+ obj.isInsideServer ());
System.out.println (" Here's the date of the server: "+ obj.getDate ());}
}
Other important information about RMI: RMI
The system is based on a multi-threaded servers, each call The Server returns the object instance memory location, which means that it is for the busy schedule to manage every aspect to make the system thread-safe.
Our object extended UnicastRemoteObject , if we have a remote object that can not be changed in this respect, we can use in the constructor of our object a method call UnicastRemoteObject.exportObject (this) and remember to implement correct methods Object.hashcode () , Object.Equals (Object o) and Object.toString () .
From Java 1.5 onwards there is no need to create, using rmic stubs and skeletons, the system handles them automatically, unfortunately, for the certification, they must be created with rmic .
We used remote methods without being aware of a particular important: the parameters for the remote methods and return values \u200b\u200bmust be of type Serializable , this leads to several consequences which will be discussed in the paragraph relating to the interface.
objects that we send (and receive) can be:
  1. primitive types - in this case is made a copy ( pass-by-value )
  2. items - if they are not Serializable verrà lanciato NotSerializableException ; viene passato per valore (come i tipi primitivi)
  3. oggetti remoti - viene mandato lo stub (quindi per riferimento)
In generale gli oggetti che creiamo sul Server (e dentro gli oggetti remoti) possono essere:
  • Remote
  • UnicastRemoteObject
  • Serializable
Gli oggetti Remote sono oggetti che vengono considerati remoti; gli unici metodi che possono essere chiamati da un client sono i metodi definiti in un interfaccia Remote .
Gli oggetti UnicastRemoteObject sono tutti oggetti che vivono sul server; sono gli unici oggetti che rimangono sul server, e che restituiscono un riferimento quando ci viene restituita una istanza dell'oggetto.

Ecco anche il codice relativo all'esempio di RMI.
Ecco anche il codice relativo all'esempio di RMI usando un Factory Method.

Sympathy Quotes In Arabic



Ciao a tutti,

come promesso prima o poi sarei tornato a coltivare il mio Giardino, ed ora dopo un periodo di riflessione su molte cose ricomincio a scrivere su questi "fogli" raccontandovi le mie piccole esperienze miste a zen e oriente...