Tuesday, February 21, 2012

What is eager loading?

There are three levels:
  1. Eager loading: you do everything when asked. Classic example is when you multiply two matrices. You do all the calculations. That's eager loading;
  2. Lazy loading: you only do a calculation when required. In the previous example, you don't do any calculations until you access an element of the result matrix; and
  3. Over-eager loading: this is where you try and anticipate what the user will ask for and preload it.
I hope that makes sense in the context you're seeing it.
Let me give you a "Webby" example.
Imagine a page with rollover images like for menu items or navigation. There are three ways the image loading could work on this page:
  1. Load every single image required before you render the page (eager);
  2. Load only the displayed images on page load and load the others if/when they are required (lazy); and
  3. Load only the displayed images on page load. After the page has loaded preload the other images in the background in case you need them (over-eager).

Tuesday, February 14, 2012

JAX-RPC Service-Side Programming Models


JAX-RPC defines two server-side programming models for creating J2EE Web service endpoints: JAX-PRC Service Endpoints andEnterprise JavaBeans Endpoints.  The service endpoint is deployed in a container-based JAX-RPC runtime system.
  • Using a JAX-RPC service endpoint (JSE) ? The service implementation is a Java class in the Web container. The service adheres to the Web container's servlet lifecycle and concurrency requirements.
  • Using an EJB service endpoint? The service implementation is a stateless session bean in an EJB container. The service adheres to the EJB container's lifecycle and concurrency requirements.
In either case, the service is made portable with the definition of a port component, which provides the service's outside view for Web service implementation. A port component consists of:
  • A WSDL document describing the Web service that its clients can use
  • A service endpoint interface defining the Web service's methods that are available to clients.
  • A service implementation bean implementing the business logic of the methods defined in the service endpoint interface. The implementation may be either a Java class in the Web container or a stateless session bean in the EJB container.
JAX-RPC requires the service definition interfaces must follow RMI conventions, no remote references allowed, and all objects are passed by copy.
Container-specific service interfaces, created by the J2EE container, provide static stub and dynamic proxies for all ports. A client of a J2EE platform Web service can be a Web service peer, a J2EE component, or a stand-alone application. It is not required that the client be a Web service or application implemented in Java.
Use a stateless Session Bean to expose Web services if you: 
  • Need to expose previously existing stateless Session Beans as Web services
  • Need declarative transaction management
  • Need the thread management provided by EJB Container
  • Need role based security
    Use Java classes to expose your Web services if you: 
    • Need to expose previously existing Java classes as Web services
    • Want a light-weight system, and don't care much about transactional capabilities that an EJB container provides

    Sunday, February 12, 2012

    How to unlock Sample HR database in oracle


    For working with tutorial of oracle Introduaction to oracle/sql you need to work on the tables which is locked in oracle. for Unlocking these tables you have to follow these steps
    1. Login in sqlplus or sqlplus or isqlplus as a user “system” with respective password.
    2. Execute the following command
    ALTER USER HR IDENTIFIED BY password ACCOUNT UNLOCK;
    here password is your passord which you want to use for your account remember this password for further use.
    3. Login in with user HR with password specified above
    Now you can use all tables specified in tutorial.

    Monday, February 6, 2012

    Difference between String StringBuffer and StringBuilder

    String is immutable whereas StringBuffer and StringBuilder can change their values.
    The only difference between StringBuffer and StringBuilder is that StringBuilder is unsynchronized whereas StringBuffer is synchronized. So when the application needs to be run only in a single thread then it is better to use StringBuilder. StringBuilder is more efficient than StringBuffer.
    Criteria to choose among String, StringBuffer and StringBuilder
    1. If your text is not going to change use a string Class because a String object is immutable.
    2. If your text can change and will only be accessed from a single thread, use a StringBuilder because StringBuilder is unsynchronized.
    3. If your text can changes, and will be accessed from multiple threads, use a StringBuffer because StringBuffer is synchronous.
    http://www.java-tips.org/java-se-tips/java.lang/difference-between-string-stringbuffer-and-stringbu.html