What is GeoNetwork?

October 28, 2012 under Java, GIS, Technologies

GeoNetwork is a web application that allows you to maintain a geographic referenced metadata catalogue. This means, a search portal that allows you to view metadata combined with maps. It strictly follows different standards for metadata, from Inspire to OGC. This has allowed GeoNetwork to expand to a lot of organizations, like the swiss geoportal or the brasilian one, not forgetting the New zealander.

It is deployed inside a java application container (like tomcat or jetty), working over the Jeeves framework. Jeeves is based on XSTL transformations that allows a simple quick development (and powerfull) of interfaces, for humans or machines (XML). This makes metadata from GeoNetwork to be easily accesible by different platforms.

Related Posts:

comments: 0 » tags: , , , , , ,

Annotations in Java

April 15, 2012 under Java

The annotations on the code or decorators have become very common. They allow the programmer to add additional useful information about how to improve the code or change how to compile / run a particular class. They are a Java extension to allow aspect-oriented programming.

There are three types of annotations, according to the moment when they are used:

Information for the Compiler

These annotations allow the compiler to indicate whether or not to ignore errors and warnings or what to do with them. If you’ve worked with a Java IDE (like eclipse) probably you would have used this type of annotations, for example using @Override on a function to indicate that you are overwriting a method defined on a parent class. This annotation is completely optional, but allows both the compiler and the developer to check that they are indeed overwriting existing hierarchical functionality.

For example:

public class Parent {     
    public void do(){
        System.out.println("Parent");
     }
}

public class Son extends Parent{     
    @Override
    public void do(){
        System.out.println("Son");
     }
}
Compiler-time and deployment-time processing

These annotations allow the compiler to add extra information about how to generate the code. It can serve to modify classes (adding or modifying functionality from those described in the source code), create new classes (based on a file descriptor), etc …

These annotations will only be visible at this point, they are not written on the .class files and therefore they cannot be available at runtime.

Runtime Annotations

This annotations can be used on runtime and they work on a very similar way as an interface.

Let’s see an example on how to create a Runtime Annotation and how can we use it. The annotation named MyAnnotation can be applied to elements oftype field:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
     public @interface MyAnnotation {
}

Now we can create an annotated class by this annotation:

public class myObject
 {
 @MyAnnotation
 public String field;
 }

This way, we can check by reflection if an object has an annotated field on any part of the code:

Class<?> res = objeto.getClass();
for (Field f : res.getFields()) {
     if (f.isAnnotationPresent(MyAnnotation.class)) {
          System.out.println("OK");
      }
}

More Information:

Related Posts:

comments: 1 » tags: ,

gvSIG 2.0 Workshop Notes

February 8, 2012 under Java, GIS

This are the notes that I took over gvSIG 2.0 on the latests Jornadas GvSIG.

Pre-requisites:

  • Java
  • Eclipse
  • Ant (should)
  • Maven (should)
  • gvSIG (this is recursive :) )

The main advantage of gvSIG 2.0 is that you can create a new plugin without knowing how does gvSIG work or having to compile it. We already have a gvSIG installation that deploys the binaries to the workspace. But we don’t have to change the source code of gvSIG, unless something doesn’t work (bugs) or we have to add some new functionality to the core. Better if you don’t touch it,ask the gvSIG developers and they will take care.

  Click here to read more.. »

Related Posts:

comments: 1 » tags: , , , ,

High Concurrency in Java

July 30, 2010 under Java

When facing high concurrency applications, we often find a number of generic problems. In this article I will focus on the problems of resources (CPU and memory), allowing synchronization problems for another future article. For now on, I will focus on the most typical and most direct solutions.

When we discover threads and the advantages of parallel processing it can happen that we end up abusing their use. We have a lot of threads (100 ¿? 1000?) simultaneously, and the processor will be jumping from one to another without stopping, not letting them finish, no matter how fast is their real excution. And over time there will be more and more threads only slowing down the process. To the cost of execution of each thread, we must consider also the added cost of creating and destroying threads, which can become significant when we talk about so many threads at once.
Click here to read more.. »

Related Posts:

Simple Map on Java

July 16, 2010 under Java, GIS

Sometimes you don’t know where to start when you enter the world of GIS programming. Too many libraries, IDEs, but the truth is, everyone assumes you already have a base and everything become chaos.

For beginners I would recommend that you take a look at a fairly new project aimed at extending Swing (the default graphics java library) with geographical widgets. In this way, add a map to a Java desktop application would be a task as simple as adding a button or text field.
Click here to read more.. »

Related Posts:

comments: 0 » tags: , , , , ,

Custom Event Listeners on Java

July 13, 2010 under Java

Although the pattern Observer is implemented natively in Java, sometimes we need to make an event management that suits better our needs.

The problem of event handling is very simple: We have an object that will be changing its state. Without touching its code, we should be able to “hook” to other objects that are pending status changes and act accordingly. This “hook” must be turned on and off dynamically at runtime.
Click here to read more.. »

Related Posts:

Memory in Java

July 5, 2010 under Java

As I had to study their operation, I decided to post about the basic concepts of memory in Java.

To begin wtih, Java divides memory into two distinct segments:

  • Heap: User objects, variables, …
  • Non-Heap/Perm: code, metadata, …

The one that interests us is the Heap, as it is what we can “control”. You can configure the Non-Heap Memory (Perm) size with the parameter MaxPermSize. But this is only useful if the application is loaded or dynamically generate many different classes.

The heap is divided into two generations according to their lifetime:

  • Young Generation
  • Old Generation

Usually the younger generation is composed of local variables and temporary objects, while the older generation usually consists of structures that are necessary during the execution: configurations, viewports, …
Click here to read more.. »

Related Posts:

FastJTable

June 16, 2010 under Java

Swing JTables of Java by default usually are not prepared to handle frequent updates and a huge number of columns and rows. Basing on the code of the Java Christmas Tree , I created a lighted version of JTable which is pretty faster when handling huge amounts of data.

Click here to read more.. »

Related Posts:

comments: 0 » tags: , , , ,