|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.iona.corbautil.ImportExport
This class makes it easy to import and export CORBA object references
via files, the name service or any repository that can be accessed by
command-line utilities. The user calls the importObjRef()
or exportObjRef() methods with a string containing the
instructions.
Format of export instructions
"name_service#path/within/naming/service".
For example, "name_service#foo/bar"
"file#path/to/file".
For example, "file#C:\temp\foo.ior"
"exec#command with an IOR placeholder".
For example, "exec#cmd /c echo IOR > foo.ior"
Another example, "exec#perl script.pl IOR"
"java_class#full.package.name.of.a.java.class".
For example, "java_class#com.iona.corbautil.ImportExportExampleAlgorithm"
Format of import instructions
"name_service#path/within/naming/service".
For example, "name_service#foo/bar"
"file#path/to/file".
For example, "file#C:\temp\foo.ior"
"exec#command that writes a stringified IOR to standard output".
For example, "exec#cmd /c type foo.ior"
Another example, "exec#perl script.pl"
"java_class#full.package.name.of.a.java.class".
For example, "java_class#com.iona.corbautil.ImportExportExampleAlgorithm"
Also, any of the URL formats supported by the ORB product are allowed for import (but not for export) instructions. For example:
"IOR:..."
"corbaloc:..."
"corbaname:..."
Error handling
If any errors occur in importObjRef() or
exportObjRef() then they throw an
ImportExportException that contains a descriptive
error message.
Example of using importObjRef()
import com.iona.corbautil.*;
import org.omg.CORBA.*;
...
class Client
{
static void main(String[] args)
{
org.omg.CORBA.Object tmpObj = null;
Foo fooObj = null;
try {
orb = ORB.init(args, null);
tmpObj = ImportExport.importObjRef(orb, args[1]);
fooObj = FooHelper.narrow(foo);
if (fooObj != null) {
fooObj.someOp();
}
}
catch (ImportExportException ex) {
System.out.println(ex.getMessage());
}
catch (Exception ex) {
System.out.println(ex);
}
orb.destroy();
}
}
Example of using exportObjRef()
import com.iona.corbautil.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;
...
class Server
{
static void main(String[] args)
{
FooImpl fooSv = null;
try {
orb = ORB.init(args, null);
fooSv = ...; // create servant and activate it into a POA
ImportExport.exportObjRef(orb, fooSv._this(), args[1]);
orb.run();
}
catch (ImportExportException ex) {
System.out.println(ex.getMessage());
}
catch (Exception ex) {
System.out.println(ex);
}
orb.destroy();
}
}
| Constructor Summary | |
ImportExport()
|
|
| Method Summary | |
static void |
exportObjRef(org.omg.CORBA.ORB orb,
org.omg.CORBA.Object obj,
java.lang.String instructions)
Exports the object reference using the specified instructions. |
static org.omg.CORBA.Object |
importObjRef(org.omg.CORBA.ORB orb,
java.lang.String instructions)
Imports an object reference, using the specified instructions. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ImportExport()
| Method Detail |
public static void exportObjRef(org.omg.CORBA.ORB orb,
org.omg.CORBA.Object obj,
java.lang.String instructions)
throws ImportExportException
orb - The orb.obj - The objectinstructions - The instructions
ImportExportException
public static org.omg.CORBA.Object importObjRef(org.omg.CORBA.ORB orb,
java.lang.String instructions)
throws ImportExportException
orb - The orb.instructions - The instructions.
ImportExportException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||