m2 j2ee services
TRANSCRIPT
-
8/9/2019 M2 J2EE Services
1/59
J2EE ServicesJ2EE Services
Technology Consulting Technology Consulting
PramatiPramati TechnologiesTechnologies
-
8/9/2019 M2 J2EE Services
2/59
J2EE ServicesJ2EE Services
Services provided areServices provided areJNDI (Java Naming and Directory Service)JTA (Java Transaction API)
JAAS (Java Authorization and Authentication Service)JMS (Java Message Service)JCA (J2EE Connector Architecture)RMI-IIOP (Inter-operability)JDBC (Java Database Connectivity)JavaMailJAXP (Java API for XML Parsing)
-
8/9/2019 M2 J2EE Services
3/59
Naming Services & JNDI Naming Services & JNDI
-
8/9/2019 M2 J2EE Services
4/59
Naming Services:Overview Naming Services:Overview
Requirement:Requirement:Distributed applications require something to helpDistributed applications require something to helpthe components to find each other the components to find each other
The Java Naming and Directory Interface (JNDI)The Java Naming and Directory Interface (JNDI) provides just this capability. provides just this capability.
-
8/9/2019 M2 J2EE Services
5/59
Naming Services Naming Services
Maintains a set of Maintains a set of b indings.b indings.Bindings relate names to objects.Bindings relate names to objects.
Naming Convention Naming Convention - - All objects in aAll objects in anaming system are named in the same waynaming system are named in the same wayClients use the naming service to locateClients use the naming service to locateobjects by name.objects by name.
-
8/9/2019 M2 J2EE Services
6/59
Existing naming servicesExisting naming services
DNS (Domain Name SystemDNS (Domain Name SystemLDAP (Lightweight Directory AccessLDAP (Lightweight Directory Access
Protocol):Protocol):NIS (Network Information System) NIS (Network Information System)COS (Common Object Services) NamingCOS (Common Object Services) Naming
-
8/9/2019 M2 J2EE Services
7/59
A look at JNDI namingA look at JNDI naming
JNDI is anJNDI is an interfaceinterface rather than anrather than animplementation.implementation. Advantage
Allows JNDI to integrate seamlessly into an existingcomputing environment where an established naming serviceholds sway.
DisadvantageNeed access to an existing naming service ( such as LDAPservice) and hence the need to understand something abouthow it works in order to play with JNDI.
-
8/9/2019 M2 J2EE Services
8/59
Context and InitialContextContext and InitialContext
The Context interface:The Context interface: Represents a set of bindings Provides the methods for binding names to objects and unbinding
names from objects, for renaming objects, and for listing the bindings.
provides methods for creating and destroying subcontexts
InitialContext class:InitialContext class: This class is instantiated with properties that define the type of
naming service in use and, for naming services that providesecurity, the ID and password to use when connecting.
-
8/9/2019 M2 J2EE Services
9/59
Context's methods:Context's methods:
void bind(String stringName, Object object)void rebind(String stringName, Object object)Object lookup(String stringName)void unbind(String stringName)void rename(String stringOldName, String stringNewName)NamingEnumeration listBindings(String stringName)NamingEnumeration list(String stringName)
The Context interface also provides methods for renamingand listing bindings.
-
8/9/2019 M2 J2EE Services
10/59
Container Naming ServicesContainer Naming Services
Provide application clients, enterprise beans, andWeb components with access to a JNDI namingenvironment
naming environment allows a component to becustomized without the need to access or changethe components source code.Container implements the componentsenvironment, provides it to the component as aJNDI naming contex t.
-
8/9/2019 M2 J2EE Services
11/59
Container Naming ServicesContainer Naming Services
Tech detailsTech details A component creates a javax.naming.InitialContext
object
looks up the environment naming context inInitialContext under the name java:comp/en v. object should be named within a subcontext of the
naming environment according to the type of the object. For example
EJBs are named within the subcontext java:comp/env/ejbJDBC DataSource references in the subcontext
java:comp/env/jdb c.
-
8/9/2019 M2 J2EE Services
12/59
Naming Services Naming Services
Example code to show naming servicesExample code to show naming services
-
8/9/2019 M2 J2EE Services
13/59
Transactions & JTATransactions & JTA
-
8/9/2019 M2 J2EE Services
14/59
TransactionsTransactions General OverviewGeneral Overview
Ensure data integrityFree an application programmer from dealing with the
complex issues of failure recovery and multi-user programming.
Properties of Transactions ACIDAtomicityConsistencyIsolationDurability
-
8/9/2019 M2 J2EE Services
15/59
J2EE Platform TransactionsJ2EE Platform Transactions
Programmatic TransactionsProgrammatic TransactionsDeclarative TransactionsDeclarative Transactions Burden of implementation is on Container Provider Responsibilities of Server Provider
Interactions between Transaction Manager and JDBC DatabaseTransaction context propagationTwo-phase commit
Support for flat transactions
-
8/9/2019 M2 J2EE Services
16/59
JTA & JTSJTA & JTS
What is JTA?Specifies standard Java interfaces between a
transaction manager and the partiesinvolved in a distributed transaction system Transactional application J2EE server
Transaction Manager
-
8/9/2019 M2 J2EE Services
17/59
JTA & JTSJTA & JTS
What is JTS?What is JTS?Specifies the implementation of a transaction manager thatsupports JTA and implements the Java mapping of the
OMG Object Transaction Service (OTS) specification atthe level below the API.JTS implementation is transparent to J2EE components.Components should never interact directly with JTS. Theyshould use the JTA Us erTran s action interface for transaction demarcation.
-
8/9/2019 M2 J2EE Services
18/59
JTA & JTSJTA & JTS
-
8/9/2019 M2 J2EE Services
19/59
JTA TransactionsJTA Transactions
JTA transactionJTA transaction Managed andManaged andcoordinated by the J2EE platformcoordinated by the J2EE platformSpan multiple components and enterpriseSpan multiple components and enterpriseinformation systemsinformation systemsPropagated automatically betweenPropagated automatically betweencomponents and to EIS accessed bycomponents and to EIS accessed by
componentscomponents
-
8/9/2019 M2 J2EE Services
20/59
JTA TransactionsJTA Transactions
Ways to start a JTA transactionWays to start a JTA transactionBean managed transaction demarcationBean managed transaction demarcation
javax.transaction.UserTransaction javax.transaction.UserTransactionContainer managed transaction demarcationContainer managed transaction demarcation
Started automatically by EJB container based on theStarted automatically by EJB container based on thetransaction attributestransaction attributes
Main BenefitMain BenefitAbility to combine multiple components and enterpriseAbility to combine multiple components and enterpriseinformation system accesses into one single transactioninformation system accesses into one single transactionwith little programming effort.with little programming effort.
-
8/9/2019 M2 J2EE Services
21/59
Transaction Manager ImplementationTransaction Manager Implementation
-
8/9/2019 M2 J2EE Services
22/59
-
8/9/2019 M2 J2EE Services
23/59
J2EE Transactional ModelJ2EE Transactional Model
Transactions in Enterprise Beans
Transaction Attributes
RequiredRequires New
Not SupportedSupports
Mandatory Never
-
8/9/2019 M2 J2EE Services
24/59
J2EE Transactional ModelJ2EE Transactional Model
Transaction Attribute GuidelinesDefault choice RequiredRequires New useful when bean method requiresunconditional commit
NotSupported resource manager responsible for thetransaction is not supported by the J2EE product.Supports Not recommended because of unpredictable
behaviour
-
8/9/2019 M2 J2EE Services
25/59
Container Transaction ServicesContainer Transaction Services
TransactionsTransactions ACID propertyACID property Atomicity Consistency Isolation
Durability
J2EE transactions are flatJ2EE transactions are flatJ2EE platform implicitly handles many transactionJ2EE platform implicitly handles many transactiondetails,details,
Transaction propagation coordinating among multiple transaction managers.
-
8/9/2019 M2 J2EE Services
26/59
Container Transaction ServicesContainer Transaction Services
EJB TransactionsEJB TransactionsBean Managed Transaction DemarcationBean Managed Transaction Demarcation EJB manages all aspects of transaction
Container Managed Transaction DemarcationContainer Managed Transaction Demarcation Container container handles transaction management based on the Application Assemblers deployment instructions
Entity Beans can use only Container ManagedEntity Beans can use only Container Managed
Transaction DemarcationTransaction Demarcation
-
8/9/2019 M2 J2EE Services
27/59
Transactions in EISTransactions in EIS
Components should always access an EIS under the scope of a transaction
JTA TransactionsThe J2EE server is responsible for coordinating and propagatingtransactions between the server and the enterprise information system.
Components can access and perform updates on multiple EISatomically
Resource Manager Local TransactionsTransaction specific to a particular EIS connectionAccess to a transactional EIS will be under a local transaction if noJTA transaction has been initiated.
-
8/9/2019 M2 J2EE Services
28/59
Transactions in EISTransactions in EISCompensating Transactions
Transaction or a group of operations that is used to undo the effect of a previously committed transactions.
updateERPSystem();try {UserTransaction.begin();updateJDBCDatabaseOne();updateJDBCDatabaseTwo();UserTransaction.commit();
}catch (RollbackException ex) {
undoUpdateERPSystem();}}
-
8/9/2019 M2 J2EE Services
29/59
Isolation LevelsIsolation Levels
Defines how concurrent transactions to anenterprise information system are isolated fromone another.The API for managing an isolation level isresource-manager specific.Hence the EJB architecture does not define an APIfor managing isolation level
-
8/9/2019 M2 J2EE Services
30/59
Security Services & JAASSecurity Services & JAAS
-
8/9/2019 M2 J2EE Services
31/59
Security ServicesSecurity Services
Ensure that resources are accessed only byEnsure that resources are accessed only byusers authorized to use them.users authorized to use them.Access control involves two steps:Access control involves two steps: Authentication Authorization
-
8/9/2019 M2 J2EE Services
32/59
Security ServicesSecurity Services
Security MethodologiesSecurity Methodologies D eclarative security Programmatic security
-
8/9/2019 M2 J2EE Services
33/59
Security ServicesSecurity Services
AuthenticationAuthentication entity must establish its identity through authenticatio n. typically does so by providing authentication data entity that can be authenticated is called a principa l. principal can be a user or another program
Types of AuthenticationTypes of Authentication Basic Digest
Form Based Certificate
-
8/9/2019 M2 J2EE Services
34/59
Security ServicesSecurity Services
AuthorizationAuthorization system determines whether the principal is authorized to access
resources based on the security policies
S ecurity roleS ecurity role - - logical grouping of users that islogical grouping of users that isdefined by an Application Component Provider or defined by an Application Component Provider or Application Assembler.Application Assembler.Each security role is mapped by a deployer toEach security role is mapped by a deployer to
principals in the deployment environment. principals in the deployment environment.
Control access to an enterprise beans methods byControl access to an enterprise beans methods byspecifying thespecifying the method method- -permission permission
-
8/9/2019 M2 J2EE Services
35/59
JAAS GoalsJAAS Goals
1.1. Pluggable authenticationPluggable authentication Authentication Mechanism couldAuthentication Mechanism could be plugged into Authentication Frame Work. be plugged into Authentication Frame Work.
2.2. PolicyPolicy--based authentication based authentication can modify your policy file for can modify your policy file for granting permission.granting permission.
3.3. Stackable authenticationStackable authentication Multiple authentication mechanismMultiple authentication mechanismmay be pluggedmay be plugged
Adds value to java platform but is physically separate fromAdds value to java platform but is physically separate fromJava 2 Security Policy.Java 2 Security Policy.
-
8/9/2019 M2 J2EE Services
36/59
How to authenticate?How to authenticate?
Subject and Principals are created after AuthenticationSubject and Principals are created after AuthenticationTo request for Authentication, user has to createTo request for Authentication, user has to create
javax.security.auth.LoginContext Object. javax.security.auth.LoginContext Object.javax.security.auth.LoginContext {public void login();public Subject getSubject();Public void Logout();}
loginContext creates a Subject for Authentication.loginContext creates a Subject for Authentication.User cant create a subject .User cant create a subject .
-
8/9/2019 M2 J2EE Services
37/59
Messaging Services & JMSMessaging Services & JMS
-
8/9/2019 M2 J2EE Services
38/59
MessagingMessaging
Messages are asynchronous requests, reports or Messages are asynchronous requests, reports or events that are consumed by enterpriseevents that are consumed by enterpriseapplicationsapplications
contain vital information needed to coordinatecontain vital information needed to coordinatethese systems.these systems.contain precisely formatted data that describecontain precisely formatted data that describespecific business actions.specific business actions.
-
8/9/2019 M2 J2EE Services
39/59
JMSJMS
Standard API for messagingStandard API for messagingCommon way for Java programs to create, send,Common way for Java programs to create, send,receive and read an enterprise messaging systemsreceive and read an enterprise messaging systems
messages.messages.Asynchronous processingAsynchronous processingTwo messaging modelsTwo messaging models Point to Point Model Publish Subscribe Model
-
8/9/2019 M2 J2EE Services
40/59
Architecture
A JMS Application is composed of:
JMS Clients programs that send and receivemessages.Messages each app defines a set of messagesthat are used to communicate between them.JMS provider the server which brokersmessages
Administered Objects pre-configured JMSobjects created by administrator for the use of clients
-
8/9/2019 M2 J2EE Services
41/59
-
8/9/2019 M2 J2EE Services
42/59
JMSJMS
Publish/Subscribe Messaging ModelPublish/Subscribe Messaging Model
Application Topic
Application
Application
JMS
Publish Subscribe
-
8/9/2019 M2 J2EE Services
43/59
JMS Administered ObjectsJMS Administered Objects
Types of Administered ObjectsConnectionFactory
used to create connectionsDestination
represent the specific destinations the messages are sentto and recvd from. These are placed in a JNDInamespace by the administrator.
-
8/9/2019 M2 J2EE Services
44/59
JMS Concepts(interfaces)JMS Concepts(interfaces)
ConnectionFactoryConnectionFactory used by a client to create aused by a client to create aConnectionConnectionConnectionConnection An active connection to a JMS provider An active connection to a JMS provider DestinationDestination encapsulates the identity of a messageencapsulates the identity of a messagedestinationdestinationSessionSession single threaded context for sending and receivingsingle threaded context for sending and receivingmessagesmessagesMessageProducer MessageProducer object created by a Session that is usedobject created by a Session that is usedfor sending messages to a destinationfor sending messages to a destinationMessageConsumer MessageConsumer object created by a Session that isobject created by a Session that isused for receiving messages sent to a destinationused for receiving messages sent to a destination
-
8/9/2019 M2 J2EE Services
45/59
Developing a JMS clientDeveloping a JMS client
A typical JMS client executes the followingA typical JMS client executes the followingUse JNDI to find a ConnectionFactory objectUse JNDI to find a ConnectionFactory objectUse JNDI to find one or more Destination objectsUse JNDI to find one or more Destination objectsUse the ConnectionFactory to create a JMS Connection with messageUse the ConnectionFactory to create a JMS Connection with messagedelivery inhibiteddelivery inhibitedUse the Connection to create one or more JMS SessionsUse the Connection to create one or more JMS SessionsUse a Session and the Destinations to create the MessageProducers andUse a Session and the Destinations to create the MessageProducers andMessageConsumers neededMessageConsumers neededTell the Connection to start delivery of messagesTell the Connection to start delivery of messages
-
8/9/2019 M2 J2EE Services
46/59
Developing JMS clientDeveloping JMS client
Code exampleCode example
-
8/9/2019 M2 J2EE Services
47/59
Java Connector ArchitectureJava Connector Architecture
-
8/9/2019 M2 J2EE Services
48/59
Java Connector ArchitectureJava Connector Architecture
Defines a standard architecture for connecting theDefines a standard architecture for connecting theJ2EE platform to heterogeneous EISs. (e.g. ERP,J2EE platform to heterogeneous EISs. (e.g. ERP,mainmain--frame transaction processing (TP), andframe transaction processing (TP), and
database systems.)database systems.)Defines a Common Client Interface (CCI) for EISDefines a Common Client Interface (CCI) for EISaccess.access.Enables an EIS vendor to provide a standardEnables an EIS vendor to provide a standard
resource adapter which plugs into an applicationresource adapter which plugs into an applicationserver server
-
8/9/2019 M2 J2EE Services
49/59
ConnectorsConnectors
Database
IBM
ApplicationServer
-
8/9/2019 M2 J2EE Services
50/59
ConnectorsConnectors - - salient featuressalient features
Connectors sit beneath the J2EE platformConnectors sit beneath the J2EE platformDefine a portable service API to plug into existingDefine a portable service API to plug into existingenterprise vendor offeringsenterprise vendor offeringsProvide standard client APIProvide standard client API
-
8/9/2019 M2 J2EE Services
51/59
-
8/9/2019 M2 J2EE Services
52/59
Interoperability & RMIInteroperability & RMI- -IIOPIIOP
-
8/9/2019 M2 J2EE Services
53/59
InteroperabilityInteroperability
RequirementsRequirementsJ2EE applications to connect to legacy systems usingJ2EE applications to connect to legacy systems usingCORBA or lowCORBA or low- -level Socket interfaces.level Socket interfaces.
J2EE applications to connect to other J2EE applicationsJ2EE applications to connect to other J2EE applicationsacross multiple J2EE products, whether from differentacross multiple J2EE products, whether from differentProduct Providers or from the same Provider, and multipleProduct Providers or from the same Provider, and multiple
J2EE platformsJ2EE platforms ..
-
8/9/2019 M2 J2EE Services
54/59
InteroperabilityInteroperability
-
8/9/2019 M2 J2EE Services
55/59
Other ServicesOther ServicesJDBC, JavaMail, JAXPJDBC, JavaMail, JAXP
-
8/9/2019 M2 J2EE Services
56/59
JDBCJDBC
Provides databaseProvides database- -independent connectivityindependent connectivity between the J2EE platform and a wide range of between the J2EE platform and a wide range of tabular data sources.tabular data sources.Perform connection and authentication to aPerform connection and authentication to adatabase server database server Manage transactionsManage transactionsMove SQL statements to a database engine for Move SQL statements to a database engine for
preprocessing and execution preprocessing and executionExecute stored proceduresExecute stored proceduresInspect and modify the results from SelectInspect and modify the results from Selectstatementsstatements
-
8/9/2019 M2 J2EE Services
57/59
JavaMailJavaMail
Allows an application component to sendAllows an application component to sendInternet mail.Internet mail.Has two partsHas two parts an application-level interface used by the application
components to send mail a service provider interface used at the J2EE SPI level.
-
8/9/2019 M2 J2EE Services
58/59
JAXPJAXP
Provides support for the industry standardProvides support for the industry standardSAX and DOM APIs for parsing XMLSAX and DOM APIs for parsing XMLdocuments, as well as support for XSLTdocuments, as well as support for XSLTtransform engines.transform engines.
-
8/9/2019 M2 J2EE Services
59/59