|
Questions and Answers - Frequently Asked Questions
General
Java Pet Store Demo
Q. I am new to the J2EE platform, where do I
begin?
A. The best places to start are the Java Tutorial for learning about Java
programming, and the J2EE
Tutorial for getting acquainted with the different J2EE
technologies.
The Java Enterprise BluePrints and the Java Pet Store demo
application assume that developers are already familiar with the
concepts of the J2EE Tutorial. Once you have completed the J2EE
Tutorial, you should read our guidelines, and then download our
free source code to start building
J2EE applications.
Back to top
Q. Can the Java Pet Store Demo really be
ported to another platform or programming language?
A. The purpose of the JavaTM Pet
Store Demo is to illustrate design patterns and advanced coding
strategies that relate directly to the Java programming language and
specifically to the JavaTM 2
Platform, Enterprise Edition (J2EETM). A genuinely ported application would have to
implement the same design patterns and same coding strategies to
really be comparable. It would also need to have the same depth of
exception handling and use the same container-managed services such as
transaction management, threading, persistence, and asynchronous
messaging.
The Java Pet Store Demo can be re-implemented as a new application
on a proprietary platform, but then your technology
infrastructure--that is, your application platform--is
single-sourced. Source code portability is an issue only when you're
fully rewriting your application. The Java Pet Store Demo is portable
across a multitude of platform implementations from different
vendors. The J2EE deployathon demonstrates this. Vendor portability
offered by the J2EE platform allows you to select technologies for price
and performance instead of being locked into one vendor's proprietary
products, pricing, and upgrade schedules. With the J2EE platform, you
choose technology based on your needs rather than on your technology
vendor's control of your information assets. Then there's much less
reason to have to think about porting your whole application to another
platform because you're locked into a vendor-proprietary solution.
Back to top
Q. Can the Java Pet Store Demo be
extended to support XML-based Web services?
A. Yes, the version 1.3.1 of Java Pet Store Demo demonstrates
this. Sun has recently released new Java API standards on web services
that illustrate the means for extending the Java Pet Store Demo.
For details on the latest Java APIs for Web services, see the J2EE Technology and Web
Services page.
Also see the current
recommendations from the Java BluePrints team.
Back to top
Q. Can the Java Pet Store Demo be
extended to support mobile devices?
A. Yes. Sun has recently released the Java 2 Platform, Micro
Edition (J2ME) Wireless
Toolkit to support the development of client software running on
cell phones, two-way pagers, and palmtops.
The Java BluePrints program publishes guidelines for
developing mobile applications using J2ME clients that connect to
J2EE application servers. The Java Smart Ticket
Demo illustrates those guidelines in the context of an electronic
ticketing scenario.
Back to top
Q. Why does the Java Pet Store Demo have so
many lines of code?
A. The Java Pet Store Demo is designed to provide as much sample
code as possible for the key aspects of the latest release of the J2EE
platform. We deliberately added more code to create a flexible
architecture that is fully object-oriented. We were trying to show off
concepts and design patterns of Java Enterprise BluePrints, and hence
there is more code. Our goal is to offer the developer community a
well designed sample application. Also, it is widely accepted that the
number of lines of code is a poor metric for measuring either
developer productivity or ease of future maintenance.
To us a good application design involves:
Maintainability: The code is more maintainable and
flexible in the long run. New functionality can be added
easily.
Portability: Freedom of choice, no vendor
lock-in.
Scalability: A distributed application such as a J2EE
application is more scalable. However, it is demonstrably more complex
to write.
Back to top
Q. Why hasn't the Java Pet Store Demo
been optimized for performance?
A. The Java Pet Store Demo was not created to be a benchmark. The
most important function of the Java Pet Store Demo is to educate. It
was meant to illustrate design patterns and best practice guidelines
for many important aspects of J2EE applications such as portability
and maintainability:
Portability gives the developer freedom of choice in
selecting the optimal platform for their needs and in reducing the
time and effort of migrating from one platform to another. It makes it
less painful when you upgrade production versions.
Maintainability is another issue that may be tempting to
ignore but can result in major headaches. One of the critical
strengths of object oriented programming has been that the code is
easier to maintain. Object-oriented code has enabled the creation of
larger, more highly-functional and extensible applications.
The performance of the Java Pet Store Demo can be enhanced by using
local interfaces instead of remote for the enterprise beans, by improving
the SQL in its DAOs or by using container-managed persistence, and by
writing a few simple caching tags in the web layer. The
version 1.3.1 of Java Pet Store Demo implements
these optimizations.
If you are interested in source code for a larger J2EE application
that exemplifies optimized code, see the ECperfTM software page. For general guidelines on performance,
visit the Java BluePrints for Performance website.
Back to top
Q. Why doesn't the Java Pet
Store Demo use stored procedures?
A. We don't use stored procedures since they will result in a
non-portable application. Our design allows, however, for stored
procedures to be added elegantly--all you need to do is to provide an
alternate Data
Access Object that plugs into the application architecture and
makes stored procedure calls.
These are essentially a performance optimization that are
particular to a specific application and its deployment
environment. For this reason, it falls outside the scope of Java
Enterprise BluePrints which focuses on the application programming
model.
Back to top
Q. Why are there so many Enterprise
JavaBeans (EJBTM) components in the Java Pet Store Demo? Are
all of them really needed?
A. The Java Pet Store Demo strives to provide as many examples as
possible of the many features and benefits that Enterprise
JavaBeans (EJBTM) technology provides. The application design
reflects our intent to show as many examples as possible of effective
use of enterprise beans.
Your application's requirements determine where enterprise beans
are appropriate. Once you've determined where to use enterprise beans,
you can find examples the Java Pet Store Demo for how to do so
effectively.
The Java Pet Store Demo is an educational tool focusing on
demonstrating patterns and best practices espoused by Java Enterprise
BluePrints. In many places, we've sacrificed performance in order to
clarify the code or to make a particular design point.
Back to top
Q. What is the purpose of the Java Pet Store
Demo's Data Access Objects (DAOs) and why are all SQL statements
included there?
A. They are part of the persistence strategy of Java Pet Store Demo.
The preferred approach for persistence is container-managed persistence (CMP).
However, in certain
cases, bean-managed persistence (BMP) is a better fit and hence the Java
Pet Store Demo uses DAOs to implement them. See the Data Access Object pattern.
Back to top
Q. Why are the Java Pet Store Demo's
configuration files so complicated?
A. They are complicated for the same reason that the dashboard of a
fighter jet is more complicated than your car's dashboard: because
you're controlling a lot more power and functionality. Deployment
descriptors are complicated because they configure J2EE technology
components and their containers. J2EE containers provide a high level
of standard services (transactions, security, persistence, thread
safety, etc.) to the components they manage, but the interface between
the components and their container, as well as the container behavior,
need to be configured. They're also extremely flexible. These factors
make J2EE deployment descriptors somewhat complex.
Because deployment descriptors are XML documents, they can be
edited manually. Most developers shouldn't have to see
them. Deployment descriptors are better created and maintained using
the tools bundled with your J2EE environment. Powerful tools are one
of the things a J2EE product customer should look for when selecting a
platform implementation.
Back to top
Q. Why does the Java Pet Store Demo use
Model-View-Controller (MVC)?
A. See the Model-View-Controller pattern.
Back to top
Q. Does the Java Pet Store Demo
provide guidelines on caching?
A. No. To some extent, this falls into performance optimization. We
do provide strategies such as using a Stateless Session Bean EJB to
hold onto reuseable resources and the ServiceLocator pattern. We don't
really address caching of application data very much. We also have
some strategies for extending the petstore app to do some caching
which have been discussed on the J2EE
BluePrints interest list.
Back to top
Q. Why does the Java Pet Store Demo
contain so many design patterns? Should all of them be used every
time?
A. The reason here is because the Java Pet Store demo application
is primarily educational, and we want to illustrate how to use J2EE design patterns
in a real world application.
Back to top
Q. How portable is the Java Pet Store
Demo application really?
A. The annual J2EE Deployathon clearly demonstrates that the Java
Pet Store Demo is extremely portable. Java Pet Store Demo 1.1.2 has
successfully been deployed on 9 different J2EE platform/operating
system combinations.
The Java Developer Connection
has information on the J2EE
Deployathon with Java Pet Store 1.1.2.
Back to top
Q. Does the Java Pet Store Demo run on Windows
98?
A. The Java Pet Store Demo can run on any operating system that
supports the J2EE platform. It is possible to run implementations of
the J2EE platform on Windows 98 but the recommended systems are
Solaris, Linux, Windows NT, or
Windows 2000.
To get the demo to run on Windows 98, you must alter some of the
batch scripts which use the "%*" notation which is not supported on
Windows 98. Find each occurrence of
%*
Change it to
%1 %2 %3 %4 %5 %6 %7 %8 %9
Back to top
|