ADF Business components: creating a basic Fusion webapp (FMW)

After explore diferent ways, trying to cover the business layer with Spring/Eclipse and after that with EJB 3. If you want to develop with Oracle ADF framework, our best choice is ADFbc (business components). The reason, simple, it is better integrated with top layers (data controls and view) than EJB, this is the reference solution of the company (Oracle).

Read the rest of this entry »

JAX-WS: WS client generating with SoapUI

We will create the needed classes to generate a Web Service client from its WSDL.

We will base in the HelloWorld project, and here will add the security. In this project we response with a Hello for the name which sent as argument through the Web Service.

Read the rest of this entry »

JAX-WS Handler Chain: messages interceptor

We want to intercept the WS input and output. In order to:

  • Logging any part in the message
  • Registering sent messages
  • Add security controls
  • ….

Here we are going to do a input/output WS example log.

We annotate the WS with Handler Chain descriptor:

@WebService
@HandlerChain(file="src/META-INF/handlerChain.xml")
public class Hello {
@WebMethod
    public String sayHello(String name) {
        return "Hello, "+name+".";
    }
}

It will have the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">  
   <handler-chain>  
      <handler>  
         <handler-class>lebrijo.handlers.WSHandler</handler-class>  
      </handler>  
   </handler-chain>  
</handler-chains>

WSHandler class will implements the SOAPHandler interface:

public class WSHandler implements SOAPHandler<SOAPMessageContext> {  
 
     public Set<QName> getHeaders() {  
         return null;  
     }  
 
     public boolean handleFault(SOAPMessageContext context) {  
         logToSystemOut(context);  
         return true;  
     }  
 
     public boolean handleMessage(SOAPMessageContext context) {  
         logToSystemOut(context);  
         return true;  
     }  
 
     private void logToSystemOut(SOAPMessageContext smc) {  
         Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);  
 
         if (outboundProperty.booleanValue()) {  
             System.out.println("Outgoing message:");  
         } else {  
             System.out.println("Incoming message:");  
         }  
 
         SOAPMessage message = smc.getMessage();  
         try {  
             message.writeTo(System.out);  
         } catch (Exception e) {  
             System.out.println("Exception in handler: " + e);  
         }  
     }
 
	public void close(MessageContext context) {
		// TODO Auto-generated method stub
 
	}

ADF View: Master/Detail editable with LOVs, and Excel exporting option

Based on an earlier post where show how to make a master detail page, today we will add a box where we will be able to modify the aployee data.

It is useful too to know how to make List of Values (combos) with this technology, and see an example of how to export the detail table to Excel.

Example application in HRApplication.zip.

Read the rest of this entry »

Browsing Form, Master/Detail

In administrative environments we find with the requirement of a master/detail form. For example to browse the employee in a certain department, or the clients who bought each one of our products.

Based on the Human Resources Oracle application we will make a master/detail to navigate over the company departments.

Example application in HRApplication.zip.

Read the rest of this entry »

Creating a basic JSF View: Hello World!!

In a previous project we saw how to create a Weblogic basic web project. Based on this we will create a very basic view with JSF.

JSF has some advantages:

  • Clean Cross browsing: we can forget styles and javascript, and navigator sigularities.
  • Encapsulates the view components
  • It is XML, then is text, then is always editable.
  • Standards based = XHTML + JavaScript + JSP + Java (JEE5+)
  • Some libraries (oracle-ADF, richfaces, icefaces) allow Rich Inernet Applications development.

Read the rest of this entry »

Design: ADF Templates and skins

Usually, in all our web projects, we want all the pages have a coherent style in ehole site, to improve the usuability. The usual strategy is fix the header (with the login for example), a menu in the top or both sides, and a footer.

  • And all this parts are included in all our pages with no repeat the code.
  • Every change in the template will show in whole site.
  • And, if is possible, our WYSIWYG editor shows me the design (it is not possible with Eclipse for the moment).

Read the rest of this entry »

JDeveloper Data Controls

Data Controls are objects which acts as an intermediate layer between the view layer and business layer on JDeveloper Architecture. These takes a consistent way to manipulate data collection to show at the view in programming time. They maps the model, and business services, binding, and managing the data transactionality, keeping the view coherent.

Read the rest of this entry »

EJB 3.0: Business Layer

In this phase we will see how JDeveloper solves the business layer. EJB 3.0 is the standard to solve it. This is about to construct the business process, which will be called by the view, web services, …

We will base on a past post, where we 聽created the persistence layer for our little application.

Read the rest of this entry »

JPA: persistence model

In this post we will create a persistence model for our little employee management application. Based on an earlier post where we created a basic JDeveloper Web application.

Over the project with contextual menu, New > EJB > Entities From Tables. We will use the EJB 3.0 technology, annotating entity beans as JPA 2.0:

Creating persistence model

Select Departaments and Employees tables.

As seen in an earlier post, we can obtain the ER diagram from a made data base. I created it in the package lebrijo.diagrams:

Entity-RelationShip diagram

We can create a New > EJB Diagram, and drag-drop the created entities, we have the whole draw:

EJB diagram

I refactored the employees attribute by manager, because it defines the relationship better.

Refactoring manage relation

This is refreshed automatically to the EJB diagram (theory, in practice I have to drag the entities again).

As last exercise, we can create the ‘find by name’ query, in the query annotation at Employees entity:

@Entity
@NamedQueries({
@NamedQuery(name = "Employees.findAll", query = "select o from Employees o")
,
@NamedQuery(name = "Employees.findByName", query = "select o from Employees o where o.firstName like :p_name")
})

Securing Weblogic with SQLAuthenticator provider

In a previous article we saw how to secure a Web Service with basic authentication (this could be used for every page in our application). We did it creating users with Weblogic Default Authenticator.

Today we will create an SQLAuthenticator in Weblogic, then the server will take users and groups from the data base.

Read the rest of this entry »

Weblogic / JDeveloper: Creating the base application

Open JDeveloper with “Default role” option, to activare al environment features. We are interested in JEE and database development features.

File > New > Java EE Web Application, then we are creating the new application estructure:

Creating app

Put the name “HRApplication”, and it creates two projects on the app:

  • ViewController: contains the view of our application, which corresponds with ADF technology based on JSF standard.
  • Model: contains EJB session beand and JPA entities.

To create a database connection go to the “Database Navigator” tab, and with right buton> New, introduce the connection configuration:

Creating db connection

Drag and drop the connection to our application:

Adding HR connection to our application

Then we are ready to start modeling and programming.

JDeveloper Architecture with Weblogic

Seems obvious that the best tool to develop Weblogic/OracleDB is JDeveloper. But for me, until now, it was not so obvious, because Eclipse is my favorite IDE, it is the standard for Java development (Jboss, Spring, Android,…).

If your architecture is Oracle/Weblogic, have no fear to change, and your obsesion is to increase your productivity, then, your tool is JDeveloper. I am gonna write some posts trying to demonstrate this point. But if you want an advancement, you can see this video, you will see howcan be really ssimple make RIA applications over complex enterprise environments.

Read the rest of this entry »

JAX-WS: Container level security on Weblogic

In this post we are going to see how to secure a Web Service with basic HTTP Auth, in weblogic. We will base in a previous project where we created a very basic WS: Hello World.

In the Security Realm > MyRealm we have to create:

  • An user: user/12345678
  • A group: TutorialUser
  • Add the user to the group

In the Weblogic console as we see on the picture:

Managing users and groups

In web.xml we have to add the security confs needed (path, basic type,….):

   <!--
    SECURITY
    -->
    <security-constraint>
        <display-name>Regla01</display-name>
        <web-resource-collection>
            <web-resource-name>WSPOST</web-resource-name>
            <description>
            <url-pattern>/*</url-pattern>
            <http-method>POST</http-method>
        </description>
        <auth-constraint>
            <description>
            <role-name>TutorialUser</role-name>
        </description>
    </auth-constraint>
    <session-config>
        <session-timeout>5</session-timeout>
    </session-config>
    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>myrealm</realm-name>
    </login-config>
    <security-role>
        <description>
        <role-name>TutorialUser</role-name>
    </description>
</security-role>
</web-resource-collection>
</security-constraint>

In weblogic.xml map the application role with server role (it is mandatory):

    <wls:security-role-assignment>
        <wls:role-name>TutorialUser</wls:role-name>
        <wls:principal-name>TutorialUser</wls:principal-name>
    </wls:security-role-assignment>

We can test with SoapUI creating a new WS project, with WSDL address (http://localhost:7001/wsc/HelloService?WSDL) and previous Weblogic credentials created:

SoapUI Test

JAX-WS: Serving Web Services SOAP

Today we will create a SOAP Web Service, based on LebrijoSchool project which we were making in early weeks over Oracle-Weblogic Architechture.

First of all is to add the Web Services facet. Right button > Properties … :

Add WS facet

After, we will create the class from a Spring Service class. Right button > New > WebLogic Web Service for Spring Beans:

Expose Spring as a WS

Choose the Service, and the methods that we want to publish as Web Service.

Finally put it in the logical package: lebrijo.school.webservices. And name it as “SchoolCertificatesWS”.

This is the code:

	@Autowired
	@Qualifier("RegistryService")
	private IRegistryService springServ;
 
	@WebMethod
	public Registry findRegistryById(java.lang.String id) throws Exception {
		return springServ.findRegistryById( id );
	}

We have a Weblogic client to test the WS, we can acces thru the URL http://localhost:7001/wls_utc/.

JAX-WS: Hello World!!

Today we are going to see ho to create a WS which says Hello over Weblogic, with its IDE Eclipse OEPE.
We will create a New project > Web Service Project:

Create project

We created teh following class:

package services;import javax.jws.*;
@WebService
public class Hello {
@WebMethod
    public String sayHello(String name) {
        return "Hello, "+name+".";
    }
}

With these annotations we can serve the WS, and with right button on the classes and Run as > Run on Server. It launches the test WS application in the navigator:

WS Test

To access to WSDL: http://localhost:7001/wsc/HelloService?WSDL
To test every WSDL published: http://localhost:7001/wls_utc/begin.do

Begining with app engine

Here we are going to see how to install GAE plug-in in Eclipse, and to make and deploy my first basic application, in order to see how to manage the life deployment cycle this plug-in.

We will base in the Eclipse Galileo R2 for JEE projects on 64 bits package. And Google Plugin for Eclipse, which supports the GWT and GAE technologies, in Galileo version.

Eclipse installation is easy, download and unzip where you want. Then we execute it.

To install Google plug-in, Help > Install New Software … > Add, add the url Google Plugin for Eclipse for Galileo. And install Eclipse and both SDKs.

Create the application in Web File > New > Web Application Project:

Creating project

To test it in local mode, in the contextual menu choose Debug As > Web Application. Then we can how to debug an application with the usual eclipse debugger.

To deploy in the server we must enter in https://appengine.google.com, and create an ID (pe: firstapp-lebrijo). We configure it through the contextual menu Google > App Engine Settings… Then Eclipse knows where deploy it when we do Google > Deploy to App Engine.

I have my first application in: http://firstapp-lebrijo.appspot.com/

My First GAE App

Architecture: Services layer with Spring

In order to make the service layer and use the dependency injection we will take Spring.

Spring 2.5.6 is the OEPE default version supported.

First we will add the Spring Facet to our project. Right mouse button over the project > Properties… :

Add Spring Facet

After genertate the ORM classes. They will generate with contextual menu > Spring > Generate Spring ORM Classes …

Creating new ORM Services

You can see, about the JPA defined in our persistence package, it will create th access classes and services ones. I recommend you see the lebrijo.school.services and lebrijo.school.dao packages.

After we must clean this class of methods, the generator generates all possibilities (remove, persist, findById,…). For example, if one entity of our model is a view, we can destroy persist or remove methods.

Here I keep the zip eclipse project after these steps.

JPA: persistence with EclipseLink

Today we will see how to make the persistence in a Eclipse project with EclipseLink JPA implementation.

We will base in the last post Eclipse project. In the project properties (right buton) we will add the power to manage JPA entities, adding the facet:

Adding JPA facet

We will ue EclipseLink 1.1.2, it is the JPA implementation by defect in WebLogic 11g.

Generating entities from tables

Over the project, in the contextual menu (right button), JPA > Generate Entities from Tables… We choose the conection SCHOOL, created in other posts, and tables REGISTRY and SCHOOLCERTIFICATES. Generating the entities in the package lebrijo.school.model:

Generating entities from tables

To maintain the JPA coherence we must add an Identifier on every classes, Registry has one, but we must add one to SchoolCertificates:

Add Identifier

You may see the file src/META-INF/persistence.xml, how it configures the connection and map the entities.

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="school" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 	<class>lebrijo.school.model.Registry</class>
 
 	<class>lebrijo.school.model.Schoolcertificate</class>
		<properties>
			<property name="eclipselink.target-server" value="WebLogic_10"/>
			<property name="eclipselink.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
			<property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:@192.168.0.7:1521:xe"/>
			<property name="eclipselink.jdbc.user" value="school"/>
			<property name="eclipselink.jdbc.password" value="school"/>
			<property name="eclipselink.logging.level" value="FINEST"/>
		</properties>
 </persistence-unit>
</persistence>

here I leaveth eclipse zip project after these steps.

OEPE: Creating a basic Eclipse Project for WebLogic

In the last posts we had defined an Oracle EE architecture, we had installed Oracle XE and we connected it to our Eclipse, and we designed our data model for our example application.

Now we have to create a basic Eclipse project running on Weblogic.

Read the rest of this entry »