Linguaggi Corso M-Z - Laurea in Ingegneria Informatica A.A I/O, thread, socket in Java

Documenti analoghi
La Serializzazione in Java. L24_Serialization 1

Il linguaggio Java. Gli stream

A.A. 2006/2007 Laurea di Ingegneria Informatica. Fondamenti di C++ Horstmann Capitolo 3: Oggetti Revisione Prof. M. Angelaccio

IL GIOVANE HOLDEN FRANNY E ZOOEY NOVE RACCONTI ALZATE LARCHITRAVE CARPENTIERI E SEYMOUR INTRODUZIONE BY JD SALINGER

FISE Federazione Italiana Sport Equestri

I CAMBIAMENTI PROTOTESTO-METATESTO, UN MODELLO CON ESEMPI BASATI SULLA TRADUZIONE DELLA BIBBIA (ITALIAN EDITION) BY BRUNO OSIMO

AVERE 30 ANNI E VIVERE CON LA MAMMA BIBLIOTECA BIETTI ITALIAN EDITION

Fiori di campo. Conoscere, riconoscere e osservare tutte le specie di fiori selvatici più note

domenica 9 giugno 13 Serializzazione

Canti Popolari delle Isole Eolie e di Altri Luoghi di Sicilia (Italian Edition)

Activation In sintesi: è inutile avere attivi degli oggetti se non vengono utilizzati

Quando mi collego ad alcuni servizi hosting ricevo un messaggio relativo al certificato di protezione del sito SSL, come mai?

Java Virtual Machine (JVM)

LA SACRA BIBBIA: OSSIA L'ANTICO E IL NUOVO TESTAMENTO VERSIONE RIVEDUTA BY GIOVANNI LUZZI

100 consigli per vivere bene (Italian Edition)

LA SACRA BIBBIA: OSSIA L'ANTICO E IL NUOVO TESTAMENTO VERSIONE RIVEDUTA BY GIOVANNI LUZZI

Schemi di paginazione nell architettura 86 (32 e 64 bit)

Downloading and Installing Software Socio TIS

Introduzione alla storia dell intelligenza artificiale e della robotica

Marketing non Convenzionale: Viral, Guerrilla e prospettive future (Italian Edition)

Resources and Tools for Bibliographic Research. Search & Find Using Library Catalogues

UNIVERSITÀ DEGLI STUDI DI TORINO

L Articolo determinativo The Definite Article il, lo, la, l, i, gli, le the Is the noun singular? yes Is the noun masculine? yes

LA SACRA BIBBIA: OSSIA L'ANTICO E IL NUOVO TESTAMENTO VERSIONE RIVEDUTA BY GIOVANNI LUZZI

DICHIARAZIONE DI RESPONSABILITÀ

Web Services in Eclipse. Sistemi Informativi Aziendali A.A. 2011/2012

Introduzione all ambiente di sviluppo

Opera Aperta: Forma E Indeterminazione Nelle Poetiche Contemporanee (Tascabili Saggi) (Italian Edition) By Umberto Eco

Replacement of hose carrier chain

LA SACRA BIBBIA: OSSIA L'ANTICO E IL NUOVO TESTAMENTO VERSIONE RIVEDUTA BY GIOVANNI LUZZI

Italian 102 Daily Syllabus

LA SACRA BIBBIA: OSSIA L'ANTICO E IL NUOVO TESTAMENTO VERSIONE RIVEDUTA BY GIOVANNI LUZZI

Introduzione Kerberos. Orazio Battaglia

WELCOME. Go to the link of the official University of Palermo web site Click on the box on the right side Login unico

Lo sniffer. questo sconosciuto! Corso di Reti di Calcolatori Architetture e Servizi A.A. 2010/11. Introduzione allo sniffing TCP

ENGINE COMPONENT DESIGN Cap. 7 AIAA AIRCRAFT ENGINE DESIGN R03-23/10/2013

Esercizi (1-2): da: TCP/IP Sockets in C (Donahoo-Calvert)

Copyright 2012 Binary System srl Piacenza ITALIA Via Coppalati, 6 P.IVA info@binarysystem.eu

Una Ricerca Erboristica (Italian Edition)

Attraversamento di un albero (binario)

Risvolti patologici e allocazione rischio. Avv. Gennaro Mazzuoccolo Partner Banking Norton Rose Fulbright Studio Legale Roma 14 novembre 2013

A review of some Java basics. Java pass-by-value and List<> references

LA SACRA BIBBIA: OSSIA L'ANTICO E IL NUOVO TESTAMENTO VERSIONE RIVEDUTA BY GIOVANNI LUZZI

Introduction. The Structure of a Compiler

Musica e Dislessia: Aprire nuove porte (Italian Edition)

Il Piccolo Principe siamo noi: Adattamento teatrale per la scuola primaria (ABW. Antoine de Saint- Exupery) (Volume 1) (Italian Edition)

Insegna eco a muro. Production time: 2 to 6 working days. Tempi di produzione: da 2 a 6 giorni lavorativi AREA PER LA GRAFICA AREA FOR GRAPHICS

Sponsorship opportunities

Esercizi design patterns. Angelo Di Iorio,

Ansia e Attacchi di Panico - Breve Corso di Auto- Terapia per Risolvere il Problema (Italian Edition)

How to use the WPA2 encrypted connection


Mod INTERFACCIA USB/KEY USB/KEY INTERFACE. Sch./Ref.1067/003

LA SACRA BIBBIA: OSSIA L'ANTICO E IL NUOVO TESTAMENTO VERSIONE RIVEDUTA BY GIOVANNI LUZZI

BUON GIORNO RAGAZZI! Oggi è il 13 ottobre, 2015

CONFIGURATION MANUAL

FEROX. brand identity guidelines. Indice. Il logo The logo. Interazione con altri elementi grafici Use with other graphic elements

MOC10982 Supporting and Troubleshooting Windows 10

EC11 ANNO ACCADEMICO 2013/2014 CORSO DI LAUREA IN ECONOMIA, COMMERCIO INTERNAZIONALE e MERCATI FINANZIARI

LE MACRO DI EXCEL PER TUTTE PDF

REGISTRATION. Area Ricerca

Programmazione in Java e gestione della grafica. Lezione 24

Gocce d'anima (Italian Edition)

M-LOCK Serratura magnetica per porte in vetro a battente. M-LOCK Magnetic lock for glass swing doors

Guida all immatricolazione online

Get Instant Access to ebook D Lgs PDF at Our Huge Library D LGS PDF. ==> Download: D LGS PDF

Una storia italiana: Dal Banco Ambrosiano a Intesa Sanpaolo (Italian Edition)

Selection procedure. MASTER IN BUSINESS ADMINISTRATION - MBA (LM-77, 2-year postgraduate degree) AY 2017/18

SISTEMI OPERATIVI. Sincronizzazione in Java (Semafori e barriere) Patrizia Scandurra (MODULO DI INFORMATICA II) LABORATORIO

WEB MARKETING PER LE PMI PDF

Il Piccolo Principe siamo noi: Adattamento teatrale per la scuola primaria (ABW. Antoine de Saint- Exupery) (Volume 1) (Italian Edition)

User s Manual Modbus Protocol

UNIVERSITÀ DEGLI STUDI DI TORINO. Guidelines to ONLINE exams registration Version 02 updated on

Coaching (Italian Edition)

La Certosa di Parma (Emozioni senza tempo) (Italian Edition)

Si usa. Lesson 14 (B1/B2) Present perfect simple / Present perfect continuous

INSTALLAZIONE INSTALLATION

Ingegneria del Software 9. Macchine a stati. Dipartimento di Informatica Università di Pisa A.A. 2014/15

Per il progetto MESA 2015 andremo ad utilizzare Unity3D per la creazione di alcuni exergame da utilizzar ein ambito riabilitativo.

APP INVENTOR 2 CON DATABASE MYSQL (ITALIAN EDITION) BY ANTONIO TACCETTI

MySQL per amministratori di database

Arcadja Report Sebastiano Conca

CCTV DIVISION. Guida Alla Lettura del Numero Seriale, Codice Prodotto, Versione Firmware, Versione Software, Codice Libretto

A.S. 2011/2012. Circuito semaforico da incrocio. Corso di Elettronica. Dipartimento di Elettrotecnica

sdforexcontest2009 Tool

Gruppo di lavoro 1 Metadati e RNDT. Incontro del 22 luglio 2014

Arcadja Report Armando Pizzinato

LE IMPOSTE SULLA COMPRAVENDITA PDF

Guida utente User Manual made in Italy Rev0

Introduzione ai Web Services Alberto Polzonetti

I Cilindri dei Faraoni Egiziani: Il potere degli dei in una antica tecnologia egizia (Italian Edition)

ISTITUTO MAGISTRALE STATALE LEONARDO DA VINCI ALBA (CN) a.s

Newborn Upfront Payment & Newborn Supplement

Arcadja Report Giulio Turcato

L'euro (Farsi un'idea) (Italian Edition)

D.SSA ANGELICA BONFANTI INVESTIMENTI STRANIERI IN CINA, TRA TRATTATI BILATERALI D INVESTIMENTO E STANDARD INTERNAZIONALI

Utilizzare il NetBeans GUI Builder. Dott. Ing. M. Banci, PhD

15 Domande sui Social Media (Italian Edition)

UNA COMUNITA LEGGE VANGELO PDF

Il mio bambino non vede bene: Come orientarsi tra occhiali, lenti a contatto, ginnastica oculare, alimentaizone (Italian Edition)

Transcript:

Linguaggi Corso M-Z - Laurea in Ingegneria Informatica A.A. 2009-2010 Alessandro Longheu http://www.diit.unict.it/users/alongheu alessandro.longheu@diit.unict.it Esercitazione I/O, thread, socket in Java 1

Esempio 1 File.ZIP Realizzare un programma che, dato in ingresso il nome di una directory, crei un file.zip e lo invii successivamente via rete ad un server che lo salva sul proprio file system Realizzare l applicazione prima con un socket connection-oriented (socket stream), poi con un socket connection-less (datagram) Esempi su creazione file zip nella directory (8), mentre per la creazione di socket datagram directory (3) 2

Esempio 2 - Serializzazione Serializability of a class is enabled by the class implementing the java.io.serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface has no methods or fields and serves only to identify the semantics of being serializable. During deserialization, the fields of non-serializable classes will be initialized using the public or protected no-arg constructor of the class. A no-arg constructor must be accessible to the subclass that is serializable. The fields of serializable subclasses will be restored from the stream. When traversing a graph, an object may be encountered that does not support the Serializable interface. In this case the NotSerializableException will be thrown and will identify the class of the non-serializable object. 3

Esempio 2 - Serializzazione For an object to be serialized, it must be an instance of a class that implements either the Serializable or Externalizable interface. Both interfaces only permit the saving of data associated with an object's variables. They depend on the class definition being available to the Java Virtual Machine at reconstruction time in order to construct the object. The Serializable interface relies on the Java runtime default mechanism to save an object's state. Writing an object is done via the writeobject() method. Reading the serialized object is accomplished using the readobject() method. What about other objects that may be referred to by the object we are serializing? For instance, what if our object is a Frame containing a set of (AWT) Panel and TextArea instance variables? Using the Serializable interface, these references (and their associated data) also are converted and written to the stream. All state information necessary to reconstruct our Frame object and any objects that it references gets stored together. If those other objects or their formats weren't stored, our reconstructed Frame would contain null object references, and the content of those Panels and TextAreas would be gone. Plus, any methods that rely on the existence of the Panels or TextAreas would throw exceptions. 4

Esempio 2 - Serializzazione The Externalizable interface specifies that the implementing class will handle the serialization on its own, instead of relying on the default runtime mechanism. This includes which fields get written (and read), and in what order. The class must define a writeexternal() method to write out the stream, and a corresponding readexternal() method to read the stream. Inside of these methods the class calls ObjectOutputStream writeobject(), ObjectInputStream readobject(), and any necessary write<datatype>() and read<datatype>() methods, for the desired fields. Esempio di serializzazione nella directory (9) 5

Esempio 2 - Serializzazione Creare un programma che permetta la gestione di un log di accessi ad un sistema: Definire la struttura di base del singolo log Scegliere la struttura dati per l insieme dei log Permettere di serializzare la struttura dati cosi definita, potendo scegliere di serializzare la struttura dati sia in formato testo, che binario, che utilizzando la serializzazione Controllare infine e stampare l occupazione di memoria su disco delle tre possibilità del punto precedente 6

Esempio 2 Diversi esempi sulla programmazione con i Thread e con Socket: Esempio generale di impostazione thread (directory (1)) Esempio generale di socket (directory (2)) Esempio di socket stream e datagram (directory (3)) Particolarità sui thread (directory (4)) problema cinque filosofi + due varianti (directory (5)) problema cinque filosofi senza deadlock (directory (6)) daemon con redirection compito 260107 (directory (7)) 7

Esempio 3 Si realizzi un programma che lancia n thread per cercare un elemento in una matrice di n per n elementi. Ognuno dei thread cerca l'elemento in una delle righe della matrice. Non appena un thread ha trovato l'elemento cercato, rende note agli altri thread le coordinate dell'elemento e tutti i thread terminano. Risolvere il problema dei cinque filosofi 8