Examples of Invoker


Examples of org.apache.sirona.reporting.web.handler.internal.Invoker

        final String requestURI = httpRequest.getRequestURI();
        final String path = buildMatchablePath(httpRequest, baseUri, requestURI, true);
        final String pathWithoutParams = buildMatchablePath(httpRequest, baseUri, requestURI, false);

        // find the matching invoker
        Invoker invoker = defaultInvoker;
        Matcher matcher = null;

        for (final Map.Entry<Pattern, Invoker> entry : invokers.entrySet()) {
            final Pattern pattern = entry.getKey();
            if ((matcher = pattern.matcher(path)).matches()) {
                invoker = entry.getValue();
                if (!entry.getKey().pattern().endsWith(".*")) {
                    break;
                }
            } else if ((matcher = pattern.matcher(pathWithoutParams)).matches()) {
                invoker = entry.getValue(); // continue since that's a not perfect matching
            }
        }

        // handle Content-Type, we could use a map but this is more efficient ATM and can still be overriden
        boolean skipFiltering = false;
        if (requestURI.endsWith(".css")) {
            httpResponse.setHeader(CONTENT_TYPE, "text/css");
        } else if (requestURI.endsWith(".js")) {
            httpResponse.setHeader(CONTENT_TYPE, "application/javascript");
        } else if (requestURI.endsWith(".png")) {
            httpResponse.setHeader(CONTENT_TYPE, "image/png");
            skipFiltering = true;
        } else if (requestURI.endsWith(".gif")) {
            httpResponse.setHeader(CONTENT_TYPE, "image/gif");
            skipFiltering = true;
        } else if (requestURI.endsWith(".jpg")) {
            httpResponse.setHeader(CONTENT_TYPE, "image/jpeg");
            skipFiltering = true;
        } else if (requestURI.endsWith(".svg")) {
            httpResponse.setHeader(CONTENT_TYPE, "image/svg+xml");
            skipFiltering = true;
        } else if (requestURI.endsWith(".eot")) {
            httpResponse.setHeader(CONTENT_TYPE, "application/vnd.ms-fontobject");
            skipFiltering = true;
        } else if (requestURI.endsWith(".woff")) {
            httpResponse.setHeader(CONTENT_TYPE, "application/font-woff");
            skipFiltering = true;
        } else if (requestURI.endsWith(".ttf") || requestURI.endsWith(".itf")) {
            httpResponse.setHeader(CONTENT_TYPE, "application/octet-stream");
            skipFiltering = true;
        }

        // resource, they are in the classloader and not in the webapp to ease the embedded case
        if (pathWithoutParams.startsWith("/resources/")) {
            byte[] bytes = cachedResources.get(pathWithoutParams);
            if (bytes == null) {
                final InputStream is;
                if (!skipFiltering && invoker != defaultInvoker) { // resource is filtered so filtering it before caching it
                    final StringWriter writer = new StringWriter();
                    final PrintWriter printWriter = new PrintWriter(writer);
                    invoker.invoke(httpRequest, HttpServletResponse.class.cast(Proxy.newProxyInstance(classloader, new Class<?>[]{HttpServletResponse.class}, new InvocationHandler() {
                        @Override
                        public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
                            if ("getWriter".equals(method.getName())) {
                                return printWriter;
                            }
                            return method.invoke(httpResponse, args);
                        }
                    })), null);
                    is = new ByteArrayInputStream(writer.toString().getBytes());
                } else {
                    is = classloader.getResourceAsStream(pathWithoutParams.substring(1));
                }

                if (is != null) {
                    ByteArrayOutputStream baos = ByteArrayOutputStream.class.cast(request.getAttribute("resourceCache"));
                    if (baos == null) {
                        baos = new ByteArrayOutputStream();
                        int i;
                        while ((i = is.read()) != -1) {
                            baos.write(i);
                        }
                    }

                    bytes = baos.toByteArray();
                    cachedResources.put(pathWithoutParams, bytes);
                }
            }
            if (bytes != null) {
                if (bytes.length == 0) {
                    httpResponse.setStatus(404);
                } else {
                    httpResponse.getOutputStream().write(bytes);
                }
                return;
            }
        }

        // delegate handling to the invoker if request is not a resource
        if (invoker == null) {
            error(response, null);
        } else {
            try {
                invoker.invoke(httpRequest, httpResponse, matcher);
            } catch (final Exception e) {
                error(response, e);
            }
        }
    }

Examples of org.apache.tuscany.sca.invocation.Invoker

        // that it's an implementation.resource
        RuntimeComponentService componentService = (RuntimeComponentService) service;
        RuntimeWire wire = componentService.getRuntimeWire(binding);
       
        // Get the getLocationURL invoker
        Invoker getLocationInvoker = null;
        for (InvocationChain invocationChain : wire.getInvocationChains()) {
            String operationName = invocationChain.getSourceOperation().getName();
            if (operationName.equals("getLocationURL")) {
                getLocationInvoker = invocationChain.getHeadInvoker();
            }
        }
        if (getLocationInvoker == null) {
            throw new IllegalStateException("No getLocationURL operation found on target component");
        }

        // Get the location URL
        Message message = messageFactory.createMessage();
        message = getLocationInvoker.invoke(message);
        URL locationURL = message.getBody();
       
        // If resource is a file, register the parent dir
        try {
            if( locationURL.getProtocol().equals("file")) {

Examples of org.apache.tuscany.sca.invocation.Invoker

       
        Interface serviceInterface = operation.getInterface();
        boolean isRemotable = serviceInterface.isRemotable();


        Invoker invoker = new OSGiTargetInvoker(operation, this, service);
        if (isRemotable) {
            return new OSGiRemotableInvoker(osgiAnnotations, dataBindingRegistry, operation, this, service);
        } else {
            return invoker;
        }

Examples of org.apache.tuscany.sca.invocation.Invoker

            return;
        }

        // Get the invokers for the supported operations
        Servlet servlet = null;
        Invoker bindingInvoker = bindingChain.getHeadInvoker();
        bindingListenerServlet = new RESTBindingListenerServlet(binding, bindingInvoker, messageFactory);
        for (InvocationChain invocationChain : endpoint.getInvocationChains()) {

            Operation operation = invocationChain.getTargetOperation();
            Invoker serviceInvoker = invocationChain.getHeadInvoker();
            String operationName = operation.getName();

            if (binding.getOperationSelector() != null || binding.getRequestWireFormat() != null) {
                bindingListenerServlet.setInvoker(serviceInvoker);
                servlet = bindingListenerServlet;

Examples of org.apache.tuscany.sca.invocation.Invoker

        bindingListenerServlet = new HTTPBindingListenerServlet(binding, messageFactory );
        for (InvocationChain invocationChain : endpoint.getInvocationChains()) {
            Operation operation = invocationChain.getTargetOperation();
            String operationName = operation.getName();
            if (operationName.equals("get")) {
                Invoker getInvoker = invocationChain.getHeadInvoker();
                bindingListenerServlet.setGetInvoker(getInvoker);
                servlet = bindingListenerServlet;
            } else if (operationName.equals("conditionalGet")) {
                Invoker conditionalGetInvoker = invocationChain.getHeadInvoker();
                bindingListenerServlet.setConditionalGetInvoker(conditionalGetInvoker);
                servlet = bindingListenerServlet;
            } else if (operationName.equals("delete")) {
                Invoker deleteInvoker = invocationChain.getHeadInvoker();
                bindingListenerServlet.setDeleteInvoker(deleteInvoker);
                servlet = bindingListenerServlet;
            } else if (operationName.equals("conditionalDelete")) {
                Invoker conditionalDeleteInvoker = invocationChain.getHeadInvoker();
                bindingListenerServlet.setConditionalDeleteInvoker(conditionalDeleteInvoker);
                servlet = bindingListenerServlet;
            } else if (operationName.equals("put")) {
                Invoker putInvoker = invocationChain.getHeadInvoker();
                bindingListenerServlet.setPutInvoker(putInvoker);
                servlet = bindingListenerServlet;
            } else if (operationName.equals("conditionalPut")) {
                Invoker conditionalPutInvoker = invocationChain.getHeadInvoker();
                bindingListenerServlet.setConditionalPutInvoker(conditionalPutInvoker);
                servlet = bindingListenerServlet;
            } else if (operationName.equals("post")) {
                Invoker postInvoker = invocationChain.getHeadInvoker();
                bindingListenerServlet.setPostInvoker(postInvoker);
                servlet = bindingListenerServlet;
            } else if (operationName.equals("conditionalPost")) {
                Invoker conditionalPostInvoker = invocationChain.getHeadInvoker();
                bindingListenerServlet.setConditionalPostInvoker(conditionalPostInvoker);
                servlet = bindingListenerServlet;
            } else if (operationName.equals("service")) {
                Invoker serviceInvoker = invocationChain.getHeadInvoker();
//                servlet = new HTTPServiceListenerServlet(binding, serviceInvoker, messageFactory);
                break;
            }
        }
        if (servlet == null) {

Examples of org.apache.tuscany.sca.invocation.Invoker

        if (target != null) {
            msg.setTo(target);
        } else {
            msg.setTo(wire.getTarget());
        }
        Invoker headInvoker = chain.getHeadInvoker();
        Operation operation = chain.getTargetOperation();
        msg.setOperation(operation);
        msg.setBody(args);

        Message msgContext = ThreadMessageContext.getMessageContext();
        Object currentConversationID = msgContext.getFrom().getReferenceParameters().getConversationID();

        conversationPreinvoke(msg, wire);
        handleCallback(msg, wire, currentConversationID);
        ThreadMessageContext.setMessageContext(msg);
        try {
            // dispatch the wire down the chain and get the response
            Message resp = headInvoker.invoke(msg);
            Object body = resp.getBody();
            if (resp.isFault()) {
                throw (Throwable)body;
            }
            return body;

Examples of org.apache.tuscany.sca.invocation.Invoker

                                       InvocationChain chain,
                                       Operation operation) {
        try {
            ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding);
            if (provider != null) {
                Invoker invoker = provider.createInvoker(operation);
                if (invoker != null) {
                    chain.addInvoker(invoker);
                }
            }
        } catch (RuntimeException e) {

Examples of org.apache.tuscany.sca.invocation.Invoker

                                              ComponentService service,
                                              InvocationChain chain,
                                              Operation operation) {
        ImplementationProvider provider = ((RuntimeComponent)component).getImplementationProvider();
        if (provider != null) {
            Invoker invoker = null;
            invoker = provider.createInvoker((RuntimeComponentService)service, operation);
            chain.addInvoker(invoker);
        }
    }

Examples of org.apache.tuscany.sca.invocation.Invoker

    public void addInterceptor(Interceptor interceptor) {
        invokers.add(interceptor);
        int index = invokers.size() - 1;
        if (index - 1 >= 0) {
            Invoker before = invokers.get(index - 1);
            if (before instanceof Interceptor) {
                ((Interceptor)before).setNext(interceptor);
            }
        }
    }

Examples of org.apache.tuscany.sca.invocation.Invoker

    public void addInvoker(Invoker invoker) {
        invokers.add(invoker);
        int index = invokers.size() - 1;
        if (index - 1 >= 0) {
            Invoker before = invokers.get(index - 1);
            if (before instanceof Interceptor) {
                ((Interceptor)before).setNext(invoker);
            }
        }
    }
TOP
Copyright © 2018 www.massapi.com. 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.