Pages

Thursday, 10 April 2014

Logging in a clustered environment using Log4j

Logging using Socket Appender.

The logs should be stored in a centralized machine or sever when the application is stored in a clustered environment. Let’s get a scenario where every information level of logs goes in a clustered machine and error level log go in a server or centralized machine. So every cluster will have an information level log and if an error occurs it will show in a centralized machine.


There are four classes (Class1, Class2, Class3, Class4) these classes behave as a clustered application and ClassMain which contain the main method behave as a manager of this cluster. This cluster means class 1 2 3 4 will store the info level logs through RolingFileAppender, show the message in the console using ConsoleAppender and send the error level logs to a centralized machine using SocketAppender.

log4j.xml is the file which is defined in the application; every cluster will have the same property file and log4j-server.xml will be deployed in a centralized machine.

The command for starting socket server:-

java -classpath {Jar Path}\jars\log4j-1.2.17.jar org.apache.log4j.net.SimpleSocketServer
4712 {property file path}\log4j-server.properties 

References

Saturday, 1 March 2014

Steps for installation of Windows 2008 R2 Server

Installation of Windows 2008 R2 Server

  • Insert the appropriate Windows Server 2008 installation media into your DVD drive and reboot the computer and complete installation process.

  • When prompted for an installation language and other regional options, make your selection and press Next.

  • Next. press Install Now to begin the installation process.

  • Enter your Product ID in the next window, click Next.

  • Select the Full version of the right Windows version you're prompted, and click Next.

  • Read and accept the license terms by clicking to select the checkbox and pressing Next.

  • In the "Which type of installation do you want? " window, click the only available option –Custom (Advanced).

  • In the "Where do you want to install Windows?", if you're installing the server on a regular IDE hard disk, click to select the first disk, usually Disk 0, and click Next.

  • The installation process will reboot your computer, so make sure you remove it before going to lunch.
  • Once the install is finished, we’re prompted to change our password before logging in.

  • Windows requires that you have a strong password, seven characters long with atleast three of the four following: uppercase letter, lowercase letter, numeral, or symbol. You’ll want to make sure you write it down somewhere for now, because if you forget it later, the entire install will have to be re-done.

  • Finished! That’s all there is to doing a base install of Windows Server 2008 R2.

Friday, 4 October 2013

Example of mail merge generating multiple files.

Example of mail merge (Dependency Example) generating different files using RTFTemplate library.


  • Add required JARS in class path.
  •  Required JARS:  
       
     rtftemplate-1.0.1-b14.jar  
     commons-collections-3.2.1.jar  
     spring-beans-3.2.2.RELEASE.jar  
     spring-context-3.2.2.RELEASE.jar  
     spring-context-support-3.2.2.RELEASE.jar  
     spring-core-3.2.2.RELEASE.jar  
     spring-expression-3.2.2.RELEASE.jar  
     spring-jdbc-3.2.2.RELEASE.jar  
     spring-orm-3.2.2.RELEASE.jar  
     spring-tx-3.2.2.RELEASE.jar  
     xml-apis-1.0.b2.jar  
     commons-logging-1.1.1.jar  
     freemarker.jar  
     commons-digester-2.1.jar  
     org.apache.commons.beanutils.jar  
     velocity-1.7.jar  
     commons-lang.jar  
    


References:-
http://sourceforge.net/projects/rtftemplate/

http://rtftemplate.sourceforge.net/

Thursday, 3 October 2013

Example of mail Merging

Example of mail Merging (Address Example) using RTFTemplate library.


  • Add required JARS in class path.
  •  Required JAR:  
       
     commons-collections-3.2.1.jar  
     commons-digester-2.1.jar  
     commons-lang.jar  
     commons-logging-1.1.1.jar  
     freemarker.jar  
     org.apache.commons.beanutils.jar  
     rtftemplate-1.0.1-b14.jar  
     spring-beans-3.2.2.RELEASE.jar  
     spring-context-3.2.2.RELEASE.jar  
     spring-context-support-3.2.2.RELEASE.jar  
     spring-core-3.2.2.RELEASE.jar  
     spring-expression-3.2.2.RELEASE.jar  
     spring-tx-3.2.2.RELEASE.jar  
     velocity-1.7.jar  
     xml-apis-1.0.b2.jar  
    
  • Download the RTF sample and Template file in rtf format.
  • Add the required classes.

Wednesday, 4 September 2013

Mail merge functionality using RTF template file.

Overview

RTFTemplate is RTF engine RTF to RTF, which is able to generate RTF by merging template RTF (model RTF  source) with JAVA object (context). RTFTemplate use Velocity for  merging template  with JAVA object.

Steps to Merge RTF template and Java Context:


  • Step Parse RTF model source (1) consist to load RTF model source into RTFDocument structure .RTFDocument contains the whole RTF model, which split RTF elements interpretated by RTFTemplate as fields (RTFField), bookmarks (RTFBookmark)...
  • Step Transform RTF Document (2) consist to transform the RTFDocument structure, in other words:
    1. replace RTF code with specific macro swith template engine selected (ex : replace bookmark with#foreach macro when RTFTemplate is used with Velocity).
    2. remove some RTF code. For merge fields (MERGEFIELD), RTFTemplate remove the character " which include merge fields.









Steps for office Integration

  • RTF  template  can  be  created  with  MS  Word  by,  using MERGEFIELD,  HYPERLINK and BOOKMARK (cf. RTF specification).
  • This template will be merged with  Java objects  (can be  from database, LDAP etc.) and RTF  file will be generated at particular target.
  • These files can be saved in RTF as well as PDF format.
  • The generated files can be printed or send by email.



References:-
http://sourceforge.net/projects/rtftemplate/

http://rtftemplate.sourceforge.net/

Examples.

Address example.
Dependency example.