Posts

Showing posts with the label JAVA

JMS Producer Consumer and Publisher Subscriber examples under Spring Boot

 In this article I will present Spring Boot code for a JMS Producer and a Consumer and also for a JMS Publisher and his Subscribers running under security in an Apache Artemis ActiveMQ running with Docker on localhost. While the article is being written, you can access its related code under the following links: GITHUB: Producer's code:  https://github.com/sciencetechworks/jmscommunications Consumer's code: https://github.com/sciencetechworks/jmscommunicationsb   Publisher's code: https://github.com/sciencetechworks/jmspublisher Subscribers' code: https://github.com/sciencetechworks/jmssubscriber Apache Artemis ActiveMQ docker image: https://github.com/vromero/activemq-artemis-docker docker run -it --rm -p 8161:8161 -p 61616:61616 vromero/activemq-artemis Enjoy!

Sending CRUD (POST,GET,UPDATE,DELETE) messages to a Quarkus REST Service from an HTML Page.

Quarkus: Sending CRUD (POST,GET,UPDATE,DELETE) messages to a Quarkus REST Service from an HTML Page. Given the a simple REST Service in Quarkus for basic CRUD operations (Create, Read, Update, Delete) calling the Read operation is as simple as invoking a GET method from an HTML form. On the other hand, invoking Create, Update and Delete normally implies sending an ID and/or some Data to the service. HTML Forms allow basic GET and POST methods, but no UPDATE and DELETE are offered by them. To solve this situation JQuery AJAX calls are necessary. Let the following simple REST service be our target: package org . acme ; import javax . ws . rs . GET ; import javax . ws . rs . POST ; import javax . ws . rs . PUT ; import javax . ws . rs . Path ; import javax . ws . rs . Produces ; import javax . ws . rs . Consumes ; import javax . ws . rs . DELETE ; import javax . ws . rs . core . MediaType ; @ Path ( "/example/crud" ) public class CRUDResource { @ GET @ Produc...

JAVA JPA WITH HIBERNATE AND H2 Tutorial

Image
JAVA JPA WITH HIBERNATE AND H2 Tutorial Setting the environment: Download and install H2 Database http://www.h2database.com/html/download.html Create a connection to the database, in my case I am using Netbeans. Creation of a new Database Connection can be done from the Services Tab, Databases node: Have in mind that it is not possible to test the connection before the JDBC URL has been written into. Select the PUBLIC schema when asked. And put a name onto it, I decided to name it as "Hibernate 101 on H2" Download Hibernate http://sourceforge.net/projects/hibernate/files/hibernate3/ JPA with Hibernate: For the shake of portability and standarization we will be using JPA. Natively speaking, Hibernate relies onto a context configuration file -  hibernate.cfg -  and a single or many persistence configuration files  - hibernate.hbm.xml - .  On the other hand JPA configuration is based on just one file:  persistence.xml.  ...

Vaadin 7: Setting the Nth Element in a Container Layout

VAADIN's AbstractLayout, the parent of Horizontal and VerticalLayouts, contains methods to add components to the back and in front of existing ones, but not in the middle of them . It should be pretty obvious how to perform this task, but it is not. Once a component is moved to another layout it is removed from the original, so an iteration will not work as the list of components changes in size in each iteration. Here is the code: public void addNthComponent(             AbstractOrderedLayout layout,             Component c,             int pos) {         HorizontalLayout nc = new HorizontalLayout();         int count = layout.getComponentCount();         for (int i = 0; i < pos; i++) {             Component ci = layout.getComponent(0);             nc.addComponent...

Control Isolator. A Control Flow Java library based on Apache Commons SCXML state machines.

Image
A Control Flow Java library based on Apache Commons SCXML state machines.  Control Isolator: When an application life cycle is designed, isolation between states is highly desired, in case of failure it should be possible to tell where the state the application was in. Due to the general nature of common OOB programming languages like C++ and JAVA there is no difference in algorithm control sentences and application flow control. The purpose of this library is making it possible to define a state machine that defines the life cycle phases of an application or process allowing to isolate working phases separating flow into "Works", each of them capable of executing one or more activities. As you have probably guessed already being faithful to the UML documentation of a project was in mind. In essence what we will be controlling is an activity diagram that pauses each time a decision point is reached allowing us to evaluate the activities results at that poi...