Exemple #1
0
bool SunJVMDLL::run(const std::string& mainclass, bool waitDeath)
{
  if (m_statusCode == SunJVMDLL::JVM_NOT_STARTED)
    instanciate();

  if (m_statusCode == SunJVMDLL::JVM_LOADED)
    {
      JClassProxy disp(this, mainclass);
      jstring emptystr = newUTFString(std::string(""));  
      jobjectArray mainargs = newObjectArray(m_arguments.size(), "java.lang.String", emptystr);
      for (int i =0; i<m_arguments.size(); i++)
	  {
	    env()->SetObjectArrayElement(mainargs, i, newUTFString(m_arguments[i]));
	  }
	printf("arguments array = %d\n", mainargs);
	jvalue ma[1];
	ma[0].l = mainargs;
	disp.invokeStatic(std::string("void main(java.lang.String[] args)"), ma);
	if (waitDeath == true)
	  m_javavm->DestroyJavaVM();
	return true;
    }

  return false;
}
Exemple #2
0
    bool ModJsonRpc::execute(HttpdConnection& i_connection)
    {
        i_connection.lockHttpd();
        if(this->_mod!=NULL){
            i_connection.unlockHttpd();
            return false;
        }
        this->_mod=(TcJsonRpcEx_t*)malloc(sizeof(TcJsonRpcEx_t));
        i_connection.unlockHttpd();
        if(this->_mod==NULL){
            return false;
        }
        this->_mod->cppmod_ptr=this;

        //initialize websocket
        NyLPC_cModJsonRpc_initialize(&(this->_mod->super),this->_path,this->_rpc_table);
        if(NyLPC_cModJsonRpc_canHandle(&(this->_mod->super),i_connection._ref_inst)){
            if(NyLPC_cModJsonRpc_execute(&(this->_mod->super),i_connection._ref_inst)){
                //initialize object array
                this->_objects=newObjectArray();
                return true;
            }
        }
        NyLPC_cModJsonRpc_finalize(&(this->_mod->super));
        free(this->_mod);
        i_connection.lockHttpd();
        this->_mod=NULL;
        i_connection.unlockHttpd();
        return false;
    }
Exemple #3
0
jobjectArray  SunJVMDLL::newObjectArray(int size, const std::string& classname, jobject initialValue)
{
  jclass cls = findClass(classname);
  return newObjectArray(size, cls, initialValue);
}