Search in sources :

Example 1 with ManagedBeanMeta

use of org.webpieces.router.impl.mgmt.ManagedBeanMeta 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 ManagedBeanMeta

use of org.webpieces.router.impl.mgmt.ManagedBeanMeta in project webpieces by deanhiller.

the class ProdRouterModule method configure.

@Override
public void configure(Binder binder) {
    binder.bind(BufferPool.class).to(TwoPools.class).asEagerSingleton();
    // done with annotation..
    // binder.bind(RouterService.class).to(RouterServiceImpl.class).asEagerSingleton();
    // binder.bind(AbstractRouterService.class).to(ProdRouterService.class).asEagerSingleton();;
    // binder.bind(MetaLoaderProxy.class).to(ProdLoader.class).asEagerSingleton();
    // binder.bind(RouteInvoker.class).to(ProdRouteInvoker.class).asEagerSingleton();
    // binder.bind(ClassForName.class).to(ProdClassForName.class).asEagerSingleton();
    // binder.bind(CompressionCacheSetup.class).to(ProdCompressionCacheSetup.class).asEagerSingleton();;
    binder.bind(RouterConfig.class).toInstance(config);
    // We write all meta for platform managed beans into ManagedBeanMeta such that 'any' plugin could
    // inject ManagedBeanMeta into itself to access and use all that meta data and wrap those beans to modify them
    // The properties plugin does this to expose platform beans as well as app beans
    ManagedBeanMeta beanMeta = new ManagedBeanMeta();
    binder.bind(ManagedBeanMeta.class).toInstance(beanMeta);
    binder.bindListener(Matchers.any(), new GuiceWebpiecesListener(beanMeta));
    binder.bind(PortConfigLookup.class).toInstance(portLookup);
    Validator validator = javax.validation.Validation.buildDefaultValidatorFactory().getValidator();
    ExecutableValidator execValidator = validator.forExecutables();
    binder.bind(Validator.class).toInstance(validator);
    binder.bind(ExecutableValidator.class).toInstance(execValidator);
}
Also used : ExecutableValidator(javax.validation.executable.ExecutableValidator) GuiceWebpiecesListener(org.webpieces.router.impl.mgmt.GuiceWebpiecesListener) TwoPools(org.webpieces.data.api.TwoPools) ManagedBeanMeta(org.webpieces.router.impl.mgmt.ManagedBeanMeta) Validator(javax.validation.Validator) ExecutableValidator(javax.validation.executable.ExecutableValidator)

Example 3 with ManagedBeanMeta

use of org.webpieces.router.impl.mgmt.ManagedBeanMeta 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 SimpleStorage (org.webpieces.router.api.extensions.SimpleStorage)2 ObjectTranslator (org.webpieces.router.impl.params.ObjectTranslator)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 Validator (javax.validation.Validator)1 ExecutableValidator (javax.validation.executable.ExecutableValidator)1 TwoPools (org.webpieces.data.api.TwoPools)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 Startable (org.webpieces.router.api.extensions.Startable)1 CachedBean (org.webpieces.router.impl.mgmt.CachedBean)1 GuiceWebpiecesListener (org.webpieces.router.impl.mgmt.GuiceWebpiecesListener)1