Spring Annotations Inject properties / Anotaciones Spring Inyectar properties

December 4th, 2009

applicationContext.xml:

File parameters.properties / Fichero parameters.properties:

MyComponent.path=/some/path

Spring component / Componente gestionado por Spring:

import javax.annotation.PostConstruct;
import org.springframework.stereotype.Component;
 
@Component("MyComponent")
public class MyComponent {
 
    private String path;
 
    @PostConstruct
    public void loadPath() {
 
        System.out.println("Loading from " + this.path);
    }
 
    public String getPath() {
        return path;
    }
 
    public void setPath(String path) {
        this.path = path;
    }
}

Edu HowTo, Java, Spring , ,

Simple Javascript call from Java / Llamada simple a Javascript desde Java

December 4th, 2009

Simple call / Llamada simple:

1
2
3
4
5
6
7
8
9
10
11
try {
	ScriptEngineManager factory = new ScriptEngineManager();
	ScriptEngine engine = factory.getEngineByName("JavaScript");
 
	//Simple call to println javascript function 
	engine.eval("println('Texto JavaScript')");
 
} catch (ScriptException ex) {
 
	//Do something
}

Calling a function / Llamando a una función:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
try {
 
	ScriptEngineManager factory = new ScriptEngineManager();
	ScriptEngine engine = factory.getEngineByName("JavaScript");
	engine.eval("function amessagefunction(atext){ return 'The secret message is ' + atext;}");
	Invocable invocable = (Invocable) engine;
	Object object = invocable.invokeFunction("amessagefunction", "abc");
	System.out.println(object);
 
} catch (NoSuchMethodException ex) {
 
	//Do something
 
} catch (ScriptException ex) {
 
	//Something is wrong, perhaps
}

Edu Java, Javascript, Scripting , ,

Terminator. Terminal Emulator

November 29th, 2009

Cool terminal emulator for GNU/Linux users.

I installed on my Ubuntu box just typping:

$ sudo apt-get update
$ sudo apt-get install terminator

Looks like this:

Pantallazo-edu@somachigun: ~ - Terminator

Edu Linux, Tools ,