Skip to content

Commit

Permalink
TEIIDDES-1518: Moves the teiid client classes to teiid 8 plugin
Browse files Browse the repository at this point in the history
* Refactors ExecutionAdmin et al to the teiid 8 plugin

* Refactors the teiid server adapters and factories as a
  consequence of the move

* Adds the teiidRuntimeClient extension point for loose coupling
  of the TeiidServer class to ExecutionAdmin class
  • Loading branch information
Paul Richardson committed Dec 7, 2012
1 parent 94ca2b3 commit 948f494
Show file tree
Hide file tree
Showing 46 changed files with 1,409 additions and 438 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ serverPageJDBCUrlToolTip = The URL used to create the JDBC connection to your VD

serverPageOkStatusMsg = Define the Teiid Server connection properties required to perform both JDBC and Admin tasks.
serverPageServerNotStarted = The new jboss server has not been started
serverPageNewServerNotCompatibleWithTeiid =The new server does has not been configured with teiidor is not compatible. Ensure that it is at least a JBoss version 7+ instance.
serverPageNewServerNotCompatibleWithTeiid =The new server does has not been configured with teiid or is not compatible. Ensure that it is at least a JBoss version 7+ instance.
serverPageEmptyCustomLabelMsg = Name cannot be empty

serverWizardEditServerErrorMsg = There were errors editing a Teiid instance. See log for more details.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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.TeiidServerFactory.ServerOptions;
import org.teiid.designer.runtime.TeiidServerManager;
import org.teiid.designer.runtime.adapter.TeiidServerAdapterFactory;
import org.teiid.designer.runtime.spi.ITeiidJdbcInfo;
Expand Down Expand Up @@ -294,7 +295,12 @@ private void createTeiidServer(final IServer server) {
throw new RuntimeException("Cannot create the teiid server on the UI thread"); //$NON-NLS-1$

TeiidServerAdapterFactory factory = new TeiidServerAdapterFactory();
teiidServer = factory.createTeiidServer(server, getServerManager());
/*
* Adapt the IServer to a teiid server but have to consider that the former has
* probably not been started yet so a 'default server' will be returned. Only when
* the server is started will the settings be updated correctly.
*/
teiidServer = factory.adaptServer(server, ServerOptions.NO_CHECK_CONNECTION);

display.asyncExec(new Runnable() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.IServerLifecycleListener;
import org.eclipse.wst.server.core.util.ServerLifecycleAdapter;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServer;
import org.teiid.core.designer.util.I18nUtil;
import org.teiid.designer.runtime.DqpPlugin;
import org.teiid.designer.runtime.TeiidServerManager;
import org.teiid.designer.runtime.adapter.TeiidServerAdapterUtil;
import org.teiid.designer.runtime.spi.ITeiidDataSource;
import org.teiid.designer.runtime.spi.ITeiidTranslator;
import org.teiid.designer.runtime.spi.ITeiidVdb;
Expand Down Expand Up @@ -290,7 +290,7 @@ private void populateJBossServerCombo() {

IServer[] servers = DqpPlugin.getInstance().getServersProvider().getServers();
for (IServer server : servers) {
if (TeiidServerAdapterUtil.isJBossServer(server)) {
if (server.loadAdapter(JBossServer.class, null) != null) {
serverMap.add(server);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.server.core.IServer;
import org.teiid.core.designer.util.I18nUtil;
import org.teiid.designer.runtime.TeiidDataSource;
import org.teiid.designer.runtime.connection.SourceConnectionBinding;
import org.teiid.designer.runtime.spi.ITeiidDataSource;
import org.teiid.designer.runtime.spi.ITeiidServer;
Expand Down Expand Up @@ -107,11 +106,11 @@ public String getName() {

@Override
public String toString() {
if (value instanceof TeiidDataSource) {
if (((TeiidDataSource) value).getDisplayName() != null) {
return ((TeiidDataSource) value).getDisplayName();
if (value instanceof ITeiidDataSource) {
if (((ITeiidDataSource) value).getDisplayName() != null) {
return ((ITeiidDataSource) value).getDisplayName();
}
return ((TeiidDataSource) value).getName();
return ((ITeiidDataSource) value).getName();
}

if (value instanceof ITeiidTranslator) {
Expand Down
1 change: 0 additions & 1 deletion plugins/org.teiid.designer.dqp/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Export-Package: org.teiid.designer.runtime,
org.teiid.designer.runtime.preview.jobs
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0.0)",
org.jdom;bundle-version="[1.1.1,2.0.0)",
org.teiid8;bundle-version="[8.0.0,9.0.0)",
org.eclipse.core.resources;bundle-version="[3.8.0,4.0.0)",
org.teiid.designer.jdbc;bundle-version="[8.0.0,9.0.0)",
org.teiid.designer.jdbc.relational;bundle-version="[8.0.0,9.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import org.eclipse.wst.server.core.IServer;
import org.teiid.core.designer.util.CoreArgCheck;
import org.teiid.designer.core.util.StringUtilities;
import org.teiid.designer.runtime.impl.ExecutionAdmin;
import org.teiid.designer.runtime.adapter.TeiidServerAdapterFactory;
import org.teiid.designer.runtime.registry.TeiidRuntimeRegistry;
import org.teiid.designer.runtime.spi.EventManager;
import org.teiid.designer.runtime.spi.ExecutionConfigurationEvent;
import org.teiid.designer.runtime.spi.HostProvider;
Expand All @@ -32,6 +33,8 @@
import org.teiid.designer.runtime.spi.ITeiidServer;
import org.teiid.designer.runtime.spi.ITeiidTranslator;
import org.teiid.designer.runtime.spi.ITeiidVdb;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;
import org.teiid.designer.runtime.version.spi.TeiidServerVersion;


/**
Expand Down Expand Up @@ -65,6 +68,8 @@ private static boolean equivalent( Object thisObj,
// Fields
// ===========================================================================================================================

private ITeiidServerVersion serverVersion;

protected IExecutionAdmin admin;

/**
Expand Down Expand Up @@ -115,24 +120,27 @@ private static boolean equivalent( Object thisObj,
/**
* Constructs on new <code>Server</code>.
*
* @param host the server host (<code>null</code> or empty if default host should be used)
* @param serverVersion the version of the server
* @param adminInfo the server admin connection properties (never <code>null</code>)
* @param jdbcInfo the server JDBC connection properties (never <code>null</code>)
* @param eventManager the event manager (never <code>null</code>)
* @param parentServer the parent {@link IServer} (never <code>null</code>)
* @throws IllegalArgumentException if any of the parameters are <code>null</code>
*/
public TeiidServer( String host,
TeiidServer( ITeiidServerVersion serverVersion,
ITeiidAdminInfo adminInfo,
ITeiidJdbcInfo jdbcInfo,
EventManager eventManager,
IServer parentServer) {
CoreArgCheck.isNotNull(serverVersion, "serverVersion"); //$NON-NLS-1$
CoreArgCheck.isNotNull(adminInfo, "adminInfo"); //$NON-NLS-1$
CoreArgCheck.isNotNull(jdbcInfo, "jdbcInfo"); //$NON-NLS-1$
CoreArgCheck.isNotNull(eventManager, "eventManager"); //$NON-NLS-1$
CoreArgCheck.isNotNull(parentServer, "parentServer"); //$NON-NLS-1$

this.host = host;
this.serverVersion = serverVersion;

this.host = parentServer.getHost();

this.teiidAdminInfo = adminInfo;
this.teiidAdminInfo.setHostProvider(this);
Expand All @@ -151,6 +159,11 @@ public TeiidServer( String host,
// Methods
// ===========================================================================================================================

@Override
public ITeiidServerVersion getServerVersion() {
return serverVersion;
}

@Override
public void disconnect() {
if (this.admin != null) {
Expand Down Expand Up @@ -195,9 +208,11 @@ public void connect() throws Exception {
}

if (this.admin == null) {
this.admin = TeiidRuntimeRegistry.getInstance().getExecutionAdmin(this);

if (admin != null)
this.admin.connect();

this.admin = new ExecutionAdmin(this);
this.admin.connect();
notifyRefresh();
}
}
Expand Down Expand Up @@ -320,7 +335,11 @@ public boolean isConnected() {
*/
@Override
public boolean isParentConnected() {
return this.parentServer != null && this.parentServer.getServerState() == IServer.STATE_STARTED;
if(this.parentServer == null || this.parentServer.getServerState() != IServer.STATE_STARTED)
return false;

TeiidServerAdapterFactory factory = new TeiidServerAdapterFactory();
return factory.isParentServerConnected(parentServer);
}

/**
Expand Down Expand Up @@ -590,4 +609,14 @@ public String getAdminDriverPath() throws Exception {
connect();
return admin.getAdminDriverPath();
}

@Override
public void update(ITeiidServer otherServer) {
CoreArgCheck.isNotNull(otherServer);

serverVersion = new TeiidServerVersion(otherServer.getServerVersion().toString());

getTeiidAdminInfo().setAll(otherServer.getTeiidAdminInfo());
getTeiidJdbcInfo().setAll(otherServer.getTeiidJdbcInfo());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
* 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 java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.eclipse.wst.server.core.IServer;
import org.teiid.designer.runtime.spi.ITeiidAdminInfo;
import org.teiid.designer.runtime.spi.ITeiidJdbcInfo;
import org.teiid.designer.runtime.spi.ITeiidServer;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;

/**
* @since 8.0
*/
public class TeiidServerFactory {

/**
* Determine whether the {@link ITeiidServer} should be added
* to the {@link TeiidServerManager} after it is created and whether
* it should be connected.
*/
public enum ServerOptions {
/**
* Add the {@link ITeiidServer} to the {@link TeiidServerManager}
*/
ADD_TO_REGISTRY,

/**
* Connect the client to the teiid server
*/
CONNECT,

/**
* Do NOT query the {@link TeiidServerManager}'s registry for an existing
* {@link ITeiidServer}
*/
NO_CHECK_SERVER_REGISTRY,


/**
* Do NOT query whether the parent {@link IServer} is connected
*/
NO_CHECK_CONNECTION
}

/**
* @param teiidServer
* @param serverManager
* @param options
*/
private void processOptions(ITeiidServer teiidServer, TeiidServerManager serverManager, ServerOptions[] options) {
List<ServerOptions> optionList = Collections.emptyList();
if (options != null)
optionList = Arrays.asList(options);

if (optionList.contains(ServerOptions.CONNECT)) {
// Connect this teiid server
try {
teiidServer.connect();
} catch (Exception ex) {
DqpPlugin.Util.log(ex);
}
}

if (optionList.contains(ServerOptions.ADD_TO_REGISTRY)) {
serverManager.addServer(teiidServer);
}
}

/**
* @param serverVersion
* @param serverManager
* @param parentServer
* @param adminPort
* @param adminUserName
* @param adminPassword
* @param jdbcPort
* @param jdbcUserName
* @param jdbcPassword
* @param options
*
* @return new {@link ITeiidServer}
*/
public ITeiidServer createTeiidServer(ITeiidServerVersion serverVersion,
TeiidServerManager serverManager,
IServer parentServer,
String adminPort,
String adminUserName,
String adminPassword,
String jdbcPort,
String jdbcUserName,
String jdbcPassword,
ServerOptions... options) {

ITeiidAdminInfo teiidAdminInfo = new TeiidAdminInfo(adminPort,
adminUserName,
serverManager.getSecureStorageProvider(),
adminPassword,
false);

ITeiidJdbcInfo teiidJdbcInfo = new TeiidJdbcInfo(jdbcPort,
jdbcUserName,
serverManager.getSecureStorageProvider(),
jdbcPassword,
false);

ITeiidServer teiidServer = new TeiidServer(serverVersion, teiidAdminInfo, teiidJdbcInfo, serverManager, parentServer);

processOptions(teiidServer, serverManager, options);

return teiidServer;
}

/**
* @param serverVersion
* @param teiidAdminInfo
* @param teiidJdbcInfo
* @param serverManager
* @param parentServer
* @param options
*
* @return
*/
public ITeiidServer createTeiidServer(ITeiidServerVersion serverVersion,
ITeiidAdminInfo teiidAdminInfo,
ITeiidJdbcInfo teiidJdbcInfo,
TeiidServerManager serverManager,
IServer parentServer,
ServerOptions... options) {

ITeiidServer teiidServer = new TeiidServer(serverVersion, teiidAdminInfo, teiidJdbcInfo, serverManager, parentServer);
processOptions(teiidServer, serverManager, options);

return teiidServer;
}
}

0 comments on commit 948f494

Please sign in to comment.