There has not been any news for more than a week now. I have not been idleing the whole time
. Mostly I’ve been battling with Quercus, trying once more the PHP/Java Bridge and waiting for my mentor to get back from a week of vacation which he deserved and is back from
. One of the main tasks for last week (that i failed) was making an initial release but I was able to run into showstopper bugs. I wanted the release to have at least one feature/example that I find sexy. No luck
. I’ll give you an idea what I have been trying.
First up is using MySQL or PostgreSQL through the JSR223 PHP ScriptEngine.
mysql_connect("host", "username", "password");
mysql_select_db("databasename");
$result = mysql_query("select * from test");
while($arr=mysql_fetch_assoc($result)) {
print_r($arr);
}
Currently this produces an error (com.caucho.quercus.QuercusModuleException: Can’t find database for driver). I’ve documented the issue in the bug report. I tried different Quercus versions (currently running trunk). I even tried PostgreSQL. No luck. Although Quercus is a JSR223 ScriptEngine it is developed to run in a web container. The Servlet initializing the QuercusScriptEngine takes care of some configurations that don’t come out-of-the-box when using it as a ScriptEngine.
Secondly I thought it would be nice to do some image manipulation.
$im = @imagecreate(110, 20)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
This should produce the following image:
. Sample is taken from PHP Manual. But I get a java.io.CharConversionException: illegal utf8 encoding. The underlying OutputStream, in this case com.caucho.vfs.ReaderWriterStream insists on checking the bytes of the image for being UTF8. I’ve filed a bug report.
Thirdly I thought of incorporating some PHP into my plugin. I’ve been working on using PHP through annotations and reflection. So that the user would have something along the lines:
@ScriptableAnnotation(
fileName="org/eclipse/soc2007/php/ScriptablePlugin.php",
functionName="getVersion()")
public String getVersion(String rtrn) {
return rtrn;
}
Currently I’m registering a dynamic proxy for the interface of this class. The proxy will invoke the method and the give for the argument the return value of calling getVersion() from ScriptablePlugin.php. Cumbersome :/. I was not able to get this sample to work either. During the initialization I started getting org.osgi.framework.BundleException. Supposedly it is avoiding deadlock and has set time limits on the loading process. ScriptEngine creation takes some time. I’ve been initing the ScriptEngine in a popup menu and this has not happened before so I don’t have a clear answer why this is happening. But still as all plugins are lazily loaded then it is imporant where I put it.
I’m sure I won’t be able to find solutions to all of these problems this week, I’ll still make a release in couple of days. I’ve imported my project to eclipse-incub@sourceforge.net and working on getting the first version out. Stay tuned