The Concept of this Design Pattern is decoupling the sender and receiver. Each receiver doesn’t know about it’s sender but contains the next receiver(successor to it) and so forth . Example of a basic Java Logger with a chain of responsibilty: import java.util.logging.Logger; Logger logger = Logger.getLogger(SomeLogger.class.getName()); logger.setLevel(Level.Severe); ConsoleHandler handler =Continue Reading

In order to create a custom constraint for a bean validator, first you should declare an interface and decorate it with the following annotations: @Target = what it works on @Retention = must be runtime in order to work on runtime @Constraint = the custom validator (if you have createdContinue Reading

Creating a simple MySql Table: CREATE TABLE `YairShinar`.`employee` ( `idemployee` INT NOT NULL , `firstname` VARCHAR(45) NULL , `lastname` VARCHAR(45) NULL , PRIMARY KEY (`idemployee`) ); Creating the JPA annotations and imports package com.YairShinar.jpa.entities.Employee; import java.io.Serializable; import javax.persistence.*; @Entity public class Employee implements Serializable { @Id private int idEmployee; privateContinue Reading

JAX-B is the xml modeling for Java. It makes it easier to marshell classes. import javax.xml @XmlRootElement public  class  Book{ private string isbn; }Continue Reading

The Java Message Service (JMS) API is a Java Message Oriented Middleware (MOM) API for sending messages between two or more clients. It is an implementation to handle the Producer-consumer problem in order to create, send, receive, and read messages, It allows the communication between different components of a distributedContinue Reading

A socket connection means that two machines have information about each other’s network location IP Address and TCP port, and that they can send or receive data through the connection. In order to create a socket server: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; publicContinue Reading

A Servlet is an object that receives a request and generates a response based on that request. To deploy and run a servlet, a web container must be used such as TomCat/JWS/Jetty/Resin. In order to create a servlet the class must extend servlet. The package javax.servlet.http defines HTTP-specific subclasses ofContinue Reading

JAX-RS stands for: Java API for RESTful Web Services ,hence it is a http uniformed verb based service. Some of The main annotations in JAX – RS: @Path : specifies the relative path for a class or method @GET/@PUT/@POST/@DELETE/@HEAD: Indicates the http request type on the method but only oneContinue Reading

JAX-WS stands for Java API for XML Web Services. Creating a Service Endpoint Interface (SEI) package com.yairshinar.ws; import javax.jws.WebMethod; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style; @WebService @SOAPBinding(style = Style.DOCUMENT) public interface HelloName{ @WebMethod String getName(String name); } Creating a Service Implementation Bean (SIB) that implements all the methods of theContinue Reading

A thread in most cases is a component of a process, and shares it’s resources. In Java – Creating a basic thread and starting it: (This Example doesn’t provide any code in the start method. So the thread will exit right after it is started). Thread thread = new Thread();Continue Reading