teiid SVN: r2063 - in trunk: client/src/main/java and 31 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-04-20 15:13:08 -0400 (Tue, 20 Apr 2010)
New Revision: 2063
Added:
trunk/client/src/main/java/org/teiid/client/ProcedureErrorInstructionException.java
trunk/engine/src/main/java/com/metamatrix/api/
trunk/engine/src/main/java/com/metamatrix/api/exception/
trunk/engine/src/main/java/com/metamatrix/api/exception/query/
trunk/engine/src/main/java/com/metamatrix/api/exception/query/CriteriaEvaluationException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/ExpressionEvaluationException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/FunctionExecutionException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/FunctionMetadataException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/InvalidFunctionException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryMetadataException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryParserException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryPlannerException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryProcessingException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryResolverException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryValidatorException.java
trunk/engine/src/main/java/com/metamatrix/api/exception/query/UnresolvedSymbolDescription.java
Removed:
trunk/adminshell/src/main/java/com/
trunk/client/src/main/java/com/
trunk/common-core/src/main/java/com/metamatrix/common/properties/
trunk/runtime/src/test/java/com/metamatrix/platform/
Modified:
trunk/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
trunk/client/src/main/java/org/teiid/client/ResultsMessage.java
trunk/client/src/main/java/org/teiid/client/SourceWarning.java
trunk/client/src/main/java/org/teiid/client/plan/Annotation.java
trunk/client/src/main/java/org/teiid/client/security/LogonResult.java
trunk/client/src/main/java/org/teiid/client/security/SessionToken.java
trunk/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java
trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
trunk/client/src/main/java/org/teiid/jdbc/DeferredMetadataProvider.java
trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
trunk/client/src/main/java/org/teiid/jdbc/TeiidSQLException.java
trunk/client/src/main/java/org/teiid/net/socket/ServiceInvocationStruct.java
trunk/client/src/main/java/org/teiid/net/socket/SocketUtil.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java
trunk/client/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
trunk/client/src/test/java/org/teiid/jdbc/TestMMSQLException.java
trunk/common-core/src/main/java/com/metamatrix/api/exception/ComponentNotFoundException.java
trunk/common-core/src/main/java/com/metamatrix/api/exception/ExceptionHolder.java
trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixComponentException.java
trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixException.java
trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixProcessingException.java
trunk/common-core/src/main/java/com/metamatrix/common/types/BaseLob.java
trunk/common-core/src/main/java/com/metamatrix/common/types/BlobImpl.java
trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java
trunk/common-core/src/main/java/com/metamatrix/common/types/ClobImpl.java
trunk/common-core/src/main/java/com/metamatrix/common/types/ClobType.java
trunk/common-core/src/main/java/com/metamatrix/common/types/SQLXMLImpl.java
trunk/common-core/src/main/java/com/metamatrix/common/types/Streamable.java
trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java
trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
trunk/common-core/src/main/java/com/metamatrix/common/util/crypto/DhKeyGenerator.java
trunk/common-core/src/main/java/com/metamatrix/core/MetaMatrixCoreException.java
trunk/common-core/src/main/java/com/metamatrix/core/util/ExternalizeUtil.java
trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobValue.java
trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java
trunk/common-core/src/test/java/com/metamatrix/core/util/TestExternalizeUtil.java
trunk/connector-api/src/main/java/org/teiid/connector/api/MetadataProvider.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java
trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java
trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java
trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
Log:
TEIID-207 changes to ensure that clients will more easily adapt between versions
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -41,6 +41,8 @@
private String name;
private ListOverMap<PropertyMetadata> properties = new ListOverMap<PropertyMetadata>(new KeyBuilder<PropertyMetadata>() {
+ private static final long serialVersionUID = 3687928367250819142L;
+
@Override
public String getKey(PropertyMetadata entry) {
return entry.getName();
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ModelMetaData.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -55,7 +55,9 @@
private static final long serialVersionUID = 3714234763056162230L;
@XmlElement(name = "source")
- protected ListOverMap<SourceMappingMetadata> sources = new ListOverMap(new KeyBuilder<SourceMappingMetadata>() {
+ protected ListOverMap<SourceMappingMetadata> sources = new ListOverMap<SourceMappingMetadata>(new KeyBuilder<SourceMappingMetadata>() {
+ private static final long serialVersionUID = 2273673984691112369L;
+
@Override
public String getKey(SourceMappingMetadata entry) {
return entry.getName();
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -134,7 +134,7 @@
if (!sourceRequest()) {
return sessionId == value.sessionId && executionId == value.executionId;
}
- return sessionId == value.sessionId && executionId == value.executionId && nodeID == value.nodeID;
+ return sessionId == value.sessionId && executionId == value.executionId && nodeID.equals(value.nodeID);
}
public int hashCode() {
Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -63,6 +63,8 @@
*/
@XmlElement(name = "model", required = true, type = ModelMetaData.class)
protected ListOverMap<ModelMetaData> models = new ListOverMap<ModelMetaData>(new KeyBuilder<ModelMetaData>() {
+ private static final long serialVersionUID = 846247100420118961L;
+
@Override
public String getKey(ModelMetaData entry) {
return entry.getName();
Copied: trunk/client/src/main/java/org/teiid/client/ProcedureErrorInstructionException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/ProcedureErrorInstructionException.java)
===================================================================
--- trunk/client/src/main/java/org/teiid/client/ProcedureErrorInstructionException.java (rev 0)
+++ trunk/client/src/main/java/org/teiid/client/ProcedureErrorInstructionException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.client;
+
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+
+
+/**
+ * Used to notify the user that the virtual procedure raised an error.
+ * @since 4.3
+ */
+public class ProcedureErrorInstructionException extends MetaMatrixProcessingException {
+
+ /**
+ *
+ * @since 4.3
+ */
+ public ProcedureErrorInstructionException() {
+ super();
+ }
+
+ /**
+ * @param message
+ * @since 4.3
+ */
+ public ProcedureErrorInstructionException(String message) {
+ super(message);
+ }
+
+}
Modified: trunk/client/src/main/java/org/teiid/client/ResultsMessage.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/ResultsMessage.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/client/ResultsMessage.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -30,6 +30,7 @@
import java.util.Collection;
import java.util.List;
+import org.teiid.client.metadata.ParameterInfo;
import org.teiid.client.plan.Annotation;
import org.teiid.client.plan.PlanNode;
@@ -67,7 +68,7 @@
private int finalRow = -1;
/** The parameters of a Stored Procedure */
- private List parameters;
+ private List<ParameterInfo> parameters;
/** OPTION DEBUG log if OPTION DEBUG was used */
private String debugLog;
@@ -265,7 +266,7 @@
finalRow = in.readInt();
//Parameters
- parameters = ExternalizeUtil.readList(in);
+ parameters = ExternalizeUtil.readList(in, ParameterInfo.class);
debugLog = (String)in.readObject();
annotations = ExternalizeUtil.readList(in, Annotation.class);
Modified: trunk/client/src/main/java/org/teiid/client/SourceWarning.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/SourceWarning.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/client/SourceWarning.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -82,9 +82,9 @@
public String toString() {
StringBuffer warningBuf = new StringBuffer();
if (partialResults) {
- warningBuf.append("Error ");
+ warningBuf.append("Error "); //$NON-NLS-1$
} else {
- warningBuf.append("Warning ");
+ warningBuf.append("Warning "); //$NON-NLS-1$
}
warningBuf.append("querying the connector with binding name "); //$NON-NLS-1$
warningBuf.append(connectorBindingName);
Modified: trunk/client/src/main/java/org/teiid/client/plan/Annotation.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/plan/Annotation.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/client/plan/Annotation.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -22,14 +22,16 @@
package org.teiid.client.plan;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
/**
* Annotation describing a decision made during query execution.
*/
-public class Annotation implements Serializable {
+public class Annotation implements Externalizable {
- private static final long serialVersionUID = 7389738177788185542L;
public static final String MATERIALIZED_VIEW = "Materialized View"; //$NON-NLS-1$
public static final String HINTS = "Hints"; //$NON-NLS-1$
@@ -44,6 +46,10 @@
private String resolution;
private Priority priority = Priority.LOW;
+ public Annotation() {
+
+ }
+
public Annotation(String category, String annotation, String resolution, Priority priority) {
this.category = category;
this.annotation = annotation;
@@ -70,4 +76,21 @@
public String toString() {
return "QueryAnnotation<" + getCategory() + ", " + getAnnotation() + ">"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
+
+ @Override
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ annotation = (String)in.readObject();
+ category = (String)in.readObject();
+ resolution = (String)in.readObject();
+ priority = Priority.values()[in.readByte()];
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(annotation);
+ out.writeObject(category);
+ out.writeObject(resolution);
+ out.writeByte(priority.ordinal());
+ }
}
Modified: trunk/client/src/main/java/org/teiid/client/security/LogonResult.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/security/LogonResult.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/client/security/LogonResult.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -22,7 +22,10 @@
package org.teiid.client.security;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.TimeZone;
@@ -33,7 +36,7 @@
*
* Analogous to the server side SessionToken
*/
-public class LogonResult implements Serializable {
+public class LogonResult implements Externalizable {
private static final long serialVersionUID = 4481443514871448269L;
private TimeZone timeZone = TimeZone.getDefault();
@@ -85,5 +88,24 @@
public int getVdbVersion() {
return vdbVersion;
}
+
+ @Override
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ vdbName = (String)in.readObject();
+ sessionToken = (SessionToken)in.readObject();
+ timeZone = (TimeZone)in.readObject();
+ clusterName = (String)in.readObject();
+ vdbVersion = in.readInt();
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(vdbName);
+ out.writeObject(sessionToken);
+ out.writeObject(timeZone);
+ out.writeObject(clusterName);
+ out.writeInt(vdbVersion);
+ }
}
Modified: trunk/client/src/main/java/org/teiid/client/security/SessionToken.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/security/SessionToken.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/client/security/SessionToken.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -22,7 +22,10 @@
package org.teiid.client.security;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.UUID;
/**
@@ -33,7 +36,7 @@
* transit if sent to the client. Also it should only be sent to the client
* who creates the session.
*/
-public class SessionToken implements Serializable, Cloneable {
+public class SessionToken implements Externalizable, Cloneable {
public final static long serialVersionUID = -2853708320435636107L;
/** The session ID */
@@ -146,5 +149,20 @@
}
return null;
}
+
+ @Override
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ secret = (UUID)in.readObject();
+ sessionID = in.readLong();
+ userName = (String)in.readObject();
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(secret);
+ out.writeLong(sessionID);
+ out.writeObject(userName);
+ }
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/jdbc/CallableStatementImpl.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -115,10 +115,7 @@
BigDecimal bigDecimalParam = DataTypeTransformer.getBigDecimal(getObject(parameterIndex));
// set scale on the param value
- bigDecimalParam.setScale(scale);
-
- // return param value
- return bigDecimalParam;
+ return bigDecimalParam.setScale(scale);
}
/**
Modified: trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/jdbc/DatabaseMetaDataImpl.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -460,6 +460,7 @@
}
private ResultSet createResultSet(List records, ResultSetMetaData rsmd) throws SQLException {
+ rsmd.getScale(1); //force the load of the metadata
ResultsMessage resultsMsg = createDummyResultsMessage(null, null, records);
StatementImpl stmt = StatementImpl.newInstance(this.driverConnection, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
return new ResultSetImpl(resultsMsg, stmt, rsmd, 0);
@@ -616,18 +617,22 @@
// get the metadata for the results
rmetadata = results.getMetaData();
+ // logging
+ String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getCols_success", columnNamePattern, tableNamePattern); //$NON-NLS-1$
+ logger.fine(logMsg);
+
+ // construct results object from column values and their metadata
+ return createResultSet(records, rmetadata);
} catch(Exception e) {
// logging
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getCols_error", columnNamePattern, tableNamePattern, e.getMessage()); //$NON-NLS-1$
throw TeiidSQLException.create(e, logMsg);
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
}
- // logging
- String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getCols_success", columnNamePattern, tableNamePattern); //$NON-NLS-1$
- logger.fine(logMsg);
-
- // construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
}
/**
@@ -671,9 +676,10 @@
foreignTable = PERCENT;
}
- ResultSetImpl results = null;
+ ResultSet results = null;
+ PreparedStatement prepareQuery = null;
try {
- PreparedStatement prepareQuery = driverConnection.prepareStatement(QUERY_CROSS_REFERENCES);
+ prepareQuery = driverConnection.prepareStatement(QUERY_CROSS_REFERENCES);
prepareQuery.setObject(1, primaryCatalog.toUpperCase());
prepareQuery.setObject(2, foreignCatalog.toUpperCase());
prepareQuery.setObject(3, primarySchema.toUpperCase());
@@ -682,20 +688,23 @@
prepareQuery.setObject(6, foreignTable.toUpperCase());
// make a query against runtimemetadata and get results
- results = (ResultSetImpl) prepareQuery.executeQuery();
+ results = prepareQuery.executeQuery();
+
+ ResultSet resultSet = getReferenceKeys(results);
+
+ // logging
+ String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getCrossRef_success", primaryTable, foreignTable); //$NON-NLS-1$
+ logger.fine(logMsg);
+ return resultSet;
} catch(Exception e) {
// logging
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getCrossRef_error", primaryTable, foreignTable, e.getMessage()); //$NON-NLS-1$
throw TeiidSQLException.create(e, logMsg);
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
}
-
- ResultSet resultSet = getReferenceKeys(results);
-
- // logging
- String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getCrossRef_success", primaryTable, foreignTable); //$NON-NLS-1$
- logger.fine(logMsg);
-
- return resultSet;
}
/**
@@ -810,26 +819,30 @@
table = PERCENT;
}
- ResultSetImpl results = null;
+ ResultSet results = null;
+ PreparedStatement prepareQuery = null;
try {
- PreparedStatement prepareQuery = driverConnection.prepareStatement(QUERY_EXPORTED_KEYS);
+ prepareQuery = driverConnection.prepareStatement(QUERY_EXPORTED_KEYS);
prepareQuery.setObject(1, catalog.toUpperCase());
prepareQuery.setObject(2, schema.toUpperCase());
prepareQuery.setObject(3, table.toUpperCase());
// make a query against runtimemetadata and get results
- results = (ResultSetImpl) prepareQuery.executeQuery();
+ results = prepareQuery.executeQuery();
+ ResultSet resultSet = getReferenceKeys(results);
+
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getExpKey_success", table));//$NON-NLS-1$
+
+ return resultSet;
} catch(Exception e) {
// logging
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getExpKey_error", table, e.getMessage()); //$NON-NLS-1$
throw TeiidSQLException.create(e, logMsg);
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
}
-
- ResultSet resultSet = getReferenceKeys(results);
-
- logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getExpKey_success", table));//$NON-NLS-1$
-
- return resultSet;
}
/**
@@ -876,26 +889,31 @@
table = PERCENT;
}
- ResultSetImpl results = null;
+ ResultSet results = null;
+ PreparedStatement prepareQuery = null;
try {
- PreparedStatement prepareQuery = driverConnection.prepareStatement(QUERY_IMPORTED_KEYS);
+ prepareQuery = driverConnection.prepareStatement(QUERY_IMPORTED_KEYS);
prepareQuery.setObject(1, catalog.toUpperCase());
prepareQuery.setObject(2, schema.toUpperCase());
prepareQuery.setObject(3, table.toUpperCase());
// make a query against runtimemetadata and get results
- results = (ResultSetImpl) prepareQuery.executeQuery();
+ results = prepareQuery.executeQuery();
+
+ ResultSet resultSet = getReferenceKeys(results);
+
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getImpKey_success", table)); //$NON-NLS-1$
+
+ return resultSet;
} catch(Exception e) {
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getImpKey_error", table, e.getMessage()); //$NON-NLS-1$
throw TeiidSQLException.create(e, logMsg);
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
}
-
- ResultSet resultSet = getReferenceKeys(results);
-
- logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getImpKey_success", table)); //$NON-NLS-1$
-
- return resultSet;
}
/**
@@ -955,15 +973,17 @@
// get the metadata for the results
rmetadata = results.getMetaData();
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getIndex_success", table)); //$NON-NLS-1$
+ // construct results object from column values and their metadata
+ return createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getIndex_error", table, e.getMessage())); //$NON-NLS-1$
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
}
-
- logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getIndex_success", table)); //$NON-NLS-1$
-
- // construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
}
/**
@@ -1178,14 +1198,17 @@
// get the metadata for the results
rmetadata = results.getMetaData();
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getPrimaryKey_success")); //$NON-NLS-1$
+
+ // construct results object from column values and their metadata
+ return createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getPrimaryKey_error", table, e.getMessage())); //$NON-NLS-1$
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
}
-
- logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getPrimaryKey_success")); //$NON-NLS-1$
-
- // construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
}
public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException {
@@ -1236,14 +1259,17 @@
}// end of while
rmetadata = results.getMetaData();
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProcCol_success", columnNamePattern, procedureNamePattern)); //$NON-NLS-1$
+
+ // construct results object from column values and their metadata
+ return createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getProcCol_error", columnNamePattern, e.getMessage())); //$NON-NLS-1$
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
}
-
- logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProcCol_success", columnNamePattern, procedureNamePattern)); //$NON-NLS-1$
-
- // construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
}
public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException {
@@ -1294,14 +1320,17 @@
// get the metadata for the results
rmetadata = results.getMetaData();
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProc_success", procedureNamePattern)); //$NON-NLS-1$
+
+ // construct results object from column values and their metadata
+ return createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getProc_error", procedureNamePattern, e.getMessage())); //$NON-NLS-1$
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
}
-
- logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProc_success", procedureNamePattern)); //$NON-NLS-1$
-
- // construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
}
public String getProcedureTerm() throws SQLException {
@@ -1536,23 +1565,18 @@
// get the metadata for the results
rmetadata = results.getMetaData();
- } catch (SQLException e) {
- throw e;
+
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTable_success", tableNamePattern)); //$NON-NLS-1$
+
+ // construct results object from column values and their metadata
+ return createResultSet(records, rmetadata);
} catch (Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getTable_error", tableNamePattern, e.getMessage())); //$NON-NLS-1$
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
}
-
- // close the results (need to close case results exceed cursor size)
- //results.close();
-
- // close the PreparedStatement, too. Because of the way of closing request in current framework,
- // manually send out a close request is very necessary for PreparedStatement.
- //prepareQuery.close();
-
- logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTable_success", tableNamePattern)); //$NON-NLS-1$
-
- // construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
}
public ResultSet getTableTypes() throws SQLException {
@@ -2253,7 +2277,7 @@
* @return ResultSet object giving the reference key info.
* @throws SQLException if there is an accesing server results
*/
- private ResultSet getReferenceKeys(ResultSetImpl results) throws SQLException {
+ private ResultSet getReferenceKeys(ResultSet results) throws SQLException {
// list which represent records containing reference key info
List records = new ArrayList ();
@@ -2402,13 +2426,16 @@
// Get the metadata for the results
rmetadata = results.getMetaData();
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getschema_success")); //$NON-NLS-1$
+
+ // construct results object from column values and their metadata
+ return createResultSet(records, rmetadata);
} catch(Exception e) {
throw TeiidSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getschema_error", e.getMessage())); //$NON-NLS-1$
+ } finally {
+ if (prepareQuery != null) {
+ prepareQuery.close();
+ }
}
-
- logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getschema_success")); //$NON-NLS-1$
-
- // construct results object from column values and their metadata
- return createResultSet(records, rmetadata);
}
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/DeferredMetadataProvider.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/DeferredMetadataProvider.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/jdbc/DeferredMetadataProvider.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -40,6 +40,7 @@
public class DeferredMetadataProvider extends MetadataProvider {
private StatementImpl statement;
private long requestID;
+ private boolean loaded;
public DeferredMetadataProvider(String[] columnNames, String[] columnTypes, StatementImpl statement, long requestID) {
super(loadPartialMetadata(columnNames, columnTypes));
@@ -47,16 +48,16 @@
this.requestID = requestID;
}
- static Map[] loadPartialMetadata(String[] columnNames, String[] columnTypes) {
+ static Map<Integer, String>[] loadPartialMetadata(String[] columnNames, String[] columnTypes) {
if(columnNames == null || columnTypes == null || columnNames.length != columnTypes.length) {
Object[] params = new Object[] {
StringUtil.toString(columnNames), StringUtil.toString(columnTypes)
};
throw new IllegalArgumentException(JDBCPlugin.Util.getString("DeferredMetadataProvider.Invalid_data", params)); //$NON-NLS-1$
}
- Map[] columnMetadata = new Map[columnNames.length];
+ Map<Integer, String>[] columnMetadata = new Map[columnNames.length];
for(int i=0; i<columnNames.length; i++) {
- columnMetadata[i] = new HashMap();
+ columnMetadata[i] = new HashMap<Integer, String>();
columnMetadata[i].put(ResultsMetadataConstants.ELEMENT_NAME, columnNames[i]);
columnMetadata[i].put(ResultsMetadataConstants.DATA_TYPE, columnTypes[i]);
}
@@ -77,14 +78,12 @@
@Override
public Object getValue(int columnIndex, Integer metadataPropertyKey) throws SQLException {
- Object value = super.getValue(columnIndex, metadataPropertyKey);
-
- if(value == null) {
+ if(!loaded && !(metadataPropertyKey == ResultsMetadataConstants.ELEMENT_NAME || metadataPropertyKey == ResultsMetadataConstants.DATA_TYPE)) {
loadFullMetadata();
- value = super.getValue(columnIndex, metadataPropertyKey);
+ loaded = true;
}
-
- return value;
+
+ return super.getValue(columnIndex, metadataPropertyKey);
}
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -319,7 +319,7 @@
* @throws SQLException, if parameter type/datatype do not match
*/
public void setBoolean (int parameterIndex, boolean value) throws SQLException {
- setObject(parameterIndex, new Boolean(value));
+ setObject(parameterIndex, value);
}
/**
@@ -473,9 +473,7 @@
// transform the object to a BigDecimal
BigDecimal bigDecimalObject = DataTypeTransformer.getBigDecimal(value);
// set scale on the BigDecimal
- bigDecimalObject.setScale(scale);
-
- setObject(parameterIndex, bigDecimalObject);
+ setObject(parameterIndex, bigDecimalObject.setScale(scale));
}
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -288,7 +288,6 @@
this.driverConnection.closeStatement(this);
logger.fine(JDBCPlugin.Util.getString("MMStatement.Close_stmt_success")); //$NON-NLS-1$
- driverConnection = null;
}
/**
Modified: trunk/client/src/main/java/org/teiid/jdbc/TeiidSQLException.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/TeiidSQLException.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/jdbc/TeiidSQLException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -29,14 +29,13 @@
import java.net.UnknownHostException;
import java.sql.SQLException;
+import org.teiid.client.ProcedureErrorInstructionException;
import org.teiid.client.security.InvalidSessionException;
import org.teiid.client.security.LogonException;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
-
import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ProcedureErrorInstructionException;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.MetaMatrixRuntimeException;
Modified: trunk/client/src/main/java/org/teiid/net/socket/ServiceInvocationStruct.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/ServiceInvocationStruct.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/net/socket/ServiceInvocationStruct.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -35,7 +35,7 @@
public final class ServiceInvocationStruct implements Externalizable {
private static final long serialVersionUID = 1207674062670068350L;
- public String targetClass;
+ public Class<?> targetClass;
public String methodName;
public Object[] args;
@@ -49,12 +49,12 @@
ArgCheck.isNotNull(targetClass);
this.args = args;
this.methodName = methodName;
- this.targetClass = targetClass.getName();
+ this.targetClass = targetClass;
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
- this.targetClass = (String)in.readObject();
+ this.targetClass = (Class<?>)in.readObject();
this.methodName = (String)in.readObject();
this.args = ExternalizeUtil.readArray(in, Object.class);
}
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketUtil.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketUtil.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketUtil.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -216,12 +216,15 @@
IOException exception = new IOException(NetPlugin.Util.getString("SocketHelper.keystore_not_found", name)); //$NON-NLS-1$
exception.initCause(e);
throw exception;
- }
+ }
}
KeyStore ks = KeyStore.getInstance(type);
-
- ks.load(stream, password != null ? password.toCharArray() : null);
+ try {
+ ks.load(stream, password != null ? password.toCharArray() : null);
+ } finally {
+ stream.close();
+ }
return ks;
}
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java
===================================================================
--- trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -79,8 +79,12 @@
} else {
clazz = Class.forName(className, true, classLoader);
}
- return ObjectStreamClass.lookup(clazz);
+ return ObjectStreamClass.lookupAny(clazz);
default:
+ clazz = CompactObjectOutputStream.KNOWN_CODES.get(type);
+ if (clazz != null) {
+ return ObjectStreamClass.lookupAny(clazz);
+ }
throw new StreamCorruptedException(
"Unexpected class descriptor type: " + type); //$NON-NLS-1$
}
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java
===================================================================
--- trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -37,16 +37,46 @@
import java.sql.Clob;
import java.sql.SQLException;
import java.sql.SQLXML;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import org.teiid.client.DQP;
+import org.teiid.client.RequestMessage;
+import org.teiid.client.ResultsMessage;
+import org.teiid.client.lob.LobChunk;
+import org.teiid.client.metadata.MetadataResult;
+import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.client.plan.Annotation;
+import org.teiid.client.plan.PlanNode;
+import org.teiid.client.security.ILogon;
+import org.teiid.client.security.InvalidSessionException;
+import org.teiid.client.security.LogonException;
+import org.teiid.client.security.LogonResult;
+import org.teiid.client.security.MetaMatrixSecurityException;
+import org.teiid.client.security.SessionToken;
+import org.teiid.client.xa.XATransactionException;
+import org.teiid.client.xa.XidImpl;
+import org.teiid.net.socket.Handshake;
+import org.teiid.net.socket.Message;
+import org.teiid.net.socket.ServiceInvocationStruct;
+
+import com.metamatrix.api.exception.ExceptionHolder;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
import com.metamatrix.common.types.BlobImpl;
+import com.metamatrix.common.types.BlobType;
import com.metamatrix.common.types.ClobImpl;
+import com.metamatrix.common.types.ClobType;
import com.metamatrix.common.types.InputStreamFactory;
import com.metamatrix.common.types.SQLXMLImpl;
import com.metamatrix.common.types.Streamable;
+import com.metamatrix.common.types.XMLType;
import com.metamatrix.common.types.InputStreamFactory.StreamFactoryReference;
import com.metamatrix.common.util.ReaderInputStream;
+import com.metamatrix.core.MetaMatrixRuntimeException;
/**
* @author The Netty Project (netty-dev(a)lists.jboss.org)
@@ -60,9 +90,58 @@
static final int TYPE_PRIMITIVE = 0;
static final int TYPE_NON_PRIMITIVE = 1;
+ public static final Map<Class<?>, Integer> KNOWN_CLASSES = new HashMap<Class<?>, Integer>();
+ public static final Map<Integer, Class<?>> KNOWN_CODES = new HashMap<Integer, Class<?>>();
+
private List<InputStream> streams = new LinkedList<InputStream>();
private List<StreamFactoryReference> references = new LinkedList<StreamFactoryReference>();
+ public static void addKnownClass(Class<?> clazz, byte code) {
+ KNOWN_CLASSES.put(clazz, Integer.valueOf(code));
+ if (KNOWN_CODES.put(Integer.valueOf(code), clazz) != null) {
+ throw new MetaMatrixRuntimeException("Duplicate class"); //$NON-NLS-1$
+ }
+ }
+
+ static {
+ addKnownClass(ServiceInvocationStruct.class, (byte)2);
+ addKnownClass(Handshake.class, (byte)3);
+ addKnownClass(Message.class, (byte)4);
+ addKnownClass(SerializableReader.class, (byte)5);
+ addKnownClass(SerializableInputStream.class, (byte)6);
+
+ addKnownClass(DQP.class, (byte)10);
+ addKnownClass(LobChunk.class, (byte)11);
+ addKnownClass(RequestMessage.class, (byte)12);
+ addKnownClass(ResultsMessage.class, (byte)13);
+ addKnownClass(PlanNode.class, (byte)14);
+ addKnownClass(PlanNode.Property.class, (byte)15);
+ addKnownClass(Annotation.class, (byte)16);
+ addKnownClass(MetadataResult.class, (byte)17);
+ addKnownClass(ParameterInfo.class, (byte)18);
+ addKnownClass(XidImpl.class, (byte)19);
+ addKnownClass(BlobImpl.class, (byte)20);
+ addKnownClass(ClobImpl.class, (byte)21);
+ addKnownClass(SQLXMLImpl.class, (byte)22);
+ addKnownClass(BlobType.class, (byte)23);
+ addKnownClass(ClobType.class, (byte)24);
+ addKnownClass(XMLType.class, (byte)25);
+ addKnownClass(XATransactionException.class, (byte)26);
+
+ addKnownClass(ILogon.class, (byte)30);
+ addKnownClass(LogonResult.class, (byte)31);
+ addKnownClass(SessionToken.class, (byte)32);
+ addKnownClass(LogonException.class, (byte)33);
+ addKnownClass(MetaMatrixSecurityException.class, (byte)34);
+ addKnownClass(InvalidSessionException.class, (byte)35);
+
+ addKnownClass(ExceptionHolder.class, (byte)40);
+ addKnownClass(MetaMatrixRuntimeException.class, (byte)41);
+ addKnownClass(MetaMatrixComponentException.class, (byte)42);
+ addKnownClass(MetaMatrixException.class, (byte)43);
+ addKnownClass(MetaMatrixProcessingException.class, (byte)44);
+ }
+
public CompactObjectOutputStream(OutputStream out) throws IOException {
super(out);
enableReplaceObject(true);
@@ -83,12 +162,18 @@
@Override
protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException {
- if (desc.forClass().isPrimitive()) {
+ if (desc.forClass().isPrimitive()
+ || !(Externalizable.class.isAssignableFrom(desc.forClass()))) {
write(TYPE_PRIMITIVE);
super.writeClassDescriptor(desc);
} else {
- write(TYPE_NON_PRIMITIVE);
- writeUTF(desc.getName());
+ Integer b = KNOWN_CLASSES.get(desc.forClass());
+ if (b != null) {
+ write(b.intValue());
+ } else {
+ write(TYPE_NON_PRIMITIVE);
+ writeUTF(desc.getName());
+ }
}
}
@@ -110,17 +195,17 @@
return sfr;
} else if (obj instanceof SQLXML) {
streams.add(new ReaderInputStream(((SQLXML)obj).getCharacterStream(), Charset.forName(Streamable.ENCODING)));
- StreamFactoryReference sfr = new SQLXMLImpl((InputStreamFactory)null);
+ StreamFactoryReference sfr = new SQLXMLImpl();
references.add(sfr);
return sfr;
} else if (obj instanceof Clob) {
streams.add(new ReaderInputStream(((Clob)obj).getCharacterStream(), Charset.forName(Streamable.ENCODING)));
- StreamFactoryReference sfr = new ClobImpl(null, -1);
+ StreamFactoryReference sfr = new ClobImpl();
references.add(sfr);
return sfr;
} else if (obj instanceof Blob) {
streams.add(((Blob)obj).getBinaryStream());
- StreamFactoryReference sfr = new BlobImpl(null);
+ StreamFactoryReference sfr = new BlobImpl();
references.add(sfr);
return sfr;
}
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -29,10 +29,7 @@
import org.junit.Test;
-
-
public class TestEmbeddedProfile {
- EmbeddedProfile EmbeddedProfile = new EmbeddedProfile();
/*
* Test method for 'com.metamatrix.jdbc.EmbeddedEmbeddedProfile.acceptsURL(String)'
Modified: trunk/client/src/test/java/org/teiid/jdbc/TestMMSQLException.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestMMSQLException.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestMMSQLException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -31,15 +31,14 @@
import java.net.UnknownHostException;
import java.sql.SQLException;
-import org.teiid.jdbc.TeiidSQLException;
+import junit.framework.TestCase;
+
+import org.teiid.client.ProcedureErrorInstructionException;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
-import junit.framework.TestCase;
-
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ProcedureErrorInstructionException;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.MetaMatrixRuntimeException;
Modified: trunk/common-core/src/main/java/com/metamatrix/api/exception/ComponentNotFoundException.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/api/exception/ComponentNotFoundException.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/api/exception/ComponentNotFoundException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -28,7 +28,9 @@
*/
public class ComponentNotFoundException extends MetaMatrixComponentException {
- /**
+ private static final long serialVersionUID = 8484545412724259223L;
+
+ /**
* No-Arg Constructor
*/
public ComponentNotFoundException( ) {
Modified: trunk/common-core/src/main/java/com/metamatrix/api/exception/ExceptionHolder.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/api/exception/ExceptionHolder.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/api/exception/ExceptionHolder.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -1,23 +1,3 @@
-package com.metamatrix.api.exception;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import com.metamatrix.core.CorePlugin;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.ObjectInputStreamWithClassloader;
-import com.metamatrix.core.util.ReflectionHelper;
-
/*
* JBoss, Home of Professional Open Source.
* See the COPYRIGHT.txt file distributed with this work for information
@@ -40,6 +20,27 @@
* 02110-1301 USA.
*/
+package com.metamatrix.api.exception;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.metamatrix.core.CorePlugin;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.ExternalizeUtil;
+import com.metamatrix.core.util.ObjectInputStreamWithClassloader;
+import com.metamatrix.core.util.ReflectionHelper;
+
public class ExceptionHolder implements Externalizable {
private Throwable exception;
@@ -57,21 +58,21 @@
this.nested = nested;
}
-
//## JDBC4.0-begin ##
@Override
//## JDBC4.0-end ##
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- List<String> classNames = (List<String>)in.readObject();;
+ List<String> classNames = ExternalizeUtil.readList(in, String.class);
String message = (String)in.readObject();
StackTraceElement[] stackTrace = (StackTraceElement[])in.readObject();
+ String code = (String)in.readObject();
ExceptionHolder causeHolder = (ExceptionHolder)in.readObject();
byte[] serializedException = (byte[])in.readObject();
this.exception = readFromByteArray(serializedException);
if (this.exception == null) {
- Throwable t = buildException(classNames, message, stackTrace);
+ Throwable t = buildException(classNames, message, stackTrace, code);
if (t == null) {
if (causeHolder != null) {
this.exception = causeHolder.exception;
@@ -88,7 +89,7 @@
if (this.exception == null) {
this.exception = new MetaMatrixRuntimeException(message);
this.exception.setStackTrace(stackTrace);
- }
+ }
}
//## JDBC4.0-begin ##
@@ -104,9 +105,14 @@
classNames.add(clazz.getName());
clazz = clazz.getSuperclass();
}
- out.writeObject(classNames);
+ ExternalizeUtil.writeList(out, classNames);
out.writeObject(exception.getMessage());
out.writeObject(exception.getStackTrace());
+ if (exception instanceof MetaMatrixCoreException) {
+ out.writeObject(((MetaMatrixCoreException)exception).getCode());
+ } else {
+ out.writeObject(null);
+ }
// specify that this cause is nested exception; not top level
if (this.exception.getCause() != null && this.exception.getCause() != this.exception) {
@@ -129,7 +135,7 @@
return exception;
}
- private Throwable buildException(List<String> classNames, String message, StackTraceElement[] stackTrace) {
+ private Throwable buildException(List<String> classNames, String message, StackTraceElement[] stackTrace, String code) {
List<String> args = Arrays.asList(CorePlugin.Util.getString("ExceptionHolder.converted_exception", message, classNames)); //$NON-NLS-1$
Throwable result = null;
@@ -142,6 +148,12 @@
//
}
}
+
+ if (result instanceof MetaMatrixCoreException) {
+ ((MetaMatrixCoreException)result).setCode(code);
+ ((MetaMatrixCoreException)result).setOriginalType(classNames.get(0));
+ }
+
return result;
}
@@ -169,7 +181,7 @@
}
public static List<ExceptionHolder> toExceptionHolders(List<? extends Throwable> throwables){
- List<ExceptionHolder> list = new ArrayList();
+ List<ExceptionHolder> list = new ArrayList<ExceptionHolder>();
for (Throwable t: throwables) {
list.add(new ExceptionHolder(t));
}
@@ -177,7 +189,7 @@
}
public static List<Throwable> toThrowables(List<ExceptionHolder> exceptionHolders) {
- List<Throwable> list = new ArrayList();
+ List<Throwable> list = new ArrayList<Throwable>();
for(ExceptionHolder e: exceptionHolders) {
list.add(e.getException());
}
Modified: trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixComponentException.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixComponentException.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixComponentException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -29,8 +29,9 @@
*/
public class MetaMatrixComponentException extends MetaMatrixException {
+ private static final long serialVersionUID = 5853804556425201591L;
- /**
+ /**
* No-arg CTOR
*/
public MetaMatrixComponentException( ) {
Modified: trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixException.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixException.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -41,7 +41,9 @@
*/
public class MetaMatrixException extends MetaMatrixCoreException {
- /**
+ private static final long serialVersionUID = -7601629097382531311L;
+
+ /**
* No-arg Constructor
*/
public MetaMatrixException() {
Modified: trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixProcessingException.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixProcessingException.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/api/exception/MetaMatrixProcessingException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -29,8 +29,9 @@
*/
public class MetaMatrixProcessingException extends MetaMatrixException {
+ private static final long serialVersionUID = -4013536109023540872L;
- /**
+ /**
* No-arg Constructor
*/
public MetaMatrixProcessingException() {
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/BaseLob.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/BaseLob.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/BaseLob.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -1,18 +1,24 @@
package com.metamatrix.common.types;
+import java.io.Externalizable;
import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.Reader;
-import java.io.Serializable;
import java.sql.SQLException;
import com.metamatrix.common.types.InputStreamFactory.StreamFactoryReference;
-public class BaseLob implements Serializable, StreamFactoryReference {
+public class BaseLob implements Externalizable, StreamFactoryReference {
private static final long serialVersionUID = -1586959324208959519L;
private InputStreamFactory streamFactory;
+ public BaseLob() {
+
+ }
+
protected BaseLob(InputStreamFactory streamFactory) {
this.streamFactory = streamFactory;
}
@@ -60,5 +66,16 @@
throw ex;
}
}
+
+ @Override
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ streamFactory = (InputStreamFactory)in.readObject();
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(streamFactory);
+ }
}
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/BlobImpl.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/BlobImpl.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/BlobImpl.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -43,6 +43,10 @@
*/
public class BlobImpl extends BaseLob implements Blob, StreamProvider {
+ public BlobImpl() {
+
+ }
+
/**
* Creates a MMBlob object with the <code>valueID</code>.
* @param valueID reference to value chunk in data source.
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -39,11 +39,7 @@
private static final long serialVersionUID = 1294191629070433450L;
- /**
- * Can't construct
- */
- BlobType() {
- super();
+ public BlobType() {
}
public BlobType(Blob blob) {
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/ClobImpl.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/ClobImpl.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/ClobImpl.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -65,8 +65,12 @@
}
}
- private long len;
+ private long len = -1;
+ public ClobImpl() {
+
+ }
+
/**
* Creates a new ClobImpl. Note that the length is not taken from the {@link InputStreamFactory} since
* it refers to bytes and not chars.
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/ClobType.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/ClobType.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/ClobType.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -43,10 +43,7 @@
private static final long serialVersionUID = 2753412502127824104L;
- /**
- * Can't construct
- */
- ClobType() {
+ public ClobType() {
}
public ClobType(Clob clob) {
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/SQLXMLImpl.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/SQLXMLImpl.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/SQLXMLImpl.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -44,6 +44,10 @@
*/
public class SQLXMLImpl extends BaseLob implements SQLXML {
+ public SQLXMLImpl() {
+
+ }
+
/**
* Constructs a SQLXML from bytes that are already encoded in {@link Streamable#ENCODING}
* @param bytes
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/Streamable.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/Streamable.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/Streamable.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -22,7 +22,10 @@
package com.metamatrix.common.types;
-import java.io.Serializable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import com.metamatrix.core.CorePlugin;
@@ -34,7 +37,7 @@
* object is in buffer manager, but the contents will never be written to disk;
* this is the ID that client needs to reference to get the chunk of data.
*/
-public abstract class Streamable<T> implements Serializable {
+public abstract class Streamable<T> implements Externalizable {
private static final long serialVersionUID = -8252488562134729374L;
@@ -84,20 +87,16 @@
}
@Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof Streamable<?>)) {
- return false;
- }
- Streamable<?> other = (Streamable<?>)obj;
-
- if (this.reference != null) {
- return this.reference.equals(other.reference);
- }
-
- return this.referenceStreamId == other.referenceStreamId;
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ length = in.readLong();
+ referenceStreamId = (String)in.readObject();
}
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(length);
+ out.writeObject(referenceStreamId);
+ }
}
Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToCharacterTransform.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -39,7 +39,7 @@
String s = (String) value;
if (s.length() == 0) {
- return new Character(' ');
+ return Character.valueOf(' ');
}
return Character.valueOf(s.charAt(0));
Modified: trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -41,7 +41,6 @@
import java.util.Map;
import java.util.Properties;
-import com.metamatrix.common.properties.UnmodifiableProperties;
import com.metamatrix.core.CorePlugin;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.ArgCheck;
@@ -152,58 +151,22 @@
* copy of the underlying Properties object.
*/
public static Properties clone( Properties props ) {
- boolean makeUnmodifiable = false;
- if ( props instanceof UnmodifiableProperties ) {
- makeUnmodifiable = true;
- }
- return clone(props, makeUnmodifiable);
+ return clone(props, null, false);
}
/**
* Performs a correct deep clone of the properties object by capturing
* all properties in the default(s) and placing them directly into the
- * new Properties object. If an unmodifiable properties object is sought
- * this method returns an
- * <code>UnmodifiableProperties</code> instance around a new (flattened)
- * copy of the underlying Properties object.
- */
- public static Properties clone( Properties props, boolean makeUnmodifiable ) {
- return clone(props, null, false, makeUnmodifiable);
- }
-
- /**
- * Performs a correct deep clone of the properties object by capturing
- * all properties in the default(s) and placing them directly into the
* new Properties object. If the input is an instance of
* <code>UnmodifiableProperties</code>, this method returns an
* <code>UnmodifiableProperties</code> instance around a new (flattened)
* copy of the underlying Properties object.
*/
public static Properties clone( Properties props, Properties defaults, boolean deepClone ) {
- boolean makeUnmodifiable = false;
- if ( props instanceof UnmodifiableProperties ) {
- makeUnmodifiable = true;
- }
- return clone(props,defaults,deepClone, makeUnmodifiable);
- }
-
- /**
- * Performs a correct deep clone of the properties object by capturing
- * all properties in the default(s) and placing them directly into the
- * new Properties object. If an unmodifiable properties object is sought
- * this method returns an
- * <code>UnmodifiableProperties</code> instance around a new (flattened)
- * copy of the underlying Properties object.
- */
- public static Properties clone( Properties props, Properties defaults, boolean deepClone, boolean makeUnmodifiable ) {
Properties result = null;
if ( defaults != null ) {
if ( deepClone ) {
- if ( defaults instanceof UnmodifiableProperties ) {
- defaults = clone(defaults,true);
- } else {
- defaults = clone(defaults,false);
- }
+ defaults = clone(defaults);
}
result = new Properties(defaults);
} else {
@@ -212,10 +175,6 @@
putAll(result, props);
- if ( makeUnmodifiable ) {
- result = new UnmodifiableProperties(result);
- }
-
return result;
}
@@ -441,7 +400,7 @@
fr = new FileReader(fileName);
br = new BufferedReader(fr);
String header = br.readLine();
- if (header.indexOf('#') == 0) {
+ if (header != null && header.indexOf('#') == 0) {
header = header.substring(1);
}
return header;
@@ -887,7 +846,7 @@
// First ensure the pattern is safe to work with.
// If the pattern is an empty string, set it to '*',
// which means anything passes.
- pattern.trim();
+ pattern = pattern.trim();
if ( pattern.length() == 0 )
pattern = "*"; //$NON-NLS-1$
Modified: trunk/common-core/src/main/java/com/metamatrix/common/util/crypto/DhKeyGenerator.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/util/crypto/DhKeyGenerator.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/common/util/crypto/DhKeyGenerator.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -23,6 +23,7 @@
package com.metamatrix.common.util.crypto;
import java.io.IOException;
+import java.io.InputStream;
import java.math.BigInteger;
import java.security.AlgorithmParameterGenerator;
import java.security.AlgorithmParameters;
@@ -45,23 +46,31 @@
import com.metamatrix.core.MetaMatrixRuntimeException;
/**
- * Helper class that supports anonymous ephemeral Diffie-Hellmen
+ * Helper class that supports anonymous ephemeral Diffie-Hellman
*
* Parameters are stored in the dh.properties file
*/
public class DhKeyGenerator {
- private static String ALGORITHM = "DH"; //$NON-NLS-1$
+ private static String ALGORITHM = "DiffieHellman"; //$NON-NLS-1$
private static String DIGEST = "SHA-256"; //$NON-NLS-1$
private static DHParameterSpec DH_SPEC;
static {
Properties props = new Properties();
+ InputStream is = null;
try {
- props.load(DhKeyGenerator.class
- .getResourceAsStream("dh.properties")); //$NON-NLS-1$
+ is = DhKeyGenerator.class.getResourceAsStream("dh.properties"); //$NON-NLS-1$
+ props.load(is);
} catch (IOException e) {
throw new MetaMatrixRuntimeException(e);
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException e) {
+ }
}
BigInteger p = new BigInteger(props.getProperty("p")); //$NON-NLS-1$
BigInteger g = new BigInteger(props.getProperty("g")); //$NON-NLS-1$
Modified: trunk/common-core/src/main/java/com/metamatrix/core/MetaMatrixCoreException.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/MetaMatrixCoreException.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/core/MetaMatrixCoreException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -33,7 +33,9 @@
*/
public class MetaMatrixCoreException extends Exception {
+ private static final long serialVersionUID = -3033427629587497938L;
protected String code;
+ private transient String originalType;
public MetaMatrixCoreException() {
}
@@ -46,7 +48,6 @@
super(message);
this.code = errorCode;
}
-
public MetaMatrixCoreException(Throwable e) {
this(e, e.getMessage());
@@ -66,6 +67,18 @@
return this.code;
}
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getOriginalType() {
+ return originalType;
+ }
+
+ public void setOriginalType(String originalType) {
+ this.originalType = originalType;
+ }
+
private void setCode(Throwable e) {
if (e instanceof MetaMatrixCoreException) {
this.code = (((MetaMatrixCoreException) e).getCode());
Modified: trunk/common-core/src/main/java/com/metamatrix/core/util/ExternalizeUtil.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/ExternalizeUtil.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/ExternalizeUtil.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -155,15 +155,4 @@
return map;
}
- /*
- * Serializing CoreException and subclasses.
- */
- public static void writeThrowable(ObjectOutput out, Throwable t) throws IOException {
- out.writeObject(t);
- }
-
- public static Throwable readThrowable(ObjectInput in) throws IOException, ClassNotFoundException {
- return (Throwable)in.readObject();
- }
-
}
Modified: trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobValue.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobValue.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobValue.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -46,7 +46,7 @@
}
- public void testClobValuePersistence() throws Exception {
+ public void testBlobValuePersistence() throws Exception {
String testString = "this is test clob"; //$NON-NLS-1$
SerialBlob blob = new SerialBlob(testString.getBytes());
Modified: trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -36,7 +36,6 @@
import junit.framework.TestCase;
-import com.metamatrix.common.properties.UnmodifiableProperties;
import com.metamatrix.common.util.PropertiesUtils.InvalidPropertyException;
import com.metamatrix.core.util.UnitTestUtil;
@@ -123,127 +122,59 @@
/**
* Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties)}
*/
- public void testSimpleUnmodifiableClone(){
- Properties a = make(MAP_A, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a);
- assertTrue(verifyProps(a, LIST_A));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties)}
- */
public void testSimpleModifiableClone(){
Properties a = make(MAP_A, null, !UNMODIFIABLE);
a = PropertiesUtils.clone(a);
assertTrue(verifyProps(a, LIST_A));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
/**
* Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties)}
*/
- public void testSimpleUnmodifiableCloneWithUnmodifiableDefaults(){
- Properties ab = make(MAP_A, make(MAP_B, null, UNMODIFIABLE), UNMODIFIABLE);
- ab = PropertiesUtils.clone(ab);
- assertTrue(verifyProps(ab, LIST_AB));
- assertTrue(ab instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties)}
- */
public void testSimpleModifiableCloneWithUnmodifiableDefaults(){
Properties ab = make(MAP_A, make(MAP_B, null, UNMODIFIABLE), !UNMODIFIABLE);
ab = PropertiesUtils.clone(ab);
assertTrue(verifyProps(ab, LIST_AB));
- assertTrue(!(ab instanceof UnmodifiableProperties));
}
/**
* Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties)}
*/
- public void testSimpleUnmodifiableCloneWithModifiableDefaults(){
- Properties ab = make(MAP_A, make(MAP_B, null, !UNMODIFIABLE), UNMODIFIABLE);
- ab = PropertiesUtils.clone(ab);
- assertTrue(verifyProps(ab, LIST_AB));
- assertTrue(ab instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties)}
- */
public void testSimpleModifiableCloneWithModifiableDefaults(){
Properties ab = make(MAP_A, make(MAP_B, null, !UNMODIFIABLE), !UNMODIFIABLE);
ab = PropertiesUtils.clone(ab);
assertTrue(verifyProps(ab, LIST_AB));
- assertTrue(!(ab instanceof UnmodifiableProperties));
}
-
-
-
-
-
-
-
-
// ##################### clone(Properties, boolean) ##########################
-
/**
* Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, boolean)}
*/
public void testCloneModifiableAsModifiable(){
Properties a = make(MAP_A, null, !UNMODIFIABLE);
- a = PropertiesUtils.clone(a, !UNMODIFIABLE);
+ a = PropertiesUtils.clone(a);
assertTrue(verifyProps(a, LIST_A));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
/**
* Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, boolean)}
*/
- public void testCloneModifiableAsUnmodifiable(){
- Properties a = make(MAP_A, null, !UNMODIFIABLE);
- a = PropertiesUtils.clone(a, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_A));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, boolean)}
- */
public void testCloneUnmodifiableAsModifiable(){
Properties a = make(MAP_A, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a, !UNMODIFIABLE);
+ a = PropertiesUtils.clone(a);
assertTrue(verifyProps(a, LIST_A));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
/**
* Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, boolean)}
*/
- public void testCloneUnmodifiableAsUnmodifiable(){
- Properties a = make(MAP_A, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_A));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, boolean)}
- */
public void testCloneModifiableWithModifiableAsModifiable(){
Properties ab = make(MAP_A, make(MAP_B, null, !UNMODIFIABLE), !UNMODIFIABLE);
- ab = PropertiesUtils.clone(ab, !UNMODIFIABLE);
+ ab = PropertiesUtils.clone(ab);
assertTrue(verifyProps(ab, LIST_AB));
- assertTrue(!(ab instanceof UnmodifiableProperties));
}
-
-
// ######## clone(Properties, Properties, boolean, boolean) ##################
/**
@@ -252,9 +183,8 @@
public void testCloneModAndModAsMod(){
Properties a = make(MAP_A, null, !UNMODIFIABLE);
Properties b = make(MAP_B, null, !UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, !DEEP_CLONE, !UNMODIFIABLE);
+ a = PropertiesUtils.clone(a, b, !DEEP_CLONE);
assertTrue(verifyProps(a, LIST_AB));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
/**
@@ -263,42 +193,18 @@
public void testDeepcloneModAndModAsMod(){
Properties a = make(MAP_A, null, !UNMODIFIABLE);
Properties b = make(MAP_B, null, !UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, DEEP_CLONE, !UNMODIFIABLE);
+ a = PropertiesUtils.clone(a, b, DEEP_CLONE);
assertTrue(verifyProps(a, LIST_AB));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
/**
* Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
*/
- public void testCloneModAndModAsUnmod(){
- Properties a = make(MAP_A, null, !UNMODIFIABLE);
- Properties b = make(MAP_B, null, !UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, !DEEP_CLONE, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_AB));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
- */
- public void testDeepcloneModAndModAsUnmod(){
- Properties a = make(MAP_A, null, !UNMODIFIABLE);
- Properties b = make(MAP_B, null, !UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, DEEP_CLONE, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_AB));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
- */
public void testCloneModAndUnmodAsMod(){
Properties a = make(MAP_A, null, !UNMODIFIABLE);
Properties b = make(MAP_B, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, !DEEP_CLONE, !UNMODIFIABLE);
+ a = PropertiesUtils.clone(a, b, !DEEP_CLONE);
assertTrue(verifyProps(a, LIST_AB));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
/**
@@ -307,42 +213,18 @@
public void testDeepcloneModAndUnmodAsMod(){
Properties a = make(MAP_A, null, !UNMODIFIABLE);
Properties b = make(MAP_B, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, DEEP_CLONE, !UNMODIFIABLE);
+ a = PropertiesUtils.clone(a, b, DEEP_CLONE);
assertTrue(verifyProps(a, LIST_AB));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
/**
* Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
*/
- public void testCloneModAndUnmodAsUnmod(){
- Properties a = make(MAP_A, null, !UNMODIFIABLE);
- Properties b = make(MAP_B, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, !DEEP_CLONE, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_AB));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
- */
- public void testDeepcloneModAndUnmodAsUnmod(){
- Properties a = make(MAP_A, null, !UNMODIFIABLE);
- Properties b = make(MAP_B, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, DEEP_CLONE, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_AB));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
- */
public void testCloneUnmodAndModAsMod(){
Properties a = make(MAP_A, null, UNMODIFIABLE);
Properties b = make(MAP_B, null, !UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, !DEEP_CLONE, !UNMODIFIABLE);
+ a = PropertiesUtils.clone(a, b, !DEEP_CLONE);
assertTrue(verifyProps(a, LIST_AB));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
/**
@@ -351,42 +233,18 @@
public void testDeepcloneUnmodAndModAsMod(){
Properties a = make(MAP_A, null, UNMODIFIABLE);
Properties b = make(MAP_B, null, !UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, DEEP_CLONE, !UNMODIFIABLE);
+ a = PropertiesUtils.clone(a, b, DEEP_CLONE);
assertTrue(verifyProps(a, LIST_AB));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
/**
* Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
*/
- public void testCloneUnmodAndModAsUnmod(){
- Properties a = make(MAP_A, null, UNMODIFIABLE);
- Properties b = make(MAP_B, null, !UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, !DEEP_CLONE, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_AB));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
- */
- public void testDeepcloneUnmodAndModAsUnmod(){
- Properties a = make(MAP_A, null, UNMODIFIABLE);
- Properties b = make(MAP_B, null, !UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, DEEP_CLONE, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_AB));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
- */
public void testCloneUnmodAndUnmodAsMod(){
Properties a = make(MAP_A, null, UNMODIFIABLE);
Properties b = make(MAP_B, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, !DEEP_CLONE, !UNMODIFIABLE);
+ a = PropertiesUtils.clone(a, b, !DEEP_CLONE);
assertTrue(verifyProps(a, LIST_AB));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
/**
@@ -395,61 +253,12 @@
public void testDeepcloneUnmodAndUnmodAsMod(){
Properties a = make(MAP_A, null, UNMODIFIABLE);
Properties b = make(MAP_B, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, DEEP_CLONE, !UNMODIFIABLE);
+ a = PropertiesUtils.clone(a, b, DEEP_CLONE);
assertTrue(verifyProps(a, LIST_AB));
- assertTrue(!(a instanceof UnmodifiableProperties));
}
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
- */
- public void testCloneUnmodAndUnmodAsUnmod(){
- Properties a = make(MAP_A, null, UNMODIFIABLE);
- Properties b = make(MAP_B, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, !DEEP_CLONE, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_AB));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
- */
- public void testDeepcloneUnmodAndUnmodAsUnmod(){
- Properties a = make(MAP_A, null, UNMODIFIABLE);
- Properties b = make(MAP_B, null, UNMODIFIABLE);
- a = PropertiesUtils.clone(a, b, DEEP_CLONE, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_AB));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
-
// ########################## ADVANCED #######################################
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
- */
- public void testAdvanced(){
- Properties a = make(MAP_A, null, UNMODIFIABLE);
- Properties bc = make(MAP_B, make(MAP_C, null, UNMODIFIABLE), UNMODIFIABLE);
- a = PropertiesUtils.clone(a, bc, DEEP_CLONE, UNMODIFIABLE);
- assertTrue(verifyProps(a, LIST_ABC));
- assertTrue(a instanceof UnmodifiableProperties);
- }
-
- /**
- * Tests {@link com.metamatrix.common.utils.PropertiesUtils#clone(Properties, Properties, boolean, boolean)}
- */
- public void testAdvanced2(){
- Properties ab = make(MAP_A, make(MAP_B, null, UNMODIFIABLE), UNMODIFIABLE);
- Properties c = make(MAP_C, null, UNMODIFIABLE);
- ab = PropertiesUtils.clone(ab, c, DEEP_CLONE, UNMODIFIABLE);
- assertTrue(verifyProps(ab, LIST_ABC));
- assertTrue(ab instanceof UnmodifiableProperties);
- }
-
-
-
-
//===================================================================
//TESTS HELPERS
//===================================================================
@@ -550,9 +359,6 @@
Map.Entry anEntry = (Map.Entry) i.next();
props.setProperty((String)anEntry.getKey(),(String)anEntry.getValue());
}
- if (makeUnmodifiable){
- props = new UnmodifiableProperties(props);
- }
return props;
}
Modified: trunk/common-core/src/test/java/com/metamatrix/core/util/TestExternalizeUtil.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/core/util/TestExternalizeUtil.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/common-core/src/test/java/com/metamatrix/core/util/TestExternalizeUtil.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -31,8 +31,6 @@
import junit.framework.TestCase;
-import com.metamatrix.core.MetaMatrixCoreException;
-
public class TestExternalizeUtil extends TestCase {
private ByteArrayOutputStream bout;
@@ -51,71 +49,6 @@
oout = new ObjectOutputStream(bout);
}
- /**
- * Test ExternalizeUtil writeThrowable() and readThrowable() on Throwables.
- * @throws Exception
- */
- public void testWriteThrowable() throws Exception {
- Throwable t3 = new Throwable("throwable level 3"); //$NON-NLS-1$
- Throwable t2 = new Throwable("throwable level 2", t3); //$NON-NLS-1$
- Throwable t1 = new Throwable("throwable level 1", t2); //$NON-NLS-1$
-
- ExternalizeUtil.writeThrowable(oout, t1);
- oout.flush();
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream oin = new ObjectInputStream(bin);
-
- Throwable result1 = ExternalizeUtil.readThrowable(oin);
- assertEqualThrowables(t1, result1);
-
- Throwable result2 = result1.getCause();
- assertEqualThrowables(t2, result2);
-
- Throwable result3 = result2.getCause();
- assertEqualThrowables(t3, result3);
-
- }
-
- /**
- * Test ExternalizeUtil writeThrowable() and readThrowable() on MetaMatrixCoreExceptions.
- * @throws Exception
- */
- public void testWriteThrowableMetaMatrixCoreException() throws Exception {
- MetaMatrixCoreException t3 = new MetaMatrixCoreException(new Exception("test-externalizable")); //$NON-NLS-1$
- MetaMatrixCoreException t2 = new MetaMatrixCoreException(t3);
- MetaMatrixCoreException t1 = new MetaMatrixCoreException(t2);
-
-
- ExternalizeUtil.writeThrowable(oout, t1);
- oout.flush();
- ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream oin = new ObjectInputStream(bin);
-
- MetaMatrixCoreException result1 = (MetaMatrixCoreException) ExternalizeUtil.readThrowable(oin);
- assertEqualThrowables(t1, result1);
-
- MetaMatrixCoreException result2 = (MetaMatrixCoreException) result1.getCause();
- assertEqualThrowables(t2, result2);
-
- MetaMatrixCoreException result3 = (MetaMatrixCoreException) result2.getCause();
- assertEqualThrowables(t3, result3);
- }
-
- /**
- * Assert that the two exceptions have the same message and status.
- */
- public static void assertEqualThrowables(Throwable e1, Throwable e2) {
- assertEquals(e1.getClass(), e2.getClass());
- assertEquals(e1.getMessage(), e2.getMessage());
-
- StackTraceElement[] stack1 = e1.getStackTrace();
- StackTraceElement[] stack2 = e2.getStackTrace();
- assertEquals(stack1.length, stack2.length);
- for (int i=0; i<stack1.length; i++) {
- assertEquals(stack1[i], stack2[i]);
- }
- }
-
public void testEmptyCollection() throws Exception {
ExternalizeUtil.writeCollection(oout, Arrays.asList(new Object[0]));
oout.flush();
Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/MetadataProvider.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/MetadataProvider.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/MetadataProvider.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
package org.teiid.connector.api;
import org.teiid.connector.metadata.runtime.MetadataFactory;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -47,7 +47,6 @@
import com.sforce.soap.partner.InvalidIdFault;
import com.sforce.soap.partner.LoginFault;
import com.sforce.soap.partner.LoginResult;
-import com.sforce.soap.partner.LoginScopeHeader;
import com.sforce.soap.partner.MalformedQueryFault;
import com.sforce.soap.partner.MruHeader;
import com.sforce.soap.partner.ObjectFactory;
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/CriteriaEvaluationException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/CriteriaEvaluationException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/CriteriaEvaluationException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/CriteriaEvaluationException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+
+/**
+ * This exception is thrown when an error occurs while evaluating a SQL criteria.
+ */
+public class CriteriaEvaluationException extends MetaMatrixProcessingException {
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public CriteriaEvaluationException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public CriteriaEvaluationException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public CriteriaEvaluationException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public CriteriaEvaluationException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public CriteriaEvaluationException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/ExpressionEvaluationException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/ExpressionEvaluationException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/ExpressionEvaluationException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/ExpressionEvaluationException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+
+/**
+ * This exception is thrown when an error occurs while evaluating a SQL expression.
+ */
+public class ExpressionEvaluationException extends MetaMatrixProcessingException {
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public ExpressionEvaluationException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public ExpressionEvaluationException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public ExpressionEvaluationException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public ExpressionEvaluationException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public ExpressionEvaluationException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/FunctionExecutionException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/FunctionExecutionException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/FunctionExecutionException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/FunctionExecutionException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+/**
+ * During processing, an invalid function was detected.
+ */
+public class FunctionExecutionException extends ExpressionEvaluationException {
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public FunctionExecutionException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public FunctionExecutionException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public FunctionExecutionException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public FunctionExecutionException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public FunctionExecutionException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/FunctionMetadataException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/FunctionMetadataException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/FunctionMetadataException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/FunctionMetadataException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+/**
+ * Detected invalid function metadata during validation.
+ */
+public class FunctionMetadataException extends QueryProcessingException {
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public FunctionMetadataException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public FunctionMetadataException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public FunctionMetadataException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public FunctionMetadataException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public FunctionMetadataException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/InvalidFunctionException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/InvalidFunctionException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/InvalidFunctionException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/InvalidFunctionException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+/**
+ * During processing, an invalid function was detected.
+ */
+public class InvalidFunctionException extends ExpressionEvaluationException {
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public InvalidFunctionException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public InvalidFunctionException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public InvalidFunctionException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public InvalidFunctionException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public InvalidFunctionException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryMetadataException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/QueryMetadataException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryMetadataException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryMetadataException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+
+/**
+ * This exception is thrown when an error occurs while retrieving metadata
+ * from a query component metadata facade.
+ *
+ * TODO: this isn't really a component exception all of the time. missing entries in metadata are fine during resolving.
+ */
+public class QueryMetadataException extends MetaMatrixComponentException {
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public QueryMetadataException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public QueryMetadataException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public QueryMetadataException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public QueryMetadataException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public QueryMetadataException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryParserException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/QueryParserException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryParserException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryParserException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+
+/**
+ * Thrown when a query cannot be parsed. This is most likely due to not
+ * following the Query Parser grammar, which defines how queries are parsed.
+ */
+public class QueryParserException extends QueryProcessingException {
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public QueryParserException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public QueryParserException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public QueryParserException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public QueryParserException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public QueryParserException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryPlannerException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/QueryPlannerException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryPlannerException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryPlannerException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+/**
+ * This exception is thrown when an error occurs while planning the query. This
+ * probably indicates a problem with the query that could not be determined during
+ * query resolution or query validation.
+ */
+public class QueryPlannerException extends QueryProcessingException {
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public QueryPlannerException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public QueryPlannerException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public QueryPlannerException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public QueryPlannerException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public QueryPlannerException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryProcessingException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/QueryProcessingException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryProcessingException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryProcessingException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+
+/**
+ * This exception is thrown when an error occurs while retrieving metadata
+ * from a query component metadata facade.
+ */
+public class QueryProcessingException extends MetaMatrixProcessingException {
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public QueryProcessingException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public QueryProcessingException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public QueryProcessingException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public QueryProcessingException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public QueryProcessingException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryResolverException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/QueryResolverException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryResolverException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryResolverException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+import java.util.*;
+
+/**
+ * This exception represents the case where the query submitted could not resolved
+ * when it is checked against the metadata
+ */
+public class QueryResolverException extends QueryProcessingException {
+
+ private transient List problems;
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public QueryResolverException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public QueryResolverException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public QueryResolverException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public QueryResolverException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public QueryResolverException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+
+ /**
+ * Set the list of unresolved symbols during QueryResolution
+ * @param unresolvedSymbols List of <UnresolvedSymbolDescription> objects
+ */
+ public void setUnresolvedSymbols(List unresolvedSymbols) {
+ this.problems = unresolvedSymbols;
+ }
+
+ /**
+ * Add an UnresolvedSymbolDescription to the list of unresolved symbols
+ * @param symbolDesc Single description
+ */
+ public void addUnresolvedSymbol(UnresolvedSymbolDescription symbolDesc) {
+ if(this.problems == null) {
+ this.problems = new ArrayList();
+ }
+ this.problems.add(symbolDesc);
+ }
+
+ /**
+ * Set the list of unresolved symbols during QueryResolution
+ * @return List of {@link UnresolvedSymbolDescription} objects
+ */
+ public List getUnresolvedSymbols() {
+ return this.problems;
+ }
+
+
+
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryValidatorException.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/QueryValidatorException.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryValidatorException.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryValidatorException.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+/**
+ * This exception is thrown if an error is discovered while validating the query. Validation
+ * checks a number of aspects of a query to ensure that the query is semantically valid.
+ */
+public class QueryValidatorException extends QueryProcessingException {
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public QueryValidatorException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public QueryValidatorException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance with the message and error code specified.
+ *
+ * @param message A message describing the exception
+ * @param code The error code
+ */
+ public QueryValidatorException( String code, String message ) {
+ super( code, message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param message A message describing the exception
+ * @param e An exception to nest within this one
+ */
+ public QueryValidatorException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance from a message and a code and an exception to
+ * chain to this one.
+ *
+ * @param e An exception to nest within this one
+ * @param message A message describing the exception
+ * @param code A code denoting the exception
+ */
+ public QueryValidatorException( Throwable e, String code, String message ) {
+ super( e, code, message );
+ }
+}
Copied: trunk/engine/src/main/java/com/metamatrix/api/exception/query/UnresolvedSymbolDescription.java (from rev 2059, trunk/client/src/main/java/com/metamatrix/api/exception/query/UnresolvedSymbolDescription.java)
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/UnresolvedSymbolDescription.java (rev 0)
+++ trunk/engine/src/main/java/com/metamatrix/api/exception/query/UnresolvedSymbolDescription.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.api.exception.query;
+
+import java.io.Serializable;
+
+/**
+ * This helper object describes an unresolved symbol found during
+ * query resolution.
+ */
+public class UnresolvedSymbolDescription implements Serializable {
+
+ private String symbol;
+ private String description;
+
+ /**
+ * Construct a description given the symbol and it's description.
+ * @param symbol Unresolved symbol
+ * @param description Description of error
+ */
+ public UnresolvedSymbolDescription(String symbol, String description) {
+ this.symbol = symbol;
+ this.description = description;
+ }
+
+ /**
+ * Get the symbol that was unresolved
+ * @return Unresolved symbol
+ */
+ public String getSymbol() {
+ return this.symbol;
+ }
+
+ /**
+ * Get the description of the problem
+ * @return Problem description
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Get string representation of the unresolved symbol description
+ * @return String representation
+ */
+ public String toString() {
+ StringBuffer str = new StringBuffer();
+ if(symbol != null) {
+ str.append("Unable to resolve '"); //$NON-NLS-1$
+ str.append(symbol);
+ str.append("': "); //$NON-NLS-1$
+ }
+ if(description != null) {
+ str.append(description);
+ } else {
+ str.append("Unknown reason"); //$NON-NLS-1$
+ }
+ return str.toString();
+ }
+
+}
Modified: trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -24,11 +24,11 @@
import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import org.teiid.client.ProcedureErrorInstructionException;
import org.teiid.client.plan.PlanNode;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ProcedureErrorInstructionException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.query.processor.program.ProgramInstruction;
import com.metamatrix.query.sql.symbol.Expression;
Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -54,7 +54,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.properties.UnmodifiableProperties;
import com.metamatrix.common.types.BlobImpl;
import com.metamatrix.common.types.ClobImpl;
import com.metamatrix.common.types.DataTypeManager;
@@ -105,7 +104,7 @@
// error message cached to avoid i18n lookup each time
public static String NOT_EXISTS_MESSAGE = StringUtil.Constants.SPACE+DQPPlugin.Util.getString("TransformationMetadata.does_not_exist._1"); //$NON-NLS-1$
- private static UnmodifiableProperties EMPTY_PROPS = new UnmodifiableProperties(new Properties());
+ private static Properties EMPTY_PROPS = new Properties();
private final CompositeMetadataStore store;
private Map<String, Resource> vdbEntries;
Modified: trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -71,6 +71,8 @@
* @apiviz.landmark
*/
public class ObjectDecoder extends FrameDecoder {
+
+ public static final long MAX_LOB_SIZE = 1l << 32;
private final int maxObjectSize;
private final ClassLoader classLoader;
@@ -80,6 +82,7 @@
private OutputStream stream;
private List<StreamFactoryReference> streams;
private StorageManager storageManager;
+ private FileStore store;
/**
* Creates a new decoder with the specified maximum object size.
@@ -140,14 +143,14 @@
buffer.skipBytes(2);
if (stream == null) {
- final FileStore store = storageManager.createFileStore("temp-stream"); //$NON-NLS-1$
+ store = storageManager.createFileStore("temp-stream"); //$NON-NLS-1$
StreamFactoryReference sfr = streams.get(streamIndex);
store.setCleanupReference(sfr);
sfr.setStreamFactory(new InputStreamFactory(Streamable.ENCODING) {
-
+ FileStore fs = store;
@Override
public InputStream getInputStream() throws IOException {
- return new BufferedInputStream(store.createInputStream(0));
+ return new BufferedInputStream(fs.createInputStream(0));
}
});
this.stream = new BufferedOutputStream(store.createOutputStream());
@@ -158,12 +161,17 @@
streamIndex++;
continue;
}
+ if (store.getLength() + dataLen > MAX_LOB_SIZE) {
+ throw new StreamCorruptedException(
+ "lob too big: " + store.getLength() + dataLen + " (max: " + MAX_LOB_SIZE + ')');
+ }
buffer.readBytes(this.stream, dataLen);
}
Object toReturn = result;
result = null;
streams = null;
stream = null;
+ store = null;
return toReturn;
}
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -73,7 +73,7 @@
throw new AssertionError("unknown message contents"); //$NON-NLS-1$
}
final ServiceInvocationStruct serviceStruct = (ServiceInvocationStruct)message.getContents();
- final ClientService clientService = this.csr.getClientService(serviceStruct.targetClass);
+ final ClientService clientService = this.csr.getClientService(serviceStruct.targetClass.getName());
loggingContext = clientService.getLoggingContext();
Method m = clientService.getReflectionHelper().findBestMethodOnTarget(serviceStruct.methodName, serviceStruct.args);
Object methodResult;
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -22,8 +22,7 @@
package org.teiid.jdbc;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.*;
import java.io.BufferedReader;
import java.io.File;
@@ -42,45 +41,16 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
-import org.jboss.deployers.spi.DeploymentException;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.mockito.Mockito;
-import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.impl.ModelMetaData;
-import org.teiid.adminapi.impl.VDBMetaData;
-import org.teiid.client.DQP;
-import org.teiid.client.security.ILogon;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.deployers.MetadataStoreGroup;
-import org.teiid.deployers.VDBRepository;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
-import org.teiid.dqp.internal.process.DQPConfiguration;
-import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.jdbc.util.ResultSetUtil;
-import org.teiid.metadata.index.VDBMetadataFactory;
-import org.teiid.net.TeiidURL;
-import org.teiid.services.SessionServiceImpl;
-import org.teiid.transport.ClientServiceRegistry;
-import org.teiid.transport.ClientServiceRegistryImpl;
-import org.teiid.transport.LocalServerConnection;
-import org.teiid.transport.LogonImpl;
-import com.metamatrix.common.queue.FakeWorkManager;
import com.metamatrix.common.util.ApplicationInfo;
import com.metamatrix.core.CoreConstants;
import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
/**
*/
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2010-04-16 21:45:46 UTC (rev 2062)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2010-04-20 19:13:08 UTC (rev 2063)
@@ -146,7 +146,7 @@
public Properties getProperties() {
- Properties p = PropertiesUtils.clone(System.getProperties(), false);
+ Properties p = PropertiesUtils.clone(System.getProperties());
if (props != null) {
p.putAll(props);
}
14 years, 8 months
teiid SVN: r2062 - trunk/adminshell/src/main/resources.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-04-16 17:45:46 -0400 (Fri, 16 Apr 2010)
New Revision: 2062
Modified:
trunk/adminshell/src/main/resources/connector.xsl
Log:
TEIID-833 fixing the migration tool, the db2 package is wrong
Modified: trunk/adminshell/src/main/resources/connector.xsl
===================================================================
--- trunk/adminshell/src/main/resources/connector.xsl 2010-04-16 21:15:33 UTC (rev 2061)
+++ trunk/adminshell/src/main/resources/connector.xsl 2010-04-16 21:45:46 UTC (rev 2062)
@@ -108,7 +108,7 @@
<config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.sqlserver.SQLServerSQLTranslator</config-property>
</xsl:when>
<xsl:when test="starts-with(@ComponentType,'DB2')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.sqlserver.DB2SQLTranslator</config-property>
+ <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.db2.DB2SQLTranslator</config-property>
</xsl:when>
<xsl:when test="starts-with(@ComponentType,'H2')">
<config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.h2.H2Translator</config-property>
14 years, 8 months
teiid SVN: r2061 - in trunk: adminshell/src/main/java and 18 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-04-16 17:15:33 -0400 (Fri, 16 Apr 2010)
New Revision: 2061
Added:
trunk/adminshell/src/main/java/groovy/
trunk/adminshell/src/main/java/groovy/sql/
trunk/adminshell/src/main/java/groovy/sql/TeiidSql.java
trunk/adminshell/src/main/java/org/teiid/adminshell/
trunk/adminshell/src/main/java/org/teiid/adminshell/AdminHelpCommand.java
trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminConsole.java
trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminShell.java
trunk/adminshell/src/main/java/org/teiid/adminshell/GroovySqlExtensions.java
trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java
trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java
trunk/adminshell/src/main/resources/org/
trunk/adminshell/src/main/resources/org/codehaus/
trunk/adminshell/src/main/resources/org/codehaus/groovy/
trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/
trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/
trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/commands.xml
trunk/adminshell/src/main/resources/org/teiid/
trunk/adminshell/src/main/resources/org/teiid/adminshell/
trunk/adminshell/src/main/resources/org/teiid/adminshell/AdminHelpCommand.properties
trunk/build/kit-adminshell/adminconsole.bat
trunk/build/kit-adminshell/adminconsole.sh
trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataReader.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/StringArrayReader.java
Removed:
trunk/adminshell/src/main/java/bsh/
trunk/adminshell/src/main/java/com/metamatrix/script/junit/
trunk/adminshell/src/main/java/com/metamatrix/script/shell/
trunk/adminshell/src/main/java/org/teiid/AdminShell.java
trunk/adminshell/src/main/java/org/teiid/MigrationUtil.java
trunk/adminshell/src/main/java/org/teiid/script/io/MetadataReader.java
trunk/adminshell/src/main/java/org/teiid/script/io/StringArrayReader.java
trunk/adminshell/src/main/resources/commands/
trunk/adminshell/src/main/resources/scripts/
trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/writing-tests.xml
Modified:
trunk/adminshell/pom.xml
trunk/adminshell/src/main/java/org/teiid/script/io/ResultSetReader.java
trunk/build/kit-adminshell/adminshell.bat
trunk/build/kit-adminshell/adminshell.sh
trunk/build/kit-adminshell/migrate.bat
trunk/build/kit-adminshell/migrate.sh
trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-a.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-b.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/connection-management.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/getting-started.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/working-with-scripts.xml
trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractQueryTest.java
Log:
TEIID-1052 re-implementing adminshell with groovy tools.
Modified: trunk/adminshell/pom.xml
===================================================================
--- trunk/adminshell/pom.xml 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/pom.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,35 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>teiid</artifactId>
- <groupId>org.jboss.teiid</groupId>
- <version>7.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>teiid-adminshell</artifactId>
- <name>Adminshell</name>
- <description>Adminshell for Teiid</description>
- <dependencies>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-client</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>beanshell</groupId>
- <artifactId>bsh</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- </dependencies>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>teiid</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>7.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>teiid-adminshell</artifactId>
+ <name>Adminshell</name>
+ <description>Adminshell for Teiid</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.7.2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ <version>0.9.94</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.fusesource.jansi</groupId>
+ <artifactId>jansi</artifactId>
+ <version>1.2.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
Added: trunk/adminshell/src/main/java/groovy/sql/TeiidSql.java
===================================================================
--- trunk/adminshell/src/main/java/groovy/sql/TeiidSql.java (rev 0)
+++ trunk/adminshell/src/main/java/groovy/sql/TeiidSql.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,125 @@
+package groovy.sql;
+
+import groovy.lang.Closure;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.util.Collection;
+import java.util.logging.Level;
+
+import org.teiid.client.plan.PlanNode;
+import org.teiid.jdbc.TeiidStatement;
+
+/**
+ * An extension of Groovy's Sql to support getting {@link TeiidStatement} specific properties.
+ */
+public final class TeiidSql extends Sql {
+ private int maxRows;
+ private PlanNode plan;
+ private Collection<org.teiid.client.plan.Annotation> annotations;
+ private String debugLog;
+ private SQLWarning warnings;
+
+ public TeiidSql(Connection connection) {
+ super(connection);
+ }
+
+ @Override
+ protected void configure(Statement statement) {
+ super.configure(statement);
+ try {
+ statement.setMaxRows(maxRows);
+ } catch (SQLException e) {
+ LOG.log(Level.WARNING, "Caught exception setting max rows: " + e, e);
+ }
+ plan = null;
+ annotations = null;
+ debugLog = null;
+ warnings = null;
+ }
+
+ /**
+ * Overridden to fix passing the resultset to the closure
+ */
+ @Override
+ public void eachRow(String sql, Closure metaClosure, Closure rowClosure) throws SQLException {
+ AbstractQueryCommand command = createQueryCommand(sql);
+ ResultSet results = null;
+ try {
+ results = command.execute();
+ if (metaClosure != null) metaClosure.call(results.getMetaData());
+
+ GroovyResultSet groovyRS = new GroovyResultSetProxy(results).getImpl();
+ while (groovyRS.next()) {
+ rowClosure.call(groovyRS);
+ }
+ } catch (SQLException e) {
+ LOG.warning("Failed to execute: " + sql + " because: " + e.getMessage());
+ throw e;
+ } finally {
+ command.closeResources();
+ }
+ }
+
+ @Override
+ protected void closeResources(Connection connection,
+ Statement statement) {
+ getPlanInfo(statement);
+ super.closeResources(connection, statement);
+ }
+
+ @Override
+ protected void closeResources(Connection connection,
+ Statement statement, ResultSet results) {
+ getPlanInfo(statement);
+ super.closeResources(connection, statement, results);
+ }
+
+ protected void getPlanInfo(Statement s) {
+ if (s == null) {
+ return;
+ }
+ TeiidStatement ts;
+ try {
+ ts = s.unwrap(TeiidStatement.class);
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ plan = ts.getPlanDescription();
+ annotations = ts.getAnnotations();
+ debugLog = ts.getDebugLog();
+ try {
+ warnings = ts.getWarnings();
+ } catch (SQLException e) {
+ LOG.log(Level.WARNING, "Caught exception getting warnings: " + e, e);
+ }
+ }
+
+ public SQLWarning getSQLWarnings() {
+ return warnings;
+ }
+
+ public int getMaxRows() {
+ return maxRows;
+ }
+
+ public void setMaxRows(int maxRows) {
+ this.maxRows = maxRows;
+ }
+
+ public PlanNode getPlan() {
+ return plan;
+ }
+
+ public Collection<org.teiid.client.plan.Annotation> getAnnotations() {
+ return annotations;
+ }
+
+ public String getDebugLog() {
+ return debugLog;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/adminshell/src/main/java/groovy/sql/TeiidSql.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/adminshell/src/main/java/org/teiid/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/AdminShell.java 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/src/main/java/org/teiid/AdminShell.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,94 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintStream;
-
-import bsh.Capabilities;
-import bsh.EvalError;
-import bsh.Interpreter;
-
-import com.metamatrix.script.shell.FilePrintStream;
-import com.metamatrix.script.shell.ReaderInterceptor;
-import com.metamatrix.script.shell.SimpleParser;
-
-
-/**
- * Invokes the BeanShell window, specifically designed for the metamatrix purposes.
- * The difference with this shell is, it will plug in a customer parser on top the
- * BeanShell, and load up all the MetaMatrix commands.
- */
-public class AdminShell {
-
- public static void main( String args[] ) throws IOException {
-
- boolean gui = Boolean.getBoolean("gui"); //$NON-NLS-1$
-
- if (args.length == 0) {
- if ( !Capabilities.classExists( "bsh.util.Util" ) ) //$NON-NLS-1$
- System.out.println("Can't find the BeanShell utilities..."); //$NON-NLS-1$
-
- String teiidHome = System.getenv("TEIID_HOME"); //$NON-NLS-1$
- if (teiidHome == null) {
- teiidHome = System.getProperty("user.dir"); //$NON-NLS-1$
- }
- File logDir = new File(teiidHome, "log"); //$NON-NLS-1$
- if (!logDir.exists()) {
- logDir.mkdirs();
- }
-
- FileWriter logger = new FileWriter(teiidHome+"/log/adminscript.txt", true); //$NON-NLS-1$
- PrintStream out = new FilePrintStream(System.out, teiidHome+"/log/adminshell.log"); //$NON-NLS-1$
-
- try {
- SimpleParser p = new SimpleParser();
- Interpreter interpreter = new Interpreter(new ReaderInterceptor(p, logger), out, out, true);
- interpreter.eval("importCommands(\"commands\")"); //$NON-NLS-1$
- interpreter.eval("load(\"server\")"); //$NON-NLS-1$
-
- p.setInterpreter(interpreter);
-
- if (Capabilities.haveSwing() && gui) {
- //bsh.util.Util.startSplashScreen();
- interpreter.eval("desktop()"); //$NON-NLS-1$
- interpreter.getOut().flush();
- } else {
- interpreter.run();
- }
- } catch ( EvalError e ) {
- System.err.println("Couldn't start desktop: "+e); //$NON-NLS-1$
- } finally {
- logger.close();
- out.close();
- }
- }
- else {
- // If we running a script file run as it is
- Interpreter.main(args);
- }
- }
-
-}
Deleted: trunk/adminshell/src/main/java/org/teiid/MigrationUtil.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/MigrationUtil.java 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/src/main/java/org/teiid/MigrationUtil.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,202 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipOutputStream;
-
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import com.metamatrix.common.util.ApplicationInfo;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.ObjectConverterUtil;
-
-@SuppressWarnings("nls")
-public class MigrationUtil {
-
- //TODO: sys out info on what ds needs creating
- public static void main(String[] args) throws IOException, TransformerConfigurationException, TransformerFactoryConfigurationError, TransformerException {
- if (args.length != 1) {
- System.err.println(
- "Teiid 7.0 VDB Migration Utility" +
- "\n\nUsage:" +
- "\n A vdb or .def file must be specified as the only argument." +
- "\n\nResult:"+
- "\n 7.0 compatible replacement files will be created in the same directory " +
- "\n as your file." +
- "\n If you supply a vdb, the new vdb file will have a _70.vdb suffix." +
- "\n If you supply a dynamic vdb file, then two new files will be created: " +
- "\n <file name>-vdb.xml and <file name>-bindings.xml" +
- "\n\nNote: this program will only create connector binding connection factories " +
- "\n if the bindings are present in the specified file." +
- "\n\nNote: this program will NOT create the -ds.xml files needed by JBoss to " +
- "\n create underlying DataSource connection pools." +
- "\n You will need to manually create one -ds.xml for each JDBC DataSource " +
- "\n with a JNDI name of <connector binding name>DS, " +
- "\n where any spaces in the name are replace by _" +
- "\n\nNode: depending upon the connectors used, you may need to manually edit the " +
- " -bindings.xml file.");
- System.exit(-1);
- }
- File file = new File(args[0]);
- if (!file.exists()) {
- System.err.println(args[0] + " does not exist."); //$NON-NLS-1$
- System.exit(-1);
- }
- String fullName = file.getName();
- String fileName = fullName.substring(0, fullName.length() - 4);
- String ext = FileUtils.getExtension(file);
- if (ext == null) {
- System.err.println(fullName + " is not a vdb or xml file."); //$NON-NLS-1$
- System.exit(-1);
- }
- ext = ext.toLowerCase();
- if (ext.endsWith("vdb")) {
- File dir = createTempDirectory();
- try {
- extract(file, dir);
- File metainf = new File(dir, "META-INF");
- File config = new File(dir, "ConfigurationInfo.def");
- File manifest = new File(dir, "MetaMatrix-VdbManifestModel.xmi");
- if (manifest.exists()) {
- String configStr = ObjectConverterUtil.convertFileToString(config);
- String manifestStr = ObjectConverterUtil.convertFileToString(manifest);
- int index = configStr.lastIndexOf("</VDB>");
- int manifestBegin = manifestStr.indexOf("<xmi");
- configStr = configStr.substring(0, index) + manifestStr.substring(manifestBegin) + "</VDB>";
- FileUtils.write(configStr.getBytes(), config);
- manifest.delete();
- }
- transformConfig(config, "/vdb.xsl", new StreamResult(new File(metainf, "vdb.xml")));
- transformConfig(config, "/connector.xsl", new StreamResult(new File(file.getParentFile(), fileName + "-bindings-ds.xml")));
- config.delete();
- FileOutputStream out = new FileOutputStream(new File(file.getParent(), fileName + "_70.vdb"));
- ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(out));
- int parentLength = dir.getPath().length();
- addDirectory(dir, zos, parentLength);
- zos.close();
- } finally {
- FileUtils.removeDirectoryAndChildren(dir);
- }
- } else if (ext.endsWith("xml") || ext.endsWith("def")){
- File parent = file.getParentFile();
- transformConfig(file, "/vdb.xsl", new StreamResult(new File(parent, fileName + "-vdb.xml")));
- transformConfig(file, "/connector.xsl", new StreamResult(new File(parent, fileName + "-bindings-ds.xml")));
- } else {
- System.err.println(fullName + " is not a vdb or xml file. Run with no arguments for help."); //$NON-NLS-1$
- System.exit(-1);
- }
- }
-
- private static void addDirectory(File dir, ZipOutputStream zos,
- int parentLength) throws IOException {
- String[] files = dir.list();
- for (String entry : files) {
- File f = new File(dir, entry);
- if (f.isDirectory()) {
- addDirectory(f, zos, parentLength);
- } else {
- ZipEntry e = new ZipEntry(f.getPath().substring(parentLength));
- zos.putNextEntry(e);
- FileUtils.write(f, zos);
- zos.closeEntry();
- }
- }
- }
-
- private static void transformConfig(File config, String styleSheet, Result target)
- throws TransformerFactoryConfigurationError,
- TransformerConfigurationException, TransformerException {
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer t = tf.newTransformer(new StreamSource(MigrationUtil.class.getResourceAsStream(styleSheet)));
- t.setParameter("version", ApplicationInfo.getInstance().getReleaseNumber()); //$NON-NLS-1$
- t.transform(new StreamSource(config), target);
- }
-
- /**
- * Extract the given zip file to the given destination directory base.
- *
- * @param zipFileName
- * The full path and file name of the Zip file to extract.
- * @param destinationDirectory
- * The root directory to extract to.
- * @throws IOException
- */
- static void extract(final File sourceZipFile, File unzipDestinationDirectory) throws IOException {
- // Open Zip file for reading
- ZipFile zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);
-
- // Create an enumeration of the entries in the zip file
- Enumeration zipFileEntries = zipFile.entries();
-
- // Process each entry
- while (zipFileEntries.hasMoreElements()) {
- // grab a zip file entry
- ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();
-
- String currentEntry = entry.getName();
-
- File destFile = new File(unzipDestinationDirectory, currentEntry);
-
- // grab file's parent directory structure
- File destinationParent = destFile.getParentFile();
-
- // create the parent directory structure if needed
- destinationParent.mkdirs();
-
- // extract file if not a directory
- if (!entry.isDirectory()) {
- ObjectConverterUtil.write(zipFile.getInputStream(entry),
- destFile);
- }
- }
- zipFile.close();
- }
-
- static File createTempDirectory() throws IOException {
- File temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
-
- temp.delete();
-
- if (!(temp.mkdir())) {
- throw new IOException("Could not create temp directory: "
- + temp.getAbsolutePath());
- }
-
- return temp;
- }
-
-}
Added: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminHelpCommand.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminHelpCommand.java (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminHelpCommand.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General public static
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General public static License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General public static
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import java.util.List;
+
+import org.codehaus.groovy.tools.shell.CommandSupport;
+import org.codehaus.groovy.tools.shell.Shell;
+
+public class AdminHelpCommand extends CommandSupport {
+
+ protected AdminHelpCommand(Shell shell) {
+ super(shell, "adminhelp", "\\ah"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ //hook to introduce default imports
+ shell.execute(GroovyAdminConsole.IMPORTS);
+ }
+
+ @Override
+ public Object execute(List args) {
+ if (args.size() > 1) {
+ fail(messages.format("error.unexpected_args", new Object[] {args.toString()})); //$NON-NLS-1$
+ }
+ if (args.isEmpty()) {
+ AdminShell.adminHelp();
+ } else {
+ AdminShell.adminHelp(args.get(0).toString());
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminHelpCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,544 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General public static
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General public static License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General public static
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.nio.charset.Charset;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminFactory;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.ConnectionFactory;
+import org.teiid.adminapi.ConnectionPoolStatistics;
+import org.teiid.adminapi.ProcessObject;
+import org.teiid.adminapi.PropertyDefinition;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.Transaction;
+import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.WorkerPoolStatistics;
+import org.teiid.adminapi.Admin.DataSourceType;
+import org.teiid.adminshell.Help.Doc;
+
+import com.metamatrix.common.util.ReaderInputStream;
+import com.metamatrix.core.util.ObjectConverterUtil;
+
+/**
+ * Contextual shell wrapper around the AdminAPI, see {@link Admin}
+ */
+public class AdminShell {
+
+ protected static Logger log = Logger.getLogger(AdminShell.class.getName());
+
+ static Properties p;
+ private static int connectionCount = 1;
+ private static Admin internalAdmin;
+ private static String currentName;
+ private static HashMap<String, Admin> connections = new HashMap<String, Admin>();
+ private static Help help = new Help(AdminShell.class);
+
+ @Doc(text="Get a named Admin connection to the specified server")
+ public static void connectAsAdmin(
+ @Doc(text = "url - URL in the format \"mm[s]://host:port\"") String url,
+ @Doc(text = "username") String username,
+ @Doc(text = "password") String password,
+ @Doc(text = "connection name") String connectionName) throws AdminException {
+ internalAdmin = AdminFactory.getInstance().createAdmin(username, password.toCharArray(), url);
+ currentName = connectionName;
+ Admin old = connections.put(connectionName, internalAdmin);
+ if (old != null) {
+ System.out.println("Closing previous admin associated with " + connectionName);
+ old.close();
+ }
+ }
+
+ @Doc(text = "Connect as Admin using the defaults from connection.properties")
+ @SuppressWarnings("nls")
+ public static void connectAsAdmin() throws AdminException {
+ loadConnectionProperties();
+ connectAsAdmin(p.getProperty("admin.url", "mm://localhost:31443"), p.getProperty("admin.user", "admin"),
+ p.getProperty("admin.password", "admin"), "conn-" + connectionCount++);
+ }
+
+ static void loadConnectionProperties() {
+ if (p != null) {
+ return;
+ }
+ Properties props = new Properties();
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream("connection.properties"); //$NON-NLS-1$
+ props.load(fis);
+ } catch (IOException e) {
+ log.log(Level.WARNING, "Could not load default connection properties.", e);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ p = props;
+ }
+
+ @Doc(text = "Add a ConnectionFactory")
+ public static ConnectionFactory addConnectionFactory(
+ @Doc(text = "deployed name") String deployedName,
+ @Doc(text = "type name") String typeName,
+ Properties properties) throws AdminException {
+ return getAdmin()
+ .addConnectionFactory(deployedName, typeName, properties);
+ }
+
+ @Doc(text = "Adds a role to the specified policy")
+ public static void addRoleToDataPolicy(
+ @Doc(text = "vdb name") String vdbName,
+ @Doc(text = "vdb version") int vdbVersion,
+ @Doc(text = "policy name") String policyName,
+ @Doc(text = "role") String role) throws AdminException {
+ getAdmin().addRoleToDataPolicy(vdbName, vdbVersion, policyName, role);
+ }
+
+ @Doc(text = "Assign a ConnectionFactory to a source Model")
+ public static void assignConnectionFactoryToModel(
+ @Doc(text = "vdb name") String vdbName,
+ @Doc(text = "vdb version") int vdbVersion,
+ @Doc(text = "model name") String modelName,
+ @Doc(text = "source name") String sourceName,
+ @Doc(text = "jndi name") String jndiName)
+ throws AdminException {
+ getAdmin().assignConnectionFactoryToModel(vdbName, vdbVersion, modelName,
+ sourceName, jndiName);
+ }
+
+ @Doc(text = "Cancel a request")
+ public static void cancelRequest(
+ @Doc(text = "session id") long sessionId,
+ @Doc(text = "request id") long requestId)
+ throws AdminException {
+ getAdmin().cancelRequest(sessionId, requestId);
+ }
+
+ @Doc(text = "Clear the given cache")
+ public static void clearCache(
+ @Doc(text = "cache type") String cacheType) throws AdminException {
+ getAdmin().clearCache(cacheType);
+ }
+
+ @Doc(text = "Delete a ConnectionFactory")
+ public static void deleteConnectionFactory(
+ @Doc(text = "deployed name") String deployedName)
+ throws AdminException {
+ getAdmin().deleteConnectionFactory(deployedName);
+ }
+
+ @Doc(text = "Delete a Connector")
+ public static void deleteConnector(
+ @Doc(text = "name") String name) throws AdminException {
+ getAdmin().deleteConnector(name);
+ }
+
+ @Doc(text = "Delete a DataSource")
+ public static void deleteDataSource(
+ @Doc(text = "deployed name") String deploymentName) throws AdminException {
+ getAdmin().deleteDataSource(deploymentName);
+ }
+
+ @Doc(text = "Delete a VDB")
+ public static void deleteVDB(
+ @Doc(text = "vdb name") String vdbName,
+ @Doc(text = "vdb version") int vdbVersion) throws AdminException {
+ getAdmin().deleteVDB(vdbName, vdbVersion);
+ }
+
+ @Doc(text = "Get all cache type Strings")
+ public static Collection<String> getCacheTypes() throws AdminException {
+ return getAdmin().getCacheTypes();
+ }
+
+ @Doc(text = "Get all ConnectionFactory instances")
+ public static Collection<ConnectionFactory> getConnectionFactories()
+ throws AdminException {
+ return getAdmin().getConnectionFactories();
+ }
+
+ @Doc(text = "Get all ConnectionFactory instances in the VDB")
+ public static Collection<ConnectionFactory> getConnectionFactoriesInVDB(
+ @Doc(text = "vdb name") String vdbName,
+ @Doc(text = "vdb version") int vdbVersion) throws AdminException {
+ return getAdmin().getConnectionFactoriesInVDB(vdbName, vdbVersion);
+ }
+
+ @Doc(text = "Get the specified ConnectionFactory")
+ public static ConnectionFactory getConnectionFactory(
+ @Doc(text = "deployed name") String deployedName)
+ throws AdminException {
+ return getAdmin().getConnectionFactory(deployedName);
+ }
+
+ @Doc(text = "Get the ConnectionPoolStatistics for the given ConnectionFactory")
+ public static ConnectionPoolStatistics getConnectionFactoryStats(
+ @Doc(text = "deployed name") String deployedName) throws AdminException {
+ return getAdmin().getConnectionFactoryStats(deployedName);
+ }
+
+ @Doc(text = "Get all connector name Strings")
+ public static Set<String> getConnectorNames() throws AdminException {
+ return getAdmin().getConnectorNames();
+ }
+
+ @Doc(text = "Get all PropertyDefinition instances for the given connector")
+ public static Collection<PropertyDefinition> getConnectorPropertyDefinitions(
+ @Doc(text = "connector name") String connectorName) throws AdminException {
+ return getAdmin().getConnectorPropertyDefinitions(connectorName);
+ }
+
+ @Doc(text = "Get all ProperyDefinition instances for a DataSource")
+ public static Collection<PropertyDefinition> getDataSourcePropertyDefinitions()
+ throws AdminException {
+ return getAdmin().getDataSourcePropertyDefinitions();
+ }
+
+ @Doc(text = "Get the ProcessObject instances for the given identifier")
+ public static Collection<ProcessObject> getProcesses(
+ @Doc(text = "identifier") String processIdentifier)
+ throws AdminException {
+ return getAdmin().getProcesses(processIdentifier);
+ }
+
+ @Doc(text = "Get all Request instances")
+ public static Collection<Request> getRequests() throws AdminException {
+ return getAdmin().getRequests();
+ }
+
+ @Doc(text = "Get all Request instances for the given session")
+ public static Collection<Request> getRequestsForSession(
+ @Doc(text = "session id") long sessionId)
+ throws AdminException {
+ return getAdmin().getRequestsForSession(sessionId);
+ }
+
+ @Doc(text = "Get all Session instances")
+ public static Collection<Session> getSessions() throws AdminException {
+ return getAdmin().getSessions();
+ }
+
+ @Doc(text = "Get all Transaction instances")
+ public static Collection<Transaction> getTransactions() throws AdminException {
+ return getAdmin().getTransactions();
+ }
+
+ @Doc(text = "Get a specific VDB")
+ public static VDB getVDB(
+ @Doc(text = "vdb name") String vdbName,
+ @Doc(text = "vdb version") int vbdVersion) throws AdminException {
+ return getAdmin().getVDB(vdbName, vbdVersion);
+ }
+
+ @Doc(text = "Get all VDB instances")
+ public static Set<VDB> getVDBs() throws AdminException {
+ return getAdmin().getVDBs();
+ }
+
+ @Doc(text = "Get WorkerPoolStatistics for the given WorkManager")
+ public static WorkerPoolStatistics getWorkManagerStats(
+ @Doc(text = "identifier") String identifier)
+ throws AdminException {
+ return getAdmin().getWorkManagerStats(identifier);
+ }
+
+ @Doc(text = "Remove a role for the data policy")
+ public static void removeRoleFromDataPolicy(
+ @Doc(text = "vdb name") String vdbName,
+ @Doc(text = "vdb version") int vdbVersion,
+ @Doc(text = "policy name") String policyName,
+ @Doc(text = "role name") String role) throws AdminException {
+ getAdmin()
+ .removeRoleFromDataPolicy(vdbName, vdbVersion, policyName, role);
+ }
+
+ @Doc(text = "Set a ConnectionFactory property")
+ public static void setConnectionFactoryProperty(
+ @Doc(text = "deployed name") String deployedName,
+ @Doc(text = "propery name") String propertyName,
+ @Doc(text = "value") String propertyValue) throws AdminException {
+ getAdmin().setConnectionFactoryProperty(deployedName, propertyName,
+ propertyValue);
+ }
+
+ @Doc(text = "Set a runtime property")
+ public static void setRuntimeProperty(
+ @Doc(text = "name") String propertyName,
+ @Doc(text = "value") String propertyValue)
+ throws AdminException {
+ getAdmin().setRuntimeProperty(propertyName, propertyValue);
+ }
+
+ @Doc(text = "Start a ConnectionFactory")
+ public static void startConnectionFactory(
+ @Doc(text = "deployed name") String deployedName)
+ throws AdminException {
+ getAdmin().startConnectionFactory(deployedName);
+ }
+
+ @Doc(text = "Stop a ConnectionFactory")
+ public static void stopConnectionFactory(
+ @Doc(text = "deployed name") String deployedName)
+ throws AdminException {
+ getAdmin().stopConnectionFactory(deployedName);
+ }
+
+ @Doc(text = "Terminate a session and associated requests")
+ public static void terminateSession(
+ @Doc(text = "session id") long sessionId) throws AdminException {
+ getAdmin().terminateSession(sessionId);
+ }
+
+ @Doc(text = "Terminate a transaction")
+ public static void terminateTransaction(
+ @Doc(text = "transaction id") String transactionId)
+ throws AdminException {
+ getAdmin().terminateTransaction(transactionId);
+ }
+
+ @Doc(text = "Merge two vdbs")
+ public static void mergeVDBs(
+ @Doc(text = "source vdb name") String sourceVDBName,
+ @Doc(text = "source vdb version") int sourceVDBVersion,
+ @Doc(text = "target vdb name") String targetVDBName,
+ @Doc(text = "target vdb version") int targetVDBVersion) throws AdminException {
+ getAdmin().mergeVDBs(sourceVDBName, sourceVDBVersion, targetVDBName, targetVDBVersion);
+ }
+
+ @Doc(text = "Checks if a ConnectionFactory exists")
+ public static boolean hasConnectionFactory(
+ @Doc(text = "deployed name") String factoryName) throws AdminException {
+ Collection<ConnectionFactory> bindings = getAdmin().getConnectionFactories();
+
+ for (ConnectionFactory binding:bindings) {
+ if (binding.getName().equals(factoryName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Doc(text = "Checks if a Connector exists")
+ public static boolean hasConnector(
+ @Doc(text = "type name") String typeName) throws AdminException {
+ Collection<String> types = getAdmin().getConnectorNames();
+
+ for (String type:types) {
+ if (type.equals(typeName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Doc(text = "Checks if a VDB exists")
+ public static boolean hasVDB(
+ @Doc(text = "vdb name") String vdbName) throws AdminException {
+ Collection<VDB> vdbs = getAdmin().getVDBs();
+ for (VDB vdb:vdbs) {
+ if (vdb.getName().equals(vdbName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Doc(text = "Checks if a specific VDB version exists")
+ public static boolean hasVDB(
+ @Doc(text = "vdb name") String vdbName,
+ @Doc(text = "vdb version") int version) throws AdminException {
+ Collection<VDB> vdbs = getAdmin().getVDBs();
+ for (VDB vdb:vdbs) {
+ if (vdb.getName().equals(vdbName) && vdb.getVersion() == version) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Doc(text = "Export a Connector RAR to file")
+ public static void exportConnector(
+ @Doc(text = "connector name") String name,
+ @Doc(text = "file name") String fileName) throws AdminException, IOException {
+ InputStream contents = getAdmin().exportConnector(name);
+ writeFile(name, fileName, contents);
+ }
+
+ @Doc(text = "Export a ConnectionFactory to an XML file")
+ public static void exportConnectionFactory(
+ @Doc(text = "deployed name") String deployedName,
+ @Doc(text = "file name") String fileName) throws AdminException, IOException{
+ Reader contents = getAdmin().exportConnectionFactory(deployedName);
+ writeFile(deployedName, fileName, contents);
+ }
+
+ private static void writeFile(String deployedName, String fileName,
+ Reader contents) throws IOException, AdminProcessingException {
+ if (contents == null) {
+ throw new AdminProcessingException(deployedName + " not found for exporting");
+ }
+ ObjectConverterUtil.write(new ReaderInputStream(contents, Charset.forName("UTF-8")), fileName); //$NON-NLS-1$
+ }
+
+ private static void writeFile(String deployedName, String fileName,
+ InputStream contents) throws IOException, AdminProcessingException {
+ if (contents == null) {
+ throw new AdminProcessingException(deployedName + " not found for exporting");
+ }
+ ObjectConverterUtil.write(contents, fileName);
+ }
+
+ @Doc(text = "Add a connector from a RAR file")
+ public static void addConnector(
+ @Doc(text = "name of the Connector") String name,
+ @Doc(text = "RAR file name") String rarFile) throws FileNotFoundException, AdminException {
+ FileInputStream fis = new FileInputStream(new File(rarFile));
+ try {
+ getAdmin().addConnector(name, fis);
+ } finally {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ @Doc(text = "Export a VDB to file")
+ public static void exportVDB(
+ @Doc(text = "vdb name") String vdbName,
+ @Doc(text = "vdb version") int vdbVersion,
+ @Doc(text = "file name") String fileName) throws AdminException, IOException{
+ InputStream contents = getAdmin().exportVDB(vdbName, vdbVersion);
+ writeFile(vdbName, fileName, contents);
+ }
+
+ @Doc(text = "Deploy a VDB from file")
+ public static void deployVDB(
+ @Doc(text = "file name") String vdbFile) throws AdminException, FileNotFoundException {
+ FileInputStream fis = new FileInputStream(new File(vdbFile));
+ try {
+ getAdmin().deployVDB(vdbFile, fis);
+ } finally {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ @Doc(text = "Add a DataSource")
+ public static void addDataSource(
+ @Doc(text = "deployed name") String deploymentName,
+ DataSourceType type,
+ Properties properties) throws AdminException {
+ getAdmin().addDataSource(deploymentName, type, properties);
+ }
+
+ @Doc(text = "Export the DataSource XML to file")
+ public static void exportDataSource(
+ @Doc(text = "deployed name") String deployedName,
+ @Doc(text = "file name") String fileName) throws AdminException, IOException {
+ Reader contents = getAdmin().exportDataSource(deployedName);
+ writeFile(deployedName, fileName, contents);
+ }
+
+ @Doc(text = "Get the current Admin connection")
+ public static Admin getAdmin() {
+ if (internalAdmin == null) {
+ throw new NullPointerException("Not connected. You must call a \"connectAsAdmin\" method or choose an active connection via \"useConnection\".");
+ }
+ return internalAdmin;
+ }
+
+ @Doc(text = "Disconnect the current connection for the server")
+ public static void disconnect() {
+ if (internalAdmin != null) {
+ internalAdmin.close();
+ internalAdmin = null;
+ currentName = null;
+ connections.remove(currentName);
+ }
+ }
+
+ @Doc(text = "Disconnect all connections from the server")
+ public static void disconnectAll() {
+ for (Admin admin : connections.values()) {
+ admin.close();
+ }
+ connections.clear();
+ internalAdmin = null;
+ currentName = null;
+ }
+
+ @Doc(text = "Use another connection")
+ public static void useConnection(
+ @Doc(text = "connection name") String name) {
+ Admin admin = connections.get(name);
+ if (admin == null) {
+ System.out.println("Warning: connection is not active for " + name);
+ return;
+ }
+ internalAdmin = admin;
+ currentName = name;
+ }
+
+ @Doc(text = "Returns the current connection name")
+ public static String getConnectionName() {
+ return currentName;
+ }
+
+ @Doc(text = "Return all connection names")
+ public static Collection<String> getAllConnections() {
+ return connections.keySet();
+ }
+
+ @Doc(text = "Show help for all admin methods")
+ public static void adminHelp() {
+ help.help();
+ }
+
+ @Doc(text = "Show help for the given admin method")
+ public static void adminHelp(
+ @Doc(text = "method name") String method) {
+ help.help(method);
+ }
+
+}
Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/AdminShell.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminConsole.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminConsole.java (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminConsole.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General public static
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General public static License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General public static
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import groovy.lang.Binding;
+import groovy.lang.Closure;
+import groovy.lang.GroovyShell;
+import groovy.ui.Console;
+
+import java.io.File;
+
+import javax.swing.UIManager;
+
+import org.codehaus.groovy.runtime.StackTraceUtils;
+import org.teiid.adminapi.Admin;
+
+public class GroovyAdminConsole {
+
+ public static final String IMPORTS = "import static " + AdminShell.class.getName() + ".*\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ "import static " + GroovySqlExtensions.class.getName() + ".*\n" + //$NON-NLS-1$ //$NON-NLS-2$
+ "import " + Admin.class.getPackage().getName() + ".*\n"; //$NON-NLS-1$ //$NON-NLS-2$
+
+ public static void main(String[] args) throws Exception {
+ // allow the full stack traces to bubble up to the root logger
+ java.util.logging.Logger.getLogger(StackTraceUtils.STACK_LOG_NAME).setUseParentHandlers(true);
+
+ //when starting via main set the look and feel to system
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+
+ final Console console = new Console(Console.class.getClassLoader());
+ console.setBeforeExecution(new Closure(null) {
+ public void doCall() {
+ console.setShell(new GroovyShell(Console.class.getClassLoader(), new Binding()) {
+ public Object run(String scriptText, String fileName, String[] args) throws org.codehaus.groovy.control.CompilationFailedException {
+ return super.run(IMPORTS + scriptText, fileName, args);
+ };
+ });
+ }
+ });
+ console.run();
+ if (args.length == 1) {
+ console.loadScriptFile(new File(args[0]));
+ }
+ }
+
+}
Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminConsole.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminShell.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminShell.java (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminShell.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General public static
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General public static License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General public static
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import org.codehaus.groovy.tools.shell.Main;
+
+public class GroovyAdminShell {
+
+ public static void main(String[] args) {
+ Main.main(args);
+ }
+
+}
Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovyAdminShell.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovySqlExtensions.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/GroovySqlExtensions.java (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/GroovySqlExtensions.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General public static
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General public static License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General public static
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import groovy.sql.TeiidSql;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Types;
+import java.util.Properties;
+
+import org.teiid.jdbc.TeiidDriver;
+import org.teiid.net.TeiidURL;
+import org.teiid.script.io.ResultSetReader;
+
+/**
+ * Extensions of Groovy Sql support, which somewhat bridges the gap to our old adminshell sql logic
+ */
+public class GroovySqlExtensions {
+
+ private static Help help = new Help(GroovySqlExtensions.class);
+
+ @Help.Doc(text = "Get a Teiid connection - using connection.properties")
+ public static TeiidSql connect(
+ @Help.Doc(text = "url") String url) throws SQLException {
+ return connect(url, null, null);
+ }
+
+ @Help.Doc(text = "Get a Teiid connection")
+ public static TeiidSql connect(
+ @Help.Doc(text = "url") String url,
+ @Help.Doc(text = "user") String user,
+ @Help.Doc(text = "password") String password) throws SQLException {
+ Properties info = new Properties();
+ if (user != null) {
+ info.setProperty(TeiidURL.CONNECTION.USER_NAME, user);
+ }
+ if (password != null) {
+ info.setProperty(TeiidURL.CONNECTION.PASSWORD, password);
+ }
+ Connection c = TeiidDriver.getInstance().connect(url, info);
+ if (c == null) {
+ throw new SQLException("Invalid url " + url);
+ }
+ return new TeiidSql(c);
+ }
+
+ @SuppressWarnings("nls")
+ @Help.Doc(text = "Get a SQL connection using the defaults from connection.properties")
+ public static TeiidSql connect() throws SQLException {
+ AdminShell.loadConnectionProperties();
+ return connect(AdminShell.p.getProperty("jdbc.url", "jdbc:teiid:VDB@mm://localhost:31000"),
+ AdminShell.p.getProperty("jdbc.user", "admin"), AdminShell.p.getProperty("jdbc.password", "teiid"));
+ }
+
+ @Help.Doc(text = "Alternate row to String method that pretty prints SQL/XML," +
+ " \ne.g. sql.eachRow(\"select * from tables\", {row -> println rowToString(row) })")
+ public static String rowToString(ResultSet results) throws SQLException {
+ StringBuilder sb = new StringBuilder();
+ //alternative toString - see GroovyResultSetExtension
+ int columnCount = results.getMetaData().getColumnCount();
+ for (int col = 1; col <= columnCount; col++) {
+ int type = results.getMetaData().getColumnType(col);
+ if (type == Types.BLOB) {
+ Object anObj = results.getObject(col);
+ sb.append(anObj != null ? "BLOB" : "null"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else if (type == Types.SQLXML) {
+ SQLXML xml = results.getSQLXML(col);
+ sb.append(xml != null ? ResultSetReader.prettyPrint(xml) : "null"); //$NON-NLS-1$
+ }
+ else {
+ String str = results.getString(col);
+ sb.append(str != null ? str : "null"); //$NON-NLS-1$
+ }
+ if (col != columnCount) {
+ sb.append(" "); //$NON-NLS-1$
+ }
+ }
+ return sb.toString();
+ }
+
+ @Help.Doc(text = "Pretty prints the ResultSetMetadata")
+ public static String resultSetMetaDataToString(ResultSetMetaData rsmd) throws SQLException {
+ return ResultSetReader.resultSetMetaDataToString(rsmd, " "); //$NON-NLS-1$
+ }
+
+ @Help.Doc(text = "Show help for all Sql methods")
+ public static void sqlHelp() {
+ help.help();
+ }
+
+ @Help.Doc(text = "Show help for the given Sql method")
+ public static void sqlHelp(
+ @Help.Doc(text = "method name") String method) {
+ help.help(method);
+ }
+
+}
Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/GroovySqlExtensions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.TreeMap;
+
+/**
+ * A simple help system built off of scanning public static methods.
+ */
+public class Help {
+
+ @Documented
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ElementType.METHOD, ElementType.PARAMETER})
+ public @interface Doc {
+ String text();
+ }
+
+ private TreeMap<String, List<String>> help = new TreeMap<String, List<String>>();
+ private List<String> shortHelp = new ArrayList<String>();
+
+ public Help(Class<?> clazz) {
+ Method[] methods = clazz.getMethods();
+ for (Method method : methods) {
+ if (!Modifier.isPublic(method.getModifiers()) || !Modifier.isStatic(method.getModifiers())) {
+ continue;
+ }
+ StringBuilder sb = new StringBuilder();
+ Help.Doc doc = method.getAnnotation(Help.Doc.class);
+ StringBuilder shortSb = new StringBuilder();
+ shortSb.append(method.getName()).append("("); //$NON-NLS-1$
+ if (method.getParameterTypes().length > 0) {
+ shortSb.append(method.getParameterTypes().length);
+ }
+ shortSb.append(")"); //$NON-NLS-1$
+ String shortHelpStr = String.format(" %-25s", shortSb.toString()); //$NON-NLS-1$
+ if (doc != null && doc.text() != null) {
+ sb.append("/*\n *").append(doc.text()).append("\n */\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ shortHelpStr += " -- " + doc.text(); //$NON-NLS-1$
+ }
+ shortHelp.add(shortHelpStr);
+ Class<?> returnType = method.getReturnType();
+ sb.append(returnType.getSimpleName()).append(" "); //$NON-NLS-1$
+ sb.append(method.getName()).append("("); //$NON-NLS-1$
+ Class<?>[] params = method.getParameterTypes();
+ for (int i = 0; i < params.length; i++) {
+ if (i > 0) {
+ sb.append(","); //$NON-NLS-1$
+ }
+ sb.append("\n ").append(params[i].getSimpleName()); //$NON-NLS-1$
+ Annotation[] annos = method.getParameterAnnotations()[i];
+ for (Annotation annotation : annos) {
+ if (!(annotation instanceof Help.Doc)) {
+ continue;
+ }
+ Help.Doc paramdoc = (Help.Doc)annotation;
+ if (paramdoc.text() != null) {
+ sb.append(" /* ").append(paramdoc.text()).append(" */"); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ }
+ }
+ }
+ sb.append(")\n"); //$NON-NLS-1$
+ for(Class<?> exceptionClass : method.getExceptionTypes()) {
+ sb.append(" throws ").append(exceptionClass.getSimpleName()).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ String key = method.getName().toUpperCase();
+ List<String> signatures = help.get(key);
+ if (signatures == null) {
+ signatures = new LinkedList<String>();
+ help.put(key, signatures);
+ }
+ signatures.add(sb.toString());
+ }
+ Collections.sort(shortHelp);
+ }
+
+ public void help() {
+ System.out.println("/* method(arg count) -- description */"); //$NON-NLS-1$
+ for (String helpString : shortHelp) {
+ System.out.println(helpString);
+ }
+ }
+
+ public void help(String method) {
+ List<String> helpStrings = null;
+ if (method != null) {
+ helpStrings = help.get(method.toUpperCase());
+ }
+ if (helpStrings != null) {
+ for (String helpString : helpStrings) {
+ System.out.println(helpString);
+ }
+ } else {
+ System.out.println("Unknown method");
+ }
+ }
+
+}
Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/Help.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java (from rev 2036, trunk/adminshell/src/main/java/org/teiid/MigrationUtil.java)
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java (rev 0)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,201 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.adminshell;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import com.metamatrix.common.util.ApplicationInfo;
+import com.metamatrix.core.util.FileUtils;
+import com.metamatrix.core.util.ObjectConverterUtil;
+
+@SuppressWarnings("nls")
+public class MigrationUtil {
+
+ public static void main(String[] args) throws IOException, TransformerConfigurationException, TransformerFactoryConfigurationError, TransformerException {
+ if (args.length != 1) {
+ System.err.println(
+ "Teiid 7.0 VDB Migration Utility" +
+ "\n\nUsage:" +
+ "\n A vdb or .def file must be specified as the only argument." +
+ "\n\nResult:"+
+ "\n 7.0 compatible replacement files will be created in the same directory " +
+ "\n as your file." +
+ "\n If you supply a vdb, the new vdb file will have a _70.vdb suffix." +
+ "\n If you supply a dynamic vdb file, then two new files will be created: " +
+ "\n <file name>-vdb.xml and <file name>-bindings.xml" +
+ "\n\nNote: this program will only create connector binding connection factories " +
+ "\n if the bindings are present in the specified file." +
+ "\n\nNote: this program will NOT create the -ds.xml files needed by JBoss to " +
+ "\n create underlying DataSource connection pools." +
+ "\n You will need to manually create one -ds.xml for each JDBC DataSource " +
+ "\n with a JNDI name of <connector binding name>DS, " +
+ "\n where any spaces in the name are replace by _" +
+ "\n\nNode: depending upon the connectors used, you may need to manually edit the " +
+ " -bindings.xml file.");
+ System.exit(-1);
+ }
+ File file = new File(args[0]);
+ if (!file.exists()) {
+ System.err.println(args[0] + " does not exist."); //$NON-NLS-1$
+ System.exit(-1);
+ }
+ String fullName = file.getName();
+ String fileName = fullName.substring(0, fullName.length() - 4);
+ String ext = FileUtils.getExtension(file);
+ if (ext == null) {
+ System.err.println(fullName + " is not a vdb or xml file."); //$NON-NLS-1$
+ System.exit(-1);
+ }
+ ext = ext.toLowerCase();
+ if (ext.endsWith("vdb")) {
+ File dir = createTempDirectory();
+ try {
+ extract(file, dir);
+ File metainf = new File(dir, "META-INF");
+ File config = new File(dir, "ConfigurationInfo.def");
+ File manifest = new File(dir, "MetaMatrix-VdbManifestModel.xmi");
+ if (manifest.exists()) {
+ String configStr = ObjectConverterUtil.convertFileToString(config);
+ String manifestStr = ObjectConverterUtil.convertFileToString(manifest);
+ int index = configStr.lastIndexOf("</VDB>");
+ int manifestBegin = manifestStr.indexOf("<xmi");
+ configStr = configStr.substring(0, index) + manifestStr.substring(manifestBegin) + "</VDB>";
+ FileUtils.write(configStr.getBytes(), config);
+ manifest.delete();
+ }
+ transformConfig(config, "/vdb.xsl", new StreamResult(new File(metainf, "vdb.xml")));
+ transformConfig(config, "/connector.xsl", new StreamResult(new File(file.getParentFile(), fileName + "-bindings-ds.xml")));
+ config.delete();
+ FileOutputStream out = new FileOutputStream(new File(file.getParent(), fileName + "_70.vdb"));
+ ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(out));
+ int parentLength = dir.getPath().length();
+ addDirectory(dir, zos, parentLength);
+ zos.close();
+ } finally {
+ FileUtils.removeDirectoryAndChildren(dir);
+ }
+ } else if (ext.endsWith("xml") || ext.endsWith("def")){
+ File parent = file.getParentFile();
+ transformConfig(file, "/vdb.xsl", new StreamResult(new File(parent, fileName + "-vdb.xml")));
+ transformConfig(file, "/connector.xsl", new StreamResult(new File(parent, fileName + "-bindings-ds.xml")));
+ } else {
+ System.err.println(fullName + " is not a vdb or xml file. Run with no arguments for help."); //$NON-NLS-1$
+ System.exit(-1);
+ }
+ }
+
+ private static void addDirectory(File dir, ZipOutputStream zos,
+ int parentLength) throws IOException {
+ String[] files = dir.list();
+ for (String entry : files) {
+ File f = new File(dir, entry);
+ if (f.isDirectory()) {
+ addDirectory(f, zos, parentLength);
+ } else {
+ ZipEntry e = new ZipEntry(f.getPath().substring(parentLength));
+ zos.putNextEntry(e);
+ FileUtils.write(f, zos);
+ zos.closeEntry();
+ }
+ }
+ }
+
+ private static void transformConfig(File config, String styleSheet, Result target)
+ throws TransformerFactoryConfigurationError,
+ TransformerConfigurationException, TransformerException {
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer t = tf.newTransformer(new StreamSource(MigrationUtil.class.getResourceAsStream(styleSheet)));
+ t.setParameter("version", ApplicationInfo.getInstance().getReleaseNumber()); //$NON-NLS-1$
+ t.transform(new StreamSource(config), target);
+ }
+
+ /**
+ * Extract the given zip file to the given destination directory base.
+ *
+ * @param zipFileName
+ * The full path and file name of the Zip file to extract.
+ * @param destinationDirectory
+ * The root directory to extract to.
+ * @throws IOException
+ */
+ static void extract(final File sourceZipFile, File unzipDestinationDirectory) throws IOException {
+ // Open Zip file for reading
+ ZipFile zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);
+
+ // Create an enumeration of the entries in the zip file
+ Enumeration zipFileEntries = zipFile.entries();
+
+ // Process each entry
+ while (zipFileEntries.hasMoreElements()) {
+ // grab a zip file entry
+ ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();
+
+ String currentEntry = entry.getName();
+
+ File destFile = new File(unzipDestinationDirectory, currentEntry);
+
+ // grab file's parent directory structure
+ File destinationParent = destFile.getParentFile();
+
+ // create the parent directory structure if needed
+ destinationParent.mkdirs();
+
+ // extract file if not a directory
+ if (!entry.isDirectory()) {
+ ObjectConverterUtil.write(zipFile.getInputStream(entry),
+ destFile);
+ }
+ }
+ zipFile.close();
+ }
+
+ static File createTempDirectory() throws IOException {
+ File temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
+
+ temp.delete();
+
+ if (!(temp.mkdir())) {
+ throw new IOException("Could not create temp directory: "
+ + temp.getAbsolutePath());
+ }
+
+ return temp;
+ }
+
+}
Property changes on: trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/adminshell/src/main/java/org/teiid/script/io/MetadataReader.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/script/io/MetadataReader.java 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/src/main/java/org/teiid/script/io/MetadataReader.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.script.io;
-
-import java.io.IOException;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-
-
-public class MetadataReader extends StringLineReader {
-
- ResultSetMetaData source;
- String delimiter = " "; //$NON-NLS-1$
-
- boolean firsttime = true;
- int currentColumn = 0;
-
- public MetadataReader(ResultSetMetaData metadata, String delimiter) {
- this.source = metadata;
- this.delimiter = delimiter;
- }
-
- @Override
- protected String nextLine() throws IOException {
- if (firsttime) {
- this.firsttime = false;
- return firstLine();
- }
-
- try {
- int count = this.source.getColumnCount();
- if (this.currentColumn < count) {
- this.currentColumn++;
- return getNextRow();
- }
- } catch (SQLException e) {
- throw new IOException(e.getMessage());
- }
- return null;
- }
-
- String firstLine() {
- StringBuffer sb = new StringBuffer();
- sb.append("ColumnName").append(delimiter); //$NON-NLS-1$
- sb.append("ColumnType").append(delimiter); //$NON-NLS-1$
- sb.append("ColumnTypeName").append(delimiter); //$NON-NLS-1$
- sb.append("ColumnClassName").append(delimiter); //$NON-NLS-1$
- sb.append("isNullable").append(delimiter); //$NON-NLS-1$
- sb.append("TableName").append(delimiter); //$NON-NLS-1$
- sb.append("SchemaName").append(delimiter); //$NON-NLS-1$
- sb.append("CatalogName").append(delimiter); //$NON-NLS-1$
- sb.append("\n"); //$NON-NLS-1$
- return sb.toString();
- }
-
- String getNextRow() throws SQLException {
- StringBuffer sb = new StringBuffer();
-
- sb.append(source.getColumnName(currentColumn)).append(delimiter);
- sb.append(source.getColumnType(currentColumn)).append(delimiter);
- sb.append(source.getColumnTypeName(currentColumn)).append(delimiter);
- sb.append(source.getColumnClassName(currentColumn)).append(delimiter);
- sb.append(source.isNullable(currentColumn)).append(delimiter);
- sb.append(source.getTableName(currentColumn)).append(delimiter);
- sb.append(source.getSchemaName(currentColumn)).append(delimiter);
- sb.append(source.getCatalogName(currentColumn)).append(delimiter);
- sb.append("\n"); //$NON-NLS-1$
-
- return sb.toString();
- }
-}
Modified: trunk/adminshell/src/main/java/org/teiid/script/io/ResultSetReader.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/script/io/ResultSetReader.java 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/src/main/java/org/teiid/script/io/ResultSetReader.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -100,7 +100,7 @@
for (int i = 0; i < columnCount; i++) {
columnTypes[i] = metadata.getColumnType(i+1);
}
- return firstLine(metadata);
+ return resultSetMetaDataToString(metadata, delimiter);
}
// if you get here then we are ready to read the results.
@@ -146,8 +146,9 @@
* @return
* @throws SQLException
*/
- String firstLine(ResultSetMetaData metadata) throws SQLException{
+ public static String resultSetMetaDataToString(ResultSetMetaData metadata, String delimiter) throws SQLException{
StringBuffer sb = new StringBuffer();
+ int columnCount = metadata.getColumnCount();
for (int col = 1; col <= columnCount; col++) {
sb.append(metadata.getColumnName(col))
.append("[") //$NON-NLS-1$
@@ -161,7 +162,7 @@
return sb.toString();
}
- String prettyPrint(SQLXML xml) throws SQLException {
+ public static String prettyPrint(SQLXML xml) throws SQLException {
try {
TransformerFactory transFactory = TransformerFactory.newInstance();
transFactory.setAttribute("indent-number", new Integer(2)); //$NON-NLS-1$
Deleted: trunk/adminshell/src/main/java/org/teiid/script/io/StringArrayReader.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/script/io/StringArrayReader.java 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/adminshell/src/main/java/org/teiid/script/io/StringArrayReader.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.script.io;
-
-import java.io.IOException;
-
-
-/**
- * Converts a String Array object into a Reader object.
- */
-public class StringArrayReader extends StringLineReader {
- String[] source = null;
- int index = 0;
-
- public StringArrayReader(String[] src) {
- this.source = src;
- }
-
- protected String nextLine() throws IOException {
- if (index < this.source.length) {
- return this.source[index++]+"\n"; //$NON-NLS-1$
- }
- return null;
- }
-}
Added: trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/commands.xml
===================================================================
--- trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/commands.xml (rev 0)
+++ trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/commands.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2003-2007 the original author or authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: commands.xml 12257 2008-05-04 08:51:41Z user57 $ -->
+
+<commands>
+ <command>org.codehaus.groovy.tools.shell.commands.HelpCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.ExitCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.ImportCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.DisplayCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.ClearCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.ShowCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.InspectCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.PurgeCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.EditCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.LoadCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.SaveCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.RecordCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.HistoryCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.AliasCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.SetCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.ShadowCommand</command>
+
+ <command>org.codehaus.groovy.tools.shell.commands.RegisterCommand</command>
+
+ <command>org.teiid.adminshell.AdminHelpCommand</command>
+</commands>
+
Property changes on: trunk/adminshell/src/main/resources/org/codehaus/groovy/tools/shell/commands.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/adminshell/src/main/resources/org/teiid/adminshell/AdminHelpCommand.properties
===================================================================
--- trunk/adminshell/src/main/resources/org/teiid/adminshell/AdminHelpCommand.properties (rev 0)
+++ trunk/adminshell/src/main/resources/org/teiid/adminshell/AdminHelpCommand.properties 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,3 @@
+command.description=Display Teiid Admin Help
+command.usage=[<method>]
+command.help=Display the list of Teiid Admin methods or the help text for @|BOLD method|@. This reports the same information as the adminHelp([method]) function.
\ No newline at end of file
Property changes on: trunk/adminshell/src/main/resources/org/teiid/adminshell/AdminHelpCommand.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/build/kit-adminshell/adminconsole.bat
===================================================================
--- trunk/build/kit-adminshell/adminconsole.bat (rev 0)
+++ trunk/build/kit-adminshell/adminconsole.bat 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,79 @@
+@ECHO OFF
+@setlocal
+
+@REM JBoss, Home of Professional Open Source.
+@REM Copyright (C) 2008 Red Hat, Inc.
+@REM Licensed to Red Hat, Inc. under one or more contributor
+@REM license agreements. See the copyright.txt file in the
+@REM distribution for a full listing of individual contributors.
+@REM
+@REM This library is free software; you can redistribute it and/or
+@REM modify it under the terms of the GNU Lesser General Public
+@REM License as published by the Free Software Foundation; either
+@REM version 2.1 of the License, or (at your option) any later version.
+@REM
+@REM This library is distributed in the hope that it will be useful,
+@REM but WITHOUT ANY WARRANTY; without even the implied warranty of
+@REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+@REM Lesser General Public License for more details.
+@REM
+@REM You should have received a copy of the GNU Lesser General Public
+@REM License along with this library; if not, write to the Free Software
+@REM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+@REM 02110-1301 USA.
+
+@REM This assumes it's run from its installation directory. It is also assumed there is a java
+@REM executable defined along the PATH
+
+@if not "%ECHO%" == "" echo %ECHO%
+@if "%OS%" == "Windows_NT" setlocal
+
+if "%OS%" == "Windows_NT" (
+ set "DIRNAME=%~dp0%"
+) else (
+ set DIRNAME=.\
+)
+
+pushd %DIRNAME%
+if "x%TEIID_HOME%" == "x" (
+ set "TEIID_HOME=%CD%"
+)
+popd
+
+set DIRNAME=
+
+if "x%JAVA_HOME%" == "x" (
+ set JAVA=java
+ echo JAVA_HOME is not set. Unexpected results may occur.
+ echo Set JAVA_HOME to the directory of your local JDK to avoid this message.
+) else (
+ set "JAVA=%JAVA_HOME%\bin\java"
+ if exist "%JAVA_HOME%\lib\tools.jar" (
+ set "JAVAC_JAR=%JAVA_HOME%\lib\tools.jar"
+ )
+)
+
+set TEIID_CLASSPATH=%TEIID_HOME%\lib\patches\*;%TEIID_HOME%\lib\*;
+
+rem JVM memory allocation pool parameters. Modify as appropriate.
+set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx256m -XX:MaxPermSize=256m
+set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.config.file=log.properties
+
+echo ===============================================================================
+echo.
+echo Teiid AdminShell Bootstrap Environment
+echo.
+echo TEIID_HOME: %TEIID_HOME%
+echo.
+echo JAVA: %JAVA%
+echo.
+echo JAVA_OPTS: %JAVA_OPTS%
+echo.
+echo CLASSPATH: %TEIID_CLASSPATH%
+echo.
+echo ===============================================================================
+echo.
+
+"%JAVA%" %JAVA_OPTS% ^
+ -classpath "%TEIID_CLASSPATH%" ^
+ org.teiid.adminshell.GroovyAdminConsole %*
Property changes on: trunk/build/kit-adminshell/adminconsole.bat
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/build/kit-adminshell/adminconsole.sh
===================================================================
--- trunk/build/kit-adminshell/adminconsole.sh (rev 0)
+++ trunk/build/kit-adminshell/adminconsole.sh 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# JBoss, Home of Professional Open Source.
+# Copyright (C) 2008 Red Hat, Inc.
+# Licensed to Red Hat, Inc. under one or more contributor
+# license agreements. See the copyright.txt file in the
+# distribution for a full listing of individual contributors.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+
+DIRNAME=`dirname $0`
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false;
+linux=false;
+case "`uname`" in
+ CYGWIN*)
+ cygwin=true
+ ;;
+
+ Linux)
+ linux=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$TEIID_HOME" ] &&
+ TEIID_HOME=`cygpath --unix "$TEIID_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Setup TEIID_HOME
+if [ "x$TEIID_HOME" = "x" ]; then
+ # get the full path (without any relative bits)
+ TEIID_HOME=`cd $DIRNAME; pwd`
+fi
+export TEIID_HOME
+
+# Setup the JVM
+if [ "x$JAVA" = "x" ]; then
+ if [ "x$JAVA_HOME" != "x" ]; then
+ JAVA="$JAVA_HOME/bin/java"
+ else
+ JAVA="java"
+ fi
+fi
+
+# JPDA options. Uncomment and modify as appropriate to enable remote debugging.
+# JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
+
+TEIID_CLASSPATH="$TEIID_HOME/lib/patches/*:$TEIID_HOME/lib/*"
+JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx256m -XX:MaxPermSize=256m"
+JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.config.file=log.properties"
+
+# Print the env settings
+echo "======================================================================"
+echo ""
+echo " Teiid AdminShell Bootstrap Environment"
+echo ""
+echo " TEIID_HOME = $TEIID_HOME"
+echo " CLASSPATH = $TEIID_CLASSPATH"
+echo " JAVA = $JAVA"
+echo ""
+echo "======================================================================"
+echo ""
+
+$JAVA $JAVA_OPTS -cp $TEIID_CLASSPATH -Xmx256m org.teiid.adminshell.GroovyAdminConsole $*
\ No newline at end of file
Property changes on: trunk/build/kit-adminshell/adminconsole.sh
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/build/kit-adminshell/adminshell.bat
===================================================================
--- trunk/build/kit-adminshell/adminshell.bat 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/build/kit-adminshell/adminshell.bat 2010-04-16 21:15:33 UTC (rev 2061)
@@ -76,4 +76,4 @@
"%JAVA%" %JAVA_OPTS% ^
-classpath "%TEIID_CLASSPATH%" ^
- org.teiid.AdminShell %*
+ org.teiid.adminshell.GroovyAdminShell %*
Modified: trunk/build/kit-adminshell/adminshell.sh
===================================================================
--- trunk/build/kit-adminshell/adminshell.sh 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/build/kit-adminshell/adminshell.sh 2010-04-16 21:15:33 UTC (rev 2061)
@@ -79,4 +79,4 @@
echo "======================================================================"
echo ""
-$JAVA $JAVA_OPTS -cp $TEIID_CLASSPATH -Xmx256m org.teiid.AdminShell $*
\ No newline at end of file
+$JAVA $JAVA_OPTS -cp $TEIID_CLASSPATH -Xmx256m org.teiid.adminshell.GroovyAdminShell $*
\ No newline at end of file
Modified: trunk/build/kit-adminshell/migrate.bat
===================================================================
--- trunk/build/kit-adminshell/migrate.bat 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/build/kit-adminshell/migrate.bat 2010-04-16 21:15:33 UTC (rev 2061)
@@ -61,4 +61,4 @@
"%JAVA%" %JAVA_OPTS% ^
-classpath "%TEIID_CLASSPATH%" ^
- org.teiid.MigrationUtil %*
+ org.teiid.adminshell.MigrationUtil %*
Modified: trunk/build/kit-adminshell/migrate.sh
===================================================================
--- trunk/build/kit-adminshell/migrate.sh 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/build/kit-adminshell/migrate.sh 2010-04-16 21:15:33 UTC (rev 2061)
@@ -67,4 +67,4 @@
JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx256m -XX:MaxPermSize=256m"
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.config.file=log.properties"
-$JAVA $JAVA_OPTS -cp $TEIID_CLASSPATH -Xmx256m org.teiid.MigrationUtil $*
\ No newline at end of file
+$JAVA $JAVA_OPTS -cp $TEIID_CLASSPATH -Xmx256m org.teiid.adminshell.MigrationUtil $*
\ No newline at end of file
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -49,10 +49,8 @@
<xi:include href="content/getting-started.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/working-with-scripts.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/connection-management.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/writing-tests.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/appendix-a.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="content/appendix-b.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/appendix-c.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-a.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-a.xml 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-a.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -6,7 +6,7 @@
<para>Are there any pre-built scripts available?</para>
</question>
<answer>
- <para>Yes, there are a few utility scripts are available in the "samples" directory with ".bsh" extension.</para>
+ <para>Currently no, but we will provide samples in subsequent releases.</para>
</answer>
</qandaentry>
@@ -15,38 +15,25 @@
<para>I have written a very useful script to do XYZ, I would like this to be part of the distribution?</para>
</question>
<answer>
- <para>Yes, we would love to hear from users. Please submit the script to Technical Support, and if this script found to be useful and generic enough for all the customers, we will include the script in the scripts library in the following releases.</para>
+ <para>Yes, we would love to hear from users. Please submit the script through the <ulink url="https://jira.jboss.org/jira/browse/TEIID">Teiid JIRA</ulink>, and if this script popular, we will include the script in the scripts library in the following releases.</para>
</answer>
</qandaentry>
<qandaentry>
<question>
- <para>What is different between "connect(<url>)" method and "connectAsAdmin()"?</para>
+ <para>What is different between "connectAsAdmin()" and "connect()" ?</para>
</question>
<answer>
- <para>Connect connects to the Teiid system using a VDB name, so you should be able to run any SQL command which is based on that VDB along with Admin method calls. If you use "connectAsAdmin" then you can run all the admin calls but you can not run any SQL commands, and you do not need a VDB to connect to the Teiid system.</para>
+ <para>The connectAsAdmin methods create a contextual connection to the AdminAPI of the Teiid Server. The connect methods return an extension of the Groovy Sql object to be used for Sql calls to the Teiid Server.</para>
</answer>
</qandaentry>
<qandaentry>
<question>
- <para>How can I turn on the debug?</para>
- </question>
- <answer>
- <para>At command prompt type</para>
- <programlisting><![CDATA[
-admin $ debug= true; // to turn it ON
-admin $ debug= false; // to turn it OFF
- ]]></programlisting>
- </answer>
- </qandaentry>
-
- <qandaentry>
- <question>
<para>Is IDE support available for writing the scripts?</para>
</question>
<answer>
- <para>Full IDE support is not available, however eclipse can be used as the editor for developing the scripts. Just set the “.bsh” extension association with Java editor, so all the color syntax is available for your script.</para>
+ <para>The AdminConsole tool is a light IDE. Full IDE support is available for Groovy, but requires manual manipulation of the class path and script imports. See <link linkend="other_environments">using AdminShell methods in other environments</link>.</para>
</answer>
</qandaentry>
@@ -55,24 +42,9 @@
<para>Is debugging support available?</para>
</question>
<answer>
- <para>No. Not for the scripts. However, if the scripts are calling into other Java code, those calls can be intercepted and can be run through debugger.</para>
+ <para>The interactive shell and console do have built-in support for inspection of the current state. Performing line based debugging is beyond the scope of this document.</para>
</answer>
</qandaentry>
-
- <qandaentry>
- <question>
- <para>How to turn OFF interactive mode? How can I capture results to a file?</para>
- </question>
- <answer>
- <para>Once you start the shell in the interactive mode, at the prompt enter the following</para>
- <programlisting><![CDATA[
- bsh.interactive=false;
- ]]></programlisting>
- <para>this will turn off the interactive features like spitting the results to console. This is good way to capture
- the results of the executed query. Use <emphasis>printResults(File)</emphasis> method to capture the previously executed
- SQL command's results to the file handle supplied</para>
- </answer>
- </qandaentry>
-
+
</qandaset>
</appendix>
\ No newline at end of file
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-b.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-b.xml 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-b.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,90 +1,24 @@
-<appendix id="assertion_list">
- <title>Assert Commands Available</title>
- <para>The following are the list of assert commands available in the Admin Shell to be used with the scripts.
- </para>
- <sect1>
- <title>Assertions for SQL results</title>
- <programlisting><![CDATA[
-/**
- * Assert that the result set has given number of rows.
- * @param count – Number of rows expected
- */
-assertRowCount(int count);
-
-
-/**
- * Assert that the result set contents match those of supplied rows
- * @param expectedRows – expected rows
- */
-assertResultsSetEquals(String[] expectedRows);
-
-/**
- * Assert that the result set contents match those of supplied rows in
- * a file
- * @param expectedRows – expected rows
- */
-assertResultsSetEquals(File expected)
- ]]></programlisting>
- </sect1>
- <sect1>
- <title>Assertions for checking any values</title>
- <programlisting><![CDATA[
-/**
- * assert that the given expression is true or false
- */
-void assertTrue(boolean condition);
-void assertTrue(String message, boolean condition);
-void assertFalse(boolean condition);
-void assertFalse(String message, boolean condition);
-
-
-/**
- * Assert that two supplied values are equal
- */
-void assertEquals(boolean expected, boolean actual);
-void assertEquals(byte expected, byte actual);
-void assertEquals(char expected, char actual);
-void assertEquals(double expected, double actual,double delta) ;
-void assertEquals(float expected, float actual,float delta);
-void assertEquals(int expected, int actual);
-void assertEquals(Object expected, Object actual);
-void assertEquals(long expected, long actual);
-void assertEquals(short expected, short actual) ;
-void assertEquals(String message, boolean expected, boolean actual);
-void assertEquals(String message, byte expected,byte actual);
-void assertEquals(String message, char expected,char actual);
-void assertEquals(String message, double expected,double actual,double delta);
-void assertEquals(String message, float expected,float actual,float delta);
-void assertEquals(String message, int expected, int actual);
-void assertEquals(String message, Object expected,Object actual);
-void assertEquals(String expected, String actual);
-void assertEquals(String message,String expected,String actual);
-void assertEquals(String message,long expected,long actual)
-void assertEquals(String message,short expected,short actual);
-
-/**
- * Assert that the given object is either Null or Not Null
- */
-void assertNotNull(Object object);
-void assertNotNull(String message, Object object);
-void assertNull(Object object) ;
-void assertNull(String message, Object object);
-
-/**
- * Assertion to check if two supplied objects same objects or not
- * the difference here is these use == vs equals in the equals methods.
- */
-void assertNotSame(Object expected, Object actual) ;
-void assertNotSame(String message,Object expected,Object actual);
-void assertSame(Object expected, Object actual);
-void assertSame(String message,Object expected,Object actual);
-
-
-/**
- * Assertion to fail the program explicitly
- */
-void fail();
-void fail(String message);
- ]]></programlisting>
- </sect1>
+<appendix id="other_environments">
+ <title>Other Environments</title>
+ <para>The AdminShell methods (named contextual connections, AdminAPI
+ wrapper, and help system) have no direct dependencies on Groovy and be
+ used in other scripting languages.</para>
+ <para>To use the AdminShell methods in another language, simply import
+ the static methods and Admin classes into your script. You will also
+ need to ensure that the <admin shell
+ dist>/lib/teiid-{version}-client.jar and <admin shell
+ dist>/lib/teiid-adminshell-{version}.jar are in your class path. The
+ snippet below show import statements
+ that would work in Java,
+ BeanShell, Groovy, etc.</para>
+ <programlisting><![CDATA[
+import static org.teiid.adminshell.AdminShell.*;
+import org.teiid.adminapi.*;
+ ]]></programlisting>
+ <para>Note that the provided shell and console executables
+ automatically have the proper class path set and inject the proper
+ imports into running scripts. If you wish to use scripts in a
+ non-Teiid Groovy environment, you will need to manually add these
+ imports and add the admin/client jars to the class path.
+ </para>
</appendix>
\ No newline at end of file
Deleted: trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/appendix-c.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,59 +0,0 @@
-<appendix id="jdbc_commands">
- <title>JDBC Commands</title>
- <para>The following are the list of commands available in the JDBC module, these will aid in executing SQL
- commands in the Admin Shell. These commands can be used in your program once after the initial connection is
- made</para>
- <programlisting><![CDATA[
-/**
- * Executes a SQL Command
- */
-execute(String command);
-
-/**
- * Executes a SQL Command using the prepared statement. Note that command can contain ?
- * for input parameter place holders and the object array can contain the corresponding values. If
- * command starts with “exec” then it will treat the command as the stored procedure call.
- */
-execute(String command, Object[] parms);
-
-/**
- * Executes a supplied commands in the string array using Batch mode
- * @param commands - array of commands
- */
-execute(String[] commands);
-
-/**
- * Prints the previously executed ResultSet contents to system out; usally in the interactive more the
- * resultset is automatically read, so this applies only in the script mode.
- */
-printResults();
-
-/**
- * Prints the previously executed ResultSet contents to a file.usally in the interactive more the
- * resultset is automatically read, so this applies only in the script mode.
- * @param File
- */
-printResults(File file);
-
-/**
- * Prints the previously executed ResultSet to system out, in the form required by the assert call. Usally in
- * the interactive more the resultset is automatically read, so this applies only in the script mode.
- * @param comparePrint - true - print in the format that can be used in the regression tests
- * - false - print to console
- */
-printResults(boolean comparePrint);
-
-/**
- * Walks the ResultSet, but does not print any results. Good for performance testing. Usally in
- * the interactive more the resultset is automatically read, so this applies only in the script mode.
- */
-walkResults();
-
-/**
- * Shows the plan associated with the last executed statement.
- * @param xml - true - show in xml form
- * - false - show in text form
- */
-showPlan(boolean xml);
- ]]></programlisting>
-</appendix>
\ No newline at end of file
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/connection-management.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/connection-management.xml 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/connection-management.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -5,89 +5,77 @@
<sect1>
<title>Default Connection Properties</title>
<para>The file "connection.properties" in the installation directory of the AdminShell defines the default
- connection properties with which user can connect to Teiid system. The following properties can be
+ connection properties with which user can connect to Teiid system. The following properties can be
defined using this file</para>
<programlisting><![CDATA[
-server.host = <server host name or ip address>
-server.port = <server port number>
-user.name = <user name>
-user.password = <password>
-vdb.name = <vdb name>
+admin.url = <server host name or ip address>
+admin.name = <user name>
+admin.password = <password>
+
+jdbc.url = <server host name or ip address>
+jdbc.user = <user name>
+jdbc.password = <password>
]]></programlisting>
- <para>When properties file is found, a call to "connect()" without any input parameters, will connect to
- the Teiid system using the properties defined in properties file. However, user can always pass in
+ <para>A call to "connect()" or "connectionAsAdmin()" without any input parameters, will connect to
+ the Teiid system using the properties defined in properties file. However, a user can always pass in
parameters in the connect method to connect to a same or different server than one mentioned in the
- “connection.properties”. Look all the all the different connect methods using the “help()” method. </para>
+ “connection.properties”. Look all the all the different connect methods using the “adminHelp()” method. </para>
<para>Note that it is not secure to leave the passwords in clear text, as defined above. Please take
necessary measures to secure the properties file, or do not use this feature and always pass in password
interactively or some other secure way.</para>
<para>Note: At any given time user can be actively connected to more than one system or have more than one
connection to same system. To manage the connections correctly each connection is created given a unique
- connection name. To learn more about this look at Handling multiple Connections section.</para>
+ connection name. To learn more about this look at <link linkend="mutiple_connections">Handling Multiple Connections</link>.</para>
<para />
</sect1>
- <sect1>
+ <sect1 id="mutiple_connections">
<title>Handling Multiple Connections</title>
- <para>Using AdminShell, user can actively manage more than one connection to a single or multiple Teiid
+ <para>Using AdminShell, a user can actively manage more than one connection to a single or multiple Teiid
systems. For example, two separate connections can be maintained, one to the development server and one to
- the integration server at the same time. This is possible because Admin Shell supports a feature called named
- connections. </para>
- <para>Every time a connection is made, it assigns a unique name to that connection and manages the
- context of the connection under that name. Unless, user makes another connection all the commands executed
- after the connection is made will use that connection. If another connect command is executed then a new
- connection is made with a unique name and execution will be switched to use the new connection that has been
- created. The previous connection will be held as it is in its current state, and will not be closed.</para>
+ the integration server at the same time. This is possible because AdminShell supports a feature called named
+ connections.</para>
+ <para>Every time a connection is made, the connection has an explicit or an implicitly assigned name.
+ If another connect command is executed then a new
+ connection is made with a unique name and execution will be switched to use the new connection.
+ The previous connection will be held as it is in its current state, and will not be closed.</para>
<para />
<para>In the interactive mode the name of the connection can found in the command prompt. Also, you could
use the following command in the interactive and script mode to find out the current connection's name</para>
<programlisting><![CDATA[
-name = currentConnectionName();
+name = getConnectionName();
]]></programlisting>
- <para>Knowing the names of the connection that user is working with is important, as this would enable
- user to switch the active connection that they have currently working with another connection they have
- previously made. To switch the active connection, use the following command and supply the name of the
- connection to be used</para>
+ <para>Knowing the names of the connection that user is working with is important to switch the active connection to a previous connection.
+ To switch the active connection, use the following command and supply the name of the connection to be used</para>
<para />
<programlisting><![CDATA[
-useConnection(name);
+useConnection("name");
]]></programlisting>
<para>If user supplies the same name as the active connection as they are currently participating in, then
- this operation will simply return with out any modifications. There is no limitation as to how many
- simultaneous connections that user can maintain, this is up to the script developer.</para>
+ this operation will simply return with out any modifications. There is no limitation the number of
+ simultaneous connections.</para>
<para />
<para>The following shows an example of using and switching between two connections.</para>
<programlisting><![CDATA[
// creates a connection
-connect();
+connectAsAdmin();
//capture the connection name
-conn1 = currentConnectionName();
+conn1 = getConnectionName();
-// run a SQL command using "conn1"
-select * from table;
+deployVDB("file.vdb")
// creates a second connection
-connect();
+connectAsAdmin();
-conn2 = currentConnectionName();
+conn2 = getConnectionName();
-// runs a SQL command on the connection "conn2"
-select * from table;
-
+deployVDB("file.vdb")
+
// switch the connection to "conn1"
useConnection(conn1);
-// run the SQL command using connection "conn1"
-select * from table;
-
// close the connection in the "conn1"
-disconnect();
-
-// switch to "conn2"
-useConnection(conn2);
-disconnect();
-
-exit();
+disconnectAll();
]]></programlisting>
</sect1>
</chapter>
\ No newline at end of file
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/getting-started.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/getting-started.xml 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/getting-started.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,148 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="getting_started">
- <title>Getting Started with Admin Shell</title>
- <para>
- To learn the basics of BeanShell (<ulink url="http://beanshell.org/">http://beanshell.org</ulink>)
- take a look at their documents and tutorials on their website A copy of the BeanShell document is also can
- be found in the AdminShell installation directory. Learn how basic scripts can be written and get familiar with
- some commonly used commands.
- </para>
- <para>Note: BeanShell documentation provided is of version 1.3, which is taken as is from their website,
- for latest changes refer to BeanShell website. The BeanShell version 2.0b4 is currently being used in
- AdminShell.</para>
- <para>
- Basic knowledge of the Java programming language is required in order to effectively design and develop
- scripts using the AdminShell. To learn Java language find learning resources at
- <ulink url="http://java.sun.com/">http://java.sun.com</ulink>.
- </para>
- <para>You can learn about the Teiid administrative API either using “help()” command or find JavaDoc
- for in the installation directory.</para>
- <para>AdminShell is a specialized version of BeanShell with lots of pre-built libraries and scripts
- designed to be used with the Teiid system. AdminShell works in two different modes: interactive or script
- run mode.</para>
- <para>In interactive mode, user can invoke the tool and connect to a live Teiid system and issue any
- ad-hoc commands to control the system or issue a SQL query against connected virtual database and view the
- results. All the commands executed during interactive mode are automatically captured into a log file, more
- on this later in the document.</para>
- <para>In the script run mode, user can execute/play back previously developed scripts. This mode especially
- useful to automate any testing or to perform any repeated configurations/migrations changes to a Teiid
- system</para>
-
- <sect1>
- <title>Essential rules to follow in using AdminShell</title>
- <para>To use AdminShell successfully, there are some syntactical rules you should keep in mind.</para>
- <orderedlist>
- <listitem>
- <para>All the commands end with semi-colon [;]. Commands without any input parameters end with open
- and close parentheses '()' and semi-colon at the end. Example:</para>
- <programlisting><![CDATA[
- help();
- ]]></programlisting>
- </listitem>
- <listitem>
- <para>All commands are case sensitive. So, enter exactly as command is written.</para>
- </listitem>
- <listitem>
- <para>If a command requires input parameter(s), they should be declared inside "(" and ")" and if they
- are string based parameters then they should wrapped with double quotes. A command can have more than
- one parameter. Example:</para>
- <programlisting><![CDATA[
- cd("/home/johndoe");
+ <title>Getting Started with AdminShell</title>
+ <para>
+ To learn the basics of
+ <ulink url="http://groovy.codehaus.org/">Groovy</ulink>
+ take a look at their documents and tutorials on their website.
+ </para>
+ <para>
+ Basic knowledge of the Java programming language and types is required
+ in order to effectively design and develop
+ scripts using the AdminShell. To learn Java language find learning resources
+ at <ulink url="http://java.sun.com/">http://java.sun.com</ulink>.
+ </para>
+ <para>You can learn about the Teiid administrative API either using
+ “adminHelp()” function or find JavaDoc
+ for in the installation directory.</para>
+ <para>AdminShell is a specialized version of Groovy which works in
+ several different modes: interactive shell, console, or script
+ run mode.</para>
+ <para>In interactive shell mode (launched via adminshell), the user can invoke connect to a live
+ Teiid system and issue any
+ ad-hoc commands to control the system. The interactive buffer can be used to
+ develop a scipt and the interactive session input and output can be
+ captured into a log file, more
+ on this later in the document.</para>
+ <para>In console mode (lanched via adminconsole), the user can develop and run scripts using a graphical text editor that supports syntax highlighting.</para>
+ <para>In the script run mode, the user can execute/play back previously
+ developed scripts. This mode especially
+ useful to automate any testing or to perform any repeated
+ configurations/migrations changes to a Teiid
+ system</para>
+ <sect1>
+ <title>Essential rules to follow in using AdminShell</title>
+ <para>To use AdminShell successfully, there are some basic syntactical rules
+ you should keep in mind.</para>
+ <orderedlist>
+ <listitem>
+ <para>In interactive mode, most commands (as seen by the help command) are used to control shell behavior and are not general Groovy scripting constructs. Admin methods will typically be called using functional notation:</para>
+ <programlisting><![CDATA[
+ connectAsAdmin()
]]></programlisting>
- </listitem>
- <listitem>
- <para>Any other Java program can be invoked from script, if the required Java class libraries are
- already in class path. Import the required classes and instantiate the class to execute. Example:
+ </listitem>
+ <listitem>
+ <para>All commands and functions are case sensitive.</para>
+ </listitem>
+ <listitem>
+ <para>An ending semicolon is optional for Groovy statements.</para>
+ </listitem>
+ <listitem>
+ <para>If a function requires input parameter(s), they should be
+ declared inside "(" and ")". A function may have more than
+ one parameter. String parameters can be wrapped in double or single quotes. Example:</para>
+ <programlisting><![CDATA[
+ connectAsAdmin("mm://localhost:34413", "user", "password")
+ ]]></programlisting>
+ </listitem>
+ <listitem>
+ <para>Other Java methods and classes can be used from your scripts, if the
+ required Java class libraries are already in class path. You may place additional jars in the
+ lib directory to have be automatically part of the class path. An example showing an import:
</para>
- <programlisting><![CDATA[
- import java.sql.*;
- clazz = new MyClass();
- clazz.doSomething();
+ <programlisting><![CDATA[
+ import my.package.*;
+ myObject = new MyClass();
+ myObject.doSomething();
]]></programlisting>
- </listitem>
- <listitem>
- <para>
- Take a look at a variety of commands available in Bean Shell to be used along with your scripts. Some
- of the common ones you can find at
- <ulink url="http://beanshell.org/manual/bshmanual.html#Useful_BeanShell_Commands">http://beanshell.org/manual/bshmanual.html#Useful_BeanShell_Commands
- </ulink>
- </para>
- </listitem>
- <listitem>
- <para>You can write and publish your own scripts. See How to write your own scripts?</para>
- <para />
- </listitem>
- </orderedlist>
- <para>To execute the commands in interactive mode you enter them first and press enter to execute, then
- enter next command, so on.</para>
- <para>To exit the tool in the interactive mode, first disconnect if you are connected to the Teiid
- system by executing “disconnect();” then execute "exit();". In the script mode, when execution of the
- script finishes the tool will exit automatically, however you still have to disconnect from Teiid
- system in the script.</para>
- <para>Note: If SSL is turned on the Teiid server, you would need to supply the correct certificates
- for connection. Edit the command file used to execute the AdminShell and make sure correct trust store is
- defined in the path.</para>
- </sect1>
- <sect1>
- <title>Basic commands to get started</title>
- <para>The list below contains some common commands used in AdminShell. The best way to learn scripting in the
- AdminShell is to read the scripts in "samples" directory in the AdminShell kit's installation directory, and
- experiment your own scripts using a developer instance of Teiid System.</para>
- <programlisting><![CDATA[
-print("xxx"); // print something to console
+ </listitem>
+ </orderedlist>
+ <para>To execute the commands and arbitrary script in interactive mode you enter them first
+ and press enter to execute, then
+ enter the next line, so on.</para>
+ <para>To exit the tool in the interactive mode, first disconnect if
+ you are connected to the Teiid
+ system by executing “disconnect();” then type "exit". In the script
+ mode, when execution of the
+ script finishes the tool will exit automatically, however you still have to
+ disconnect from Teiid
+ system in the script.</para>
+ <para>Note: If SSL is turned on the Teiid server, you would need to
+ supply the correct certificates for the connection.
+ </para>
+ </sect1>
+ <sect1>
+ <title>Basic commands to get started</title>
+ <para>The list below contains some common commands used in AdminShell.</para>
+ <programlisting><![CDATA[
+println "xxx"; // print something to console
-help(); // shows all the available admin commands;
+adminHelp(); // shows all the available admin commands;
-connect(); // connect using connection.properties file
+sql = connect(); // get an extended Groovy Sql connection using connection.properties file
-connect(<URL>); // connect to Teiid using the supplied URL
+sql.execute(<SQL>); // run any SQL command.
-connectAsAdmin(<url>); // connect as admin; no need have the vdb name. SQL commands will not work under this connection
+connectAsAdmin(); // connect as admin; no need have the vdb name. SQL commands will not work under this connection
-execute(<SQL>); // run any SQL command. Note in interactive mode you can directly specify SQL on command line
+println getConnectionName(); // returns the current connection name
-currentConnectionName(); // returns the current connection name
-
useConnection(<connection name>); // switches to using the given connection settings
disconnect(); // disconnects the current connection in the context
-
-exit(); // exit the shell
]]></programlisting>
- </sect1>
- <sect1>
- <title>"help" command</title>
- <para>This below command lists all the available administrative API commands in the AdminShell. Please note
- that none of the BeanShell commands or custom commands will be shown in this list. Documentation is only
- source for reviewing those commands presently.</para>
- <programlisting><![CDATA[
- admin $ help();
+ </sect1>
+ <sect1>
+ <title>Help</title>
+ <para>The adminHelp() methods lists all the available administrative API
+ methods in the AdminShell. Please note
+ that none of the Groovy Shell commands or other available function calls will be shown in
+ this list</para>
+ <programlisting><![CDATA[
+adminHelp();
]]></programlisting>
- <para>To get a specific definition about a command and it's required input parameters , use the below form
- of help. The example shown will show detailed JavaDoc description about "addVDB" method.</para>
- <programlisting><![CDATA[
-admin $ help("deployVDB");
- /**
- * Deploy a {@link VDB} file.
- * @param name Name of the VDB file to save under
- * @param VDB VDB.
- * @throws AdminException
- *
- * @return the {@link VDB} representing the current property values and runtime state.
- */
-public void deployVDB(String fileName, InputStream vdb)
+ <para>To get a specific definition about a method and it's required
+ input parameters, use adminHelp("method")</para>
+ <programlisting><![CDATA[
+adminHelp("deployVDB");
+
+/*
+ *Deploy a VDB from file
+ */
+void deployVDB(
+ String /* file name */)
+ throws AdminException
+ throws FileNotFoundException
]]></programlisting>
- <para />
- <para>If not sure about exact command, and to narrow the list available commands, help can be used in the
- following form, note the “*” at the end</para>
- <programlisting><![CDATA[
-admin $ help(“get*”);
- ]]></programlisting>
- <para>This will list all the commands available that begin with “get”, for example “getConnectionFactories,
- getVDBs” etc.</para>
- <para>For every administrative API call, there is corresponding command in AdminShell. For a reference to
- full administrative API, please look at “documents” sections in the installation directory.</para>
- </sect1>
-
+ <para />
+ <para>The sqlHelp() methods lists all Sql extension
+ methods.</para>
+ <programlisting><![CDATA[
+sqlHelp();
+ ]]></programlisting>
+ <para>To get a specific definition about a method and it's required
+ input parameters, use sqlHelp("method")</para>
+ <para />
+ </sect1>
</chapter>
\ No newline at end of file
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,56 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="introduction">
- <title>Introduction Teiid Admin Shell</title>
- <sect1>
- <title>Introduction to AdminShell</title>
- <para>
- Admin Shell is a script based programming environment that enables user to access, monitor and control Teiid
- Server. This tool is built using programming language called BeanShell (
- <ulink url="http://beanshell.org/">http://beanshell.org</ulink>
- ). Admin Shell can be used in ad-hoc scripting, or to run pre-defined scripts. It is not a graphical tool; it's a
- command line driven environment.
- </para>
- <orderedlist>
- <listitem>
- <para>It is a fully functional programming environment with resource flow control and exception
- management. Under the covers it is a fully functional Java programming environment.</para>
- </listitem>
- <listitem>
- <para>It is an Administrative tool. The user can connect to a running Teiid Server and invoke any of
- the Admin API methods, such as "addVDB" or "stopConnector", to control Teiid System just like using
- Console. Since, this is script driven, these tasks can be automated and re-run at a later time.</para>
- </listitem>
- <listitem>
- <para>It is a data access tool. The user can connect to a VDB, issue any SQL commands, and view the
- results of the query.</para>
- </listitem>
- <listitem>
- <para>It is a migration tool. This can be used to develop scripts like moving the Virtual Databases
- (VDB), Connection Factories, and Configuration from one development environment to another. This will
- enable users to test and automate their migration scripts before production deployments.</para>
- </listitem>
- <listitem>
- <para>
- It is a testing tool. The JUnit (
- <ulink url="http://junit.org/">http://junit.org</ulink>
- ) test framework is built into it. User can write regression tests for checking system health, or data
- integrity that can be used to validate a system functionality automatically instead of manual
- verification by QA personnel.
- </para>
- </listitem>
- </orderedlist>
- <sect2>
- <title>Where can you find Admin Shell?</title>
- <para>Admin Shell is distributed along with other Teiid downloads under "teiid-{version}-adminshell-dist.zip" name. Download and unzip this
- file to any directory. Once you have unzipped the file, in root directory
- you will find “adminshell” executable script to invoke the tool.</para>
- <para>Windows: Double click or execute "adminshell.cmd"</para>
- <para>*nix: Execute the "adminshell.sh" script</para>
- <para>to invoke Admin Shell. This will initialize the shell and present you with a prompt:</para>
- <programlisting><![CDATA[
- admin $
- ]]></programlisting>
- </sect2>
- </sect1>
+ <title>Introduction to Admin Tools</title>
+ <para>
+ AdminShell provides scripting based programming environments that enable user to access, monitor and control a Teiid
+ Server. The Shell and Console tools are built on ones provide by the Groovy (
+ <ulink url="http://groovy.codehaus.org/">http://groovy.codehaus.org/</ulink>
+ ) project. The AdminShell tools be used in ad-hoc scripting or to run pre-defined scripts.
+ </para>
+ <orderedlist>
+ <title>AdminShell features:</title>
+ <listitem>
+ <para>fully functional programming environment with resource flow control and exception
+ management. See <ulink url="http://groovy.codehaus.org/">Groovy</ulink> docs for the full power of the language.</para>
+ </listitem>
+ <listitem>
+ <para>quick administrative tool. The user can connect to a running Teiid Server and invoke any of
+ the Admin API methods, such as "deployVDB" or "stopConnectionFactory", to control Teiid System.
+ Since this can be script driven, these tasks can be automated and re-run at a later time.</para>
+ </listitem>
+ <listitem>
+ <para>simplified data access tool. The user can connect to a VDB, issue any SQL commands, and view the
+ results of the query via <ulink url="http://groovy.codehaus.org/Database+features">Groovy Sql</ulink> extensions.</para>
+ </listitem>
+ <listitem>
+ <para>migration tool. This can be used to develop scripts like moving the Virtual Databases
+ (VDB), Connection Factories, and Configuration from one development environment to another. This will
+ enable users to test and automate their migration scripts before production deployments.</para>
+ </listitem>
+ <listitem>
+ <para>testing tool. The JUnit (
+ <ulink url="http://junit.org/">http://junit.org</ulink>
+ ) test framework is built in, see <ulink url="http://groovy.codehaus.org/Unit+Testing">Groovy Unit Tests</ulink>. User can write regression tests for checking system health, or data
+ integrity that can be used to validate a system functionality automatically instead of manual
+ verification by QA personnel.
+ </para>
+ </listitem>
+ </orderedlist>
+ <sect1>
+ <title>Where can you find AdminShell?</title>
+ <para>AdminShell is distributed along with other Teiid downloads under "teiid-{version}-adminshell-dist.zip" name. Download and unzip this
+ file to any directory. Once you have unzipped the file, in root directory
+ you will find "adminshell" and "adminconsole" executable scripts.</para>
+ <para>Windows: Double click or execute "adminshell.cmd"</para>
+ <para>*nix: Execute the "adminshell.sh" script</para>
+ </sect1>
</chapter>
\ No newline at end of file
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/working-with-scripts.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/working-with-scripts.xml 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/working-with-scripts.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -3,81 +3,49 @@
<chapter id="working_with_scripts">
<title>Working with Scripts</title>
<sect1>
- <title>How to write your own scripts</title>
- <para>Open up a text editor, and enter all the commands in a editor and save the file “.bsh” extension and
- place it in the distribution where Admin Shell tool can access it. Take a look at the “samples” directory for
- example scripts. For example:</para>
- <programlisting><![CDATA[
-// foo.bsh
-importCommands("commands");
-load("server");
-
-connect();
-execute("select * from pm1.g1");
-printResults();
-disconnect();
-exit();
- ]]></programlisting>
- <para>and execute this script file using instructions in Executing script file in non-interactive mode
- section.</para>
- <para>All script files that need to be executed in the non-interactive mode must have the following two
- lines at the beginning of the script file before execution. These two commands will load all the necessary
- libraries into the shell before execution.</para>
- <programlisting><![CDATA[
-importCommands("commands");
-load("server");
- ]]></programlisting>
- </sect1>
- <sect1>
<title>Executing script file in interactive mode</title>
- <para>To execute a script file "foo.bsh" in a directory "some/directory" in interactive mode, execute as
+ <para>To execute a script file "foo.groovy" in a directory "some/directory" in the shell tool, execute as
following</para>
<programlisting><![CDATA[
-admin $ source ("some/directory/foo.bsh");
+. some/directory/foo.groovy
]]></programlisting>
- <para>"foo.bsh" is read into current context of the shell as if you typed in the whole document. If
+ <para>"foo.groovy" is read into current context of the shell as if you typed in the whole document. If
your script only contained method calls, you can explicitly invoke the call to execute.</para>
+ <para>Full execute syntax may also be used, and is required outside of the Shell tool:</para>
+ <programlisting><![CDATA[
+evaluate("some/directory/foo.groovy" as File)
+ ]]></programlisting>
</sect1>
<sect1>
<title>Executing script file in non-interactive mode</title>
- <para>To execute a script file "foo.bsh" in a directory "some/directory" in non-interactive mode, execute as
+ <para>To execute a script file "foo.groovy" in a directory "some/directory" in non-interactive mode, execute as
following command at the command prompt</para>
<programlisting><![CDATA[
-admin.sh some/directory/foo.bsh
+adminshell.sh . some/directory/foo.groovy
]]></programlisting>
- <para>Note that, in the script mode it is NOT possible to pass in the command line parameters as</para>
+ <para>Parameters can be passed in as Java System properties. For example</para>
<programlisting><![CDATA[
-admin.sh some/directory/foo.bsh One Two
+adminshell.sh -Dparam=value . some/directory/foo.groovy
]]></programlisting>
- <para>The parameters can be passed in as Java system properties. For example</para>
+ <para>Inside the script file, you can access these properties using System.getProperty</para>
<programlisting><![CDATA[
-admin.sh some/directory/foo.bsh input1=One input2=Two
+value = System.getProperty(“param”); // will return "value"
]]></programlisting>
- <para>Inside the script file, you can access these properties using Java system property semantics</para>
- <programlisting><![CDATA[
-value = System.getProperty(“input1”); // will return "One"
- ]]></programlisting>
</sect1>
<sect1>
<title>Log File and Recorded Script file</title>
- <para>During the interactive mode, all the commands executed by the user are recorded in
- "adminscript.txt" file. This file can be found in the root installation directory. This file later can serve
- as reference to commands that are executed or will aid in converting commands executed in the interactive
- mode into a standalone script, that can be run at a later time.</para>
+ <para>During the interactive mode, input is recorded in a history file. This file can be accessed via the up arrow in the interactive shell.
+ </para>
<para>User can also capture the commands entered during a interactive session to their own script file by
using “startRecording” and “stopRecording” commands. For example,</para>
<para />
<programlisting><![CDATA[
-admin $ startRecording (“directory/filename.bsh”);
-admin $ <commands..>
-admin $ stopRecording()
+record start directory/filename.txt
+<commands and script ..>
+record stop
]]></programlisting>
- <para>in this case all the commands executed after the “startRecording” and before the “stopRecording” are
- captured in the “directory/filename.bsh” file. This gives the user an option to capture only certain portions
- of the interactive session tat they are interested in and ignore the rest of it.</para>
+ <para>All input and output between the start and stop are captured in the “directory/filename.txt” file.
+ This gives the user an option to capture only certain portions of the interactive session and to later refine a script out of recorded file.</para>
<para />
- <para>Also note that all the output during the interactive mode is sent to "adminshell.log" file. In the
- script mode, no such files are created. In script mode, user can capture the standard out and redirect to a
- file if they need the log file.</para>
</sect1>
</chapter>
\ No newline at end of file
Deleted: trunk/documentation/admin-guide/src/main/docbook/en-US/content/writing-tests.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/writing-tests.xml 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/writing-tests.xml 2010-04-16 21:15:33 UTC (rev 2061)
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-<chapter id="writing_tests">
- <title>Writing Tests using AdminShell</title>
- <para>
- <ulink url="http://junit.org">JUnit</ulink>
- testing framework is integrated into the AdminShell, so you can write regression tests and run tests in the JUnit
- style. To write a test,
- <orderedlist>
- <listitem>
- <para>start a method name which begins with "testxxxx()"</para>
- </listitem>
- <listitem>
- <para>use method body to write actual test. Method body can contain any Admin Shell based script using Admin
- API and JDBC commands</para>
- </listitem>
- <listitem>
- <para>finally use “assertions” to validate results.</para>
- </listitem>
- </orderedlist>
- For example:
- </para>
- <programlisting><![CDATA[
-testCountRows(){
- connect();
- execute("select * from table");
-
- // make sure you have 100 rows
- assertRowCount(100);
-
- disconnect();
-}
-
-testResults(){
- connect();
- execute("select * from table");
-
- // defines the all the values you are expecting
- String[] expected ={
- {"col1[string]", "col2[int]"},
- {"VALUE1", "100"}
- ..
- };
-
- // make sure your results match to expected
- assertResultSet(expected);
- disconnect();
-}
-
-// now actually run the above defined tests
-runTests();
- ]]></programlisting>
- <para>In the above example, “testCountRows”, made connection to a Teiid system and issued a query and made
- sure that certain table has required number of rows. Where as “testResults” asserted that results match to a
- certain set of pre-built results.</para>
- <para>
- Note the “runTests()” call at the end of the script, as this is the call which triggers the execution of the
- tests defined in the script. There are various types asserts you can use in your scripts, for the all the
- available assert types please refer to
- <link linkend="assertion_list">Assertion Library</link>
- </para>
-</chapter>
\ No newline at end of file
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractQueryTest.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractQueryTest.java 2010-04-16 21:07:02 UTC (rev 2060)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractQueryTest.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -41,9 +41,7 @@
import java.sql.Statement;
import org.junit.After;
-import org.teiid.script.io.MetadataReader;
import org.teiid.script.io.ResultSetReader;
-import org.teiid.script.io.StringArrayReader;
Copied: trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataReader.java (from rev 2057, trunk/adminshell/src/main/java/org/teiid/script/io/MetadataReader.java)
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataReader.java (rev 0)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/MetadataReader.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.io.IOException;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+
+import org.teiid.script.io.StringLineReader;
+
+
+public class MetadataReader extends StringLineReader {
+
+ ResultSetMetaData source;
+ String delimiter = " "; //$NON-NLS-1$
+
+ boolean firsttime = true;
+ int currentColumn = 0;
+
+ public MetadataReader(ResultSetMetaData metadata, String delimiter) {
+ this.source = metadata;
+ this.delimiter = delimiter;
+ }
+
+ @Override
+ protected String nextLine() throws IOException {
+ if (firsttime) {
+ this.firsttime = false;
+ return firstLine();
+ }
+
+ try {
+ int count = this.source.getColumnCount();
+ if (this.currentColumn < count) {
+ this.currentColumn++;
+ return getNextRow();
+ }
+ } catch (SQLException e) {
+ throw new IOException(e.getMessage());
+ }
+ return null;
+ }
+
+ String firstLine() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("ColumnName").append(delimiter); //$NON-NLS-1$
+ sb.append("ColumnType").append(delimiter); //$NON-NLS-1$
+ sb.append("ColumnTypeName").append(delimiter); //$NON-NLS-1$
+ sb.append("ColumnClassName").append(delimiter); //$NON-NLS-1$
+ sb.append("isNullable").append(delimiter); //$NON-NLS-1$
+ sb.append("TableName").append(delimiter); //$NON-NLS-1$
+ sb.append("SchemaName").append(delimiter); //$NON-NLS-1$
+ sb.append("CatalogName").append(delimiter); //$NON-NLS-1$
+ sb.append("\n"); //$NON-NLS-1$
+ return sb.toString();
+ }
+
+ String getNextRow() throws SQLException {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append(source.getColumnName(currentColumn)).append(delimiter);
+ sb.append(source.getColumnType(currentColumn)).append(delimiter);
+ sb.append(source.getColumnTypeName(currentColumn)).append(delimiter);
+ sb.append(source.getColumnClassName(currentColumn)).append(delimiter);
+ sb.append(source.isNullable(currentColumn)).append(delimiter);
+ sb.append(source.getTableName(currentColumn)).append(delimiter);
+ sb.append(source.getSchemaName(currentColumn)).append(delimiter);
+ sb.append(source.getCatalogName(currentColumn)).append(delimiter);
+ sb.append("\n"); //$NON-NLS-1$
+
+ return sb.toString();
+ }
+}
Copied: trunk/test-integration/common/src/test/java/org/teiid/jdbc/StringArrayReader.java (from rev 2057, trunk/adminshell/src/main/java/org/teiid/script/io/StringArrayReader.java)
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/StringArrayReader.java (rev 0)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/StringArrayReader.java 2010-04-16 21:15:33 UTC (rev 2061)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.io.IOException;
+
+import org.teiid.script.io.StringLineReader;
+
+
+/**
+ * Converts a String Array object into a Reader object.
+ */
+public class StringArrayReader extends StringLineReader {
+ String[] source = null;
+ int index = 0;
+
+ public StringArrayReader(String[] src) {
+ this.source = src;
+ }
+
+ protected String nextLine() throws IOException {
+ if (index < this.source.length) {
+ return this.source[index++]+"\n"; //$NON-NLS-1$
+ }
+ return null;
+ }
+}
14 years, 8 months
teiid SVN: r2060 - in trunk: jboss-integration/src/main/java/org/teiid/adminapi/jboss and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-04-16 17:07:02 -0400 (Fri, 16 Apr 2010)
New Revision: 2060
Modified:
trunk/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
Log:
TEIID-1051: Adding .RAR extension to the connector names, so that there is no extra logic needs to be done when user looking at the connection factory property.
Modified: trunk/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
===================================================================
--- trunk/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml 2010-04-15 20:03:04 UTC (rev 2059)
+++ trunk/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml 2010-04-16 21:07:02 UTC (rev 2060)
@@ -24,7 +24,7 @@
<factory bean="DSDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-jdbc-${project.version}</parameter>
+ <parameter class="java.lang.String">connector-jdbc-${project.version}.rar</parameter>
<parameter class="java.lang.String">Teiid JDBC Connector</parameter>
</constructor>
</bean>
@@ -38,7 +38,7 @@
<factory bean="DSDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-ldap-${project.version}</parameter>
+ <parameter class="java.lang.String">connector-ldap-${project.version}.rar</parameter>
<parameter class="java.lang.String">Teiid LDAP Connector</parameter>
</constructor>
</bean>
@@ -52,7 +52,7 @@
<factory bean="DSDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-loopback-${project.version}</parameter>
+ <parameter class="java.lang.String">connector-loopback-${project.version}.rar</parameter>
<parameter class="java.lang.String">Teiid Loopback Connector</parameter>
</constructor>
</bean>
@@ -66,7 +66,7 @@
<factory bean="DSDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-salesforce-${project.version}</parameter>
+ <parameter class="java.lang.String">connector-salesforce-${project.version}.rar</parameter>
<parameter class="java.lang.String">Teiid Salesforce Connector</parameter>
</constructor>
</bean>
@@ -80,7 +80,7 @@
<factory bean="DSDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-text-${project.version}</parameter>
+ <parameter class="java.lang.String">connector-text-${project.version}.rar</parameter>
<parameter class="java.lang.String">Teiid Text Connector</parameter>
</constructor>
</bean>
@@ -94,7 +94,7 @@
<factory bean="DSDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-xmlsource-file-${project.version}</parameter>
+ <parameter class="java.lang.String">connector-xmlsource-file-${project.version}.rar</parameter>
<parameter class="java.lang.String">Teiid XML File Connector</parameter>
</constructor>
</bean>
@@ -108,7 +108,7 @@
<factory bean="DSDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-xmlsource-soap-${project.version}</parameter>
+ <parameter class="java.lang.String">connector-xmlsource-soap-${project.version}.rar</parameter>
<parameter class="java.lang.String">Teiid XML SOAP Connector</parameter>
</constructor>
</bean>
@@ -122,7 +122,7 @@
<factory bean="DSDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
<parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-xml-http-${project.version}</parameter>
+ <parameter class="java.lang.String">connector-xml-http-${project.version}.rar</parameter>
<parameter class="java.lang.String">Teiid XML HTTP Connector</parameter>
</constructor>
</bean>
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-04-15 20:03:04 UTC (rev 2059)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-04-16 21:07:02 UTC (rev 2060)
@@ -96,8 +96,9 @@
import com.metamatrix.core.util.ObjectConverterUtil;
public class Admin extends TeiidAdmin {
+ private static final String CONNECTOR_PREFIX = "connector-";
+ private static final String RAR = ".rar"; //$NON-NLS-1$
private static final ProfileKey DEFAULT_PROFILE_KEY = new ProfileKey(ProfileKey.DEFAULT);
-
private static final String XA_DATA_SOURCE_TEMPLATE = "XADataSourceTemplate"; //$NON-NLS-1$
private static final String LOCAL_DATA_SOURCE_TEMPLATE = "LocalTxDataSourceTemplateInfo"; //$NON-NLS-1$
private static final long serialVersionUID = 7081309086056911304L;
@@ -195,7 +196,7 @@
return exportJCAConnection(deployedName, mc, type);
}
}
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_not_found", deployedName)); //$NON-NLS-1$
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("connectionfactory_not_found", deployedName)); //$NON-NLS-1$
} catch (Exception e) {
throw new AdminComponentException(e);
}
@@ -443,8 +444,8 @@
HashSet<String> matched = new HashSet<String>();
for(ManagedDeployment md:rarFiles) {
String name = md.getSimpleName();
- if (name.startsWith("connector-") && name.endsWith(".rar")) {//$NON-NLS-1$ //$NON-NLS-2$
- matched.add(name.substring(0, name.length()-4));
+ if (name.startsWith(CONNECTOR_PREFIX) && name.endsWith(RAR)) {
+ matched.add(md.getSimpleName());
}
}
return matched;
@@ -722,21 +723,17 @@
}
@Override
- public void addConnector(String connectorName, InputStream rar) throws AdminException{
- if (!connectorName.startsWith("connector-")) {//$NON-NLS-1$
+ public void addConnector(String connectorName, InputStream contents) throws AdminException{
+ if (!connectorName.startsWith(CONNECTOR_PREFIX) || !connectorName.endsWith(RAR)) {//$NON-NLS-1$
throw new AdminProcessingException(IntegrationPlugin.Util.getString("bad_connector_type_name")); //$NON-NLS-1$
}
-
- if (!connectorName.endsWith(".rar")) {//$NON-NLS-1$
- connectorName = connectorName + ".rar";//$NON-NLS-1$
- }
-
+
String deployerName = getRarDeployerName(connectorName);
if (deployerName != null) {
- throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_type_exists", deployerName)); //$NON-NLS-1$
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_type_exists", connectorName)); //$NON-NLS-1$
}
- ManagedUtil.deployArchive(getDeploymentManager(), connectorName, rar, false);
+ ManagedUtil.deployArchive(getDeploymentManager(), connectorName, contents, false);
//also need to add a template for the properties
try {
@@ -751,29 +748,32 @@
@Override
public void deleteConnector(String connectorName) throws AdminException {
- if (!connectorName.endsWith(".rar")) {//$NON-NLS-1$
- connectorName = connectorName + ".rar";//$NON-NLS-1$
+ if (!connectorName.startsWith(CONNECTOR_PREFIX) || !connectorName.endsWith(RAR)) {//$NON-NLS-1$
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("bad_connector_type_name")); //$NON-NLS-1$
}
+
String deployerName = getRarDeployerName(connectorName);
- if (deployerName != null) {
- //also need to delete template for the properties
- String connectorNameWithoutExt = connectorName.substring(0, connectorName.length()-4);
- ManagedUtil.removeArchive(getDeploymentManager(), connectorNameWithoutExt+"-template.jar");//$NON-NLS-1$
-
- ManagedUtil.removeArchive(getDeploymentManager(), deployerName);
+ if (deployerName == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_not_found", connectorName));
}
+
+ //also need to delete template for the properties
+ String connectorNameWithoutExt = connectorName.substring(0, connectorName.length()-4);
+ ManagedUtil.removeArchive(getDeploymentManager(), connectorNameWithoutExt+"-template.jar");//$NON-NLS-1$
+ ManagedUtil.removeArchive(getDeploymentManager(), deployerName);
}
@Override
public InputStream exportConnector(String connectorName) throws AdminException {
- if (!connectorName.endsWith(".rar")) {//$NON-NLS-1$
- connectorName = connectorName + ".rar";//$NON-NLS-1$
+ if (!connectorName.startsWith(CONNECTOR_PREFIX) || !connectorName.endsWith(RAR)) {//$NON-NLS-1$
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("bad_connector_type_name")); //$NON-NLS-1$
}
+
String deployerName = getRarDeployerName(connectorName);
- if (deployerName != null) {
- return exportDeployment(deployerName);
+ if (deployerName == null) {
+ throw new AdminProcessingException(IntegrationPlugin.Util.getString("connector_not_found", connectorName));
}
- return null;
+ return exportDeployment(deployerName);
}
@Override
@@ -1003,7 +1003,7 @@
" <factory bean=\"DSDeploymentTemplateInfoFactory\"/>\n" + //$NON-NLS-1$
" <parameter class=\"java.lang.Class\">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>\n" + //$NON-NLS-1$
" <parameter class=\"java.lang.Class\">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>\n" + //$NON-NLS-1$
- " <parameter class=\"java.lang.String\">${name}</parameter>\n" + //$NON-NLS-1$
+ " <parameter class=\"java.lang.String\">${name}.rar</parameter>\n" + //$NON-NLS-1$
" <parameter class=\"java.lang.String\">${name}</parameter>\n"+ //$NON-NLS-1$
" </constructor>\n" + //$NON-NLS-1$
"</bean>\n"+ //$NON-NLS-1$
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2010-04-15 20:03:04 UTC (rev 2059)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2010-04-16 21:07:02 UTC (rev 2060)
@@ -30,14 +30,15 @@
failed_to_start_connector=Failed to start Connection factory = {0}
failed_to_stop_connector=Failed to start Connection factory = {0}
bad_vdb_extension=The extension of the file name must be either ".vdb" for designer vdb or "xxx-vdb.xml" for dynamic VDBs
-bad_connector_type_name="Teiid connector names must start with \"connector-\""
+bad_connector_type_name=Teiid connector names must start with \"connector-\" and end with ".rar" extension.
connector_type_exists=Connector with name:"{0}" already exists!
connector_type_not_found=Connector template "{0}" not found in the configuration.
vdb_not_found=VDB with name "{0}" version "{1}" not found in configuration
model_not_found=Model name "{0}" not found in the VDB with name "{1}" version "{2}"
policy_not_found=Policy name "{0}" not found in the VDB with name "{1}" version "{2}"
-connector_not_found=Connection factory {0} not found in the configuration.
+connectionfactory_not_found=Connection factory {0} not found in the configuration.
datasource_not_found=Datasource {0} not found in the configuration.
+connector_not_found=Connector {0} not found in the configuration.
sourcename_not_found=No source name {0} found in the model: {1}.{2}.{3}
connector_started= Teiid connector {0} started
Modified: trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-04-15 20:03:04 UTC (rev 2059)
+++ trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-04-16 21:07:02 UTC (rev 2060)
@@ -306,16 +306,16 @@
}
@Test
- public void testTemplate() throws Exception{
+ public void testConnectorAddDelete() throws Exception{
File f = new File(UnitTestUtil.getTestDataPath()+"/connector-loopback.rar"); //$NON-NLS-1$
FileInputStream fis = new FileInputStream(f);
- admin.addConnector("connector-loopy", fis); //$NON-NLS-1$
+ admin.addConnector("connector-loopy.rar", fis); //$NON-NLS-1$
fis.close();
Set<String> names = admin.getConnectorNames();
- assertTrue(names.contains("connector-loopy")); //$NON-NLS-1$
+ assertTrue(names.contains("connector-loopy.rar")); //$NON-NLS-1$
- admin.deleteConnector("connector-loopy"); //$NON-NLS-1$
+ admin.deleteConnector("connector-loopy.rar"); //$NON-NLS-1$
names = admin.getConnectorNames();
//assertTrue(!names.contains("connector-loopy")); //$NON-NLS-1$
14 years, 8 months
teiid SVN: r2059 - in trunk: build/kit-jboss-container/deploy/teiid and 6 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-04-15 16:03:04 -0400 (Thu, 15 Apr 2010)
New Revision: 2059
Removed:
trunk/common-core/src/main/java/com/metamatrix/common/util/NetUtils.java
trunk/common-core/src/test/java/com/metamatrix/common/util/TestNetUtils.java
Modified:
trunk/adminshell/src/main/resources/scripts/adminapi.bsh
trunk/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml
trunk/client/src/main/java/org/teiid/net/HostInfo.java
trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java
Log:
TEIID-1047: Host name resolution now match that of the JBoss AS. If user specifies "-b" option with JBoss, then Teiid will use that address. Otherwise "InetAddress.getLocalAddress()" is used. User can override JBoss bind address behavior by specifying the address in the Teiid configuration.
Modified: trunk/adminshell/src/main/resources/scripts/adminapi.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/adminapi.bsh 2010-04-15 15:56:33 UTC (rev 2058)
+++ trunk/adminshell/src/main/resources/scripts/adminapi.bsh 2010-04-15 20:03:04 UTC (rev 2059)
@@ -1,5 +1,5 @@
import org.teiid.adminapi.*;
-
+import org.teiid.adminapi.Admin.DataSourceType;
import com.metamatrix.core.util.ObjectConverterUtil;
Modified: trunk/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-04-15 15:56:33 UTC (rev 2058)
+++ trunk/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-04-15 20:03:04 UTC (rev 2059)
@@ -73,8 +73,6 @@
<property name="securityHelper"><inject bean="SecurityHelper"/></property>
<property name="VDBRepository"><inject bean="VDBRepository"/></property>
- <!-- Name of the process that uniquely identifies this process -->
- <property name="processName">localhost</property>
<!-- Process pool maximum thread count. (default 32) Increase this value if your load includes a large number of XQueries or if the system's available processors is larger than 8. -->
<property name="maxThreads">32</property>
<!-- Query processor time slice, in milliseconds. (default 2000) -->
@@ -102,7 +100,7 @@
<!-- JDBC Socket connection properties (SSL see below) -->
<bean name="JdbcSocketConfiguration" class="org.teiid.transport.SocketConfiguration">
<property name="enabled">true</property>
- <property name="bindAddress">localhost</property>
+ <!-- property name="bindAddress">localhost</property-->
<property name="portNumber">31000</property>
<!-- Max number of threads dedicated to initial request processing (default 15) -->
<property name="maxSocketThreads">15</property>
@@ -130,7 +128,7 @@
<!-- Admin Socket connection settings (SSL see below) -->
<bean name="AdminSocketConfiguration" class="org.teiid.transport.SocketConfiguration">
<property name="enabled">true</property>
- <property name="bindAddress">localhost</property>
+ <!-- property name="bindAddress">localhost</property-->
<property name="portNumber">31443</property>
<!-- Max number of threads dedicated to Admin and initial request processing (default 4) -->
<property name="maxSocketThreads">4</property>
Modified: trunk/client/src/main/java/org/teiid/net/HostInfo.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/HostInfo.java 2010-04-15 15:56:33 UTC (rev 2058)
+++ trunk/client/src/main/java/org/teiid/net/HostInfo.java 2010-04-15 20:03:04 UTC (rev 2059)
@@ -25,7 +25,6 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
-import com.metamatrix.common.util.NetUtils;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.core.util.HashCodeUtil;
@@ -43,7 +42,7 @@
if (inetAddress != null) {
return inetAddress;
}
- return NetUtils.resolveHostByName(hostName);
+ return InetAddress.getByName(this.hostName);
}
public HostInfo (String host, int port) {
@@ -53,8 +52,8 @@
//only cache inetaddresses if they represent the ip.
try {
- InetAddress addr = NetUtils.resolveHostByName(hostName);
- if (addr.getHostAddress().equalsIgnoreCase(hostName)) {
+ InetAddress addr = InetAddress.getByName(this.hostName);
+ if (addr.getHostAddress().equalsIgnoreCase(this.hostName)) {
this.inetAddress = addr;
}
} catch (UnknownHostException e) {
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java 2010-04-15 15:56:33 UTC (rev 2058)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java 2010-04-15 20:03:04 UTC (rev 2059)
@@ -45,10 +45,9 @@
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.HostInfo;
-import org.teiid.net.TeiidURL;
import org.teiid.net.ServerConnectionFactory;
+import org.teiid.net.TeiidURL;
-import com.metamatrix.common.util.NetUtils;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.util.ReflectionHelper;
@@ -264,7 +263,7 @@
static void updateConnectionProperties(Properties connectionProperties) {
try {
- InetAddress addr = NetUtils.getInstance().getInetAddress();
+ InetAddress addr = InetAddress.getLocalHost();
connectionProperties.put(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS, addr.getHostAddress());
connectionProperties.put(TeiidURL.CONNECTION.CLIENT_HOSTNAME, addr.getCanonicalHostName());
} catch (UnknownHostException err1) {
Deleted: trunk/common-core/src/main/java/com/metamatrix/common/util/NetUtils.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/util/NetUtils.java 2010-04-15 15:56:33 UTC (rev 2058)
+++ trunk/common-core/src/main/java/com/metamatrix/common/util/NetUtils.java 2010-04-15 20:03:04 UTC (rev 2059)
@@ -1,172 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.util;
-
-import java.io.IOException;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-
-public class NetUtils {
- private InetAddress inetAddress;
-
- private static NetUtils INSTANCE = new NetUtils();
-
- public static NetUtils getInstance() {
- return INSTANCE;
- }
-
- public InetAddress getInetAddress() throws UnknownHostException {
- resolveHostName();
- return this.inetAddress;
- }
-
-
- /**
- * Resolves the given host name into InetAddress; if host name can not be resolved then it will
- * throw {@link UnknownHostException}
- * @param hostName
- * @return
- * @throws UnknownHostException
- */
- public static InetAddress resolveHostByName(String hostName) throws UnknownHostException {
- if( hostName.equalsIgnoreCase("localhost")) { //$NON-NLS-1$
- try {
- return getInstance().getInetAddress();
- } catch (UnknownHostException e) {
- }
- }
- return InetAddress.getByName(hostName);
- }
-
- /*
- * Dynamically resolving the host name should only be done when setupmm is being run
- * or when the vm initially starts up and the configuration Host has to be found based on that resolution.
- * After that, the {@link VMNaming} class should be used to obtain the logical and physical host addresses.
- */
- private synchronized void resolveHostName() throws UnknownHostException {
- UnknownHostException une = null;
-
- boolean preferIPv6=Boolean.getBoolean("java.net.preferIPv6Addresses");//$NON-NLS-1$
-
- // majority of the times we will find the address with this below call
- if (this.inetAddress == null) {
- try {
- InetAddress addr = InetAddress.getLocalHost();
- if(!addr.isLoopbackAddress()) {
- this.inetAddress = addr;
- }
- } catch(UnknownHostException e) {
- une=e;
- }
- }
-
- // see if you can find a non-loopback address, based on the preference
- if (this.inetAddress == null) {
- this.inetAddress = findAddress(preferIPv6, false);
- }
-
- // if no-addresses found so far then resort to IPv4 loopback address
- if (this.inetAddress == null) {
- this.inetAddress = findAddress(false, true);
- }
-
- if (this.inetAddress == null) {
- if (une != null) throw une;
- throw new UnknownHostException("failed to resolve the address for localhost"); //$NON-NLS-1$
- }
- }
-
-
-
- /**
- * Finds a InetAddress of the current host where the JVM is running, by querying NetworkInterfaces installed
- * and filters them by given preferences. It will return the first Address which UP and meets the criteria
- * @param preferIPv6
- * @param perferLoopback
- * @return null is returned if requested criteria is not met.
- * @throws UnknownHostException
- * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4665037 (Linux issue with resolving to loopback in the DHCP situations)
- */
- private InetAddress findAddress(boolean preferIPv6, boolean perferLoopback) throws UnknownHostException {
- try {
- Enumeration<NetworkInterface> ne = NetworkInterface.getNetworkInterfaces();
- while (ne.hasMoreElements()) {
- NetworkInterface ni = ne.nextElement();
- //## JDBC4.0-begin ##
- if (ni.isUp()) {
- //## JDBC4.0-end ##
- Enumeration<InetAddress> addrs = ni.getInetAddresses();
- while (addrs.hasMoreElements()) {
- InetAddress addr = addrs.nextElement();
-
- boolean isIPv6 = (addr instanceof Inet6Address);
- if (preferIPv6 == isIPv6 && perferLoopback == addr.isLoopbackAddress() ) {
- return addr;
- }
- }
- //## JDBC4.0-begin ##
- }
- //## JDBC4.0-end ##
- }
- } catch (SocketException e) {
- // treat this as address not found and return null;
- }
- return null;
- }
-
- /**
- * Call to determine if a port is available to be opened.
- * This is used to determine if a port is already opened
- * by some other process. If the port is available, then
- * it's not in use.
- * @param host
- * @param port
- * @return true if the port is not opened.
- * @since 4.3
- */
- public boolean isPortAvailable(String host, int port) throws UnknownHostException {
-
- try {
- //using Socket to try to connect to an existing opened socket
- Socket ss = new Socket(host, port);
-
- try {
- ss.close();
- } catch (Exception ce) {
- // it was open and considered available, then dont worry about the close error
- }
- return false;
- } catch (UnknownHostException ce) {
- throw ce;
- } catch (IOException e) {
- //ignore
- }
- return true;
- }
-}
Deleted: trunk/common-core/src/test/java/com/metamatrix/common/util/TestNetUtils.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/util/TestNetUtils.java 2010-04-15 15:56:33 UTC (rev 2058)
+++ trunk/common-core/src/test/java/com/metamatrix/common/util/TestNetUtils.java 2010-04-15 20:03:04 UTC (rev 2059)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.util;
-
-import java.net.UnknownHostException;
-
-import junit.framework.TestCase;
-
-
-public class TestNetUtils extends TestCase {
-
- public TestNetUtils(String name) {
- super(name);
- }
-
- public void testResolveHostName() {
-
- try {
- String hostname = NetUtils.getInstance().getInetAddress().getCanonicalHostName();
- assertNotNull(hostname, "Host name is not resolved");//$NON-NLS-1$
- } catch (UnknownHostException err) {
- fail("Unable to get host name"); //$NON-NLS-1$
- }
-
- }
-}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-04-15 15:56:33 UTC (rev 2058)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2010-04-15 20:03:04 UTC (rev 2059)
@@ -38,7 +38,6 @@
public static final int DEFAULT_MAX_PROCESS_WORKERS = 16;
- private String processName = "localhost"; //$NON-NLS-1$
private int maxThreads = DEFAULT_MAX_PROCESS_WORKERS;
private int timeSliceInMilli = DEFAULT_PROCESSOR_TIMESLICE;
private boolean processDebugAllowed;
@@ -52,15 +51,6 @@
private int maxResultSetCacheEntries = DQPConfiguration.DEFAULT_MAX_RESULTSET_CACHE_ENTRIES;
private boolean useEntitlements = false;
- @ManagementProperty (description="Name of the process that uniquely identifies this process")
- public String getProcessName() {
- return processName;
- }
-
- public void setProcessName(String processName) {
- this.processName = processName;
- }
-
@ManagementProperty(description="Process pool maximum thread count. (default 16) Increase this value if your load includes a large number of XQueries or if the system's available processors is larger than 8")
public int getMaxThreads() {
return maxThreads;
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java 2010-04-15 15:56:33 UTC (rev 2058)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java 2010-04-15 20:03:04 UTC (rev 2059)
@@ -29,11 +29,13 @@
import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
-import com.metamatrix.common.util.NetUtils;
import com.metamatrix.core.MetaMatrixRuntimeException;
@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
public class SocketConfiguration {
+ private static final String ANY = "0.0.0.0"; //$NON-NLS-1$
+ private static final String JBOSS_SERVER_BIND_ADDRESS = "jboss.bind.address";
+
private int outputBufferSize;
private int inputBufferSize;
private int maxSocketThreads;
@@ -41,12 +43,11 @@
private InetAddress hostAddress;
private SSLConfiguration sslConfiguration;
private boolean enabled;
- private String hostName;
+ private String hostName;
public void setBindAddress(String addr) {
this.hostName = addr;
- this.hostAddress = resolveHostAddress(addr);
}
public void setPortNumber(int port) {
@@ -69,12 +70,17 @@
this.sslConfiguration = value;
}
- private InetAddress resolveHostAddress(String bindAddress) {
+ private void resolveHostName() {
try {
- if (bindAddress == null) {
- return NetUtils.getInstance().getInetAddress();
+ // if host name not specified try to get it from the JBoss configuration
+ if (this.hostName == null) {
+ this.hostName = System.getProperty(JBOSS_SERVER_BIND_ADDRESS);
}
- return NetUtils.resolveHostByName(bindAddress);
+
+ // if not defined then see if can bind to local address; if supplied resolve it by name
+ if (this.hostName == null || ANY.equals(this.hostName)) {
+ this.hostName = InetAddress.getLocalHost().getHostName();
+ }
} catch (UnknownHostException e) {
throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
}
@@ -110,11 +116,25 @@
}
public InetAddress getHostAddress() {
- return hostAddress;
+ resolveHostName();
+ if (this.hostAddress != null) {
+ return hostAddress;
+ }
+ try {
+ //only cache inetaddresses if they represent the ip.
+ InetAddress addr = InetAddress.getByName(this.hostName);
+ if (addr.getHostAddress().equalsIgnoreCase(this.hostName)) {
+ this.hostAddress = addr;
+ }
+ return addr;
+ } catch (UnknownHostException e) {
+ throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
+ }
}
@ManagementProperty(description="Host Name",readOnly=true)
public String getHostName() {
+ resolveHostName();
return this.hostName;
}
14 years, 8 months
teiid SVN: r2058 - trunk/adminshell/src/main/resources/scripts.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-04-15 11:56:33 -0400 (Thu, 15 Apr 2010)
New Revision: 2058
Modified:
trunk/adminshell/src/main/resources/scripts/adminapi.bsh
Log:
TEIID-1042: fixing the to use simple name as the name instead fullpath name.
Modified: trunk/adminshell/src/main/resources/scripts/adminapi.bsh
===================================================================
--- trunk/adminshell/src/main/resources/scripts/adminapi.bsh 2010-04-14 21:49:25 UTC (rev 2057)
+++ trunk/adminshell/src/main/resources/scripts/adminapi.bsh 2010-04-15 15:56:33 UTC (rev 2058)
@@ -9,12 +9,12 @@
* Deploy a {@link VDB} file.
* @param vdbFile - VDB File Name
* @throws AdminException
- * @return the {@link VDB} representing the current property values and runtime state.
*/
-VDB deployVDB(String vdbFile) {
+void deployVDB(String vdbFile) {
debug("Adding VDB " + vdbFile);
checkAdmin();
- return internalAdmin.deployVDB(vdbFile, new FileInputStream(new File(vdbFile)));
+ f = new File(vdbFile);
+ internalAdmin.deployVDB(f.getName(), new FileInputStream(f));
}
/**
@@ -183,13 +183,13 @@
* Add Connector Type, will import Connector Type from a file
*
* @param name of the Connector to add
- * @param rarFile RAR file to be added
* @throws AdminException
*/
-void addConnector(String name, String rarFile) {
- debug("Adding Connector " + name + " from " + rarFile);
+void addConnector(String rarFile) {
+ debug("Adding Connector " + rarFile);
checkAdmin();
- internalAdmin.addConnector(name, new FileInputStream(new File(rarFile)));
+ f = new File(rarFile);
+ internalAdmin.addConnector(f.getName(), new FileInputStream(f));
}
14 years, 8 months