Search in sources :

Example 1 with ThreadLocalInvoker

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);
        }
    });
}
Also used : Broadcaster(org.atmosphere.runtime.Broadcaster) Method(java.lang.reflect.Method) ThreadLocalInvoker(org.atmosphere.util.ThreadLocalInvoker)

Aggregations

Method (java.lang.reflect.Method)1 Broadcaster (org.atmosphere.runtime.Broadcaster)1 ThreadLocalInvoker (org.atmosphere.util.ThreadLocalInvoker)1