Package javax.resource.spi.endpoint

Examples of javax.resource.spi.endpoint.MessageEndpoint


  public void onMessage(javax.jms.Message message) {
    if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
      AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
                                    this + " onMessage(" + message + ")");

    MessageEndpoint endpoint = null;
    try {
      if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
        AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
                                      "ServerSession passes message to listener.");
      endpoint = endpointFactory.createEndpoint(xaResource);
      ((javax.jms.MessageListener) endpoint).onMessage(message);
      endpoint.release();
    } catch (Exception exc) {
      try {
        // try to clean the context for next invocation
        if (endpoint != null) endpoint.release();
      } catch (Exception e) {
        // ignore the exception
      }
      throw new java.lang.IllegalStateException("Could not get endpoint "
                                                + "instance: " + exc);
View Full Code Here


      log.debug("endpointActivation, spec="+spec);
      QuartzActivationSpec quartzSpec = (QuartzActivationSpec) spec;

      // allocate instance of endpoint to figure out its endpoint interface
      Class clazz = QuartzJob.class;
      MessageEndpoint tmpMe = endpointFactory.createEndpoint(null);
      if (tmpMe instanceof StatefulJob) clazz = StatefulQuartzJob.class;
      tmpMe.release();

      try
      {
         JobDetail jobDetail = new JobDetail(quartzSpec.getJobName(), quartzSpec.getJobGroup(), clazz, true, false, false);
         jobDetail.getJobDataMap().setAllowsTransientData(true);
View Full Code Here

        public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
            EmailAccountInfo accountInfo = (EmailAccountInfo) activationSpec;

            EmailConsumer emailConsumer = consumers.remove(accountInfo.getAddress());
            MessageEndpoint endpoint = (MessageEndpoint) emailConsumer;
            endpoint.release();
        }
View Full Code Here

            EmailConsumer emailConsumer = consumers.get(to);

            if (emailConsumer == null) throw new Exception("No such account");

            MessageEndpoint endpoint = (MessageEndpoint) emailConsumer;

            endpoint.beforeDelivery(EmailConsumer.class.getMethod("receiveEmail", Properties.class, String.class));
            emailConsumer.receiveEmail(headers, body);
            endpoint.afterDelivery();
        }
View Full Code Here

        public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException {
            assertNotNull("messageEndpointFactory is null", messageEndpointFactory);
            assertNotNull("activationSpec is null", activationSpec);
            assertTrue("activationSpec should be an instance of FakeActivationSpec", activationSpec instanceof FakeActivationSpec);

            MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
            assertNotNull("endpoint is null", endpoint);
            assertTrue("endpoint should be an instance of FakeMessageListener", endpoint instanceof FakeMessageListener);
        }
View Full Code Here

    }
   
    protected boolean receiveAndExecute(Object invoker, Session session, MessageConsumer consumer)
        throws JMSException {
        boolean messageReceived = false;
        MessageEndpoint ep = null;
        MessageConsumer mc = null;
        XASession xa = null;
        Session s = null;

        try {       
            xa = (XASession)createSession(getSharedConnection());
            XAResource xar = xa.getXAResource();
            s = xa.getSession();
            mc = s.createConsumer(getDestination());           
            ep = factory.createEndpoint(xar);
           
            Map<Class<?>, Object> mp = new HashMap<Class<?>, Object>();
            mp.put(MessageEndpoint.class, ep);
           
            ENDPOINT_LOCAL.set(mp);
            ep.beforeDelivery(method);               
            messageReceived = doReceiveAndExecute(invoker, s, mc, null);
            ep.afterDelivery();
        } catch (Exception ex) {
            throw new JMSException(ex.getMessage());
        } finally {
            ep.release();
            JmsUtils.closeMessageConsumer(mc);
            JmsUtils.closeSession(xa);
            JmsUtils.closeSession(s);
        }
View Full Code Here

    if(jobHandlerActivation == null) {
      // TODO: stop acquisition / only activate acquisition if MDB active?
      log.warning("Cannot execute acquired job, no JobExecutionHandler MDB deployed.");
      return;
    }
    MessageEndpoint endpoint = null;
    try {
      endpoint = jobHandlerActivation.getMessageEndpointFactory().createEndpoint(null);

      try {
        endpoint.beforeDelivery(method);
      } catch (NoSuchMethodException e) {
        log.log(Level.WARNING, "NoSuchMethodException while invoking beforeDelivery() on MessageEndpoint '"+endpoint+"'", e);
      } catch (ResourceException e) {
        log.log(Level.WARNING, "ResourceException while invoking beforeDelivery() on MessageEndpoint '"+endpoint+"'", e);
      }

      try {
        ((JobExecutionHandler)endpoint).executeJob(nextJobId, commandExecutor);
      }catch (Exception e) {
        log.log(Level.WARNING, "Exception while executing job with id '"+nextJobId+"'.", e);
      }

      try {
        endpoint.afterDelivery();
      } catch (ResourceException e) {
        log.log(Level.WARNING, "ResourceException while invoking afterDelivery() on MessageEndpoint '"+endpoint+"'", e);
      }

    } catch (UnavailableException e) {
      log.log(Level.SEVERE, "UnavailableException while attempting to create messaging endpoint for executing job", e);
    } finally {
      if(endpoint != null) {
        endpoint.release();
      }
    }
  }
View Full Code Here

      trace = log.isTraceEnabled();
     
      if (trace)
         log.trace("createEndpoint " + this + " xaResource=" + resource);
         
      MessageEndpoint endpoint = createProxy(resource);
       
      if (trace)
         log.trace("Created endpoint " + endpoint + " from " + this);

      return endpoint;
View Full Code Here

         MessageInflowLocalProxy proxy = new MessageInflowLocalProxy(container);
         proxy.setXaResource(resource);
         proxy.setMessageEndpointFactory(this);
        
         Object[] args = {proxy};
         MessageEndpoint endpoint = (MessageEndpoint)proxyConstructor.newInstance(args);
         return endpoint;
        
      } catch (Exception e)
      {
         e.printStackTrace();
View Full Code Here

    /**
     * Performs the work
     */
    public void run() {
        // get message driven bean proxy
        MessageEndpoint endpoint = getMesssageEndpoint();
        if (endpoint == null) {
            // error has been logged.
            return;
        }
   
        // get class loader
        ClassLoader classLoader = endpoint.getClass().getClassLoader();
        ClassLoader savedClassLoader = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(classLoader);
            activate(endpoint, classLoader);
        } finally {
View Full Code Here

TOP

Related Classes of javax.resource.spi.endpoint.MessageEndpoint

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.