Java EE 5 Notes
lisa yang
Overview
A Java EE application is delivered in an Enterprise Archive (EAR) file, a standard Java Archive (JAR) file with an .ear extension.
There are two types of deployment descriptors: Java EE and runtime. A Java EE deployment descriptor is defined by a Java EE specification and can be used to configure deployment settings on any Java EE-compliant implementation. A runtime deployment descriptor is used to configure Java EE implementation-specific parameters.
A Java EE module consists of one or more Java EE components for the same container type and one component deployment descriptor of that type. The four types of Java EE modules are as follows:
• EJB modules, which contain class files for enterprise beans and an EJB deployment descriptor. EJB modules are packaged as JAR files with a .jar extension.
• Web modules, which contain servlet class files, JSP files, supporting class files, GIF and HTML files, and a web application deployment descriptor. Web modules are packaged as JAR files with a .war (Web ARchive) extension.
• Application client modules, which contain class files and an application client deployment descriptor. Application client modules are packaged as JAR files with a .jar extension.
• Resource adapter modules, which contain all Java interfaces, classes, native libraries, and other documentation, along with the resource adapter deployment descriptor. Together, these implement the Connector architecture (see J2EE Connector Architecture, page 24) for a particular EIS. Resource adapter modules are packaged as JAR files with an .rar (resource adapter archive) extension.
Enterprise JavaBeans Technology
There are two kinds of enterprise beans: session beans and message-driven beans. A session bean represents a transient conversation with a client. When the client finishes executing, the session bean and its data are gone. A message-driven bean combines features of a session bean and a message listener, allowing a business component to receive messages asynchronously. Commonly, these are Java Message Service (JMS) messages.
In Java EE 5, entity beans have been replaced by Java™ persistence API entities. An entity represents persistent data stored in one row of a database table. If the client terminates, or if the server shuts down, the persistence manager ensures that the entity data is saved.
Java servlet technology lets you define HTTP-specific servlet classes. A servlet class extends the capabilities of servers that host applications that are accessed by way of a request-response programming model.
JavaServer Pages™ (JSP™) technology lets you put snippets of servlet code directly into a text-based document.
The JavaServer Pages Standard Tag Library (JSTL) encapsulates core functionality common to many JSP applications.
JavaServer Faces technology is a user interface framework for building web applications.
The Java Message Service (JMS) API is a messaging standard that allows Java EE application components to create, send, receive, and read messages.
The Java Transaction API (JTA) provides a standard interface for demarcating transactions. The Java EE architecture provides a default auto commit to handle transaction commits and rollbacks.
Java EE applications use the JavaMail™ API to send email notifications.
The JavaBeans Activation Framework (JAF)
The Java API for XML Processing (JAXP), part of the Java SE platform, supports the processing of XML documents using Document Object Model (DOM), Simple API for XML (SAX), and Extensible Stylesheet Language Transformations (XSLT).
The Java API for XML Web Services (JAX-WS) provides support for web services that use the JAXB API for binding XML data to Java objects.
The Java Architecture for XML Binding (JAXB) provides a convenient way to bind an XML schema to a representation in Java language programs.
The Java API for XML Registries (JAXR) lets you access business and generalpurpose registries over the web. JAXR supports the ebXML Registry and Repository standards and the emerging UDDI specifications.
The J2EE Connector architecture is used by tools vendors and system integrators to create resource adapters that support access to enterprise information systems that can be plugged in to any Java EE product.
The Java™ Database Connectivity (JDBC) API lets you invoke SQL commands from Java programming language methods.
The Java™ Persistence API is a new all Java standards based solution for persistence. Persistence uses an object-relational mapping approach to bridge the gap between an object oriented model and a relational database.
The Java Naming and Directory Interface™ (JNDI) provides naming and directory functionality, enabling applications to access multiple naming and directory services, including existing naming and directory services such as LDAP, NDS, DNS, and NIS.
The Java Authentication and Authorization Service (JAAS) provides a way for a Java EE application to authenticate and authorize a specific user or group of users to run i
The Sun Java System Application Server Platform Edition 9 is a fully cmpliant implementation of the Java EE 5 platform.
To start the Application Server,
asadmin start-domain --verbose domain1
• The Application Server’s port number. The default is 8080.
• The administration server’s port number. The default is 4848.
• An administration user name and password.
To stop the Application Server,
asadmin stop-domain domain1
To start the Admin Console,
http://localhost:4848/asadmin/
To start the Java DB database server,
asadmin start-database
To stop the Java DB server,
asadmin stop-database
Web Tier
Web Application Life Cycle
# Develop the web component code.
# Develop the web application deployment descriptor.
# Compile the web application components and helper classes referenced by the components.
# Optionally package the application into a deployable unit.
# Deploy the application into a web container.
# Access a URL that references the web application.
Web Modules
A context root must start with a forward slash (/) and end with a string.
(sun-web.xml)
Mapping URLs to Web Components When a request is received by the web container it must determine which web component should handle the request. It does so by mapping the URL path contained in the request to a web application and a web component. A URL path contains the context root and an alias:
http://host:port/context_root/alias
Setting the Component Alias
The alias identifies the web component that should handle a request. The alias path must start with a forward slash (/) and end with a string or a wildcard expression with an extension (for example, *.jsp). Since web containers automatically map an alias that ends with *.jsp, you do not have to specify an alias for a JSP page unless you wish to refer to the page by a name other than its file name.
servlets need to be mapped in the web.xml file
Declaring Welcome Files (WEB-INF/web.xml)
Setting Initialization Parameters (WEB-INF/web.xml)
# A param-name element that specifies the context object.
# A param-value element that specifies the parameter to pass to the context object.
# A context-param element that encloses the previous two elements.
Mapping Errors to Error Screens (web.xml ->Error Page )
Declaring Resource References
If your web component uses objects such as enterprise beans, data sources, or web services, you use Java EE annotations to inject these resources into your application.
you can only inject resources into container-managed objects.
Web Components That Accept Resource Injections
Component
Interface/Class
Servlets
javax.servlet.Servlet
Servlet Filters
javax.servlet.ServletFilter
Event Listeners
javax.servlet.ServletContextListener
javax.servlet.ServletContextAttributeListener
javax.servlet.ServletRequestListener
javax.servlet.ServletRequestAttributeListener
javax.servlet.http.HttpSessionListener
javax.servlet.http.HttpSessionAttributeListener
javax.servlet.http.HttpSessionBindingListener
Taglib Listeners
same as above
Taglib Tag Handlers
javax.servlet.jsp.tagext.JspTag
Managed Beans
Plain Old Java Objects
Declaring a Reference to a Resource The @Resource annotation is used to declare a reference to a resource such as a data source, an enterprise bean, or an environment entry. This annotation is equivalent to declaring a resource-ref element in the deployment descriptor.
@Resource javax.sql.DataSource catalogDS;
public getProductsByCategory() {
// get a connection and execute the query
Connection conn = catalogDS.getConnection();
..
}
multiple resources:
@Resources ({
@Resource (name="myDB" type=java.sql.DataSource),
@Resource(name="myMQ" type=javax.jms.ConnectionFactory)
})
Declaring a Reference to a Web Service
The @WebServiceRef annotation provides a reference to a web service.
...
import javax.xml.ws.WebServiceRef;
...
public class ResponseServlet extends HTTPServlet {
@WebServiceRef(wsdlLocation=
"http://localhost:8080/helloservice/hello?wsdl")
static HelloService service;
Duke's Bookstore Examples
Declaring a Reference to a Web Service
Tuesday, July 3, 2007
Subscribe to:
Post Comments (Atom)
Disable Microsoft Defender for Cloud for Visual Studio Subscription (MSDN)
I use a visual studio pro subscription which comes with $150 azure cloud credit, for some reason Microsoft Defender for Cloud was turned on ...
-
Error 15401: Windows NT user or group '%s' not found. Check the name again. SELECT name FROM syslogins WHERE sid = SUSER_SID ('Y...
-
Finally, it is time. E4SE 811 and eBackoffice 736 will replace our current 810b/735a environment after staying so many years. Just got the n...
-
/etc/ipsec.config conn ios keyexchange=ikev1 authby=xauthrsasig xauth=server lef...
No comments:
Post a Comment