SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
OurMovies
                       Christoph Pickl




                              1
Friday, July 4, 2008                     1
Agenda
                       1. OurMovies - Das Programm kurz vorgestellt
                       2. SwingX - Die Zukunft von Swing; bereits jetzt
                       3. QTJ - QuickTime Integration für Java
                       4. db4o - Eine objektorientierte Datenbank



                                               2
Friday, July 4, 2008                                                      2
Profil

             •         Christoph Pickl

             •         22 Jahre, Wien (urspr. Bgld)

             •         Bakk. Software Engineering

             •         Java Entwickler bei Erste Bank

             •         DJ bei Hörspiel Crew



                                                      3
Friday, July 4, 2008                                      3
OurMovies



                           4
Friday, July 4, 2008               4
OurMovies ist ...

              • ... ein weiteres Tool um Videos zu verwalten
              • ... ein Video-Player (QuickTime vorausgesetzt)
              • ... OpenSource und auf SourceForge gehosted
              • ... dem Look&Feel von iTunes nachempfunden
                       ... entstandem aus dem einfachen Wunsch heraus,
                       den Prozess des Sharings zu vereinfachen:

                       1. HTML-Report erstellen
                       2. HTML verschicken und sich IDs schicken lassen (zb: “[[31,53,84]]”)
                       3. mit SmartCopy Filme einfach anhand IDs kopieren (auf externe HD)
                       4. vorbereitete externe HD mitnehmen
                                                                             5
Friday, July 4, 2008                                                                           5
Metriken
                           Modul         Klassen    LoC

                          omovApp         173      12,193

                          omovCore        143      9,065

                       omovQtjApi/Impl     19      1,399

                       omovWebApi/Impl     7        689

                          Summe           342      23,346
                                                    App == rein die aufgesetzte GUI
                                                    Core == BusinessLogik & Co

                                                    -> viel Zeit in die GUI investiert
                                            6
Friday, July 4, 2008                                                                     6
Keyfeatures
                        •     Metadata Fetching

                        •     SmartFolder

                        •     SmartCopy

                        •     QuickView

                       * Remote Feature in arbeit (mit v2.0 verfügbar)
                         ... Filme über’s Netzwerk synchronisieren
                         ... nur Wunschliste (IDs für SmartCopy) erstellen
                            keine Übermittlung der Filmdateien selbst (zaaach)


                                                                                 7
Friday, July 4, 2008                                                                 7
8
Friday, July 4, 2008       8
9
Friday, July 4, 2008       9
SwingX



                         10
Friday, July 4, 2008            10
Enhanced Components
                       • Sorting/Filtering for Tables/Trees/Lists
                       • Find/Search
                       • Auto-Completion
                       • Login/authentication framework
                       • Date picker component
                       • Drop Shadows, Translucency, ...
                                              11
Friday, July 4, 2008                                                11
12
Friday, July 4, 2008        12
JXTable vs JTable
                       • Alternierende Hintergrundfarbe der Zeilen
                       • Tabellenspalten ein-/ausblenden
                       • Nach Spalten sortieren (Indizes?!)
                       • Tabellenhintergrund “weiterzeichnen”
                       • Vertikale Linien des Grids zeichnen

                                           13
Friday, July 4, 2008                                                 13
Auto-Completion

                       • Vorschläge für JTextField/JComboBox/JList
                       • strikte und nicht-strikte Vorschläge
                       • Vorgeschlagener Text vormarkiert


                                            14
Friday, July 4, 2008                                                 14
QTJ



                        15
Friday, July 4, 2008         15
QuickTime for Java
                       • Plattform-unabhängige API
                       • Manipulieren von Bildern/Audio/Video
                       • Erstellung von 2D/3D-Animationen
                       • Integration von QuickTime Funktionalität,
                         nicht reines API für die Anwendung selbst



                                            16
Friday, July 4, 2008                                                 16
QTSession.open();

           File file = new File(quot;/some_movie.mpgquot;);
           OpenMovieFile openMovieFile =
               OpenMovieFile.asRead(new QTFile(file));
           Movie movie = Movie.fromFile(openMovieFile);

           MoviePlayer player = new MoviePlayer(movie);
           QTJComponent qtjPlayer = QTFactory.makeQTJComponent(player);
           JComponent playerComponent = qtjPlayer.asJComponent();

           JPanel somePanel = new JPanel();
           somePanel.add(playerComponent);

           // ...

           QTSession.close();
                                MovieController controller = new MovieController(movie);
                                controller.setKeysEnabled(true);
                                QTComponent qtControllerComponent = QTFactory.makeQTComponent(controller);
                                Component controllerComponent = qtControllerComponent.asComponent();

                                                   17
Friday, July 4, 2008                                                                                         17
db4o



                        18
Friday, July 4, 2008          18
db4o ist ...
                       • ... OpenSource (+ kommerzielle Lizenz)
                       • ... für Java und .Net (C#) verfügbar
                       • ... einfach installiert/konfiguriert/verwendet
                        • Jar runterladen und in den Klassenpfad
                        • Keine Konfiguration/Treiber/Mappingfiles
                         •   Db4o.openFile(“db.yap”).set(new Object());



                                              19
Friday, July 4, 2008                                                      19
Wie geeignet sind RDBMS für OOP?



                                 - komplexe Objekte in flache Relationen
                                 - Mapping ist mühevoll/lästig/umständlich (trotz Hibernate & Co)
                                 - wir kennen alle RDBMS, deshalb benützen wir sie (weil wir sie gewohnt sind)
                                 - performance von RDBMS ist aber -derzeit- besser als von OODBMS




                                                  20
Friday, July 4, 2008                                                                                             20
Erste Schritte
           package at.ac.tuwien.e0525580.jsuga;

           import com.db4o.*;

           public class Db4oFirstSteps {
             public static void main(String[] args) {
               ObjectContainer db = Db4o.openFile(quot;db.yapquot;);
               try {
                 // database operations
               } finally {
                 db.close();
               }
             }
           }




                                         21
Friday, July 4, 2008                                           21
Datenmodell
                       (einfaches)




                                      22
Friday, July 4, 2008                               22
Insert/Update/Delete
           // insert
           Person person = new Person(“Anna”, “Nym”);
           db.set(person);


           // update
           person.setLastName(“Nüm”);
           db.set(person);


                                                  nicht ganz so einfach,
           // delete
                                                  da es haken gibt bzgl ObjektIdentität!
           db.delete(person);
                                                  woher weiss db4o welches objekt gemeint ist,
                                                  ohne primary key (int ID) ?




                                         23
Friday, July 4, 2008                                                                             23
Abfragesprachen
                       1. QbE (Query by Example)
                        •  Abfrage anhand eines Prototyps
                       2. SODA (Simple Object Database Access)
                        •  Verknüpfung von Constraints
                       3. NQ (Native Queries)
                        •  Filterung durch Predicate Interface


                                           24
Friday, July 4, 2008                                             24
QbE - Simple Select
           // fetch all objects by given Class instance
           ObjectSet<Person> result = db.get(Person.class);

           // ObjectSet implements List and Iterable interface
           // therefore foreach loop can be used
           for(Person p : result) {

                // process persons (and students!)

           }




                                            25
Friday, July 4, 2008                                             25
QbE - By Example
           // default values (null, false, 0, 0.0) will be ignored
           Person prototype = new Person(“Anna”, null);

           // pass ObjectContainer the example
           ObjectSet<Person> result = db.get(prototype);

           while(result.hasNext()) {
             Person p = result.next();
             // process every person with firstName equals “Anna”
           }




                                         26
Friday, July 4, 2008                                                 26
SODA - Simple Select
           // create a Query object (obtained from ObjectContainer)
           Query query = db.query();

           // define a constrain
           query.constrain(Student.class);

           // result contains all students
           ObjectSet<Student> result = query.execute();




                                              - abstrakte Spezifikation durch Constrain-Graph
                                              - ...




                                         27
Friday, July 4, 2008                                                                           27
SODA - Where Clause
           Query query = db.query();

           query.constrain(Student.class);

           // no getters necessary (private variables are accessible)
           query.descend(“firstName”).constrain(“Anna”);

           // will be and-connected with previous constrain (default)
           query.descend(“matrNr”).constrain(525580).or(
                query.descend(“matrNr”).constrain(525581)
             );

           ObjectSet<Student> result = query.execute();




                                         28
Friday, July 4, 2008                                                    28
SODA - Where Clause
           // SELECT *
           Query query = db.query();

           // FROM student
           query.constrain(Student.class);

           // WHERE firstName like ‘A%’
           query.descend(“firstName”).constrain(“A”).startsWith(true);
           // AND matrNr >= 500000
           query.descend(“matrNr”).constrain(500000).greater().equal();
           // ORDER BY lastName ASC
           query.descend(“lastName”).orderAscending();

           ObjectSet<Student> result = query.execute();




                                         29
Friday, July 4, 2008                                                      29
SODA - Evaluation
           Query query = db.query();

           query.constrain(Student.class);
           query.constrain(new Evaluation() {
             public void evaluate(Candidate candidate) {
               Student student = (Student) candidate.getObject();
               boolean match = (student.getMatrNr() >= 500000);
               candidate.include(match)
             }
           });

           // performance of Evaluation mechanism is very bad :(
           ObjectSet<Student> result = query.execute();




                                         30
Friday, July 4, 2008                                                30
NQ - Simple Select
           ObjectSet<Person> result = db.query(
              new Predicate<Person>() {
                public boolean match(Person candidate) {
                  return candidate.getFirstName().startsWith(“A”);
                  // or fetch all: return true;
                }
              }
           );




                                              - NQ wird (optional) in äquivalente SODA-Darstellung transformiert
                                                -> NQ sind auch gegen Feldindizes ausführbar



                                         31
Friday, July 4, 2008                                                                                               31
NQ - Sortiert
           Predicate<Student> predicate = new Predicate<Student>() {
              public boolean match(Student candidate) {
                boolean matched =
                  candidate.getMatrNr() >= 500000 &&
                  candidate.getMatrNr() < 600000;
                return matched;
              }
           };
           Comparator<Student> comparator = new Comparator<Student>() {
              public int compare(Student s1, Student s2) {
                return s1.getLastName().compareTo(s2.getLastName());
              }
           };
           ObjectSet<Student> result = db.query(predicate, comparator);




                                         32
Friday, July 4, 2008                                                      32
+                                    -
         QbE                 einfach zu erlernen           nicht nach Defaultwerte suchbar

                                                              äußerst ausdrucksschwach

                                                               Attributname als Strings
      SODA               Feldindizes werden genutzt
                                                             (Tippfehler erst zur Laufzeit)

                         etwas performanter als NQ           bricht das Geheimnisprinzip

                       in Programmiersprache definiert        viel Schreibarbeit notwendig
         NQ
                        (Typsicherheit, refaktorisierbar) (evtl mit Java 7 closures verfübar)

                             sehr ausdrucksstark



                                                    33
Friday, July 4, 2008                                                                            33
Konfiguration - Global
           Configuration config = Db4o.configure();

           config.generateUUIDs(Integer.MAX_VALUE);
           config.detectSchemaChanges(true);
           config.callConstructors(true);
           config.messageLevel(2);
           config.readOnly(false);
           config.exceptionsOnNotStorable(true);
           config.optimizeNativeQueries(true);
           config.setBlobPath(“/db4o/blob/path”);
           // ...

           // open db-file afterwards!
           ObjectContainer db = Db4o.openFile(“db4o.yap”);




                                         34
Friday, July 4, 2008                                         34
Konfiguration - Objekte
           Configuration config = Db4o.configure();

           config.objectClass(Person.class).cascadeOnActivate(true);
           config.objectClass(Person.class).cascadeOnUpdate(true);
           config.objectClass(Person.class).cascadeOnDelete(true);
           config.objectClass(Person.class).storeTransientFields(true);
           config.objectClass(Person.class).
             objectField(“lastName”).indexed(true);
           // ...

           // open db-file afterwards!
           ObjectContainer db = Db4o.openFile(“db4o.yap”);   - gibt auch Annotation “Indexed”

                                                             public class Person {
                                                              @Indexed
                                                              private String firstName;
                                                             }




                                         35
Friday, July 4, 2008                                                                            35
ObjectManager




                             36
Friday, July 4, 2008                   36
Offene Themen
                       •   Aktivierungstiefe




                                                        ???
                       •   Objektidentität

                       •   Transaktionen

                       •   Server
                           (embedded/networking)


                       •   ...



                                                   37
Friday, July 4, 2008                                          37
Links
                       http://omov.sourceforge.net
                       http://db4o.com
                       http://swinglabs.org
                       http://developer.apple.com/quicktime/qtjava



                                              38
Friday, July 4, 2008                                                 38
JavaDeus
                       • 19. Juni 2008
                       • FH St. Pölten (gratis Bustransfer)
                       • keine Teilnahmegebühr
                       • Präsentation von
           http://at.sun.com/sunnews/events/2008/jun/javadeus08/

                                             39
Friday, July 4, 2008                                               39

Weitere ähnliche Inhalte

Mehr von Christoph Pickl

JSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklJSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklChristoph Pickl
 
JSUG - TeX, LaTeX und der Rest by Norbert Preining
JSUG - TeX, LaTeX und der Rest by Norbert PreiningJSUG - TeX, LaTeX und der Rest by Norbert Preining
JSUG - TeX, LaTeX und der Rest by Norbert PreiningChristoph Pickl
 
JSUG - Java Service Enabler by Andreas Hubmer
JSUG - Java Service Enabler by Andreas HubmerJSUG - Java Service Enabler by Andreas Hubmer
JSUG - Java Service Enabler by Andreas HubmerChristoph Pickl
 
JSUG - Hoppla by Florian Motlik and Petar Petrov
JSUG - Hoppla by Florian Motlik and Petar PetrovJSUG - Hoppla by Florian Motlik and Petar Petrov
JSUG - Hoppla by Florian Motlik and Petar PetrovChristoph Pickl
 
JSUG - Google Web Toolkit by Hans Sowa
JSUG - Google Web Toolkit by Hans SowaJSUG - Google Web Toolkit by Hans Sowa
JSUG - Google Web Toolkit by Hans SowaChristoph Pickl
 
JSUG - TU Wien Cocoon Project by Andreas Pieber
JSUG - TU Wien Cocoon Project by Andreas PieberJSUG - TU Wien Cocoon Project by Andreas Pieber
JSUG - TU Wien Cocoon Project by Andreas PieberChristoph Pickl
 
JSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas LangJSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas LangChristoph Pickl
 
JSUG - LaTeX Introduction by Christoph Pickl
JSUG - LaTeX Introduction by Christoph PicklJSUG - LaTeX Introduction by Christoph Pickl
JSUG - LaTeX Introduction by Christoph PicklChristoph Pickl
 
JSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael GreifenederJSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael GreifenederChristoph Pickl
 
JSUG - Seam by Florian Motlik
JSUG - Seam by Florian MotlikJSUG - Seam by Florian Motlik
JSUG - Seam by Florian MotlikChristoph Pickl
 
JSUG - Google Guice by Jan Zarnikov
JSUG - Google Guice by Jan ZarnikovJSUG - Google Guice by Jan Zarnikov
JSUG - Google Guice by Jan ZarnikovChristoph Pickl
 
JSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklJSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklChristoph Pickl
 
JSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklJSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklChristoph Pickl
 
JSUG - Inversion Of Control by Florian Motlik
JSUG - Inversion Of Control by Florian MotlikJSUG - Inversion Of Control by Florian Motlik
JSUG - Inversion Of Control by Florian MotlikChristoph Pickl
 
JSUG - QTJambi by Jan Zarnikov
JSUG - QTJambi by Jan ZarnikovJSUG - QTJambi by Jan Zarnikov
JSUG - QTJambi by Jan ZarnikovChristoph Pickl
 
JSUG - Bazaar by Florian Motlik
JSUG - Bazaar by Florian MotlikJSUG - Bazaar by Florian Motlik
JSUG - Bazaar by Florian MotlikChristoph Pickl
 
JSUG - Effective Java Puzzlers by Christoph Pickl
JSUG - Effective Java Puzzlers by Christoph PicklJSUG - Effective Java Puzzlers by Christoph Pickl
JSUG - Effective Java Puzzlers by Christoph PicklChristoph Pickl
 
JSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael GreifenederJSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael GreifenederChristoph Pickl
 
JSUG - RESTful Web Services by Florian Motlik
JSUG - RESTful Web Services by Florian MotlikJSUG - RESTful Web Services by Florian Motlik
JSUG - RESTful Web Services by Florian MotlikChristoph Pickl
 
JSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael GreifenederJSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael GreifenederChristoph Pickl
 

Mehr von Christoph Pickl (20)

JSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph PicklJSUG - AS3 vs Java by Christoph Pickl
JSUG - AS3 vs Java by Christoph Pickl
 
JSUG - TeX, LaTeX und der Rest by Norbert Preining
JSUG - TeX, LaTeX und der Rest by Norbert PreiningJSUG - TeX, LaTeX und der Rest by Norbert Preining
JSUG - TeX, LaTeX und der Rest by Norbert Preining
 
JSUG - Java Service Enabler by Andreas Hubmer
JSUG - Java Service Enabler by Andreas HubmerJSUG - Java Service Enabler by Andreas Hubmer
JSUG - Java Service Enabler by Andreas Hubmer
 
JSUG - Hoppla by Florian Motlik and Petar Petrov
JSUG - Hoppla by Florian Motlik and Petar PetrovJSUG - Hoppla by Florian Motlik and Petar Petrov
JSUG - Hoppla by Florian Motlik and Petar Petrov
 
JSUG - Google Web Toolkit by Hans Sowa
JSUG - Google Web Toolkit by Hans SowaJSUG - Google Web Toolkit by Hans Sowa
JSUG - Google Web Toolkit by Hans Sowa
 
JSUG - TU Wien Cocoon Project by Andreas Pieber
JSUG - TU Wien Cocoon Project by Andreas PieberJSUG - TU Wien Cocoon Project by Andreas Pieber
JSUG - TU Wien Cocoon Project by Andreas Pieber
 
JSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas LangJSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas Lang
 
JSUG - LaTeX Introduction by Christoph Pickl
JSUG - LaTeX Introduction by Christoph PicklJSUG - LaTeX Introduction by Christoph Pickl
JSUG - LaTeX Introduction by Christoph Pickl
 
JSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael GreifenederJSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael Greifeneder
 
JSUG - Seam by Florian Motlik
JSUG - Seam by Florian MotlikJSUG - Seam by Florian Motlik
JSUG - Seam by Florian Motlik
 
JSUG - Google Guice by Jan Zarnikov
JSUG - Google Guice by Jan ZarnikovJSUG - Google Guice by Jan Zarnikov
JSUG - Google Guice by Jan Zarnikov
 
JSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph PicklJSUG - Java FX by Christoph Pickl
JSUG - Java FX by Christoph Pickl
 
JSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph PicklJSUG - Tech Tips1 by Christoph Pickl
JSUG - Tech Tips1 by Christoph Pickl
 
JSUG - Inversion Of Control by Florian Motlik
JSUG - Inversion Of Control by Florian MotlikJSUG - Inversion Of Control by Florian Motlik
JSUG - Inversion Of Control by Florian Motlik
 
JSUG - QTJambi by Jan Zarnikov
JSUG - QTJambi by Jan ZarnikovJSUG - QTJambi by Jan Zarnikov
JSUG - QTJambi by Jan Zarnikov
 
JSUG - Bazaar by Florian Motlik
JSUG - Bazaar by Florian MotlikJSUG - Bazaar by Florian Motlik
JSUG - Bazaar by Florian Motlik
 
JSUG - Effective Java Puzzlers by Christoph Pickl
JSUG - Effective Java Puzzlers by Christoph PicklJSUG - Effective Java Puzzlers by Christoph Pickl
JSUG - Effective Java Puzzlers by Christoph Pickl
 
JSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael GreifenederJSUG - Maven by Michael Greifeneder
JSUG - Maven by Michael Greifeneder
 
JSUG - RESTful Web Services by Florian Motlik
JSUG - RESTful Web Services by Florian MotlikJSUG - RESTful Web Services by Florian Motlik
JSUG - RESTful Web Services by Florian Motlik
 
JSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael GreifenederJSUG - Scala Lightning Talk by Michael Greifeneder
JSUG - Scala Lightning Talk by Michael Greifeneder
 

JSUG - OurMovies by Christoph Pickl

  • 1. OurMovies Christoph Pickl 1 Friday, July 4, 2008 1
  • 2. Agenda 1. OurMovies - Das Programm kurz vorgestellt 2. SwingX - Die Zukunft von Swing; bereits jetzt 3. QTJ - QuickTime Integration für Java 4. db4o - Eine objektorientierte Datenbank 2 Friday, July 4, 2008 2
  • 3. Profil • Christoph Pickl • 22 Jahre, Wien (urspr. Bgld) • Bakk. Software Engineering • Java Entwickler bei Erste Bank • DJ bei Hörspiel Crew 3 Friday, July 4, 2008 3
  • 4. OurMovies 4 Friday, July 4, 2008 4
  • 5. OurMovies ist ... • ... ein weiteres Tool um Videos zu verwalten • ... ein Video-Player (QuickTime vorausgesetzt) • ... OpenSource und auf SourceForge gehosted • ... dem Look&Feel von iTunes nachempfunden ... entstandem aus dem einfachen Wunsch heraus, den Prozess des Sharings zu vereinfachen: 1. HTML-Report erstellen 2. HTML verschicken und sich IDs schicken lassen (zb: “[[31,53,84]]”) 3. mit SmartCopy Filme einfach anhand IDs kopieren (auf externe HD) 4. vorbereitete externe HD mitnehmen 5 Friday, July 4, 2008 5
  • 6. Metriken Modul Klassen LoC omovApp 173 12,193 omovCore 143 9,065 omovQtjApi/Impl 19 1,399 omovWebApi/Impl 7 689 Summe 342 23,346 App == rein die aufgesetzte GUI Core == BusinessLogik & Co -> viel Zeit in die GUI investiert 6 Friday, July 4, 2008 6
  • 7. Keyfeatures • Metadata Fetching • SmartFolder • SmartCopy • QuickView * Remote Feature in arbeit (mit v2.0 verfügbar) ... Filme über’s Netzwerk synchronisieren ... nur Wunschliste (IDs für SmartCopy) erstellen keine Übermittlung der Filmdateien selbst (zaaach) 7 Friday, July 4, 2008 7
  • 10. SwingX 10 Friday, July 4, 2008 10
  • 11. Enhanced Components • Sorting/Filtering for Tables/Trees/Lists • Find/Search • Auto-Completion • Login/authentication framework • Date picker component • Drop Shadows, Translucency, ... 11 Friday, July 4, 2008 11
  • 13. JXTable vs JTable • Alternierende Hintergrundfarbe der Zeilen • Tabellenspalten ein-/ausblenden • Nach Spalten sortieren (Indizes?!) • Tabellenhintergrund “weiterzeichnen” • Vertikale Linien des Grids zeichnen 13 Friday, July 4, 2008 13
  • 14. Auto-Completion • Vorschläge für JTextField/JComboBox/JList • strikte und nicht-strikte Vorschläge • Vorgeschlagener Text vormarkiert 14 Friday, July 4, 2008 14
  • 15. QTJ 15 Friday, July 4, 2008 15
  • 16. QuickTime for Java • Plattform-unabhängige API • Manipulieren von Bildern/Audio/Video • Erstellung von 2D/3D-Animationen • Integration von QuickTime Funktionalität, nicht reines API für die Anwendung selbst 16 Friday, July 4, 2008 16
  • 17. QTSession.open(); File file = new File(quot;/some_movie.mpgquot;); OpenMovieFile openMovieFile = OpenMovieFile.asRead(new QTFile(file)); Movie movie = Movie.fromFile(openMovieFile); MoviePlayer player = new MoviePlayer(movie); QTJComponent qtjPlayer = QTFactory.makeQTJComponent(player); JComponent playerComponent = qtjPlayer.asJComponent(); JPanel somePanel = new JPanel(); somePanel.add(playerComponent); // ... QTSession.close(); MovieController controller = new MovieController(movie); controller.setKeysEnabled(true); QTComponent qtControllerComponent = QTFactory.makeQTComponent(controller); Component controllerComponent = qtControllerComponent.asComponent(); 17 Friday, July 4, 2008 17
  • 18. db4o 18 Friday, July 4, 2008 18
  • 19. db4o ist ... • ... OpenSource (+ kommerzielle Lizenz) • ... für Java und .Net (C#) verfügbar • ... einfach installiert/konfiguriert/verwendet • Jar runterladen und in den Klassenpfad • Keine Konfiguration/Treiber/Mappingfiles • Db4o.openFile(“db.yap”).set(new Object()); 19 Friday, July 4, 2008 19
  • 20. Wie geeignet sind RDBMS für OOP? - komplexe Objekte in flache Relationen - Mapping ist mühevoll/lästig/umständlich (trotz Hibernate & Co) - wir kennen alle RDBMS, deshalb benützen wir sie (weil wir sie gewohnt sind) - performance von RDBMS ist aber -derzeit- besser als von OODBMS 20 Friday, July 4, 2008 20
  • 21. Erste Schritte package at.ac.tuwien.e0525580.jsuga; import com.db4o.*; public class Db4oFirstSteps { public static void main(String[] args) { ObjectContainer db = Db4o.openFile(quot;db.yapquot;); try { // database operations } finally { db.close(); } } } 21 Friday, July 4, 2008 21
  • 22. Datenmodell (einfaches) 22 Friday, July 4, 2008 22
  • 23. Insert/Update/Delete // insert Person person = new Person(“Anna”, “Nym”); db.set(person); // update person.setLastName(“Nüm”); db.set(person); nicht ganz so einfach, // delete da es haken gibt bzgl ObjektIdentität! db.delete(person); woher weiss db4o welches objekt gemeint ist, ohne primary key (int ID) ? 23 Friday, July 4, 2008 23
  • 24. Abfragesprachen 1. QbE (Query by Example) • Abfrage anhand eines Prototyps 2. SODA (Simple Object Database Access) • Verknüpfung von Constraints 3. NQ (Native Queries) • Filterung durch Predicate Interface 24 Friday, July 4, 2008 24
  • 25. QbE - Simple Select // fetch all objects by given Class instance ObjectSet<Person> result = db.get(Person.class); // ObjectSet implements List and Iterable interface // therefore foreach loop can be used for(Person p : result) { // process persons (and students!) } 25 Friday, July 4, 2008 25
  • 26. QbE - By Example // default values (null, false, 0, 0.0) will be ignored Person prototype = new Person(“Anna”, null); // pass ObjectContainer the example ObjectSet<Person> result = db.get(prototype); while(result.hasNext()) { Person p = result.next(); // process every person with firstName equals “Anna” } 26 Friday, July 4, 2008 26
  • 27. SODA - Simple Select // create a Query object (obtained from ObjectContainer) Query query = db.query(); // define a constrain query.constrain(Student.class); // result contains all students ObjectSet<Student> result = query.execute(); - abstrakte Spezifikation durch Constrain-Graph - ... 27 Friday, July 4, 2008 27
  • 28. SODA - Where Clause Query query = db.query(); query.constrain(Student.class); // no getters necessary (private variables are accessible) query.descend(“firstName”).constrain(“Anna”); // will be and-connected with previous constrain (default) query.descend(“matrNr”).constrain(525580).or( query.descend(“matrNr”).constrain(525581) ); ObjectSet<Student> result = query.execute(); 28 Friday, July 4, 2008 28
  • 29. SODA - Where Clause // SELECT * Query query = db.query(); // FROM student query.constrain(Student.class); // WHERE firstName like ‘A%’ query.descend(“firstName”).constrain(“A”).startsWith(true); // AND matrNr >= 500000 query.descend(“matrNr”).constrain(500000).greater().equal(); // ORDER BY lastName ASC query.descend(“lastName”).orderAscending(); ObjectSet<Student> result = query.execute(); 29 Friday, July 4, 2008 29
  • 30. SODA - Evaluation Query query = db.query(); query.constrain(Student.class); query.constrain(new Evaluation() { public void evaluate(Candidate candidate) { Student student = (Student) candidate.getObject(); boolean match = (student.getMatrNr() >= 500000); candidate.include(match) } }); // performance of Evaluation mechanism is very bad :( ObjectSet<Student> result = query.execute(); 30 Friday, July 4, 2008 30
  • 31. NQ - Simple Select ObjectSet<Person> result = db.query( new Predicate<Person>() { public boolean match(Person candidate) { return candidate.getFirstName().startsWith(“A”); // or fetch all: return true; } } ); - NQ wird (optional) in äquivalente SODA-Darstellung transformiert -> NQ sind auch gegen Feldindizes ausführbar 31 Friday, July 4, 2008 31
  • 32. NQ - Sortiert Predicate<Student> predicate = new Predicate<Student>() { public boolean match(Student candidate) { boolean matched = candidate.getMatrNr() >= 500000 && candidate.getMatrNr() < 600000; return matched; } }; Comparator<Student> comparator = new Comparator<Student>() { public int compare(Student s1, Student s2) { return s1.getLastName().compareTo(s2.getLastName()); } }; ObjectSet<Student> result = db.query(predicate, comparator); 32 Friday, July 4, 2008 32
  • 33. + - QbE einfach zu erlernen nicht nach Defaultwerte suchbar äußerst ausdrucksschwach Attributname als Strings SODA Feldindizes werden genutzt (Tippfehler erst zur Laufzeit) etwas performanter als NQ bricht das Geheimnisprinzip in Programmiersprache definiert viel Schreibarbeit notwendig NQ (Typsicherheit, refaktorisierbar) (evtl mit Java 7 closures verfübar) sehr ausdrucksstark 33 Friday, July 4, 2008 33
  • 34. Konfiguration - Global Configuration config = Db4o.configure(); config.generateUUIDs(Integer.MAX_VALUE); config.detectSchemaChanges(true); config.callConstructors(true); config.messageLevel(2); config.readOnly(false); config.exceptionsOnNotStorable(true); config.optimizeNativeQueries(true); config.setBlobPath(“/db4o/blob/path”); // ... // open db-file afterwards! ObjectContainer db = Db4o.openFile(“db4o.yap”); 34 Friday, July 4, 2008 34
  • 35. Konfiguration - Objekte Configuration config = Db4o.configure(); config.objectClass(Person.class).cascadeOnActivate(true); config.objectClass(Person.class).cascadeOnUpdate(true); config.objectClass(Person.class).cascadeOnDelete(true); config.objectClass(Person.class).storeTransientFields(true); config.objectClass(Person.class). objectField(“lastName”).indexed(true); // ... // open db-file afterwards! ObjectContainer db = Db4o.openFile(“db4o.yap”); - gibt auch Annotation “Indexed” public class Person { @Indexed private String firstName; } 35 Friday, July 4, 2008 35
  • 36. ObjectManager 36 Friday, July 4, 2008 36
  • 37. Offene Themen • Aktivierungstiefe ??? • Objektidentität • Transaktionen • Server (embedded/networking) • ... 37 Friday, July 4, 2008 37
  • 38. Links http://omov.sourceforge.net http://db4o.com http://swinglabs.org http://developer.apple.com/quicktime/qtjava 38 Friday, July 4, 2008 38
  • 39. JavaDeus • 19. Juni 2008 • FH St. Pölten (gratis Bustransfer) • keine Teilnahmegebühr • Präsentation von http://at.sun.com/sunnews/events/2008/jun/javadeus08/ 39 Friday, July 4, 2008 39