SlideShare ist ein Scribd-Unternehmen logo
Helma-Workshop
       Philipp Naderer



      ASE-Projekt: Tenez
     http://www.tenez.at
   philipp.naderer@tenez.at
Demo-Distribution


http://tenez.at/downloads/helma-1.6.3-inafara.zip
Helma?

JavaScript Web Application Server

Open Source – BSD-Lizenz

Mozilla Rhino zum Interpretieren

  Rhino ist in der J2SE 6 fest verankert

Helma ist anders.
Helma ist anders!
Prototyp-basiertes Objekthandling

  Ganz grob gesagt: Prototype = Klasse

Prototypen bestimmen Applikations-Layout

REST-konform - jeder Ressource wird eine
URL zugeordnet.

  /photographers/leibovitz/
Helma ist anders!
Ruby on Rails:         Helma:
application            application
  -- models             -- Photographer
  -- controllers          |-   Photographer.js
                           |-   Photographer.actions.js
  -- helpers
                           |-   Photographer.macros.js
  -- views                |-   preview.skin
    -- photographer       |-   main.skin
    -- agency           -- Agency
    -- photo            -- Photo
Helma & Java
Rhino ermöglich Zugriff auf Java-Klassen

var url = new java.net.URL('http://orf.at‘);
var host = url.getHost();

var bigInt = new java.math.BigInteger('1000000‘);
res.write('Next prime: ' + bigInt.nextProbablePrime());




Zugriff auf alle möglichen Java-Libraries!

  Captchas, Chart-Rendering, ...
Request-Handling
Im Prototypen eine Funktion:
ProtoName.prototype.methodenname_action()

Wird gemapped auf: /objektId/methodenname
 Photo.prototype.delete_action = function() {
    // Request-Objekte:
    req
    res
    session
    root
 }

 URL:   /leibovitz/photos/1024/delete
Rendering
renderSkin(); renderSkinAsString();

Skins: /Prototype/skinname.skin

Macros: bezeichnung_macro(){...}

<li class="taskLine">
   <% this.text %>    <%// property %>
   <% this.status %> <%// status_macro() %>
</li>
DB-Mapping
Für jeden Prototype mit type.properties
# Photographer/type.properties
_db     = photoworld
_table = T_PHOTOGRAPHERS
_id     = PGR_ID
_parent = agency.photographers, root

name       =    PGR_NAME
birthday   =    PGR_BIRTHDAY

address         =      object(Address)
address.local   =      PGR_ADDRESS_FK
address.foreign =      ADR_ID

photo              =   collection(Photo)
photo.local        =   PGR_ID
photo.foreign      =   PHO_PHOTOGRAPHER_FK
REST-URLs
    /agency/magnum/photographers/philippnaderer

/Root/type.properties

agency            =     collection(Agency)
agency.accessname =     agencyAlias


          /Agency/type.properties
          _parent     = root.agency

          photographers            =     collection(Photographer)
          photographers.accessname =     photographerUsername
Vererbung
Alles, was für den Super-Prototypen definiert
wird, erbt der Sub-Prototype.

  Konstruktoren, Methoden, type.properties

_extends = SuperPrototypeName

Optional, aber üblich: Sub-Prototypen in selbe
Datenbank-Tabelle ablegen
# Dog/type.properties
_extends     = Animal
_prototype   = ANI_PROTOTYPE_NAME
_extensionId = Dog (String oder frei wählbarer Integer)
Vererbung
Collections:
Sub-Prototypes sind auch in Collections vom
Super-Prototype enthalten

allUpdates           = collection(Update)
allUpdates.local     = USR_ID
allUpdates.foreign   = UPD_CREATOR
                                                  Update

                       StatusUpdate         TaskUpdate
Caching
Obj1       Obj10

Obj2       Obj11

Obj3       Obj12
                   DB
           Obj13

           Obj14

           Obj15

new         old
Caching
Obj1        Obj10

Obj2        Obj11

Obj3        Obj12
                    DB
Obj26       Obj13

            Obj14

            Obj15

new          old
Caching
              Obj1                     Obj10

              Obj2                     Obj11

              Obj3                     Obj12
                                                             DB
              Obj26                    Obj13

              Obj27                    Obj14

              Obj28                    Obj15
cachesize/2                                    cachesize/2
                      cachesize = 12
              new                      old
Caching
                                     Obj1

                                     Obj2

                                     Obj3
                                                           DB
                                     Obj26

                                     Obj27

                                     Obj28
cachesize/2                                  cachesize/2
                    cachesize = 12
              new                    old
Sfârşit

(Ende)

Weitere ähnliche Inhalte

PDF
Lehmanns Rails Erweitern
PDF
Scharfe Anmerkungen für Java 6 mit Lombok
KEY
JSTF-Workshop Teil 1
PDF
Cache me if you can
PDF
JavaScript Performance
PDF
Einführung in die funktionale Programmierung mit Clojure
KEY
JRuby
PDF
MySQL Backup/Recovery
Lehmanns Rails Erweitern
Scharfe Anmerkungen für Java 6 mit Lombok
JSTF-Workshop Teil 1
Cache me if you can
JavaScript Performance
Einführung in die funktionale Programmierung mit Clojure
JRuby
MySQL Backup/Recovery
Anzeige

Helma Workshop

  • 1. Helma-Workshop Philipp Naderer ASE-Projekt: Tenez http://www.tenez.at philipp.naderer@tenez.at
  • 3. Helma? JavaScript Web Application Server Open Source – BSD-Lizenz Mozilla Rhino zum Interpretieren Rhino ist in der J2SE 6 fest verankert Helma ist anders.
  • 4. Helma ist anders! Prototyp-basiertes Objekthandling Ganz grob gesagt: Prototype = Klasse Prototypen bestimmen Applikations-Layout REST-konform - jeder Ressource wird eine URL zugeordnet. /photographers/leibovitz/
  • 5. Helma ist anders! Ruby on Rails: Helma: application application -- models -- Photographer -- controllers |- Photographer.js |- Photographer.actions.js -- helpers |- Photographer.macros.js -- views |- preview.skin -- photographer |- main.skin -- agency -- Agency -- photo -- Photo
  • 6. Helma & Java Rhino ermöglich Zugriff auf Java-Klassen var url = new java.net.URL('http://orf.at‘); var host = url.getHost(); var bigInt = new java.math.BigInteger('1000000‘); res.write('Next prime: ' + bigInt.nextProbablePrime()); Zugriff auf alle möglichen Java-Libraries! Captchas, Chart-Rendering, ...
  • 7. Request-Handling Im Prototypen eine Funktion: ProtoName.prototype.methodenname_action() Wird gemapped auf: /objektId/methodenname Photo.prototype.delete_action = function() { // Request-Objekte: req res session root } URL: /leibovitz/photos/1024/delete
  • 8. Rendering renderSkin(); renderSkinAsString(); Skins: /Prototype/skinname.skin Macros: bezeichnung_macro(){...} <li class="taskLine"> <% this.text %> <%// property %> <% this.status %> <%// status_macro() %> </li>
  • 9. DB-Mapping Für jeden Prototype mit type.properties # Photographer/type.properties _db = photoworld _table = T_PHOTOGRAPHERS _id = PGR_ID _parent = agency.photographers, root name = PGR_NAME birthday = PGR_BIRTHDAY address = object(Address) address.local = PGR_ADDRESS_FK address.foreign = ADR_ID photo = collection(Photo) photo.local = PGR_ID photo.foreign = PHO_PHOTOGRAPHER_FK
  • 10. REST-URLs /agency/magnum/photographers/philippnaderer /Root/type.properties agency = collection(Agency) agency.accessname = agencyAlias /Agency/type.properties _parent = root.agency photographers = collection(Photographer) photographers.accessname = photographerUsername
  • 11. Vererbung Alles, was für den Super-Prototypen definiert wird, erbt der Sub-Prototype. Konstruktoren, Methoden, type.properties _extends = SuperPrototypeName Optional, aber üblich: Sub-Prototypen in selbe Datenbank-Tabelle ablegen # Dog/type.properties _extends = Animal _prototype = ANI_PROTOTYPE_NAME _extensionId = Dog (String oder frei wählbarer Integer)
  • 12. Vererbung Collections: Sub-Prototypes sind auch in Collections vom Super-Prototype enthalten allUpdates = collection(Update) allUpdates.local = USR_ID allUpdates.foreign = UPD_CREATOR Update StatusUpdate TaskUpdate
  • 13. Caching Obj1 Obj10 Obj2 Obj11 Obj3 Obj12 DB Obj13 Obj14 Obj15 new old
  • 14. Caching Obj1 Obj10 Obj2 Obj11 Obj3 Obj12 DB Obj26 Obj13 Obj14 Obj15 new old
  • 15. Caching Obj1 Obj10 Obj2 Obj11 Obj3 Obj12 DB Obj26 Obj13 Obj27 Obj14 Obj28 Obj15 cachesize/2 cachesize/2 cachesize = 12 new old
  • 16. Caching Obj1 Obj2 Obj3 DB Obj26 Obj27 Obj28 cachesize/2 cachesize/2 cachesize = 12 new old