Package org.mule.api.endpoint

Examples of org.mule.api.endpoint.EndpointURI


        assertEquals("testMethod", url.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
    }

    public void testQueryParams2() throws Exception
    {
        EndpointURI url = new MuleEndpointURI(
            "jnp://localhost:1099/BeeShirtsjnpServer?method=testMethod&endpointName=jnpProvider&blankParam=", muleContext);
        url.initialise();
        assertEquals("jnp", url.getScheme());
        assertEquals("jnp://localhost:1099", url.getAddress());
        assertEquals("/BeeShirtsjnpServer", url.getPath());
        assertNotNull(url.getEndpointName());
        assertEquals("jnpProvider", url.getEndpointName());
        assertEquals(1099, url.getPort());
        assertEquals("localhost", url.getHost());
        assertEquals(
            "jnp://localhost:1099/BeeShirtsjnpServer?method=testMethod&endpointName=jnpProvider&blankParam=",
            url.toString());
        assertEquals("method=testMethod&endpointName=jnpProvider&blankParam=", url.getQuery());
        assertEquals(3, url.getParams().size());
        assertEquals("testMethod", url.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
        assertEquals("", url.getParams().getProperty("blankParam"));
    }
View Full Code Here


        try
        {
            // We parse a new uri based on the listening host and port with the
            // request parameters appended
            // Using the soap prefix ensures that we use a soap endpoint builder
            EndpointURI endpointUri = context.getEndpointURI();
            //We need to re-parse the URI here because we are only give the listening endpoint, not the actual
            //request endpoint. The request endpoint needs to have the query parameters from the client
            //There is no need to do this for Servlet because it does things differently
            if (!"true".equalsIgnoreCase(context.getEndpointURI().getParams().getProperty("servlet.endpoint")))
            {
                String uri = SoapConstants.SOAP_ENDPOINT_PREFIX + context.getEndpointURI().getScheme()
                                + "://" + context.getEndpointURI().getHost() + ":"
                                + context.getEndpointURI().getPort();
                uri += context.getMessage().getInboundProperty(HttpConnector.HTTP_REQUEST_PROPERTY, StringUtils.EMPTY);
                endpointUri = new MuleEndpointURI(uri, context.getMuleContext());
                endpointUri.initialise();
            }

            AxisEngine engine = getAxis();
            String pathInfo = endpointUri.getPath();
            boolean wsdlRequested = false;
            boolean listRequested = false;

            if (endpointUri.getAddress().endsWith(".jws"))
            {
                throw new AxisFault("Jws not supported by the Mule Axis service");
            }

            String queryString = endpointUri.getQuery();
            if (queryString != null)
            {
                if (queryString.equalsIgnoreCase(SoapConstants.WSDL_PROPERTY))
                {
                    wsdlRequested = true;
                }
                else
                {
                    if (queryString.equalsIgnoreCase(SoapConstants.LIST_PROPERTY))
                    {
                        listRequested = true;
                    }
                }
            }

            boolean hasNoPath = (StringUtils.isEmpty(pathInfo) || pathInfo.equals("/"));
            if (!wsdlRequested && !listRequested && hasNoPath)
            {
                reportAvailableServices(context, response);
            }
            else
            {
                MessageContext msgContext = new MessageContext(engine);
                populateMessageContext(msgContext, context, endpointUri);

                msgContext.setProperty("transport.url", endpointUri.toString());
                if (wsdlRequested)
                {
                    processWsdlRequest(msgContext, response);
                }
                else if (listRequested)
View Full Code Here

        String contentType;
        try
        {
            //EndpointURI endpointUri = getEndpoint(context);
            EndpointURI endpointUri = context.getEndpointURI();
            populateMessageContext(msgContext, context, endpointUri);
            if (securityProvider != null)
            {
                if (logger.isDebugEnabled())
                {
                    logger.debug("securityProvider:" + securityProvider);
                }
                msgContext.setProperty("securityProvider", securityProvider);
            }

            Object request = context.getMessage().getPayload();
            if (request instanceof File)
            {
                request = new FileInputStream((File)request);
            }
            else if (request instanceof byte[])
            {
                request = new ByteArrayInputStream((byte[])request);
            }

            final String cType = context.getMessage().getInboundProperty(HTTPConstants.HEADER_CONTENT_TYPE);
            final String cLocation = context.getMessage().getInboundProperty(HTTPConstants.HEADER_CONTENT_LOCATION);
            Message requestMsg = new Message(request, false, cType, cLocation);

            if (logger.isDebugEnabled())
            {
                logger.debug("Request Message:" + requestMsg);
            }
            msgContext.setRequestMessage(requestMsg);
            msgContext.setProperty("transport.url", endpointUri.toString());

            soapAction = getSoapAction(context);
            if (soapAction != null)
            {
                msgContext.setUseSOAPAction(true);
View Full Code Here

        AxisProperties.setProperty("axis.doAutoTypes", String.valueOf(connector.isDoAutoTypes()));
        String style = (String) endpoint.getProperties().get(AxisConnector.STYLE);
        String use = (String) endpoint.getProperties().get(AxisConnector.USE);
        String doc = (String) endpoint.getProperties().get("documentation");

        EndpointURI uri = endpoint.getEndpointURI();
        String serviceName = flowConstruct.getName();

        SOAPService existing = this.connector.getAxis().getService(serviceName);
        if (existing != null)
        {
            soapService = existing;
            logger.debug("Using existing service for " + serviceName);
        }
        else
        {
            // Check if the style is message. If so, we need to create
            // a message oriented provider
            if (style != null && style.equalsIgnoreCase("message"))
            {
                logger.debug("Creating Message Provider");
                soapService = new SOAPService(new MuleMsgProvider(connector));
                // } else if (style != null && style.equalsIgnoreCase("document")) {
                // logger.debug("Creating Doc Provider");
                // service = new SOAPService(new MuleDocLitProvider(connector));
            }
            else
            {
                logger.debug("Creating RPC Provider");
                soapService = new SOAPService(new MuleRPCProvider(connector));
            }

            soapService.setEngine(connector.getAxis());
        }

        String servicePath = uri.getPath();
        soapService.setOption(serviceName, this);
        soapService.setOption(AxisConnector.SERVICE_PROPERTY_SERVCE_PATH, servicePath);
        soapService.setOption(AxisConnector.SERVICE_PROPERTY_COMPONENT_NAME, serviceName);

        soapService.setName(serviceName);

        // Add any custom options from the Descriptor config
        Map options = (Map) endpoint.getProperties().get(AXIS_OPTIONS);

        // IF wsdl service name is not set, default to service name
        if (options == null)
        {
            options = new HashMap(2);
        }
        if (options.get("wsdlServiceElement") == null)
        {
            options.put("wsdlServiceElement", serviceName);
        }

        Map.Entry entry;
        for (Iterator iterator = options.entrySet().iterator(); iterator.hasNext();)
        {
            entry = (Map.Entry) iterator.next();
            soapService.setOption(entry.getKey().toString(), entry.getValue());
            logger.debug("Adding Axis option: " + entry);
        }

        // set method names
        Class[] interfaces = AxisServiceProxy.getInterfacesForComponent(service);
        if (interfaces.length == 0)
        {
            throw new InitialisationException(
                    AxisMessages.objectMustImplementAnInterface(serviceName), service);
        }
        // You must supply a class name if you want to restrict methods
        // or specify the 'allowedMethods' property in the axisOptions property
        String methodNames = "*";

        Map methods = (Map) endpoint.getProperties().get(AxisConnector.SOAP_METHODS);
        if (methods != null)
        {
            Iterator i = methods.keySet().iterator();
            StringBuffer buf = new StringBuffer(64);
            while (i.hasNext())
            {
                String name = (String) i.next();
                Object m = methods.get(name);
                SoapMethod method;
                if (m instanceof List)
                {
                    method = new SoapMethod(name, (List) m);
                }
                else
                {
                    method = new SoapMethod(name, (String) m);
                }

                List namedParameters = method.getNamedParameters();
                ParameterDesc[] parameters = new ParameterDesc[namedParameters.size()];
                for (int j = 0; j < namedParameters.size(); j++)
                {
                    NamedParameter parameter = (NamedParameter) namedParameters.get(j);
                    byte mode = ParameterDesc.INOUT;
                    if (parameter.getMode().equals(ParameterMode.IN))
                    {
                        mode = ParameterDesc.IN;
                    }
                    else if (parameter.getMode().equals(ParameterMode.OUT))
                    {
                        mode = ParameterDesc.OUT;
                    }

                    parameters[j] = new ParameterDesc(parameter.getName(), mode, parameter.getType());
                }

                soapService.getServiceDescription().addOperationDesc(
                        new OperationDesc(method.getName().getLocalPart(), parameters, method.getReturnType()));
                buf.append(method.getName().getLocalPart() + ",");
            }
            methodNames = buf.toString();
            methodNames = methodNames.substring(0, methodNames.length() - 1);
        }
        else
        {
            String[] methodNamesArray = AxisServiceProxy.getMethodNames(interfaces);
            StringBuffer buf = new StringBuffer(64);
            for (int i = 0; i < methodNamesArray.length; i++)
            {
                buf.append(methodNamesArray[i]).append(",");
            }
            methodNames = buf.toString();
            methodNames = methodNames.substring(0, methodNames.length() - 1);
        }

        String className = interfaces[0].getName();
        // The namespace of the service.
        // Todo use the service qname in Mule 2.0
        String namespace = (String) endpoint.getProperties().get(SERVICE_NAMESPACE);
        if (namespace == null)
        {
            namespace = Namespaces.makeNamespace(className);
        }

        // WSDL override
        String wsdlFile = (String) endpoint.getProperties().get("wsdlFile");
        if (wsdlFile != null)
        {
            soapService.getServiceDescription().setWSDLFile(wsdlFile);
        }
        /*
         * Now we set up the various options for the SOAPService. We set:
         * RPCProvider.OPTION_WSDL_SERVICEPORT In essense, this is our service name
         * RPCProvider.OPTION_CLASSNAME This tells the serverProvider (whether it be
         * an AvalonProvider or just JavaProvider) what class to load via
         * "makeNewServiceObject". RPCProvider.OPTION_SCOPE How long the object
         * loaded via "makeNewServiceObject" will persist - either request, session,
         * or application. We use the default for now.
         * RPCProvider.OPTION_WSDL_TARGETNAMESPACE A namespace created from the
         * package name of the service. RPCProvider.OPTION_ALLOWEDMETHODS What
         * methods the service can execute on our class. We don't set:
         * RPCProvider.OPTION_WSDL_PORTTYPE RPCProvider.OPTION_WSDL_SERVICEELEMENT
         */
        setOptionIfNotset(soapService, JavaProvider.OPTION_WSDL_SERVICEPORT, serviceName);
        setOptionIfNotset(soapService, JavaProvider.OPTION_CLASSNAME, className);
        setOptionIfNotset(soapService, JavaProvider.OPTION_SCOPE, "Request");
        if (StringUtils.isNotBlank(namespace))
        {
            setOptionIfNotset(soapService, JavaProvider.OPTION_WSDL_TARGETNAMESPACE, namespace);
        }

        // Set the allowed methods, allow all if there are none specified.
        if (methodNames == null)
        {
            setOptionIfNotset(soapService, JavaProvider.OPTION_ALLOWEDMETHODS, "*");
        }
        else
        {
            setOptionIfNotset(soapService, JavaProvider.OPTION_ALLOWEDMETHODS, methodNames);
        }

        // Note that Axis has specific rules to how these two variables are
        // combined. This is handled for us
        // Set style: RPC/wrapped/Doc/Message

        if (style != null)
        {
            Style s = Style.getStyle(style);
            if (s == null)
            {
                throw new CreateException(
                        CoreMessages.valueIsInvalidFor(style, AxisConnector.STYLE), this);
            }
            else
            {
                soapService.setStyle(s);
            }
        }
        // Set use: Endcoded/Literal
        if (use != null)
        {
            Use u = Use.getUse(use);
            if (u == null)
            {
                throw new CreateException(CoreMessages.valueIsInvalidFor(use, AxisConnector.USE),
                        this);
            }
            else
            {
                soapService.setUse(u);
            }
        }

        soapService.getServiceDescription().setDocumentation(doc);

        // Tell Axis to try and be intelligent about serialization.
        // TypeMappingRegistryImpl registry = (TypeMappingRegistryImpl)
        // service.getTypeMappingRegistry();
        // TypeMappingImpl tm = (TypeMappingImpl) registry.();

        // Handle complex bean type automatically
        // registry.setDoAutoTypes( true );

        // Axis 1.2 fix to handle autotypes properly
        // AxisProperties.setProperty("axis.doAutoTypes",
        // String.valueOf(connector.isDoAutoTypes()));

        // TODO Load any explicitly defined bean types
        // List types = (List) descriptor.getProperties().get(BEAN_TYPES);
        // connector.registerTypes(registry, types);

        soapService.setName(serviceName);

        // Add initialisation callback for the Axis service
        Component component = service.getComponent();
        if (component instanceof JavaComponent)
        {
            ((AbstractJavaComponent) component).getObjectFactory().addObjectInitialisationCallback(
                new AxisInitialisationCallback(soapService));
        }

        if (uri.getScheme().equalsIgnoreCase("servlet"))
        {
            connector.addServletService(soapService);
            String endpointUrl = uri.getAddress() + "/" + serviceName;
            endpointUrl = endpointUrl.replaceFirst("servlet:", "http:");
            soapService.getServiceDescription().setEndpointURL(endpointUrl);
        }
        else
        {
            soapService.getServiceDescription().setEndpointURL(uri.getAddress() + "/" + serviceName);
        }
        if (StringUtils.isNotBlank(namespace))
        {
            soapService.getServiceDescription().setDefaultNamespace(namespace);
        }
View Full Code Here

        if (!endpoint.startsWith("axis:"))
        {
            endpoint = "axis:" + endpoint;
        }
        EndpointURI ep = new MuleEndpointURI(endpoint, connector.getMuleContext());
        String method = (String)ep.getParams().remove(MuleProperties.MULE_METHOD_PROPERTY);
        call.setOperationName(method);

        call.setOperationName(method);
        Object result = call.invoke(method, args);
        return AxisMessageDispatcher.createMessage(result, call, connector.getMuleContext());
View Full Code Here

    }

    protected OutboundEndpoint lookupEndpoint(String uri) throws MuleException
    {
        Service axis = muleContext.getRegistry().lookupService(AxisConnector.AXIS_SERVICE_COMPONENT_NAME);
        EndpointURI endpoint = new MuleEndpointURI(uri, muleContext);

        OutboundEndpoint ep;

        if (axis != null)
        {
            synchronized (endpointsCache)
            {
                ep = (OutboundEndpoint) endpointsCache.get(endpoint.getAddress());
                if (ep == null)
                {
                    updateEndpointCache((OutboundRouterCollection) axis.getOutboundMessageProcessor());
                    ep = (OutboundEndpoint) endpointsCache.get(endpoint.getAddress());
                    if (ep == null)
                    {
                        logger.debug("Dispatch Endpoint uri: " + uri
                                     + " not found on the cache. Creating the endpoint instead.");
                        ep = muleContext.getRegistry().lookupEndpointFactory()
View Full Code Here

        assertEquals("jms:/my.queue?endpointName=jmsProvider", url.toString());
    }

    public void testJmsUrl() throws Exception
    {
        EndpointURI url = new MuleEndpointURI("jms://queue1?endpointName=jmsProvider", muleContext);
        url.initialise();
        assertEquals("jms", url.getScheme());
        assertEquals("queue1", url.getAddress());
        assertEquals("jmsProvider", url.getEndpointName());
        assertEquals("jms://queue1?endpointName=jmsProvider", url.toString());
    }
View Full Code Here

    }


    public void testJmsTopic() throws Exception
    {
        EndpointURI url = new MuleEndpointURI("jms://topic:topic1", muleContext);
        url.initialise();
        assertEquals("jms", url.getScheme());
        assertEquals("topic1", url.getAddress());
        assertEquals("topic", url.getResourceInfo());
        assertEquals(null, url.getEndpointName());
        assertEquals("jms://topic:topic1", url.toString());
    }
View Full Code Here

            String filterAddress = receiver.getEndpointURI().getAddress();
            WildcardFilter filter = new WildcardFilter(filterAddress);
            if (filter.accept(endpointUri.getAddress()))
            {
                InboundEndpoint endpoint = receiver.getEndpoint();
                EndpointURI newEndpointURI = new MuleEndpointURI(endpointUri, filterAddress);
                receiver.setEndpoint(new DynamicURIInboundEndpoint(endpoint, newEndpointURI));

                if (logger.isDebugEnabled())
                {
                    logger.debug("Found receiver match on endpointUri: " + receiver.getEndpointURI()
View Full Code Here

        assertEquals("jms://topic:topic1", url.toString());
    }

    public void testJmsTopicWithProvider() throws Exception
    {
        EndpointURI url = new MuleEndpointURI("jms://topic:topic1?endpointName=jmsProvider", muleContext);
        url.initialise();
        assertEquals("jms", url.getScheme());
        assertEquals("topic1", url.getAddress());
        assertEquals("jmsProvider", url.getEndpointName());
        assertEquals("topic", url.getResourceInfo());
        assertEquals("jms://topic:topic1?endpointName=jmsProvider", url.toString());
    }
View Full Code Here

TOP

Related Classes of org.mule.api.endpoint.EndpointURI

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.