Posted in ASP .Net, C#, Core Java, Design Pattern, Framework, Inversion of Control, Java EE, Library

Library vs Framework

The key difference between Library and Framework is in IoC (Inversion of Control)

  • by using a feature from a Library you are in control.
  • The Framework include some abstract design with built-in behaviors. Control is inverted and the framework calls you; framework code will call the code at those various points that behavior has inserted. The Hollywood principle: Don’t call Us, we’ll call You.

Library

Framework

A certain set of reusable functions of an application (mostly organized into classes) As a skeleton of an application
A collection of class definitions A collection of patterns
You call the library APIs in your code A framework calls your code
The control is always with you The control in with the framework if you’re using it
Libraries meant to do some specific tasks only Framework is a predefined design
You need to scaffold your project manually Super easy to scaffold
   

 

 

 

Posted in Groovy, Java EE, JSON

Groovy String comparison in WorkFusion

For instance I have this variable of json expression:

<var-def name=”successFlag”>
<json expression   =”$….Response…..SuccessFlag”>
<var name=”HTTP_RESPONSE” />
</json>
</var-def>

to compare it with for an if else condition case, I need to create a boolean variable then put it in the condition; this was really tricky to use, I tried equals, == and some converting ones but this one works like a piece of cake:

then:

<case>
<if condition=”${eduSuccess.equals(‘true’)}”>
.

.

.

</if>

<else>

</else>

</case>

Posted in Core Java, Groovy, Java EE

Groovy vs Java

  Java Groovy
Access modifier (by default) package public
getters and setters Need to provide for fields Are automatically generated for class members
Utility methods System.out.println println
Support substitution   Can print dynamic content without string concatation

Println(“Hello $name !”)

 

Specifying type definition   Instead use keyword def

Mandatory for methods, optional for method arguments

Using semicolons Every statements end with semicolon optional
main method To make a class executable Don’t need
Initializing String arrays, static arrays Curly braces { “abc”, “dfg”} Square brackets [“abc”, “dfg”]
autoboxing/unboxing/conversion of primitives yes No, everything is Object and uses only Objects
Inner static classes yes no
Anonymous classes yes no
     
Posted in Java EE, JDBC

Statement vs. PreparedStatement in JDBC

Statement

PreparedStatement

for executing static SQL statements execute dynamic queries with parameter inputs
use String Concatenation to create the query and it can’t accept input parameters Use setter methods to set the input parameters for the query
Suitable for DDL  Suitable for DML
Slower Faster
  Prevent SQL Injection attacks
   
Posted in AOP, Java EE, Spring

AOP Concepts

 

Joinpoint A specific point in the code, every method in every class is a Joinpoint.
Pointcut A collection of one or more Joinpoints, for example all the methods of a class.
Advice The implementation of crosscutting concern, it means what do I want to do with crosscutting concern (Before, Around, After).
Aspect What crosscutting concern do I execute (=Advice) at which location (=Pointcut); in other words what do I want to do, where do I want to do it in the code. –> advice + pointcut
Weave The advice code together + Target code at corresponding Pointcuts such that we get the correct execution; it means different methods together with right sequence.

And this would be an example how we can write a Pointcut:

poincut

Posted in App-server, Java EE, Tomcat, Uncategorized, Web-Server

Application Server vs. Web Server

This chart* perfectly captures different features of App Servers versus Web Servers:

Application Server Web Server
What is it? A server that exposes business logic to client applications through various protocols including HTTP. A server that handles HTTP protocol.
Job Application server is used to serve web based applications and enterprise based applications(i.e servlets, jsps and ejbs…). Application servers may contain a web server internally. Web server is used to serve web based applications.(i.e servlets and jsps)
Functions To deliver various applications to another device, it allows everyone in the network to run software off of the same machine. Keeping HTML, PHP, ASP, etc files available for the web browsers to view when a user accesses the site on the web, handles HTTP requests from clients.
Supports distributed transaction and EJB’s Servlets and JSP
Resource utilization High Low

Question: Apache Tomcat is a Web Server or an Application Server?

Answer: Tomcat is a web server (can handle HTTP requests/responses) and web container (implements Java Servlet API, also called servletcontainer) in one. Some may call it an application server, but it is definitely not an fullfledged Java EE application server (it does not implement the whole Java EE API).**

————————————————————————–

* source: http://www.diffen.com/difference/Application_Server_vs_Web_Server

**http://stackoverflow.com/questions/2469949/tomcat-is-web-server-or-application-server