Wednesday, March 30, 2016

Java Collection

Iterator collection over Iterator vs For-each

   Only Iterator can modify the collection
Iterator vs ListIterator

  • Iterator travel only forward. ListIterator both side
  • Iterator can use on List, Set, Queue but ListIterator only List


ArrayList vs Vector

  • Vector is synchronized and ArrayList not
  • Vector increase its size by doubling, ArrayList in 50%

ArrayList vs LinkList

  • ArrayList use a dynamic array, LinkList use doubly linked list
  • ArrayList Fast store and fetch data, LinkList efficient manipulation



ArryList read past
LinkList list item modify fast 

Set
HashSet Use has map (hashCode()) need to implement hashCode() and equals() //hashcode Ojbject.hash(,,)
TreeSet   Use tree Map ordered
EnumSet 

HashSet vs TreeSet
HashSet  - no order , TreeSet - ascending order

HashMap vs HashTable
  •  HashTable synchronized HashMap not
  • HashTable can't have null key or value but HashMap can 
Collection vs Collections
  • Collection is interface and provide normal functionality
  • Collections is a class to sort and synchronize collections

Fail-Fast vs Fail Safe Iteration 
Fail-Fast - throw concurrent exc - HashMap,Vector, ArrayList, HashSet
Fail-Safe - create a copy when iterator -CopyOnWriteArrayList,
ConcurrentHashMap

Sunday, February 28, 2016

SQL Interview Question

Type Of JOINS
INNER JOIN-simple join/default
    Returns all rows for which there is at least one match in both table

LEFT JOIN- left outer join
    Return all rows form left table and the match row form right table

RIGIT JOIN-right outer join
    Return all from right table and match row for left table

FULL JOIN
    Return all rows for which there is a match in either of tables. union of left and right join

CROSS JOIN


   

Interview Question

IOC vs ID?
IOC
Giving control to the container to get instance of object is called Inversion of Control., means instead of you are creating object using new operator, let the container do that for you.

DI
Way of injecting properties to an object is called Dependency injection.
    We have three types of Dependency injection
        1)  Constructor Injection
        2)  Setter/Getter Injection
        3)  Interface Injection - not support by spring 

Friday, April 5, 2013

JBOSS Login module tutorial



STEP 1
Jsp login form

  • set form action as j_security_check
  • set user ID text field name as j_username
  • set password text field name as j_password
login.jsp


STEP 2
Set security area of the web application in web.xml file
Hear we are defined separate secured url patten such as http://www.localhost/test-login/secure/home.jsp  .

This mean request which comes with url patten like http://www.localhost/test-login/secure/* only could access for successfully log-in users.


/WEB-INF/web.xml

In the login-config.xml it should be mention
  • login-relam name
  • login form url
  • login error url

STEP 3
Add jboss-web.xml in WEB-INF folder in project

/WEB-INF/jboss-web.xml

STEP 4
JBOSS Configuration

Add new application policy on log-config.xml. Hear
  • TESTLoginRealm – login-relam name
  • test_datasource – Datasource name which has created on test_ds.xml in deploy directory
  • principalsQuery – This query should return password of the user
/default/conf/login-config.xml


Add multiple log for JBOSS server


  1. $JBOSS_HOME\<jboss instance eg: default>\conf\jboss-log4j.xml
  2. Add new appender
  3. Add new category with reference to appender

Hear priority value should be  DEBUG , INFO, WARN, ERROR,FATAL
if you put,

  1. DEBUG you will have all logging levels
  2. INFO you will INFO, WARN, ERROR,FATAL
  3. WARN you will  WARN, ERROR,FATAL
  4. ERROR you will   ERROR,FATAL
Put package name which contain you logger java class as  category name
Eg : com.dinusha

Spring context file path from outside jar

How to add plug-in to eclipse manually

  1. Download  and extract Eclipse  zip or tar file
  2. go to eclipse home folder(\opt\eclipse or F:\eclipse)
  3. There you can fined folder call features and plugins. Copy that extracted eclipse plugin folder into both features and plugins