Search in sources :

Example 6 with Event

use of io.vertx.up.atom.agent.Event in project vertx-zero by silentbalanceyh.

the class FilterInquirer method extract.

private Event extract(final String path, final Class<?> clazz) {
    final Event event = new Event();
    event.setPath(path);
    final Annotation annotation = clazz.getAnnotation(Ordered.class);
    int order = Orders.FILTER;
    if (null != annotation) {
        final Integer setted = Instance.invoke(annotation, "value");
        // Order specification
        Fn.flingUp(setted < 0, LOGGER, FilterOrderException.class, this.getClass(), clazz);
        order = order + setted;
    }
    event.setOrder(order);
    // Proxy
    final Object proxy = Instance.singleton(clazz);
    Fn.flingUp(null == proxy, LOGGER, FilterInitialException.class, this.getClass(), clazz);
    event.setProxy(proxy);
    // Action
    final Method action = this.findMethod(clazz);
    event.setAction(action);
    event.setConsumes(new HashSet<>());
    event.setProduces(new HashSet<>());
    return event;
}
Also used : Event(io.vertx.up.atom.agent.Event) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation)

Example 7 with Event

use of io.vertx.up.atom.agent.Event in project vertx-zero by silentbalanceyh.

the class EventExtractor method extract.

@Override
public Set<Event> extract(final Class<?> clazz) {
    return Fn.get(new ConcurrentHashSet<>(), () -> {
        // 1. Class verify
        this.verify(clazz);
        // 2. Check whether clazz annotated with @PATH
        final Set<Event> result = new ConcurrentHashSet<>();
        Fn.safeSemi(clazz.isAnnotationPresent(Path.class), LOGGER, () -> {
            // 3.1. Append Root Path
            final Path path = ZeroHelper.getPath(clazz);
            assert null != path : "Path should not be null.";
            result.addAll(this.extract(clazz, PathResolver.resolve(path)));
        }, () -> {
            // 3.2. Use method Path directly
            result.addAll(this.extract(clazz, null));
        });
        return result;
    }, clazz);
}
Also used : Path(javax.ws.rs.Path) ConcurrentHashSet(io.vertx.core.impl.ConcurrentHashSet) Event(io.vertx.up.atom.agent.Event)

Example 8 with Event

use of io.vertx.up.atom.agent.Event in project vertx-zero by silentbalanceyh.

the class Flower method verifyPureArguments.

private static WebException verifyPureArguments(final Validator verifier, final Depot depot, final Object[] args) {
    final Event event = depot.getEvent();
    final Object proxy = event.getProxy();
    final Method method = event.getAction();
    WebException error = null;
    try {
        if (Virtual.is(proxy)) {
        // TODO: Wait for proxy generation
        // Validation for dynamic proxy
        // final Object delegate = Instance.getProxy(method);
        // verifier.verifyMethod(delegate, method, args);
        } else {
            // Validation for proxy
            verifier.verifyMethod(proxy, method, args);
        }
    } catch (final WebException ex) {
        // Basic validation failure
        error = ex;
    }
    return error;
}
Also used : WebException(io.vertx.up.exception.WebException) Event(io.vertx.up.atom.agent.Event) Method(java.lang.reflect.Method)

Aggregations

Event (io.vertx.up.atom.agent.Event)8 Method (java.lang.reflect.Method)3 ConcurrentHashSet (io.vertx.core.impl.ConcurrentHashSet)2 Annotation (java.lang.annotation.Annotation)2 Path (javax.ws.rs.Path)2 HttpMethod (io.vertx.core.http.HttpMethod)1 HttpServerRequest (io.vertx.core.http.HttpServerRequest)1 HttpServerResponse (io.vertx.core.http.HttpServerResponse)1 Route (io.vertx.ext.web.Route)1 Router (io.vertx.ext.web.Router)1 RoutingContext (io.vertx.ext.web.RoutingContext)1 ED (io.vertx.quiz.example.ED)1 ED1 (io.vertx.quiz.example.ED1)1 WebException (io.vertx.up.exception.WebException)1 Fn (io.vertx.up.func.Fn)1 Annal (io.vertx.up.log.Annal)1 Axis (io.vertx.up.rs.Axis)1 Instance (io.vertx.up.tool.mirror.Instance)1 ZeroAnno (io.vertx.up.web.ZeroAnno)1 EndPointThread (io.vertx.up.web.thread.EndPointThread)1