spring me

40
Spring ME Unleashing Spring to the Rest of the Platorm J-Spring 2009 Wilfred Springer

Upload: wilfred-springer

Post on 18-Dec-2014

951 views

Category:

Technology


4 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Spring ME

Spring MEUnleashing Spring to the Rest of the Platorm

J-Spring 2009Wilfred Springer

Page 2: Spring ME

2

Java is doing AWESOME!

Source: Tiobe Programming Community Index March

Page 3: Spring ME

3

Spring is doing GREAT!

Source: Evans Data, 2008

+ =

Page 4: Spring ME

4

But that's like... a freaking big number

Page 5: Spring ME

5

… or is it?

SAN MATEO, Calif.—November 19, 2008 – SpringSource, a leading provider of infrastructure software and the company behind Spring, the de facto standard in enterprise Java, today announced that results from an extensive Evans Data research study reveal large scale adoption and penetration of Spring as a means of increasing developer productivity and

combating complexity in today’s enterprise application infrastructure market.

Page 6: Spring ME

6

Java Nodes in the Cloud

● 3 Billion Java-Enabled Cards in 2007

● 1.8 Billion Java-Enabled Phones in 2007

● 7 Million Java Set-top Boxes

● 1 Million GWT downloads in 2007

Page 7: Spring ME

7

Not all men are equal

Versus

Page 8: Spring ME

8

We the people

“We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the Pursuit of

Happiness.”

Page 9: Spring ME

9

We the people

“We hold these truths to be self-evident, that all men... Java Developers are enttled to get their

porton of Spring goodness.”

Not just Java EE developersNot just Java SE developersBut also Java ME developers

And Java Card developers

Page 10: Spring ME

10

Why Spring?

All Spring's goodness summarized in famous last words

Page 11: Spring ME

11

IoC Container

“Trust us, we know what we're doing.”“Don't call us, we call you.”

Page 12: Spring ME

Sanitized API

“Any problem in computer science can be solved with another layer of indirecton.”

– David Wheeler

Page 13: Spring ME

AOP

“Once you have a hammer, everything else is a nail.”

Page 14: Spring ME

So why not use Spring itself?

Platorm Limitatons

● Limited Java Runtme capabilites

● Limitatons imposed by deployment

● Limited computatonal resources

– Limitatons on heap

– Limitatons on applicaton size

– Limitatons on performance

Page 15: Spring ME

Java Runtime Limitations

GWT n n n y y yJava ME y y n y y nJava Card n n n n n n

Class.fo

rName(..

.)

Class.newInsta

nce()

Other java

.lang.re

flect

java.la

ng.Strin

g

char

java.util.

List

BeanFactory#getBean(String name)?BeanFactory#getBean(char[] name)?

Page 16: Spring ME

Deployment Limitations (1)

<bean id=”movie1” class=”sample.Movie”> <property name=”title” value=”Into the Wild”/></bean>

package com.mgm;

public class Movie { void setTitle(String title);}

package a.b;

public class a { void a(String ...);}

<bean id=”movie1” class=”a.b.a”> <property name=”a” value=”Into the Wild”/></bean>

OBFUSCATION

1

2 3

4

Page 17: Spring ME

Deployment Limitations (2)

● GWT → JavaScript

● Java Card → CAP fles

Page 18: Spring ME

Computational Resources (1)

● Heap:

● Java SE

– Max heap approx. 1.5 GB

● Java ME

– Lower bound max. heap: 140 KB

– Upper bound max. heap: 128 MB

– Between factor 11 and 11,714 diference

● Java Card

– 16 K RAM

Page 19: Spring ME

Computational Resources (2)

● Applicaton size:

● Java ME: Upperbounds between 64 KB and 28 MB

Spring Core 267KBSpring Beans 467KBSpring Context 455KBTotal 1189KB

Page 20: Spring ME

Throughput

● Nokia E71:

– 369 MHz ARM 11 CPU

● Gameboy Advance

– 16 MHz ARM 7 CPU

– C-Ray Raytracing Benchmark 296108 s

● Dell PowerEdge M710

– 2.4 GHz Xeon Quad Core CPU

– C-Ray Raytracing Benchmark 201 s

Page 21: Spring ME

21

Introducing Spring ME's IoC

Do most of the hard work at build time

Page 22: Spring ME

22

Assume this object model

Page 23: Spring ME

23

And you want to create this

Page 24: Spring ME

24

The Spring (ME) configuration

<beans xmlns=”…”> <bean id=”movieFinder” class=”….InMemoryMovieFinder”> <property name=”movies”> <list> <bean class=”….Movie”> <property name=”title” value=”Bye Bye Blue Bird”/> <property name=”director” value=”Søren Kragh-Jacobsen”/> <property name=”year” value=”1999”/> </bean> … </list> </property> </bean></beans>

Page 25: Spring ME

25

… And with the Maven plugin

<project> <build> <plugins> <plugin> <groupId>me.springframework</groupId> <artifactId>spring-me-maven-plugin</artifactId> <version>1.0-SNAPSHOT</version> <executions> <execution> <goals> <goal>generate</goal> </goals> <configuration> <contextFile>....context.xml</contextFile> <className>com.mgm.BeanFactory</className> </configuration> </execution> </executions>

Page 26: Spring ME

26

You get this BeanFactory

public class BeanFactory { public Object getBean(String name) { if (“movieFinder”.equals(name)) { return getMovieFinder(); } } private final Object getMovieFinder() { … } …}

Page 27: Spring ME

27

DEMO

● Spring ME on Java SE

● Spring ME on Java ME

● Spring ME on GWT

Page 28: Spring ME

Spring ME

● Compile tme validaton

– “Is 10e2 a valid int representaton?”

– “Is an instance of Boeing747 assignable to a property of type Airplane?”

● Minimal or no runtme dependencies

● Superfast (but no benchmarks to verify this)

● Small (1K?)

Page 29: Spring ME

29

Under the hood

Page 30: Spring ME

30

Spring ME Meta Model

Spring XMLConfiguration

Spring MEMeta Model

Spring ME BeanFactory

● Meta Model independent of Spring

● Typically Spring XML confguraton is used

● Meta Model supports other sources

Page 31: Spring ME

31

Other sources?

Spring MEMeta Model

Spring ME BeanFactory

Annotations

@Autowired@PostConstruct@PostDestroy

@ProvidedBy@Inject@ImplementedBy

Spring XMLConfiguration

Page 32: Spring ME

32

Spring ME's Meta Model

Page 33: Spring ME

33

Meta Model Instantiated

Page 34: Spring ME

If not Spring ME, then what?

● Java Card

– None

– (Spring ME?)

● Java ME

– Signal

– Israfl IoC

– Fall ME

– Spring ME

● GWT

– GWToolbox

– Rocket GWT

– GIN

– Spring ME

– Suco

Page 35: Spring ME

35

Inversion of Control Galore

Rocket GWT y n y y y y y y y y n y n n all y y y n ?Spring ME y y y y y y y y y y n n y n l/m y y y y ...Israfil IoC n y y n n n n n n n n n n n ... y n n y yFall ME n y y n n n n n n n n n n n ... y n n n nGWToolbox y n y y y y ? y y n y y n n all n y n y ySignal n n y y n n ? n n n y n y n all n y y ? ?

GWTJa

va M

E

Singletons

Prototyp

es

LazyEage

r

Factory

methods

Init method

Destroy m

ethod

XML config

uratio

n

Annotation co

nfigura

tion

Property

placeholders

Spring C

ompliant S

yntax

AliasColle

ctions

*

Constructo

r injec

tion

Property

injecti

on

By name

By typ

e

Autowiring

Page 36: Spring ME

36

The Rest: Sanitized API

● Java ME needs a lot more sanity

– J2ME Polish is your friend

● Java Card is probably too limited to use wrapper API

● GWT is already addressed by a lot of frameworks

Page 37: Spring ME

37

The Rest: AOP?

● What about it?

● Using the metadata, proxies could be constructed at build tme

● The factory could construct these proxies instead of the actual objects

Page 38: Spring ME

38

Current status

● 'Request' scope

● 'Session' scope

● 'Global session' scope

● BeanFactoryAware, but ...

● BeanPostProcessor (without refecton?)

● BeanFactoryPostProcessor, but ...

● FactoryBean, but ...

Page 39: Spring ME

39

If there's only one thing

● “ME” as in “supportng Java ME”

● “ME” as in “a microscopic small version of Spring”

● Useful for Java ME

● Useful for GWT

● Useful for Java SE

● Potentally useful for Java Card and Java EE

Page 40: Spring ME

40

Roadmap

● Version 1.0 (J109 release) end of May 2009

● Integraton with J2ME Polish

● BOF-4470, June 4, JavaOne

● htp://springframework.me/

[email protected]