Package net.sf.hajdbc.durability

Examples of net.sf.hajdbc.durability.DurabilityListener


   * @see net.sf.hajdbc.durability.none.NoDurability#getInvocationStrategy(net.sf.hajdbc.invocation.InvocationStrategy, net.sf.hajdbc.durability.Durability.Phase, java.lang.Object)
   */
  @Override
  public InvocationStrategy getInvocationStrategy(final InvocationStrategy strategy, final Phase phase, final Object transactionId)
  {
    final DurabilityListener listener = this.cluster.getStateManager();

    return new InvocationStrategy()
    {
      @Override
      public <ZZ, DD extends Database<ZZ>, T, R, EE extends Exception> SortedMap<DD, R> invoke(ProxyFactory<ZZ, DD, T, EE> proxy, Invoker<ZZ, DD, T, R, EE> invoker) throws EE
      {
        InvocationEvent event = new InvocationEventImpl(transactionId, phase, proxy.getExceptionFactory().getType());

        listener.beforeInvocation(event);

        try
        {
          return strategy.invoke(proxy, invoker);
        }
        catch (Exception e)
        {
          throw proxy.getExceptionFactory().createException(e);
        }
        finally
        {
          listener.afterInvocation(event);
        }
      }
    };
  }
View Full Code Here


   * @see net.sf.hajdbc.durability.none.NoDurability#getInvoker(net.sf.hajdbc.invocation.Invoker, net.sf.hajdbc.durability.Durability.Phase, java.lang.Object, net.sf.hajdbc.ExceptionFactory)
   */
  @Override
  public <T, R, E extends Exception> Invoker<Z, D, T, R, E> getInvoker(final Invoker<Z, D, T, R, E> invoker, final Phase phase, final Object transactionId, final ExceptionFactory<E> exceptionFactory)
  {
    final DurabilityListener listener = this.cluster.getStateManager();
   
    return new Invoker<Z, D, T, R, E>()
    {
      @Override
      public R invoke(D database, T object) throws E
      {
        InvokerEvent event = new InvokerEventImpl(transactionId, phase, database.getId());
       
        listener.beforeInvoker(event);
       
        try
        {
          R result = invoker.invoke(database, object);
         
          event.setResult(new InvokerResultImpl(result));
         
          return result;
        }
        catch (Exception e)
        {
          event.setResult(new InvokerResultImpl(e));
         
          throw exceptionFactory.createException(e);
        }
        finally
        {
          listener.afterInvoker(event);
        }
      }
    };
  }
View Full Code Here

TOP

Related Classes of net.sf.hajdbc.durability.DurabilityListener

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.