Search in sources :

Example 1 with JavaClassTemplateFactory

use of org.whole.lang.java.codebase.JavaClassTemplateFactory in project whole by wholeplatform.

the class PojoUtilsTest method getCompilationUnits.

public static Misc getCompilationUnits(Class<?>... classes) {
    MiscEntityFactory mef = MiscEntityFactory.instance;
    Misc misc = mef.createMisc(0);
    for (int i = 0; i < classes.length; i++) {
        JavaClassTemplateFactory javaSourceTemplateFactory = new JavaClassTemplateFactory(classes[i]);
        CompilationUnit compilationUnit = javaSourceTemplateFactory.create();
        Any stageUpFragment = CommonsEntityAdapterFactory.createStageUpFragment(MiscEntityDescriptorEnum.Any, compilationUnit);
        misc.wAdd(stageUpFragment);
    }
    return misc;
}
Also used : MiscEntityFactory(org.whole.lang.misc.factories.MiscEntityFactory) CompilationUnit(org.whole.lang.java.model.CompilationUnit) JavaClassTemplateFactory(org.whole.lang.java.codebase.JavaClassTemplateFactory) Misc(org.whole.lang.misc.model.Misc) Any(org.whole.lang.misc.model.Any)

Example 2 with JavaClassTemplateFactory

use of org.whole.lang.java.codebase.JavaClassTemplateFactory in project whole by wholeplatform.

the class WorkflowsInterpreterVisitor method getJavaTemplateFactory.

protected ITemplateFactory<CompilationUnit> getJavaTemplateFactory(LoadJavaModel entity) {
    entity.getClassName().accept(this);
    String className = getResultString();
    if (!Matcher.matchImpl(WorkflowsEntityDescriptorEnum.ClassPath, entity.getClassProvider()))
        throw new UnsupportedOperationException("The Eclipse Workspace is not available");
    try {
        return new JavaClassTemplateFactory(Class.forName(className, false, ReflectionFactory.getClassLoader(getBindings())));
    } catch (ClassNotFoundException e) {
        throw new WholeIllegalArgumentException(e).withSourceEntity(entity).withBindings(getBindings());
    }
}
Also used : JavaClassTemplateFactory(org.whole.lang.java.codebase.JavaClassTemplateFactory) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

Example 3 with JavaClassTemplateFactory

use of org.whole.lang.java.codebase.JavaClassTemplateFactory in project whole by wholeplatform.

the class WorkflowsInterpreterVisitorTest method testLoadJavaModel.

@Test
public void testLoadJavaModel() {
    IEntity loadJavaModelTest = WorkflowsTestTemplateManager.instance().create("loadJavaModelTest");
    IBindingManager args = BindingManagerFactory.instance.createArguments();
    InterpreterOperation.interpret(loadJavaModelTest, args);
    Assert.assertTrue(Matcher.match(args.wGet("model"), new JavaClassTemplateFactory(SampleModel.class).create()));
}
Also used : IEntity(org.whole.lang.model.IEntity) JavaClassTemplateFactory(org.whole.lang.java.codebase.JavaClassTemplateFactory) IBindingManager(org.whole.lang.bindings.IBindingManager) Test(org.junit.Test)

Aggregations

JavaClassTemplateFactory (org.whole.lang.java.codebase.JavaClassTemplateFactory)3 Test (org.junit.Test)1 IBindingManager (org.whole.lang.bindings.IBindingManager)1 WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)1 CompilationUnit (org.whole.lang.java.model.CompilationUnit)1 MiscEntityFactory (org.whole.lang.misc.factories.MiscEntityFactory)1 Any (org.whole.lang.misc.model.Any)1 Misc (org.whole.lang.misc.model.Misc)1 IEntity (org.whole.lang.model.IEntity)1