Monday, September 11, 2017

Java 9 releasing on 21 September 2017

After postponing release many times, finally Java 9 will be releasing on 21 September 2017.
It is much awaited release of Java as there are many structural changes coming with this release in platform.
Java 9 is Modular Java.
Pre-general availability documentation is available on Oracle website.

Link to documentation:
https://docs.oracle.com/javase/9/whatsnew/toc.htm#JSNEW-GUID-C23AFD78-C777-460B-8ACE-58BE5EA681F6

More details about Java 9 project is available at:
http://openjdk.java.net/projects/jdk9/

Java 9 is finally released and JDK download link is:
http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html

Sunday, September 10, 2017

Interceptor for Spring Rest controller

Create a java class which extends HandlerInterceptorAdapter.
You can override preHandle and postHandle methods as per your requirement.

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
System.out.println("In Prehandle");
}
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
    System.out.println("In postHandle");
}

In spring-mvc-context.xml file, define class as interceptor as

 
  

Now your interceptor class should intercept all requests towards Rest controller. 

Sunday, July 30, 2017

Amazon Web Services - Getting started

Registration:

  • After filling basic information, you need to fill billing information (Credit card details) during the registration process.
  • After entering billing information, Transaction of Rs. 2 will be initiated to verify your Billing details (Transaction will be cancelled later by Amazon automatically).
  • Verification of Phone/Mobile with Automated Call.
  • Post verification, your account will be created.

Getting Started with Amazon Web Service Cloud:
  • On AWS dashboard, there are different options to start with, Choose - Launch a Virtual Machine option

  • Type Name for your instance.
  • There will be option to download private key to connect to instance.
  • Download private key(*.pem format)
  • After you submit, your instance will be launched successfully.
  • You can view the instance from Instances option of EC2 Dashboard.


Connecting to Virtual Machine using Putty:
  • You need to generate private key using PuttyGen application.
  • Load your_key.pem in PuttyGen by clicking Load button.
  • Click on generate private key button. (It will warning message to save key without passcode. Select Yes).
  • Save the private key (format *.ppk)
  • Open Putty terminal window.
  • Default user for VM is "ec2-user".
  • Check Public DNS of your Virtual machine on EC2 dashboard. Format of DNS is like ëc2-*-2.compute.amazonaws.com
  • Enter hostname as : ec2-user@public-DNS of your VM. - ec2-user@ec2-*-us-east-2.compute.amazonaws.com
  • Enter port as 22.
  • Open SSH tab on left and on Auth tab - Select private key file as *.ppk file which is generated using PuttyGen tool.
  • Click on Open. You should be able to connect to Virtual Machine.
TroubleShooting while connecting to VM:
  • By default, IP address for Inbound connections on VM is the one from which you have created Virtual Machine and it is managed by Security Groups.
  • Check which Security Group is assigned to your VM in Description at the bottom.
  • View Inbound Rules - Set source IP as 0.0.0.0/0 for Port 22 if it is not already set as 0.0.0.0/0
  • Now you should be able to connect.
You will see Terminal console with following message:

Using username "ec2-user".
Authenticating with public key "imported-openssh-key"
       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2017.03-release-notes/
1 package(s) needed for security, out of 3 available
Run "sudo yum update" to apply all updates.
[machine-info/] $


Note:
By default, JDK version .7 is installed on VM. You can change it to JDK version 8