El fenómeno se desarrolla con calma; es inevitable, irresistible ... Viéndolo nacer y crecer, nos damos cuenta de que no está en la mano del observador acelerarlo o frenarlo ... Todo el mundo, en su presencia ... se queda pensativo y callado durante unos instantes y por lo general se va con una sensación más apremiante e intensa de nuestra incesante movilidad en el espacio.
Jean-Barnard-Léon Foucault
(Extraido de Historias de la ciencia)
Monday, January 29, 2007
El péndulo de Foucault
Sunday, January 28, 2007
Lookup extensions
Thanks to Emilian Bold, who appoints me a reference to this page Lookup and Service Installation, I am able to do a little more things.
The question comes when you have many status line elements and want to show them in a desired order. The answer is in this Emilian's blog entry and also in the later link.
Saturday, January 27, 2007
Thread pools
Here is a good article that describes the importance and implications using pool threads.
http://www-128.ibm.com/developerworks/library/j-jtp0730.html
Are you creating any kind of applications that needs to create variable number of threads to get resources? If so, then perhaps you need to read this.
Monday, January 22, 2007
Bye Properties, hello Preferences
Since version 1.4.2 Java platform offers the Preferences API which intended to substitute and improve the older Properties API.
http://java.sun.com/j2se/1.5.0/docs/guide/preferences/index.html#prefs-other
http://www.onjava.com/pub/a/onjava/synd/2001/10/17/j2se.html
Monday, January 15, 2007
EJB3 and dependency injection
Mistakes are a way to learn if one has enough persistence to find the solution.
Recently, in my adventure with the EJB3 I learn bit more.
Suposse you have a session bean named A_Bean. Inside it you can use anotations like @Resource, @PersistenceContext, ...
Suposse you have another bean named B_Bean needed by A_Bean in some method. Also B_Bean can have it own @Resource and @PersistenceContext annotations.
To do that, you have to options:
- Create the B_Bean by your hand,
- Left the container create a B_Bean instance and inject it in your code.
@Stateless
public class A_BeanImpl implements A_Bean {
@PersistenceContext
private EntityManager em;
private B_Bean bbean;
public void foo() {
bbean = new B_BeanImlp();
bbena.foo();
}
}
@Stateless
public class B_BeanImpl implements B_Bean {
@PersistenceContext
private EntityManager em;
public void foo() {
// Do something
}
}
Here, when the container instantiates an instance of our A_Bean, it is responsible to obtain a reference to an EntityManager and inject it.Later in the A_Bean.foo() methos we are creating by our hand an instance of B_Bean. This means the container hadn't had nothing to do with the instanciation and then, the B_Bean EntityManager reference is null, NULL !!!
The second method, let the container create the B_Bean instance is something like:
@Stateless
public class A_BeanImpl implements A_Bean {
@PersistenceContext
private EntityManager em;
@EJB
private B_Bean bbean;
public void foo() {
bbena.foo();
}
}
@Stateless
public class B_BeanImpl implements B_Bean {
@PersistenceContext
private EntityManager em;
public void foo() {
// Do something
}
}
Here, in the A_Bean.foo() method you can invoque a B_Bean method because the container was responsible to instantiate a B_Bean bean and inject it. Also, and the most important, the container has injected the EntityManager references into the B_Bean and they aren't null.
Wednesday, December 27, 2006
View frustum and the ilogical way to think
Hi, this is a little post to warn all can read it, about the ilogical way to think on the view frustum.
Suposse you have the bounding box (of an object to be rendered), your camera's frustum and you can calculate if a point is inside the camera's view frustum, then:
- A = All points of the bounding box are inside the frustum.
- B = Some part of the object are in the frustum and must be rendered.
- A-->B, that is, if all points are into the view frustum then the object if completely inside the frustum.
- The oposit of A-->B is not (no A -->no B). That is, if all points of the bounding box are outside the view frustum then the object is outside the view frustum. This is false.
The right oposite proposition for A-->B is "not (A-->B)" or "not (no A or B)" or "A and no B", and this a very different thing than the previous and erroneous definition.
Finally (thanks Brandon) the right to think to know when to draw a object because it is present in the camera view frustum is (or could be):
- If all points of the bounding box are inside the frustum, then the object is completely inside the frustum and must be render,
- if all points are outside by the left plane, or all points are outside by the right plane, etc, then the object is completely outside the frustum and must not be drawn.
- other cases, portions of the object intersects with the view frustum and can be drawn.
Sunday, December 03, 2006
Improving performance with display lists
Recently I have been working with shapefiles to add support for it in The Balloon Project. Thanks to the GeoTools I can read the format easyly and render it as line loops (GL_LINE_LOOP).
Initially I was using the brute force for rendering, that is, all points in the window are calculate every time they are going to be rendered. They work for polygons with few points and textures (tile images), but when a shapefile with a thousand of points appears in the scene the brute force is not a good solution.
For this, I change some code and now I am using display list in all my renderable object. The performance has increased surprising in my latpop even with a shapefile.
Saturday, December 02, 2006
NetBeans with your preferred LAF
To all that want to change the default LookAndFeel of its NetBeans:
Can I run NetBeans with a custom look and feel?
Also you can take a look at the themes way here.
Tips about "Out of memory" exception
Recently I have problems with the memory in The Balloon Project. By default, Java starts with a maximum configured memory of 64 Mb and when a layer is loaded with a great number of 512x512 image tiles that is not enought.
Here I want to put a couple of links to pages that talks about the JVM memory options and the out of memory exception:
Thursday, November 23, 2006
Glassfish and socket problems
I was trying use gnu.hylafax libraries (a libraries that implement the HylaFAX protocol, similar to the FTP) to comunicate with a HylaFAX server.
I had created an EJB module with a class containig all the necessary code. I had been tested it in a simple java application and works fine, but when I put it into the EJB class, it fails. See the post at: Hylafax connection into an EJB module to see the error.
To resume the error was in the socket implementation. Looking for help I saw that many people has the same problem, and the solution was to do (see Unable to launch the Java AppServer or Timeout waiting for domain1 to start):
- cd
\domains\domain1 - edit config\domain.xml
- search for elements like
- add
-Dcom.sun.enterprise.server.ss.ASQuickStartup=false - save the file.