The traditional approach to J2EE architecture has often produced disappointing results: applications that are more complex than their business requirements warrant, show disappointing performance, are hard to test, and cost too much to develop and maintain traditional J2EE architecture often gives us. Results of disappointment: It is too complicated, even more than business needs itself, performance problem, difficult to test, development and maintenance cost. It does not need to be so hard. There is a better way for most applications. In this book, we'll describe a simpler, yet powerful architectural approach, building on experience with J2EE and newer technologies such as Inversion of Control and AOP . Replacing EJB with lighter-weight, more flexible, infrastructure typically produces significant benefits. We and many others have used this approach in many production applications, with better results than are usually produced from traditional architectures. in fact, to solve these problems is not very The difficulty is mainly to find a better way. This book, we will show a simple and robust architecture - it takes advantage of the lessons of J2EE over the years and some emerging technologies, such as: IOC (Inversion of Control) and AOP (Aspect O). Light, flexible, unique architectural models instead of the benefits of EJB. We have applied this method in multiple product applications and have achieved better results than traditional architectural modes. Let's begin with a quick tour of the topics we'll Examine in more detail in latrapters. Now let's start our truthful experience.
EJB Under EJB Like most in the Spotlight spotlight of my colleagues, I was excited by the promise of EJB when it first appeared. I believed it was the way forward for enterprise middleware. However, I've since revised my opinions, in the Light of my experiences and those of many colleagues. Like my colleagues, when EJB just appeared, EJB's propaganda made me excited. I believe this will be the bright avenue of enterprise middleware. However, in the near future, I changed our point and my colleagues. Much Has Changed Since The EJB Specification WAS CONCEIVED: Since the EJB specification, many things have changed:
Parts of the specification's design now seem dated. For example, dynamic proxies, introduced in J2SE 1.3, call into question the container code generation envisaged in the EJB specification and the multiple source files needed to implement every EJB. Part of the standard design obsolete, such as Say, the dynamic agent in J2SE1.3 is called XXXX in the EJB specification, and many program files need to implement each EJB. The Traditional Link Between EJB AND RMI Remoting is Looking Dated, Because of the Emergence of Web Services and T Recognition That EJBS Sometimes Need Only Local Interfaces. EJB IS A Heavyweight Model for Objects That Don't Need TO OFFER Remote Access. The remote connection has expired in the EJB and RMI chapters, because with the rapid development of the web service, and EJB sometimes Only the call of the local interface is required. EJB is a heavyweight object model that does not require remote calls. This is a special case of the fact that basing typical applications around distributed business objects-the architectural choice EJB implements best-has proved problematic. Typical distributed only on the actual use of the business objects embodiment, EJB nothing but the best choice, which has Verified by countless use cases. Usage of EJB indicates its strengths and weaknesses. Most developers and architects have restricted their use of EJB to stateless session beans and (if asynchronous calls are needed) message-driven beans. The relative simplicity of the services provided by the EJB container to support SLSBs The use of Means That The Overhead of An EJB Container is Hard to Justify In Such Applications. Its advantages and weaknesses have no doubt. Most developers and architects are only limited to the use of stateless Session beans and messages. For the EJB container to provide us with support SLSBS, EJB containers are nothing more than the air-building pavilion in these applications.
Although EJB has been around for five years, and its use is a given in many J2EE projects, it has become apparent that its complexity means that many developers still do not understand it. For example, many developer candidates I interview can not correctly Describe How Ejb Containers Handle Excection Management. Although EJB has five years of development, and it is applied to many special enterprise applications, it is obvious, his complexity means that many developers are now It can't really understand. For example, many developers I interview cannot correctly describe how EJB containers operate exception, how to deal with transactions. The EJB specification is becoming more and more complex in an attempt to address problems with EJB. It's now so long and complex that few developers or architects will have time to read and understand it. With specifications, as with applications, the need for continual workarounds And Constantly Growing Complexity Suggests Fundamental Problems. The current EJB specification is increasingly complex by EJB to solve the problem. This is only a few developers and architects to spend time to read it and understand it. For specification, like applications, this requires constant improvement and a corresponding solution to traditional issues. The Complexity of EJB Means That Productivity In EJB Applications Is Relatively Poor. A Number of Tools Try To Address this, from "Enterprise" Ides to xdoclet and other code generation Tools, But The Complexity Still Lurks Under The Surface and Imposes ONGOING COSTS. Complex EJB means a decrease in productivity in the EJB project. Some tools are trying to solve this problem, from the enterprise integration development environment (IDE) to XDoclet and some code build tools, but this is only hidden under the surface, there is a huge risk. Rigorous Unit Testing and test Driven . development have become increasingly, and deservedly, popular It's become clear that applications making heavy use of EJB are hard to test Developing EJB applications test first requires a lot of fancy footwork;. essentially, minimization of the dependence of application code on the EJB container Strict unit testing and test drive development is increasing, XXXX until popular. This is also increasingly obvious in the EJB project.
Developing an EJB application test program, first of all, we must do a lot of preparation, but in fact, our application code needs to minimize the dependence of the EJB container, which has violated our original intentions. The Emergence of Aspect Oriented Programming (AOP ) points the way to more powerful-yet potentially simpler-approaches to the middleware problems addressed by EJB. AOP can be viewed in part as a more general application of the central EJB concepts, although of course it's much more than a potential replacement to EJB The view of the aspect programming (AOP) indicates a clear road that simply solves the problem of EJB on the intermediate layer. The AOP section solves some of the usual problems that control the status of the EJB component, although AOP does not completely replace EJB. Source Level Metadata Attributes, As Used IN .NET, SUGGEST A Superior Alternative In Many Cases To The Verbose XML-Based Deployment descriptors used since EJB 1.1. EJB 3.0 looks like it's heading down that road as well, but it's a way off and will carry a lot of baggage.Experience has also shown EJB to incur greater cost and deliver fewer benefits than were initially predicted.
Developers have encountered intractable problem, weeen't Apparent When EJB FIRST
Appered. Experience Has Shown That EJB Fails to Deliver In Several Co.
Experience tells us that EJB brings huge cost and less advantages than imagination. Developers have encountered many problems that are difficult to handle than just developing EJBs, mainly in the following aspects:
IT Doesn't Necessarily Reduce Complexity. It is not necessary to simplify complexity. And more complicated. The Entity Bean Experiment for Persistence Has Largely Failed. Entity Bean has a large extent to which the persistence layer is largely failed. Applications using EJB tend to be less portable between application servers than applications using other J2EE technologies, such as servlets. EJB applications become more complex Despite the promises that EJB would prove between the application server and the application of other J2EE Application Technology (servlet) the key to scalability, EJB systems often perform poorly and do not necessarily scale up well. Although statistics are hard to come by, anecdotal evidence suggests that the overhead of excessive use of EJB necessitates re-architecture or causes outright failure in a significant number of Projects. ~ Although EJB promises provide the necessary measurement, the performance of the system has always been a problem, and it is still very serious. Although it is difficult to analyze why, many recommendations EJB need to reform or announce complete failure. EJB CAN Make Simple Things Hard. For Example, The Singleton Design Pattern (or Alternative) IS HARD TO IMPLEMENT IN EJB. EJB makes some simple things complicated. For example, the Singleton mode is difficult to apply to Ejb.all of these Issues Suggest That it's wise to analyze exactly what the value proposition is before using
EJB. I hope to equip you with the Tools to do this effectively and disphandyle.
These issues are proposed by tight analysis before using EJB, I hope you can use some tools to cool and effectively use EJB.
In Chapter 5, We'll Talk More About EJB AND ITS Problems. In The Meantime, Let's Look at Where J2EE IS
Today, WHERE I Feel It's Going, And How this book will help you deliver real solution on time and budget.
In Chapter 5, we will describe more about EJB and related questions. Now let's take a look at today's J2EE, J2EE's development and how this book helps you get more efficient solutions.
What's Left of J2EE?
You May BE WONDERING, "What's Left of J2EE WITHOUT EJB?"
You might be strange, what is "What's left of j2ee without ejb?"
THE ANSWER IS: A Great DEAL. J2EE IS MUCH More Than EJB. Many J2ee Developers Believe Otherwise, Andwill Tell You So WHEN THED
What J2EE DOES OVERALL, Shows That EJB IS Only a Part of a Much Bigger and More Important Picture.
The answer is: a Great deal. J2EE is more extensive than EJB. Many J2EE developers don't even believe this, they will tell you that they have seen this book, but what can be done for EJB, I know that EJB is not unbelievable, just a part of J2EE app, more important .
J2EE Is Essentially About Standardizing A Range of Enterprise Services, Such As Naming and Directory Services
(JNDI) Transaction Management Offering A Standard API Potentially Spanning Disparate Transactional
Resources (JTS and JTA), Connection To Legacy Systems (JCA), Resource Pooling, and Thread
Management. The True Power of J2ee Lies in these Services, and this Standardization Has Done Great
Service to the industry.
J2EE The essence is a range of enterprise-level services, such as JNDI, (JTA / JTS), JCA, Resource Pooling and thread management. J2EE's strength is to apply for these services, and services built by these standards to industry.
EJB, ON The Other Hand, IS MRELY One Way of Leveling Those Valuable Services, Through a Particular
Component model.
EJB is merely a valuable lever in many ways, a special component model.
We can Still Access JNDI, JTA, JCA, Resource Pooling, AND Other Core J2EE Services without using ejb. We
Can do this by Writing Code That Uses Them Directly (Not as Hair-Raising As It May Seem) OR-BETTER-USING
PROVEN LIBRARIES AND Frameworks That Abstract Their Use without Imposing The Complexity of EJB.
Only A Few EJB Container Services Are Unique to EJB, AND There Good Alternative to Those. For example:
We can access JDI, JTA, JCA, Resource Pool, and numerous J2EE core services without EJB. We can use them directly to use them, or use some tools and frames to circulate the complexity of EJB. Only a small amount of EJB container service S is unique to EJB, and there is also a good workfority, such as:
Entity beans are the only dedicated data access components in J2EE. However, they're also the most questionable part of J2EE, and there are much better non-J2EE alternatives, such as Hibernate and JDO. In some applications, JDBC is a better option In J2EE, the entity bean is only important to data storage, which is also part of J2EE, there are many ways to solve the J2EE, such as Hibernate and JDO. In some applications, JDBC is the best choice. Container management Transactions CMT): EJBs are the only part of J2EE to enjoy declarative transaction management This is a valuable service, but as we'll see in Chapters 8 and 9 we can also achieve declarative transaction management using AOP CMT is a relatively thin layer over.. the underlying J2EE JTA service It would be hard (and foolhardy to attempt) to replace an application server's global transaction management, but it's not so hard to access it to develop an alternative form of CMT container-managed transactions (CMT):.. in J2EE In that, EJB is just one of the transaction management solution. Of course, for such an important service, we will introduce our method to use AOP to resolve transaction management in Chapter 8 and 9.cmt just in J2EE JTA service to the last layer. Although it is difficult to replace the application server Global transaction management, but using CMT development transactions is really not easy. Thread pooling for business objects: we usually don't need this if we're supporting Only Web Clients (or Web Services Clients Going Through a servlet Engine), Because A web container provides thread pooling and there's no need to duplicate it in the business object tier. We do need thread pooling to support remote clients over RMI / IIOP, one case in which EJB remains a good, simple technology choice. thread pool business objects : If we only do this service, we usually do not need this service, you should provide a thread pool for each web container, and you don't need to copy a business object layer. When developing remote calls on RMI / IIOP, we need thread pools, which is also one of the few EJBs, and simple technological benefits.
(Related) Thread management for business objects: the ability to implement EJBs as though they are single-threaded In my experience this is overrated for stateless service objects (the most useful kinds of EJB) EJB can not eliminate all threading complexity anyway.. AS Problems Can Remain with Objects Used by EJB FACADES. There Are Good ALTERNATIVES TO EJB Thread Management, Discussed In Chapter 12. Thread Management of Business Objects: Like a single thread, you have the ability to extend EJB. With my experience, this is only too high to estimate the ability of stateless service objects. EJB does not eliminate complexity of all threads because the objects used by EJB may have problems. In Chapter 12, we discuss a better way than the EJB thread is managed.
. Only in the area of remoting is EJB the only way to implement such functionality in standard J2EE As we'll see, only in RMI / IIOP remoting is EJB clearly an outstanding remoting technology; there are better alternatives for web services remoting .. can It is seen that EJB extends only the functionality of J2EE in remote calls. Only in the RMI / IIOP remote aspects have highlighted advantages, you can make us have a better choice in web. There's a strong argument this ejb attempts to address a lot of ip, it's shop, Take O / R mapping . This is a complex problem to which EJB provides a complex yet under-specified solution (entity beans) that simply ignores some of the central problems, such as mapping objects with an inheritance hierarchy to relational database tables. It would have been better for the Designers of The EJB Specification To Leave this Problem To Those with Much More Experience of the Issues Around Object Persistence. These discussion marks EJB trying to solve some problems they can't solve. Operation O / R mapping, for this complex problem, EJB is also A set of solutions is given - entity bean- only ignores some important problems. For example: mapping objects for associated data tables at the inheritance level. This makes the problem to the JEB specification to transfer the problem to the persistent layer of the object. Note # 1: J2EE is much more than EJB Using J2EE without EJB, we do not have to reinvent the wheel We do not need to reimplement J2EE services, just consider alternative ways of tapping into them J2EE EJB more than... Come extensive. With J2EE, it is not necessarily necessary to use EJB. We don't have to re-invent the wheel, we don't need to re-implement J2EE service, just choose a shortcut. J2EE at a Crossroads at the intersection of J2EE J2EE is at a fascinating point in its evolution In many respects it's a great success It has succeeded in bringing standardization where none existed;.. It has introduced a welcome openness into enterprise software It has achieved. The temptation of the J2EE is its development potential. It is already successful in many aspects. These success comes from non-standardization.
J2EE is an open enterprise software, greatly approved by business and developers. On The Other Hand, I Feel It Has Come Up Short ON A Number of MeasureS. J2ee Applications Are Usually Too Expensive To Develop. J2EE Application Projects Are at least as prone to failure as pre-J2EE projects (Which means that the failure rate is unacceptably high;. developing software is far too hit-and-miss an affair). In the areas where J2EE has failed, EJB has usually played a significant part. J2EE has significant issues with ease of development. As I've said, J2EE applications tend to be unnecessarily complex. This is especially true of J2EE web applications, which, like the Sun Java Pet Store, are often absurdly over-engineered On the other hand, I think the deficiency is that J2EE application development costs are too high, which makes pure J2EE projects to end in failure. (The failure here means that the solution is not adopted).
Summary J2EE failure, EJB is often an important factor. J2EE's key issue is to make development easier, as I said, reduce unnecessary complications. Especially J2EE's web application, like Sun Java Pet Store is typical the over-engineering. J2EE is still a relatively young technology. It's not surprising that it's imperfect. It's time to take stock of where it's worked, and where it has not worked so well, so that we can eliminate the negatives and enjoy the positives . Because J2EE contains a lot, this essentially means identifying the subset of J2EE that delivers most value, along with some supplementary infrastructure we need to harness it most effectively. In contrast, J2EE as the development of a new generation of technology, there are some shortcomings as inadequate Odd. We can carry forward the advantage, to go to the disadvantage, thereby positioning J2EE applications, due to J2EE full of too much content, in principle, it is necessary to position J2EE's core value, opening up an effective development. There is a growth movement in the J2EE community toward simpler solutions and less use of EJB. My previous book, Expert One-on-One J2EE Design and Development (2002), was a step in the growth of that movement, but was part of a broader trend. I believe This Book Repesents The next Step in Defining and Popular QUCH SOLUTIONS, But It's Important to Note T hat I'm by no means alone. Fellow pioneers include Rickard Oberg and Jon Tirsen (of Nanning Aspects), who have helped to demonstrate the power and simplicity of AOP-based solutions. The revisions in the second edition of Core J2EE Patterns suggest that Even sun is not immune; there is a new and welcome EMPHASIS ON Use of Plain Java Objects. Most of the development is simply moving, including EJB usage. Compared with my last book
Core J2EE Patterns in the second revision of the Sun is not even involved in, but the focus lies with POJO. Some of the problems with J2EE and EJB relate to its specification-driven origins. History shows that the most successful standards evolve, rather than are created by a committee The danger of a "specificationfirst" approach is shown by the example of the OMG and CORBA The OMG was founded to create a distributed object standard Over 300 vendors signed up;... the result was the slow production of complex . specifications that never achieved widespread acceptance as is often the case with committees, usability by developers was barely a consideration;. the result was a horribly complex programming model some problems in J2EE and EJB is the norm drive caused by historical proof. Many successful development is faster than standards. The results caused by "Specifications" are obvious, such as OMG and CORBA.oMG are criteria for creating a distributed object. More than 300 people are added, but the results have given us a super complex product that has never been accepted by the public.
However, in the work of the Standards Committee, there is no consider the availability of developers. Of course, it can only be a complex programming model. J2EE IS Partly An Evolution of Existing Middleware, Because Many of The Problems It Addresses Were Familiar WHEN IT WAS CONCEIVED in the late 1990s. for example, stateless session EJBs are merely an EJB take on a component type of proven value. Service objects with declarative transaction management existed in Microsoft Transaction Server, for example, before the EJB 1.0 specification. It's arguable that where J2EE has tried to innovate, through specifications being developed before any real applications using them, it has often failed. Stateful session beans, for example, were a new and unproven component type introduced in EJB. Five years on, they remain largely unproven. The tricky Issue of State Replication Remains Problematic, And MOST Architects Avoid Stateful Session Beans if at All Possible. ~ J2EE is also a part of the development of middleware, because in 1990, J2EE encountered many common problems. For example, stateless session EJBS is just a component type provided by EJB. Not finished ...