Package javax.jbi.component

Examples of javax.jbi.component.ComponentContext


    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


    /* (non-Javadoc)
     * @see org.servicemix.common.Endpoint#activate()
     */
    public void activate() throws Exception {
        ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
        loadWsdl();
        if (getRole() == Role.PROVIDER) {
            activated = ctx.activateEndpoint(service, endpoint);
            processor = createProviderProcessor();
        } else {
            activated = createExternalEndpoint();
            ctx.registerExternalEndpoint(activated);
            processor = createConsumerProcessor();
        }
        processor.start();
    }
View Full Code Here

    /* (non-Javadoc)
     * @see org.servicemix.common.Endpoint#deactivate()
     */
    public void deactivate() throws Exception {
        if (activated != null) {
            ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
            if (getRole() == Role.PROVIDER) {
                ServiceEndpoint ep = activated;
                activated = null;
                ctx.deactivateEndpoint(ep);
            } else {
                ServiceEndpoint ep = activated;
                activated = null;
                ctx.deregisterExternalEndpoint(ep);
            }
        }
        processor.stop();
    }
View Full Code Here

        MessageExchange exchange = createExchange(mep);
        exchange.setService((QName) context.getProperty(Context.SERVICE));
        exchange.setInterfaceName((QName) context.getProperty(Context.INTERFACE));
        exchange.setOperation((QName) context.getProperty(Context.OPERATION));
        if (context.getProperty(Context.ENDPOINT) != null) {
            ComponentContext componentContext = endpoint.getServiceUnit().getComponent().getComponentContext();
            QName serviceName = (QName) context.getProperty(Context.SERVICE);
            String endpointName = (String) context.getProperty(Context.ENDPOINT);
            ServiceEndpoint se = componentContext.getEndpoint(serviceName, endpointName);
            if (se != null) {
                exchange.setEndpoint(se);
            }
        }
        NormalizedMessage inMessage = exchange.createMessage();
View Full Code Here

        context.setProperty(Context.KEYSTORE_MANAGER, endpoint.getKeystoreManager());
        return context;
    }

    protected MessageExchange createExchange(URI mep) throws MessagingException {
        ComponentContext context = endpoint.getServiceUnit().getComponent().getComponentContext();
        DeliveryChannel channel = context.getDeliveryChannel();
        MessageExchangeFactory factory = channel.createExchangeFactory();
        MessageExchange exchange = factory.createExchange(mep);
        return exchange;
    }
View Full Code Here

    protected Operation findOperation(Context context) throws Exception {
        QName interfaceName = (QName) context.getProperty(Context.INTERFACE);
        QName serviceName = (QName) context.getProperty(Context.SERVICE);
        String endpointName = (String) context.getProperty(Context.ENDPOINT);
        ComponentContext componentContext = endpoint.getServiceUnit().getComponent().getComponentContext();
        QName bodyName = context.getInMessage().getBodyName();
       
        // Find target endpoint
        ServiceEndpoint se = null;
        if (serviceName != null && endpointName != null) {
            se = componentContext.getEndpoint(serviceName, endpointName);
        }
        if (se == null && interfaceName != null) {
            ServiceEndpoint[] ses = componentContext.getEndpoints(interfaceName);
            if (ses != null && ses.length > 0) {
                se = ses[0];
            }
        }
       
View Full Code Here

        return null;
    }

    protected Definition getDefinition(ServiceEndpoint se) throws WSDLException, JBIException {
        Definition definition;
        ComponentContext componentContext = endpoint.getServiceUnit().getComponent().getComponentContext();
            String key = se.getServiceName() + se.getEndpointName();
            synchronized (definitions) {
                definition = (Definition) definitions.get(key);
                if (definition == null) {
                    WSDLFactory factory = WSDLFactory.newInstance();
                    Document description = componentContext.getEndpointDescriptor(se);
                    if (description != null) {
                        // Parse WSDL
                        WSDLReader reader = factory.newWSDLReader();
                        reader.setFeature(Constants.FEATURE_VERBOSE, false);
                        try {
View Full Code Here

        }
       
        protected class TestEndpoint extends Endpoint implements ExchangeProcessor {
            protected ServiceEndpoint activated;
            public void activate() throws Exception {
                ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
                activated = ctx.activateEndpoint(service, endpoint);
            }
View Full Code Here

            public void activate() throws Exception {
                ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
                activated = ctx.activateEndpoint(service, endpoint);
            }
            public void deactivate() throws Exception {
                ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
                ctx.deactivateEndpoint(activated);
                activated = null;
            }
View Full Code Here

      sendMessages(messageCount, false);
    }
       
    public void sendMessages(int messageCount, boolean sync)  {
        try {
            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) {
                  context.getDeliveryChannel().sendSync(exchange, 4000);
                } else {
                  context.getDeliveryChannel().send(exchange);
                }
                //Thread.sleep(100);
            }
        }
        catch (JBIException e) {
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.