Package org.atmosphere.config.service

Examples of org.atmosphere.config.service.ManagedService


    protected AnnotatedProxy proxyHandler() throws IllegalAccessException, InstantiationException {
        return config.framework().newClassInstance(AnnotatedProxy.class, ManagedAtmosphereHandler.class);
    }

    protected ManagedAnnotation managed(AnnotatedProxy ap, AtmosphereResource r){
        final ManagedService a = ap.target().getClass().getAnnotation(ManagedService.class);
        if (a == null) return null;

        return new ManagedAnnotation(){
            @Override
            public String path() {
                return a.path();
            }

            @Override
            public Class<? extends Broadcaster> broadcaster() {
                return a.broadcaster();
            }
        };
    }
View Full Code Here


    @Override
    public void handle(AtmosphereFramework framework, Class<Object> annotatedClass) {
        try {
            Class<?> aClass = annotatedClass;
            ManagedService a = aClass.getAnnotation(ManagedService.class);
            framework.setBroadcasterCacheClassName(a.broadcasterCache().getName());

            List<AtmosphereInterceptor> l = new LinkedList<AtmosphereInterceptor>();

            atmosphereConfig(a.atmosphereConfig(), framework);
            filters(a.broadcastFilters(), framework);

            AtmosphereInterceptor aa = listeners(a.listeners(), framework);
            if (aa != null) {
                l.add(aa);
            }

            Object c = framework.newClassInstance(Object.class, aClass);
            AtmosphereHandler handler = framework.newClassInstance(ManagedAtmosphereHandler.class,
                    ManagedAtmosphereHandler.class).configure(framework.getAtmosphereConfig(), c);
            // MUST BE ADDED FIRST, ALWAYS!
            l.add(framework.newClassInstance(AtmosphereInterceptor.class, ManagedServiceInterceptor.class));

            framework.filterManipulator(new BroadcasterConfig.FilterManipulator() {
                @Override
                public Object unwrap(Object o) {
                    if (o != null && ManagedAtmosphereHandler.Managed.class.isAssignableFrom(o.getClass())) {
                        o = ManagedAtmosphereHandler.Managed.class.cast(o).object();
                    }
                    return o;
                }

                @Override
                public BroadcastFilter.BroadcastAction wrap(BroadcastFilter.BroadcastAction a, boolean wasWrapped) {
                    if (wasWrapped) {
                        return new BroadcastFilter.BroadcastAction(a.action(), new ManagedAtmosphereHandler.Managed(a.message()));
                    } else {
                        return a;
                    }
                }
            });

            AnnotationUtil.defaultInterceptors(framework, l);
            AnnotationUtil.interceptors(framework, a.interceptors(), l);
            framework.addAtmosphereHandler(a.path(), handler, broadcaster(framework, a.broadcaster(), a.path()), l);
        } catch (Throwable e) {
            logger.warn("", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.atmosphere.config.service.ManagedService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.