use of org.atmosphere.util.ThreadLocalInvoker in project atmosphere by Atmosphere.
the class BroadcasterIntrospector method injectable.
@Override
public Broadcaster injectable(AtmosphereResource r) {
String named = nameLocal.get();
if (named == null) {
named = Broadcaster.ROOT_MASTER;
}
String s = (String) r.getRequest().getAttribute(Named.class.getName());
int indx = named.indexOf("{");
if (s != null && indx != -1) {
named = named.substring(0, indx) + s;
}
final Broadcaster broadcaster = r.getAtmosphereConfig().getBroadcasterFactory().lookup(named, true);
return (Broadcaster) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { Broadcaster.class }, new ThreadLocalInvoker() {
{
set(broadcaster);
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return method.invoke(broadcaster, args);
}
});
}
Aggregations