Previous Page | Next Page

Understanding com.sas.metadata.remote Interfaces and Classes

Working with the MdFactory Interface

The MdFactory interface instantiates the Java object factory and provides methods for creating and deleting Java objects, for invoking the SAS Java Metadata Interface event-handling interface and messaging mechanisms, and for deleting the object factory.


Instantiating the Object Factory

The object factory is instantiated one time only for a SAS Java Metadata Interface client before any other tasks are performed with the getInstance method:

MdFactory factory = new MdFactoryImpl();

If the object factory does not need to be used in a remote environment--that is, it does not need to be available to remote Java Virtual Machines (JVMs)--you can pass in a "false" value to the constructor. In this way, the factory will behave as if it is running in a local, single JVM environment.


Creating Java Objects

After you have instantiated the object factory and connected to the SAS Metadata Server (using the makeOMRConnection method of the MdOMRConnection interface), you can then use the methods in the MdFactory interface to create objects on the client. MdFactory provides the createComplexMetadataObject method for creating objects. The createComplexMetadataObject method creates a complex object that stores information about a metadata object's attributes and its potential associations. You can use this method to create an object that represents a new or existing object that will be persisted to the SAS Metadata Server.

The following are examples of the createComplexMetadataObject method. A method call that creates a complex object describing a new metadata object has the following form:

MdFactory.createComplexMetadataObject(myNewObjectName, 
                                            metadata_type, 
                                            8char_target_repository_identifier)

A method call that creates a complex object representing an existing object on the SAS Metadata Server has the following form:

MdFactory.createComplexMetadataObject(myNewObjectName,
                                           metadata_type,
                                           identifier_of_existing_metadata_object)

You can get the identifiers of all repositories registered on the SAS Metadata Server by using the getRepositories method of the MdOMIUtil interface. You can get the identifier of an existing object instance by using one of the getMetadataObjects methods of the MdOMIUtil interface. For more information about repository and object instance identifiers, see Identifying Metadata.


Invoking the Event Handling Interface

The MdFactoryListener interface includes the MdFactoryEvent class and the addMdFactoryListener method. MdFactoryListener is a newer version of the SAS 9.1 MdObjectFactoryListener interface, which is deprecated in SAS 9.2.

You can have multiple listeners in a factory. The addMdFactoryListener method can be instantiated either directly before or after the server connection is made. The MdFactoryListener interface notifies other users of the factory every time a metadata object is created, updated, or deleted on the SAS Metadata Server. Notifications are sent when the changes are persisted to the SAS Metadata Server. Users of the factory can use the information to make other changes (for example, to refresh their displays to include the new, modified, or deleted objects).

If a listener is added to a factory, it must be removed at the end of the factory session.


Deleting Objects

To delete an existing metadata object from the SAS Metadata Server, you must create an object that represents it in the SAS Java Metadata Interface client. Then, you delete both the server and client metadata objects by calling the deleteMetadataObjects method of the MdFactory interface. Calling this method removes the object from the server and client, as well as its object store.

A new object that was created on the client and persisted to the SAS Metadata Server can also be deleted from its object store by calling the CMetadata delete method. The CMetadata delete method marks the client object as deleted. The client object is deleted the next time the updateMetadataAll method is called on the object store.


Disposing of the Object Factory

To remove the object factory from memory, use the MdFactory dispose method before closing the client application. The dispose method removes the object factory and any remaining object stores.

Previous Page | Next Page | Top of Page