Package org.apache.muse.core.routing

Examples of org.apache.muse.core.routing.ResourceRouter


  public Element invoke(Element soapBody){
    Resource resource = null;
    try {
      Bundle bundle = getDelegateBundle();     
      ResourceRouter delegateRouter = null;
      if(bundle != null){
        delegateRouter = (ResourceRouter)delegateMap.get(bundle);
      }
          ((OSGiEnvironment)getEnvironment()).setThreadLocalBundle(bundle);
    return delegateRouter.invoke(soapBody);
        } finally {
            ((OSGiEnvironment)getEnvironment()).setThreadLocalBundle(null);
        }
  }
View Full Code Here


      // as a delegate when trying to resolve a reference
      // to a resource
      //
      RouterDefinition rd = dd.getRouterDefinition();
      Class delegateRouter = rd.getRouterClass();
      ResourceRouter delegate = null;
     
      //initialize persistence for router
      PersistenceDefinition persistenceDef = rd.getPersistenceDefinition();
      if(delegateRouter != null){
        delegate = rd.newInstance();
     
        if(persistenceDef != null){
                RouterPersistence persistence = (RouterPersistence)persistenceDef.newInstance();
                delegate.setPersistence(persistence);
        }       
        delegate.initialize();
      }

      Collection resourceDefs = dd.getResourceDefinitions();

      this.addResourceDefinitions(bundle, resourceDefs);
View Full Code Here

   
    public ResourceRouter newInstance()
    {
        Class theClass = getRouterClass();
       
        ResourceRouter router = (ResourceRouter)ReflectUtils.newInstance(theClass);
       
        Environment env = getEnvironment();       
        router.setEnvironment(env);
       
        LoggingConfig logging = getLoggingConfig();       
        Logger log = logging.newInstance();
        router.setLog(log);
       
        router.setResourceDefinitions(getResourceDefinitions());
       
        PersistenceDefinition persistenceDef = getPersistenceDefinition();
       
        if (persistenceDef != null)
        {
            RouterPersistence persistence = (RouterPersistence)persistenceDef.newInstance();
            router.setPersistence(persistence);
        }
       
        return router;
    }
View Full Code Here

   
    public ResourceRouter newInstance()
    {
        Class theClass = getRouterClass();
       
        ResourceRouter router = (ResourceRouter)ReflectUtils.newInstance(theClass);
       
        Environment env = getEnvironment();       
        router.setEnvironment(env);
       
        LoggingConfig logging = getLoggingConfig();       
        Logger log = logging.newInstance();
        router.setLog(log);
       
        router.setResourceDefinitions(getResourceDefinitions());
       
        PersistenceDefinition persistenceDef = getPersistenceDefinition();
       
        if (persistenceDef != null)
        {
            RouterPersistence persistence = (RouterPersistence)persistenceDef.newInstance();
            router.setPersistence(persistence);
        }
       
        return router;
    }
View Full Code Here

        return env.convertToAxiom(soapResponse);
    }
   
    public Element invoke(OMElement request)
    {
        ResourceRouter router = getRouter();
        AxisEnvironment env = (AxisEnvironment)router.getEnvironment();
       
        //
        // log incoming SOAP envelope
        //
        // NOTE: This is kind of hack-ish, but we check to see if the
        //       current log level is 'FINE' before we try and log the
        //       message. We don't actually have to do this - the JDK
        //       logging API fine() will do this for us - but because
        //       we have to translate from Axiom to DOM once already,
        //       I don't want to do it twice unless the tracing is being
        //       used. If SOAP-level tracing is on, it's likely that this
        //       is not being used in a production system, so we can afford
        //       the performance hit of an extra conversion.
        //
        if (router.getLog().getLevel() == Level.FINE)
        {
            SOAPEnvelope soap = MessageContext.getCurrentMessageContext().getEnvelope();
            Element soapAsDOM = env.convertToDOM(soap);
            LoggingUtils.logMessage(router.getLog(), soapAsDOM, true);
        }
       
        MessageHeaders wsa = env.convertContext();       
        env.addAddressingContext(wsa);
       
View Full Code Here

        if (body == null)
            throw new RuntimeException("Invalid SOAP envelope: no body element.");

        Element requestData = XmlUtils.getFirstElement(body);
       
        ResourceRouter router = getRouter();
        Environment env = router.getEnvironment();

        MessageHeaders addressing = null;

        try
        {
            //
            // WS-A info provides resource context for this request
            //
            addressing = new MessageHeaders(header);
            env.addAddressingContext(addressing);
        }

        catch (Throwable error)
        {
            LoggingUtils.logError(router.getLog(), error);
        }

        if (!hasFailedToInitialize())
            LoggingUtils.logMessage(router.getLog(), request, true);

        //
        // actually perform the operation with the given parameters
        //
        Element result = router.invoke(requestData);
       
        //
        // the standard response wsa:Action name is Action + "Response"
        //
        MessageHeaders replyAddressing = null;

        //
        // send back fault headers on exception
        //
        if (SoapUtils.isFault(result))
            replyAddressing = addressing.createFaultHeaders();

        else
            replyAddressing = addressing.createReplyHeaders();

        //
        // DONE - must be sure to remove the request context, or
        // we'll have a memory leak
        //
        env.removeAddressingContext();

        //
        // import all of the headers into the response envelope...
        //       
        Element replyXML = replyAddressing.toXML();
        Element[] children = XmlUtils.getAllElements(replyXML);

        Document response = XmlUtils.createDocument();

        soap = XmlUtils.createElement(response, SoapConstants.ENVELOPE_QNAME);
        response.appendChild(soap);

        header = XmlUtils.createElement(response, SoapConstants.HEADER_QNAME);
        soap.appendChild(header);

        for (int n = 0; n < children.length; ++n)
        {
            Node next = response.importNode(children[n], true);
            header.appendChild(next);
        }

        //
        // add the result (valid or fault) to the SOAP body...
        //
        body = XmlUtils.createElement(response, SoapConstants.BODY_QNAME);
        soap.appendChild(body);

        result = (Element)response.importNode(result, true);
        body.appendChild(result);

        if (!hasFailedToInitialize())
            LoggingUtils.logMessage(router.getLog(), response, false);

        return response;
    }
View Full Code Here

  public Element invoke(Element soapBody){
    Resource resource = null;
    try {
      Bundle bundle = getDelegateBundle();     
      ResourceRouter delegateRouter = null;
      if(bundle != null){
        delegateRouter = (ResourceRouter)delegateMap.get(bundle);
      }
          ((OSGiEnvironment)getEnvironment()).setThreadLocalBundle(bundle);
    return delegateRouter.invoke(soapBody);
        } finally {
            ((OSGiEnvironment)getEnvironment()).setThreadLocalBundle(null);
        }
  }
View Full Code Here

      // as a delegate when trying to resolve a reference
      // to a resource
      //
      RouterDefinition rd = dd.getRouterDefinition();
      Class delegateRouter = rd.getRouterClass();
      ResourceRouter delegate = null;
     
      //initialize persistence for router
      PersistenceDefinition persistenceDef = rd.getPersistenceDefinition();
      if(delegateRouter != null){
        delegate = rd.newInstance();
     
        if(persistenceDef != null){
                RouterPersistence persistence = (RouterPersistence)persistenceDef.newInstance();
                delegate.setPersistence(persistence);
        }       
        delegate.initialize();
      }

      Collection resourceDefs = dd.getResourceDefinitions();

      this.addResourceDefinitions(bundle, resourceDefs);
View Full Code Here

        if (body == null)
            throw new RuntimeException("Invalid SOAP envelope: no body element.");

        Element requestData = XmlUtils.getFirstElement(body);
       
        ResourceRouter router = getRouter();
        Environment env = router.getEnvironment();

        MessageHeaders addressing = null;

        try
        {
            //
            // WS-A info provides resource context for this request
            //
            addressing = new MessageHeaders(header);
            env.addAddressingContext(addressing);
        }

        catch (Throwable error)
        {
            LoggingUtils.logError(router.getLog(), error);
        }

        if (!hasFailedToInitialize())
            LoggingUtils.logMessage(router.getLog(), request, true);

        //
        // actually perform the operation with the given parameters
        //
        Element result = router.invoke(requestData);
       
        //
        // the standard response wsa:Action name is Action + "Response"
        //
        MessageHeaders replyAddressing = null;

        //
        // send back fault headers on exception
        //
        if (SoapUtils.isFault(result))
            replyAddressing = addressing.createFaultHeaders();

        else
            replyAddressing = addressing.createReplyHeaders();

        //
        // DONE - must be sure to remove the request context, or
        // we'll have a memory leak
        //
        env.removeAddressingContext();

        //
        // import all of the headers into the response envelope...
        //       
        Element replyXML = replyAddressing.toXML();
        Element[] children = XmlUtils.getAllElements(replyXML);

        Document response = XmlUtils.createDocument();

        soap = XmlUtils.createElement(response, SoapConstants.ENVELOPE_QNAME);
        response.appendChild(soap);

        header = XmlUtils.createElement(response, SoapConstants.HEADER_QNAME);
        soap.appendChild(header);

        for (int n = 0; n < children.length; ++n)
        {
            Node next = response.importNode(children[n], true);
            header.appendChild(next);
        }

        //
        // add the result (valid or fault) to the SOAP body...
        //
        body = XmlUtils.createElement(response, SoapConstants.BODY_QNAME);
        soap.appendChild(body);

        result = (Element)response.importNode(result, true);
        body.appendChild(result);

        if (!hasFailedToInitialize())
            LoggingUtils.logMessage(router.getLog(), response, false);

        return response;
    }
View Full Code Here

        return env.convertToAxiom(soapResponse);
    }
   
    public Element invoke(OMElement request)
    {
        ResourceRouter router = getRouter();
        AxisEnvironment env = (AxisEnvironment)router.getEnvironment();
       
        //
        // log incoming SOAP envelope
        //
        // NOTE: This is kind of hack-ish, but we check to see if the
        //       current log level is 'FINE' before we try and log the
        //       message. We don't actually have to do this - the JDK
        //       logging API fine() will do this for us - but because
        //       we have to translate from Axiom to DOM once already,
        //       I don't want to do it twice unless the tracing is being
        //       used. If SOAP-level tracing is on, it's likely that this
        //       is not being used in a production system, so we can afford
        //       the performance hit of an extra conversion.
        //
        if (router.getLog().getLevel() == Level.FINE)
        {
            SOAPEnvelope soap = MessageContext.getCurrentMessageContext().getEnvelope();
            Element soapAsDOM = env.convertToDOM(soap);
            LoggingUtils.logMessage(router.getLog(), soapAsDOM, true);
        }
       
        MessageHeaders wsa = env.convertContext();       
        env.addAddressingContext(wsa);
       
View Full Code Here

TOP

Related Classes of org.apache.muse.core.routing.ResourceRouter

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.