Service Registry 3 2005Q4 Developer's Guide

Creating an Extrinsic Object

To create an ExtrinsicObject, you first need to create a javax.activation.DataHandler object for the repository item. The LifeCycleManager.createExtrinsicObject method takes a DataHandler argument.


Note –

You can also use an implementation-specific form of the createExtrinsicObject method that takes no arguments. If you use this form, you can create the DataHandler object later and use the ExtrinsicObject.setRepositoryItem method to specify the repository item. You can also create extrinsic objects that have no associated repository items.


To store a file in the repository, for example, first create a java.io.File object. From the File object, create a javax.activation.FileDataSource object, which you use to instantiate the DataHandler object.

String filename = "./MyFile.xml";
File repositoryItemFile = new File(filename);
DataHandler repositoryItem =
     new DataHandler(new FileDataSource(repositoryItemFile));

Next, call createExtrinsicObject with the DataHandler as argument:

ExtrinsicObject eo =
     blcm.createExtrinsicObject(repositoryItem);
eo.setName("My Graphics File");

Set the MIME type of the object to make the object accessible. The default MIME type is application/octet-stream. If the file is an XML file, set the MIME type as follows:

eo.setMimeType("text/xml");

Finally, call the implementation-specific ExtrinsicObjectImpl.setObjectType method to store the ExtrinsicObject in an appropriate area of the Registry. This method has the following signature:

public void setObjectType(Concept objectType)
    throws JAXRException

The easiest way to find the appropriate concept for a particular type of file is to use the Explore feature of the Web Console. Look under the ObjectType classification scheme for the various types of ExtrinsicObject concepts. Specify the ID for the concept as the argument to getRegistryObject, then specify the concept as the argument to setObjectType.

String conceptId =
"urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExtrinsicObject:XML";
Concept objectTypeConcept =
     (Concept) bqm.getRegistryObject(conceptId);
((ExtrinsicObjectImpl)eo).setObjectType(objectTypeConcept);

Finally, you save the ExtrinsicObject to the Registry.

Collection extobjs = new ArrayList();
extobjs.add(eo);
BulkResponse response = blcm.saveObjects(extobjs);

The ExtrinsicObject contains the metadata, and a copy of the file is stored in the repository.

If the Registry does not have a concept for the kind of file that you want to store there, you can create and save the concept yourself.

Creating an Extrinsic Object: Example

For an example of creating an extrinsic object, see JAXRPublishExtrinsicObject.java in the directory <INSTALL>/registry/samples/publish-extrinsic/src. This example publishes an XML file to the Registry (its own build.xml file).

ProcedureTo Run the JAXRPublishExtrinsicObject Example

Steps
  1. Go to the directory <INSTALL>/registry/samples/publish-extrinsic.

  2. Type the following command:


    asant run