View Full Version : Passing Java object reference into Quercus

08-12-2011, 06:47 PM

I'm trying to integrate Quercus with NetKernel. This means taking control of Quercus outside the context of the supplied servlet. I've been mostly successful so far but one problem I've struggled with but found a hacky solution for is passing a Java object into the environment to made available to the executing php as a global variable.

I've searched the docs but not found a solution. This the hacky code I've got:

MyClass myObj;
ModuleContext mc=new ModuleContext(null, getSpace().getClassLoader());
JavaClassDef jcd=new JavaClassDef(mc, "MyClass", MyClass.class);
Collection c = new ArrayList();
JavaAdapter ja=new JavaCollectionAdapter(c,jcd);
JavaAdapterVar jav= new JavaAdapterVar(ja,StringValue.create("dummy value"));
env.setGlobalValue("myObj", jav);

Is there a better/easier/safer way to do this?