Ein kleines Demo zeigt, was heute mit BeanBeans möglich ist: http://www.netbeans.org/download/flash/netbeans_6_gui_builder/netbeans_6_gui_builder.html. Sehr hübsch. Ich lasse mich mal überraschen, wie verpfuscht dann die Gui-Anwendungen werden, wenn sie ohne Kenntnisse über den Entwurf mehrschichtiger Anwendungen gebaut werden.
Autor: Christian Ullenboom
Automatische Konvertierung von .NET Enterprise Anwendungen über Cross-Compiler in eine Java EE Anwendung
Das hat Mainsoft geschafft. Über die Portierung spricht sich der Hersteller des Cross-Compilers unter http://www.mainsoft.com/solutions/pdfs/PerformanceStudy.pdf aus. Interessant finde ich die Performace-Ergebnisse: Die Anwendung läuft unter dem WebSphere AppServer genauso schnell wie unter der MS .NET Plattform.
The software vendor successfully ported their .NET based application platform onto Java EE using Mainsoft’s technology and professional services saving $1M in R&D costs. The performance of this application was tested on the same hardware and under the same stress test conditions. The ported version of the application showed equivalent performance in average response time, and equivalent performance in server throughput. Thus, an SLA could be met using the ported version of the application without additional hardware investment. The Java EE version of the application also showed that in multi-CPU environments, the scalability characteristics of Java EE and WebSphere Application Server began to show marked improvements over the original .NET application.
Kostenschätzung von Open-Source Projekten mit ohloh
Die Seite ohloh schätzt die Projektkosten bekannter Open-Source Projekte. Unter der Annahme, ein Entwickler verdient $55,000 im Jahr, ergeben das für einige Projekte folgende Zahlen:
Open-Office: $186,086,458
Eclipse WTP: $46,954,139 (WOW!) Nur das WTP soll teurer als das gesamte NetBeans sein?
NetBeans: $35,872,047
Firefox: $27,993,803
JBoss: $20,908,809
Gimp: $17,219,225
Hibernate: $11,779,390
ghostscript: $11,439,855
Samba: $8,359,750
PostgreSQL: $7,473,356
Derby: $7,210,467
Tomcat: $2,766,102
Lucene: $1,809,755
HSQLDB: $1,686,517
Notepad++: $1,224,341
XFire: $931,946
IBMs tolle Seminarbeschreibung…
„Für einen Administrator ist Administration eines Servers, der in Java geschrieben ist und auf dem eine Software läuft, die wiederum in Java geschrieben ist, ohne grundlegende Kenntnisse der Programmiersprache Java sehr schwierig.“ (Quelle) Danke IBM!
Some more information about eBays J2EE application?
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#
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
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
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
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
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
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();
double s2p = new Scanner( s2 ).useLocale( Locale.FRENCH ).nextDouble();
The methods format()/printf() and the class Scanner are very handy and easy to use.
Verhältnis von deprecated Elementen zur Gesamtheit
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
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.
UML diagram for JVLC, the Java Multimedia Library for VideoLAN
I created an UML diagram for the JVLC Java Multimedia Library version 0.9.
Die Physik-Engine Phys2D
Phys2D ist eine 2D Physik-Engine, welches Massen, Trägheiten, Reibung simuliert. Die Bibliothek ist in Java 1.4 programmiert und unterstützt
- Boxes
- Circles
- Static Lines
- Restituion and Friction
- Fixed, Elastic and Loose Joints
- Angluar Velocity/Momentum
- Simple API
- Quad Tree Collision
- Gideon Smeding’s Polygon
Ein Demo gibt es via via webstart.
Shell-Script-Editor (ShellEd) und Eclipse Target Management Project/Remote System Explorer
ShellEd (Bild) ist ein Shell-Script-Editor für Unix-Skripte (also ash, bsh, bash, csh, ksh, sh, zsh). Mit Manual und Vervollständigung. Interessant dazu ist das relativ unbekannte Target Management Project, wo man remote, etwa über SSH oder FTP auf einem Server arbeiten und zum Beispiel Dokumente editieren kann. Siehe dazu den Screenshot zum Remote System Explorer (RSE).
Mehr Eclipse-Plugins gibt’s unter http://www.tutego.com/java/eclipse/plugin/eclipse-plugins.html.
Korrekte Inhaltsbreite in paintComponent() durch Insets beachten
Entwickler eigener Swing-Komponenten werden fürs Zeichnen auf getWidth() und getHeight() zurückgreifen. Wegen möglichen Insets sollte man jedoch beim Zeichen die Größenveränderungen betrachten.
@Override
protected void paintComponent( Graphics g )
{
Insets insets = getInsets();
int x = insets.left;
int y = insets.top;
int width = getWidth() - insets.left - insets.right;
int height = getHeight() - insets.top - insets.bottom;
...
range() in Java
A range is a very handy feature of programing languages like Python.
- range( 10 ) -> 0 1 2 3 4 5 6 7 8 9
- range( 5, 10 ) -> 5 6 7 8 9
- range( 0, 10, 3 ) -> 0 3 6 9
- range( ‚0‘, ‚9‘ ) -> 012345678
package com.tutego;
import static com.tutego.Range.range;
public class RangeDemo
{
public static void main( String[] args )
{
for ( int i : range( 10 ) )
System.out.print( i + " " );
System.out.println();
for ( int i : range( 5, 10 ) )
System.out.print( i + " " );
System.out.println();
for ( int i : range( 0, 10, 3 ) )
System.out.print( i + " " );
System.out.println();
for ( int i : range( '0', '9' ) )
System.out.print( (char) i );
System.out.println();
String[] a = { "Mary", "had", "a", "little", "lamb" };
for ( int i : range(a.length ) )
System.out.printf( "%d %s%n", i, a[i] );
}
}
And the main class Range
/*
* This project is made available under the terms of the BSD license, more information can be found at
* http://www.opensource.org/licenses/bsd-license.html
*
* Copyright (c) 2007. Christian Ullenboom (http://www.tutego.com/) and contributors. All rights reserved.
*/
package com.tutego;
import java.util.Iterator;
/**
* Class that generates immutable sequences (ranges) as Iterable<Integer>
* objects. A range represents a start (0 if not given), an stop (mandatory) and
* an optional step (1 by default). The start value is included in the range,
* the stop value is exclusive. Every range is handled by an Iterable<Integer>
* which can by used in an extended for loop.
*
* <pre>
* for ( int i : range( 0, 10, 3 ) )
* System.out.print( i + " " ); // 0 3 6 9
* </pre>
*
* @author Christian Ullenboom (tutego)
* @version 1.0
*/
public class Range
{
public static Iterable<Integer> range( final int start, final int stop, final int step )
{
if ( step <= 0 )
throw new IllegalArgumentException( "step > 0 isrequired!" );
return new Iterable<Integer>()
{
public Iterator<Integer> iterator()
{
return new Iterator<Integer>()
{
private int counter = start;
public boolean hasNext()
{
return counter < stop;
}
public Integer next()
{
try
{
return counter;
}
finally { counter += step; }
}
public void remove() { }
};
}
};
}
public static Iterable<Integer> range( final int start, final int stop )
{
return range( start, stop, 1 );
}
public static Iterable<Integer> range( final int stop )
{
return range( 0, stop, 1 );
}
}
JavaServer Faces 2.0 Draft und Diskussionen
Dinge, die aktuell diskutiert werden und ich interessanter finde:
- The act of writing JSF applications and components „by hand“ will be made much easier by this JSR.
- Allow for „zero configuration“ web applications. No faces-config.xml, no web.xml. If necessary, annotations will be used to supplement the configuration data.
- Leverage annotations to declare JSF artifacts (components, managed beans, navigation rules, etc) to the runtime.
- Eliminate the need to author a JSP tag handler when writing JSF components.
- Real world, production view description technology, including templating: include something influenced by Facelets, JSFTemplating or Tiles in the specification
- All the artifacts that comprise a JSF application can be modified while the application is running.
- Expand the request processing lifecycle to be aware of Ajax.
- Decent client side, inter-component and form-level validation (leveraging JSR-303 validation if possible).
- Strategic additions to the Standard HTML RenderKit: Date Picker, Tree, Tab View, File Upload components.
- Provide a mechanism to minimize the „Lost Update“ and „Duplicate Button Press“ problems.
- Page actions: The ability to say, „when this page loads, invoke this action (via Ajax if necessary).“
- Allow JSF application resources to be accessed via REST. Add support for REST (JSR 311)
- „Skinning“, or „Themeing“ of components.
- WebBeans (JSR-299)
Die Dinge (und mehr) könnten Teil von Java EE 6 werden.
Links zu dem Thema:
- https://javaserverfaces-spec-public.dev.java.net/proposals/JSF-2_0-draft.html
- http://weblogs.java.net/blog/edburns/archive/2007/03/prejcpfiled_dra_1.html
- http://www.jsfcentral.com/editorial/jsf2_wishlist_1.html
- http://wiki.java.net/bin/view/Projects/Jsf2RequirementsScratchpad
- http://www.theserverside.com/news/thread.tss?thread_id=44836
So etwas bei RowSetMetaDataImpl in den Sun-Quellen zu sehen tut weh
Neue String-Objekte als Kopie von existierende Strings aufzubauen ist ganz schön übel. Aus javax.sql.rowset.RowSetMetaDataImpl:
public void setColumnLabel(int columnIndex, String label) throws SQLException
{
checkColRange(columnIndex);
if (label != null) {
colInfo[columnIndex].columnLabel = new String(label);
} else {
colInfo[columnIndex].columnLabel = new String("");
}
}
Wie die API-Doku zum Konsturktor so schön schreibt:
Unless an explicit copy of {@code original} is needed, use of this constructor is unnecessary since Strings are immutable.