Tuesday, September 28, 2010

Interview-java-

http://www.javaperformancetuning.com/tips/appservers.shtml#REF9




Class Loader

Typically class loaders are arranged in a parent/child hierarchy. When a class loading request is presented to a class loader, it first asks its parent class loader to fulfill the request. The parent, in turn, asks its parent for the class until the request reaches the top of the hierarchy. If the class loader at the top of the hierarchy cannot fulfill the request, then the child class loader that called it is responsible for loading the class. If the child is also unable to load the class, the request continues back down the hierarchy until a class loader fulfills it or aClassNotFoundException is produced by the class loader at the bottom of the hierarchy.


Figure 1 illustrates a basic class loading hierarchy. Note that a class loaded at a given level in the hierarchy may not reference any classes loaded at a lower level in the hierarchy. Stated another way, a class loader has no visibility into classes loaded by its descendants. In figure 1, if class Foo is loaded by class loader B, and Foodepends on class Baz, then class Baz must be loadable by either class loader A or B. If Baz is only visible to class loader C or D, then a ClassNotFoundException will occur.

ArrayList

Now for some implementation notes. The ArrayList is actually encapsulating an actualy Array, an Object[]. When you instanciate ArrayList, an array is created, and when you add values into it, the array changes its size accordingly. This gives you strengths and weaknesses:

  • Fast Random Access
  • You can perform random access without fearing for performence. Calling get(int) will just access the underlying array.

  • Adding values might be slow When you don’t know the amount of values the array will contain when you create it, a lot of shifting is going to be done in the memory space when the ArrayList manipulates its internal array.
  • Slow manipulation When you’ll want to add a value randomly inside the array, between two already existing values, the array will have to start moving all the values one spot to the right in order to let that happen.

LinkedList

The LinkedList is implemented using nodes linked to each other. Each node contains aprevious node link, next node link, and value, which contains the actual data. When new data is inserted, a node is inserted and the links of the surrounding nodes are updated accordingly. When one is removed, the same happens – The surrounding nodes are changing their links and the deleted node is garbage collected. This, as well, gives strengths and weaknesses:

  • Fast manipulation As you’d expect, adding and removing new data anywhere in the list is instantanious. Change two links, and you have a new value anywhere you want it.
  • No random access Even though the get(int) is still there, it now just iterates the list until it reaches the index you specified. It has some optimizations in order to do that, but that’s basically it.

Some Conclusions

ArrayList is very useful when a well defined set of data is needed in a List interface as opposed to an array. It can be dynamically changed, but try not to do so frequently throughout the life of the application. LinkedList is there for you to do just that:Manipulating it is very easy, and as long as its used for iteration purposes only and not for random accessing, it’s the best solution. Further, if you need random accessing from time to time, I suggest toArray for that specific moment.

Another point I didn’t raise here is the Queue issue. LinkedList implements extended abilities to the normal List interface which allows it to add and remove elements from its beginning and end. This makes the LinkedList perfect for Queue and Stack purposes – Although in Java 5 they already added a Stack class.

Hope this helped someone. Tell me if you want to differ.



SoftReferences are typically used for implementing memory caching. The JVM should try to keep softly referenced objects in memory as long as possible, and when memory is low clear the oldest soft references first. According to the JavaDoc, there are no guarantees though.

WeakReferences is the reference type I use most frequently. It's typically used when you want weak listeners or if you want to connect additional information to an object (using WeakHashMap for example). Very useful stuff when you want to reduce class coupling.

Phantom references can be used to perform pre-garbage collection actions such as freeing resources. Instead, people usually use the finalize() method for this which is not a good idea. Finalizers have a horrible impact on the performance of the garbage collector and can break data integrity of your application if you're not very careful since the "finalizer" is invoked in a random thread, at a random time.

In the constructor of a phantom reference, you specify a ReferenceQueue where the phantom references are enqueued once the referenced objects becomes "phantom reachable". Phantom reachable means unreachable other than through the phantom reference. The initially confusing thing is that although the phantom reference continues to hold the referenced object in a private field (unlike soft or weak references), its getReference() method always returns null. This is so that you cannot make the object strongly reachable again.

From time to time, you can poll the ReferenceQueue and check if there are any new PhantomReferences whose referenced objects have become phantom reachable. In order to be able to to anything useful, one can for example derive a class from java.lang.ref.PhantomReference that references resources that should be freed before garbage collection. The referenced object is only garbage collected once the phantom reference becomes unreachable itself.

  • Performance
    • How quickly must the system respond to interactive operations of different kinds?
    • Are there different classes of interactive operations that users have different tolerances / expectations for?
    • Is there a batch window? What runs in it?
    • Do the batches have their own performance constraints, e.g., to clear the batch window before it closes?
    • Does the batch load influence any interactive users running at the same time?
    • Is there data with a high read/write access ratio that can be cached in memory at different tiers in the architecture?
    • What are the expected performance bottlenecks?
      • CPU?
      • Memory on client, server or intermediate nodes?
      • Hard drive space on each node?
      • Communications links?
      • DB
        • Access
        • Searching
        • Complex joins
      • Interaction with other internal systems?
      • Interaction with systems in other departments?
      • Interaction with partner systems?
      • Interactions with public systems?
  • Scalability
    • Peak load of how many users doing what kinds of operations?
    • Ability to grow to how many records in which critical database tables without slowing down related operations by more than X
    • Avoiding saturating a communication link that cannot be upgraded to a higher speed?
    • What dimensions can be scaled, e.g., more CPUs, more memory, more servers, geographical distribution?
    • Is the primary scaling strategy to "scale up" or to "scale out" -- that is, to upgrade the nodes in a fixed topology, or to add nodes?
  • Availability
    • What is the required uptime percentage?
    • Does this vary by time of day or location?
    • What is the current schedule of controlled outages? Is this acceptable, or is there a goal to improve it?
  • Reliability
    • Are there components with reliabilities that are known to be less than the required reliability of the system?
    • What strategies are currently in place to build more reliable capabilities out of less reliable capabilities?
    • What is the expected mean time to failure by failure severity by operation?
    • How will reliability be assessed prior to deployment?
  • Security
    • What operations need to be secured?
    • How will users be administered?
    • How will users be given permissions to access secured operations?
    • What are the different levels of security and how do these map
      • Security by operation
      • Security by type of object
      • Security by instance of object
  • Maintainability
    • Are there concerns about the ability to hire appropriate technology skills, attract them to the area at reasonable prices?
    • What kinds of changes are anticipated in the first rounds of maintenance? What are their relative priority?
    • What sort of regression testing is required to ensure that maintenance changes do not degrade existing functionality?
    • What sort of maintenance documentation is expected to be produced? When?
  • Flexibility
    • Is there system behavior that needs to be changed regularly without program changes?
      • Can this be encoded in the database?
      • Are there run-time rules that can be handled using a rules interpretation engine?
      • Are there functions that should be user scripted? If so, how will these be QA-ed?
  • Configurability
    • What parameters need to be set on a machine-by-machine basis?
  • Personalizability
    • What aspects of the system can be customized on a per-user basis?
    • How does the user change these settings?
    • What is the strategy for defaults?
  • Usability
    • Are there operations that need to be done as quickly as possible, so that user gestures should be minimized?>
    • Are there difficult or occasional-user operations that require non-standard presentations to help the user perform correctly?
    • What is the balance between data integrity and the ability to stop in a "work in progress" state?
    • What styles of validation are used in what situations?
    • What metaphors from existing or parallel systems should be used?
    • What sort of training deliverables are expected?
    • What sort of on-board help system is expected?
  • Portability
    • Data portability between this system and other systems?
    • Portability across different versions of a single vendor's DB?
    • Ability to port to a different vendor's DB? Which one(s)? When?
    • Browser portability? What browser versions? Historical and future?
    • Operating system portability?
  • Conformance to standards
    • What legal standards apply?
    • What technical standards apply?
    • Other standards, e.g., 508.1 for disabled users?
    • What development standards apply?
      • Database naming standards
      • Existing internal architectural standards (e.g., everything goes in an Oracle database)
      • Language and coding standards
      • Testing and review standards
      • Presentation standards, e.g., use of standard colors, controls or other affordances?
      • Lifecycle models or methodologies
  • Internationalizability
    • What languages?
    • In what order?
    • How translated?
    • Single or multi byte character sets?
  • Efficiency -- space and time
  • Responsiveness
    • What are the expected and upper limit response times per operation in the system?
    • What is the trade-off between lower averages and wider variations in response time?
  • Interoperability
    • What systems will this system interoperate with immediately?
    • What other systems are anticpated?
    • What classes of internal and external systems might later be needed to interoperate with?
    • What functionality from this system needs to be exposed as a service in a service oriented architecture?
    • What functionality from this system needs to be exposed as a Web service or via a portal?
  • Upgradeability
    • Do the servers need to be upgraded while running?
    • How many client stations need to be upgraded, and what are the costs and mechanisms for upgrading them?
    • How often do different kind of fixes need to be distributed? Are there "hot fixes" that have to go out right away, but others that can wait? How often do each kind occur?
  • Auditability / traceability
    • What record of who did what when must be maintained?
    • For how long?
    • Who accesses the audit trails?
    • How?
    • Is archive to tape or other off-site storage media required?
    • Is "effective dating" required?
  • Transactionality
    • What are the important database and application transaction boundaries?
    • Is standard "optimistic" locking appropriate, or is something more complex required in some or all cases>
    • Is disconnected operation required by any node?
  • Administrability
    • What live usage information needs to be displayed?
    • To who? How? When?
    • What "live" interventions are required?
    • What ability to handle remote configurations are required?
    • Are there existing application management consoles that will be used to manage this application?
  • Lots of others -- what are your favorites?

Tuesday, September 7, 2010

Data Structure

Tree traversal
public Node find(int key) // find node with given key
{ // (assumes non-empty tree)
Node current = root; // start at root
Finding a Node 377
while(current.iData != key) // while no match,
{
if(key <>
current = current.leftChild;
else
current = current.rightChild; // or go right?
if(current == null) // if no child,
return null; // didn’t find it
}
return current; // found it
}

-=====================
Inserting in a tree
public void insert(int id, double dd)
{
Node newNode = new Node(); // make new node
newNode.iData = id; // insert data
newNode.dData = dd;
if(root==null) // no node in root
root = newNode;
else // root occupied
{
Node current = root; // start at root
Node parent;
while(true) // (exits internally)
{
parent = current;
if(id <>
{
current = current.leftChild;
if(current == null) // if end of the line,
{ // insert on left
parent.leftChild = newNode;
return;
}
} // end if go left
else // or go right?
{
380 CHAPTER 8 Binary Trees
current = current.rightChild;
if(current == null) // if end of the line
{ // insert on right
parent.rightChild = newNode;
return;
}
} // end else go right
} // end while
} // end else not root
} // end insert()
// -------------------------------------------------------------



Quick sort

function quicksort(array)      var list less, greater      if length(array) ≤ 1          return array      select and remove a pivot value pivot from array      for each x in array          if x <>then append x to less          else if x > pivot then append x to greater      return concatenate(quicksort(less), pivot, quicksort(greater))

Shell sort
inc ← round(n/2)
while inc > 0 do:
for i = inc .. n − 1 do:
temp ← a[i]
j ← i
while j ≥ inc and a[j − inc] > temp do:
a[j] ← a[j − inc]
j ← j − inc
a[j] ← temp
inc ← round(inc / 2.2)


Quick sort
As you can see, there are three basic steps:
1. Partition the array or subarray into left (smaller keys) and right (larger keys)
groups.
Quicksort 333
2. Call ourselves to sort the left group.
3. Call ourselves again to sort the right group.

Thursday, September 2, 2010

products considering

1) Classification.
a) open source product - Statistical knowledge lacking.
b) configurable product.

2) Cloud computing is in demand.

Tuesday, August 31, 2010

Interview questions PM


1) How to call functions from oracle?

2) The difference between drop and truncate table.

2) What is the difference between function and stored procedure?
1. Function is mainly used in the case where it must return a value. Where as a procedure may or may not return a value or may return more than one value using the OUT parameter.
Â
2. Function can be called from SQL statements where as procedure can not be called from the sql statements

3. Functions are normally used for computations where as procedures are normally used for executingbusiness logic.

4. You can have DML (insert,update, delete) statements in a function. But, you cannot call such a function in a SQL query.

5. Function returns 1 value only. Procedure can return multiple values (max 1024).

6.Stored Procedure: supports deferred name resolution. Example while writing a stored procedure that uses table named tabl1 and tabl2 etc..but actually not exists in database is allowed only in during creation but runtime throws error Function wont support deferred name resolution.

7.Stored procedure returns always integer value by default zero. where as function return type could be scalar or table or table values

8. Stored procedure is precompiled execution plan where as functions are not.
Â
9.A procedure may modify an object where a function can only return a value The RETURN statement immediately completes the execution of a subprogram and returns control to the caller.

2) What are different artifacts required at different stages of project management.

3) What are different statistical reports do you generate

4) CPM of the project management.

4.1) Difference between enumeration and iterator
Enumeration does not have remove method but iteration has.......

5) Definition of a milestone.
A significant event in the project, usually completion of a major deliverable.

6) Distribution of effort in project management.

7) Defect density.
Defect density refers to the ratio of number of defects to program size, typically measured in lines of code (LOC) or function points (FP)

8) Class loading have a delegation where if the child is not able to find, it will delegate to parent to find the class.


Static variables are stored in the heap area called perm generation.


By default, classes in Java do not support cloning; the default implementation of the clone() method throws a CloneNotSupportedException. You should override implementation of the clone() method. Remember that you must make it public and, inside the method, your first action must be super.clone(). Classes that want to allow cloning must implement the marker interface Cloneable. Since the default implementation of Object.clone only performs a shallow copy, classes must also override clone to provide a custom implementation when a deep copy is desired. Basically, if you want to make objects of your class publicly cloneable, you need code like this:



The only requirement on the constructor for a class that implements Serializable is that the first non-serializable superclass in its inheritence hierarchy must have a no-argument constructor.

he virtual machine incorporated a number of different garbage collection algorithms that are combined using generational collection.

When the young generation fills up it causes a minor collection.Minor collections can be optimized assuming a high infant mortality rate.

Some surviving objects are moved to atenured generation. When the tenured generation needs to be collected there is a major collectionthat is often much slower because it involves all live objects.

If the garbage collector has become a bottleneck, you may wish to customize the generation sizes. Check the verbose garbage collector output, and then explore the sensitivity of your individual performance metric to the garbage collector parameters.

The young generation consists of eden plus two survivor spaces . Objects are initially allocated in eden. One survivor space is empty at any time, and serves as a destination of the next, copying collection of any live objects in eden and the other survivor space. Objects are copied between survivor spaces in this way until they are old enough to be tenured, or copied to the tenuredgeneration.

Thepermanent generation is special because it holds data needed by the virtual machine to describe objects that do not have an equivalence at the Java language level. For example objects describing classes and methods are stored in the permanent generation.

-verbose:gc

The bridge pattern is a design pattern used in software engineering which is meant to "decouple an abstraction from its implementation so that the two can vary independently" [1]. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.


the adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface

use case generalization is reverse arrow.


The composite pattern describes that a group of objects are to be treated in the same way as a single instance of an object.

In object-oriented programming, the decorator pattern is a design pattern that allows new/additional behaviour to be added to an existing object dynamically.

A facade is an object that provides a simplified interface to a larger body of code, such as a class library. A facade can:

  • make a software library easier to use and understand and test, since the facade has convenient methods for common tasks;
  • make code that uses the library more readable, for the same reason;
  • reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system;
  • wrap a poorly-designed collection of APIs with a single well-designed API (as per task needs).
A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate.

The memento pattern is a software design pattern that provides the ability to restore an object to its previous state (undo via rollback).


  • Atomicity—all changes that a transaction makes to a database are made as one unit; otherwise, all changes are rolled back.
  • Consistency—a successful transaction transforms a database from a previous valid state to a new valid state.
  • Isolation—changes that a transaction makes to a database are not visible to other operations until the transaction completes its work.
  • Durability—changes that a transaction makes to a database survive future system or media failures.

For XA drivers, the system automatically selects the Two-Phase Commit protocol for global transaction processing.

Emulate Two-Phase Commit: With this option, the transaction branch in which the connection is used always returns success for the prepare phase of the transaction. It offers performance benefits, but also has risks to data in some failure conditions. Select this option only if your application can tolerate heuristic conditions.


  1. Import the following classes:
  2. import javax.transaction.UserTransaction;
    import java.sql.*;
    import javax.naming.*;
    import java.util.*;
    import weblogic.jndi.*;
  3. Establish the transaction by using the UserTransaction class. You can look up this class on the JNDI tree. The UserTransaction class controls the transaction on the current execute thread. Note that this class does not represent the transaction itself. The actual context for the transaction is associated with the current execute thread.
  4. Context ctx = null;
    Hashtable env = new Hashtable();

    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");

    // Parameters for the WebLogic Server.
    // Substitute the correct hostname, port number
    // user name, and password for your environment:
    env.put(Context.PROVIDER_URL, "t3://localhost:7001");
    env.put(Context.SECURITY_PRINCIPAL, “Fred”);
    env.put(Context.SECURITY_CREDENTIALS, “secret”);

    ctx = new InitialContext(env);

    UserTransaction tx = (UserTransaction)
    ctx.lookup("javax.transaction.UserTransaction");
  5. Start a transaction on the current thread:
  6. // Start the global transaction before getting a connection
    tx.begin();
  7. Load the JTS driver:
  8. Driver myDriver = (Driver)
    Class.forName("weblogic.jdbc.jts.Driver").newInstance();
  9. Get a connection from the data source:
  10. Properties props = new Properties();
    props.put("connectionPoolID", "myDataSource");

    conn = myDriver.connect("jdbc:weblogic:jts", props);
  11. Execute your database operations. These operations may be made by any service that uses a database connection, including EJB, JMS, and standard JDBC statements. These operations must use the JTS driver to access the same data source as the transaction begun in step 3 in order to participate in that transaction.
  12. If the additional database operations using the JTS driver use a different data source than the one specified in step 5, an exception will be thrown when you try to commit or roll back the transaction.

  13. Close your connection objects. Note that closing the connections does not commit the transaction nor return the connection to the pool:
  14. conn.close();
  15. Complete the transaction by either committing the transaction or rolling it back. In the case of a commit, the JTS driver commits all the transactions on all connection objects in the current thread and returns the connection to the pool.
  16. tx.commit();

    // or:

    tx.rollback();


    Resultset wasnull will give the option whether the value is null or not


    UserTransaction tx = (UserTransaction)
    ctx.lookup("javax.transaction.UserTransaction");
    tx.begin();


    PreparedStatement is not compiling query every time.
    PreparedStatement is better for CLOB and BLOB object.
    Example:


    transaction attribute may have one of the following values:

    • Required
    • RequiresNew
    • Mandatory
    • NotSupported
    • Supports
    • Never

    Required

    If the client is running within a transaction and invokes the enterprise bean's method, the method executes within the client's transaction. If the client is not associated with a transaction, the container starts a new transaction before running the method.

    The Required attribute will work for most transactions. Therefore, you may want to use it as a default, at least in the early phases of development. Because transaction attributes are declarative, you can easily change them at a later time.

    RequiresNew

    If the client is running within a transaction and invokes the enterprise bean's method, the container takes the following steps:

    1. Suspends the client's transaction
    2. Starts a new transaction
    3. Delegates the call to the method
    4. Resumes the client's transaction after the method completes

    If the client is not associated with a transaction, the container starts a new transaction before running the method.

    You should use the RequiresNew attribute when you want to ensure that the method always runs within a new transaction.

    Mandatory

    If the client is running within a transaction and invokes the enterprise bean's method, the method executes within the client's transaction. If the client is not associated with a transaction, the container throws theTransactionRequiredException.

    Use the Mandatory attribute if the enterprise bean's method must use the transaction of the client.

    NotSupported

    If the client is running within a transaction and invokes the enterprise bean's method, the container suspends the client's transaction before invoking the method. After the method has completed, the container resumes the client's transaction.

    If the client is not associated with a transaction, the container does not start a new transaction before running the method.

    Use the NotSupported attribute for methods that don't need transactions. Because transactions involve overhead, this attribute may improve performance.

    Supports

    If the client is running within a transaction and invokes the enterprise bean's method, the method executes within the client's transaction. If the client is not associated with a transaction, the container does not start a new transaction before running the method.

    Because the transactional behavior of the method may vary, you should use the Supports attribute with caution.

    Never

    If the client is running within a transaction and invokes the enterprise bean's method, the container throws a RemoteException. If the client is not associated with a transaction, the container does not start a new transaction before running the method.


    setup() for setting up

    teardown() for releasing the resources.



    MVC1 is request goes to JSP which works as controller.

    MVC2 the request goes to servlet which works as controller.



    Different modules of spring are

    • The core container provides the essential functionality of the Spring framework. A primary component of the core container is the BeanFactory, an implementation of the Factory pattern. The BeanFactory applies the Inversion of Control (IOC) pattern to separate an application's configuration and dependency specification from the actual application code.
    • The Spring context is a configuration file that provides context information to the Spring framework. The Spring context includes enterprise services such as JNDI, EJB, e-mail, internalization, validation, and scheduling functionality.
    • The Spring AOP module integrates aspect-oriented programming functionality directly into the Spring framework, through its configuration management feature. As a result you can easily AOP-enable any object managed by the Spring framework. The Spring AOP module provides transaction management services for objects in any Spring-based application. With Spring AOP you can incorporate declarative transaction management into your applications without relying on EJB components.
    • The Spring JDBC DAO abstraction layer offers a meaningful exception hierarchy for managing the exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the amount of exception code you need to write, such as opening and closing connections. Spring DAO's JDBC-oriented exceptions comply to its generic DAO exception hierarchy.
    • The Spring framework plugs into several ORM frameworks to provide its Object Relational tool, including JDO, Hibernate, and iBatis SQL Maps. All of these comply to Spring's generic transaction and DAO exception hierarchies.
    • The Web context module builds on top of the application context module, providing contexts for Web-based applications. As a result, the Spring framework supports integration with Jakarta Struts. The Web module also eases the tasks of handling multi-part requests and binding request parameters to domain objects.
    • The Model-View-Controller (MVC) framework is a full-featured MVC implementation for building Web applications. The MVC framework is highly configurable via strategy interfaces and accommodates numerous view technologies including JSP, Velocity, Tiles, iText, and POI.
      • Setter-based DI is realized by calling setter methods on your beans after invoking a no-argument constructor or no-argument static factory method to instantiate your bean.

      • Constructor-based DI is realized by invoking a constructor with a number of arguments, each representing a collaborator.

      What is Bean Factory ?

      A BeanFactory is like a factory class that contains a collection of beans. The BeanFactory holds Bean Definitions of multiple beans within itself and then instantiates the bean whenever asked for by clients.

      • BeanFactory is able to create associations between collaborating objects as they are instantiated. This removes the burden of configuration from bean itself and the beans client.
      • BeanFactory also takes part in the life cycle of a bean, making calls to custom initialization and destruction methods.

      What is the difference between Bean Factory and Application Context ?

      On the surface, an application context is same as a bean factory. But application context offers much more..

      • Application contexts provide a means for resolving text messages, including support for i18n of those messages.
      • Application contexts provide a generic way to load file resources, such as images.
      • Application contexts can publish events to beans that are registered as listeners.
      • Certain operations on the container or beans in the container, which have to be handled in a programmatic fashion with a bean factory, can be handled declaratively in an application context.
      • ResourceLoader support: Spring’s Resource interface us a flexible generic abstraction for handling low-level resources. An application context itself is a ResourceLoader, Hence provides an application with access to deployment-specific Resource instances.
      • MessageSource support: The application context implements MessageSource, an interface used to obtain localized messages, with the actual implementation being pluggable

      . How is a typical spring implementation look like ?

      For a typical Spring Application we need the following files:

      • An interface that defines the functions.

      • An Implementation that contains properties, its setter and getter methods, functions etc.,

      • Spring AOP (Aspect Oriented Programming)

      • A XML file called Spring configuration file.

      • Client program that uses the function.



        14. What is the typical Bean life cycle in Spring Bean Factory Container ?

        Bean life cycle in Spring Bean Factory Container is as follows:

        • The spring container finds the bean’s definition from the XML file and instantiates the bean.

        • Using the dependency injection, spring populates all of the properties as specified in the bean definition

        • If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID.

        • If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of itself.

        • If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization() methods will be called.

        • If an init-method is specified for the bean, it will be called.

        • Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called.

          14. What is the typical Bean life cycle in Spring Bean Factory Container ?

          Bean life cycle in Spring Bean Factory Container is as follows:

          • The spring container finds the bean’s definition from the XML file and instantiates the bean.

          • Using the dependency injection, spring populates all of the properties as specified in the bean definition

          • If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID.

          • If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of itself.

          • If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization() methods will be called.

          • If an init-method is specified for the bean, it will be called.

          • Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called.