예제 #1
0
  private IVocabulary makeVocabulary(XlsModuleSyntaxNode moduleNode) {

    final IdentifierNode vocabularyNode = moduleNode.getVocabularyNode();

    if (vocabularyNode == null) {
      return null;
    }

    final ClassLoader userClassLoader = userContext.getUserClassLoader();
    Thread.currentThread().setContextClassLoader(userClassLoader);

    IVocabulary vocabulary =
        (IVocabulary)
            userContext.execute(
                new IExecutable() {

                  public Object execute() {

                    String vocabularyClassName = vocabularyNode.getIdentifier();

                    try {
                      Class<?> vClass = userClassLoader.loadClass(vocabularyClassName);

                      return vClass.newInstance();
                    } catch (Throwable t) {
                      String message =
                          String.format(
                              "Vocabulary type '%s' cannot be loaded", vocabularyClassName);
                      BindHelper.processError(message, vocabularyNode, t);

                      return null;
                    }
                  }
                });
    return vocabulary;
  }