Interview Questions - J2EE

Interview Questions - J2EE

Struts2
Struts2 mainly originates form pervious Webwork2 project.

The main concepts in Struts2 are ActionContext, Interceptors, Action, Result, ValueStack and OGNL.

First every request must be handled by interceptor stack, these interceptors are provided and configured by Struts2, the main pre-configured interceptors includes, params interceptor, validation, fileupolad etc.

Interceptor is a key part of the Struts 2 framework; these interceptors are invoked both before and after the action.
Interceptor allows common, cross-cutting tasks to be defined in clean, reusable components that can keep separate from the action code.

Then Struts2 will call Action the request corresponds, developers can implement whatever logic, usually Action will call business service method to do real work.

At last Action would return a control string that tells Struts2 which results would render the view that’ll be returned in the request response.
Then Struts2 would return the response to client.

In the process, Struts 2 uses the ValueStack as a storage area for application data that will be needed during the processing of a request.
And OGNL is used to reference and manipulate properties on the ValueStack.

Struts2 VS Struts1

1.Action is POJO, Action does not need include any Struts2 specific API, even implanting the interface is optional, thus Action is easy to test, we don't need to mock HTTP objects.

2.There is no ActionForms any more.

3.Enhanced Results, except JSP, Struts2 also supports other view technologies such

as Free-marker, Velocity, PDF etc.

4.Struts2 provides easy Spring integration,

5.Struts2 also provides Intelligent Defaults, we can use annotations and conventions to drastically reduce XML-based configuration.

6.Struts2 provides easy plugging mechanisms, we can easily extend Struts2 functionality, and there are already many Struts2 plugin, such as restful, Json etc.

Maven:
Compared with Ant, Maven is very easy to use, Using ant, we have to write its build file build.xml, from scratch, all by ourselves, it is very painful, and boring,

1.First, Maven provides Archetypes, we can use just one command to generate java project, and its pom.xml file in seconds, and the pom.xml file is much simpler than ANt's build.xml.

2.Second, Maven follows best practices, it defines Standard Project Layout, and developers can quickly understand the project's layout.

3.Third, Use Maven to manage project's dependencies, in the past, if one project need third-party libraries, developers directly put jars to the project lib directory, Using maven, we just need to decalre the dependency in pom.xml, maven will download the jars, and put it into local repository, this can save disk space, and if we need to update the jar to new version, we just need to modify the pom.xml.

4.Fourthly, maven introduces the concept, standard life cycles. user just need to learn a small set of commands to invoke defined goals to build any Maven project,Maven provides many built-in life-cycles: such as validatecompiletestpackageinstalldeploy.
Maven is a plugin execution framework, it is easy to write maven plugin to extend maven's functionality, there are already hundreds of maven plugin, such as mvn eclipse:eclipse.

Also we can run mvn ant:ant to generate ant build files from pom.xml directly, also maven can invoke ant target.

EJB3:
EJB 3 learns and benefits a lot from several technologies such as POJO, IOC, AOP, Spring and Hibernate.
EJB3's chief advantages include:

1.EJB3 supports AOP, that is aspect oriented programming, First we can use Interceptors to encapsulate common cross-cutting concerns in one place. Secondly, developers can use annotation to declare transaction and security.

2.EJB3 supports Dependency Injection, we can use annotation @EJB, @Resource to inject and refer another EJB, or external resource directly.

3.EJB2 demand that SessionBean and EntityBean implement many unnecessary callback methods, such as ejbActivate,ejbPassivate,ejbCreate etc, normally these methods are empty, in EJB3, developers don't need to write these methods at all, and if they really want to provide this function, they can annotate any method with annotation @PreDestroy,@PrePassivate etc.

4.Home interface is removed from EJB3; instead EJB3 enables simple lookup process.

5.EJB3 entity bean is totally redesigned, JB3.0 entity bean doesn't have home, local or remote interfaces, it is just a POJO with newly introduced annotation such as @Entity, @Id and uses entity manager to make java Objects persisted and detached, and also there is no Data Transfer Object any more in EJB3, and Persistence has its own specification: Java Persistence. Other OR mapping project such as Hibernate, Toplink supports JPA.

6.Annotations are used in EJB3, EJB3 use it as a "replacement" for XML Deployment Descriptors, Using Annotation can simplify configuration drastically. Also developers can choose to use all annotations, all XML or a mix of annotations and a XML, and EJB deployment descriptors are not required in ejb3.0.

Spring
Spring is a full Stack Web Framework, its main purpose is to make J2EE easier to use, and it provides many features.

Two key components of Spring are IOC or DI that is inverse of control, or dependency injection.
Spring supports AOP, that is aspect oriented programming.
Spring supports declarative transaction management through the Spring AOP framework.
Spring abstracts and integates with a number of related frameworks, Spring makes it easy to work with JDBC, JPA, Hibernate, or struts, and EJB, JMS, Email, Scheduling, Quartz, Test support and many others.
Aslo Spring has its own web framewrok, SpringMVC, and Security framework, Spring Security.
In one word, Spring is a very important framework for j2ee enterprise application.
AOP
AOP means Aspect-oriented programming.
It is used to complement traditional OOP; OOP is good for implementing the core business logic, but not the crosscutting concerns.
Crosscutting concern is a functionality that spans multiple modules of an application.
In applications, there are core business concerns and crosscutting concerns.
Crosscutting concerns are very common in enterprise applications such as logging, validation, authentication, and transaction.
Traditional object-oriented approach would cause two problems.

1.First is code tangling. Methods would include core logic and other crosscutting concerns; this will lead to poor code maintainability and reusability.

2.Another problem is code scattering, we have to repeat same statements and logics multiple times in multiple modules to fulfill a single requirement, if later we need to change the logic; we have to change in all places.

AOP provides another way to implement crosscutting concerns.
Instead of the classes and interfaces of OOP, the main programming elements of AOP are aspects.
We implement the crosscutting concerns as aspects, and then through XML or Annotation, we weave aspects into various objects, in this way, we place the crosscutting concern in only one place.
Spring has its AOP implementation, and AspectJ is the most complete and popular AOP framework in the Java community.
Hibernate
Hibernate is an object/relational mapping project of Jboss, Hibernate maps Database Table to Java Class, Table's column to Class Field.
Hibernate lets us develop persistent classes following OO idiom - including association, inheritance, polymorphism, composition, and collections.
Hibernate allows us to use its portable HQL to express queries  in object-oriented terms—using classes and properties of classes, Using HQL, we don't need write different SQL for different Databse any more. we also it supports native SQL.
Hibernate supports Annotation and XML configuration.
Also Hibernate supports JPA specification and allows us to write queries with the standardized JPA Query Language.

Dojo

Dojo is mainly divided into three projects: Dojo, Dijit, and Dojox.

Dojo module provides many wonderful basic and core functions, such as Language and Browser Utilities, DOM Utilities, String Utilities, and asynchronous requests (dojo.xhrGet,dojo.xhrPost), JSON support, Drag-and-Drop(dojo.dnd), Animation and Special Effects,.

And Dojo normalizes browser, allowing the same source code to work in several browsers. Dojo also fixes several gross browser errors such as memory leaks in IE's event system.

Dijit is Dojo widget framework, it packs a fantastic library of widgets, such as Form Widgets, Layout Widgets, such as tab/split containers, Tree, Calendar, TimePicker, Dialog, Slider, Progress Bar, AutoComplete etc...

We can create Dijit widgets declaratively or programmatically.

Declarative widgets use nonstandard HTML attributes such as dojoType=.

We can also create same widgets through JavaScript, These are called programmatic widgets.

DojoX is a collection of subprojects for Dojo Extensions and Experimental, such as

Grid, Charting, highlight, FishEye, ColorPicker etc.

 

Dojo also provides several tools like ShrinkSafe, Checkstyle.

Dojo's loader, packaging and build system is very powerful.

It modularizes Dojo - a large project into any number of independent source files yet packages it into only a few highly compressed files.

dojo.require maps a module name to a URL, downloads, and then evals that resource.

 

Main API:

dojo.require

Asynchronous Request

dojo.xhrGet

dojo.xhrPost

dojo.connect(myButton, "click", myFunction)


Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language. 

Selenium IDE is a Firefox extension, and allows recording, editing, and debugging tests.

Selenium Remote Control (RC) makes it possible to write automated tests for a web application in any programming language, including Java, .NET, Python, Ruby,  Perl, and PHP, and allows for better integration of Selenium in existing unit test frameworks.

Post a Comment

Labels

Java (159) Lucene-Solr (112) Interview (61) All (58) J2SE (53) Algorithm (45) Soft Skills (38) Eclipse (33) Code Example (31) Linux (25) JavaScript (23) Spring (22) Windows (22) Web Development (20) Tools (19) Nutch2 (18) Bugs (17) Debug (16) Defects (14) Text Mining (14) J2EE (13) Network (13) Troubleshooting (13) PowerShell (11) Chrome (9) Design (9) How to (9) Learning code (9) Performance (9) Problem Solving (9) UIMA (9) html (9) Http Client (8) Maven (8) Security (8) bat (8) blogger (8) Big Data (7) Continuous Integration (7) Google (7) Guava (7) JSON (7) Shell (7) ANT (6) Coding Skills (6) Database (6) Lesson Learned (6) Programmer Skills (6) Scala (6) Tips (6) css (6) Algorithm Series (5) Cache (5) Dynamic Languages (5) IDE (5) System Design (5) adsense (5) xml (5) AIX (4) Code Quality (4) GAE (4) Git (4) Good Programming Practices (4) Jackson (4) Memory Usage (4) Miscs (4) OpenNLP (4) Project Managment (4) Spark (4) Testing (4) ads (4) regular-expression (4) Android (3) Apache Spark (3) Become a Better You (3) Concurrency (3) Eclipse RCP (3) English (3) Happy Hacking (3) IBM (3) J2SE Knowledge Series (3) JAX-RS (3) Jetty (3) Restful Web Service (3) Script (3) regex (3) seo (3) .Net (2) Android Studio (2) Apache (2) Apache Procrun (2) Architecture (2) Batch (2) Bit Operation (2) Build (2) Building Scalable Web Sites (2) C# (2) C/C++ (2) CSV (2) Career (2) Cassandra (2) Distributed (2) Fiddler (2) Firefox (2) Google Drive (2) Gson (2) How to Interview (2) Html Parser (2) Http (2) Image Tools (2) JQuery (2) Jersey (2) LDAP (2) Life (2) Logging (2) Python (2) Software Issues (2) Storage (2) Text Search (2) xml parser (2) AOP (1) Application Design (1) AspectJ (1) Chrome DevTools (1) Cloud (1) Codility (1) Data Mining (1) Data Structure (1) ExceptionUtils (1) Exif (1) Feature Request (1) FindBugs (1) Greasemonkey (1) HTML5 (1) Httpd (1) I18N (1) IBM Java Thread Dump Analyzer (1) JDK Source Code (1) JDK8 (1) JMX (1) Lazy Developer (1) Mac (1) Machine Learning (1) Mobile (1) My Plan for 2010 (1) Netbeans (1) Notes (1) Operating System (1) Perl (1) Problems (1) Product Architecture (1) Programming Life (1) Quality (1) Redhat (1) Redis (1) Review (1) RxJava (1) Solutions logs (1) Team Management (1) Thread Dump Analyzer (1) Visualization (1) boilerpipe (1) htm (1) ongoing (1) procrun (1) rss (1)

Popular Posts