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 voidclearRetryCount()This will set the failedRetryCount to zero.voiddelete(String remappedName)Delete the table with this ID.voiddisableAllAndRestart()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.doublegetDouble(String parameterKey, double defaultValue)Get the first parameter with this key, interpreted as an double.ExternalServerConnectionTypegetExternalServerConnection()intgetFailedRetryAttempts()StringgetId()intgetInt(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.TableProvidergetProvider()TableProviderStatusgetStatus()StringgetString(String parameterKey, String defaultValue)Get the first parameter with this key, trimmed.CatalogedTablegetTable(String remappedName)Find the Table with this ID.TablePropertiesConfigurationWrappergetTableFilteredAliases(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.longgetWakeup()voidinsert(CatalogedTable catalogedTable)Insert this Table.FilelocateFile(String filename, boolean required)This will attempt to locate a file within the project.Stringremap(String name)check and remap a name.voidsetEnabled(String tableId, boolean enabled)Change the enabled state of an existing table.voidsetStartThread(Thread thread)voidsetStatus(TableProviderStatus status)voidshutMeDown()Shut down the associated TableProvider.voidupdate(CatalogedTable catalogedTable)Update this Table.voidupsert(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:TableProviderControlChange 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:
setEnabledin 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:TableProviderControlFind the Table with this ID. If one doesn't exist, then it will return null.- Specified by:
getTablein 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:TableProviderControlGet 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:
getTablesin interfaceTableProviderControl- Returns:
- all the CatalogedTables that belong to your TableProvider
-
insert
public void insert(CatalogedTable catalogedTable)
Description copied from interface:TableProviderControlInsert this Table. It is an error if a Table with that ID already exists.- Specified by:
insertin 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:TableProviderControlInsert or Update the Table, depending on whether or not it already exists.- Specified by:
upsertin 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:TableProviderControlUpdate this Table. It is an error if a Table with that ID does not already exist.- Specified by:
updatein 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:TableProviderControlDelete the table with this ID. It is an error if a Table with that ID does not already exist.- Specified by:
deletein interfaceTableProviderControl
-
shutMeDown
public void shutMeDown()
Description copied from interface:TableProviderControlShut 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:
shutMeDownin 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:TableProviderParametersGet 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:
getStringin 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:TableProviderParametersGet 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:
getIntin 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:TableProviderParametersGet 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:
getDoublein 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:TableProviderParametersFor keys that might appear more than once, this will return all of the values for that key.- Specified by:
getMultivaluein 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:TableProviderParametersGet all the keys that were specified.- Specified by:
getKeysin interfaceTableProviderParameters- Returns:
-
remap
public String remap(String name)
Description copied from interface:TableNameMappercheck 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:
remapin 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:TableNameMapperThis 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:
getTableFilteredAliasesin 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:TableProviderControlThis 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:
clearRetryCountin interfaceTableProviderControl
-
setStartThread
public void setStartThread(Thread thread)
-
disableAllAndRestart
public void disableAllAndRestart()
Description copied from interface:TableProviderControlWhen 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:
disableAllAndRestartin interfaceTableProviderControl
-
locateFile
public File locateFile(String filename, boolean required) throws LiveViewException
Description copied from interface:TableProviderControlThis will attempt to locate a file within the project.- Specified by:
locateFilein 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.
-
-