Novell is now a part of Micro Focus

Overview of Universal Component System (UCS)

Articles and Tips: article

Surendra Nath Mohanty
Software Consultant
India Development Center
smohanty@novell.com

01 Nov 2000


This AppNote addresses the Universal Component System (UCS) which provides the interface to different programming and scripting languages on NetWare.

Introduction

The Universal Component System (UCS) provides the interface to different programming languages as well as scripting languages on NetWare to access different component systems. This makes the reusable components available in scripting languages from different component systems.

UCS is a lightweight layer and provides features like Common Object Request Broker Architecture (CORBA) on NetWare. It caters to heterogeneous components residing in the network. This allows developers to use their favorite language in application development.

All scripting languages have a set of native components to perform certain operations. Using UCS you can access the components of other scripting languages as if they are native components and available anywhere in the network.

On NetWare the scripting languages can access Universal Component eXtension components (UCX), Java classes and JavaBeans, and remote ActiveX controls. UCS exposes set of simple APIs for the C, C++ and Java programmer to access these components on NetWare.

How UCS Can Be Used

UCS provides an interface (addressed as provider interface in the forthcoming sections) to write a pluggable extension for any scripting language on NetWare. These extensions are used as a bridge for scripting languages to talk to the core of the UCS (UCSCORE). Modules do data type conversion from native data types to UCS data type. UCSCORE redirects the request to the corresponding component system through the respective provider. The provider for the specific component system creates the instance of the component, or object, and gives that object to the requesting scripting language. After getting the object from the component system, the scripting language can handle it like a native component.

The scripting languages available on NetWare are the following:

  • Novell Script for NetWare (NSN)-100 percent VBScript compatible

  • Perl--Industry standard Perl

  • ScriptEase - 100% ECMA compatible JavaScript.

These scripting languages can access UCS through their respective extensions. These extensions are developed using UCS APIs. Other programming languages like C, C++, and Java can directly talk to UCS to access different components from different component systems.

Figure 1: UCS architecture.

Universal Language Adapter (ULA)

The ULA provides interface for any scripting language to access UCS. Scripting languages can develop their extensions using simple APIs provided by UCS. These extensions are extremely modular and are not part of UCSCORE or UCSAPI. The ULA sends the request to UCS from a specific scripting language to access a particular component in a component system. For each scripting language there is one extension:

  • NSN2UCS for NSN

  • PERL2UCS for Perl

  • SE2UCS for ScriptEase

  • JAVA2UCS for Java.

These extensions also perform data type conversion from specific languages to UCS generic data types.

UCSCORE and UCSAPI

UCSCORE and UCSAPI play a major role in the whole system. UCSCORE is the interface implementation of APIs. UCSAPI is the library implementation of APIs. Both bridge the gap between heterogeneous component systems by providing generic intermediate data types for different data types in different component systems. Requests from any scripting language through extensions or directly from programming languages like C or C++ are redirected to their respective providers by this layer. After getting the request this layer forwards the request to the specific provider. It converts the script data types to a generic UCS data type, which can be understood by providers. The provider references are maintained by UCSCORE.

Provider Interface

This interface provides a set of APIs to develop providers for any component system. The provider gets the UCS request from UCSCORE //UCSAPI and does the real operation on the component system. These providers convert the UCS request to their own request type, which can be understood by their component system. They convert all UCS generic data types to the component system specific data types. There are three providers on NetWare for three different component systems:

  • UCS2UCX--to access UCX components

  • UCS2JAVA--to access Java classes and JavaBeans

  • UCS2RMT and UCS2WIN--to access remote ActiveX controls that reside on Windows machines.

Provider for UCX Components (UCS2UCX)

This provider creates the instance of a UCX component. These are native components of NSN, in which Novell services are wrapped. After getting the instance of the component, you can manipulate the object like native a component.

ScritpEase Accesses UCX Component Using UCS

//Using UCX component UCS retrieves all the objects under
default
context of user
#link "UCSJS" //To use SE2UCS language adapter

var DirObj = CreateObject("UCX:NWDIR");
DirObj.login(Username, Password); // Log in to the
Directory Tree
Clib.printf("\nFullName is %s", DirObj.FullName); 

var Entries = DirObj.Entries; // Gets the list of all
entries under
the specific context

Entries.Reset(); 
While(Entries.HasMoreElements()) //Check for more entry
{
	 Entry  = Entries.Next(); // Gets next entry object from
the tree
	 Clib.printf("\nName of the Entry is %s",
Entry.ShortName);
}
DirObj.logout(); //Log out from the Tree

Provider for Java classes and JavaBeans (UCS2JAVA)

This provider creates the instance of a Java class or JavaBeans available under CLASSPATH. UCS redirects the request came from a script to this provider to instantiate the Java object. This provider provides fewer APIs to UCSCORE/UCSAPI to interact with Java. It takes care of Java object handles and provides a simple way to access Java classes and JavaBeans. It gives a simple look to UCSCORE/UCSAPI by discovering method signatures in this layer. No JNI (Java Native Interface) calls are required by UCSCORE and UCSAPI to invoke Java classes and JavaBeans.

NSN Accesses Java Class Using UCS

//Pushes three values to a hash table and retrieves them 
Set HashTable = CreateObject("java.util.Hashtable")

If (HashTable = null) Then
	 Print "Unable to create object"
	 Exit Sub
End If
//Puts the values in the hash table
HashTable.put(1, true)
HashTable.put(2, "Apples")
HashTable.put(3, 3.142)
//Retrieves them from hash table
For i = 3 To 1 Step -1
	 Element = HashTable.get(i)
	 Print Element
Next i

Perl Accesses JavaBean Using UCS

//It lists all the entries under the context specified in
FullName
use UCSExt; //To use PERL2UCS language adapter

$DirObj = UCSExt->new("NWDir(NWDir)") or die "Unable to
create the object";

print "\nEnter this server's NDS FullName (NDS:\\\\Tree
Name\\Organization):\n";
$FullName = <STDIN>;
chop $FullName;
$ DirObj->{"FullName"} = $FullName;

$RootEntry = $ DirObj->getEntry();
$Entries = $RootEntry->{"Entries"} or die "Incorrect NDS
FullName\n";
print "\nEntry List:\n";
//Prints all entries under the context specified
while ($Entries->hasMoreElements())
{
	 $Entry = $Entries->next();
	 $ShortName = $Entry->{"ShortName"};
	 print $ShortName . "\n";
}

ScriptEase Accesses JavaBeans Using UCS

//Lists all the entries under the context specified in
FullName
#link "ucsjs" //To use SE2UCS language adapter
var NDS = CreateObject("NWDir(NWDir)");

Clib.printf("\nEnter this server's NDS FullName
(NDS:\\\\Tree
Name\\Organization):\n");
FullName = Clib.gets();
NDS.FullName = FullName;

rootEntry = NDS.getEntry();
entries = rootEntry.Entries;

Clib.printf("\nEntry List:\n");
while (entries.hasMoreElements())
{
	 entry = entries.next();
	 Clib.printf ("%s\n", entry.ShortName);
}

Provider for Remote ActiveX Controls (UCS2RMT and UCS2WIN)

This provider helps to access remote ActiveX controls residing on Windows machines. It is a master/slave model. NetWare from where the request originates acts as master and the Windows machine where controls reside acts as a slave. UCS2RMT is the NetWare executable (NLM) which takes the request from the scripts and sends to a slave machine. UCS2WIN is a Window executable to process the request came from the master.

The communication between master and slave takes place though SOAP1.0. SOAP (Simple Object Access Protocol) is used over HTTP to access the Internet. SOAP over HTTP is used to overcome the firewall problem to access the Internet. The master (UCS2RMT) encodes the request to the SOAP packet and forwards the same to the target slave (UCS2WIN). The slave decodes the request and does appropriate invocation of the ActiveX control for the request and sends back the response in a SOAP packet. The master waits for the response, then decodes the packet and converts it to the appropriate UCS data and sends it to UCSCORE/UCSAPI.

The slave offers the following functionality:

  • HTTP listener

  • Decodes SOAP packet

  • Invoking ActiveX controls--ActiveX container activity

  • Encodes the response to the SOAP packet

ScriptEase Accesses Remote ActiveX Control Using UCS

//This sample opens a excel sheet and fills the cells in
the first
column of sheet1 //med Novell

#link "ucsjs" //To use SE2UCS language adapter
var Excl = CreateObject("OLE:Excel.Application.9@IP
address of
slave/DNS Name,port"); //Pass the IP address or DNS name
of the
window m/c where the //ntrol resides. Port is optional
Excl.Visible = true; // Makes the excel sheet visible on
slave
var wbs = Excl.Workbooks;
var wb = wbs.Add();
var sheet = Excl.ActiveSheet;
sheet.Name = "Novell"; //Sets the name of the work sheet
var cr1 = sheet.Range("A1"); //Adds the elements in the
1st  column
of the sheet
cr1.Value = "Welcome to UCS";
var cr2 = sheet.Range( "A2" );
cr2.Value = "Cell one";
var cr3 = sheet.Range( "A3" );
cr3.Value = "Cell two";
var cr4 = sheet.Range( "A4" );
cr4.Value = "Cell three";
var cr5 = sheet.Range( "A5" );
cr5.Value = "Cell four";
var cr6 = sheet.Range( "A6" );
cr6.Value = "Cell five";

Extension for Java (JAVA2UCS)

This extension provides the facilities to Java programmers to access UCX components and remote ActiveX controls from Java. The request from Java is taken by the extension and forwarded to UCSCORE. Then UCSCORE decides which component to be invoked through which provider. Java programmers will get few UCS data types to operate with other component system. These UCS data types' implementation is available in a package (ucs.jar) which is a part of UCS.

Java Accesses UCX Component Using UCS

//To retrieves all objects under the default context of
the user
import com.novell.utility.ucs.*;
class dsbrowse{
	 public static void main(String argv[]){
try{
	 	 UCSClassFactory ClsFactory = new UCSClassFactory();
	 	 UCSClass UcsCls  =  ClsFactory.getInstance("UCX:NWDIR");
	 	 UCSObject UcsObj = UcsCls.createObject();
	 	 if (UcsObj ==null){
	 	 	 	 System.out.println("Unable to create the object:
");
	 	 	 	 return;}
	 	 UCSVariable RetVal = new UCSVariable();
	 	 UCSVariable ArgList[] = new UCSVariable[2];
	 	 ArgList[0] = new UCSVariable(Username);
	 	 ArgList[1] = new UCSVariable(Password);
	 	 RetVal = UcsObj.callMethod("Login",ArgList);
	 	 RetVal = UcsObj.getProperty("Entries");
	 	 UCSObject EntriesObj  = RetVal.getObject();
	 	 RetVal = EntriesObj.callMethod("HasMoreElements"); 
	 	 boolean Bool = RetVal.getBoolean();
	 	 while(Bool) {
	 	 	 	 RetVal = EntriesObj.callMethod("Next");
	 	 	 	 UCSObject EntryObj = RetVal.getObject();
	 	 	 System.out.println("Shortname of EntryObj " +
EntryObj.getProperty("ShortName"));
	 	 	 RetVal = EntriesObj.callMethod("HasMoreElements"); 
	 	 	 Bool = RetVal.getBoolean();}
	 	 	 RetVal = UcsObj.callMethod("Logout");
	 	 } catch (UCSException e){
	 	 	 	 	 System.out.println("UCSException");
	 	 	 	 	 System.out.println(e.getMessage());
	 	 }catch (java.lang.Throwable e){
	 	 	 	 	 System.out.println("java language exception");
	 	 	 	 	 System.out.println(e.toString());
	 	 }
	 }
}

References

Following are suggested references for further information on the topics covered in this AppNote:

* Originally published in Novell AppNotes


Disclaimer

The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.

© Copyright Micro Focus or one of its affiliates