Overview of other J2EE technologies Version 1.0
Introduction •The three primary components of J2EE application are: – Servlet – JSP – EJB •In addition to these, J2EE provides additional technologies which helps in building J2EE applications. •This session is an overview of all these technologies. TCS Internal
September 3, 2009
Technologies •Java Messaging Service •JavaMail •JNDI •JAAS
TCS Internal
September 3, 2009
Java Messaging Service (JMS) •JMS is a wrapper API that standardizes messaging functionality of other service providers such as IBM MQSeries, etc. •JMS does not provide any services directly. •It facilitates to access messaging facilities provided by different messaging-service provider.
TCS Internal
September 3, 2009
Messaging •Messaging is a means by which distributed applications communicate with each other. •A message is a self-contained package of business data and routing headers. •Message based applications communicate asynchronously through a message server. •Services that support message-based applications are known as message-oriented middleware.
TCS Internal
September 3, 2009
JMS Features •JMS supports clustered, high-availability message servers. •JMS supports transaction to ensure that related messages are either delivered together or not at all. •JMS messages can be accessed/processed by message driven beans. •JMS, unlike RMI helps create loosely coupled applications.
TCS Internal
September 3, 2009
Message Structure •Headers – Fixed set of metadata fields •Properties – Set of key-value pairs used for application specific purpose. •Body – The actual content to be sent.
TCS Internal
September 3, 2009
Message Types •ByteMessage – A stream of bytes •MapMessage – A set of key-value paiars •ObjectMessage – Serialized object instance •StreamMessage – A stream of primitives •TextMessage – A String instance TCS Internal
September 3, 2009
Types of Messaging •Point-to-point messaging – Messages send through queues. – Only one consumer can consume a message. •Publish-and-subscribe messaging – Messages are sent through topics. – Many subscribers can consume messages.
TCS Internal
September 3, 2009
Message Components •Destinations – Place where the message is sent. – Specific type of destinations are queues (point-to-point systems) and topics (publish-subscribe) systems. – Destinations are configured by messaging server. – Destinations are not created by application, but can be obtained by JNDI lookup. •Connections – This represents the connection between the application and messaging server over which messages can be sent. TCS Internal
September 3, 2009
Message Components (Contd.) •Connection Factories – Connections cannot be directly instantiated. – Connection factory creates connection objects. – Connection factory is found by JNDI lookup. •Sessions – Messages are not directly sent and received. – Session serves as a factory which is used by message, producers and consumers. – Session provides transactional behavior TCS Internal
September 3, 2009
Message Components (Contd.) •Producers – Producers represent objects which produce message. •Consumers – Consumers represent objects which consumer message.
TCS Internal
September 3, 2009
Java Mail •JavaMail API is an abstract suite of classes for handling message-based systems. •JavaMail makes it easy to incorporate complete e-mail connectivity within any Java program, Servlet, bean, or applet.
TCS Internal
September 3, 2009
Mail Protocols •Protocols define the way mails are packages and sent. •The three popular mail transfer protocols are: – SMTP (Simple Mail Transfer Protocol) •Designed to deliver mails to server – POP3 (Post Office Protocol Version 3) •Popular mechanism to collect/read mails. – Internet Message Access Protocol (IMAP) •Rich set of functionalities. TCS Internal
September 3, 2009
JavaMail Functions •The major functions of JavaMail API are: – Session Management •Manages all aspects of communication •Means for mail to interact with network – Message Manipulation •Used to create and manipulate mails. – Mail Storage and Retrieval •Used to store mails in hierarchical structure. – Transportation •Takes care of delivery of mails. TCS Internal
September 3, 2009
JAAS •JAAS stands for Java Authentication and Authorization Services. •JAAS is the security mechanism of preventing unauthorized users into J2EE application.
TCS Internal
September 3, 2009
JASS Mechanisms •Authentication services – These services ensure that every user is authorized to use system and its resources – This essentially matches with the underlying operating system’s access mechanism. •Authorization services – These services associate a set of permissions with each user. – This helps in granting differing levels of access to different users. TCS Internal
September 3, 2009
JAAS Security Realms •JAAS Security Realm is a logical grouping of users and services that make sense. •It may be: – Users using a particular machine – Users working for a company / division / workgroup.
TCS Internal
September 3, 2009
JNDI •Naming service essentially translates human-friendly names to machine-friendly names. •Normally these are called directory services associating names as well as assign some additional attributes. •Directory services are important in network infrastructure, because they enable users and applications to look up network resources. •JNDI provides a set of API that provide directory and naming services to Java applications. TCS Internal
September 3, 2009
JNDI Packages •Naming – Used to access simple naming services. •Directory – Used to access directory services. •Event – Handles event notification •LDAP – Deals with LDAP controls and operations •SPI – Consists of Service Provider Interface (SPI) classes and interfaces used by LDAP TCS Internal
September 3, 2009
Java Transaction API (JTA) •All transactions with the database should be atomic with ACID property. •In normal applications local transaction takes place which is easy to manage. •In distributed applications, various applications will be involved in transaction and somebody should take care. •JTA provides interface that can communicate with JTS (Java Transaction Service).
TCS Internal
September 3, 2009
Reference •James Mc Govern, et. al., J2EE 1.4. Bible •S Allamaraju, et. al., Professional Java Server Programming, J2EE 1.3 Ed.
TCS Internal
September 3, 2009