Package javax.jbi.component

Examples of javax.jbi.component.ComponentContext


    public void sendMessages(int messageCount) throws JBIException {
      sendMessages(messageCount, false);
    }
       
    public void sendMessages(int messageCount, boolean sync) throws JBIException {
        ComponentContext context = getContext();

        for (int i = 0; i < messageCount; i++) {
            InOnly exchange = context.getDeliveryChannel().createExchangeFactory().createInOnlyExchange();
            NormalizedMessage message = exchange.createMessage();

            ServiceEndpoint destination = null;
            if (resolver != null) {
                destination = resolver.resolveEndpoint(getContext(), exchange, NullEndpointFilter.getInstance());
            }
            if (destination != null) {
                // lets explicitly specify the destination - otherwise
                // we'll let the container choose for us
                exchange.setEndpoint(destination);
            }

            exchange.setInMessage(message);
            // lets set the XML as a byte[], String or DOM etc
            String xml = "<s12:Envelope xmlns:s12='http://www.w3.org/2003/05/soap-envelope'><s12:Body> <foo>Hello!</foo> </s12:Body></s12:Envelope>";
            message.setContent(new StringSource(xml));
            if (sync) {
              boolean result = context.getDeliveryChannel().sendSync(exchange, 1000);
                if (!result) {
                    throw new MessagingException("Message delivery using sendSync has timed out");
                }
            } else {
              context.getDeliveryChannel().send(exchange);
            }
        }
    }
View Full Code Here


        this.componentRegistry.unregister(componentWrapper, null);
        super.tearDown();
    }

    public void testQueryEndpoint() throws Exception {
        ComponentContext context = componentRegistry.createComponentContext();
        ServiceEndpoint ep = context.getEndpoint(new QName("urn:test", "service"), "provider");
        assertNotNull(ep);
    }
View Full Code Here

        ServiceEndpoint ep = context.getEndpoint(new QName("urn:test", "service"), "provider");
        assertNotNull(ep);
    }

    public void testQueryEndpointForService() throws Exception {
        ComponentContext context = componentRegistry.createComponentContext();
        ServiceEndpoint[] eps = context.getEndpointsForService(new QName("urn:test", "service"));
        assertNotNull(eps);
        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }
View Full Code Here

        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }

    public void testQueryEndpointsForInterface() throws Exception {
        ComponentContext context = componentRegistry.createComponentContext();
        ServiceEndpoint[] eps = context.getEndpoints(new QName("urn:test", "interface"));
        assertNotNull(eps);
        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }
View Full Code Here

        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }

    public void testQueryEndpoints() throws Exception {
        ComponentContext context = componentRegistry.createComponentContext();
        ServiceEndpoint[] eps = context.getEndpoints(null);
        assertNotNull(eps);
        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }
View Full Code Here

        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }

    public void testQueryExternalEndpointForService() throws Exception {
        ComponentContext context = componentRegistry.createComponentContext();
        ServiceEndpoint[] eps = context.getExternalEndpointsForService(new QName("urn:test", "service"));
        assertNotNull(eps);
        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }
View Full Code Here

        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }

    public void testQueryExternalEndpointsForInterface() throws Exception {
        ComponentContext context = componentRegistry.createComponentContext();
        ServiceEndpoint[] eps = context.getExternalEndpoints(new QName("urn:test", "interface"));
        assertNotNull(eps);
        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }
View Full Code Here

        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }

    public void testQueryExternalEndpoints() throws Exception {
        ComponentContext context = componentRegistry.createComponentContext();
        ServiceEndpoint[] eps = context.getExternalEndpoints(null);
        assertNotNull(eps);
        assertEquals(1, eps.length);
        assertNotNull(eps[0]);
    }
View Full Code Here

                     DOMUtil.getQName(e));
        assertEquals("urn:test", DOMUtil.getElementText(e));
    }

    public void testConfigureExchange() {
        ComponentContext ctx = (ComponentContext) Proxy.newProxyInstance(
                                                        ComponentContext.class.getClassLoader(),
                                                        new Class[] { ComponentContext.class },
                                                        new InvocationHandler() {
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                throw new UnsupportedOperationException();
View Full Code Here

    protected void retrieveProxiedEndpointDefinition() {
        if (logger.isDebugEnabled()) {
            logger.debug("Retrieving proxied endpoint definition");
        }
        try {
            ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
            ServiceEndpoint ep = null;
            if (targetService != null && targetEndpoint != null) {
                ep = ctx.getEndpoint(targetService, targetEndpoint);
                if (ep == null && logger.isDebugEnabled()) {
                    logger.debug("Could not retrieve endpoint targetService/targetEndpoint");
                }
            }
            if (ep == null && targetService != null) {
                ServiceEndpoint[] eps = ctx.getEndpointsForService(targetService);
                if (eps != null && eps.length > 0) {
                    ep = eps[0];
                }
                if (ep == null && logger.isDebugEnabled()) {
                    logger.debug("Could not retrieve endpoint for targetService");
                }
            }
            if (ep == null && targetInterfaceName != null) {
                ServiceEndpoint[] eps = ctx.getEndpoints(targetInterfaceName);
                if (eps != null && eps.length > 0) {
                    ep = eps[0];
                }
                if (ep == null && logger.isDebugEnabled()) {
                    logger.debug("Could not retrieve endpoint for targetInterfaceName");
                }
            }
            if (ep == null && service != null && endpoint != null) {
                ep = ctx.getEndpoint(service, endpoint);
                if (ep == null && logger.isDebugEnabled()) {
                    logger.debug("Could not retrieve endpoint for service/endpoint");
                }
            }
            if (ep != null) {
                Document doc = ctx.getEndpointDescriptor(ep);
                if (doc != null) {
                    WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
                    reader.setFeature(Constants.FEATURE_VERBOSE, false);
                    Definition def = reader.readWSDL(null, doc);
                    if (def != null) {
View Full Code Here

TOP

Related Classes of javax.jbi.component.ComponentContext

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.