use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class MetaRelationshipRepositoryImpl method getSource.
private MetaElement getSource(String sourceId) {
MetaLookup lookup = lookupSupplier.get();
MetaElement source = lookup.getMetaById().get(sourceId);
if (source == null) {
throw new ResourceNotFoundException(sourceId);
}
return source;
}
use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class MetaResourceRepositoryImpl method findAll.
@Override
public ResourceList<T> findAll(QuerySpec querySpec) {
MetaLookup lookup = lookupSupplier.get();
Collection<T> values = filterByType(lookup.getMetaById().values());
return querySpec.apply(values);
}
use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class MetaLookupTest method setup.
@Before
public void setup() {
metaProvider = new JpaMetaProvider(Collections.<Class>emptySet());
MetaLookup lookup = new MetaLookup();
lookup.addProvider(metaProvider);
}
use of io.crnk.meta.MetaLookup 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.MetaLookup 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