Posts

Example:Immutable Class

Immutable class is thread safe Imuutable class objects cannot be modified Examples : Integer String package com.demo.immutable; //make ur class final public final class MyImmutable {  //make ur instance variables final     final String s="Anjana";     private String s2=null; //access the private via constructors--to modify     public MyImmutable(String s2) {         super();         this.s2 = s2;     }     public static void main(String args[]){         MyImmutable  myimmutable=new MyImmutable("dff");     } }  

CXF RESTFUL Service - Example jax-rs

CXF frame work  supports restful web services. It is provided in the following ways: JAX_RS JAX_WS ProviderDispatch HtppBinding Below is the example of RESTFUL service which gives an xml response .The data is pulled form  the database .I have also integrated  spring-jdbc with cxf. check the response after running the application at- http://localhost:8086/cxf-jaxrs-poc/myservice/users Port number can change based on availability. Lets start with the configurations-cxf.xml : <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd" default-lazy-in...

cxf-jaxws-SOAP Example-Live Resturant Example

This is a simple cxf-jaxws application.The appliction offers 2 services cancel order place order The wsdl can be accessed at: http://localhost:8086/cxf-jaxws-LiveResturant/OrderService?wsdl CXF webservice depends on the service endpoint interface. Uses spring based configuration. The application has been tested on tomcat and uses the latest cxf jar files. Create a web application project in eclipse cxf.xml -add a cxf.xml in web-inf folder <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:wsa="http://cxf.apache.org/ws/addressing" xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager" xmlns:wsp="http://www.w3.org/2006/07/ws-policy" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy" xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata...

Code First Webservice using jax-ws and CXF- webservice framework

Create a Bean Create a SEI-Service End Point Interface Use Annotation on the SEI @ webservice Create a Implementation Class which implements the SEI Create a CXF.xml file add the  SEI and impl mapping in the xml file configure the cxf file in the web.xml map the  spring context listener and cxf servlet in the web.xml.

What are the Front ends Provided by Apache CXF

JAX-WS JAX-RS Simple JavaScript

What is Bindings in Webservice and types of Bindings

Bindings: Maps a webservice message to the protocol. Types of Bindings: SOAP bindings: Maps a webservice message to a SOAP service Pure XML Bindings :sends a raw xml message HTTP Bindings :Maps webservice message using a RESTFUL service.

Creating threadpool to execute tasks

The below code shows  usage of  util.concourrent.ExecutorService to create a thread pool. The tasks are executed concurrently using the avilable number of fixed threads. Below link tells us the difference of thread vs runnable interface 3) Runnable interface represent a Task which can be executed by either plain Thread or Executors or any other means. so logical separation of Task as Runnable than Thread is good design decision. Read more: http://javarevisited.blogspot.com/2012/01/difference-thread-vs-runnable-interface.html#ixzz22rz8RZqi   package com.anjana.threadpools; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.anjana.dao.TenantManager; public class Main { private static final int NTHREDS = 4; public static void main(String[] args) { ExecutorService executor = Executors.newFixedThreadPool(NTHRED...