Java Cloud Service: Implementing ADFbc Service

Java Cloud Service (JCS) provides a platform to develop and deploy business applications in the cloud. In Fusion Applications Cloud deployments customers do not have the option to deploy custom applications developed with JDeveloper to ensure the integrity and supportability of the hosted application service. Instead the custom applications can be deployed to the JCS and integrated to the Fusion Application Cloud instance.

This series of articles will go through the features of JCS, provide end-to-end examples on how to develop and deploy applications on JCS and how to integrate them with the Fusion Applications instance.

This series of articles cover Java Cloud Service (JCS) features in context of Fusion Applications. In this article we build and deploy a simple ADFbc service to JCS.

Prerequisites

Reader is expected to be familiar with JDeveloper, ADF and JCS. In order to follow the steps the reader will also need to have:

  • JDeveloper contains Cloud specific features related to e.g. connection and deployment. To use these features download the JDeveloper from JDeveloper download site by clicking the “Download JDeveloper 11.1.1.7.1 for ADF deployment on Oracle Cloud” link, this version of JDeveloper will have the JCS integration features that will be used in this article. For versions that do not include the Cloud integration features the Oracle Java Cloud Service SDK or the JCS Java Console can be used for deployment. For details on installing and configuring the JDeveloper refer to the installation guide. For details on SDK refer to Using the Command-Line Interface to Monitor Oracle Java Cloud Service and Using the Command-Line Interface to Manage Oracle Java Cloud Service
  • Understanding of basic concepts of ADFbc services, for details refer to the Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework
  • Access to a JCS instance to which to deploy the service. In this document I am using a trial instance, details of the JCS instance such as the name of the data source may vary between JCS instances and the reader is expected to reflect the details of their environment on the configuration. For further details refer to Starting Trial and Paid Services.
  • Access to a local database. The database associated with the JCS instance cannot be connected to with JDBC. Since creating ADFbc business component requires a JDBC connection we will need access to a local database.

Implementation

The implementation is based on a simplest possible ADFbc service that returns a "Hello World!" string when invoked. Purpose is to keep the focus of the document in configuration, packaging and deployment of the service not the functionality of the service.

Application

First we create a new application, choose "File -> New -> General : Applications :Generic Application" and on the first screen of the wizard enter the name of the application. The value used as the name has no impact on the configuration / packaging of the application so any name can be used, in this case I used "JCSWsDemo". Also enter the "Application Package Prefix", this will be used when code artifact are created in the application as the base path, the value can be anything you want in my case I used "oracle.demo.ws":

Click next and on the next screen enter a name for the project to be included. Again the name of the project has no impact on the configuration / packaging of the application so any name can be used, in this case I used "Service". In order to create the ADFbc service we will need the "ADF Business Components" so select the technology to be included in the project. Note that selecting "ADF Business Components" also automatically select "Java" to be included in the project:

Click next and on the next screen enter the "Default package" this will be used when code artifact are created in the project as the base path, the value can be anything you want in my case I used "oracle.demo.ws":

Click Finish to complete the creation of the Application and the "ADF Business Components" project to used for the application.

ADFbc Service

Next we will create a simple ADFbc Service; choose "File -> New -> Business Tier : ADF Business Components : Application Module". You will be presented with "Initialize Business Components Project" screen to provide connection to the database. Even though we will not create anything based on data model, the connection is required to create the ADFbc components. Also the connection needs to be a JDBC connection so we cannot use the JCS database rather we need a local database connection. Click the green "+" icon and enter the details of your local database as needed:

Click "Ok" and on the next screen enter name for the application, the name has no impact on the configuration / packaging of the application so any name can be used, in this case I used "TestServiceAM":

Click next until step 4 and check the "Generate Application Module Class" check box. This will generate a Java class for the Application Module allowing us to create a custom method that we can expose as a service:

Next we create the custom method that we expose with the service, open the Java class generated for the AM in this example "TestServiceAMImpl":

In the java file editor enter our custom method:

public String sayHello() {

return "Hello World";

}

Next navigate to the "Web Service" tab on the AM definition:

Click the green "+" icon to generate a service interface for our AM. On the first step define the "Web Service Name", the value entered here will be part of the URL for the Endpoint so make note of the value used. In our case I used "TestService", leave other values as defaulted:

Click next until step 3 and select our custom method to be exposed on the service, leave other values as defaulted:

Click Finish and we are done creating our service.

Package the application

In order to deploy the ADFbc service we need to create deployment profiles to package the application.

First we create the deployment profile for the project. Select the "Service" project and choose "Application -> Project Properties : Deployment : New". Select "Business Component Service Interface" as the "Archive Type" and the name of the deployment profile. The value used as the name has no impact on the configuration / packaging of the application so any name can be used, in this case I used "ServiceProfile":

Next we will create the deployment profile for the application. Choose "Application -> Application Properties : Deployment : New". Select "EAR file" as the "Archive Type" and the name of the deployment profile. The value used as the name will be displayed as the application name when deployed to JCS in this case I used "ServiceEARProfile":

On the newly created "ServiceEARProfile" navigate to "Application Assembly" and choose the "MiddleTier" Java EE Module to be included:

Service Configuration

When the service was created it was created based on a local database connection. JCS does not allow JDBC connections so we will need to configure the AM to use a data source. The name of the data source can be obtained from the JCS Java console in my case the name is ”database”:


To configure the AM navigate to the Configuration tab on the AM, choose the "TestService" configuration and click Edit icon:


On the "Edit Business Components Configuration" change the "Connection Type" to "JDBC DataSource" and "Datasource name" to match the data source obtained from the JCS Java Console, in my trial instance the name is "database":

Project Configuration

On the project we can configure how the Endpoint URL will look like, these steps are not mandatory, however they make the URL to be used shorter than the defaulted value. Select the "Service" project and choose "Application -> Project Properties : Java EE Application". The "Java EE Web Application Name" controls the name of the application, the "Java EE Web Context Root" controls the the path to the service Endpoint. Make note of the values used here, we will need them when constructing the URL to test the service, I have used value "JCSWsDemo" for both:

Deployment

Now we are ready to deploy the service. In this example we are using the Jdeveloper integration to deploy to JCS. Alternatively you could use the Cloud SDK or deploy the EAR file directly using the Java Console in the Cloud. In order to use the JDeveloper integration we first need to create a application server connection to the JCS instance.For details on how to create the connection to JCS instance refer to section "Creating a Connection to the Oracle Java Cloud Instance" in Deploying ADF Applications to Oracle Cloud by Using JDeveloper, Part 2. Once the connection is created we can deploy the application by navigating "Application -> Deploy -> ServiceEARProfile". Select "Deploy to Application Server" and the Application Server connection created previously for JCS.The end of the deployment log displayed in JDeveloper should look something like this:

[03:39:57 AM] Deploying Application...
[03:40:35 AM] Oracle Cloud Job ID: 34655
[03:40:35 AM] Oracle Cloud Deploy Job Log: /tmp/cloud-3100530780986722950.log
[03:40:35 AM] Oracle Cloud Return status : COMPLETE
[03:40:35 AM] Application Deployed Successfully.
[03:40:35 AM] Application url(s):
[03:40:35 AM] https://server.em1.oraclecloudapps.com/JCSWsDemo
[03:40:35 AM] Elapsed time for deployment:  1 minute, 8 seconds
[03:40:35 AM] ----  Deployment finished.  ----

Make note of the URL included in this case "https://server.em1.oraclecloudapps.com/JCSWsDemo" where the "JCSWsDemo" matches the value we set in the project properties for "Java EE Web Context Root".

Once deployed we can navigate to the Java Console and the application should be active and status green:

The URL displayed in the deployment log can also be accessed by clicking the "Test Application" link:

Testing

Once deployed we can use the URL provided by the deployment log (also visible in the Java Console) to test the service. Take the value of the "Web Service Name" defined on the AM service interface, in this example we used "TestService" and append it to the end of the URL, so in our case it becomes:

https://server.em1.oraclecloudapps.com/JCSWsDemo/TestService

Use a browser to navigate to the service and you should be presented with:

Click the "invoke" and you should see the string "Hello World" in the results:

Summary

In this article we covered an example how to create, configure, package and deploy ADFbc service to the JCS.


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Follow us on twitter Fusion Applications Extensibility, Customizations and Integration forum Fusion Applications Dev Relations YouTube Channel
This blog offers news, tips and information for developers building extensions, customizations and integrations for Oracle Fusion Applications.

Search

Categories
Archives
« July 2015
SunMonTueWedThuFriSat
   
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Today