Customizing navigation and security in OpenXava

 Java, Web Development  Comments Off on Customizing navigation and security in OpenXava
Aug 122015
 

OpenXava does not include a complete security and navigation system, although you can easily add security and navigation in an OpenXava application if you use a Java portal, such as Liferay. Also, you can use the official solution that OpenXava team offers: XavaPro. Even though these solutions may be valid for new projects, for legacy projects you may need apply other ones. In this post we are going to customize our own solution for navigation and security starting from the standard OpenXava solution: NaviOX. Continue reading »

Main JSPs in OpenXava

 Java, Web Development  Comments Off on Main JSPs in OpenXava
Aug 112015
 

OpenXava is an AJAX Java Framework for rapid development of enterprise web applications. In OpenXava you only have to write the domain classes in plain Java to get a web application ready for production. Under the hood, there are a lot of JSPs that, magically, build all the pages on the fly. In spite of being an extensible and customizable framework, if you want to change the default behaviour of OpenXava projects, you will have to know how different JSPs are related each other.
Continue reading »

Reverse Engineering and Code Generation

 DataBase, Java, Web Development  Comments Off on Reverse Engineering and Code Generation
Aug 102015
 

The goal of this post is to explain how to model a database into java pojo classes with EJB or JPA annotations using reverse engineering. We can use several tools such as MinuteProject or Mogwai ERDesignerNG. In this post we are going to use JBoss Tools plugins for Eclipse (Hibernate Tools). With this tool not only can you configure files using JPA and EJB annotations, but also other annotations such as OpenXava. Continue reading »

Streams in Java 8

 Java  Comments Off on Streams in Java 8
Jul 252015
 

Streams are the key abstraction in Java 8 for processing collections of values and specifying what you want to have done, leaving the scheduling of operations to the implementation. Furthermore, streams can leverage multi-core architectures without you having to write a single line of multithread code, and simplify the description of aggregate computations, exponing opportunities for optimisation. Streams basically allow us to write collections-processing code at a higher level of abstraction.
Continue reading »

Timer versus ScheduledThreadExecutor

 Sin categoría  Comments Off on Timer versus ScheduledThreadExecutor
May 132015
 

According to Java Concurrency in Practice and other sources of information main differences between Timer and ScheduledThreadExecutor are:

  • Timer can be sensitive to changes in the system clock, ScheduledThreadPoolExecutor isn’t
  • Timer has only one execution thread, so long-running task can delay other tasks. ScheduledThreadPoolExecutor can be configured with any number of threads. Furthermore, you have full control over created threads, if you want (by providing ThreadFactory)
  • Runtime exceptions thrown in TimerTask kill that one thread, thus making Timer dead 🙁 … i.e. scheduled tasks will not run anymore. ScheduledThreadExecutor not only catches runtime exceptions, but it lets you handle them if you want (by overriding afterExecute method from ThreadPoolExecutor). Task which threw exception will be canceled, but other tasks will continue to run.

Calling

ScheduledExecutorService ex= Executors.newSingleThreadScheduledExecutor();

will give you a ScheduledExecutorService with similar functionality to Timer (i.e. it will be single-threaded) but whose access may be slightly more scalable (under the hood, it uses concurrent structures rather than complete synchronization as with the Timer class). Using a ScheduledExecutorService also gives you advantages such as:

  • You can customize it if need be (see the newScheduledThreadPoolExecutor() or the ScheduledThreadPoolExecutor class)
  • The ‘one off’ executions can return results
  • You can reschedule the same task inside run method using a ScheduledExecutorService, but not using  a Timer. With Timer you get java.lang.IllegalStateException: Task already scheduled or cancelled