use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class ValueMetaFactory method getValueMetaPluginClasses.
public static List<ValueMetaInterface> getValueMetaPluginClasses() throws KettlePluginException {
List<ValueMetaInterface> list = new ArrayList<ValueMetaInterface>();
List<PluginInterface> plugins = pluginRegistry.getPlugins(ValueMetaPluginType.class);
for (PluginInterface plugin : plugins) {
ValueMetaInterface valueMetaInterface = (ValueMetaInterface) pluginRegistry.loadClass(plugin);
list.add(valueMetaInterface);
}
return list;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class ValueMetaFactory method createValueMeta.
public static ValueMetaInterface createValueMeta(String name, int type, int length, int precision) throws KettlePluginException {
PluginInterface stringPlugin = pluginRegistry.getPlugin(ValueMetaPluginType.class, String.valueOf(type));
if (stringPlugin == null) {
throw new KettlePluginException("Unable to locate value meta plugin of type (id) " + type);
}
ValueMetaInterface valueMeta = pluginRegistry.loadClass(stringPlugin, ValueMetaInterface.class);
valueMeta.setName(name);
valueMeta.setLength(length, precision);
return valueMeta;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class DatabaseMetaStoreUtil method loadDatabaseMetaFromDatabaseElement.
public static DatabaseMeta loadDatabaseMetaFromDatabaseElement(IMetaStore metaStore, IMetaStoreElement element) throws KettlePluginException {
DatabaseMeta databaseMeta = new DatabaseMeta();
PluginRegistry pluginRegistry = PluginRegistry.getInstance();
// Load the appropriate database plugin (database interface)
//
String pluginId = getChildString(element, MetaStoreConst.DB_ATTR_ID_PLUGIN_ID);
String driverClassName = getChildString(element, MetaStoreConst.DB_ATTR_DRIVER_CLASS);
if (Utils.isEmpty(pluginId) && Utils.isEmpty(driverClassName)) {
throw new KettlePluginException("The attributes 'plugin_id' and 'driver_class' can't be both empty");
}
if (Utils.isEmpty(pluginId)) {
// Determine pluginId using the plugin registry.
//
List<PluginInterface> plugins = pluginRegistry.getPlugins(DatabasePluginType.class);
for (PluginInterface plugin : plugins) {
DatabaseInterface databaseInterface = (DatabaseInterface) pluginRegistry.loadClass(plugin);
if (driverClassName.equalsIgnoreCase(databaseInterface.getDriverClass())) {
pluginId = plugin.getIds()[0];
}
}
}
if (Utils.isEmpty(pluginId)) {
throw new KettlePluginException("The 'plugin_id' attribute could not be determined using 'driver_class' value '" + driverClassName + "'");
}
// Look for the plugin
//
PluginInterface plugin = PluginRegistry.getInstance().getPlugin(DatabasePluginType.class, pluginId);
DatabaseInterface databaseInterface = (DatabaseInterface) PluginRegistry.getInstance().loadClass(plugin);
databaseInterface.setPluginId(pluginId);
databaseMeta.setDatabaseInterface(databaseInterface);
databaseMeta.setObjectId(new StringObjectId(element.getId()));
databaseMeta.setName(element.getName());
databaseMeta.setDescription(getChildString(element, MetaStoreConst.DB_ATTR_ID_DESCRIPTION));
String accessTypeString = getChildString(element, MetaStoreConst.DB_ATTR_ID_ACCESS_TYPE);
if (Utils.isEmpty(accessTypeString)) {
accessTypeString = DatabaseMeta.getAccessTypeDesc(DatabaseMeta.TYPE_ACCESS_NATIVE);
}
databaseMeta.setAccessType(DatabaseMeta.getAccessType(accessTypeString));
databaseMeta.setHostname(getChildString(element, MetaStoreConst.DB_ATTR_ID_HOSTNAME));
databaseMeta.setDBPort(getChildString(element, MetaStoreConst.DB_ATTR_ID_PORT));
databaseMeta.setDBName(getChildString(element, MetaStoreConst.DB_ATTR_ID_DATABASE_NAME));
databaseMeta.setUsername(getChildString(element, MetaStoreConst.DB_ATTR_ID_USERNAME));
databaseMeta.setPassword(metaStore.getTwoWayPasswordEncoder().decode(getChildString(element, MetaStoreConst.DB_ATTR_ID_PASSWORD)));
databaseMeta.setServername(getChildString(element, MetaStoreConst.DB_ATTR_ID_SERVERNAME));
databaseMeta.setDataTablespace(getChildString(element, MetaStoreConst.DB_ATTR_ID_DATA_TABLESPACE));
databaseMeta.setIndexTablespace(getChildString(element, MetaStoreConst.DB_ATTR_ID_INDEX_TABLESPACE));
IMetaStoreAttribute attributesChild = element.getChild(MetaStoreConst.DB_ATTR_ID_ATTRIBUTES);
if (attributesChild != null) {
// Now add a list of all the attributes set on the database connection...
//
Properties attributes = databaseMeta.getAttributes();
for (IMetaStoreAttribute attr : attributesChild.getChildren()) {
String code = attr.getId();
String value = getAttributeString(attr);
attributes.put(code, Const.NVL(value, ""));
}
}
return databaseMeta;
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class DataHandler method setInfo.
private void setInfo(DatabaseMeta meta) {
if (meta == null) {
return;
}
if (meta.getAttributes().containsKey(EXTRA_OPTION_WEB_APPLICATION_NAME)) {
meta.setDBName((String) meta.getAttributes().get(EXTRA_OPTION_WEB_APPLICATION_NAME));
meta.getAttributes().remove(EXTRA_OPTION_WEB_APPLICATION_NAME);
meta.setChanged();
}
getControls();
// Name:
if (connectionNameBox != null) {
connectionNameBox.setValue(meta.getDisplayName());
}
PluginRegistry registry = PluginRegistry.getInstance();
PluginInterface dInterface = registry.getPlugin(DatabasePluginType.class, meta.getPluginId());
// Connection type:
int index = (dInterface == null ? -1 : new ArrayList<>(connectionMap.keySet()).indexOf(dInterface.getName()));
if (index >= 0) {
connectionBox.setSelectedIndex(index);
} else {
LogChannel.GENERAL.logError("Unable to find database type " + (dInterface == null ? "null" : dInterface.getName()) + " in our connection map");
}
// Access type:
accessBox.setSelectedItem(DatabaseMeta.getAccessTypeDescLong(meta.getAccessType()));
// this is broken out so we can set the cache information only when caching
// connection values
setConnectionSpecificInfo(meta);
loadAccessData();
// Port number:
if (portNumberBox != null) {
portNumberBox.setValue(meta.getDatabasePortNumberString());
}
// Options Parameters:
setOptionsData(meta.getExtraOptions());
// Advanced panel settings:
if (supportBooleanDataType != null) {
supportBooleanDataType.setChecked(meta.supportsBooleanDataType());
}
if (supportTimestampDataType != null) {
supportTimestampDataType.setChecked(meta.supportsTimestampDataType());
}
if (quoteIdentifiersCheck != null) {
quoteIdentifiersCheck.setChecked(meta.isQuoteAllFields());
}
if (lowerCaseIdentifiersCheck != null) {
lowerCaseIdentifiersCheck.setChecked(meta.isForcingIdentifiersToLowerCase());
}
if (upperCaseIdentifiersCheck != null) {
upperCaseIdentifiersCheck.setChecked(meta.isForcingIdentifiersToUpperCase());
}
if (preserveReservedCaseCheck != null) {
preserveReservedCaseCheck.setChecked(meta.preserveReservedCase());
}
if (strictBigNumberInterpretaion != null) {
// check if Oracle
if (meta.getDatabaseInterface() instanceof OracleDatabaseMeta) {
strictBigNumberInterpretaion.setVisible(true);
strictBigNumberInterpretaion.setChecked(((OracleDatabaseMeta) meta.getDatabaseInterface()).strictBigNumberInterpretation());
} else {
strictBigNumberInterpretaion.setVisible(false);
strictBigNumberInterpretaion.setChecked(false);
}
}
if (preferredSchemaName != null) {
preferredSchemaName.setValue(Const.NVL(meta.getPreferredSchemaName(), ""));
}
if (sqlBox != null) {
sqlBox.setValue(meta.getConnectSQL() == null ? "" : meta.getConnectSQL());
}
if (clusteringCheck != null) {
clusteringCheck.setChecked(meta.isPartitioned());
}
setClusterData(meta.getPartitioningInformation());
if (poolingCheck != null) {
poolingCheck.setChecked(meta.isUsingConnectionPool());
}
if (meta.isUsingConnectionPool()) {
if (poolSizeBox != null) {
poolSizeBox.setValue(Integer.toString(meta.getInitialPoolSize()));
}
if (maxPoolSizeBox != null) {
maxPoolSizeBox.setValue(Integer.toString(meta.getMaximumPoolSize()));
}
setPoolProperties(meta.getConnectionPoolingProperties());
}
setReadOnly(meta.isReadOnly());
setDeckChildIndex();
onPoolingCheck();
onClusterCheck();
}
use of org.pentaho.di.core.plugins.PluginInterface in project pentaho-kettle by pentaho.
the class ExtensionPointIntegrationTest method testExtensionPointMapConcurrency.
@Test
public void testExtensionPointMapConcurrency() throws InterruptedException {
final LogChannelInterface log = mock(LogChannelInterface.class);
List<Runnable> parallelTasksList = new ArrayList<>(TOTAL_THREADS_TO_RUN);
for (int i = 0; i < TOTAL_THREADS_TO_RUN; i++) {
parallelTasksList.add(() -> {
KettleExtensionPoint kettleExtensionPoint = getRandomKettleExtensionPoint();
PluginInterface pluginInterface = PluginRegistry.getInstance().getPlugin(ExtensionPointPluginType.class, "id" + kettleExtensionPoint.id);
try {
PluginRegistry.getInstance().removePlugin(ExtensionPointPluginType.class, pluginInterface);
PluginRegistry.getInstance().registerPlugin(ExtensionPointPluginType.class, pluginInterface);
} catch (KettlePluginException e) {
e.printStackTrace();
} catch (NullPointerException e) {
// NullPointerException can be thrown if trying to remove a plugin that doesn't exit, discarding occurence
}
ExtensionPointMap.getInstance().reInitialize();
try {
ExtensionPointMap.getInstance().callExtensionPoint(log, kettleExtensionPoint.id, null);
} catch (KettleException e) {
e.printStackTrace();
}
});
}
assertConcurrent(parallelTasksList);
}
Aggregations