Class TableProviderControlImpl
- java.lang.Object
-
- com.streambase.liveview.server.table.plugin.TableProviderControlImpl
-
- All Implemented Interfaces:
TableNameMapper
,TableProviderControl
,TableProviderParameters
public class TableProviderControlImpl extends Object implements TableProviderControl, TableNameMapper, TableProviderParameters
-
-
Constructor Summary
Constructors Constructor Description TableProviderControlImpl(String id, TableProvider provider, TableProviderManager manager, ExternalServerConnectionType externalServerConnection, int failedRetryAttempts)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearRetryCount()
This will set the failedRetryCount to zero.void
delete(String remappedName)
Delete the table with this ID.void
disableAllAndRestart()
When a condition arises where the table provider is unable to service any of tables, but it does not wish to have its tables removed from the system.double
getDouble(String parameterKey, double defaultValue)
Get the first parameter with this key, interpreted as an double.ExternalServerConnectionType
getExternalServerConnection()
int
getFailedRetryAttempts()
String
getId()
int
getInt(String parameterKey, int defaultValue)
Get the first parameter with this key, interpreted as an integer.Set<String>
getKeys()
Get all the keys that were specified.List<String>
getMultivalue(String parameterKey)
For keys that might appear more than once, this will return all of the values for that key.TableProvider
getProvider()
TableProviderStatus
getStatus()
String
getString(String parameterKey, String defaultValue)
Get the first parameter with this key, trimmed.CatalogedTable
getTable(String remappedName)
Find the Table with this ID.TablePropertiesConfigurationWrapper
getTableFilteredAliases(String name)
This will match the name against the selector.Collection<CatalogedTable>
getTables()
Get a collection of all the CatalogedTables that belong to your TableProvider.long
getWakeup()
void
insert(CatalogedTable catalogedTable)
Insert this Table.File
locateFile(String filename, boolean required)
This will attempt to locate a file within the project.String
remap(String name)
check and remap a name.void
setEnabled(String tableId, boolean enabled)
Change the enabled state of an existing table.void
setStartThread(Thread thread)
void
setStatus(TableProviderStatus status)
void
shutMeDown()
Shut down the associated TableProvider.void
update(CatalogedTable catalogedTable)
Update this Table.void
upsert(CatalogedTable catalogedTable)
Insert or Update the Table, depending on whether or not it already exists.
-
-
-
Constructor Detail
-
TableProviderControlImpl
public TableProviderControlImpl(String id, TableProvider provider, TableProviderManager manager, ExternalServerConnectionType externalServerConnection, int failedRetryAttempts)
-
-
Method Detail
-
setEnabled
public void setEnabled(String tableId, boolean enabled) throws LiveViewException
Description copied from interface:TableProviderControl
Change the enabled state of an existing table. This is a shortcut over update when you only need to enable or disable the Table. However, it will not update anything else in the Table.- Specified by:
setEnabled
in interfaceTableProviderControl
- Parameters:
tableId
- The ID of the Table to change.enabled
- The new state to change it to.- Throws:
LiveViewException
- if attempting to set a table that does not exist enabled. (Setting a non-existant table disabled is ignored.)
-
getTable
public CatalogedTable getTable(String remappedName)
Description copied from interface:TableProviderControl
Find the Table with this ID. If one doesn't exist, then it will return null.- Specified by:
getTable
in interfaceTableProviderControl
- Parameters:
remappedName
- The ID by which the table is saved (i.e. the remapped name)- Returns:
- null if no Table has that name.
-
getTables
public Collection<CatalogedTable> getTables()
Description copied from interface:TableProviderControl
Get a collection of all the CatalogedTables that belong to your TableProvider. This list it returns is a copy of the real list, so it will not reflect any changes you might make.- Specified by:
getTables
in interfaceTableProviderControl
- Returns:
- all the CatalogedTables that belong to your TableProvider
-
insert
public void insert(CatalogedTable catalogedTable)
Description copied from interface:TableProviderControl
Insert this Table. It is an error if a Table with that ID already exists.- Specified by:
insert
in interfaceTableProviderControl
- Parameters:
catalogedTable
- The Table to insert. Note that the catalogedTable will be copied so further changes to it will not affect anything until you update or upsert.
-
upsert
public void upsert(CatalogedTable catalogedTable)
Description copied from interface:TableProviderControl
Insert or Update the Table, depending on whether or not it already exists.- Specified by:
upsert
in interfaceTableProviderControl
- Parameters:
catalogedTable
- The Table to insert. Note that the catalogedTable will be copied so further changes to it will not affect anything until you update or upsert.
-
update
public void update(CatalogedTable catalogedTable)
Description copied from interface:TableProviderControl
Update this Table. It is an error if a Table with that ID does not already exist.- Specified by:
update
in interfaceTableProviderControl
- Parameters:
catalogedTable
- The Table to insert. Note that the catalogedTable will be copied so further changes to it will not affect anything until you update or upsert.
-
delete
public void delete(String remappedName)
Description copied from interface:TableProviderControl
Delete the table with this ID. It is an error if a Table with that ID does not already exist.- Specified by:
delete
in interfaceTableProviderControl
-
shutMeDown
public void shutMeDown()
Description copied from interface:TableProviderControl
Shut down the associated TableProvider. This is called by the TableProvider upon his learning that his back end is no longer available. These steps will happen on your behalf: - Your tables will all be marked as disabled (which will prevent new queries) - All your active QueryListeners will be closed. This will cause your table's removeListener method to be called. - Your shutdown method will be called - (If you haven't already done so) all your tables will be removed from the Table List (as if you had called delete on them). - If requested in the LVConf or service call, after the specified delay a new instance of your TableProvider will be started up again with the same arguments.- Specified by:
shutMeDown
in interfaceTableProviderControl
-
getProvider
public TableProvider getProvider()
-
getId
public String getId()
-
getStatus
public TableProviderStatus getStatus()
-
setStatus
public void setStatus(TableProviderStatus status)
-
getWakeup
public long getWakeup()
-
getFailedRetryAttempts
public int getFailedRetryAttempts()
-
getExternalServerConnection
public ExternalServerConnectionType getExternalServerConnection()
-
getString
public String getString(String parameterKey, String defaultValue)
Description copied from interface:TableProviderParameters
Get the first parameter with this key, trimmed. Note that if the value exists but is empty, it will return the empty string, not the defaultValue.- Specified by:
getString
in interfaceTableProviderParameters
- Returns:
- String value of the first parameter with that key, or the defaultValue if there weren't any.
-
getInt
public int getInt(String parameterKey, int defaultValue)
Description copied from interface:TableProviderParameters
Get the first parameter with this key, interpreted as an integer. If the parameter does not exist, or if it can't be interpreted as an integer, return the defaultValue- Specified by:
getInt
in interfaceTableProviderParameters
- Returns:
- int value of the first parameter with that key, or the defaultValue if there weren't any or if it isn't an int.
-
getDouble
public double getDouble(String parameterKey, double defaultValue)
Description copied from interface:TableProviderParameters
Get the first parameter with this key, interpreted as an double. If the parameter does not exist, or if it can't be interpreted as a double, return the defaultValue- Specified by:
getDouble
in interfaceTableProviderParameters
- Returns:
- double value of the first parameter with that key, or the defaultValue if there weren't any or if it isn't a double.
-
getMultivalue
public List<String> getMultivalue(String parameterKey)
Description copied from interface:TableProviderParameters
For keys that might appear more than once, this will return all of the values for that key.- Specified by:
getMultivalue
in interfaceTableProviderParameters
- Returns:
- a list, possibly empty, of all values that had that key, in the order that they existed in the Parameters.
-
getKeys
public Set<String> getKeys()
Description copied from interface:TableProviderParameters
Get all the keys that were specified.- Specified by:
getKeys
in interfaceTableProviderParameters
- Returns:
-
remap
public String remap(String name)
Description copied from interface:TableNameMapper
check and remap a name. This will match the name against the selectors. Returns null if none matched, or the remapped string if one did. Note that having no mappings (either because mappings is null or empty) is legitimate, and implies a mapping of (.*) to %s (i.e. everything passes and maps to itself).- Specified by:
remap
in interfaceTableNameMapper
- Parameters:
name
- the name to be remapped- Returns:
- null for no match or the remapped name.
-
getTableFilteredAliases
public TablePropertiesConfigurationWrapper getTableFilteredAliases(String name)
Description copied from interface:TableNameMapper
This will match the name against the selector. Returns null if none matched, or TablePropertiesConfigurationWrapper instance with re-mapped string if one did. Note that having no mappings (either because mappings is null or empty) is legitimate, and implies a mapping of (.*) to %s (i.e. everything passes and maps to itself).- Specified by:
getTableFilteredAliases
in interfaceTableNameMapper
- Parameters:
name
- is the name to be remapped and be wrapped inTablePropertiesConfigurationWrapper
- Returns:
- null for no match or TablePropertiesConfigurationWrapper with remapped name and a list of FilteredAlias instances for this table name
-
clearRetryCount
public void clearRetryCount()
Description copied from interface:TableProviderControl
This will set the failedRetryCount to zero. The failedRetryCount is compared to the MaxRetryCount value that was set by the user in the LVConf (or the web service). This method will be called automatically if your start() method returns normally. However, if you keep the start thread and use it to poll your server (which you are welcome to do), then you should call this method yourself once you've successfully connected.- Specified by:
clearRetryCount
in interfaceTableProviderControl
-
setStartThread
public void setStartThread(Thread thread)
-
disableAllAndRestart
public void disableAllAndRestart()
Description copied from interface:TableProviderControl
When a condition arises where the table provider is unable to service any of tables, but it does not wish to have its tables removed from the system. This method will mark the providers tables as disabled and schedule a restart, if the provider has been so configured. The table provider is responsible for closing any active queries if it can no longer service them.- Specified by:
disableAllAndRestart
in interfaceTableProviderControl
-
locateFile
public File locateFile(String filename, boolean required) throws LiveViewException
Description copied from interface:TableProviderControl
This will attempt to locate a file within the project.- Specified by:
locateFile
in interfaceTableProviderControl
- Parameters:
filename
- indicates a file in the LiveView projectrequired
- if true, this method will throw an exception if the file can't be found.- Returns:
- reference to the actual file, or null if it could not be found (or filename was empty) and required was false.
- Throws:
LiveViewException
- thrown if the required flag was true and either filename was empty or it couldn't find the file.
-
-