use of org.webpieces.plugin.backend.spi.BackendGuiDescriptor in project webpieces by deanhiller.
the class H2DbModule method configure.
@Override
protected void configure() {
Multibinder<BackendGuiDescriptor> backendBinder = Multibinder.newSetBinder(binder(), BackendGuiDescriptor.class);
backendBinder.addBinding().to(H2DbGuiDescriptor.class);
bind(H2DbConfig.class).toInstance(config);
bind(ServerConfig.class).toInstance(svrConfig);
try {
String[] args;
// if this port1 is 0, server.getPort will get the real port later in this method
int port1 = config.getPort().get();
if (config.getConvertDomain() == null) {
args = new String[] { "-webPort", port1 + "" };
} else {
// if we are converting a domain, definitely need to allow other ip addresses in..
// this is because we are exposing a domain url on the web to hit
args = new String[] { "-webPort", port1 + "", "-webAllowOthers" };
}
log.info("Creating H2 webserver for html GUI interface to serve up as a webpage(for development servers)");
// start the TCP Server
Server server = Server.createWebServer(args);
log.info("Starting H2 webserver");
server.start();
int port = server.getPort();
log.info("H2 webserver started on port=" + port);
if (config.getConvertDomain() == null) {
log.info("H2 webserver setting webpage to use=" + port);
this.svrConfig.setPort(port);
} else {
log.info("H2 webserver using the domain converter=" + config.getConvertDomain());
}
return;
} catch (Exception e) {
throw SneakyThrow.sneak(e);
}
}
use of org.webpieces.plugin.backend.spi.BackendGuiDescriptor in project webpieces by deanhiller.
the class PropertiesModule method configure.
@Override
public void configure(Binder binder) {
Multibinder<BackendGuiDescriptor> backendBinder = Multibinder.newSetBinder(binder, BackendGuiDescriptor.class);
backendBinder.addBinding().to(PropertiesGuiDescriptor.class);
binder.bind(PropertiesConfig.class).toInstance(config);
Multibinder<Startable> startableBinder = Multibinder.newSetBinder(binder, Startable.class);
// Unfortunately, DURING guice heirarchy construction, we need to record into BeanMetaData
// later, after Guice construction is complete and the Startable.class implementations are being
// called, BeanMetaData can officially use the ObjectTranslator at that point to know if it
// can install methods or not into the GUI
//
// This is a bit complex but
// 1. while guice is creating things, it records in BeanMetaData(which is not injected into anything except the guice listeners at this point)
// 2. guice is done creating the full tree, webpieces invokes all Startable.class including BeanMetaData
// 3. BeanMetaData's start() method now loads all methods and such
// 4. BeanMetaData now loads all properties from DB and applies them from the DB if they exist
// 5. BeanMetaData now kicks off a recurring task to load DB properties (in case props are edited on another server)
Provider<ObjectTranslator> translatorProvider = binder.getProvider(ObjectTranslator.class);
Provider<SimpleStorage> storageProvider = binder.getProvider(SimpleStorage.class);
Provider<ManagedBeanMeta> webpiecesBeanProvider = binder.getProvider(ManagedBeanMeta.class);
Provider<ScheduledExecutorService> schedulerProvider = binder.getProvider(ScheduledExecutorService.class);
BeanMetaData proxy = new BeanMetaData(config, translatorProvider, storageProvider, webpiecesBeanProvider, schedulerProvider);
// this binding is for the controller....
binder.bind(BeanMetaData.class).toInstance(proxy);
// this binding is to plugin to webpieces so the start() method is called
startableBinder.addBinding().toInstance(proxy);
binder.bindListener(Matchers.any(), new GuiceTypeListener(proxy, config));
}
use of org.webpieces.plugin.backend.spi.BackendGuiDescriptor in project webpieces by deanhiller.
the class MenuCreator method createMenuOnce.
private void createMenuOnce() {
Map<MenuCategory, List<SingleMenuItem>> menuMap = new HashMap<>();
for (BackendGuiDescriptor desc : descriptors) {
wireInPages(routes.getReverseRouteLookup(), menuMap, desc);
}
menus = create(menuMap);
}
Aggregations