lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Jarrod,

There are several ways to write business logic in Lua.
Here I present just one way, implementing a java interface in Lua.


////////////////////////////////////////////////////
// IBusinessLogic.java
public interface IBusinessLogic {
	public void doLogic ();
}


----------------------------------------------------
-- LuaLogic.lua
local logic = {}
function logic.doLogic ()
	print("hello from logic written in Lua")
End
return logic



/////////////////////////////////////////////////////
// LuaJavaTest.java
public class LuaJavaTest {

	public static void main(String[] args) throws
ClassNotFoundException, LuaException {
		LuaState l = LuaStateFactory.newLuaState();
		l.doFile("LuaLogic.lua");
		LuaObject logic = l.getLuaObject(-1);
		IBusinessLogic jlogic = (IBusinessLogic)
logic.createProxy("IBusinessLogic");
		jlogic.doLogic();
		l.pop(1);
	}
}



> I am evaluating using LuaJava 5.0 and just can't seem to find 
> any concrete practical examples on how it might be used.
> 
> I want to be able to script some very simple business logic 
> using lua instead using native Java and having to recompile 
> and redeploy my application just to add a simple if..then 
> type condition.
> 
> Any help would be appreciated!