コード例 #1
0
  protected Object invokeEJBObjectMethod(Object id, MethodInfo info, Object args[])
      throws Exception {
    Method unadvisedMethod = info.getUnadvisedMethod();
    if (unadvisedMethod.getName().equals("getEJBHome")) {
      if (CurrentRemoteProxyFactory.isSet())
        return CurrentRemoteProxyFactory.get(EJB2RemoteProxyFactory.class).createHome();
      return this.getInitialContext().lookup(this.getMetaData().getHomeJndiName());
    }
    if (unadvisedMethod.getName().equals("getPrimaryKey")) {
      return id;
    }
    if (unadvisedMethod.getName().equals("isIdentical")) {
      // object has no identity
      if (id == null) return false;

      EJBObject bean = (EJBObject) args[0];

      Object primaryKey = bean.getPrimaryKey();
      if (primaryKey == null) return false;

      boolean isIdentical = id.equals(primaryKey);

      return isIdentical;
    }
    if (unadvisedMethod.getName().equals("remove")) {
      try {
        destroySession(id);
      } catch (NoSuchEJBException nsee) {
        String invokingClassName = unadvisedMethod.getDeclaringClass().getName();
        Exception newException =
            (Exception) this.constructProperNoSuchEjbException(nsee, invokingClassName);
        throw newException;
      }

      return null;
    }
    throw new RuntimeException("NYI");
  }
コード例 #2
0
 public void addMethodInfo(MethodInfo info) {
   methodInfos.put(info.getHash(), info);
 }