[Show all top banners]

yellow
Replies to this thread:

More by yellow
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 Java: Need Help/Suggestion from fellow developers
[VIEWED 5798 TIMES]
SAVE! for ease of future access.
Posted on 11-24-11 2:05 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

I do have a fair understanding of core Java and there are plenty resources on it. I am looking to enhance some Java EE concepts and looking for suggestions regarding resources. Sajha has plenty of developers with lots of experience, so I was looking for some help regarding how to best approach learning these stuff. I have gone thrug some books and online reading materials. What I'm really looking for is some video tutorials, I've found them to be really helpful and easy to follow.

So, I'm hoping you guys can share some of your knowledge or 2cents.
Main area of focus being Java, EE, struts 1.x, 2.x, JPA and other relevant technlogies.

Thans and happy thanks giving.

 
Posted on 11-25-11 10:47 AM     [Snapshot: 103]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

JavaSE  (Java Standard Edition)

        -> I think you already this edition of Java is for Desktop applications.
       Whatever, if haven't done so, please go through some of the tutorials here: http://docs.oracle.com/javase/tutorial/
      Go through topics under Trails Covering the Basics and also some of the topics (e.g. JDBC, JNDI, Generics, JAXP, JavaBeans, some Reflection)  under Specialized Trails and Lessons. But you don't have bother going through the topics that I didn't mention unless you need to because of your job requirement. Otherwise, it will be a perfect waste of time because since you are a developer I assume you are already aware that JEE is really really vast.
       One important thing to note is JEE itself is buit on top of JavaSE so it's better to learn some techniques to do stuffs in a better way. And if you want to learn those techniques then the book "Effective Java" by Joshua Bloch is the book almost everybody recommends.

JEE (Java Enterprise Edition)

      -> First of all, enterprise applications are a lot more complicated then regular desktop applications. May be that's why they follow layered architecture. As far as I remember, different layers in a layered architecture are - Data layer, Business layer, Presentaton layer.

       Data layer: As the name implies, you are going to put all of your code that is responsible for retriveing and persisting the data from the database in this layer. So, that your Business layer don't get polluted with data access codes.

      Business layer: This is the layer where you put your business (application) code. It's good to make sure, we don't put the view (presentation) related code here.

      Presentation layer: This is where you manipulate the data, you recieved for either data layer or business layer, to turn it into something more suitable and meaningful to be presented to the end user.

      Layered Architecture: This is a kind architectures that an application might follow (whether it's an enterprise application, or just a web application, or even a desktop application). I just want you to know that you can not use Java at all and develop an enterprise application which is layered. So, don't be confused that Layered Architecture is something that lies within JEE, but try to understand that it's a totally different concept and your job is to figure out how it is implemented by JEE.

      Servlet API -> EJB -> JPA (This is how the layered architecture is implemented in JEE)

      Servlet API: This API is used to write codes that handle the request from the end user. A HTTP request is decoded in this layer, service (business) layer is called to invoke the corresponding business code which inturn might invoke the data access code. This request processing cycle is ended by the response being sent back to the end user.
      Here we are using the Servlet API. There is something called Servlet Specification, against which we write our code and which is also followed by the Servlet (web) container. So, we have to make sure that we follow that specification properly for us to expect our sevlet to run properly in a web container.
      This is where the web application frameworks like Struts, JSF, etc comes into play. As you can see, these frameworks are there to help you build your presentation (view) layer, just like Swing in JavaSE, they also follow the MVC Design Pattern just like Swing does.
      e.g. JSF (Java Server Faces) is the standard (or official) framework, which has the Faces-Servlet as the Controller (C in MVC), managed-beans as Models (M in MVC), and facelets (xhtml) or JSPs as Views (V in MVC). Any application that uses JSF, process a request phase by phase. The phases are - Restore View, Apply Request Values, Process Validations, Update Model Values, Invoke Application, and Render Response. This might not be very useful to you, but if you look at the names of those phases then you can see how they are distinct from one another and resposible for tackeling a whole different set of concern. JSF also comes with a huge set of reusable codes. JSF is also called a component-based or event-based web framework.
     As you can see that these frameworks are nothing but a huge library of codes that helps to write a web application in a very managed and meaningful way.

       A Java web application (also called web-module) is packaged into a file with the extension war. WAR (Web Archive) is a package that contains some folders with some specific names layed out in some specific way, some specific files which helps the server (or container) in which it will be deployed. It also contains your application specific stuffs like pages and file (JSP, html, xhtml, css, Javascript), classes (these might be some manged-beans, servlets, filters) basically these are considered as (web) components in general, and some libraries that your application needs.

      So, we can develop a web application for the view (presentation) layer of our enterprise application. Or, it can be an application on it's own independant of any enterprise application in which case we can implement the layered architecture with the web application. Which is done specially for separation of concerns.

      EJB (Enterprise Java Bean):     
         Within JavaEE there is another specification called EJB. Whatever this specification says is followed by the EJB containers, and as a developer we code out EJBs using the relative API, against the same specification to make when we deploy are ejb-module into a ejb-container, it works the way it's supposed to.
         Here, the container is responsible for low-levle functionalities like multithreading, transactions (while accessing data or while dealing with messaging (JMS)), management of our enterprise beans' lifecycle.
         A lot times, if you try to read about EJB you get confused because some times you might be reading about EJB 2.x and sometimes you might reading about EJB 3.x. And the fact is that EJB has changed drastically between those versions. So, from next time instead of getting confused make sure you know what version of the EJB that post applies to.
        E.g. I might say there are two types of EJBs (Session and Message-Driven) and some else might say actually there are three (Session, Message-Driven, and Entity). While that's true for EJB 2.x, that's not true for EJB 3.x. It has already been realized that entity is something that represents a table in the database, so obviously it something that belongs in JPA not in EJB. So, it's a part of JPA API. And even though we can use the JPA within a desktop application without a need for a ejb-container, I think it's still considered a sub-specification under EJB.
       JPA (Java Persistence API):
       It's build on top of JDBC, it's not hard to tell that. But, main purpose is to persistence framework that lets developers deal with RDBMS related code just like they do with regular Java code. This is the idea borrowed from the framework like Hibernate.
       But, since JPA is the standard, it's good to learn JPA then other frameworks like hibernate directly. If you code using JPA you can use other frameworks like hibernate, eclipse-link, toplink, etc as runtime provider.
       If you want to learn about JPA, then would recommend you to start with JDBC and move towards JPA, but do all that in a desktop application. Because, desktop applications are easier and you can lear more JPA.

      Here (http://docs.oracle.com/javaee/6/tutorial/doc/) where you will find some tutorial on every thing you will find in JEE. It's offical JEE tutorial. This is where you should go whenever you have some confusion and you need to know the fact. It's for JEE version 6, but if you google you will also find one for version 1.4. But, version 6 is pretty old so I thinks it's good to follow that.

JavaEE 6 also provides a feature called CDI (Context and Dependancy Injection). This is new in version version 6, and wasn't there in the prior versions (better known as J2EE). This feature helps us decouple our components (or beans) by specifying the dependency to the container which will make sure that dependancy is injected into our component before it brings it into life and starts managing it's lifecycle. Spring is the framework that is really famous when comes to DI. Actually, standard JEE itself borrowed that idea from Spring.

I hope this helps a little.

     
Last edited: 25-Nov-11 11:06 AM
Last edited: 25-Nov-11 11:07 AM

 
Posted on 11-25-11 11:01 PM     [Snapshot: 182]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Thank you -eetow  your post was quite insightful and appreciate taking the time to type all that out.

I do have a little bit of .Net experience and everything seemed integrated with MS products but Java seems to overwhelm me with so many technologies...haha

Let me ask another follow up question, I am right now learning a little bit of struts 1.x and already 2.x seems a little different in its implementation. How does it par with other frameworks like Hibernate and Spring. Also, is it easier learning those once I learn struts or am in compraring apples to oranges ? Every job description has Hibernate, Spring etc.


Last edited: 25-Nov-11 11:06 PM

 
Posted on 11-26-11 10:28 AM     [Snapshot: 233]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

No problem, I typed whatever I had in my head then. That's just scratching the surface. I know It will take years to learn the whole JEE stack.

If you have been doing web programming for while and are well introduced to stuffs like HTTP, Request, Response, Session, and, Core Java than it should not that hard for you learn Struts. It's just a framework that helps you build web application. I haven't used Struts at all. But, Struts 1.x is Struts itself whereas Struts 2.x is not. There used to be another web framework called WebWorks which is actually Struts 2.x. So, may be that's why Struts 2.x is nothing like Struts.

First of all, when you are comparing Struts with Hibernate and Spring, then you are actually comparing Apples with Oranges.
If you revist the layered architecture, we see there can be different layers like Presentation, Service (Business), and Data (Persistence) layer. And, let's see where we will be using those framesworks to develop different layers of your application -

    Presentation Layer (Struts)
    Service (Business) Layer (Spring)
    Data (Presistence) Layer (Hibernate)

This applies to layered "enterprise" application, where your web application (developed using Struts) will only be the presentation layer. And, if you have noticed then we have instead of using EJB from JEE stack, we have decided to use Spring framework (which is not a standard Java framework) to develop our business layer. Same for the data layer, instead of using JPA (standard Java persistence framework) we chose Hibernate to develop our data layer.

In this case, you don't need a full blown application server with both web and ejb containers. A simple Java web application server will do. You need web container to deploy you war, web application that you built using Struts, and Spring comes with it's own container that provides facitlies to Java beans just as an ejb container would do for enterprise Java beans.

But don't be fooled with however I have presented the frameworks above, because e.g. if you take Spring then Spring is a really huge framework and it's really full blown meaning that you use Spring only and develop all the layers of your application. And if it's just a simple web application then you can only Struts will suffice. And it's not like you will not have access you data no more if you don't use Hibernate (or JPA).

My writing skill is not so good, I hope you get what I am trying to say.





 
Posted on 11-26-11 4:16 PM     [Snapshot: 282]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Comparing those frameworks with .net ;

Struts is basically the implemenation of MVC architecture. It 's use is similar to the MVC webproject in .net .

As fu*ketoow said, Spring is little more complicated than Struts because it has different modules you can use separately. You can use component of spring to replace struts and hibernate both. But mostly, it is used in business layer 

Hibernate is used for application persistence. The .net version of hibernate is NHibernate. Entity framework in .net is later developed by microsoft to replace opensource framework NHibernate.  So i believe you know why hibernate is used .

If you integrate all these three frameworks in one project , the project contents would be like as [Disallowed String for - Bad word 'fuk']etoow said .

Struts - presentation/view with controller 
Spring -business layer
Hibernate -Persistence 



 
Posted on 11-26-11 8:11 PM     [Snapshot: 310]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Thanks guys for drawing the bigger picture. I was just having problems tying those technologies together. Although, they say no question is a stupid question, at this point, with limited knowledge, anything I ask will sound stupid haha.

Now I just gotta find motivation to go through those learning resources.

Thanks,
-Yellow

 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 200 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
ChatSansar.com Naya Nepal Chat
Toilet paper or water?
TPS EAD auto extended to June 2025 or just TPS?
Biden out, Trump next president, so what’s gonna happen to TPS, termination?
and it begins - on Day 1 Trump will begin operations to deport millions of undocumented immigrants
Tourist Visa - Seeking Suggestions and Guidance
From Trump “I will revoke TPS, and deport them back to their country.”
I hope all the fake Nepali refugee get deported
Anybody gotten the TPS EAD extension alert notice (i797) thing? online or via post?
advanced parole
TPS Renewal Reregistration
Sajha Poll: Who is your favorite Nepali actress?
Biden said he will issue new Employment visa for someone with college degree and job offers
Why Americans reverse park?
Nepali Passport Renew
Driver license help ASAP sathiharu
They are openly permitting undocumented immigrants to participate in federal elections in Arizona now.
ढ्याउ गर्दा दसैँको खसी गनाउच
To Sajha admin
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters