Create server event handler by type and handler class

@param type event type
@param clazz handler class
@return a ServerEventHandler object
332209
private ServerEventHandler createServerEventHandler(
			SFSEventType type, Class<?> clazz) {
		try {
			return (ServerEventHandler)
					ReflectClassUtil.newInstance(
					clazz, BaseAppContext.class, context);
		} catch (ExtensionException e) {
		    getLogger().error("Error when create server event handlers", e);
			throw new RuntimeException("Can not create event handler of class "
					+ clazz, e);
		}
	}
603045
public static <TYPE> Provider<TYPE> of(final Class<TYPE> clazz)
    {
        return new ConfigProvider<TYPE>(null, clazz, null);
    }
894265
public URLStreamHandler createURLStreamHandler (String protocol)
    {
        Class<? extends URLStreamHandler> handler = _handlers.get(protocol.toLowerCase());
        if (handler != null) {
            try {
                return handler.newInstance();
            } catch (Exception e) {
                log.warning("Unable to instantiate URLStreamHandler", "protocol", protocol,
                            "cause", e);
            }
        }
        return null;
    }
110697
@Nonnull
  public final HandlerRegistration addMessageHandler( @Nonnull final MessageEvent.Handler handler )
  {
    return _eventBus.addHandler( MessageEvent.getType(), handler );
  }
415023
protected List<HandlerWrapper> createHandlerWrappers(Class<?> type, MessageHandler handler, boolean partialHandler) {
        //check the encodings first
        Encoding encoding = session.getEncoding();
        List<HandlerWrapper> ret = new ArrayList<>(2);
        if (encoding.canDecodeText(type)) {
            ret.add(new HandlerWrapper(FrameType.TEXT, handler, type, true, false));
        }
        if (encoding.canDecodeBinary(type)) {
            ret.add(new HandlerWrapper(FrameType.BYTE, handler, type, true, false));
        }
        if(!ret.isEmpty()) {
            return ret;
        }
        if (partialHandler) {
            // Partial message handler supports only String, byte[] and ByteBuffer.
            // See JavaDocs of the MessageHandler.Partial interface.
            if (type == String.class) {
                return Collections.singletonList(new HandlerWrapper(FrameType.TEXT, handler, type, false, true));
            }
            if (type == byte[].class || type == ByteBuffer.class) {
                return Collections.singletonList(new HandlerWrapper(FrameType.BYTE, handler, type, false, true));
            }
            throw JsrWebSocketMessages.MESSAGES.unsupportedFrameType(type);
        }
        if (type == byte[].class || type == ByteBuffer.class || type == InputStream.class) {
            return Collections.singletonList(new HandlerWrapper(FrameType.BYTE, handler, type, false, false));
        }
        if (type == String.class || type == Reader.class) {
            return Collections.singletonList(new HandlerWrapper(FrameType.TEXT, handler, type, false, false));
        }
        if (type == PongMessage.class) {
            return Collections.singletonList(new HandlerWrapper(FrameType.PONG, handler, type, false, false));
        }
        throw JsrWebSocketMessages.MESSAGES.unsupportedFrameType(type);
    }
376913
function(element, type, handler) {
      var types = type.split(' ');
      for(var t=0; t<types.length; t++) {
        element.addEventListener(types[t], handler, false);
      }
    }
1219523
public JsonRequestHandler getRequestHandler(RequestType pType) {
        JsonRequestHandler handler = requestHandlerMap.get(pType);
        if (handler == null) {
            throw new UnsupportedOperationException("Unsupported operation '" + pType + "'");
        }
        return handler;
    }
446847
public <T> EventHandler<RemoteEvent<T>> getHandler() {
    return new RemoteSenderEventHandler<T>(encoder, transport, executor);
  }
341549
@SuppressWarnings("unchecked")
    protected OptionHandler createOptionHandler(CmdLineParser parser, OptionDef o, Setter setter) {
        checkNonNull(o, "CmdLineParser");
        checkNonNull(o, "OptionDef");
        checkNonNull(setter, "Setter");

        Class<? extends OptionHandler> h = o.handler();
        if(h==OptionHandler.class) {
            // infer the type
            Class<?> t = setter.getType();

            // enum is the special case
            if(Enum.class.isAssignableFrom(t))
                return new EnumOptionHandler(parser,o,setter,t);

            OptionHandlerFactory factory = handlers.get(t);
            if (factory==null)
                throw new IllegalAnnotationError(Messages.UNKNOWN_HANDLER.format(t));

            return factory.getHandler(parser, o, setter);
        } else {
            // explicit handler specified
            return new DefaultConstructorHandlerFactory(h).getHandler(parser, o, setter);
        }
    }
485756
@SuppressWarnings("unchecked")
    public <T> TypeHandler<T> getInstance(Class<?> javaTypeClass, Class<?> typeHandlerClass) {
        if (javaTypeClass != null) {
          try {
            Constructor<?> c = typeHandlerClass.getConstructor(Class.class);
            return (TypeHandler<T>) c.newInstance(javaTypeClass);
          } catch (NoSuchMethodException ignored) {
            // ignored
          } catch (Exception e) {
            throw new TypeException("Failed invoking constructor for handler " + typeHandlerClass, e);
          }
        }
        try {
          Constructor<?> c = typeHandlerClass.getConstructor();
          return (TypeHandler<T>) c.newInstance();
        } catch (Exception e) {
          throw new TypeException("Unable to find a usable constructor for " + typeHandlerClass, e);
        }
      }
984993
public AutoCloseable registerHandler(
      final Class<? extends T> messageType,
      final EventHandler<RemoteMessage<? extends T>> theHandler) {

    this.msgTypeToHandlerMap.put(messageType, theHandler);

    LOG.log(Level.FINER, "Add handler for class: {0}", messageType.getCanonicalName());

    return new SubscriptionHandler<>(messageType, this.unsubscribeClass);
  }
231164
@SuppressWarnings("unchecked")
    public <H extends CompletionHandler> H createAsyncHandler(Class<H> handlerClass) {
        if (handlerClass == null || handlerClass == CompletionHandler.class) return (H) createAsyncHandler();
        return context.loadAsyncHandlerCreator(handlerClass).create(createAsyncHandler());
    }
400258
private static void _registerTypeMapping(WSServer server, Class clazz) {
	if (clazz == null) return;

	if (!isComplexType(clazz)) {
	    if (clazz.isArray()) {
		_registerTypeMapping(server, clazz.getComponentType());
	    }
	    return;
	}
	server.registerTypeMapping(clazz);
	registerTypeMapping(server, clazz);
    }
871352
@Deprecated
  @SuppressWarnings("unchecked")
  private static <E extends LogRecordHandler> E getHandler(Class<E> clazz){
    for(LogRecordHandler cand : handlers){
      if(clazz == cand.getClass()){
        return (E) cand;
      }
    }
    return null;
  }
709528
@SuppressWarnings("unchecked")
    public <E> MessageHandler<? super E> removeSentMessageHandler(Class<E> type) {
        sentMessageHandlerCache.clear();
        return (MessageHandler<? super E>) sentMessageHandlers.remove(type);
    }
339756
public static <T> FastEvent<T> of(Class<T> type, BeanManagerImpl manager, ObserverNotifier notifier, Annotation... qualifiers) {
        ResolvedObservers<T> resolvedObserverMethods = notifier.<T> resolveObserverMethods(type, qualifiers);
        if (resolvedObserverMethods.isMetadataRequired()) {
            EventMetadata metadata = new EventMetadataImpl(type, null, qualifiers);
            CurrentEventMetadata metadataService = manager.getServices().get(CurrentEventMetadata.class);
            return new FastEventWithMetadataPropagation<T>(resolvedObserverMethods, metadata, metadataService);
        } else {
            return new FastEvent<T>(resolvedObserverMethods);
        }
    }
1071874
protected <T> T create(Class<T> type, Map<String, String> config) {
        // Use #doInstantiate so inheriting classes can override it, as #instantiate is static final.
        T instance = doInstantiate(type, config);

        if (instance instanceof AsyncInitialize) {
            asyncInitializeAwaiting.incrementAndGet();
            ((AsyncInitialize) instance).initialize(initResult -> {
                asyncInitializeAwaiting.decrementAndGet();
                if (initResult.isError()) {
                    if (!failed) { // Not already failed before
                        failed = true;
                        if (handler != null)
                            handler.handle(initResult);
                    } else {
                        System.err.println("Failure occurred, but error handler was already invoked: " + initResult.getError().getCause()); //$NON-NLS-1$
                    }
                } else {
                    checkLoadingStatus();
                }
            });
        }

        checkLoadingStatus();
        return instance;
    }