56
OSS Java Development Library Guide Third Edition December 2008 Oracle Communications IP Service Activator™ Version 5.2.4

OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

  • Upload
    others

  • View
    14

  • Download
    0

Embed Size (px)

Citation preview

Page 1: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java DevelopmentLibrary Guide

Third EditionDecember 2008

Oracle Communications IP Service Activator™ Version 5.2.4

Page 2: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Copyright © 1997, 2008, Oracle. All rights reserved.

The Programs (which include both the software and documentation) contain proprietary information; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent, and other intellectual and industrial property laws. Reverse engineering, disassembly, or decompilation of the Programs, except to the extent required to obtain interoperability with other independently created software or as specified by law, is prohibited.

The information contained in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. This document is not warranted to be error-free. Except as may be expressly permitted in your license agreement for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose.

If the programs are delivered to the United States Government or anyone licensing or using the Programs on behalf of the United States Government, the following notice is applicable:

U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the Programs, including documentation and technical data, shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement, and, to the extent applicable, the additional rights set forth in FAR 52.227-19, Commercial Computer Software--Restricted Rights (June 1987). Oracle USA, Inc., 500 Oracle Parkway, Redwood City, CA 94065.

The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently dangerous applications. It shall be the licensee’s responsibility to take all appropriate fail-safe, backup, redundancy and other measures to ensure the safe use of such applications if the Programs are used for such purposes, and we disclaim liability for any damages caused by such use of the Programs.

The Programs may provide links to Web sites and access to content, products, and services from third parties. Oracle is not responsible for the availability of, or any content provided on, third-party Web sites. You bear all risks associated with the use of such content. If you choose to purchase any products or services from a third party, the relationship is directly between you and the third party. Oracle is not responsible for: (a) the quality of third-party products or services; or (b) fulfilling any of the terms of the agreement with the third party, including delivery of products or services and warranty obligations related to purchased products or services. Oracle is not responsible for any loss or damage of any sort that you may incur from dealing with any third party.

Oracle, JD Edwards, and PeopleSoft are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Page 3: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition

Contents

Preface .................................................................................. vii

About this document ................................................................................ vii

Assumptions ........................................................................................... vii

Before contacting Oracle Global Customer Support (GCS) .............................viii

Contacting Oracle Global Customer Support (GCS) ......................................viii

Downloading products and documentation ..................................................viii

Downloading a media pack ................................................................... ix

Service Activator publications .................................................................... ix

Chapter 1 Overview .......................................................................... 1

About the OJDL .........................................................................................2

System architecture ..................................................................................3

Installing the OJDL ....................................................................................5

Prerequisites .......................................................................................5

Installing the OJDL ...............................................................................6

Chapter 2 Using the OJDL ................................................................. 7

Java development environment ...................................................................8

OJDL directory and file structure .................................................................8

JavaDocs ............................................................................................... 10

Java classes ........................................................................................... 10

EomAttribute ..................................................................................... 11

EomAttributesSet ............................................................................... 11

EomConnection .................................................................................. 11

EomConnectionManager ...................................................................... 11

EomDebug ........................................................................................ 11

EomDefaultConnection ........................................................................ 11

EomDifferenceResolver ....................................................................... 11

EomDiscovery .................................................................................... 11

Service Activator 5.2.4 iii

Page 4: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Contents

EomException .................................................................................... 12

EomExtendedSearchIterator ................................................................ 12

EomIntersectionResolver ..................................................................... 12

EomIterator ....................................................................................... 12

EomIteratorParameters ....................................................................... 12

EomNonIntegerException .................................................................... 12

EomObject ........................................................................................ 12

EomObjectException ........................................................................... 13

EomObjectFactory .............................................................................. 13

EomOimException .............................................................................. 13

EomResolver ..................................................................................... 13

EomSearchIterator ............................................................................. 13

EomSession ....................................................................................... 14

EomSessionException ......................................................................... 14

EomTransaction ................................................................................. 14

EomTransactionStateChange ............................................................... 15

Best practices for minimizing commits ........................................................ 16

Appendix A Managing Configuration Policies using the OJDL API ... 17

Initial Setup ........................................................................................... 18

Creating a Configuration Policy .................................................................. 18

Create the Configuration Policy data type. ............................................. 18

Create the RuleGeneric EOM object to contain the Configuration Policy ...... 19

Assign the Configuration Policy the required Device and Interface Roles ..... 20

Modifying a Configuration Policy ................................................................ 20

Query for the configuration policy ......................................................... 20

Modify the policy definition .................................................................. 21

Interface Management - Interface Policy Registration ................................... 21

Create a Subinterface ......................................................................... 22

Interface Management—Main Interface Creation ..................................... 24

Interface Management—Interface Decoration ......................................... 24

Comparing Created and Discovered Interfaces ....................................... 25

Configuration Policy Classes ...................................................................... 25

Service Activator 5.2.4 iv

Page 5: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Contents

Configuration Policy Example Source Code .................................................. 28

Interface Management Example Source Code .............................................. 38

Index ..................................................................................... 45

Service Activator 5.2.4 v

Page 6: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Contents OSS Java Development Library Guide – Third Edition

vi Service Activator 5.2.4

Page 7: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition

Preface

About this documentThe OSS Java Development Library Guide provides information for developing application programming interfaces to Service Activator. It is intended for systems integrators and developers who will be using the OJDL to develop their own Java-based interfaces, for example customized web-based applications for Customer Network Management.

The OSS Java Development Library (OJDL) provides a Java-based Application Programming Interface (API) to Service Activator. It comprises a set of Java classes together with some code samples and an example Web interface.

The OSS Java Development Library Guide consists of the following chapters:

Chapter 1: Overview provides a brief introduction to the OJDL and its capabilities.

Chapter 2: Using the OJDL provides information on the Java classes provided and outlines development considerations.

AssumptionsThis guide assumes that readers have the following knowledge:

Knowledge of the OSS Integration Manager (OIM), including the External Object Model (EOM), the OIM command language, and the ability to write scripts

Refer to the OSS Integration Manager Guide for further information

Familiarity with the core Service Activator features

Experience of the Java programming language and Java technologies

Knowledge of the Solaris operating system and its commands, including the ability to use a text editor such as vi

Service Activator 5.2.4 vii

Page 8: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Preface OSS Java Development Library Guide – Third Edition

Before contacting Oracle Global Customer Support (GCS)

If you have an issue or question, Oracle recommends reviewing the product documentation and articles on MetaLink in the Top Technical Documents section to see if you can find a solution. MetaLink is located at http://metalink.oracle.com.

In addition to MetaLink, product documentation can also be found on the product CDs and in the product set on Oracle E-Delivery.

Within the product documentation, the following publications may contain problem resolutions, work-arounds and troubleshooting information:

— Release Notes

— Oracle Installation and User's Guide

— README files

Contacting Oracle Global Customer Support (GCS)You can submit, update, and review service requests (SRs) of all severities on MetaLink, which is available 24 hours a day, 7 days a week. For technical issues of an urgent nature, you may call Oracle Global Customer Support (GCS) directly.

Oracle prefers that you use MetaLink to log your SR electronically, but if you need to contact GCS by telephone regarding a new SR, a support engineer will take down the information about your technical issue and then assign the SR to a technical engineer. A technical support representative for the Oracle and/or former MetaSolv products will then contact you.

Note that logging a new SR in a language other than English is only supported during your local country business hours. Outside of your local country business hours, technical issues are supported in English only. All SRs not logged in English outside of your local country business hours will be received the next business day. In order to obtain the broadest access to skilled technical support, Oracle advises you to log new SRs in English.

Oracle GCS can be reached locally in each country. Refer to the Oracle website for the support contact information in your country. The Oracle support website is located at http://www.oracle.com/support/contact.html.

Downloading products and documentationTo download the Oracle and/or former MetaSolv products and documentation, go to the Oracle E-Delivery site, located at http://edelivery.oracle.com.

viii Service Activator 5.2.4

Page 9: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Preface

You can purchase a hard copy of Oracle product documentation on the Oracle store site, located at http://oraclestore.oracle.com.

For a complete selection of Oracle documentation, go to the Oracle documentation site, located at http://www.oracle.com/technology/documentation.

Downloading a media pack

To download a media pack from Oracle E-Delivery

1. Go to http://edelivery.oracle.com.

2. Select the appropriate language and click Continue.

3. Enter the appropriate Export Validation information, accept the license agreements and click Continue.

4. For Product Pack, select Oracle Communications Applications.

5. For Platform, select the appropriate platform for your installation.

6. Click Go.

7. Select the appropriate media pack and click Continue.

8. Click Download for the items you wish to download.

9. Follow the installation documentation for each component you wish to install.

Service Activator publicationsThe Service Activator documentation suite includes a full range of publications. Refer to the Service Activator Release Notes for more information.

Service Activator 5.2.4 ix

Page 10: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Preface OSS Java Development Library Guide – Third Edition

x Service Activator 5.2.4

Page 11: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition

Chapter 1

Overview

This chapter provides a brief introduction to the OJDL, the components of the package and its relationship to the rest of the Service Activator system. It includes the following:

What the OJDL consists of

The architecture of the OJDL and how it relates to the rest of the system

Software delivery and installation

Service Activator 5.2.4 1

Page 12: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Overview OSS Java Development Library Guide – Third Edition

About the OJDLThe OJDL is a generic Java API to Service Activator, allowing Java developers to develop or customize interfaces, including web-based or intranet-based user interfaces.

The OJDL package comprises:

The Java Classes

Some Java code samples

An example web-based interface

The OJDL can be used to:

Code against the API directly, using the Java classes provided

Develop Java-based interfaces used to integrate with either the service provider’s internal OSS environment or an external Customer Network Management solution

See Using the OJDL on page 7 for further information.

2 Service Activator 5.2.4

Page 13: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Overview

System architectureThe following diagram shows the relationship between the OJDL and the rest of the Service Activator system:

The OJDL uses the OIM interface and provides access to the EOM (External Object Model), a simplified version of Service Activator’s internal object model used by the OIM API.

In effect, the OJDL provides additional layers that are built on top of OIM, which in turn sits on top of the core Service Activator system:

JAVAINTERFACE

OM

OSS

OIM

POLICY SERVER

OM

USER INTERFACE

OM

OM

OJDL

DB

EOM

CORBA

Service Activator 5.2.4 3

Page 14: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Overview OSS Java Development Library Guide – Third Edition

The EOM is a subset of Service Activator’s internal object model. It defines all the objects that can be accessed or updated by external applications, including their attributes and the relationships between them. The EOM allows user programs to create and access data objects without requiring knowledge of the underlying complexity of the entire object model.

The Java Classes provide access to the objects in the EOM. The EOM interface is mapped directly on to Java classes; the OJDL therefore provides the same functionality as the OIM, allowing you to create objects, get and set attributes, search for objects, manage transactions and report errors.

The JSPs are built for web deployment, so that the application can be viewed through a web browser.

CORBA IDL

OSS Java Development Library (OJDL)

Java Server Pages / Portal

Web Browser

External Object Model

Presentation Layer (UI)

Internal Object Model

Java BeansCRM

Service provider's self-service interface

Service Activator

OIM

coreService Activatorsystem

4 Service Activator 5.2.4

Page 15: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Overview

Installing the OJDLThe OJDL package is not installed as part of the Service Activator standard installation. It is a separate package downloadable from the Oracle E-Delivery site.

The OJDL is stored in a directory called ojdlpackage-<rel#.build#>. (For example, ojdlpackage-4.2.1.122)

The OJDL directory consists of the following subdirectories:

doc – contains the Java documentation (JavaDocs)

lib – contains the OJDL jar file that contains the java classes

samples – contains code samples for testing purposes

PrerequisitesThere are no restrictions on where to install the OJDL directory on the host system. However, you must ensure that the following software is installed on the host system where you will be installing OJDL:

Service Activator must be installed, including OIM. For details, see the Setup Guide.

If you are using SLA Integration, the SLA Integration component must be installed. (Note that this application is usually installed on a different host than the Policy Server.) For details, see the Setup Guide. If you wish to provide an interface to InfoVista for reporting, InfoVista must be installed. For details, see Network and SLA Monitoring Guide.

If you are developing Java code or running web-based applications, a suitable Java development environment must be installed, such as J2SE (JDK). See Java development environment on page 8.

If you are using or developing web applications, a suitable execution environment must be installed. We recommend the use of Tomcat.

Service Activator 5.2.4 5

Page 16: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Overview OSS Java Development Library Guide – Third Edition

Installing the OJDL1. Log in to the Oracle E-Delivery site and select Product Downloads. Select

Oracle Communications IP Service Activator, then the Components folder for the desired release.

2. Download the file ojdlpackage-<rel#.build#>.tar.gz. (For example, ojdlpackage-4.2.1.122.tar.gz)

3. Move the file to the desired directory on the host where you are installing OJDL. There are no restrictions on which directory path you choose.

4. Unzip and untar the file to create the OJDL directory. The name of the OJDL directory is denoted as ojdlpackage-<rel#.build#> (For example, ojdlpackage-4.2.1.122)

6 Service Activator 5.2.4

Page 17: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition

Chapter 2

Using the OJDL

This chapter outlines the OJDL, including the Java classes provided for developers. It includes the following:

Setting up a suitable Java development environment

The OJDL file structure

The codes samples provided

Summary of the Java classes provided

Requirements for using a different ORB

Best Practices for Minimizing Commits

Service Activator 5.2.4 7

Page 18: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Using the OJDL OSS Java Development Library Guide – Third Edition

Java development environmentIn order to develop Java code you need a suitable development environment, such as the Java 2 Platform Standard Edition (J2SE) from Sun (previously known as the Java Development Kit (JDK)). The J2SE can be downloaded free from http://java.sun.com/j2se/

OJDL directory and file structureWhen using the OJDL for developing Java code, you need the following directories:

\doc directory

Contains HTML files containing class, and package information. The file index.html lists all the classes and packages, and contains links to access the HTML files which provide the relevant information.

\doc\com\mslv\osa\ojdl\eom directory

HTML files describing the EOM Java API classes.

The J2SE (JDK) can be downloaded free, and can be used for commercial or non-commercial purposes. However, you must retain the copyright notices.

This guide assumes the use of JDK, but other suitable Java tools can be used if required. You need to ensure they are configured correctly.

<Document_Root>

com

mslv

eom OIM

doc lib samples

osa

ojdl

8 Service Activator 5.2.4

Page 19: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Using the OJDL

\doc\com\mslv\osa\ojdl\Oim directory

HTML files describing the OIM Java API subclasses (for the OIM IDL).

\lib directory

Contains the ojdl.jar file, which contains a compressed version of all the Java classes. If you unpack the ojdl.jar file, the following directory structure is created:

The \Meta-inf directory holds the Manifest.mf file, which is generated when you jar the files.

You must put the ojdl.jar file in the class path.

<Document_Root>

com

mslv

eom OIM

Meta-inf

osa

ojdl

Service Activator 5.2.4 9

Page 20: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Using the OJDL OSS Java Development Library Guide – Third Edition

\samples directory

Contains Java code samples, which provide an illustration of the use of the classes.

JavaDocsThe JavaDocs are stored in the \doc directory. For more information, refer to section \doc directory on page 8.

Java classesThe Java classes provide access to the EOM objects. The classes are used to create beans which can be used to create reusable user interface components for particular tasks. These may be written as Java applications, applets, or as scripts within a Java Server Page.

The JavaDocs are stored in the \lib directory. For more information, refer to section \lib directory on page 9.

Note the following:

Browsing is done through iteration, which is basically the results of a find command based on a Java class

Transactions are created in the same way as in the current Service Activator user interface, but they work through OSS classes

The Java classes are all fully documented:

Information on the classes is contained in the file \doc\index.htm

Details of methods and variables used are contained in the file \doc\index-all.htm file

The main classes are summarized below.

To find out the OJDL version number you are using, double-click on the ojdl.jar file, or enter the following command:

java -jar <document_root>\lib\ojdl.jar

A window will appear displaying the OJDL version number.

10 Service Activator 5.2.4

Page 21: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Using the OJDL

EomAttributeEomAttribute is a base class for representing an attribute within the EOM. By default, an attribute is modeled by two strings representing an attribute value pair.

EomAttributesSetEomAttributesSet holds a set of EomAttribute objects.

EomConnectionEomConnection represents the way that commands are sent to the OIM.

EomConnectionManagerEomConnectionManager defines a connection manager interface for connecting to the OIM. This interface should be implemented if you use a different ORB to the one provided by the JDK. In this case use the following EomSession constructor:

public EomSession(EomConnectionManager connectionMgr) throws EomException

EomDebugEomDebug provides a way to enable traces. There are four levels of debug:

0 = no debug

1 = commands sent debug

2 = other traces

3 = all traces

EomDefaultConnectionEomDefaultConnection is the default implementation of EomConnectionManager using the JDK ORB.

EomDifferenceResolverEomDifferenceResolver finds the logical difference of EomObjects contained in two iterators.

EomDiscoveryEomDiscovery enables the discovery of devices.

Service Activator 5.2.4 11

Page 22: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Using the OJDL OSS Java Development Library Guide – Third Edition

EomExceptionEomException may be thrown by methods interacting with the OIM. It is the base class for any exception thrown by the OJDL.

EomExtendedSearchIteratorEomExtendedSearchIterator extends the EomSearchIterator by searching on an iterator of EomObjects.

EomIntersectionResolverEomIntersectionResolver finds the logical intersection of EomObjects contained in two iterators.

EomIteratorEomIterator is an extension of the java.util.Iterator interface. It provides a wrapper around the search functionality of the OIM find command. A search iterator is constructed from the direction of the search, the class of object to search for, and any parameters to match. It searches from a given root object.

An extended search iterator is constructed from the same search criteria but uses the results of another iterator as the root of its search.

EomIteratorParametersEomIteratorParameters provides a way to pass parameters to an EomSearchIterator to refine the search.

Example:

EomSearchIterator gatewayRoleDeviceIterator = new EomSearchIterator(eomSession, rootDomain, "RoleDevice", "child", new EomIteratorParameters("type", "gateway"), false);

EomNonIntegerExceptionThe EomNonIntegerException is thrown when a non-integer value is being assigned to an integer variable.

EomObjectEomObject is a base class for representing objects within the EOM. Each object has an Id, name, and set of attributes.

12 Service Activator 5.2.4

Page 23: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Using the OJDL

EomObjectExceptionThe EomObjectException is thrown during an EomObject creation.

EomObjectFactoryEomObjectFactory is a factory to build EomObjects. You can subclass this class to build your own object factory and override the getEomObjectForClassName() method.

EomOimExceptionEomOimException is thrown when a command cannot be executed by OIM.

EomResolverEomResolver is a base class for combining the results of two iterator sets. It combines the contents of two iterators according to a desired algorithm. It can be subclassed, and includeObject can be overwritten to decide which objects are included in the final set.

Extensions of EomResolver are provided to perform typical set operations on iterators.

EomSearchIteratorEomSearchIterator looks for all objects of a specific type with a given attribute. A call to begin() is needed to start the search. The following shows an example.

EomObject rootDomain;

...

...

try{

EomSearchIterator accessroleInterfaceIterator = new EomSearchIterator(eomSession, rootDomain, "RoleInterface", "child", new EomIteratorParameters("type", "access"), false);

accessroleInterfaceIterator.begin();

while ( accessroleInterfaceIterator.hasNext()){

EomObject nextInterface = accessroleInterfaceIterator.next();

...

}

}catch(EomException e){

Service Activator 5.2.4 13

Page 24: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Using the OJDL OSS Java Development Library Guide – Third Edition

System.out.println(" Exception thrown by iterator : " + e);

}

EomSessionAn instance of EomSession represents a connection to the OIM. Each Java application must create an instance of EomSession and call login() to register as a user within the OIM. Commands are sent to the OIM through the EomSession instance.

The following is an example of how to login to the system.

short port = 2809;

String host = "127.0.0.1";

try{

EomSession session = new EomSession(host, port);

boolean logged = session.login("orchestream","orchestream");

System.out.println("login status : " + logged);

}catch(Exception e){

System.out.println("exception thrown at login : " + e);

}

You can call the logout() method to logout and login as a different user. By calling close() you close the connection to the OIM. You then need to instantiate a new EomSession.

EomSessionExceptionEomSessionException is thrown by a method in EomSession when connected to the OIM.

EomTransactionAn instance of EomTransaction models the general Service Activator transaction concept. Any changes made to the EOM, for example create, modify, delete, link and unlink, are done via an EomTransaction object. Transactions can be queued, scheduled or committed directly.

You can pass to the constructor a subclass of EomObjectFactory to build EomObjects from your own subclasses of EomObject.

14 Service Activator 5.2.4

Page 25: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Using the OJDL

Create an instance of EomTransaction by calling openTransaction on an EomSession instance. The parameter supplied is used to identify the transaction within Service Activator.

Example:

EomSession session("localhost", 2809);

session.login("orchestream", "orchestream");

...

EomSearchIterator domains(session, session.getPolicyObject(), "Domain", "child", true);

EomObject myDomain = domains.getFirstItem();

...

EomTransaction trMyTransaction = session.openTransaction("My Transaction");

Modify the external object model by performing actions within the transaction:

trMyTransaction.createObject(myDomain,

tr.delete(obj);

Call commit() to execute the command put in the transaction:

tr.commit();

EomTransactionStateChangeEomTransactionStateChange is a base class which allows Service Activator to synchronously return configuration success or failure messages via the OJDL for transactions which perform adds, modifies, or deletes. In order to do this, the state of each individual configuration concrete involved in a transaction is monitored. When the concrete has reached its final state, the success or failure result is sent back through the calling API.

The class contains methods to take serialized transaction blobs, locate the CIDs in them, and then locate existing transactions and perform evaluations on the states of the transactions.

Service Activator 5.2.4 15

Page 26: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Using the OJDL OSS Java Development Library Guide – Third Edition

Best practices for minimizing commitsIt is best to minimize the number of commits to complete an operation, since each commit introduces a delay when the object model is updated to reflect the new changes.

The following example shows how commits may be minimized when an application generates a large number of devices for testing. These devices are all the same type and use the device capabilities of an existing device.

To link the desired capabilities, you must first unlink the default capabilities that are linked when the device is created. In the least efficient case, the client code would take three commits; device create, commit, setpath to device and unlink existing caps, commit, link new caps, commit.

In the more efficient form, the client code could accomplish this via one commit by constructing a reference to the default capabilities of the device by appending/DeviceCapabilities:"DeviceCapabilities" to the path of the device object.

Example:

Construct an EomIdentifier that references the capabilities linked to the device when the transaction is commited:

EomIdentifier idForNotYetLinkedDefaultCaps = new EomIdentifier("DeviceCapabilities", "DeviceCapabilities", newDevice.getPath() + "/" + "DeviceCapabilities" + ":\"DeviceCapabilities\"");

Unlink the default caps, and link the appropriate device caps:

itsTransaction.unlinkObjects(newDevice, itsSession.createEomObject(idForNotYetLinkedDefaultCaps));

itsTransaction.linkObjects(newDevice, deviceCaps);

tr = eomSession.openTransaction();

tr.commit();

16 Service Activator 5.2.4

Page 27: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition

Appendix A:

Managing Configuration Policies using the OJDL API

This appendix outlines how to use the OJDL API to manage Configuration Policies in IPSA. It includes the following:

Initial Setup

Creating a Configuration Policy

Modifying a Configuration Policy

Interface Policy Registration

Create a Subinterface

Main Interface Creation

Interface Decoration

Comparing Created and Discovered Interfaces

Configuration Policy Classes

Configuration Policy Example Source Code

Interface Management Example Source Code

Service Activator 5.2.4 17

Page 28: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

Initial SetupThe following jar files are required in the application classpath in order to create Configuration Policies using the OJDL API.

servicemodelextensions.jar—XML Bean Classes for the Configuration Policy Service Model Extensions.

xbean.jar—Apache XML Beans API.

jsr173_api.jar—Streaming API for XML, provided as part of the Apache XML Beans API.

ojdl.jar—IPSA Orchestream Java Development Library (OJDL) API.

These files are located in the following IPSA installation directory:

unix: /opt/Orchestream/ServiceActivator/lib/java-lib

windows: C:\Program Files\Oracle Communications\IP Service Activator\lib\java-lib

Creating a Configuration PolicyConfiguration Policies are optional XML extensions to the IPSA object model that are supported by the Network Processor Cartridges.

A configuration policy is created using the OJDL API by creating a RuleGeneric object as a child of an Interface (or of any parent of an Interface in the object hierarchy). The Configuration Policy XML definition is set in the RuleGeneric ContentValue attribute.

The structure of the XML for each Configuration policy is defined by an XML Schema specification. An API is provided to programmatically construct the configuration policy XML data structures using Java XML Beans, using the Apache XML Beans technology http://xmlbeans.apache.org/

The following example demonstrates the steps interacting with configuration policy objects using the OJDL APIs. Refer to Configuration Policy Example Source Code on page 28 for the complete example source.

Create the Configuration Policy data type.Each Configuration Policy top level XML element is represented by an XML Beans Document class. For example the StaticNats configuration policy is created as a StaticNatsDocument object. Refer to Configuration Policy Classes on page 25 for the complete configuration policy class mapping.

The content of the StaticNats object is set using the XML Beans API.

18 Service Activator 5.2.4

Page 29: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

import com.metasolv.serviceactivator.staticnat.StaticNatsDocument;

...

// Create the StaticNat configuration policy

StaticNatsDocument staticNatDoc = StaticNatsDocument.Factory.newInstance();

StaticNats staticNats = staticNatDoc.addNewStaticNats();

StaticNat staticNat = staticNats.addNewStaticNat();

staticNat.setInsideIpAddress("192.168.100.1");

staticNat.setOutsideIpAddress("10.10.100.1");

Create the RuleGeneric EOM object to contain the Configuration Policy

The Configuration Policy objects are represented in the IPSA External Object Model as a RuleGeneric object. The following two attributes must be set:

ContentType—the configuration policy type

ContentValue—the configuration policy xml string

EomTransaction tr = eomSession.openTransaction();

// Set the object attributes for the RuleGeneric object

EomAttributesSet gpAttrs = new EomAttributesSet();

gpAttrs.setAttribute("ContentType", "staticNats");

gpAttrs.setAttribute("ContentValue", escapeForOIM(staticNatDoc.toString()));

EomObject gpObject = tr.createObject(parent, "RuleGeneric", "Static NATs", gpAttrs);

The ContentValue configuration policy XML is generated by invoking the toString() function, as follows:

<staticNats xmlns="http://www.metasolv.com/serviceactivator/staticnat">

<staticNat>

<insideIpAddress>192.168.100.1</insideIpAddress>

<outsideIpAddress>10.10.100.1</outsideIpAddress>

</staticNat>

</staticNats>

For passing XML strings in to the EOM object attributes some special characters need to be escaped by pre-pending an additional "\" character. For example, \"

Service Activator 5.2.4 19

Page 30: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

and \' must be fully escaped to \\\" and \\\' respectively. This conversion is performed by the escapeForOIM() function provided in the example.

Assign the Configuration Policy the required Device and Interface Roles

The RuleGeneric object can be created as a child of any object in the object hierarchy, however the policy object Concrete is applied at any of the Interface objects in the inheritance hierarchy that match the RuleGeneric Roles. This implies that, the RuleGeneric Device and Interface Roles must match the Device and Interface Roles on the Interface where the Configuration Policy is applied.

EomObject roleDevice = findRole("Gateway", "RoleDevice");

EomObject roleInterface = findRole("Access", "RoleInterface");

tr.linkObjects(gpObject, roleDevice);

tr.linkObjects(gpObject, roleInterface);

Modifying a Configuration PolicyModification of a configuration policy involves querying the object model for the current configuration policy definition. Modifying the configuration policy and updating the whole definition back into the object model.

Query for the configuration policyThe Configuration Policy XML can be obtainted from the RuleGeneric ContentValue parameter. The XML is parsed back in to the XML Beans object definition of the service model extension.

// Find the existing Static NAT configuration policy on the device.

EomObject device = eomSession.getObjectByPath(deviceId);

EomSearchIterator interfaceIterator = new EomSearchIterator(

eomSession, device, "RuleGeneric", "child",

new EomIteratorParameters("name", "staticNats"), false);

// Should be just one exact match

EomObject staticNat = (EomObject) interfaceIterator.getFirstItem();

// Construct the configuration policy XMLBean from the RuleGeneric XML

StaticNatsDocument staticNatDoc = StaticNatsDocument.Factory

.parse(unescapeFromOIM(staticNat.getAttribute("ContentValue")));

20 Service Activator 5.2.4

Page 31: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

Note that as with the case of creating the configuration policy the XML content of the RuleGeneric updated to handle the extra escape characters around the \" and \' characters This conversion is performed by the unescapeFromOIM() function provided in the example.

Modify the policy definitionThe configuration policy definition is modified using the XML Bean APIs for the service model extension documents.

// Update the static NAT definitions

staticNatDoc.getStaticNats().getStaticNatArray(0).setOutsideIpAddress("10.10.55.1");

// Update the Static NATs policy definition

staticNat.setAttribute("ContentValue", escapeForOIM(staticNatDoc.toString()));

EomTransaction tr = eomSession.openTransaction();

tr.modifyObject(staticNat);

tr.commit();

Interface Management - Interface Policy RegistrationCreating a new interface in IPSA via the OIM and OJDL APIs involves a specialized used of configuration policies with interface configuration management framework. As with interface management through the IPSA there are three main types of interface management interactions.

Main interface creation

Subinterface creation

Interface Decoration

Each possible interaction must be registered as a Interface Policy Registration. The Interface Policy Registration objects can either be pre-setup in IPSA, or created using the IPSA APIs - For the purposes of this example we will register a Cisco Frame Relay Subinterface Creation Policy.

EomTransaction tr = eomSession.openTransaction();

// Set the object attributes for the Interface Policy Registration object

Service Activator 5.2.4 21

Page 32: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

String name = "CreateCiscoFrameRelaySerialSubinterface";

EomAttributesSet attributes = new EomAttributesSet();

attributes.setAttribute("GenericPolicyTypeName", "frSubInterfaceData");

attributes.setAttribute("PolicyType", "Create");

attributes.setAttribute("Context", "Interface");

attributes.setAttribute("ContextPrefix", "Serial");

attributes.setAttribute("ContextSnmpIfType", "32"); // frameRelay(32)

attributes.setAttribute("CreationPrefix", "");

attributes.setAttribute("CreationSnmpIfType", "32"); // frameRelay(32)

attributes.setAttribute("CreationUseParentPrefix", "True");

attributes.setAttribute("Enabled", "True");

attributes.setAttribute("MenuText", "Frame Relay Serial Subinterface");

attributes.setAttribute("VendorEnterpriseId", "9"); // Cisco

// The registration policy is created as a child of the top

// level /Policy:"Policy" object

EomObject policy = eomSession.getObjectByPath("/Policy:\"Policy\"");

EomObject interfacePolicyRegistration = tr.createObject(policy,

"InterfacePolicyRegistration", name, attributes);

// Commit the transaction.

tr.commit();

Note: Once an interface policy registration is used to create or decorate an interface it cannot no be modified or deleted until all dependent parent interfaces have been deleted or unlinked from the policy registration.

Create a SubinterfaceTo correctly create a new interface in IPSA so that the new interface configuration will be created on the device requires a number of specific steps.

As a pre-requisite the appropriate subinterface creation interface policy registration must be created.

Create the Subinterface object

Create a new subinterface object under the target interface. For consistency it is recommended to create child the interface with the correct ifType, although IPSA will update this value on the next device discovery.

// Create the new subinterface interface object

22 Service Activator 5.2.4

Page 33: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

String subinterfaceName = "Serial1/3.100";

attributes = new EomAttributesSet();

attributes.setAttribute("Type", "32");

EomObject subinterface = tr.createObject(parentInterface, "Subinterface",

subinterfaceName, attributes);

Link the new Subinterface object to the Interface Policy Registration

The created subinterface object is linked to the previously defined interface policy registration. The act of linking the registration policy will automatically create a new RuleGeneric configuration policy object with the correct data type settings based on the interface registration policy definition.

// Link the new subinterface object to the interface policy registration

tr.linkObjects(subinterface, registrationPolicy);

tr.commit();

The new RuleGeneric is named with the interface names and appended with "-Data".

Modify the interface configuration policy data

The interface management configuration policy will not contain any default settings. These must be manually created using the appropriate XML data structure for the configuration policy data type defined in the interface registration policy, in this example it is the frSubinterfaceData policy. The XML content can be created manually or using the XML Beans API provided.

// A new RuleGeneric object for the interface management configuration policy is

// automatically created under the subinterface. Create the interface policy definition.

EomObject interfaceSettings = eomSession.getObjectByPath(subinterface.getPath() +

"/RuleGeneric:\"" + subinterfaceName + "-Data\"");

FrSubInterfaceDataDocument interfaceSettingsBean =

FrSubInterfaceDataDocument.Factory.newInstance();

interfaceSettingsBean.addNewFrSubInterfaceData();

interfaceSettingsBean.getFrSubInterfaceData().setDlci(100);

String interfaceSettingsXml = escapeForOIM(interfaceSettingsBean.toString());

Service Activator 5.2.4 23

Page 34: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

interfaceSettings.setAttribute("ContentValue", interfaceSettingsXml);

tr.modifyObject(interfaceSettings);

Link the new interface to an Interface Role

Up to this point the new interface has only been created in the IPSA object model. To commit the interface creation to the device the new interface object must be linked to an appropriate Interface Role.

// Link a suitable interface role to the new subinterface.

tr.linkObjects(subinterface, interfaceRole);

tr.commit();

Discover the Device (optional)

The device can optionally be re-discovered to align any interface changes with the object model. That is, for the interface ifType, and any VC objects. For interface types that have child VC object created by the configuration (such as the framerelay DLCI) device rediscovery is recommended.

// Optionally rediscover the device the get any VC level objects (in this example

// the DLCI)

eomSession.sendCommandtoOIM("discover " + parentDeviceId);

Interface Management—Main Interface CreationThe steps for main interface creation are largely the same as for Subinterface creation. For a main interface the new interface is created as child of the Device and is linked to an appropriate Interface type Interface Policy Registration object.

One specific distinction of the for interface creation is that the Interface Policy Registration must define the default capabilities that the interface (and it's sub interfaces and VCs) will be assigned. If the default settings are used the created interface will not have any capabilities assigned and a capabilities reset and rediscovery must be performed instead.

Interface Management—Interface DecorationFor interface decoration follow the same steps as Subinterface creation, with the exception that the interface does not need to be created first. For interface decoration the existing interface must be links to a Decorate type Interface Policy Registration object.

24 Service Activator 5.2.4

Page 35: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

Comparing Created and Discovered InterfacesIt is possible to determine if an interface was created using the IPSA interface configuration management framework, or was initially discovered from the device, by inspecting the IsConfigurable parameter on the Interface or SubInterface object.

"IsConfigurable = True in Created Interface

"IsConfigurable = False in Discovered Interface

Configuration Policy Classes

Extension Configuration Policy Java XMLBeans Class

DlswModule dlswDevice com.metasolv.serviceactivator.dlsw.DlswDeviceDocument

dlswEthernetInterface com.metasolv.serviceactivator.dlsw.DlswEthernetInterfaceDocument

dlswTokenRingInterface com.metasolv.serviceactivator.dlsw.DlswTokenRingInterfaceDocument

Service Activator 5.2.4 25

Page 36: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

InterfaceConfigMgmtModule

atmSubInterfaceData com.metasolv.serviceactivator.subinterface.AtmSubInterfaceDataDocument

backUpInterfacePolicy com.metasolv.serviceactivator.subinterface.BackUpInterfacePolicyDocument

basicRateInterfaceData com.metasolv.serviceactivator.subinterface.BasicRateInterfaceDataDocument

ciscoUniversalInterface com.metasolv.serviceactivator.subinterface.CiscoUniversalInterfaceDocument

dialerInterface com.metasolv.serviceactivator.subinterface.DialerInterfaceDocument

e1ChannelizedSerialInterface

com.metasolv.serviceactivator.subinterface.E1ChannelizedSerialInterfaceDocument

e1Controller com.metasolv.serviceactivator.controller.E1ControllerDocument

e3ChannelizedSerialInterface

com.metasolv.serviceactivator.subinterface.E3ChannelizedSerialInterfaceDocument

e3Controller com.metasolv.serviceactivator.controller.E3ControllerDocument

frSubInterfaceData com.metasolv.serviceactivator.subinterface.FrSubInterfaceDataDocument

hsrp com.metasolv.serviceactivator.hsrp.HsrpDocument

loopbackInterfaceData com.metasolv.serviceactivator.subinterface.LoopbackInterfaceDataDocument

multilinkInterface com.metasolv.serviceactivator.subinterface.MultilinkInterfaceDocument

plPosInterfaceData com.metasolv.serviceactivator.subinterface.PlPosInterfaceDataDocument

pppMultilink com.metasolv.serviceactivator.subinterface.PppMultilinkDocument

stm1ChannelizedSerialInterface

com.metasolv.serviceactivator.subinterface.Stm1ChannelizedSerialInterfaceDocument

stm1Controller com.metasolv.serviceactivator.controller.Stm1ControllerDocument

t1ChannelizedSerialInterface com.metasolv.serviceactivator.subinterface.T1ChannelizedSerialInterfaceDocument

t1Controller com.metasolv.serviceactivator.controller.T1ControllerDocument

t3ChannelizedSerialInterface com.metasolv.serviceactivator.subinterface.T3ChannelizedSerialInterfaceDocument

t3Controller com.metasolv.serviceactivator.controller.T3ControllerDocument

Extension Configuration Policy Java XMLBeans Class

26 Service Activator 5.2.4

Page 37: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

InterfaceConfigMgmtModule

virtualTemplateInterface com.metasolv.serviceactivator.subinterface.VirtualTemplateInterfaceDocument

vlanSubInterface com.metasolv.serviceactivator.subinterface.VlanSubInterfaceDataDocument

vrfExportRouteFilter com.metasolv.serviceactivator.vrfexportroutefilter.VrfExportRouteFilterDocument

MiscPluginsModule

atmVcClass com.metasolv.serviceactivator.vcclass.AtmVcClassDocument

banners com.metasolv.serviceactivator.banner.BannersDocument

bgpCE com.metasolv.serviceactivator.bgpce.BgpCEDocument

dailerList com.metasolv.serviceactivator.dialerList.DialerListDocument

dslInterfaceData com.metasolv.serviceactivator.subinterface.DslInterfaceDataDocument

extendedAcl com.metasolv.serviceactivator.extendedAcl.ExtendedAclDocument

ipPools com.metasolv.serviceactivator.ippool.IpPoolsDocument

keyChains com.metasolv.serviceactivator.keyChain.KeyChainsDocument

saveConfig com.metasolv.serviceactivator.saveConfig.SaveConfigDocument

staticNats com.metasolv.serviceactivator.staticnat.StaticNatsDocument

staticRoutes com.metasolv.serviceactivator.staticroute.StaticRoutesDocument

userAuth com.metasolv.serviceactivator.userAuth.UserAuthDocument

userData com.metasolv.serviceactivator.userData.UserDataDocument

ServiceAssuranceModule

collectorParameters com.metasolv.serviceactivator.collectorParameters.CollectorParametersDocument

netflowParameters com.metasolv.serviceactivator.netflowParameters.NetflowParametersDocument

rtrResponder com.metasolv.serviceactivator.rtrr.RtrResponderDocument

SnmpModule snmpCommunities com.metasolv.serviceactivator.snmp.SnmpCommunitiesDocument

snmpHosts com.metasolv.serviceactivator.snmp.SnmpHostsDocument

Extension Configuration Policy Java XMLBeans Class

Service Activator 5.2.4 27

Page 38: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

Configuration Policy Example Source CodeThis section details the complete configuration policy example source code.

/*

* The following source provides and example of using the service model

* extensions XML Beans API in conjunction with the IPSA OJDL API to create

* a Configuration Policy object.

*

* The following jar files are required by the client to implement to the api:

*

* - servicemodelextensions.jar (from IPSA)

* - ojdl.jar (from IPSA)

* - xbean.jar (from Apache XMLBeans)

* - jsr173.jar (from Apache XMLBeans)

*/

import java.text.StringCharacterIterator;

import org.apache.xmlbeans.XmlException;

import com.metasolv.serviceactivator.staticnat.StaticNat;

import com.metasolv.serviceactivator.staticnat.StaticNats;

import com.metasolv.serviceactivator.staticnat.StaticNatsDocument;

import com.mslv.osa.ojdl.eom.EomAttributesSet;

import com.mslv.osa.ojdl.eom.EomException;

import com.mslv.osa.ojdl.eom.EomIteratorParameters;

import com.mslv.osa.ojdl.eom.EomObject;

import com.mslv.osa.ojdl.eom.EomSearchIterator;

import com.mslv.osa.ojdl.eom.EomSession;

import com.mslv.osa.ojdl.eom.EomSessionException;

import com.mslv.osa.ojdl.eom.EomTransaction;

public class StaticNATsConfigurationPolicyExample {

28 Service Activator 5.2.4

Page 39: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

// OJDL EOM Session object

static EomSession eomSession;

/**

* Creates the example StaticNATs configuration policy document containing

* three static NAT definitions.

*

* @return StaticNatsDocument XMLBean

*/

public StaticNatsDocument constructStaticNatPolicyDocument() {

StaticNatsDocument staticNatDoc = StaticNatsDocument.Factory

.newInstance();

StaticNats staticNats = staticNatDoc.addNewStaticNats();

StaticNat staticNat = staticNats.addNewStaticNat();

staticNat.setInsideIpAddress("192.168.100.1");

staticNat.setOutsideIpAddress("10.10.100.1");

StaticNat staticNat1 = staticNats.addNewStaticNat();

staticNat1.setInsideIpAddress("192.168.100.2");

staticNat1.setOutsideIpAddress("10.10.100.2");

StaticNat staticNat2 = staticNats.addNewStaticNat();

staticNat2.setInsideIpAddress("192.168.100.3");

staticNat2.setOutsideIpAddress("10.10.100.3");

return staticNatDoc;

}

/**

* Creates a new device level configuration policy. Device level

* configuration policies such as the staticNATs policy generate device

Service Activator 5.2.4 29

Page 40: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

* level configuration. As configuration policies do not support device

* level concretes the policy must be applied to an interface with matching

* roles, for this example the we create the policy under the Loopback0

* interface which is the recommended default to attach device level

* configuration policies.

*

* @param configPolicyType

* the configuration policy type e.g. "staticNats".

* @param configPolicyXml

* the XML content for the configuration policy.

* @param deviceId

* The OIM ID of the device to which the configuration policy is

* to be applied.

*/

public void applyConfigurationPolicyToDevice(String configPolicyType,

String configPolicyXml, String deviceId) {

try {

EomTransaction tr = eomSession.openTransaction();

// Set the object attributes for the RuleGeneric object

EomAttributesSet gpAttrs = new EomAttributesSet();

gpAttrs.setAttribute("ContentType", configPolicyType);

gpAttrs.setAttribute("ContentValue", configPolicyXml);

// Configuration Policies is created as a child of an interface.

EomObject loopback0 = getLoopback0ForDevice(deviceId);

30 Service Activator 5.2.4

Page 41: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

EomObject gpObject = tr.createObject(loopback0, "RuleGeneric",

configPolicyType, gpAttrs);

// The configuration policy must have valid device and interface

// roles applied.

EomObject roleDevice = findRole("Gateway", "RoleDevice");

EomObject roleInterface = findRole("Access", "RoleInterface");

tr.linkObjects(gpObject, roleDevice);

tr.linkObjects(gpObject, roleInterface);

// Commit the transaction.

tr.commit();

} catch (EomSessionException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (EomException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

/**

* This example demonstrates how to modify the contents of a configuration

* policy. The policy's XML is read from the RuleGeneric object and parsed

* back into he XMLBean policy definition. The policy is modified using the

* XMLBeans API and the updated XML is used to replace original policy.

*

Service Activator 5.2.4 31

Page 42: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

* @param deviceId

* The OIM ID of the device on whichc the configuration policy is

* to be modified.

*/

public void updateStaticNatEntry(String deviceId) {

try {

// Find the existing Static NAT configuration policy on the device.

EomObject device = eomSession.getObjectByPath(deviceId);

EomSearchIterator interfaceIterator = new EomSearchIterator(

eomSession, device, "RuleGeneric", "child",

new EomIteratorParameters("name", "staticNats"), false);

// Should be just one exact match

EomObject staticNat = (EomObject) interfaceIterator.getFirstItem();

// Construct the configuration policy XMLBean from the RuleGeneric

// XML

StaticNatsDocument staticNatDoc = StaticNatsDocument.Factory

.parse(unescapeFromOIM(staticNat

.getAttribute("ContentValue")));

// Remove the first static NAT entry.

staticNatDoc.getStaticNats().removeStaticNat(0);

// Update the static NAT definitions

staticNatDoc.getStaticNats().getStaticNatArray(0)

.setOutsideIpAddress("10.10.55.1");

// Update the Static NATs policy definition

staticNat.setAttribute("ContentValue", escapeForOIM(staticNatDoc

32 Service Activator 5.2.4

Page 43: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

.toString()));

EomTransaction tr = eomSession.openTransaction();

tr.modifyObject(staticNat);

tr.commit();

} catch (EomSessionException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (EomException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (XmlException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

/**

* Removes a configuration policy from a device. This example assumes that

* the only one instance of the configuration policy type is attached to an

* interface on the device, typically Loopback0.

*

* @param configPolicyType

* the configuration policy type e.g. "staticNats".

* @param deviceId

* The OIM ID of the device to which the configuration policy is

* to be applied.

*/

public void removeStaticNatPolicyFromDevice(String configPolicyType,

String deviceId) {

try {

Service Activator 5.2.4 33

Page 44: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

EomTransaction tr = eomSession.openTransaction();

// Configuration Policies is created as a child of an interface.

EomObject device = eomSession.getObjectByPath(deviceId);

EomSearchIterator policyIterator = new EomSearchIterator(

eomSession, device, "RuleGeneric", "child",

new EomIteratorParameters("ContentType", configPolicyType),

false);

// Should be just one exact match

EomObject policy = (EomObject) policyIterator.getFirstItem();

tr.delete(policy);

// Commit the transaction.

tr.commit();

} catch (EomSessionException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (EomException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

/**

* The XML String has to be padded with extra escape characters around the "

* and ' quote characters.

*/

private static String escapeForOIM(String xml) {

34 Service Activator 5.2.4

Page 45: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

final StringBuffer result = new StringBuffer();

final StringCharacterIterator iterator = new StringCharacterIterator(

xml);

char character = iterator.current();

while (character != StringCharacterIterator.DONE) {

if (character == '\'') {

result.append("\\\'");

} else if (character == '\"') {

result.append("\\\"");

} else {

// the char is not a special one

// add it to the result as is

result.append(character);

}

character = iterator.next();

}

return result.toString();

}

/**

* Remove the extra escape characters around the " and ' characters when

* reading XML back from the OIM.

*/

private static String unescapeFromOIM(String xml) {

String result1 = xml.replaceAll("\\\\\"", "\\\"");

String result2 = result1.replaceAll("\\\\\'", "\\\'");

return result2;

}

private EomObject getLoopback0ForDevice(String deviceId) {

Service Activator 5.2.4 35

Page 46: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

EomObject loopback0 = null;

try {

EomObject device = eomSession.getObjectByPath(deviceId);

EomSearchIterator interfaceIterator = new EomSearchIterator(

eomSession, device, "Interface", "child",

new EomIteratorParameters("name", "Loopback0"), false);

// Should be just one exact match

loopback0 = (EomObject) interfaceIterator.getFirstItem();

} catch (EomSessionException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (EomException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return loopback0;

}

/**

* Find the EomObject instance for a specific Role type.

*

* @param name

* the Role name

* @param type

* the Role type, "RoleDevice" or "RoleInterface"

* @return the EomObject of the Role

* @throws EomSessionException

* @throws EomException

*/

private EomObject findRole(String name, String type)

throws EomSessionException, EomException {

36 Service Activator 5.2.4

Page 47: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

return (EomObject) (new EomSearchIterator(eomSession, eomSession

.getPolicyObject(), type, "child", new EomIteratorParameters(

"name", name), false)).getFirstItem();

}

public static void main(String[] args) {

String deviceId = "[5257]";

try {

eomSession = new EomSession("localhost", (short) 2809);

eomSession.login("orchestream", "orchestream");

StaticNATsConfigurationPolicyExample application = new StaticNATsConfigurationPolicyExample();

// Create the StaticNat configuration policy.

StaticNatsDocument staticNatsDoc = application

.constructStaticNatPolicyDocument();

// Create the StaticNats policy on the target device.

String staticNatsXml = escapeForOIM(staticNatsDoc.toString());

application.applyConfigurationPolicyToDevice("staticNats",

staticNatsXml, deviceId);

// Update the content of the StaticNats definition.

application.updateStaticNatEntry(deviceId);

// Remove the StaticNats configuration policy from the device.

application.removeStaticNatPolicyFromDevice("staticNats", deviceId);

Service Activator 5.2.4 37

Page 48: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

} catch (EomException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

Interface Management Example Source CodeThis section details the complete interface management example source code.

/*

* The following source provides and example of using the service model

* extensions XML Beans API in conjunction with the IPSA OJDL API and

* the interface management configuration policy to create new interfaces

* on a Device

* *

* The following jar files are required by the client to implement to the api:

*

* - servicemodelextensions.jar (from IPSA)

* - ojdl.jar (from IPSA)

* - xbean.jar (from Apache XMLBeans)

* - jsr173.jar (from Apache XMLBeans)

*/

import java.text.StringCharacterIterator;

import com.metasolv.serviceactivator.subinterface.FrSubInterfaceDataDocument;

import com.mslv.osa.ojdl.eom.EomAttributesSet;

import com.mslv.osa.ojdl.eom.EomException;

import com.mslv.osa.ojdl.eom.EomObject;

import com.mslv.osa.ojdl.eom.EomSession;

38 Service Activator 5.2.4

Page 49: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

import com.mslv.osa.ojdl.eom.EomSessionException;

import com.mslv.osa.ojdl.eom.EomTransaction;

/*

* TODO Main level interface creation with caps

*/

public class InterfaceManagementPolicyExample {

// OJDL EOM Session object

static EomSession eomSession;

/**

* Create an interface policy registration.

*/

public void createSubinterfacePolicyRegistration() {

try {

EomTransaction tr = eomSession.openTransaction();

// Set the object attributes for the Interface Policy Registration

// object

String name = "CreateCiscoFrameRelaySerialSubinterface";

EomAttributesSet attributes = new EomAttributesSet();

attributes.setAttribute("GenericPolicyTypeName",

"frSubInterfaceData");

attributes.setAttribute("PolicyType", "Create");

attributes.setAttribute("Context", "Interface");

attributes.setAttribute("ContextPrefix", "Serial");

attributes.setAttribute("ContextSnmpIfType", "32"); // frameRelay(32)

attributes.setAttribute("CreationPrefix", "");

Service Activator 5.2.4 39

Page 50: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

attributes.setAttribute("CreationSnmpIfType", "32"); // frameRelay(32)

attributes.setAttribute("CreationUseParentPrefix", "True");

attributes.setAttribute("Enabled", "True");

attributes.setAttribute("MenuText",

"Frame Relay Serial Subinterface");

attributes.setAttribute("VendorEnterpriseId", "9"); // Cisco

// The registration policy is created as a child of the top

// level /Policy:"Policy" object

EomObject policy = eomSession.getObjectByPath("/Policy:\"Policy\"");

EomObject interfacePolicyRegistration = tr.createObject(policy,

"InterfacePolicyRegistration", name, attributes);

// Commit the transaction.

tr.commit();

} catch (EomSessionException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (EomException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

/**

* Create a new Serial Subinterface. Use the Interface Policy Registration

* to create a new subinterface.

*/

public void createSubInterface() {

40 Service Activator 5.2.4

Page 51: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

try {

String parentInterfaceId = "[4215]";

String parentDeviceId = "[3901]";

String registrationPolicyId = "/Policy:\"Policy\"/InterfacePolicyRegistration:\"CreateCiscoFrameRelaySerialSubinterface\"";

String interfaceRoleId = "/Policy:\"Policy\"/RoleInterface:\"Access\"";

EomObject parentInterface = eomSession

.getObjectByPath(parentInterfaceId);

EomObject registrationPolicy = eomSession

.getObjectByPath(registrationPolicyId);

EomObject interfaceRole = eomSession

.getObjectByPath(interfaceRoleId);

EomTransaction tr = eomSession.openTransaction();

EomAttributesSet attributes = null;

// Create the new subinterface interface object

String subinterfaceName = "Serial1/3.100";

attributes = new EomAttributesSet();

attributes.setAttribute("Type", "32");

EomObject subinterface = tr.createObject(parentInterface,

"Subinterface", subinterfaceName, attributes);

// Link the new subinterface object to the interface policy

// registration

tr.linkObjects(subinterface, registrationPolicy);

tr.commit();

// A new RuleGeneric object for the interface management

// configuration policy is automatically

Service Activator 5.2.4 41

Page 52: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

// created under the subinterface. Create the interface policy

// definition.

EomObject interfaceSettings = eomSession

.getObjectByPath(subinterface.getPath() + "/RuleGeneric:\""

+ subinterfaceName + "-Data\"");

FrSubInterfaceDataDocument interfaceSettingsBean =

FrSubInterfaceDataDocument.Factory.newInstance();

interfaceSettingsBean.addNewFrSubInterfaceData();

interfaceSettingsBean.getFrSubInterfaceData().setDlci(100);

String interfaceSettingsXml = escapeForOIM(interfaceSettingsBean

.toString());

interfaceSettings

.setAttribute("ContentValue", interfaceSettingsXml);

tr.modifyObject(interfaceSettings);

// Link a suitable interface role to the new subinterface.

tr.linkObjects(subinterface, interfaceRole);

tr.commit();

// Optionally rediscover the device the get any VC level objects (in

// this example the DLCI)

eomSession.sendCommandtoOIM("discover " + parentDeviceId);

} catch (EomSessionException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (EomException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

42 Service Activator 5.2.4

Page 53: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Managing Configuration Policies using the OJDL API

/**

* The XML String has to be padded with extra escape characters around the "

* and ' quote characters.

*/

private static String escapeForOIM(String xml) {

final StringBuffer result = new StringBuffer();

final StringCharacterIterator iterator = new StringCharacterIterator(

xml);

char character = iterator.current();

while (character != StringCharacterIterator.DONE) {

if (character == '\'') {

result.append("\\\'");

} else if (character == '\"') {

result.append("\\\"");

} else {

// the char is not a special one

// add it to the result as is

result.append(character);

}

character = iterator.next();

}

return result.toString();

}

/**

* Remove the extra escape characters around the " and ' characters when

* reading XML back from the OIM.

*/

private static String unescapeFromOIM(String xml) {

Service Activator 5.2.4 43

Page 54: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

Managing Configuration Policies using the OJDL API OSS Java Development Library Guide – Third Edition

String result1 = xml.replaceAll("\\\\\"", "\\\"");

String result2 = result1.replaceAll("\\\\\'", "\\\'");

return result2;

}

public static void main(String[] args) {

String deviceId = "[5257]";

try {

eomSession = new EomSession("localhost", (short) 2809);

eomSession.login("orchestream", "orchestream");

InterfaceManagementPolicyExample application = new

InterfaceManagementPolicyExample();

application.createSubinterfacePolicyRegistration();

application.createSubInterface();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

44 Service Activator 5.2.4

Page 55: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition

Index

CClasses 10classes directory 5customer support viii

DDebug levels 11Directories

classes 5doc 5lib 5samples 5

doc directory 5documentation

downloading viiiService Activator ix

EEomAttribute 11EomAttributeSet 11EomConnection 11EomConnectionManager 11EomDebug 11EomDefaultConnection 11EomDifferenceResolver 11EomDiscovery 11EomException 12EomExtendedSearchIterator 12EomIntersectionResolver 12EomIterator 12EomIteratorParameters 12EomNonIntegerException 12EomObject 12EomObjectException 13EomObjectFactory 13EomOimException 13EomResolver 13EomSearchIterator 13

EomSession 14EomSessionException 14EomTransaction 14Exception 13Exceptions 12External Object Model 3

Iindex.htm file 10index.html 8index-all.htm file 10InfoVista 5Installing the OJDL 5, 6

JJ2SE 5, 8Java 2 Platform Standard Edition 8Java classes

EomAttribute 11EomAttributeSet 11EomConnection 11EomConnectionManager 11EomDebug 11EomDefaultConnection 11EomDifferenceResolver 11EomDiscovery 11EomException 12EomExtendedSearchIterator 12EomIntersectionResolver 12EomIterator 12EomIteratorParameters 12EomNonIntegerException 12EomObject 12EomObjectException 13EomOimException 13EomOjbectFactory 13EomResolver 13EomSearchIterator 13

Service Activator 5.2.4 45

Page 56: OSS Java Development Library Guide - OracleService Activator 5.2.4 vii OSS Java Development Library Guide – Third Edition Preface About this document The OSS Java Development Library

OSS Java Development Library Guide – Third Edition Index

EomSession 14EomSessionException 14EomTransaction 14

Java development environment 5, 8Java Development Kit 8Java documentation 5Java execution environment 5JDK 5, 8

Llib directory 5

MManifest.mf file 9

OObject model 4OIM 3OJDL

architecture 3basic toolkit 7, 17installing 5

PPrerequisites 5products

downloading viii

Ssamples directory 5SLA Integration 5Software delivery 5support

customer viiiSystem architecture 3

TThe Java classes 10Tomcat 5Trace levels 11Transactions 14

Service Activator 5.2.4 46