use of io.crnk.meta.MetaModule in project crnk-framework by crnk-project.
the class TSGeneratorTest method setup.
@Before
public void setup() {
Project project = Mockito.mock(Project.class);
TSGeneratorExtension config = new TSGeneratorExtension(project, null);
File outputDir = testProjectDir.getRoot();
MetaModuleConfig metaConfig = new MetaModuleConfig();
metaConfig.addMetaProvider(new ResourceMetaProvider());
MetaModule metaModule = MetaModule.createServerModule(metaConfig);
CrnkBoot boot = new CrnkBoot();
boot.setServiceDiscovery(new EmptyServiceDiscovery());
boot.addModule(metaModule);
boot.boot();
generator = new TSGenerator(outputDir, metaModule.getLookup(), config);
}
use of io.crnk.meta.MetaModule in project crnk-framework by crnk-project.
the class MetaModuleProducer method createMetaModule.
@Produces
@ApplicationScoped
public MetaModule createMetaModule() {
MetaModuleConfig metaConfig = new MetaModuleConfig();
metaConfig.addMetaProvider(new ResourceMetaProvider());
MetaModule metaModule = MetaModule.createServerModule(metaConfig);
return metaModule;
}
use of io.crnk.meta.MetaModule in project crnk-framework by crnk-project.
the class AbstractMetaJerseyTest method createModule.
public MetaModule createModule() {
MetaModule module = MetaModule.create();
module.addMetaProvider(new ResourceMetaProvider());
return module;
}
use of io.crnk.meta.MetaModule in project crnk-framework by crnk-project.
the class CdiRunner method run.
public void run(GeneratorTrigger context) throws IOException {
Weld weld = new Weld();
try {
weld.setClassLoader(context.getClassLoader());
weld.initialize();
CrnkBoot boot = new CrnkBoot();
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://<generator>"));
boot.boot();
ModuleRegistry moduleRegistry = boot.getModuleRegistry();
Optional<MetaModule> optionalModule = moduleRegistry.getModule(MetaModule.class);
if (!optionalModule.isPresent()) {
throw new IllegalStateException("add MetaModule to CDI setup, got: " + moduleRegistry.getModules() + " with " + boot.getServiceDiscovery());
}
MetaModule metaModule = optionalModule.get();
MetaLookup lookup = metaModule.getLookup();
context.generate(lookup);
} finally {
weld.shutdown();
}
}
use of io.crnk.meta.MetaModule in project crnk-framework by crnk-project.
the class SpringRunner method run.
public void run(GeneratorTrigger context) {
SpringRuntimeConfig springConfig = context.getConfig().getRuntime().getSpring();
if (springConfig.getConfiguration() == null) {
throw new IllegalStateException("typescriptGen.runtime.spring.configuration not specified");
}
if (springConfig.getProfile() == null) {
throw new IllegalStateException("typescriptGen.runtime.spring.profile not specified");
}
ConfigurableApplicationContext applicationContext = null;
try {
Class configurationClass = getClass().getClassLoader().loadClass(springConfig.getConfiguration());
String initializerMethodName = springConfig.getInitializerMethod();
if (initializerMethodName != null) {
Method initializerMethod = configurationClass.getMethod(initializerMethodName);
initializerMethod.invoke(configurationClass);
}
SpringApplication application = new SpringApplication(configurationClass);
application.setWebEnvironment(false);
application.setAdditionalProfiles(springConfig.getProfile());
application.setDefaultProperties(springConfig.getDefaultProperties());
applicationContext = application.run();
MetaModule metaModule = applicationContext.getBean(MetaModule.class);
MetaLookup lookup = metaModule.getLookup();
context.generate(lookup);
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
} catch (IOException e) {
throw new IllegalStateException(e);
} catch (IllegalAccessException e) {
throw new IllegalStateException(e);
} catch (NoSuchMethodException e) {
throw new IllegalStateException(e);
} catch (InvocationTargetException e) {
throw new IllegalStateException(e);
} finally {
if (applicationContext != null) {
applicationContext.close();
}
}
}
Aggregations