New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can instantiate Interfaces behind a dynamic Proxy #281

Closed
hdsdi3g opened this Issue Jul 12, 2017 · 1 comment

Comments

@hdsdi3g
Owner

hdsdi3g commented Jul 12, 2017

For future devs, like instantiate interfaces with a Javascript function set.

@hdsdi3g hdsdi3g added the enhancement label Jul 12, 2017

@hdsdi3g hdsdi3g added this to the v0 Beta version milestone Jul 12, 2017

@hdsdi3g hdsdi3g self-assigned this Jul 12, 2017

hdsdi3g added a commit that referenced this issue Jul 12, 2017

@hdsdi3g

This comment has been minimized.

Show comment
Hide comment
@hdsdi3g

hdsdi3g Jul 12, 2017

Owner

Demo code:

import hd3gtv.mydmam.factory.Factory;

public static interface MessageHandler {
	String handle(String message);
}
	
public static void main(String[] args) throws Exception {
	MessageHandler ma = Factory.instanceDynamicProxy(MessageHandler.class, (method, arguments) -> {
		return ((String) arguments[0]).toUpperCase();
	});
	System.out.println(ma.handle("toto2"));
}

Return TOTO2

Owner

hdsdi3g commented Jul 12, 2017

Demo code:

import hd3gtv.mydmam.factory.Factory;

public static interface MessageHandler {
	String handle(String message);
}
	
public static void main(String[] args) throws Exception {
	MessageHandler ma = Factory.instanceDynamicProxy(MessageHandler.class, (method, arguments) -> {
		return ((String) arguments[0]).toUpperCase();
	});
	System.out.println(ma.handle("toto2"));
}

Return TOTO2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment