diff --git a/plugin/ignite-plugin/src/main/scala/org/finos/vuu/feature/ignite/table/IgniteTableFactory.scala b/plugin/ignite-plugin/src/main/scala/org/finos/vuu/feature/ignite/table/IgniteTableFactory.scala index 91795612f..f112dbc68 100644 --- a/plugin/ignite-plugin/src/main/scala/org/finos/vuu/feature/ignite/table/IgniteTableFactory.scala +++ b/plugin/ignite-plugin/src/main/scala/org/finos/vuu/feature/ignite/table/IgniteTableFactory.scala @@ -1,10 +1,10 @@ package org.finos.vuu.feature.ignite.table import org.finos.vuu.api.TableDef -import org.finos.vuu.core.table.DataTable +import org.finos.vuu.core.table.{DataTable, TableContainer} import org.finos.vuu.feature.TableFactory import org.finos.vuu.provider.JoinTableProvider class IgniteTableFactory extends TableFactory { - override def createTable(tableDef: TableDef, joinTableProvider: JoinTableProvider): DataTable = ??? + override def createTable(tableDef: TableDef, tableContainer: TableContainer, joinTableProvider: JoinTableProvider): DataTable = ??? } diff --git a/plugin/virtualized-table-plugin/src/main/scala/org/finos/vuu/plugin/virtualized/VirtualizedTablePlugin.scala b/plugin/virtualized-table-plugin/src/main/scala/org/finos/vuu/plugin/virtualized/VirtualizedTablePlugin.scala index 3bb454bfe..2f168ac12 100644 --- a/plugin/virtualized-table-plugin/src/main/scala/org/finos/vuu/plugin/virtualized/VirtualizedTablePlugin.scala +++ b/plugin/virtualized-table-plugin/src/main/scala/org/finos/vuu/plugin/virtualized/VirtualizedTablePlugin.scala @@ -2,7 +2,7 @@ package org.finos.vuu.plugin.virtualized import org.finos.toolbox.jmx.MetricsProvider import org.finos.vuu.api.TableDef -import org.finos.vuu.core.table.InMemDataTable +import org.finos.vuu.core.table.{InMemDataTable, TableContainer} import org.finos.vuu.feature.{FilterFactory, JoinTableFactory, SessionTableFactory, SortFactory, TableFactory, ViewPortCallableFactory, ViewPortFactory, ViewPortKeysCreator, ViewPortTableCreator, ViewPortTreeCallableFactory} import org.finos.vuu.plugin.virtualized.plugin.ViewPortVirtualizedTableCreator import org.finos.vuu.plugin.virtualized.viewport.VirtualizedViewPortCallableFactory @@ -14,8 +14,10 @@ object VirtualizedTablePlugin extends DefaultPlugin { final val callableFactory = new VirtualizedViewPortCallableFactory - override def tableFactory(implicit metrics: MetricsProvider): TableFactory = (tableDef: TableDef, joinTableProvider: JoinTableProvider) => { - new InMemDataTable(tableDef, joinTableProvider) + override def tableFactory(implicit metrics: MetricsProvider): TableFactory = (tableDef: TableDef, tableContainer: TableContainer, joinTableProvider: JoinTableProvider) => { + val table = new InMemDataTable(tableDef, joinTableProvider) + tableContainer.addTable(table) + table } override def pluginType: PluginType = VirtualizedTablePluginType diff --git a/plugin/virtualized-table-plugin/src/main/scala/org/finos/vuu/plugin/virtualized/plugin/ViewPortVirtualizedTableCreator.scala b/plugin/virtualized-table-plugin/src/main/scala/org/finos/vuu/plugin/virtualized/plugin/ViewPortVirtualizedTableCreator.scala index 104b538f4..f2daee811 100644 --- a/plugin/virtualized-table-plugin/src/main/scala/org/finos/vuu/plugin/virtualized/plugin/ViewPortVirtualizedTableCreator.scala +++ b/plugin/virtualized-table-plugin/src/main/scala/org/finos/vuu/plugin/virtualized/plugin/ViewPortVirtualizedTableCreator.scala @@ -9,20 +9,22 @@ import org.finos.vuu.plugin.virtualized.api.VirtualizedSessionTableDef import org.finos.vuu.plugin.virtualized.table.VirtualizedSessionTable import org.finos.vuu.viewport.{GroupBy, RowSource} -object ViewPortVirtualizedTableCreator extends ViewPortTableCreator{ +object ViewPortVirtualizedTableCreator extends ViewPortTableCreator { - override def create(table: RowSource, clientSession: ClientSessionId, groupBy: GroupBy, tableContainer: TableContainer)(implicit metrics: MetricsProvider, clock: Clock): RowSource = { +override def create(table: RowSource, clientSession: ClientSessionId, groupBy: GroupBy, tableContainer: TableContainer)(implicit metrics: MetricsProvider, clock: Clock): RowSource = { assert(table.asTable.getTableDef.isInstanceOf[VirtualizedSessionTableDef]) val sessionTableDef = table.asTable.getTableDef.asInstanceOf[VirtualizedSessionTableDef] + createSessionTable(clientSession, sessionTableDef, tableContainer) + } + + private def createSessionTable(clientSession: ClientSessionId, sessionTableDef: VirtualizedSessionTableDef, tableContainer: TableContainer) (implicit metrics: MetricsProvider, clock: Clock) : RowSource= { val sessionTable = new VirtualizedSessionTable(clientSession, sessionTableDef, tableContainer.joinTableProvider, cacheSize = 20_000) val archetypeTable = tableContainer.getTable(sessionTableDef.name) - val provider = archetypeTable.getProvider - sessionTable.setProvider(provider) tableContainer.addTable(sessionTable) diff --git a/vuu/src/main/scala/org/finos/vuu/core/VuuServer.scala b/vuu/src/main/scala/org/finos/vuu/core/VuuServer.scala index c916efdcc..61c1e7ceb 100644 --- a/vuu/src/main/scala/org/finos/vuu/core/VuuServer.scala +++ b/vuu/src/main/scala/org/finos/vuu/core/VuuServer.scala @@ -112,21 +112,17 @@ class VuuServer(config: VuuServerConfig)(implicit lifecycle: LifecycleContainer, def createTable(tableDef: TableDef): DataTable = { logger.info(s"Creating table ${tableDef.name}") - pluginRegistry.withPlugin(tableDef.pluginType){ + pluginRegistry.withPlugin(tableDef.pluginType) { plugin => - val table = plugin.tableFactory.createTable(tableDef, joinProvider) - tableContainer.addTable(table) - table + plugin.tableFactory.createTable(tableDef, tableContainer, joinProvider) } } def createJoinTable(joinDef: JoinTableDef): DataTable = { logger.info(s"Creating joinTable ${joinDef.name}") - pluginRegistry.withPlugin(joinDef.pluginType){ + pluginRegistry.withPlugin(joinDef.pluginType) { plugin => - val table = plugin.joinTableFactory.createJoinTable(joinDef, tableContainer, joinProvider) - tableContainer.addTable(table) - table + plugin.joinTableFactory.createJoinTable(joinDef, tableContainer, joinProvider) } } diff --git a/vuu/src/main/scala/org/finos/vuu/feature/TableFactory.scala b/vuu/src/main/scala/org/finos/vuu/feature/TableFactory.scala index ca651c4b6..cc6192a41 100644 --- a/vuu/src/main/scala/org/finos/vuu/feature/TableFactory.scala +++ b/vuu/src/main/scala/org/finos/vuu/feature/TableFactory.scala @@ -2,9 +2,9 @@ package org.finos.vuu.feature import org.finos.toolbox.jmx.MetricsProvider import org.finos.vuu.api.TableDef -import org.finos.vuu.core.table.DataTable +import org.finos.vuu.core.table.{DataTable, TableContainer} import org.finos.vuu.provider.JoinTableProvider trait TableFactory { - def createTable(tableDef: TableDef, joinTableProvider: JoinTableProvider): DataTable + def createTable(tableDef: TableDef, tableContainer: TableContainer, joinTableProvider: JoinTableProvider): DataTable } diff --git a/vuu/src/main/scala/org/finos/vuu/feature/inmem/VuuInMemPlugin.scala b/vuu/src/main/scala/org/finos/vuu/feature/inmem/VuuInMemPlugin.scala index e8f0974c8..f906c7670 100644 --- a/vuu/src/main/scala/org/finos/vuu/feature/inmem/VuuInMemPlugin.scala +++ b/vuu/src/main/scala/org/finos/vuu/feature/inmem/VuuInMemPlugin.scala @@ -41,8 +41,10 @@ class VuuInMemPlugin extends DefaultPlugin { override def viewPortFactory: ViewPortFactory = ??? override def filterFactory: FilterFactory = ??? override def sortFactory: SortFactory = ??? - override def tableFactory(implicit metrics: MetricsProvider): TableFactory = (tableDef: TableDef, joinTableProvider: JoinTableProvider) => { - new InMemDataTable(tableDef, joinTableProvider) + override def tableFactory(implicit metrics: MetricsProvider): TableFactory = (tableDef: TableDef, tableContainer: TableContainer, joinTableProvider: JoinTableProvider) => { + val table = new InMemDataTable(tableDef, joinTableProvider) + tableContainer.addTable(table) + table } final val viewPortCallableFactoryInstance = new InMemViewPortCallableFactory() diff --git a/vuu/src/test/scala/org/finos/vuu/plugin/TestPlugin.scala b/vuu/src/test/scala/org/finos/vuu/plugin/TestPlugin.scala index fb31d1f24..774335b71 100644 --- a/vuu/src/test/scala/org/finos/vuu/plugin/TestPlugin.scala +++ b/vuu/src/test/scala/org/finos/vuu/plugin/TestPlugin.scala @@ -1,7 +1,7 @@ package org.finos.vuu.plugin import org.finos.toolbox.jmx.MetricsProvider import org.finos.vuu.api.TableDef -import org.finos.vuu.core.table.DataTable +import org.finos.vuu.core.table.{DataTable, TableContainer} import org.finos.vuu.feature.{Feature, FilterFactory, JoinTableFactory, SessionTableFactory, SortFactory, TableFactory, ViewPortCallableFactory, ViewPortFactory, ViewPortKeysCreator, ViewPortTableCreator, ViewPortTreeCallableFactory} import org.finos.vuu.provider.JoinTableProvider @@ -31,7 +31,7 @@ class TestPlugin extends Plugin with TableFactory { override def sortFactory: SortFactory = ??? - override def createTable(tableDef: TableDef, joinTableProvider: JoinTableProvider): DataTable = ??? + override def createTable(tableDef: TableDef, tableContainer: TableContainer, joinTableProvider: JoinTableProvider): DataTable = ??? override def viewPortCallableFactory: ViewPortCallableFactory = ???