Tuesday, September 4, 2012

OPSS security registration via REST

I had been playing around with an ADF application developed by the Fusion Middleware Architecture Group called ezShare. This worked great with the integrated LDAP provided by JDeveloper. But what I wanted to do was see if we could leverage OpenLDAP and configure it to possibly use in our future implementations.

We recently installed an openLDAP to test out a prototype we were working on. I was able to leverage the ldapDC (LDAP DataControl) provided in the ezShare sample application (referenced below).

ezShare Application Reference (OPSS Sample Application):

Since the application had some pre-built OPSS service calls I decided to write a REST service wrapper so that I could invoke the “createUserProfile()” method already built for me. I took the ldapDC project and put it in my ADF application. I modified it to include a new group (which is defined in my openLDAP) “homeowner.”

Once I was finished with that I created a simple java class called “registerUser.” I exposed it as a service by including the @Path(“registeruser”) above the class name. I then added a new method called “postRegister” which was exposed as an @POST method which @Produces (“text/plain”). I could have easily used application/json or another mime type. But I just wanted to output the results of the service call.

I have a simple HTML form that posts the REST parameters via:
 
Once it’s invoked you should see a success message. If you are interested in the prototype application you’ll need to make sure you have an LDAP environment set up and your LDAPAuthenticator configured in your security realm of your weblogic instance. Post your comments and questions here and I’ll be happy to help you.

Code


Tuesday, August 28, 2012

To Extend or Not To Extend Base Classes?

This is one of many follow-up to my previous post: Planning an Enterprise Scale ADF Implementation?

Should you extend your base classes in your BC Model project? It's up to you if you think you'll need to. Do you think you'll need to change a built-in feature to behave differently or to add a new feature? Do they need to be used by all of your applications? To do so requires that you do it prior to generating any business components in your project. The most common components extended are:
  • Entity Definition
  • View Object
  • View Row
  • Application Module
  • Database Transaction Factory
  • Database Transaction
By extending these classes you can override logging methods to provide your own unique logging to your applications. Or you can override transactional methods like the doDML() methods handling the transactional commit operation.
 If you think you will use shared business components then you need to use generic extended interfaces. I would go ahead and set these up and get use to using the extended classes. It will give you a way to provide a common interface to all your business components. Any exposed custom method in any of your generic extended base classes can be used in any other business component class in the application.

So there are a lot of benefits to using extended base classes. It's just up to you and your development team to use it the right way.

Monday, August 27, 2012

Planning an Enterprise Scale ADF Implementation?

There are tons of resources out there that follow the same standard MVC architecture by using the "Fusion Middleware Application" template provided by JDeveloper 11.x. But is this sufficient for a large scale enterprise application or portal? No ... I don't think so. I highly recommend that you structure the overall project by using workspaces, projects, and libraries. By organizing application specific artifacts (BC Model, taskflows, templates, java utilities, project properties) into shared libraries will increase productivity amongst your team and provide the modularity your project needs to be successful today and in the future when you start enhancing the applications with new developers rolling on.

I typically structure my applications to use a SharedBC and SharedViewController project. I create a deployment profile for each and deploy them on a network shared folder as an "ADF Library JAR File."

Now any developer can create a "File System" resource in their Resource Palette.

After that you should be able to see your deployed libraries when you expand the resource.

If you want you could also set the dependency on the shared VC from the build output of the shared BC and deploy just one ADF Shared Lib. So it just depends on how you modular you want your components to be. Now the shared code is packaged and ready to be consumed by other applications in your enterprise. This will allow your development team to be more productive and allow them to only change code in fewer places. I suggest you start on a small scale to make sure everyone understands the capabilities and the benefits of this before things get a little hairy. I would put together a few POCs using this method and do a write up explaining why and how to use this.

In future posts I'll go into setting up extended base classes in your model application, ADF logging, controller utility examples, binding examples, and some tips and tricks in Skinning/Templating.

Wednesday, July 25, 2012

Mixing ADF with HTML5/JQuery/REST?

In my previous posts I showed you how to develop a simple JSON REST api and incorporate it with a standard HTML5/JQuery mobile application. All of this was accomplished with JDeveloper.

What it didn't include was ADF Faces ...

Why not? Well ... As of today ADF Mobile uses a framework that "extends" Oracle's ADF framework. So why didn't I show you this instead? Well, I didn't really like how the mobile framework handled my mobile sites I designed. It was still a bit clunky and didn't really flow well. So I looked into developing my mobile applications using JQuery and HTML5.

In order to handle my database interactions I turned to REST. With the latest version of Jdeveloper 11g R2 it has expanded it's capability to include REST services (libraries) into it's development framework.

So I turned to 11.1.2.1(or 2) to build my simple REST services. I was still able to successfully deploy them to my 10.3.5 (production needs a patchset I believe). But I still developed my mobile app in 11.1.1.5. I only needed JDeveloper really to just deploy the application so it would run on the same domain (JSON is not cross-domain compatible without JSONP).

Now ... I recently received a comment asking when I was going to develop this mobile application using ADF Faces. Well ... I hadn't planned on it. I was just going to show you that the same REST services could be used like any other business service (web service, WSDL, Etc.) in your ADF application for re-usability purposes.

I did however look into seeing if I could combine the functionality of ADF Faces with HTML5/JQuery/REST. Even migrating my application over from 11.1.1.5 to 11.1.2.2 and leveraging the new feature of "Pretty URLS" making REST calls from a .jsf or .jspx didn't function properly.
It still did not function properly ... I think I'm going to just chalk this one up to AJAX/JS code interfering (wrapped) with my JQuery mobile code.

Brian Huff has a nice presentation discussing the Next-Generation Oracle Mobile Applications

For now I will build my mobile applications using standard HTML5/JQuery/REST services. I hope when PS6 is released it will then make it a little easier to port my code over to the ADF Mobile PS6 framework. We'll just have to wait and see ...

I welcome any comments or suggestions you might have. I'm still learning as well ...

Wednesday, June 27, 2012

Part II: Mobile Application with REST services

Application Download: https://www.dropbox.com/s/7d0k9cqhf2sqhoj/MobileApp.zip 


Use Case Scenario

This is part II of the “Verify User – JSON REST API” we created and previously deployed. This is just a simple HTML5 jQuery mobile application wrapped as a standard J2EE application and deployed onto the same server as the REST service.

It is a simple login page that invokes the REST service to determine whether the user is authenticated or not. It doesn’t encrypt/decrypt the password. It’s just to demonstrate that you can leverage these REST services in any type of application. We could easily use this same REST service in our ADF portal application or a standard portlet. It doesn’t matter …

In this application you can enter any user in the HR schema Employees table with the password “welcome1” and it will authenticate. In this demonstration we’ll use SKING (mixed case works fine). If authentication fails it takes them to an ERROR dialog page (still inside the same page). If it passes the user is taken to a private page “welcome.jsp” (This is not really protected).

If you’ve kept up with ADF Mobile the next release (PS6) is supposed to support a better HTML5, JQuery, PhoneGap, etc. etc. to provide a quicker template solution for mobile development within the ADF techstack.

Part II: The Mobile App

I started out by creating a “Generic Application” and a “Generic Project” with Java, JSP and Servlet technology added to it.



I created a couple of standard JSP pages:
  • Login.jsp
    • I’m using a standard HTML5 JQuery Mobile template layout to leverage multiple display sections in a single page. If you look through the code you’ll notice:
      • Main Content
        • This is my main page displayed to the user and has the username, password, and submission button.
      • Content Dialog
        • This is the dialog section that notifies the user that there was an issue with their login. Once they return to the main content the fields that are required are highlighted.
      • Content Error Dialog
        • This is the dialog section that notifies the user that there was an issue with their login. If the user is not found they must enter the username/password again.
      • Content Transition
        • If your REST service takes a while (this shouldn’t) this portion of the content will display with an animated gif to show the user the transaction is in progress.
  • /priv/welcome.jsp
    • This is a standard page that lets the user know that the login was successful and they can log out if they wish to do so.
Below is a screenshot of the application layout.


Once you deploy the application you should be able to run it using the URL below:

http://localhost:7101/MobileApp/login.jsp

Tuesday, June 26, 2012

Part I: Verify User – JSON REST API

Untitled Document
Application Download: https://www.dropbox.com/s/s7csgy8svcij3aj/VerifyUserJson.zip

Use Case Scenario

I wanted to be able to invoke a REST service from an application (regardless of it being ADF Mobile, ADF portal, BPEL, or a standard HTML5 JQuery Mobile app). So I built the sample application (using JDev 11.1.2.1) as a JSON REST app using JAX-RS Jersey and standard J2EE. This was deployed to my standalone WebLogic 10.3.5 server. I created a standard J2EE mobile application (using JDev 11.1.1.5 … coming in PART II) to invoke and consume the REST service. Both were deployed to the same server so they could leverage the same domain name. I will discuss more about why they need to be on the same domain (in PART II when we build the mobile app).

Part I: VerifyUserJson App

In JDev 11.1.2.1 they’ve built in support for REST Web Services projects. So we’ll go ahead and use this version of JDEV. We’re still able to package and deploy the application on a standard 10.3.5 instance of WebLogic because we include the .jar libs in our WEB-INF/lib folder (included in the sample app).


After that I created three Java classes (LoginRequest, LoginRequestHandler, and DataHandler).
  • LoginRequest()
    • This java class has the main verifyLogin method which accepts a username and password as input parameters. It returns either true or false back to the calling method.
  • LoginRequestHandler()
    • This is method invokes the LoginRequest method and returns the response as plain/text. You can also return application/xml or application/json depending on how you want to display it in your application. I also used the GET HTTP method to retrieve the “stuff” from the resource.
  • DataHandler()
    • Method to get the connection to the ORACLE XE database for the HR Schema. You can change this to point to any database that has the HR SCHEMA.
We need to modify the web.xml file to include the JERSEY servlet and servlet mapping.We open the web.xml and add these lines of codes before the closing </web-app>

1:   <servlet>  
2:    <servlet-name>jersey</servlet-name>  
3:    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>  
4:    <load-on-startup>1</load-on-startup>  
5:   </servlet>  
6:   <servlet-mapping>  
7:    <servlet-name>jersey</servlet-name>  
8:    <url-pattern>/jersey/*</url-pattern>  
9:   </servlet-mapping>  

I added these .jar libs to my WEB-INF/lib folder so that I don’t have to worry about matching any of the versions on the application server. Here is a list of the libs in the screenshot below. They are also attached to the code in this blog post. Your application structure should look similar to this: You can test the LoginRequest by running it locally in your JDev (main method) before you deploy it to your
 WebLogic server.



After I deploy the application to server we can test it by invoking this URL with the appropriate parameters.

1:  http://localhost:7101/VerifyUserJsonApp/jersey/verifyUser?p_username=SKING&p_password=welcome1  

If you have any suggestions or comments please let me know.

Monday, June 25, 2012

Oracle EMG Samples

If you've been looking for a collaboration of all of the undocumented samples in one place here is the place to go:

http://java.net/projects/smuenchadf/pages/ADFSamples#Categories

This was tweeted earlier by Frank Nimphius.

Be sure to bookmark it and re-tweet! You can follow me @ADFDeveloper !

Welcome to my Oracle ADF/Fusion Middleware Blog

I've been working with Oracle technologies for 7 years now. I started out learning Oracle database tables, pl/sql, reporting, etc. I moved into the Portal (OracleAS 10g Portal) early in my career building custom applications with PL/SQL portlets. Since my main IT background was in web development, portal development came natural to me. I was able to create nice looking portal applications that looked nothing like the standard Oracle blue and beige colors that most were use to.

I went into consulting shortly after that to expand my skill-set and knowledge of the up-and-coming Fusion Middleware that Oracle was releasing. During my consulting days my knowledge of Java expanded and I was exposed to JSR-168 portlet development, ADF 10g, and mobile development. After dabbling in ADF for a while I knew that was the technology I wanted to gain exposure to so I joined Keste, LLC. Keste specialized in Fusion Middleware Architecture. My first project was SunGard. It was one of the first implementations of the expanded Fusion Middleware tech-stack.

I worked with a team that built a complete custom ADF 11g portal that was integrated with OAM, OIM, UCM (content), and a third party SalesForce.com application. We were able to deliver the application within 4 months. It was a pretty successful project and I gained a ton of knowledge working on it.

After that I was working on a 10g ADF portal migration to ADF 11g PS2 portal for WindRiver. This was a daunting task to say the least. It was a portal built on the spring framework with EJBs. After the migration was completed we were tasked to build a completely custom portal application that would replace Oracle iSupport and Oracle Tele-Service by combining a lot of the features a in a clean ADF rich UI interface. This project used ADF BC for the model implementation with the integration interfaces coming from PL/SQL packages wrapped and exposed as web services.

After these successful launches I was recruited by an old boss to come and work at his new company to help implement a fusion middleware architecture to replace their point-to-point integrations. I will be posting some of the proof-of-concepts that I've built in hopes to help others in the webcenter / adf / mobile development field.

... More to come soon!