Skip to main content

How to use Global Transactions and Data Sources with Spring Framework 2.0.8 in J2EE Applications, Part 2

In the previous part (1st), we saw how to configure SAP JTA Transaction into the Spring Context, now we are going to review the SAP J2EE Datasources.

We need to review two parts:

1. Configuration of the JEE datasources in the data-sources.xml file (in according to the SAP AS Platform).

In the next picture, you can see the last file that I used in my project

data-sources.xml

In this image you can see the definition of the Driver JDBC (2nd box), it needs to be set-up in the Visual Administrator. After, you see the sql-engine tag, it allows us to define the SQL type support (help). The valid values are (link):

  • Open_SQL: the system returns a DBI CommonConnection
  • Native_SQL: the system returns a DBI DirectConnection
  • Vendor_SQL: the system returns a standard connection from JDBC driver (not using DBI at all)

In this case, I have used the value of Vendor_SQL because I have used iBatis in my persistence layer and not the persistence engines of SAP NW AS (jdo or entity beans).

Finally, you need to define the connection parameters as user, password, driver class name, and url parameters.

2. The configuration of Spring Application context.

In the first picture (in the 1st box on the picture), you can see the name of the datasource, we will use this name in the spring application contexte file, with the standard prefix "jdbc/" how the following picture shows

spring application context  file

We need to create 2 beans to able the j2ee datasources in our development. The first bean is named "serviceLocator" and the 2nd the bean dataSource.

The bean serviceLocator is a bean factory to the dataSource bean, where the factory method "getDataSource" is defined in the class implementation of the bean serviceLocator.The implementation of this bean complais with the singleton pattern and in the bean definition also its scope is singleton. You could use obly the scope spring definition of the beans.

You ask yourself why you don't use "org.springframework.jndi.JndiObjectFactoryBean" or tag.



Well, I have tried them, but I didn't have success.

Finally, the name of the j2ee datasource is defined as parameter constructor for the dataSource bean.

Here the related source files.

Comments

Popular posts from this blog

How to .. Integration Non-SAP J2EE-based Web Applications into SAP Portal with SSO Part 2

After we have configured our portal object, we must install the gateway application and modified the target application. 1. Deployment of the Gateway Web J2EE Application : We must to create an j2ee web application with the purpose to be a gateway from every application that want to validate the SAP Ticket Logon. I have created this application because of the problem with the sapssoext library provied from SAP, it can't be loaded from more than one classloader, then this new web application will be the unque application on the server that can load this library. This application could expose 2 or more services, it depends of you. I will mention 2 services: /SsoGatewayWeb/ssojson.dtx : under this URI will happen the vaidation of the SAP Ticket Logon sent by the SAP Portal, it returns a JSON string with the information retrieved from the ticket. /SsoGatewayWeb/sendsso2cookietest : this URI generates HTML content, it generates the string ACL of the certificate file. Both only acc...

How to .. Integration Non-SAP J2EE-based Web Applications into SAP Portal with SSO Part 1

We are going to integrate Non-SAP J2EE-based Web Applications into the SAP Portal with Application Integrator and SSO. In this part, I will discuss the overall of these posts and configure the iView with Application Integrator Overview of Integration. To perform this integration must take into account the following steps: Deployment of the portal application for the creation of the system portal object Create and set the type of Application Integrator iView that will contain the applications to integrate. Installing SAPSSOEXT and SAPSECU libraries Deployment of the application gateway called SsoGatewayWeb Changing the target application. This integration has the following restrictions: It applies only for web applications based on J2EE Servlet. Depend exclusively on the sucessful load of the libraries supported by SAP (sapssoext and sapsecu) in both Windows and UNIX environments. The target application must have created a profile for the user id logged to the SAP portal, this sh...

WebDynpro for Java: Tutorial of the Basic Usage of RoadMap Component

We will create a local Development component project of the type Web Dynpro as follow Our project will contain only 3 views with the purpose of show the basic usage of the roadMap object. After, we create our component controller RoadMap and the RoadMapView view as follow Now, we will create the 2 views more, the previous one will contain only the RoadMap Object (RoadMapView) used in all the project, the other ones show the flow between screens. Here the list of the 3 views: RoadMapView,  InitView, and ConfirmView. Now, we will add the component RoadMap object (it is on the Standar Complex Group) to the RoadMapView view, but first delete the default object added to the view, after we will need to add two steps (it could be more, depends of your logic) to our roadmap object. In order to do that we will use the Outline view of the NWDS. We add the two steps as follow The type steps to add at the RoadMap object will be ot the "RoadMapStep" type. The name of the steps are: Init...