The component model supported by Microsoft® Visual J++Ö is known as JavaBeans, the Java equivalent of ActiveXÖ. If you choose to develop your component with Visual J++, you will create classes that expose methods. When an ASP script calls your component, it is hosted by the Microsoft Virtual Machine (VM). ActiveX components and JavaBeans are completely integrated in the VM. To a Java programmer, an ActiveX component can be treated as just another JavaBean, and to a Visual Basic programmer, a JavaBean can be treated as an ActiveX component.
One key difference between JavaBeans and ActiveX components is the tool that you use for registration. You register ActiveX components with regsrv32.exe, while you can register JavaBeans with the javareg.exe tool, which is installed with the VM. When you use JavaReg you must specify the Progid switch. For example, the following code creates a Progid
for a Java class called MyClass
.
javareg /register /class:MyClass /progid:MyClasses.FirstClass
Another difference between the two models is that you can create an instance of a JavaBean by using a Java Moniker. A Java Moniker is a name that describes the path of the Java class file to the VM. You use the Java Moniker to create an instance of an object from your component in exactly the same way as a Progid is used with Server.CreateObject. For example, if a Java Bean was defined in the path C:\MyBeans\coolbean.class
, the following script would create an instance of coolbean
.
<%GetObject ("Java:C:\MyBeans\coolbean.class") %>
Notice that when you create an instance of a Java class using a Java Moniker you must use GetObject rather than Server.CreateObject. When you create an object with GetObject, the object will not have access to the ObjectContext object. You should not create an object instance with a Java Moniker if the object needs to access the ASP Built-in Objects or participate in transactions.
As with ActiveX components, you can develop JavaBeans with a dual interface to support v-table access. The Microsoft SDK for Java includes a tool called jactivex.exe which you can use for vtable access to COM interfaces and methods.
Your Java component can access the ASP Built-in objects by calling the Java class files which are created when you install IIS. The classes use native Java types, and support native Java interfaces.You can refer to these classes directly, however, the Java Component Framework (JCF) simplifies creating Active Server Components. The JCF creates new interfaces that expose the ASP object model. The goal is to retain all of the features and flavor of the ASP Programming model, but to expose it in a way that is more natural for the Java programmer.
For more information, see the Java Component Framework Reference!href("/iissamples/sdk/components/java/overview.htm").
For more information on developing JavaBeans, see the Microsoft SDK for Java.