Skip to content

Commit

Permalink
TEIIDDES-1518: Create interfaces for TeiidConnectionInfo and subclasses
Browse files Browse the repository at this point in the history
* TeiidConnectionInfo
* TeiidAdminInfo
* TeiidJdbcInfo
 * Makes the codebase more flexible and easier to create a common spi
  • Loading branch information
Paul Richardson committed Nov 15, 2012
1 parent 5583a06 commit 0807d48
Show file tree
Hide file tree
Showing 19 changed files with 248 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import org.teiid.designer.metamodels.relational.ProcedureParameter;
import org.teiid.designer.metamodels.webservice.Operation;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.ITeiidJdbcInfo;
import org.teiid.designer.runtime.ITeiidServer;
import org.teiid.designer.runtime.ITeiidTranslator;
import org.teiid.designer.runtime.ITeiidVdb;
Expand Down Expand Up @@ -383,7 +384,7 @@ private void internalRun( final EObject eObject,
vdbName = vdbName.substring(0, vdbName.length() - 4);
}

TeiidJdbcInfo jdbcInfo = new TeiidJdbcInfo(vdbName, defaultServer.getTeiidJdbcInfo());
ITeiidJdbcInfo jdbcInfo = new TeiidJdbcInfo(vdbName, defaultServer.getTeiidJdbcInfo());

// Note that this is a Transient profile, it is not visible in
// the UI and goes away when it is garbage collected.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
import org.teiid.designer.core.util.StringUtilities;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.ITeiidJdbcInfo;
import org.teiid.designer.runtime.ITeiidServer;
import org.teiid.designer.runtime.TeiidJdbcInfo;
import org.teiid.designer.runtime.TeiidServerManager;
import org.teiid.designer.runtime.adapter.TeiidServerAdapterFactory;
import org.teiid.designer.runtime.ui.DqpUiConstants;
Expand Down Expand Up @@ -203,7 +203,7 @@ private void constructTeiidJdbcConnectionPanel( Composite parent ) {
GridDataFactory.swtDefaults().applyTo(label);

jdbcUsernameText = new Text(teiidJdbcGroup, SWT.BORDER);
jdbcUsernameText.setText(TeiidJdbcInfo.DEFAULT_JDBC_USERNAME);
jdbcUsernameText.setText(ITeiidJdbcInfo.DEFAULT_JDBC_USERNAME);
GridDataFactory.fillDefaults().applyTo(jdbcUsernameText);
jdbcUsernameText.setToolTipText(UTIL.getString("serverPageUserToolTip")); //$NON-NLS-1$
jdbcUsernameText.addFocusListener(new FocusAdapter() {
Expand All @@ -220,7 +220,7 @@ public void focusLost(FocusEvent e) {
GridDataFactory.swtDefaults().applyTo(label);

jdbcPasswordText = new Text(teiidJdbcGroup, SWT.BORDER);
jdbcPasswordText.setText(TeiidJdbcInfo.DEFAULT_JDBC_PASSWORD);
jdbcPasswordText.setText(ITeiidJdbcInfo.DEFAULT_JDBC_PASSWORD);
GridDataFactory.fillDefaults().grab(true, false).applyTo(jdbcPasswordText);
jdbcPasswordText.setToolTipText(UTIL.getString("serverPagePasswordToolTip")); //$NON-NLS-1$
jdbcPasswordText.setEchoChar('*');
Expand Down Expand Up @@ -311,12 +311,12 @@ public void run() {

jbossServerNameText.setText(server.getName());

TeiidJdbcInfo teiidJdbcInfo = teiidServer.getTeiidJdbcInfo();
ITeiidJdbcInfo teiidJdbcInfo = teiidServer.getTeiidJdbcInfo();

if (TeiidJdbcInfo.DEFAULT_JDBC_USERNAME.equals(jdbcUsernameText.getText()))
if (ITeiidJdbcInfo.DEFAULT_JDBC_USERNAME.equals(jdbcUsernameText.getText()))
jdbcUsernameText.setText(teiidJdbcInfo.getUsername());

if (TeiidJdbcInfo.DEFAULT_JDBC_PASSWORD.equals(jdbcPasswordText.getText()))
if (ITeiidJdbcInfo.DEFAULT_JDBC_PASSWORD.equals(jdbcPasswordText.getText()))
jdbcPasswordText.setText(teiidJdbcInfo.getPassword());

jdbcURLText.setText(teiidJdbcInfo.getUrl());
Expand All @@ -339,7 +339,7 @@ private void handlePropertiesModified() {
if (teiidServer != null) {
teiidServer.setCustomLabel(displayNameText.getText());

TeiidJdbcInfo teiidJdbcInfo = teiidServer.getTeiidJdbcInfo();
ITeiidJdbcInfo teiidJdbcInfo = teiidServer.getTeiidJdbcInfo();
teiidJdbcInfo.setUsername(jdbcUsernameText.getText());
teiidJdbcInfo.setPassword(jdbcPasswordText.getText());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import org.teiid.designer.runtime.ExecutionConfigurationEvent;
import org.teiid.designer.runtime.ExecutionConfigurationEvent.TargetType;
import org.teiid.designer.runtime.IExecutionConfigurationListener;
import org.teiid.designer.runtime.ITeiidJdbcInfo;
import org.teiid.designer.runtime.ITeiidServer;
import org.teiid.designer.runtime.TeiidJdbcInfo;
import org.teiid.designer.runtime.TeiidServerManager;
import org.teiid.designer.ui.common.util.WidgetFactory;

Expand Down Expand Up @@ -326,7 +326,7 @@ public void doSave(IProgressMonitor monitor) {
// Overwrite the properties of the teiid server
teiidServer.setCustomLabel(customNameText.getText());

TeiidJdbcInfo jdbcInfo = teiidServer.getTeiidJdbcInfo();
ITeiidJdbcInfo jdbcInfo = teiidServer.getTeiidJdbcInfo();
jdbcInfo.setUsername(jdbcUserNameText.getText());
jdbcInfo.setPassword(jdbcPasswdText.getText());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.teiid.designer.datatools.ui.dialogs.NewTeiidFilteredCPWizard;
import org.teiid.designer.datatools.ui.dialogs.TeiidCPWizardDialog;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.ITeiidJdbcInfo;
import org.teiid.designer.runtime.ITeiidServer;
import org.teiid.designer.runtime.TeiidJdbcInfo;
import org.teiid.designer.runtime.ui.DqpUiConstants;
Expand Down Expand Up @@ -139,7 +140,7 @@ public void processForDTP(ITeiidServer teiidServer, String vdbName)
throws Exception {

String driverPath = teiidServer.getAdminDriverPath();
TeiidJdbcInfo jdbcInfo = new TeiidJdbcInfo(vdbName,teiidServer.getTeiidJdbcInfo());
ITeiidJdbcInfo jdbcInfo = new TeiidJdbcInfo(vdbName, teiidServer.getTeiidJdbcInfo());

String connectionURL = jdbcInfo.getUrl();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* JBoss, Home of Professional Open Source.
*
* See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
*
* See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
*/
package org.teiid.designer.runtime;

/**
* @since 8.0
*/
public interface ITeiidAdminInfo extends ITeiidConnectionInfo {

/**
* The default Teiid Admin persist password flag. Value is {@value} .
*/
public static final boolean DEFAULT_PERSIST_PASSWORD = true;
/**
* The default Teiid Admin port number. Value is {@value} .
*/
public static final String DEFAULT_PORT = "9999"; //$NON-NLS-1$
/**
* The default Teiid Admin secure protocol flag. Value is {@value} .
*/
public static final boolean DEFAULT_SECURE = true;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* JBoss, Home of Professional Open Source.
*
* See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
*
* See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
*/
package org.teiid.designer.runtime;

import org.eclipse.core.runtime.IStatus;
import org.teiid.datatools.connectivity.security.ISecureStorageProvider;

/**
* @since 8.0
*/
public interface ITeiidConnectionInfo {

/**
* Protocol address prefix for secure server connections
*/
public static final String MMS = "mms://"; //$NON-NLS-1$
/**
* Protocol address prefix for server connections
*/
public static final String MM = "mm://"; //$NON-NLS-1$

/**
* @return the password (can be <code>null</code> or empty)
*/
String getPassword();

/**
* @return the port (can be <code>null</code> or empty)
*/
String getPort();

/**
* @return the port number
*/

int getPortNumber();

/**
* @return the connection type (never <code>null</code>)
*/
String getType();

/**
* @return the host provider (never <code>null</code>)
*/
HostProvider getHostProvider();

/**
* @return the secureStorageProvider
*/
ISecureStorageProvider getSecureStorageProvider();

/**
* @return the URL (never <code>null</code>)
*/
String getUrl();

/**
* @return the user name (can be <code>null</code> or empty)
*/
String getUsername();

/**
* @return <code>true</code> if a secure connection protocol is being used
*/
boolean isSecure();

/**
* The port, password, user name, persisting password, secure protocol, and host provider are set.
*
* @param info the connection properties whose values are being used to update state
*/
void setAll(ITeiidConnectionInfo info);

/**
* @param hostProvider the new value for host provider (never <code>null</code>)
* @throws IllegalArgumentException if hostProvider is <code>null</code>
*/
void setHostProvider(HostProvider hostProvider);

/**
* @param password the new value for password (can be empty or <code>null</code>)
*/
void setPassword(String password);

/**
* @param port the new value for port (never empty or <code>null</code>)
* @see #validate()
*/
void setPort(String port);

/**
* @param secure the new value for if a secure connection protocol should be used
*/
void setSecure(boolean secure);

/**
* @param username the new value for user name
* @see #validate()
*/
void setUsername(String username);

/**
* @return a status indicating if the connection info is in a validate state (never <code>null</code>)
*/
IStatus validate();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* JBoss, Home of Professional Open Source.
*
* See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
*
* See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
*/
package org.teiid.designer.runtime;

/**
* @since 8.0
*/
public interface ITeiidJdbcInfo extends ITeiidConnectionInfo {

/**
* The default Teiid JDBC port number. Value is {@value} .
*/
public static final String DEFAULT_PORT = "31000"; //$NON-NLS-1$
/**
* The default Teiid Admin secure protocol flag. Value is {@value} .
*/
public static final boolean DEFAULT_SECURE = false;
/**
* The default username for the teiid server
*/
public static final String DEFAULT_JDBC_USERNAME = "user"; //$NON-NLS-1$
/**
* The default password for the teiid server
*/
public static final String DEFAULT_JDBC_PASSWORD = "user"; //$NON-NLS-1$

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public interface ITeiidServer extends IExecutionAdmin, HostProvider {
/**
* @return TeiidAdminInfo
*/
TeiidAdminInfo getTeiidAdminInfo();
ITeiidAdminInfo getTeiidAdminInfo();

/**
* @return TeiidJdbcInfo
*/
TeiidJdbcInfo getTeiidJdbcInfo();
ITeiidJdbcInfo getTeiidJdbcInfo();

/**
* An appropriate name for this teiid server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class OrphanedTeiidServerException extends Exception {
*
* @param teiidAdminInfo
*/
public OrphanedTeiidServerException(TeiidAdminInfo teiidAdminInfo) {
public OrphanedTeiidServerException(ITeiidAdminInfo teiidAdminInfo) {
this.teiidServerUrl = teiidAdminInfo.getUrl();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,7 @@
*
* @since 8.0
*/
public class TeiidAdminInfo extends TeiidConnectionInfo {

/**
* The default Teiid Admin persist password flag. Value is {@value} .
*/
public static final boolean DEFAULT_PERSIST_PASSWORD = true;

/**
* The default Teiid Admin port number. Value is {@value} .
*/
public static final String DEFAULT_PORT = "9999"; //$NON-NLS-1$

/**
* The default Teiid Admin secure protocol flag. Value is {@value} .
*/
public static final boolean DEFAULT_SECURE = true;
public class TeiidAdminInfo extends TeiidConnectionInfo implements ITeiidAdminInfo {

/**
* @param port the connection port (can be <code>null</code> or empty)
Expand Down Expand Up @@ -55,7 +40,7 @@ protected String getPasswordKey() {
*/
@SuppressWarnings( "javadoc" )
@Override
public TeiidAdminInfo clone() {
public ITeiidAdminInfo clone() {
TeiidAdminInfo cloned = new TeiidAdminInfo(getPort(), getUsername(), getSecureStorageProvider(), getPassword(), isSecure());
cloned.setHostProvider(getHostProvider());
return cloned;
Expand Down

0 comments on commit 0807d48

Please sign in to comment.