« Home « Kết quả tìm kiếm

Pro Java EE Spring Patterns


Tóm tắt Xem thử

- Printed and bound in the United States of America .
- This book is an effort to document a cata- log of frequently used design strategies with the Spring Framework, which is relevant in the context of the latest Java 5 EE specifications.
- Chapter 3 explains the design problems in the presentation tier and presents solutions with the Spring MVC framework.
- In the process, it also interacts with the data access layer..
- In the early 1980s, personal computers (PCs) became very popular.
- This, coupled with the growth of the Internet and web-based application development trends, resulted in the emergence of three-tier architectures..
- The platform was based on Java Platform, Standard Edition 2, and as a result it had the benefit of “write once, deploy and run anywhere.” The platform received tremendous support from the open source community and major commercial vendors such as IBM, Oracle, BEA, and others because it was based on specifications.
- In the traditional MVC architecture, the data access or integration layer was assumed to be part of the business layer.
- In the next chapter, I’ll show how the Spring Framework further simplifies Java EE application design and architecture.
- Finally, I will wind up this chapter with the Spring Java design pattern directive that will be used in the next three chapters of this book.
- Figure 2-1 shows the various modules of the Spring Framework..
- High-level building blocks of the Spring Framework.
- we’ll call you.” (The junior artists often hear this from production managers in Holly- wood.) However, this is important in software development as well to control the flow of applications while ensuring high cohesion and low coupling.
- Now that I have wired the bean in the XML configuration file, it is time to start the IOC container, as shown in Listing 2-6..
- Because I have the Spring container up and running, it is now possible to retrieve beans from the bean factory that can then be used to perform some useful work in the application..
- Registering event listeners in the bean factory.
- The Spring application context can be created like a bean factory and without any alteration in the configuration file, as shown in Listing 2-12..
- It also binds the data objects returned by the page controllers after invoking the model objects in the business tier and finally dispatches the HTTP response to the client.
- The POJO business objects are all configured in the Spring IOC container just like any other bean shown in earlier examples.
- The Spring AOP module plays a significant role in the business tier.
- In the previous chapter, I have discussed the foundations of Java EE architecture and design.
- This pattern template or directive will be used in the next four chapters to describe how Java EE design patterns can be best applied using the Spring Framework..
- In this chapter, I put the Spring application framework in the context of Java EE application architecture and design.
- Just like any application, the Spring application framework’s core lies in the IOC container..
- The lack of design and OO skills in the eInsure team (most of the team members themselves were making a transition to acquire Java EE technology skills along with the product) added to the woes.
- In this and subsequent chapters, I will discuss in greater detail some of the problems in the application under consideration.
- This was the case with 95 percent of the JSPs in the application..
- This is because every technology in the Java EE platform has its own role.
- These are registered in the Spring container and implement the GOF command pattern.
- All the code in the if-else block is moved into page controllers.
- <url-pattern>*.do</url-pattern>.
- On initialization, the DispatcherServlet looks for a configuration file with the naming convention <servlet-name>-servlet.xml in the WEB-INF folder of the web application.
- The handleRequest method should have most of the code that was in the if-else block of the JSP controller.
- Simply stated, this controller will take care of the code in the if-else blocks.
- Out-of-the-box front controller: The Spring MVC provides a ready-made front con- troller that can be used in the application by mere configuration..
- As with the JSP con- troller, it is entirely possible to build the two other functions in the front controller.
- This was exactly the problem with the JSP- based controller used in the eInsure application..
- In the next few sections, I will go through the various application controller configuration options available with the Spring Framework.
- The doDispatch method looks for an interceptor list that has been configured in the Spring container.
- This handler mapping is used to map the request URL directly to the bean object or a page controller registered in the Spring IOC container.
- matched with the name of the bean in the application context.
- Now that the handler mapping is detected, the front con- troller will then look up a bean with the name / createPolicy.do in the Spring container..
- However, it is possible to turn on the use of full path by setting a boolean flag, alwaysUseFullPath , as shown in the con- figuration in Listing 3-7..
- Since this is not the default handler mapping, it has to be explicitly configured in the Spring configuration file, as shown in Listing 3-8..
- As shown in Listing 3-8, the controllers are configured just like any other bean in the Spring container.
- jsp will result in the URL claimdetail.jsp .
- In the next section, I will show some of the commonly used concrete view resolvers in action..
- This file is picked up from the classpath and should be placed in the /WEB-INF/classes folder of the web application..
- Finally, the page controller and view resolver should be configured in the Spring application context so that the dispatcher servlet can use them.
- In this is the value of the property policydetails.class .
- Finally, we need to configure the XmlViewResolver in the application con- text so that it can be used by the front controller servlet.
- value=".jsp"></property>.
- Moreover, it can be used as references for policies taken by the claimant in the future..
- It is easy to consider embedding these blocks in the front controller dispatcher servlet.
- In the next few sections, I will explore the page controllers in greater detail..
- Putting the JavaBean creation logic in the controller violates SRP.
- Any change to the form field may cause a change in the controller.
- value=".jsp".
- It converts a resource name in the URL into a logical view name..
- Finally, I will wire up the beans in the Spring configuration file as shown in.
- The form bean is automatically set in the model object by the framework itself, with the identifier as the command name.
- Hence, you don’t need to register the form bean in the constructor of the page controller..
- In the form shown in Listing 3-24, the fields have certain restrictions.
- This is done by wiring it in the Spring configuration.
- This is shown in the modified Spring configuration in Listing 3-31..
- Finally, the controller needs to be added in the Spring configuration, as shown in Listing 3-36..
- The tight coupling of the form bean in the page controller can be solved by a custom solution.
- Finally, I will wire up everything in the Spring configuration file..
- In the previous few sections, I have tried to alter and extend the workflow of the throw- away controller.
- Otherwise, the next filters in the chain (if any) are executed.
- This is shown in the Spring configuration file (Listing 3-45).
- Use view helpers to adapt model data with the view components in the presentation layer..
- Listing 3-47 shows the controller that binds the transfer object in the request scope..
- It is retrieved and supplied in the form bean by the controller (see in Listing 3-52) by overriding the formBackingObject method..
- Since I have added a field in the form presented by the JSP, a new field has to be added to the form bean class.
- <h3>eInsure - rel 3.0.1 </h3>.
- Extract the content of the title tag, and apply it in the primary layout..
- It looks for a bean with the name /policydetails.do in the application context and dele- gates the processing to it.
- Hence, the next handler mapping in the chain,.
- The simplified workflow is shown in the sequence diagram in Figure 3-18..
- In Listing 3-58, it looks for an attribute with the key productDtlList in the servlet context..
- The bridge between the two layers is provided by the Business Delegate pattern, which we will explore in the next chapter..
- The Front Controller pattern intercepted all requests and delegated to the action handlers in the Application Controller pattern.
- The JndiObjectFactoryBean is the most widely used service locator class in the Spring Framework.
- In the case of.
- Hence, it is necessary that the EJBs are loaded and registered in the JNDI before the Spring web application starts initialization..
- It is possible to look up and load JNDI objects lazily in the Spring IOC container.
- The EJB objects looked up by the service locator are injected in the business delegate by the Spring IOC container.
- Now everything needs to be wired up in the Spring configuration file shown in List- ing 4-14.
- Finally, you will need to wire this bean in the Spring configuration to replace the EJB..
- The business delegate introduces an extra layer that increases the number of classes in the application.
- In an ideal situation, the page controllers will be unaware of such internal changes in the business delegate.
- In the next few sections, I will try to simplify the development of the session facade with Spring EJB support classes..
- The bean implementation class is responsible for providing imple- mentation for the business methods defined in the remote interface.
- The eInsure application’s business logic was entirely coded in the session facades.
- The session facades run in the EJB container.
- The PolicyDetailDao is injected in the application service by the Spring container..
- This is shown in the EJB application context configuration in Listing 4-23..
- The constant in the business interface supplies the value of the key used to look up the application service bean..
- In the case of the remote SLSB, the business interface methods must declare a throws clause for RemoteException

Xem thử không khả dụng, vui lòng xem tại trang nguồn
hoặc xem Tóm tắt