Search in sources :

Example 1 with InterceptorChainInvoker

use of jp.ossc.nimbus.service.aspect.interfaces.InterceptorChainInvoker in project nimbus by nimbus-org.

the class EJBDriveDispatcher method invokeInterceptor.

/**
 * インターセプタを通してUnitOfWorkを実行する。
 * インターセプタが指定されていなければ直接UnitOfWorkを実行する。
 * @param input
 * @return 出力オブジェクト
 * @throws InterceptorException
 * @throws TargetCheckedException
 * @throws TargetUncheckedException
 */
public Object invokeInterceptor(Object input) throws InterceptorException, TargetCheckedException, TargetUncheckedException {
    Object ret = null;
    if (mFactory == null && chainFactory == null) {
        try {
            ret = (UnitOfWork) invokeUnitOfWorkBase((UnitOfWork) input);
        } catch (IOCException e) {
            throw new TargetUncheckedException(e.getCause());
        } catch (Throwable e) {
            if (this.getLogger() != null) {
                this.getLogger().write("IOC__00018", e);
            }
            throw new TargetUncheckedException(e);
        }
    } else {
        if (this.getLogger() != null) {
            this.getLogger().write("IOC__00004", this.getInterceptorKey());
        }
        if (mFactory != null) {
            InterceptorChainInvoker ici = this.mFactory.createInterceptorInvoker(this.getInterceptorKey());
            ret = ici.invokeChain(this, input);
        } else if (chainFactory != null) {
            try {
                InterceptorChain chain = chainFactory.getInterceptorChain(getInterceptorKey());
                ret = chain.invokeNext(createInvocationContext(input));
            } catch (TargetUncheckedException e) {
                throw e;
            } catch (TargetCheckedException e) {
                throw e;
            } catch (InterceptorException e) {
                throw e;
            } catch (RuntimeException e) {
                throw e;
            } catch (Exception e) {
                throw new IOCException(e);
            } catch (Throwable th) {
                if (th instanceof Error) {
                    throw (Error) th;
                }
            }
        }
    }
    return ret;
}
Also used : InterceptorChainInvoker(jp.ossc.nimbus.service.aspect.interfaces.InterceptorChainInvoker) InterceptorChain(jp.ossc.nimbus.service.aop.InterceptorChain) InterceptorException(jp.ossc.nimbus.service.aspect.interfaces.InterceptorException) IOCException(jp.ossc.nimbus.ioc.IOCException) TargetUncheckedException(jp.ossc.nimbus.service.aspect.interfaces.TargetUncheckedException) TargetCheckedException(jp.ossc.nimbus.service.aspect.interfaces.TargetCheckedException) NamingException(javax.naming.NamingException) InterceptorException(jp.ossc.nimbus.service.aspect.interfaces.InterceptorException) TargetUncheckedException(jp.ossc.nimbus.service.aspect.interfaces.TargetUncheckedException) TargetCheckedException(jp.ossc.nimbus.service.aspect.interfaces.TargetCheckedException) IOCException(jp.ossc.nimbus.ioc.IOCException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) CreateException(javax.ejb.CreateException)

Example 2 with InterceptorChainInvoker

use of jp.ossc.nimbus.service.aspect.interfaces.InterceptorChainInvoker in project nimbus by nimbus-org.

the class SLSBCommandBean method invokeCommand.

/**
 * コマンドを実行する。
 * @param cmd コマンド
 * @return 実行後のコマンド
 */
public Command invokeCommand(Command cmd) {
    if (this.getLogger() != null) {
        this.getLogger().write("IOC__00006");
    }
    // インターセプタで実行した際にも同じフローキーで実行させるため保持しておく。
    String key = cmd.getFlowKey();
    InterceptorChainInvoker ici = null;
    InterceptorChain ic = null;
    if (this.getIciFactory() != null) {
        ici = this.getIciFactory().createInterceptorInvoker(key);
    } else if (this.getIcFactory() != null) {
        ic = this.getIcFactory().getInterceptorChain(key);
    }
    Object ret = null;
    if (ici == null && ic == null) {
        // 直接実行
        if (this.getLogger() != null) {
            this.getLogger().write("IOC__00007");
        }
        try {
            ret = invokeBeanFlow(cmd);
        } catch (Exception e) {
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            } else {
                cmd.setException(e);
            }
        } catch (Throwable e) {
            throw new IOCException("SLSBCommandBean invokeCommand Unrecognize Exception", e);
        }
    } else if (ici != null) {
        // インターセプタを通して実行
        try {
            if (this.getLogger() != null) {
                this.getLogger().write("IOC__00008");
            }
            ret = ici.invokeChain(this, cmd);
            if (this.getLogger() != null) {
                this.getLogger().write("IOC__00012");
            }
        } catch (InterceptorException e) {
            if (this.getLogger() != null) {
                this.getLogger().write("IOC__00009", e);
            }
            throw new IOCException("SLSBCommandBean invokeCommand InterceptorException", e);
        } catch (TargetCheckedException e) {
            if (this.getLogger() != null) {
                this.getLogger().write("IOC__00010", e);
            }
            cmd.setException(e.getCause());
            return cmd;
        } catch (TargetUncheckedException e) {
            if (this.getLogger() != null) {
                this.getLogger().write("IOC__00011", e.getCause());
            }
            if (e.getCause() instanceof RuntimeException) {
                throw (RuntimeException) e.getCause();
            } else {
                throw new IOCException("SLSBCommandBean invokeCommand TargetUncheckedException", e.getCause());
            }
        } catch (Throwable e) {
            throw new IOCException("SLSBCommandBean invokeCommand Unrecognize Exception", e);
        }
    } else {
        // インターセプタを通して実行
        try {
            if (this.getLogger() != null) {
                this.getLogger().write("IOC__00008");
            }
            ret = ic.invokeNext(createInvocationContext(cmd));
            if (this.getLogger() != null) {
                this.getLogger().write("IOC__00012");
            }
        } catch (RuntimeException e) {
            if (this.getLogger() != null) {
                this.getLogger().write("IOC__00011", e);
            }
            throw e;
        } catch (Exception e) {
            if (this.getLogger() != null) {
                this.getLogger().write("IOC__00010", e);
            }
            cmd.setException(e);
            return cmd;
        } catch (Throwable e) {
            throw new IOCException("SLSBCommandBean invokeCommand Unrecognize Exception", e);
        }
    }
    cmd.setOutObject(ret);
    return cmd;
}
Also used : InterceptorChainInvoker(jp.ossc.nimbus.service.aspect.interfaces.InterceptorChainInvoker) InterceptorChain(jp.ossc.nimbus.service.aop.InterceptorChain) InterceptorException(jp.ossc.nimbus.service.aspect.interfaces.InterceptorException) TargetUncheckedException(jp.ossc.nimbus.service.aspect.interfaces.TargetUncheckedException) TargetCheckedException(jp.ossc.nimbus.service.aspect.interfaces.TargetCheckedException) InterceptorException(jp.ossc.nimbus.service.aspect.interfaces.InterceptorException) TargetUncheckedException(jp.ossc.nimbus.service.aspect.interfaces.TargetUncheckedException) TargetCheckedException(jp.ossc.nimbus.service.aspect.interfaces.TargetCheckedException) RemoteException(java.rmi.RemoteException)

Aggregations

RemoteException (java.rmi.RemoteException)2 InterceptorChain (jp.ossc.nimbus.service.aop.InterceptorChain)2 InterceptorChainInvoker (jp.ossc.nimbus.service.aspect.interfaces.InterceptorChainInvoker)2 InterceptorException (jp.ossc.nimbus.service.aspect.interfaces.InterceptorException)2 TargetCheckedException (jp.ossc.nimbus.service.aspect.interfaces.TargetCheckedException)2 TargetUncheckedException (jp.ossc.nimbus.service.aspect.interfaces.TargetUncheckedException)2 CreateException (javax.ejb.CreateException)1 EJBException (javax.ejb.EJBException)1 NamingException (javax.naming.NamingException)1 IOCException (jp.ossc.nimbus.ioc.IOCException)1