コード例 #1
0
ファイル: BeanUtil.java プロジェクト: gmeurant/benerator
 /**
  * Instantiates the specified class.
  *
  * @param name the name of the class to instantiate
  * @return the Class instance
  */
 @SuppressWarnings({"unchecked", "rawtypes"})
 public static <T> Class<T> forName(String name) {
   Assert.notNull(name, "class name");
   Class type = simpleTypeMap.get(name);
   if (type != null) return type;
   else {
     try {
       return (Class<T>) getContextClassLoader().loadClass(name);
     } catch (ClassNotFoundException e) {
       throw ExceptionMapper.configurationException(e, name);
     } catch (NullPointerException e) {
       // this is raised by the Eclipse BundleLoader if it does not find the class
       throw ExceptionMapper.configurationException(e, name);
     }
   }
 }
コード例 #2
0
  public SqlMapRepositoryFactory(SqlMapClient sqlMapClient) {
    Assert.notNull(sqlMapClient, "SqlMapClient must not be null!");

    this.sqlMapClient = (SqlMapClientImpl) sqlMapClient;
    this.sqlMapClientTemplate = new SqlMapClientTemplate(sqlMapClient);

    if (ExtendedSqlMapClient.class.isAssignableFrom(sqlMapClient.getClass())) {
      this.sqlMapExecutorDelegate = ((ExtendedSqlMapClient) sqlMapClient).getDelegate();
    } else if (hasSqlMapExecutorDelegate(sqlMapClient)) {
      Field field = findSqlMapExecutorDelegate(sqlMapClient);
      field.setAccessible(true);

      this.sqlMapExecutorDelegate =
          (SqlMapExecutorDelegate) ReflectionUtils.getField(field, sqlMapClient);
    } else {
      throw new IllegalArgumentException("not found SqlMapExecutorDelegate in SqlMapClient.");
    }
  }
コード例 #3
0
  /**
   * Generates views based on annotations found in a persistent class. Typically @DocumentReferences
   * annotations.
   *
   * @param persistentType
   * @return a Map with generated views.
   */
  public Map<String, DesignDocument.View> generateViewsFromPersistentType(
      final Class<?> persistentType) {
    Assert.notNull(persistentType, "persistentType may not be null");
    final Map<String, DesignDocument.View> views = new HashMap<String, DesignDocument.View>();

    createDeclaredViews(views, persistentType);

    eachField(
        persistentType,
        new Predicate<Field>() {
          public boolean apply(Field input) {
            if (hasAnnotation(input, DocumentReferences.class)) {
              generateView(views, input);
            }
            return false;
          }
        });
    return views;
  }
コード例 #4
0
ファイル: AssemblerTest.java プロジェクト: rjsingh/graal
  protected InstalledCode assembleMethod(Method m, CodeGenTest test) {
    ResolvedJavaMethod method = codeCache.lookupJavaMethod(m);
    RegisterConfig registerConfig = codeCache.lookupRegisterConfig();
    CallingConvention cc =
        CodeUtil.getCallingConvention(codeCache, CallingConvention.Type.JavaCallee, method, false);

    CompilationResult compResult = new CompilationResult();
    Buffer codeBuffer = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc);
    compResult.setTargetCode(codeBuffer.close(true), codeBuffer.position());

    InstalledCode code = codeCache.addMethod(method, compResult);

    DisassemblerProvider dis = Graal.getRuntime().getCapability(DisassemblerProvider.class);
    if (dis != null) {
      String disasm = dis.disassemble(code);
      Assert.assertTrue(code.toString(), disasm == null || disasm.length() > 0);
    }
    return code;
  }
コード例 #5
0
ファイル: AssemblerTest.java プロジェクト: rjsingh/graal
 protected void assertReturn(
     String methodName, CodeGenTest test, Object expected, Object... args) {
   Object actual = runTest(methodName, test, args);
   Assert.assertEquals("unexpected return value", expected, actual);
 }