Thursday, November 26, 2009
BAM 11g Buttons disabled?
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
· Access to the SCOTT schema on an Oracle DB
· Both downloadable from http://na.blackberry.com/eng/developers/browserdev/devtoolsdownloads.jsp
· Install both simulators
· Create a new application in JDev 11g --> Fusion Web Application (ADF)
Open browser
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 Objects3 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...
Radial4.6. Set the image source to point to the servlet
Friday, November 6, 2009
Calling Java Classes from SOA Suite 11g
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