martedì 18 luglio 2017

Http Download Manager

A complete Netbeans 7.0 Java project (all sources) of my HTTP download manager in Java.

You can purchase the code on Fiverr web site (only 5 dollar)

*** Important ***
You must use NetBeans 7.0 (it's free) and use Jdk 1.6 
otherwise the project does not work properly. However you are free to use my sources with every  IDE, JDK  you like but you will need to do some adjustements.The project can be useful for students that wish to see an example of Java Api Networking, Multithread management, File and database access from Java.  The project handles only HTTP protocol and direct file url.

Video Demo

lunedì 17 luglio 2017

Lambda Expressions in 5 minutes

Lambda expressions allow us to realize a more compact code and avoid anonymous inner classes. We can use them with functional interface. So, for instance, we can assign a lambda expression to a functional interface reference variable,  functional interface method parameter or functional interface returned type. The general  form is the following:
parameters list -> body
Here the video with different usage examples:

domenica 16 luglio 2017

Functional interface and :: keyword in 5 minutes

 A functional interface
  1. Has only one method
  2. Allows static implemented methods
  3. Allows default  (non static) implemented methods

While the general use of the :: keyword is:
  1. ClassName::methodName
  2. ObjectInstance::methodName
  3. ClassName::new

venerdì 30 giugno 2017

JAX-RS : Produce and consume XML and JSON messages with RestEasy

In this post we will use a more advanced JAX-RS features like produce and consume JSON an XML messages. The application demo simulates a news service exposing a RestEasy service, inside JBoss Wildlfly, that allows the use of the following methods:
  1. Add a news
  2. List all news
  3. Get a particular news using the news title
While we doesn't have problems about JSON messages generation, we have to pay attention about XML messages. In order to build an XML message we need to use XML annotations as showed in the video tutorial. Rest clients have some dependencies:
  1. HTTP Client
  2. Commons IO
So you must download and add this libraries  in your classpath as showed at the start of the video.

martedì 27 giugno 2017

JAX-RS Parameters with JBoss Wildfly

In this Tutorial we will show you two video about using JAX-RS parameters with JBoss Wildfly and RestEasy:

venerdì 23 giugno 2017

JAX-RS Kickstart with JBoss Wildfly

We can define Rest (Representational State Transfer) as an Architectural Style. The idea behind REST is to see the Web as a distributed platform for data elaboration. REST uses only HTTP protocol and from this point of view the Web has all we need. The use of REST is often preferred over SOAP  because REST does not leverage as much bandwidth, which makes it a better fit for use over the Internet. REST is often used in mobile applications. The REST style emphasizes that interactions between clients and services is enhanced by having a limited number of operations. Flexibility is provided by assigning resources to their own unique  URI. In this tutorial we will create a simple REST Web Service from scratch using JBoss Wildfly, RestEasy and JBoss Developer Studio.

Part 2:

mercoledì 21 giugno 2017

JAX-WS Web Services : Expose a Stateless Session Bean as Web Service

EJB 3 specification allows to expose stateless session beans as JAX-WS Web services. EJB is relevant as an integration and remote invocation protocol at least for the following reasons:

  • Transaction and security context is built into EJB.
  • EJB containers have support for load balancing and failover that it's not easy to reach with simple Web Services.
The best way to realize an EJB 3 Web Service is to follow the following three steps:

  • Design the service contract using WSDL.
  • Use JAX-WS (wsimport) to generate a corresponding Java interface. 
  • Create a stateless session bean implementing the interface.

Let's see an example using Jboss Developer Studio and JBoss Wildfly 9. The first EJB 3.2 project follows the Bottom-Up approach: we realize the java code implementing the Web Service and from this one we generate the WSDL file:

Pay attention in this first video, TicketService.wsdl is not automatically generated, I created this file using the Web Service URL. The second EJB project uses the Top-Down approach: starting from the TicketService.wsdl file, we can generate all Web Service classes except the implementation class:

The most important part of the second project is the use of wsimport tool inside an Ant Script for the Web Service classes generation task:

<?xml version = '1.0'?> 
<!DOCTYPE project>
<project default="wsimport">
  <property name="jdk.home" value="C:\Program Files\Java\jdk1.8.0_91" />
  <target name="wsimport">
    <exec executable="${jdk.home}/bin/wsimport">
      <arg line="  -s ../../ejbModule 
                          -d ../../build/classes 
                          -p http://localhost:8080/JAX-WS-                                                                                       BottomUp/TicketServiceService/ITicketServiceImpl?wsdl"/>