Search in sources :

Example 1 with ObjectTranslator

use of org.webpieces.router.impl.params.ObjectTranslator in project webpieces by deanhiller.

the class BeanMetaData method start.

@Override
public void start() {
    // We are NOW inside Guice and can call the providers
    ManagedBeanMeta webpiecesBeans = webpiecesBeanMetaProvider.get();
    ObjectTranslator objectTranslator = objectTranslatorProvider.get();
    SimpleStorage storage = simpleStorageProvider.get();
    // let's add any webpieces platform beans(we use our own stuff here)
    cachedBeans.addAll(webpiecesBeans.getBeans());
    for (CachedBean bean : cachedBeans) {
        loadBean(objectTranslator, bean.getInjectee(), bean.getInterfaze());
    }
    loadFromDbAndSetProperties(storage, new PropertyInvoker(objectTranslator));
}
Also used : ObjectTranslator(org.webpieces.router.impl.params.ObjectTranslator) ManagedBeanMeta(org.webpieces.router.impl.mgmt.ManagedBeanMeta) SimpleStorage(org.webpieces.router.api.extensions.SimpleStorage) CachedBean(org.webpieces.router.impl.mgmt.CachedBean)

Example 2 with ObjectTranslator

use of org.webpieces.router.impl.params.ObjectTranslator in project webpieces by deanhiller.

the class WebpiecesToAppBindingModule method configure.

@Override
public void configure(Binder binder) {
    // creates an empty binder in case app installs ZERO plugins
    Multibinder.newSetBinder(binder, Startable.class);
    Multibinder.newSetBinder(binder, EntityLookup.class);
    Multibinder.newSetBinder(binder, BodyContentBinder.class);
    Multibinder.newSetBinder(binder, ObjectStringConverter.class);
    Multibinder.newSetBinder(binder, HtmlTagCreator.class);
    // special case so the notFound controller can inspect and list all routes in a web page
    // OR some client application can inject and introspect all web routes as well
    // OR some plugin on startup can look at all routes as well
    // Also, special case so the backend plugin can accept route ids and reverse lookup the URL on them
    binder.bind(RoutingHolder.class).toInstance(routingHolder);
    // These next two bindings are specifically used by the properties plugin but could be used by any other plugins as well
    // special case exposing webpieces managed beans for modification to any plugin that wants to use it
    binder.bind(ManagedBeanMeta.class).toInstance(managedMeta);
    // special case exposing webpieces + application converters (object to string and string to object)
    // This is the lookup class for all those ObjectStringConverter that get installed in the above Multibinder
    // including if you put an object into a cookie as well, so it gets written as a String
    binder.bind(ObjectTranslator.class).toInstance(objectTranslator);
    binder.bind(ScheduledExecutorService.class).toInstance(scheduler);
    binder.bind(PlatformInjector.class).toInstance(new PlatformInjector(injector));
    binder.bind(MeterRegistry.class).toInstance(metrics);
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ObjectTranslator(org.webpieces.router.impl.params.ObjectTranslator) ManagedBeanMeta(org.webpieces.router.impl.mgmt.ManagedBeanMeta) PlatformInjector(org.webpieces.router.api.PlatformInjector) MeterRegistry(io.micrometer.core.instrument.MeterRegistry)

Example 3 with ObjectTranslator

use of org.webpieces.router.impl.params.ObjectTranslator 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));
}
Also used : BackendGuiDescriptor(org.webpieces.plugin.backend.spi.BackendGuiDescriptor) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) BeanMetaData(org.webpieces.plugin.secure.properties.beans.BeanMetaData) ManagedBeanMeta(org.webpieces.router.impl.mgmt.ManagedBeanMeta) Startable(org.webpieces.router.api.extensions.Startable) ObjectTranslator(org.webpieces.router.impl.params.ObjectTranslator) GuiceTypeListener(org.webpieces.plugin.secure.properties.beans.GuiceTypeListener) SimpleStorage(org.webpieces.router.api.extensions.SimpleStorage)

Aggregations

ManagedBeanMeta (org.webpieces.router.impl.mgmt.ManagedBeanMeta)3 ObjectTranslator (org.webpieces.router.impl.params.ObjectTranslator)3 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 SimpleStorage (org.webpieces.router.api.extensions.SimpleStorage)2 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1 BackendGuiDescriptor (org.webpieces.plugin.backend.spi.BackendGuiDescriptor)1 BeanMetaData (org.webpieces.plugin.secure.properties.beans.BeanMetaData)1 GuiceTypeListener (org.webpieces.plugin.secure.properties.beans.GuiceTypeListener)1 PlatformInjector (org.webpieces.router.api.PlatformInjector)1 Startable (org.webpieces.router.api.extensions.Startable)1 CachedBean (org.webpieces.router.impl.mgmt.CachedBean)1