Chapter 34 Creating and Using Jaguar Pseudocomponents
To instantiate a pseudocomponent, call the ORB.object_to_string method, passing a URL that specifies the information required to load the component. Java, C++, and ActiveX all use a variation of this method.
The object URL for a pseudocomponent specifies the shared library file or Java class that contains the implementation, the Jaguar package name, and the Jaguar component name.
To identify a C++ pseudocomponent, format a URL as follows:
pseudo://cpp/library/package/componentWhere:
mypseudo
to indicate
a file named mypseudo.dll. The location of
the library must be specified in the system's library search
path.
To identify a Java pseudocomponent, format a URL as follows:
pseudo://java/java-package/jaguar-package/componentWhere:
com.sybase.sample
as
the Java package name. The code base under which the class is deployed
must be specified in the CLASSPATH.
Java applications or Jaguar Java components can instantiate pseudocomponents implemented in Java or C++. Java applets cannot instantiate pseudocomponents. In order to instantiate a C++ pseudocomponent, the environment for a Java application must include all the settings required by the Jaguar C++ client runtime, and the location of the library must be specified in the system's library search path. Java stub classes for the pseudocomponent must be available.
You can instantiate a pseudocomponent any time after initializing and instantiating an ORB instance. Call the ORB.string_to_object method, passing a URL formatted as described in "Pseudocomponent object URLs". Narrow the returned object to an interface supported by the component. See Chapter 13, "Creating CORBA-Compatible Java Clients" for more information on the ORB interface and narrowing objects to an interface.
The following fragment instantiates a pseudocomponent proxy for a C++ component in the DLL CppPseudo.dll that is installed in the package Demo and has component name PseudoCpp. The returned object is narrowed to Arithmetic interface. On UNIX platforms, this syntax also works for a shared library with base name "CppPseudo", as in CppPseudo.so.
String url = "pseudo://cpp/CppPseudo/Demo/PseudoCPP";
_comp = ArithmeticHelper.narrow(
orb.string_to_object(url) );
The following fragment instantiates a pseudocomponent proxy for a Java component. The implementation class and skeleton class are in the Java package Sample.PseudoComponents. The component is installed in the Jaguar package Demo and has component name PseudoJava. The returned object is narrowed to Arithmetic interface.
String url = "pseudo://java/Sample.PseudoComponents/Demo/PseudoJava";
_comp = ArithmeticHelper.narrow(
orb.string_to_object(url) );
C++ standalone programs or Jaguar components can instantiate pseudocomponents implemented in C++. Pseudocomponents implemented in Java can be instantiated only by C++ components that are executing in a Jaguar server.
In order to instantiate a C++ pseudocomponent in a standalone program, the environment must include all the settings required by the Jaguar C++ client runtime, and the location of the library must be specified in the system's library search path.
You can instantiate a pseudocomponent any time after initializing and instantiating an ORB instance. Call the ORB.string_to_object method, passing a URL formatted as described in "Pseudocomponent object URLs". Narrow the returned object to an interface supported by the component. See Chapter 17, "Creating CORBA C++ Clients" for more information on the ORB interface and narrowing objects to an interface.
The following fragment instantiates a pseudocomponent proxy for a C++ component in the DLL CppPseudo.dll that is installed in the package Demo and has component name PseudoCpp. The returned object is narrowed to PseudocomponentDemo::Arithmetic interface. On UNIX platforms, this syntax also works for a shared library with base name "CppPseudo", as in CppPseudo.so.
String url = "pseudo://cpp/CppPseudo/Demo/PseudoCPP";
obj = orb->string_to_object(url);
PseudocomponentDemo::Arithmetic_var arith =
PseudocomponentDemo::Arithmetic::_narrow(obj);
The following fragment instantiates a pseudocomponent proxy for a Java component. The implementation class and skeleton class are in the Java package Sample.PseudoComponents. The component is installed in the Jaguar package Demo and has component name PseudoJava. The returned object is narrowed to PseudocomponentDemo::Arithmetic interface.
String url = "pseudo://java/Sample.PseudoComponents/Demo/PseudoJava";
obj = orb->string_to_object(url);
PseudocomponentDemo::Arithmetic_var arith =
PseudocomponentDemo::Arithmetic::_narrow(obj);
Once loaded in your debugger, a C++ pseudocomponent can be debugged like any other shared library or DLL. However, since the library is not loaded until a client program instantiates the pseudocomponent, setting breakpoints is tricky. The procedure below allows you to set breakpoints and step into your method code.
Debugging a C++ pseudocomponent
dbx $JAGUAR/devbin/jagsrv ServerName
msdev %JAGUAR%\devbin\jagsrv ServerName
void jag_client_dbg_stop(char *compName)
Make sure the jag_client_dbg_stop breakpoint is set before your client application instantiates any pseudocomponents.
Copyright © 2000 Sybase, Inc. All rights reserved. |