blprnt เขา post source code ที่่ paint รูปต้นไม้
- cherrytree (***** เอาไปห้าดาว)
- birchtree (ตอนที่กิ่งน้อยๆ สวยกว่าตอนกิ่งเยอะๆ)
Javaเร็วส์, Javascript, Erlang, Python, Ruby, Clojure, Groovy, เลี้ยงลูก, วาดภาพ
Quartz timer component ===msg===> Log Component
public class LogComponent extends ComponentSupport {
private Log log = LogFactory.getLog(TraceComponent.class);
public Log getLog() {
return log;
}
public void setLog(Log log) {
this.log = log;
}
public void onMessageExchange(MessageExchange exchange) throws MessagingExce
ption {
// lets dump the incoming message
NormalizedMessage message = exchange.getMessage("in");
if (message == null) {
log.warn("Received null message from exchange: " + exchange);
}
else {
log.info("Exchange: " + exchange + " received IN message: " + messag
e);
}
}
}
public class LogComponent extends ComponentSupport
implements MessageExchangeListener {...}
public class PojoReceiver implements MessageExchangeListener {
public void onMessageExchange(MessageExchange exchange) throws MessagingExce
ption {
NormalizedMessage message = exchange.getMessage("in");
....
}
}
#!/bin/bash
#
# Dump wma to mp3
for i in *.wma
do
if [ -f $i ]; then
rm -f “$i.wav”
mkfifo “$i.wav”
mplayer -vo null -vc dummy -af resample=44100 -ao pcm -waveheader “$i” -aofile “$i.wav” &
dest=`echo “$i”|sed -e ’s/wma$/mp3/’`
lame -h -b 192 “$i.wav” “$dest”
rm -f “$i.wav”
fi
done
One of the (several) goals of Seam is to bring Ruby On Rails style productivity to the Java EE platform
@Name("user")
register.register
@Name("register")
register
ให้public class Person {
private String name;
private int age;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public aspect PersonValidate {
declare parents: Person implements Validatable;
public Errors Person.validate() {
Errors errs = new Errors();
if (this.getName() == null ||
this.getName().length() == 0) {
errs.addError("name", "name must not be empty");
}
if (this.getAge() <= 0) {
errs.addError("age", "age must not be negative or zero");
}
return errs;
}
}
declare parents: Person implements Validatable;
public static void main(String[] args) {
Person p = new Person();
p.setAge(-1);
Validatable vt = (Validatable) p;
Errors err = vt.validate();
for (int i = 0; i < err.size(); i++) {
System.out.println(err.getError(i));
}
}
name:name must not be empty
age:age must not be negative or zero