Saturday 7 May 2016

context,servlet, path info

The servlet engine splits the URI into three useful sections: the context path (application prefix), the servlet path, and the path info.

For example, given an application prefix of '/myapp', the api /myapp/dir/test.jsp/data will be split as follows:

/myapp/dir/test.jsp/datagetRequestURI()
/myappgetContextPath()
/dir/test.jspgetServletPath()
/datagetPathInfo()

REF : Servlet API

why to choose enum in java

why to choose enum in java

This are special data type that enables for a variable to set  predefined constants REF[1]

If you use enums instead of integers (or String codes), you increase compile-time checking and avoid errors from passing in invalid constants, and you document which values are legal to use REF[2]


Let us take an example where you want to send the status code for service call requested.

ex :

define a service class which will take a request

# make a Http request.
@GET
#define the path for request.
@PATH(/voice)
#define mediatype to produce/consume
@Produces(MediaType.APPLICATION_JSON)
#start the service method
public Response VoiceResponse(){
ResponseBuilder responseBuilder = Response.status(ServerStatus.Server_Error);

}



Because they are constants, the names of an enum type's fields are in uppercase letters. REF[1]

define a class of enum type.

public enum ServerStatus {

#define status code
SUCCESS(200,'OK'),

#define server error.
Server_Error(500,'Internal server error')
}





REF :
1.oracle
2. stackoverflow

Friday 6 May 2016

Eclipse shortcuts

Eclipse shortcuts

Navigational Shortcuts:

F10

Main menu:

Shift+ F10 Context menu
Ctrl +F10 View menu

Workspace navigation:

F12 Activate editor
Ctrl+Shift+W Switch editor
Ctrl +F6 Next editor
Ctrl +Shift+ F6 Prev editor
Ctrl F7 Next workspace
Ctrl Shift F7 Prev workspace
Ctrl+ F8 Next perspective
Ctrl +Shift+ F8 Prev perspective
Alt +Left Back
Alt+ Right Forward

Files:

Alt +Shift+ S Show in…
Ctrl+ Shift+ R Jump to file
Ctrl+ N New file
Ctrl +S Save file
Ctrl +Shift+ S Save all files
Ctrl+ F4 Close file
Ctrl+ Shift+ F4 Close all files

Find:

Ctrl +L Goto line
Ctrl +F Find
Ctrl +J Incremental find
Ctrl +Shift+ J Incremental find prev
Ctrl+ K Find next
Ctrl +Shift+ K Find prev
Ctrl +H Search workspace
Ctrl +(dot) Navigate next
Ctrl +(comma) Navigate prev

Java navigation:

F3 Goto declaration
Ctrl+ Shift+ U Find references in file
Ctrl +Shift+ G Find references in workspace
Ctrl+ G Find declarations in workspace
Ctrl +Shift+ P Navigate to matching bracket/brace
Ctrl +T Popup type hierarchy
Ctrl +Shift+ T Open Type
Ctrl +O Outline of current source
Ctrl +F3 Outline of current cursor position
Ctrl +Shift+ Arrow Jump beetween methods up or down
F2 Show Javadoc
F4 Show hierarchy
Ctrl +Alt+ H Open call hierarchy

General editing:

Alt+ Arrow+ Move line(s) up or down
Alt +Shift+ Up Expand selection to enclosing element
Alt +Shift+ Right Expand selection to next element
Alt+ Shift+ Left Expand selection to previous element
Alt +Shift+ Down Restore previous selection
Ctrl +Alt +Arrow Duplicate line(s) up or down
Shift +Enter Insert line below
Ctrl +Shift+ Enter Insert line above
Ctrl +D Delete line
Ctrl +Shift+ Q Toggle Quick Diff
Ctrl +Shift+ Y Convert to lowercase
Ctrl +Shift +X Convert to uppercase

Java editing:

Al+t Shift+ U Remove occurrence annotations
Ctrl +1 Quick fix (works even when there are no errors
Ctrl +Shift+ M Add import
Ctrl +Shift+ F Reformat
Ctrl +Shift+ O Organize Imports
Ctrl +/ Comment
Ctrl +\ UnComment
Ctrl +Shift+ Space Parameter hints
Ctrl Hyperlink identifier
Ctrl+ I Correct indentation
Shift+ Space Incremental content assist

Debugger:

F5 Step into
F6 Step over
F7 Run to return
F8 Resume
F9 Relaunch last
F11 Run/debug last
Ctrl+ F11 Run
Ctrl +Shift+ B Toggle breakpoint
Ctrl+ D Display
Ctrl +Q Inspect
Ctrl +R Run to line
Ctrl +U Run snippet

Refactoring:

Alt+ T Refactoring menu
Ctrl+ Shift+ Z Undo refactor
Ctrl +Shift+ Y Redo refactor
Alt +Shift +R Rename
Alt +Shift+ V Move
Alt +Shift+ I Inline
Alt +Shift+ M Extract method
Alt +Shift+ L Extract local
Alt +Shift+ C Change method signature

Misc:

F5 Refresh
F1 Infopop
F2 Show resizeable hover


Thanks to Sathya

Thursday 5 May 2016

Create public and private keys using ssh-key-gen to connect repository.

Create public and private keys using ssh-key-gen

1. go to your machine.

2. check if ssh key are available or not.
cmd : ls -al ~/.ssh

3. create/genrate new ssh key.
cmd : ssh-keygen -t rsa -C "voice@voice.com"

4)  go to .ssh directory, open new created   id_rsa.pub file, copy the content and save at you local, so we can to other repo
ex : github
ssh dir :  /home/../.ssh

5) open github and paste key in ssh section of github setting and save.

6) now come to machine make a ssh call to git
ex : ssh -vT git@github.com


REF :
1. github
2. video








same procedure follow for git.
how do you access private git repository from jenkins.

Failed to connect to repository : Error performing command: git ls-remote -h in jenkins

Failed to connect to repository : Error performing command: git ls-remote -h git@github.com:voice/voice_Java.git HEAD.

solution : problem might be due to you have not installed git repo on the machine.

install and try again in jenkins when creating a job configuration.

Wednesday 4 May 2016

error: [ng:areq] Argument ' ' is not a function, got undefined

error: [ng:areq] Argument ' ' is not a function, got undefined.

initialize the controller.

solution :

console.log("hi");
 
  var voiceApp =  angular.module("voice",[]);
 
  surveyApp.controller('voiceCTRL', function() {
 
  console.log("hi");
  });

Tuesday 3 May 2016

jprofiler

jprofiler.

install jprofiler.

jprofiler is java profiling tool, it also includes feature to profile cpu,memory,threads.

getting started with jprofiler.

1. download latest version
ref: jprofiler

2) Insatall the software.

3) intigrate with ide(eclipse).
steps to intigrate.

a) start jprofiler.
b) go to session ->IDE intigration ->select IDE-> eclipse (version). click on intigrate.

c) start eclipse.
d) go to windows->prespective->custom prespective->Action set visiblity->check profiler.
intigration is done


2) how to run jprofiler on project.

a) select the project.
b) right click and run ->profile ->profile configuration-> choose the project
c)choose ->apache tomcat-> source (remove the default if there are any).
d)add the project source directory.click on profile.
e) jprofiler will start window with statistics.