You are here: Re: PHP combined with JAVA « PHP « IT news, forums, messages
Re: PHP combined with JAVA

Posted by Oliver Grδtz on 09/16/05 03:39

If I read this correctly then your question is in no way JAVA-specific.
You want to instantiate an object (which you suppose to be of large size
and slow in instantiation) and save this object in the session during
page requests.

First of all, any data put in the session array will be serialized
(read: converted into a string containing all the data in this object).
This in itself is slow for large objects. A performance gain for large
objects through using a session isn't likely.

The second problem with this - and this is the point where JAVA kicks in
- not all data in objects is serializable. The Java-API of PHP is just
some kind of adapter to the Java system. If you serialize an adapter
object then your adapter is saved but not the Java object it uses
(because PHP has no control over it). Think of the Java API as some kind
of socket connection where you only see the stuff on your side (the
client side) and the JAVA object on the "server" side is not under your
control but just used.

What happens is: you save you adapter object and the script terminates.
The JAVA VM notices that an object is no longer referenced and it is
thrown away by the garbage collection.

What could you do? Well, you could use it the other way round (Servlet
uses PHP), because then you control the JAVA side. Or you still do it
the way you do it now but write some clever JAVA code that keeps running
and retains your objects. You give those objects a name known to both
the PHP and JAVA side and this name can be serialized. You can then
re-reference any object on the next page request by its name.

AllOLLi
____________
Jayne spits a large glob of saliva on his blade,
wipes it on his shirt, shining it.
"Could you NOT do that while we're.... ever!"
[Simon on firefly 09]

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация