Skip to main content

Posts

Showing posts with the label J2EE

EJB 2.0 Drawbacks

Complex Products Unmaintainable System Non-portable, frame-work committed business components Unpredictable System Why EJB 2.0 is complex / complicated? Session bean - to write say hello method in EJB 2.x, you need to write home interface component interface bean in EJB 3.x, you need to write interface (with annotation) bean (with annotation) EJB 2.x; lookup is the only way to get server object/resource EJB 3; DI (dependency injection) & lookup are the available way there are more points. But basically, with EJB 3 responsibility of container is heavy & responsibility of developer is light weight; so that development is less & maintenance is easy.

Seam, EJB and Hibernate useful tips

  Here are some tips I have gathered during our Seam project. @Create - Signals that this method should be called upon instantiation of the JavaBean. @Stateless - Makes an EJB3 object @Stateful - (SESSION) Caches in memory between server requests @In - These variables will automatically be set by Seam through injection of the variables labeled by the annotation. i.e String zipCode; (Behind the curtain: zipCode = request.getParameter("zipCode"); ) @Out - Same as above. This variable is also automatically set by Seam. Behind the curtain this variable is set in the HttpSession object. ( request.setAttribute("bestRestaurant", restaurant); ) What you also must remember is that if you want to use the outjected object, you only call it with its name. Not component name first. i.e. If you stateful session bean is named @Name("someName") and you have a @Out String test, then when you use it in the view, you must write #{test} and not #{someName.test} You can als...

Hibernate Introduction

Hibernate is a Object relational mapping framework. What it will help us is in saving the objects into the relational world. Employee.java public class Employee { private String Name; private int Emp_Id; private String Designation; private String Reportee; private int Access_Carad_No;          public String getName() {         return Name;     }     public void setName(String name) {         Name = name;     }     public int getEmp_Id() {         return Emp_Id;     }     public void setEmp_Id(int emp_Id) {         Emp_Id = emp_Id;     }     public String getDesignation() {         return Designation;     }     public void setDesignation(String designation) {         Designation = designation;     }     public String getReportee() {         return Reportee;     }     public void setReportee(String reportee) {         Reportee = reportee;     }     public int getAccess_Carad_No() {         return Access_Carad_No;     }     public void setAccess_Carad_No(int access_Carad_No) {         Acc...

Overview of EJB and Lifecycle

The container is responsible for loading, activating, and in general maintaining the "life-cycle" of objects it provides. EJB have a fairly complex life-cycle. There are several kinds of EJB: Session Beans: These may be either stateful or stateless, and are primarily used to encapsulate business logic, carry out tasks on behalf of a client, and act as controllers or managers for other beans.   Entity Beans: Entity beans represent persistent objects or business concepts that exist outside a specific application's lifetime. They are typically stored in a relational database. Entity beans can be developed using bean-managed persistence, which is implemented by the developer, or container-managed persistence, implemented by the container.   Message-Driven Beans : Message-driven beans listen asynchronously for Java Message Service (JMS) messages from any client or component and are used for loosely coupled, typically batch processing.

Hibernate Notes

  The Hibernate project has the structure as shown in the figure as above. We need one hibernate.cfg.xml file for hibernate configuration which handles connection pulling and other stuff like driver name, username of the database, password of the database, and the following properties.. Hibernate.cfg.xml <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory>   <property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver</property>   <property name="hibernate.connection.url"> jdbc:mysql://localhost/hibernatetutorial </property>   <property name="hibernate.connection.username"> root </property>   <property name="hibernate.connection.password"></pr...

MVC Design Patterns

Context MVC is an architectural pattern that is used when developing interactive application such as a shopping cart on the Internet. Problem User interfaces change often, especially on the internet where look-and-feel is a competitive issue. Also, the same information is presented in different ways. The core business logic and data is stable . Solution Use the concept of dividing the concerns to divide the application into three areas Model :- Encapsulates the core data and the functionality View :- Encapsulates the presentation of the data there can be many views of the common data Controller:- accepts input from the user and makes request from the model for the data to produce a new view The model represents the structure of the data and the operations that can be performed on that data. The view represents the data that is in a presentable format. The controller translates the user action like mouse events, submit, keystrokes, words spoken with user input to call the call t...

Enterprise JavaBeans Technology

A building block to execute the business logic. Types Entity beans Enterprise beans Message driven Beans Enterprise beans use the databases if required The most important benefit of the enmity bean is that it doesn't need any code for JDBC connection API EJB container itself handles the same. If we have a need to use session bean to use the database we need to implement the JDBC connection code.

Development Roles

The entire Web Development Process has following steps to be followed. Purchase and installation of J2EE products and tools. J2EE components can be developed by application component providers. Assembled by application assemblers. Deployed by application deployers.   J2EE Product Provider Product providers are typically operating system, database system, application server, or web server vendors who implement the J2EE platform according to the Java 2 Platform, Enterprise Edition specification.   Tool Provider The tool provider is the company or person who creates development, assembly, and packaging tools used by component providers, assemblers, and deployers.   Application Component Provider The application component provider is the company or person who creates web components, enterprise beans, applets, or application clients for use in J2EE applications.   Enterprise Bean Developer An enterprise bean developer performs the following tasks to deliv...

Packaging Applications

The enterprise application is delivered to the client as a .ear file having a no of .jar files, settings, other libraries , deployment descriptors and other web resources. A deployment descriptor is an XML document with an .xml extension that describes the deployment settings of an application, a module, or a component. At runtime the J2EE container reads the deployment descriptors and acts upon the application, module or component accordingly. Two types of Deployment descriptor J2EE Deployment Descriptors:-Defined by the J2EE Specification. It can be used to configure settings for any J2EE compliant implementation. Runtime Deployment Descriptors: - It is used to configure J2EE implementation specific parameters.

Web Service Support

Web services are web-based enterprise applications that use open, XML-based standards and transport protocols to exchange data with calling clients. The J2EEplatform provides the XML APIs and tools you need to quickly design, develop, test, and deploy web services and clients that fully interoperate with other web services and clients running on Java-based or non-Java-based platforms. The translation of data to a standardized XML-based data stream is what makes web services and clients written with the J2EE XML APIs fully interoperable. It is not like one should pass data in the xml format but it can be any type of data like plain text, audio, video, maps, programme files.   XML XML is a cross-platform, extensible, text-based standard for representing data. It helps in reusability of the data being processed for Example One company might put XML pricing information through a program to translate the XML to HTML so that it can post the price lists to its intranet. A...

LEARNINGS OF J2EE(04/10/2011)

J2EE Containers Helps in separating the business logic and other mechanisms like Resource pooling , multi-threading and state management . Before Deployment Any Component is to be assembled to the J2EE container. Each assembly owns the settings for the container services like Security, Transaction management, JNDI, Remote Connectivity, etc. JNDI lookup services provide a unified interface to multiple naming and directory services in the enterprise so that application components can access naming and directory services. The J2EE remote connectivity model manages low-level communications between clients and enterprise beans. After an enterprise bean is created, a client invokes methods on it as if it were in the same virtual machine. Having configurable environment it can behave differently on different environment. Also provides some non-configurable services like data persistence, dB resource pooling, servlet lifecycle, Enterprise bean.   J2EE CONTAINER TYPES ...

Abstract Factory DesignPattern-1

Abstract Factory Design Pattern In software development, a  factory  is the location in the code at which objects are constructed.  The intent in employing the pattern is to insulate the creation of objects from their usage. This allows for new derived types to be introduced with no change to the code that uses the base class. The essence of the Abstract Factory method Pattern is to "Provide an interface for creating families of related or dependent objects without specifying their concrete classes". For Example: Address Factory has no of factories like: US Address Factory which implements the Address Interface. French Address Factory which implements the Address interface. Can have many more country specific factories…. When we create the French Address using the method implemented in the French Address Factory class it returns the Object reference to the Abstract class of Address. The Abstract Address class holds the ...