Results 1 to 4 of 4

Thread: Developer

  1. #1
    Mike Yu Guest

    Default Developer

    Hi There,<BR><BR>I am a Java developer but new to asp and com technologies. I have some questions related to these technologies and wonder if anybody can help me out with them:<BR><BR>1. My general impression of this asp -- Java components communication methodology is based on the com object communication technologies. If that&#039s the case, I would assume the Java class must be registered with the window registry. But I can&#039t seem to find this information through either registry or OLE viewer tool (under Java classes). Is the Java component a true com object? I would like to have an insight into how Microsoft jvm magically turns a plain Java class into a com-like (automation) server and enables asp page to instantiate it using getObject() method and make use of it.<BR><BR>2. If I have an asp page calling the Java component and leave the instance alive throughout. I guess the Java component is (for one time) instantiated (via the VBScript getObject() method) and then lives (together with the jvm in which the Java component is instantiated) in the asp application process. How does asp (or perhaps more accurately IIS) handle multiple threads corresponding to requests, and what are some of the issues (if any) when we code the Java components so that it works within IIS/ASP threading model and is also thread safe? My assumption is that the Java component, as a single instance, is being accessed by the same multiple threads in which asp calls come in. In the project I am working on, this Java component serves as kind of a gateway from which requests are made to database or remote middle ware (also written in Java in a servlet environment) for further processing. Thread safety is critical since there are (financial) transacions involved for a given session.<BR><BR>I am not sure if I made my questions clear. I would appreciate it greatly if I could be point in the right direction regarding above issues. Maybe some resources on the web or a good book?Thanks in advance for any advise.<BR><BR>Regards,<BR><BR>Mike <BR><BR>

  2. #2
    Ed Guest

    Default RE: Developer

    There is a decent Java article on 4Guys at:<BR><BR>It shows how to create a simple Java class and have it callable from an ASP page as a COM component.

  3. #3
    Ian Stallings Guest

    Default RE: Developer

    And the follow up article is here:<BR>

  4. #4
    Matt Jacyno Guest

    Default RE: Developer

    Mike,<BR><BR>1. I&#039m not exactly sure what jvc does internally. What I&#039ve done in the past is listed at:<BR><BR>which is different from what Ian&#039s articles outline, in that you have to run javaReg on the class file. I haven&#039t verified it, but you would certainly expect it to show in the registry, and javaReg presumably generates a CLSID and probably a type library as well (although I don&#039t know where it puts it). Maybe if you do it that way, it shows in the OLE Viewer too. I&#039m unclear on it, but I would imagine that it doesn&#039t actually become a COM object per se, but ASP knows how to take the type library and call the supported methods. (I&#039d love some clarification and/or solid documentation on this, myself).<BR><BR>2. There are a few issues here, maybe. Does your object really stay alive across pages? I&#039ll trust you if it does, I&#039m just a little surprised is all. Maybe getObject() sticks it in the vm&#039s sandbox instead of how ASP usually does things (which is sort of scary, but whatever works). At any rate, if the object stays alive across pages, then I&#039ve learned something new. I usually use CreateObject; maybe GetObject is different. (it still might make me nervous)<BR><BR>As to thread safety, well that&#039s a different (and often neglected) animal. I&#039m not sure what threading model ASP will use in communicating with your java class (anyone? Apartment? Maybe you can specify it?), but you may be suffering from either performance problems or thread unsafety, or both.<BR><BR>What I would say is the following:<BR>- You&#039re right about ASP having multiple threads on your single instance, and you&#039re right to be nervous about threading. It IS very possible for performance to suffer and for threads to walk on each other if you&#039re not careful.<BR>- the ONLY way to safely store an object at Session or Application scope (even though it doesn&#039t sound like you&#039re explicitly doing that) and not take big performance hits in the process is to have your component be "Both" threaded AND also to aggregate the Free Threaded Marshaller. MAYBE you can make your java class be threaded that way, but I would expect that you&#039d need to write your components in Visual C++ to do it (Visual Basic won&#039t support anything higher than Apartment threading). (again, anyone know if you can specify java threading models that way, and how ASP treats them?)<BR><BR>(I&#039m slightly oversimplifying when I say that&#039s the only way. Read this article on component agility for more:<BR> Things are a little different in IIS 5, as well.)<BR><BR>But, you probably have a specific reason for using java, and using C++ might not be an option. If that&#039s the case, it would be important to know how you might specify your threading model. Hopefully that&#039s not bad news to you.<BR><BR>Hope this helps, instead of just confusing you more,<BR>Matt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts