Thursday, November 26, 2009

BAM 11g Buttons disabled?

You log in to BAM 11g
http://localhost:9001/OracleBAM

as weblogic/welcome1 for example and the buttons - are disabled?

Then go to em
http://localhost:7001/em

Right-mouse click on soa-infra
Select Security --> Application Roles
Search for all roles
Check that "Administrators" is a member of the BAM Roles.


Login to BAM again

Wednesday, November 18, 2009

JDev 11g - ADF Mobile on my Blackberry

Pre-requisites
· Access to the SCOTT schema on an Oracle DB

· Blackberry Email/MDS server simulator > BlackBerry_Email_MDS_4.1.4.exe

· Blackberry simulator E.g.
> BlackBerry_Simulators_4.6.1.168_8900-Vodafone.exe
· Both downloadable from http://na.blackberry.com/eng/developers/browserdev/devtoolsdownloads.jsp


Install / Start Blackberry Software
· Install both simulators

· Start MDS emulator
--> Start Programs --> Research in Motion --> Blackberry Email and MDS Services Simulators 4.1.4 --> MDS

This will open a cmd window.

· Start Blackberry 8900 emulator
--> Start --> Programs --> Research in Motion --> Blackberry Smartphone Simulators 4.6.1. --> 4.6.1.168 --> 8900-Vodaphone

This will start up the Simulator.


Create the ADF Mobile App

· Create a new application in JDev 11g --> Fusion Web Application (ADF)
. Enter app name --> Accept defaults on all other screens
Create the data model
--> Right-mouse click on the Model project -->
--> New... ADF Business Components --> ...from Tables


· Create a new DB Connection


· Select Entity Objects


· Select View Objects


· Specify Application Module


Create the UI

· Double-click on faces-config.xml in the ViewContrioller project
--> Drop a JSF page onto the designer


Double-click to create the page
--> Select Render in Mobile Device



Drop EmpView as a Tables --> Trinidad Read only table




Run mobile.jspx



Looks good in IE, but let’s change the project setting so as to avoid having to type such a long URL in the Blackberry.

--> Right-click on ViewController project
----> Project properties --> Java EE Application Change context root to xyz
Re-test in IE

Test in Blackberry

Open browser


Type in the URL
I have installed the MSFT loopback adapter on my machine (ip address = 1.1.1.1) so that is what I use here. e.g. http://1.1.1.1:7101/xyz/faces/mobile.jspx


You can enable JavaScript and create a couple of more interesting pages





Tuesday, November 17, 2009

ADF 11g - Hierarchy Viewer Example with BFile

In this lab I will leverage the ADF Hierarchy Viewer to display data on Countries and Regions in an innovative way.

Pre-Requisites

- 2 DB Tables --> Country, Region

CREATE TABLE COUNTRY
(
COUNTRY VARCHAR2(20 BYTE) NOT NULL,
POPULATION NUMBER(10, 0) NOT NULL,
CAPITAL VARCHAR2(100 BYTE) NOT NULL,
GNP VARCHAR2(20 BYTE) NOT NULL,
BURGER_INDEX NUMBER(3, 2) NOT NULL,
IMAGE BFILE,
COMMENTS VARCHAR2(100 BYTE)
, CONSTRAINT COUNTRY_PK PRIMARY KEY
(
COUNTRY
)
ENABLE
)
TABLESPACE "USERS"
LOGGING
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE
(
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
;

CREATE TABLE REGION
(
REGION VARCHAR2(100 BYTE) NOT NULL,
COUNTRY VARCHAR2(20 BYTE) NOT NULL,
CAPITAL VARCHAR2(100 BYTE) NOT NULL,
IMAGE BFILE,
MOST_SCENIC_SITE VARCHAR2(100 BYTE),
COMMENTS VARCHAR2(255 BYTE)
, CONSTRAINT REGION_PK PRIMARY KEY
(
REGION
)
ENABLE
)
TABLESPACE "USERS"
LOGGING
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE
(
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT
)
;

ALTER TABLE REGION
ADD CONSTRAINT REGION_COUNTRY_FK FOREIGN KEY
(
COUNTRY
)
REFERENCES COUNTRY
(
COUNTRY
)
ON DELETE CASCADE ENABLE
;

Add Some Test Data, I'm using jpgs for Ireland and its 4 regions

– In SQLPLUS -->


Create or replace directory imagedir
AS 'D:\fmw11g\demos\ADF-General\images';
insert into country values (’Ireland’, 4000000, ’Dublin’, 200, 4.5,
bfilename ('IMAGEDIR', 'Ireland.JPG'), ’ Great Place to Live! ’);

insert into region values (’Leinster’, ’Ireland’, ’Dublin’,
bfilename ('IMAGEDIR', 'Leinster.JPG'), ’ Hill of Howth ’,
’ Well worth a visit! ’);

insert into region values (’Ulster’, ’Ireland’, ’Belfast’,
bfilename ('IMAGEDIR', 'Ulster.JPG'), ’ Giants Causeway’,
’ Well worth a visit! ’);

insert into region values (’Munster’, ’Ireland’, ’Cork’,
bfilename ('IMAGEDIR', 'Munster.JPG'), ’ Ring of Kerry ’,
’ Well worth a visit! ’);

insert into region values (’Connaught’, ’Ireland’, ’Galway’,
bfilename ('IMAGEDIR', 'Connaught.JPG'), ’ Connemara’,
’ Well worth a visit! ’);

Check in JDev DB Browser


Create the ADF App

1. Create an ADF app of type – Fusion Web Application (ADF)


1.1. Accept defaults on the next screens.
2. Right-mouse click on the Model project
2.1. New...


2.1.1. Create a new DB connection for scott




2.1.2. Select Entity Objects

2.1.3. Select View Objects


2.1.4. Specify Application Module




3 Add a Servlet to retrieve the BFile Images


3.1. Right-mouse click on the ViewController project and select New...




3.2. add the Servlet code –


package view.servlet;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.*;
import javax.servlet.http.*;
import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
import oracle.jbo.domain.BFileDomain;
import oracle.jbo.domain.BlobDomain;

public class GetImagesServlet extends HttpServlet { private static final String CONTENT_TYPE = "image/jpeg; charset=windows-1252";

public void init(ServletConfig config) throws ServletException {
super.init(config);
}

public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);

/* here we will pass in the country / region as key for image retrieval */
String country = request.getParameter("Country");
String region = request.getParameter("Region");
String where = "";

OutputStream os = response.getOutputStream();

// get a handle to the Application Module
String amDef = "am.AppModule";
String config = "AppModuleLocal";
ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
ViewObject vo = am.findViewObject("CountryView1");
BFileDomain image = new BFileDomain();

// set where clause for country or region and get approp. View
if (country != null){
where = "country = " + "'"+ country +"'";
vo.setWhereClause(where);
vo.executeQuery();
}

if (region != null){
where = "region = " + "'"+ region +"'";
vo = am.findViewObject("RegionView1");
vo.setWhereClause(where);
vo.executeQuery();
}
if(vo.getEstimatedRowCount() != 0){
Row row = vo.first();
image = (BFileDomain)row.getAttribute("Image");
image.openFile();
InputStream is = image.getInputStream();
// copy bfile to output
byte[] buffer = new byte[10 * 1024];
int nread;
while ((nread = is.read(buffer)) != -1)
os.write(buffer, 0, nread);
os.close();

}

vo.setWhereClause(null);
Configuration.releaseRootApplicationModule(am, false);
}
}

4. Create a jsp to display the Country hierarchy
4.1 Double click on faces-config.xml

4.2 Drop a JSF page icon onto the designer --> Rename to hierarchy.jspx



4.3 Double click on hierarchy.jspx to create the page

4.4. Open the Data Controls


4.5 Drop CountryView1 as Hierarchy Viewer...

Radial















4.6. Set the image source to point to the servlet





























Friday, November 6, 2009

Calling Java Classes from SOA Suite 11g

Essentially the same procedure, from a development perspective, as in 10g -
but under the hood we're using the 11g Infrastructure layer.

The Oracle documentation can be found at
http://download.oracle.com/docs/cd/E12839_01/integration.1111/e10224/bp_java.htm#BABCBEJJ


Here's a simple example based on WSDL Java binding, later posts will cover bpel:exec etc. -

1. Create a generic Application/Project in Jdev 11g

1.1. Add 2 classes - Cust & Greeting

Cust -

package cccwsif;

public class Cust {

private String custName1;
private String custName2;
private String custXMASgreeting;


public Cust() {
super();
}

public void setCustName1(String custName1) {
this.custName1 = custName1;
}

public String getCustName1() {
return custName1;
}

public void setCustName2(String custName2) {
this.custName2 = custName2;
}

public String getCustName2() {
return custName2;
}

public void setCustXMASgreeting(String custXMASgreeting) {
this.custXMASgreeting = custXMASgreeting;
}

public String getCustXMASgreeting() {
return custXMASgreeting;
}
}

Greeting -

package cccwsif;

public class Greeting {
public Greeting() {
super();
}

public Cust XMASgreet(Cust c){
String g = "Happy Christmas " + c.getCustName1() + " " +
c.getCustName2();
c.setCustXMASgreeting(g);
return c;
}
}

1.2. expose Greeting as a Web Service
1.2.1. Right-mouse click on Greeting
1.2.2. Then select "Create Web Service..."






1.2.3. Accept defaults for all steps up until step 9.
1.2.4. Additional Classes --> Include "Cust" class




1.2.5. open the wsdl file and set nillable=false




1.2.6. open the GreetingService-java-wsdl-mapping.xml file
1.2.7. check the mapping order

1.3. Add the Java Binding to the WSDL
1.3.1. Open the wsdl in "Design" mode
1.3.2. Click the + by Bindings



1.3.3. Click the Map button
1.3.4. select the Cust class


1.3.5. Amend the Service entry in the WSDL as follows -

1.4. Jar up the project
1.4.1. File --> New --> Deployment Profile --> Jar
1.4.2. Deploy to Jar




2. Create a SOA App in JDev 11g

2.1. Copy the WSDL into the project


2.2. Drop a BPEL service component onto the designer
2.2.1. Set input / output as follows -



2.3. Add a partner Link to the process, pointing to the imported WSDL
2.3.1. Add Assign - Invoke - Assign Activities




2.3.2 Assign input / output vars in the 2 Assigns
2.4. Copy the Jar file from the previous project to the SOA Project sca-inf\lib directory




2.5. Deploy the SOA App

3 Test