Wednesday, 10 December 2014

Log4J

Log4J applications:
public class LogUtility
{
    public static Logger getLogger(Class clazz)
    {
       System.setProperty("logFileName", name + ".log");
        return Logger.getLogger(clazz.getName());
    }
}
log4j.properties:
log4j.rootLogger=DEBUG,CONSOLE,FILE

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.conversionPattern=%m%n

log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=${logFileName}
#log4j.appender.FILE.MaxFileSize=512KB
#log4j.appender.FILE.MaxBackupIndex=3
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p - %m%n

Webservice

Web services:

1. Type of web services:

A. Jax-RPC
B. Jax-WS

2. Ways of building web services:

A. Contract first
B. Contract Last

3. End point choice:

A. Servlet
B. EJB

5. Message exchanging format:

A. Synchronous request and response format
B. Asynchronous request and response
C. One way invoke or fire and forgot

6. Message Exchanging pattern:

A. Style
        a. RPC
        b.  Document
B. Use
        a. Literal
        b. encode

Web service implementation:


@WebService
public interface Reservation
{
    @WebMethod
    public Ticket doBooking(JourneyInfo jInfo, PassiengerInfo pInfo);
}
--------------------------------------------------------------
@WebService(endpointInterface = "com.ibm.pdc.ephs.ws.Reservation")
public class ReservationImpl implements Reservation
{

    public Ticket doBooking(JourneyInfo jInfo, PassiengerInfo pInfo)
    {
        System.out.println("Passenger information:");
        System.out.println(pInfo.getPassName());
        System.out.println(pInfo.getProof());
        System.out.println(pInfo.getAddress());
        System.out.println(pInfo.getAge());
        System.out.println(pInfo.isSex() ? "Male" : "Female");
       
        System.out.println("Journey Information:");
        System.out.println(jInfo.getFromStation());
        System.out.println(jInfo.getToStation());
       
        Ticket ticket = new Ticket();
        ticket.setBearthNumber("B1");
        ticket.setCoathcNumber("B");
        ticket.setPnrNumber(123456);
        ticket.setDateOfjourny(new Date());
        return ticket;
    }

}
-----------------------------------------------------------------------
public class JourneyInfo
{
    private String fromStation;
    private String toStation;
}
public class PassiengerInfo
{
    private String passName;
    private String proof;
    private String address;
    private Integer age;
    private boolean sex;

}
--------------------------------------------------------------------------------
schema




Completed Java Standard Edition 6 certification with 96%.