Some more information about eBays J2EE application?
0 Kommentar(e). Veröffentlicht von Christian Ullenboom am Mittwoch, Mai 30, 2007.The presentation The eBay Architecture – Striking a balance between site stability, feature velocity, performance and cost gave me a first impression of the internal architecture but I would like to know a little bit more about the realization. J2EE is (inglorious) “famous” for EJBs, JMS, JCA, … but these terms are not mentioned in the pdf. I got the impression that eBay is not really using the „hard“ stuff.
- “eBay internally-developed pure Java OR mapping solution.” OK. No CMP. That implies that the container is not responsible for CMT.
- “Keep Application Tier Completely Stateless”. Ok. No Stateful Session Beans.
- “eBay scales on Servlets and a rewritten connection pool.” Hm. So no JDBC 2 connection pool from a vendor. So why is this a Java EE application? Because of Stateless Session Beans? (Then JNDI is in the boat.) The Spring folks will see a opportunity for POJOs on Tomcat/Jetty, … :-)
Does anyone have some more information about this?
Gegenüberstellung Java und C#
0 Kommentar(e). Veröffentlicht von Christian Ullenboom am Sonntag, Mai 20, 2007.Die Webseite http://www.25hoursaday.com/CsharpVsJava.html widmet sich sehr detailiert den Unterschieden (und natürlich Gemeinsamkeiten) der beiden Sprachen Java und C#. Die Diskussion ist auf der Basis von Java 6 und C# 2.0, wobei der Autor Dare Obasanjo in seiner Zusammenfassung auch Bezüge zu C# 3.0 herstellt.
Erste Implementierung für JSR 308
0 Kommentar(e). Veröffentlicht von Christian Ullenboom am Sonntag, Mai 20, 2007.Die JSR 308 (Annotations on Java Types) hat unter anderem das Ziel, Annotationen an weiteren Dingen festzumachen:
- for generic type arguments to parameterized classes:
Map<@NonNull String, @NonEmpty List<@Readonly Document>> files;
- for generic type arguments in a generic method or constructor invocation:
o.<@NonNull String>m("..."); - for type parameter bounds and wildcards:
class Folder<F extends @Existing File> { ... }
Collection<? super @Existing File> - for class inheritance:
class UnmodifiableList<T> implements @Readonly List<@Readonly T> { ... } - for throws clauses:
void monitorTemperature() throws @Critical TemperatureException { ... } - for typecasts:
myString = (@NonNull String) myObject;
- for type tests:
boolean isNonNull = myString instanceof @NonNull String;
- for object creation:
new @NonEmpty @Readonly List<String>(myNonEmptyStringSet)
For generic constructors (JLS section 8.8.4), the annotation follows the explicit type arguments (JLS section 15.9):
new <String> @Interned MyObject()
- for method receivers:
public int size() @Readonly { ... } - for class literals:
Class<@NonNull String> c = @NonNull String.class;
- for arrays:
Document[@Readonly][] docs4 = new Document[@Readonly 2][12];
Document[][@Readonly] docs5 = new Document[2][@Readonly 12];This syntax permits independent annotations for each distinct level of array, and for the elements; see Section 3.4 for alternative syntaxes.
Die Beispiele stammen aus dem working document von Michael D. Ernst. Auf seiner Homepage lässt sich die Compilererweiterung herunterladen und alles über die JSR 308 nachlesen.
Java-Spiel FreeCol - Remake von Sid Meier’s Colonization
0 Kommentar(e). Veröffentlicht von Christian Ullenboom am Donnerstag, Mai 17, 2007.FreeCol ist ein Open-Source (GPL) Spiel in Java und ist stark angelehnt an Sid Meier’s Colonization.
Die Grafiken sind ausgezeichnet: http://www.freecol.org/index.php?section=5.
NASA stellt seine World Wind Applikation in Java vor
0 Kommentar(e). Veröffentlicht von Christian Ullenboom am Samstag, Mai 12, 2007.Eigentlich ganz cool und flott in der Darstellung. Es gibt eine JNLP-Datei für Web-Start, mit der man das gleich ausprobieren kann. Interessant ist auch folgende Aussage:
With this SDK, developers can embed World Wind technology in their own applications. The API documentation will be made available later.
Mit "Place Name" würde ich mir jetzt irgendwie Ortsnamen wünschen, die kommen aber nicht. Der Server könnte auch schneller sein und für feine Auflösungen sind nicht immer Kacheln dabei. Sehr merkwürdig, dass beim Zoom mal Kacheln kommen und dann wieder verschwinden.
Eine erste Programmieranleitung habe ich hier gefunden.
Contact to javax.beans.binding
2 Kommentar(e). Veröffentlicht von Christian Ullenboom am Mittwoch, Mai 09, 2007.This little example will show you how to bind a JTextField to a name property of a Person with Beans Binding (JSR-295). First the Person:
package com.tutego.binding;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
public class Person
{
private PropertyChangeSupport pcs = new PropertyChangeSupport( this );
private String name = "";
public void addPropertyChangeListener( PropertyChangeListener x )
{
pcs.addPropertyChangeListener( x );
}
public void removePropertyChangeListener( PropertyChangeListener x )
{
pcs.removePropertyChangeListener( x );
}
public String getName()
{
return name;
}
public void setName( String name )
{
String old = getName();
this.name = name;
pcs.firePropertyChange( "name", old, getName() );
System.out.println( "Changed name!" );
}
}
The code for the JavaBean Person is a litte bit cumbersome because of the PropertyChangeListener who will notify the Binding Framework if the model change.
package com.tutego.binding;
import javax.beans.binding.BindingContext;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class BindingDemo
{
public static void main( String[] args )
{
Person p = new Person();
JTextField tf = new JTextField();
BindingContext bindingContext = new BindingContext();
bindingContext.addBinding( p, "${name}", tf, "text" );
bindingContext.bind();
JFrame f = new JFrame();
f.add( tf );
f.pack();
f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
f.setVisible( true );
p.setName( "Christian Ullenboom" );
}
}
Swing on the other side will although notify the model if the user type text in the text field and press Return. This will change the model.
Using format()/printf() for formatting and Scanner for parsing localized elements
0 Kommentar(e). Veröffentlicht von Christian Ullenboom am Montag, Mai 07, 2007.format() from String or printf() from e.g. PrintWriter will use the default language except you give a Local object as the first argument:
String s1 = String.format( Locale.ENGLISH, "%,.2f", 1000234234.56772345 );
String s2 = String.format( Locale.FRANCE, "%,.2f", 1000234234.56772345 );
System.out.println( s1 ); // 1,000,234,234.57
System.out.println( s2 ); // 1 000 234 234,57
And the class Scanner offers nextDouble() that uses the default language too except you use useLocale().
double s1p = new Scanner( s1 ).useLocale( Locale.ENGLISH ).nextDouble();The methods format()/printf() and the class Scanner are very handy and easy to use.
double s2p = new Scanner( s2 ).useLocale( Locale.FRENCH ).nextDouble();
Verhältnis von deprecated Elementen zur Gesamtheit
0 Kommentar(e). Veröffentlicht von Christian Ullenboom am Donnerstag, Mai 03, 2007.Die Standardbibliothek enthält 200 Pakete, die Java in der Version 6 deklariert. Sie beschreiben zusammen 3777 Typen, davon 2457 Klassen, 972 Schnittstellen, 49 Aufzählungen, 473 Ausnahmeklassen und 32 Errorklassen. Insgesamt gibt es 1482 Objektvariablen, 4408 statische Variablen/Konstanten, 21881 Objektmethoden in Klassen und 5226 aus Schnittstellen, 3039 Klassenmethoden sowie 4973 Konstruktoren. (In Java 1.0 verteilten sich 212 Klassen auf 8 Pakete.)
Veraltetes hat sich im Laufe der Zeit einiges angesammelt. In Java 6 sind über 334 Methoden, 20 Konstruktoren, 54 Variablen/Konstanten, 21 Klassen (zuzüglich 4 Exceptions), 17 Schnittstellen (viele aus CORBA), 3 Annotationstypen und ein Annotationselement veraltet. Dennoch ist das in Relation zur Gesamtheit klein:
Setzen wir beides in Relation (# Elemente/#deprecated davon)
Klassen: 2457/21 = 0,85%
Schnittstellen: 972/17=1,75%
Exceptions: 473/4=0,85%
Methoden: 21881/334=1,53%
Konstruktoren: 4973/20=0,40%
Variablen/Konstanten: 4408/54=1,22%
Einmal Finalizier, vielleicht mehrmals der GC
0 Kommentar(e). Veröffentlicht von Christian Ullenboom am Mittwoch, Mai 02, 2007.Objekte von Klassen, die eine finalize()-Methode besitzen, kann Suns JVM nicht so schnell erzeugen und entfernen, wie Klassen ohne finalize(). Das liegt auch daran, dass der GC vielleicht mehrmals laufen muss, um das Objekt zu löschen. Es gilt zwar, dass der GC aus dem Grund finalize() aufruft, weil das Objekt nicht mehr benötigt wird, es kann aber sein, dass aus der finalize()-Funktion die this-Referenz nach außen gegeben wurde, sodass das Objekt wegen einer bestehenden Referenz nicht gelöscht werden kann. Das Objekt wird zwar irgendwann entfernt, aber der Finalizer läuft nur einmal und nicht immer pro GC-Versuch. Einige Hintergründe erfährt der Leser unter http://www.iecc.com/gclist/GC-lang.html#Finalization.
Löst eine Anweisung in finalize() eine Ausnahme aus, so wird diese ignoriert. Das heißt aber, dass die Finalizierung des Objekts stehen bleibt. Den GC beeinflusst das in seiner Arbeit aber nicht.
