ejbbean.java
来自「RESIN 3.2 最新源码」· Java 代码 · 共 2,224 行 · 第 1/4 页
JAVA
2,224 行
return _remoteHome; } /** * Gets the remote home class. */ public Class getRemoteHomeClass() { if (_remoteHome == null) return null; try { return Class.forName(_remoteHome.getName(), false, getClassLoader()); } catch (Exception e) { throw new RuntimeException(e); } } /** * Sets the ejb remote interface */ public void setRemote(Class remote) throws ConfigException { setRemoteWrapper(new ApiClass(remote)); } /** * Sets the remote interface class. */ public void setRemoteWrapper(ApiClass remote) throws ConfigException { if (! remote.isPublic()) throw error(L.l("'{0}' must be public. <remote> interfaces must be public.", remote.getName())); if (! remote.isInterface()) throw error(L.l("'{0}' must be an interface. <remote> interfaces must be interfaces.", remote.getName())); if (! EJBObject.class.isAssignableFrom(remote.getJavaClass()) && ! isAllowPOJO()) throw new ConfigException(L.l("'{0}' must extend EJBObject. <remote> interfaces must extend javax.ejb.EJBObject.", remote.getName())); if (! _remoteList.contains(remote)) { _remoteList.add(remote); } } /** * Adds a remote interface class */ public void addBusinessRemote(Class remoteClass) { ApiClass remote = new ApiClass(remoteClass); if (! remote.isPublic()) throw error(L.l("'{0}' must be public. <business-remote> interfaces must be public.", remote.getName())); if (! remote.isInterface()) throw error(L.l("'{0}' must be an interface. <business-remote> interfaces must be interfaces.", remote.getName())); if (! _remoteList.contains(remote)) { _remoteList.add(remote); } } /** * Gets the remote interface class. */ public ArrayList<ApiClass> getRemoteList() { return _remoteList; } /** * Gets the remote class. */ public Class getRemoteClass() { if (_remoteList.size() < 1) return null; try { ApiClass remote = _remoteList.get(0); return Class.forName(remote.getName(), false, getClassLoader()); } catch (Exception e) { throw new RuntimeException(e); } } /** * Sets the ejb local home interface */ public void setLocalHome(Class localHomeClass) throws ConfigException { ApiClass localHome = new ApiClass(localHomeClass); setLocalHomeWrapper(localHome); } /** * Sets the local home interface class. */ public void setLocalHomeWrapper(ApiClass localHome) throws ConfigException { _localHome = localHome; if (! localHome.isPublic()) throw error(L.l("'{0}' must be public. <local-home> interfaces must be public.", localHome.getName())); if (! localHome.isInterface()) throw error(L.l("'{0}' must be an interface. <local-home> interfaces must be interfaces.", localHome.getName())); if (! EJBLocalHome.class.isAssignableFrom(localHome.getJavaClass()) && ! isAllowPOJO()) throw new ConfigException(L.l("'{0}' must extend EJBLocalHome. <local-home> interfaces must extend javax.ejb.EJBLocalHome.", localHome.getName())); } /** * Gets the local home interface class. */ public ApiClass getLocalHome() { return _localHome; } /** * Sets the ejb local interface */ public void setLocal(Class local) throws ConfigException { setLocalWrapper(new ApiClass(local)); } /** * Sets the local interface class. */ public void setLocalWrapper(ApiClass local) throws ConfigException { if (! local.isPublic()) throw error(L.l("'{0}' must be public. <local> interfaces must be public.", local.getName())); if (! local.isInterface()) throw error(L.l("'{0}' must be an interface. <local> interfaces must be interfaces.", local.getName())); if (EJBLocalObject.class.isAssignableFrom(local.getJavaClass())) { } else if (! isAllowPOJO()) throw new ConfigException(L.l("'{0}' must extend EJBLocalObject. <local> interfaces must extend javax.ejb.EJBLocalObject.", local.getName())); if (! _localList.contains(local)) { _localList.add(local); } } /** * Adds a local interface class */ public void addBusinessLocal(Class localClass) { ApiClass local = new ApiClass(localClass); if (! local.isPublic()) throw error(L.l("'{0}' must be public. <local> interfaces must be public.", local.getName())); if (! local.isInterface()) throw error(L.l("'{0}' must be an interface. <local> interfaces must be interfaces.", local.getName())); if (! _localList.contains(local)) { _localList.add(local); } } /** * Gets the local interface class. */ public ArrayList<ApiClass> getLocalList() { return _localList; } /** * Returns true if the transaction type is container. */ public boolean isContainerTransaction() { return _isContainerTransaction; } /** * Returns true if the transaction type is container. */ public void setContainerTransaction(boolean isContainerTransaction) { _isContainerTransaction = isContainerTransaction; } /** * Adds a method. */ public EjbMethodPattern createMethod(MethodSignature sig) { for (int i = 0; i < _methodList.size(); i++) { EjbMethodPattern method = _methodList.get(i); if (method.getSignature().equals(sig)) return method; } EjbMethodPattern method = new EjbMethodPattern(this, sig); _methodList.add(method); return method; } /** * Adds a method. */ public void addMethod(EjbMethodPattern method) { _methodList.add(method); } /** * Gets the best method. */ public EjbMethodPattern getMethodPattern(ApiMethod method, String intf) { EjbMethodPattern bestMethod = null; int bestCost = -1; for (int i = 0; i < _methodList.size(); i++) { EjbMethodPattern ejbMethod = _methodList.get(i); MethodSignature sig = ejbMethod.getSignature(); if (sig.isMatch(method, intf) && bestCost < sig.getCost()) { bestMethod = ejbMethod; bestCost = sig.getCost(); } } return bestMethod; } /** * returns the method list. */ public ArrayList<EjbMethodPattern> getMethodList() { return _methodList; } /** * Sets the transaction timeout. */ public void setTransactionTimeout(Period timeout) { _transactionTimeout = timeout.getPeriod(); } /** * Gets the transaction timeout. */ public long getTransactionTimeout() { return _transactionTimeout; } public MessageDestinationRef createMessageDestinationRef() { return new MessageDestinationRef(Vfs.lookup(_ejbModuleName)); } /** * Sets the security identity */ public void setSecurityIdentity(EjbSecurityIdentity securityIdentity) { } /** * Adds a list of dependencies. */ public void addDependencyList(ArrayList<PersistentDependency> dependList) { for (int i = 0; dependList != null && i < dependList.size(); i++) { addDependency(dependList.get(i)); } } /** * Add a dependency. */ public void addDepend(Path path) { addDependency(new Depend(path)); } /** * Add a dependency. */ public void addDependency(PersistentDependency depend) { if (! _dependList.contains(depend)) _dependList.add(depend); } /** * Add a dependency. */ public void addDependency(Class cl) { addDependency(new ClassDependency(cl)); } /** * Gets the depend list. */ public ArrayList<PersistentDependency> getDependList() { return _dependList; } /** * Add a bean dependency. */ public void addBeanDependency(String ejbName) { if (! _beanDependList.contains(ejbName)) _beanDependList.add(ejbName); } /** * Gets the bean depend list. */ public ArrayList<String> getBeanDependList() { return _beanDependList; } /** * Adds an init program. */ public void addInitProgram(ConfigProgram init) { if (_initProgram == null) _initProgram = new ContainerProgram(); _initProgram.addProgram(init); } /** * Adds an undefined value, e.g. env-entry */ public void addBuilderProgram(ConfigProgram init) { if (_serverProgram == null) _serverProgram = new ContainerProgram(); _serverProgram.addProgram(init); } public void setInit(ContainerProgram init) { if (_initProgram == null) _initProgram = new ContainerProgram(); _initProgram.addProgram(init); } public void addPostConstruct(PostConstructType postConstruct) { _postConstructList.add(postConstruct.getProgram(getEJBClass())); } /** * Gets the init program. */ public ContainerProgram getInitProgram() { if (_postConstructList != null) { if (_initProgram == null) _initProgram = new ContainerProgram(); for (ConfigProgram program : _postConstructList) _initProgram.addProgram(program); _postConstructList = null; } return _initProgram; } /** * Gets the server program. */ public ContainerProgram getServerProgram() { return _serverProgram; } /** * Configure initialization. */ @PostConstruct public void init() throws ConfigException { try { if (_isInit) return; _isInit = true; if (getEJBClassWrapper() == null) throw error(L.l("ejb-class is not defined for '{0}'", getEJBName())); _bean = createBeanGenerator(); if (getLocalHome() != null) _bean.setLocalHome(getLocalHome()); for (ApiClass localApi : _localList) { _bean.addLocal(localApi); } if (getRemoteHome() != null) _bean.setRemoteHome(getRemoteHome()); for (ApiClass remoteApi : _remoteList) { _bean.addRemote(remoteApi); } // XXX: add local api introspect(); _bean.createViews(); InterceptorBinding interceptor = getConfig().getInterceptorBinding(getEJBName(), false); if (_aroundInvokeMethodName != null) { ApiMethod method = getMethod(_aroundInvokeMethodName, new Class[] { InvocationContext.class }); if (method == null) throw error(L.l("'{0}' is an unknown around-invoke method", _aroundInvokeMethodName)); _bean.setAroundInvokeMethod(method.getMethod()); } if (interceptor != null) { for (Class cl : interceptor.getInterceptors()) { _bean.addInterceptor(cl); } } for (View view : _bean.getViews()) { for (BusinessMethodGenerator bizMethod : view.getMethods()) { if (! isContainerTransaction()) bizMethod.getXa().setContainerManaged(false); } } for (EjbMethodPattern method : _methodList) { method.configure(_bean); } for (RemoveMethod method : _removeMethods) { method.configure(_bean); } // initIntrospect(); // assembleBeanMethods(); // createViews(); } catch (ConfigException e) { throw ConfigException.createLine(_location, e); } } protected void introspect() { _bean.introspect(); } /** * Creates the BeanGenerator generator instance */ protected BeanGenerator createBeanGenerator() { throw new UnsupportedOperationException(getClass().getName()); } /** * Configure initialization. */ public void initIntrospect() throws ConfigException { boolean isExcludeDefault = false; // XXX: ejb/0f78 /* if (_ejbClass != null) { Interceptors interceptorsAnn = _ejbClass.getAnnotation(Interceptors.class); if (interceptorsAnn != null) { for (Class cl : interceptorsAnn.value()) { // XXX: ejb/0fb0 if (! containsInterceptor(cl.getName())) { addInterceptor(configureInterceptor(cl)); } } } // ejb/0fbj if (_ejbClass.isAnnotationPresent(ExcludeDefaultInterceptors.class)) isExcludeDefault = true; } */ // ejb/0fb5 InterceptorBinding binding = _ejbConfig.getInterceptorBinding(getEJBName(), isExcludeDefault); /* if (binding != null) { ArrayList<Class> interceptorClasses = binding.getInterceptors(); // ejb/0fb7 if (interceptorClasses.isEmpty()) { InterceptorOrder interceptorOrder = binding.getInterceptorOrder(); // ejb/0fbf if (interceptorOrder != null) interceptorClasses = interceptorOrder.getInterceptorClasses(); } for (String className : interceptorClasses) { Interceptor interceptor = getInterceptor(className); // ejb/0fb5 vs ejb/0fb6 if (interceptor != null) { _interceptors.remove(interceptor); addInterceptor(interceptor);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?