[teiid-commits] teiid SVN: r1731 - in branches/JCA: build/kit-jboss-container/deploy and 16 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Tue Jan 12 16:02:14 EST 2010
Author: rareddy
Date: 2010-01-12 16:02:10 -0500 (Tue, 12 Jan 2010)
New Revision: 1731
Added:
branches/JCA/build/kit-jboss-container/conf/jboss-log4j.xml
branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java
branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java
Removed:
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
branches/JCA/runtime/src/main/java/org/teiid/WrappedTeiidConnection.java
Modified:
branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml
branches/JCA/build/kit-jboss-container/deploy/teiid-runtime.rar
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java
branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java
branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java
branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java
branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
branches/JCA/runtime/src/main/java/org/teiid/Server.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java
branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java
branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
Log:
TEIID-833: adding embedded connection which currenly works only in JBoss container
Added: branches/JCA/build/kit-jboss-container/conf/jboss-log4j.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/conf/jboss-log4j.xml (rev 0)
+++ branches/JCA/build/kit-jboss-container/conf/jboss-log4j.xml 2010-01-12 21:02:10 UTC (rev 1731)
@@ -0,0 +1,417 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: jboss-log4j.xml 87678 2009-04-22 16:47:08Z bstansberry at jboss.com $ -->
+
+<!--
+ | For more configuration information and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A time/date based rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/server.log"/>
+ <param name="Append" value="true"/>
+ <!-- In AS 5.0.x the server log threshold was set by a system
+ property. In 5.1 and later we are instead using the system
+ property to set the priority on the root logger (see <root/> below)
+ <param name="Threshold" value="${jboss.server.log.threshold}"/>
+ -->
+
+ <!-- Rollover at midnight each day -->
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+
+ <!-- Rollover at the top of each hour
+ <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
+ -->
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] (Thread) Message\n -->
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
+
+ <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ -->
+ </layout>
+ </appender>
+
+ <!-- A size based file rolling appender
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/server.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ====================== -->
+ <!-- More Appender examples -->
+ <!-- ====================== -->
+
+ <!-- Buffer events and log them asynchronously
+ <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="SMTP"/>
+ </appender>
+ -->
+
+ <!-- EMail events to an administrator
+ <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="To" value="admin at myhost.domain.com"/>
+ <param name="From" value="nobody at myhost.domain.com"/>
+ <param name="Subject" value="JBoss Sever Errors"/>
+ <param name="SMTPHost" value="localhost"/>
+ <param name="BufferSize" value="10"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Syslog events
+ <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Facility" value="LOCAL7"/>
+ <param name="FacilityPrinting" value="true"/>
+ <param name="SyslogHost" value="localhost"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Log events to JMS (requires a topic to be created)
+ <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Threshold" value="ERROR"/>
+ <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
+ <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
+ </appender>
+ -->
+
+ <!-- Log events through SNMP
+ <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="ImplementationClassName" value="org.apache.log4j.ext.JoeSNMPTrapSender"/>
+ <param name="ManagementHost" value="127.0.0.1"/>
+ <param name="ManagementHostTrapListenPort" value="162"/>
+ <param name="EnterpriseOID" value="1.3.6.1.4.1.24.0"/>
+ <param name="LocalIPAddress" value="127.0.0.1"/>
+ <param name="LocalTrapSendPort" value="161"/>
+ <param name="GenericTrapType" value="6"/>
+ <param name="SpecificTrapType" value="12345678"/>
+ <param name="CommunityString" value="public"/>
+ <param name="ForwardStackTraceWithTrap" value="true"/>
+ <param name="Threshold" value="DEBUG"/>
+ <param name="ApplicationTrapOID" value="1.3.6.1.4.1.24.12.10.22.64"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Emit events as JMX notifications
+ <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+
+ <param name="Threshold" value="WARN"/>
+ <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Security AUDIT Appender
+ <appender name="AUDIT" class="org.jboss.logging.appender.DailyRollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/audit.log"/>
+ <param name="Append" value="true"/>
+ <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t:%x) %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- un-comment to enable Teiid COMMAND log
+ <appender name="COMMAND" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="${jboss.server.log.dir}/teiid-command.log"/>
+ <param name="MaxFileSize" value="1000KB"/>
+ <param name="MaxBackupIndex" value="25"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t:%x) %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- Un-comment to enable Teiid AUDIT log
+ <appender name="AUDIT" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="${jboss.server.log.dir}/teiid-audit.log"/>
+ <param name="MaxFileSize" value="1000KB"/>
+ <param name="MaxBackupIndex" value="25"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] (%t:%x) %m%n"/>
+ </layout>
+ </appender>
+ -->
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
+ <category name="org.apache">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the jacorb category to WARN as its INFO is verbose -->
+ <category name="jacorb">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Set the logging level of the JSF implementation that uses
+ | java.util.logging. The jdk logging levels can be controlled
+ | through the org.jboss.logging.log4j.JDKLevel class that
+ | in addition to the standard log4j levels it adds support for
+ | SEVERE, WARNING, CONFIG, FINE, FINER, FINEST
+ -->
+ <category name="javax.enterprise.resource.webcontainer.jsf">
+ <priority value="INFO" class="org.jboss.logging.log4j.JDKLevel"/>
+ </category>
+
+ <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
+ <category name="org.jgroups">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->
+ <category name="org.quartz">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the com.sun category to INFO as its FINE is verbose -->
+ <category name="com.sun">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the sun category to INFO as its FINE is verbose -->
+ <category name="sun">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the javax.xml.bind category to INFO as its FINE is verbose -->
+ <category name="javax.xml.bind">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit JBoss categories
+ <category name="org.jboss">
+ <priority value="INFO"/>
+ </category>
+ -->
+
+ <!-- Limit the JSR77 categories -->
+ <category name="org.jboss.management">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Limit the verbose facelets compiler -->
+ <category name="facelets.compiler">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the verbose ajax4jsf cache initialization -->
+ <category name="org.ajax4jsf.cache">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the verbose embedded jopr categories -->
+ <category name="org.rhq">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Limit the verbose seam categories -->
+ <category name="org.jboss.seam">
+ <priority value="WARN"/>
+ </category>
+
+ <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
+ <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
+ <priority value="TRACE"/>
+ </category>
+ -->
+
+ <!-- Category specifically for Security Audit Provider
+ <category name="org.jboss.security.audit.providers.LogAuditProvider" additivity="false">
+ <priority value="TRACE"/>
+ <appender-ref ref="AUDIT"/>
+ </category>
+ -->
+
+ <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
+ <category name="org.jboss.serial">
+ <priority value="INFO"/>
+ </category>
+
+ <!-- Decrease the priority threshold for the org.jboss.varia category
+ <category name="org.jboss.varia">
+ <priority value="DEBUG"/>
+ </category>
+ -->
+
+ <!-- Enable JBossWS message tracing
+ <category name="org.jboss.ws.core.MessageTrace">
+ <priority value="TRACE"/>
+ </category>
+ -->
+
+ <!--
+ | An example of enabling the custom TRACE level priority that is used
+ | by the JBoss internals to diagnose low level details. This example
+ | turns on TRACE level msgs for the org.jboss.ejb.plugins package and its
+ | subpackages. This will produce A LOT of logging output.
+ |
+ | Note: since jboss AS 4.2.x, the trace level is supported natively by
+ | log4j, so although the custom org.jboss.logging.XLevel priority will
+ | still work, there is no need to use it. The two examples that follow
+ | will both enable trace logging.
+ <category name="org.jboss.system">
+ <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+ </category>
+ <category name="org.jboss.ejb.plugins">
+ <priority value="TRACE"/>
+ </category>
+ -->
+
+ <!--
+ | Logs these events to SNMP:
+ - server starts/stops
+ - cluster evolution (node death/startup)
+ - When an EJB archive is deployed (and associated verified messages)
+ - When an EAR archive is deployed
+
+ <category name="org.jboss.system.server.Server">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.MainDeployer">
+ <priority value="ERROR" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.ejb.EJBDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+
+ <category name="org.jboss.deployment.EARDeployer">
+ <priority value="INFO" />
+ <appender-ref ref="TRAP_LOG"/>
+ </category>
+ -->
+
+ <!-- Clustering logging -->
+ <!-- Uncomment the following to redirect the org.jgroups and
+ org.jboss.ha categories to a cluster.log file.
+
+ <appender name="CLUSTER" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="${jboss.server.log.dir}/cluster.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+ </layout>
+ </appender>
+ <category name="org.jgroups">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ <category name="org.jboss.ha">
+ <priority value="DEBUG" />
+ <appender-ref ref="CLUSTER"/>
+ </category>
+ -->
+
+ <!-- Teiid specific categoryies -->
+ <logger name="org.teiid">
+ <level value="WARN" />
+ </logger>
+
+ <!-- un-comment to enable COMMAND log
+ <logger name="org.teiid.COMMAND_LOG" additivity="false">
+ <level value="INFO"/>
+ <appender-ref ref="COMMAND"/>
+ </logger>
+ -->
+
+ <!-- Un-comment to enable AUDIT log
+ <logger name="org.teiid.AUDIT_LOG" additivity="false">
+ <level value="INFO"/>
+ <appender-ref ref="AUDIT"/>
+ </logger>
+ -->
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <!--
+ Set the root logger priority via a system property. Note this is parsed by log4j,
+ so the full JBoss system property format is not supported; e.g.
+ setting a default via ${jboss.server.log.threshold:WARN} will not work.
+ -->
+ <priority value="${jboss.server.log.threshold}"/>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml 2010-01-12 21:02:10 UTC (rev 1731)
@@ -10,7 +10,6 @@
<config-property name="TeiidHome" type="java.lang.String">/home/rareddy/teiid/teiid-6.3.0/</config-property>
<max-pool-size>20</max-pool-size>
- <security-domain-and-application>teiid-security</security-domain-and-application>
</no-tx-connection-factory>
</connection-factories>
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-runtime.rar
===================================================================
(Binary files differ)
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/api/MMURL.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -61,11 +61,6 @@
*/
public static final String DISCOVERY_STRATEGY = "discoveryStategy"; //$NON-NLS-1$
- /**
- * if "true" in the embedded mode if there is a active instance that instance will be shutdown.
- */
- public static final String SHUTDOWN = "shutdown"; //$NON-NLS-1$
-
public static final String SERVER_URL = "serverURL"; //$NON-NLS-1$
/**
* Non-secure MetaMatrix Protocol.
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -33,6 +33,8 @@
void close();
+ void reallyClose();
+
boolean isOpen();
LogonResult getLogonResult();
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -26,12 +26,9 @@
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.core.MetaMatrixCoreException;
public interface ServerConnectionFactory {
- void initialize(Properties info) throws MetaMatrixCoreException;
-
/**
* Establish a connection to the server.
* @param connProps The properties used by the transport to find a connection. These
@@ -42,13 +39,5 @@
* problems with the connection properties (bad user name, bad password, bad host name, etc)
*/
ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException;
-
- /**
- * Is the connection factory alive
- * @return true if alive; false otherwise.
- */
- boolean isAlive();
-
- void shutdown();
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -317,4 +317,9 @@
this.failOver = failOver;
}
+ @Override
+ public void reallyClose() {
+ close();
+ }
+
}
\ No newline at end of file
Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -179,7 +179,6 @@
}
- @Override
public void initialize(Properties info) {
PropertiesUtils.setBeanProperties(this, info, "org.teiid.sockets"); //$NON-NLS-1$
this.pingTimer = new Timer("SocketPing", true); //$NON-NLS-1$
@@ -287,17 +286,4 @@
public void setMaxCachedInstances(int maxCachedInstances) {
this.maxCachedInstances = maxCachedInstances;
}
-
-
- @Override
- public void shutdown() {
- // only applies in the Embedded scenario.
- }
-
- @Override
- public boolean isAlive() {
- // only applies in the Embedded scenario.
- return false;
- }
-
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -66,7 +66,6 @@
public static final String BOOTURL = "bootURL"; //$NON-NLS-1$
public static final String ENABLE_SOCKETS = "sockets.enabled"; //$NON-NLS-1$
public static final String HOST_ADDRESS = "hostAddress"; //$NON-NLS-1$
- public static final String DQP_BOOTSTRAP_FILE = "bootstrapFile"; //$NON-NLS-1$
public static final String TEIID_HOME = "teiid.home"; //$NON-NLS-1$
public static final String TEIID_LOGDIR = "teiid.logdir"; //$NON-NLS-1$
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/RequestMetadata.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -25,7 +25,6 @@
import java.io.Serializable;
import java.util.Date;
-import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.metatype.api.annotations.MetaMapping;
import org.teiid.adminapi.Request;
@@ -33,7 +32,6 @@
import com.metamatrix.dqp.message.RequestID;
- at ManagementObject
@MetaMapping(RequestMetadataMapper.class)
public class RequestMetadata extends AdminObjectImpl implements Request, Serializable {
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -23,7 +23,6 @@
import java.util.Date;
-import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementObjectID;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.metatype.api.annotations.MetaMapping;
@@ -33,7 +32,6 @@
/**
* Add and delete properties also in the Mapper class for correct wrapping for profile service.
*/
- at ManagementObject
@MetaMapping(SessionMetadataMapper.class)
public class SessionMetadata extends AdminObjectImpl implements Session {
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -24,14 +24,12 @@
import java.util.Date;
-import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.metatype.api.annotations.MetaMapping;
import org.teiid.adminapi.Transaction;
import com.metamatrix.admin.AdminPlugin;
- at ManagementObject
@MetaMapping(TransactionMetadataMapper.class)
public class TransactionMetadata extends AdminObjectImpl implements Transaction {
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/WorkerPoolStatisticsMetadata.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -22,14 +22,12 @@
package org.teiid.adminapi.impl;
-import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.teiid.adminapi.WorkerPoolStatistics;
/**
* This class is a holder for all the statistics gathered about a worker pool.
*/
- at ManagementObject
public class WorkerPoolStatisticsMetadata extends AdminObjectImpl implements WorkerPoolStatistics {
private static final long serialVersionUID = -4917902925523802295L;
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDataSource.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -33,23 +33,4 @@
}
- /**
- * Returns the path and file name from which embedded DQP configuration information will be read.
- *
- * @return the name of the config file for this data source; may be null
- */
- public String getBootstrapFile() {
- return getEmbeddedBootstrapFile();
- }
-
- /**
- * Sets file name from which embedded DQP configuration information * will be read.
- *
- * @param configFile
- * The name of the config file name to set
- */
- public void setBootstrapFile(final String configFile) {
- setEmbeddedBootstrapFile(configFile);
- }
-
}
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -287,7 +287,7 @@
} catch (SQLException se) {
firstException = se;
} finally {
- this.serverConn.close();
+ this.serverConn.reallyClose();
if ( firstException != null )
throw (SQLException)firstException;
}
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/util/MMJDBCURL.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -59,8 +59,7 @@
ExecutionProperties.PROP_XML_VALIDATION,
ExecutionProperties.DISABLE_LOCAL_TRANSACTIONS,
MMURL.CONNECTION.AUTO_FAILOVER,
- MMURL.CONNECTION.DISCOVERY_STRATEGY,
- MMURL.CONNECTION.SHUTDOWN
+ MMURL.CONNECTION.DISCOVERY_STRATEGY
};
private String vdbName;
@@ -74,8 +73,7 @@
}
public MMJDBCURL(String vdbName, String connectionURL, Properties props) {
- if (vdbName == null || vdbName.trim().length() == 0 ||
- connectionURL == null || connectionURL.trim().length() == 0) {
+ if (vdbName == null || vdbName.trim().length() == 0) {
throw new IllegalArgumentException();
}
this.vdbName = vdbName;
@@ -198,9 +196,10 @@
public String getJDBCURL() {
if (urlString == null) {
StringBuffer buf = new StringBuffer(JDBC_PROTOCOL)
- .append(vdbName)
- .append('@')
- .append(connectionURL);
+ .append(vdbName);
+ if (this.connectionURL != null) {
+ buf.append('@').append(connectionURL);
+ }
for (Iterator i = properties.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry)i.next();
if (entry.getValue() instanceof String) {
Modified: branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -22,70 +22,43 @@
package org.teiid.jdbc;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Enumeration;
-import java.util.List;
import java.util.Properties;
import java.util.ResourceBundle;
-import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
-import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.classloader.PostDelegatingClassLoader;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.common.protocol.MMURLConnection;
-import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
-import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.JDBCPlugin;
import com.metamatrix.jdbc.MMConnection;
-import com.metamatrix.jdbc.MMSQLException;
-import com.metamatrix.jdbc.api.SQLStates;
import com.metamatrix.jdbc.util.MMJDBCURL;
final class EmbeddedProfile {
- /**
+ private static final String TEIID_RUNTIME = "java:teiid/runtime-engine";
+ private static final String BUNDLE_NAME = "com.metamatrix.jdbc.basic_i18n"; //$NON-NLS-1$
+
+ /**
* Match URL like
- * - jdbc:metamatrix:BQT at c:/foo.properties;version=1..
- * - jdbc:metamatrix:BQT at c:\\foo.properties;version=1..
- * - jdbc:metamatrix:BQT@\\foo.properties;version=1..
- * - jdbc:metamatrix:BQT@/foo.properties;version=1..
- * - jdbc:metamatrix:BQT at ../foo.properties;version=1..
- * - jdbc:metamatrix:BQT at ./foo.properties;version=1..
- * - jdbc:metamatrix:BQT at file:///c:/foo.properties;version=1..
- * - jdbc:metamatrix:BQT
- * - jdbc:metamatrix:BQT;verson=1
+ * - jdbc:teiid:BQT
+ * - jdbc:teiid:BQT;verson=1
*/
- static final String URL_PATTERN = "jdbc:(teiid|metamatrix):(\\w+)@(([^;]*)[;]?)((.*)*)"; //$NON-NLS-1$
- static final String BASE_PATTERN = "jdbc:(teiid|metamatrix):((\\w+)[;]?)(;([^@])+)*"; //$NON-NLS-1$
+ static final String BASE_PATTERN = "jdbc:teiid:((\\w+)[;]?)(;([^@])+)*"; //$NON-NLS-1$
private static Logger logger = Logger.getLogger("org.teiid.jdbc"); //$NON-NLS-1$
- private static EmbeddedTransport currentTransport = null;
- static Pattern urlPattern = Pattern.compile(URL_PATTERN);
static Pattern basePattern = Pattern.compile(BASE_PATTERN);
/**
@@ -106,79 +79,37 @@
// parse the URL to add it's properties to properties object
parseURL(url, info);
- MMConnection conn = createConnection(info);
- boolean shutdown = Boolean.parseBoolean(info.getProperty(MMURL.CONNECTION.SHUTDOWN, "false")); //$NON-NLS-1$
- if (shutdown) {
- Admin admin = conn.getAdminAPI();
- try {
- // this will make sure the user has permissions to do the shutdown.
- admin.shutdown(0);
- shutdown();
- throw new MMSQLException(getResourceMessage("EmbeddedDriver.shutdown_sucessful"), SQLStates.SUCESS); //$NON-NLS-1$
- } catch (AdminException e) {
- conn.close();
- throw new MMSQLException(e, getResourceMessage("EmbeddedDriver.shutdown_failure"), SQLStates.DEFAULT); //$NON-NLS-1$
- }
- }
-
- // logging
- String logMsg = JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess"); //$NON-NLS-1$
- logger.fine(logMsg);
-
+ MMConnection conn = createConnection(url, info);
+ logger.fine(JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess")); //$NON-NLS-1$
return conn;
-
}
- static MMConnection createConnection(Properties info) throws SQLException{
+ static MMConnection createConnection(String url, Properties info) throws SQLException{
// first validate the properties as this may called from the EmbeddedDataSource
// and make sure we have all the properties we need.
validateProperties(info);
-
- URL dqpURL;
- try {
- dqpURL = URLHelper.buildURL(info.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE));
- } catch (MalformedURLException e) {
- throw MMSQLException.create(e);
+ try {
+ InitialContext ic = new InitialContext();
+ ServerConnectionFactory scf = (ServerConnectionFactory)ic.lookup(TEIID_RUNTIME);
+ ServerConnection conn = scf.getConnection(info);
+ // this close has no effect; it only closes the managed connection of server connection
+ conn.close();
+ return new MMConnection(conn, info, url);
+ } catch (NamingException e) {
+ throw new SQLException(e);
+ } catch (ConnectionException e) {
+ throw new SQLException(e);
+ } catch (CommunicationException e) {
+ throw new SQLException(e);
}
-
- // now create the connection
- EmbeddedTransport transport = getDQPTransport(dqpURL);
-
- MMConnection conn = transport.createConnection(info);
-
- return conn;
}
/**
- * Get the DQP transport or build the transport if one not available from the
- * DQP URL supplied. DQP transport contains all the details about DQP.
- * @param dqpURL - URL to the DQP.properties file
- * @return EmbeddedTransport
- * @throws SQLException
- * @since 4.4
- */
- private synchronized static EmbeddedTransport getDQPTransport(URL dqpURL) throws SQLException {
- EmbeddedTransport transport = currentTransport;
- if (transport == null || !transport.isAlive() || !currentTransport.getURL().equals(dqpURL)) {
- // shutdown any previous instance; we do encourage single instance in a given VM
- shutdown();
- try {
- transport = new EmbeddedTransport(dqpURL);
- } catch (SQLException e) {
- logger.log(Level.SEVERE, "Could not start the embedded engine", e); //$NON-NLS-1$
- throw e;
- }
- }
- currentTransport = transport;
- return transport;
- }
-
- /**
* This method parses the URL and adds properties to the the properties object. These include required and any optional
* properties specified in the URL.
* Expected URL format --
- * jdbc:metamatrix:local:VDB@<pathToConfigFile>logFile=<logFile.log>; logLevel=<logLevel>;credentials=mycredentials;
+ * jdbc:teiid:VDB;[name=value]*;
*
* @param The URL needed to be parsed.
* @param The properties object which is to be updated with properties in the URL.
@@ -195,16 +126,6 @@
// Set the VDB Name
info.setProperty(BaseDataSource.VDB_NAME, jdbcURL.getVDBName());
-
- // Need to resolve the URL fully, if we are using the default URL like
- // jdbc:metamatrix:<vdbName>.., where as this fully qualifies to
- // jdbc:metamatrix:<vdbName>@classpath:<vdbName>/mm.properties;...
- String connectionURL = jdbcURL.getConnectionURL();
- if (connectionURL == null) {
- connectionURL = getDefaultConnectionURL();
- info.setProperty(DQPEmbeddedProperties.VDB_DEFINITION, jdbcURL.getVDBName()+".vdb"); //$NON-NLS-1$
- }
- info.setProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE, connectionURL);
Properties optionalParams = jdbcURL.getProperties();
MMJDBCURL.normalizeProperties(info);
@@ -231,15 +152,6 @@
}
/**
- * Create the default connection URL, if one is not supplied
- * @param jdbcURL
- * @return default connection URL
- */
- static String getDefaultConnectionURL() {
- return "classpath:/deploy.properties"; //$NON-NLS-1$
- }
-
- /**
* validate some required properties
* @param info the connection properties to be validated
* @throws SQLException
@@ -257,226 +169,12 @@
}
public static boolean acceptsURL(String url) {
- Matcher m = urlPattern.matcher(url);
- boolean matched = m.matches();
- if (matched) {
- // make sure the group (2) which is the name of the file
- // does not start with mm:// or mms://
- String name = m.group(3).toLowerCase();
- return (!name.startsWith("mm://") && !name.startsWith("mms://") && (name.endsWith(".properties")||name.endsWith(".properties;"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
// Check if this can match our default one, then allow it.
- m = basePattern.matcher(url);
- matched = m.matches();
+ Matcher m = basePattern.matcher(url);
+ boolean matched = m.matches();
return matched;
}
-
-
- /**
- * Shutdown the DQP instance which has been started using the given URL
- * @param dqpURL
- */
- public static synchronized void shutdown() {
- if (currentTransport != null) {
- currentTransport.shutdown();
- currentTransport = null;
- }
- }
-
- /**
- * inner class to hold DQP tansportMap object
- * @since 4.3
- */
- static class EmbeddedTransport {
- private ServerConnectionFactory connectionFactory;
- private ClassLoader classLoader;
- private URL url;
-
- public EmbeddedTransport(URL dqpURL) throws SQLException {
- this.url = dqpURL;
-
- //Load the properties from dqp.properties file
- Properties props = loadDQPProperties(dqpURL);
-
- props = PropertiesUtils.resolveNestedProperties(props);
-
- // a non-delegating class loader will be created from where all third party dependent jars can be loaded
- ArrayList<URL> runtimeClasspathList = new ArrayList<URL>();
- String libLocation = props.getProperty(DQPEmbeddedProperties.DQP_LIBDIR, "./lib/"); //$NON-NLS-1$
- if (!libLocation.endsWith("/")) { //$NON-NLS-1$
- libLocation = libLocation + "/"; //$NON-NLS-1$
- }
-
- // find jars in the "lib" directory; patches is reverse alpaha and not case sensitive so small letters then capitals
- if (!EmbeddedProfile.getDefaultConnectionURL().equals(dqpURL.toString())) {
- runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation+"patches/", MMURLConnection.REVERSEALPHA)); //$NON-NLS-1$
- runtimeClasspathList.addAll(libClassPath(dqpURL, libLocation, MMURLConnection.DATE));
-
- try {
- String configLocation = props.getProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, "./deploy/"); //$NON-NLS-1$
- if (!configLocation.endsWith("/")) { //$NON-NLS-1$
- configLocation = configLocation + "/"; //$NON-NLS-1$
- }
- runtimeClasspathList.add(URLHelper.buildURL(dqpURL, configLocation));
- } catch(IOException e) {
- // ignore..
- }
- }
-
- URL[] dqpClassPath = runtimeClasspathList.toArray(new URL[runtimeClasspathList.size()]);
- this.classLoader = new PostDelegatingClassLoader(dqpClassPath, this.getClass().getClassLoader(), new MetaMatrixURLStreamHandlerFactory());
-
- String logMsg = getResourceMessage("EmbeddedDriver.use_classpath"); //$NON-NLS-1$
- logger.log(Level.FINER, logMsg + " " + Arrays.toString(dqpClassPath)); //$NON-NLS-1$
-
- props.setProperty(DQPEmbeddedProperties.BOOTURL, url.toExternalForm());
- props.setProperty(DQPEmbeddedProperties.TEIID_HOME, getHomeDirectory(props));
- // Now using this class loader create the connection factory to the dqp.
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(this.classLoader);
- String className = "com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl"; //$NON-NLS-1$
- try {
- this.connectionFactory = (ServerConnectionFactory)ReflectionHelper.create(className, null, this.classLoader);
- } catch (MetaMatrixCoreException e) {
- throw MMSQLException.create(e, "Could not load the embedded server, please ensure that your classpath is set correctly."); //$NON-NLS-1$
- }
- try {
- this.connectionFactory.initialize(props);
- } catch (MetaMatrixCoreException e) {
- throw MMSQLException.create(e);
- }
- } finally {
- Thread.currentThread().setContextClassLoader(current);
- }
- }
-
- URL getURL() {
- return this.url;
- }
-
- /**
- * Note that this only works when embedded loaded with "mmfile" protocol in the URL.
- * @param dqpURL
- * @return
- */
- private List<URL> libClassPath (URL dqpURL, String directory, String sortStyle) {
- ObjectInputStream in = null;
- ArrayList<URL> urlList = new ArrayList<URL>();
- try {
- urlList.add(URLHelper.buildURL(dqpURL, directory));
- dqpURL = URLHelper.buildURL(dqpURL, directory+"?action=list&filter=.jar&sort="+sortStyle); //$NON-NLS-1$
- in = new ObjectInputStream(dqpURL.openStream());
- String[] urls = (String[])in.readObject();
- for (int i = 0; i < urls.length; i++) {
- urlList.add(URLHelper.buildURL(urls[i]));
- }
- } catch(IOException e) {
- //ignore, treat as if lib does not exist
- } catch(ClassNotFoundException e) {
- //ignore, treat as if lib does not exist
- } finally {
- if (in != null) {
- try{in.close();}catch(IOException e) {}
- }
- }
- return urlList;
- }
-
- /**
- * Load DQP Properties from the URL supplied.
- * @param dqpURL - URL to the "dqp.properties" object
- * @return Properties loaded
- * @throws SQLException
- */
- Properties loadDQPProperties(URL dqpURL) throws SQLException {
- InputStream in = null;
- try{
- in = dqpURL.openStream();
- Properties props = new Properties(System.getProperties());
- props.load(in);
-
- String logMsg = getResourceMessage("EmbeddedDriver.use_properties"); //$NON-NLS-1$
- logger.log(Level.FINER, logMsg + props);
- return props;
- }catch(IOException e) {
- String logMsg = getResourceMessage("EmbeddedTransport.invalid_dqpproperties_path", new Object[] {dqpURL}); //$NON-NLS-1$
- throw MMSQLException.create(e, logMsg);
- }finally {
- if (in != null) {
- try{in.close();}catch(IOException e) {}
- }
- }
- }
-
- /**
- * Shutdown the current transport
- */
- void shutdown() {
- this.connectionFactory.shutdown();
- }
-
- boolean isAlive() {
- return this.connectionFactory.isAlive();
- }
-
- /**
- * Create a connection to the DQP defined by this transport object based on
- * properties supplied
- * @param info
- * @return Connection
- */
- MMConnection createConnection(Properties info) throws SQLException {
- ClassLoader current = null;
- try {
- current = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(classLoader);
- try {
- ServerConnection conn = connectionFactory.getConnection(info);
- return new MMConnection(conn, info, url.toExternalForm());
- } catch (CommunicationException e) {
- throw MMSQLException.create(e);
- } catch (ConnectionException e) {
- throw MMSQLException.create(e);
- }
- } finally {
- Thread.currentThread().setContextClassLoader(current);
- }
- }
-
- String getHomeDirectory(Properties props) throws SQLException {
- try {
- String teiidHome = props.getProperty(DQPEmbeddedProperties.TEIID_HOME);
-
- if (teiidHome == null) {
- if (EmbeddedProfile.getDefaultConnectionURL().equals(url.toString())) {
- teiidHome = System.getProperty("user.dir")+"/teiid"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- URL installDirectory = URLHelper.buildURL(url, "."); //$NON-NLS-1$
- teiidHome = installDirectory.getPath();
- }
- }
- File f = new File(teiidHome);
- return f.getCanonicalPath();
- } catch(IOException e) {
- throw MMSQLException.create(e);
- }
- }
-
- }
- private static final String BUNDLE_NAME = "com.metamatrix.jdbc.basic_i18n"; //$NON-NLS-1$
-
-
- static String getResourceMessage(String key, Object[] args) {
- ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);
- String messageTemplate = messages.getString(key);
- return MessageFormat.format(messageTemplate, args);
- }
-
-
static String getResourceMessage(String key) {
ResourceBundle messages = ResourceBundle.getBundle(BUNDLE_NAME);
String messageTemplate = messages.getString(key);
Modified: branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/main/java/org/teiid/jdbc/TeiidDataSource.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -22,21 +22,17 @@
package org.teiid.jdbc;
-import java.net.URL;
import java.sql.Connection;
-import java.sql.SQLException;
import java.util.Properties;
import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.protocol.URLHelper;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.jdbc.BaseDataSource;
import com.metamatrix.jdbc.JDBCPlugin;
import com.metamatrix.jdbc.MMSQLException;
import com.metamatrix.jdbc.util.MMJDBCURL;
/**
- * The MetaMatrix JDBC DataSource implementation class of {@link javax.sql.DataSource} and
+ * The Teiid JDBC DataSource implementation class of {@link javax.sql.DataSource} and
* {@link javax.sql.XADataSource}.
* <p>
* The {@link javax.sql.DataSource} interface follows the JavaBean design pattern,
@@ -52,10 +48,11 @@
* The following are the properties for this DataSource:
* <table cellspacing="0" cellpadding="0" border="1" width="100%">
* <tr><td><b>Property Name</b></td><td><b>Type</b></td><td><b>Description</b></td></tr>
- * <tr><td>portNumber </td><td><code>int </code></td><td>The port number where a MetaMatrix Server is listening
+ * <tr><td>portNumber </td><td><code>int </code></td><td>The port number where a Teiid Server is listening
* for requests.</td></tr>
- * <tr><td>serverName </td><td><code>String</code></td><td>The hostname or IP address of the MetaMatrix Server.</td></tr>
- * <table>
+ * <tr><td>serverName </td><td><code>String</code></td><td>The hostname or IP address of the Teiid Server.</td></tr>
+ * <table>
+ * If "serverName" property is not set then data source will try to create a embedded connection to the Teiid server.
* </p>
*/
public class TeiidDataSource extends BaseDataSource {
@@ -96,8 +93,6 @@
private String discoveryStrategy;
- private String bootstrapFile;
-
/**
* Constructor for MMDataSource.
*/
@@ -217,10 +212,9 @@
final TeiidDriver driver = new TeiidDriver();
// check if this is embedded connection
- if (getEmbeddedBootstrapFile() != null) {
- validateEmbeddedProperties(userName,password);
+ if (getServerName() == null) {
final Properties props = buildEmbeddedProperties(userName, password);
- String url = new MMJDBCURL(getDatabaseName(), getEmbeddedBootstrapFile(), props).getJDBCURL();
+ String url = new MMJDBCURL(getDatabaseName(), null, props).getJDBCURL();
return driver.connect(url, props);
}
@@ -233,20 +227,7 @@
private Properties buildEmbeddedProperties(final String userName, final String password) {
Properties props = buildProperties(userName, password);
-
- if (this.getEmbeddedBootstrapFile().equals(EmbeddedProfile.getDefaultConnectionURL())) {
- props.put(DQPEmbeddedProperties.VDB_DEFINITION, getDatabaseName() + ".vdb"); //$NON-NLS-1$
- }
- props.put(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE, this.bootstrapFile);
return props;
- }
-
- private void validateEmbeddedProperties(final String userName, final String password) throws java.sql.SQLException {
- super.validateProperties(userName, password);
- String reason = reasonWhyInvalidConfigFile(this.bootstrapFile);
- if (reason != null) {
- throw new SQLException(reason);
- }
}
/**
@@ -495,46 +476,5 @@
public void setDiscoveryStrategy(String discoveryStrategy) {
this.discoveryStrategy = discoveryStrategy;
}
-
- /**
- * Returns the path and file name from which embedded DQP configuration information will be read.
- *
- * @return the name of the config file for this data source; may be null
- */
- public String getEmbeddedBootstrapFile() {
- return bootstrapFile;
- }
-
- /**
- * Sets file name from which embedded DQP configuration information * will be read.
- *
- * @param configFile
- * The name of the config file name to set
- */
- public void setEmbeddedBootstrapFile(final String configFile) {
- this.bootstrapFile = configFile;
- }
-
- /**
- * Return the reason why the supplied config file may be invalid, or null if it is considered valid.
- *
- * @param configFile
- * a possible value for the property
- * @return the reason why the property is invalid, or null if it is considered valid
- * @see #setEmbeddedBootstrapFile(String)
- */
- public static String reasonWhyInvalidConfigFile(final String configFile) {
- if(configFile == null) {
- return getResourceMessage("EmbeddedDataSource.The_configFile_property_is_null"); //$NON-NLS-1$
- }
-
- try {
- URL url = URLHelper.buildURL(configFile);
- url.openStream();
- } catch (Exception e) {
- return getResourceMessage("EmbeddedDataSource.The_configFile_does_not_exist_or_cant_be_read"); //$NON-NLS-1$
- }
- return null;
- }
}
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/util/TestMMJDBCURL.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -242,13 +242,8 @@
} catch (Exception e) {
}
+
try {
- new MMJDBCURL("myVDB", null, null); //$NON-NLS-1$
- fail("Should have failed."); //$NON-NLS-1$
- } catch (Exception e) {
-
- }
- try {
new MMJDBCURL("myVDB", " ", null); //$NON-NLS-1$ //$NON-NLS-2$
fail("Should have failed."); //$NON-NLS-1$
} catch (Exception e) {
Modified: branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestEmbeddedProfile.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -45,112 +45,81 @@
* // (\\w:[\\\\,\\/]|file:\\/\\/|\\/|\\\\|(\\.){1,2}){1}
*/
@Test public void testAcceptsURL() {
-// // Windows Path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
- // Alternative windows path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at c:/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // Abosolute path (Unix or windows)
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // relative path
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at ../../metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at ../../metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at ../../metamatrix/dqp/dqp.properties;version=1;autoCommitTxn=ON;partialResultsMode=YES")); //$NON-NLS-1$
-
- // File URL should be supported (not sure)
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at file:///c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at testdata/dqp/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
-
// ClassPath based URL
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at classpath:/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT at classpath:/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
// These are specific to the MMorg.teiid.jdbc.EmbeddedProfile and should not be suported
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at mm://host:7001;version=1")); //$NON-NLS-1$
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at mms://host:7001;version=1")); //$NON-NLS-1$
- //assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT at http://host:7001;version=1"));
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT at mm://host:7001;version=1")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT at mms://host:7001;version=1")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT")); //$NON-NLS-1$
- assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT!/path/foo.properties")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT;")); //$NON-NLS-1$
- assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:metamatrix:BQT;version=1;logFile=foo.txt")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT")); //$NON-NLS-1$
+ assertFalse(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT!/path/foo.properties")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT;")); //$NON-NLS-1$
+ assertTrue(org.teiid.jdbc.EmbeddedProfile.acceptsURL("jdbc:teiid:BQT;version=1;logFile=foo.txt")); //$NON-NLS-1$
}
@Test public void testParseURL() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT at c:\\metamatrix\\dqp\\dqp.properties", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("c:\\metamatrix\\dqp\\dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
- assertEquals(3, p.size());
+ assertEquals(2, p.size());
}
@Test public void testParseURL2() throws SQLException {
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@\\metamatrix\\dqp\\dqp.properties;version=3", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;version=3", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("\\metamatrix\\dqp\\dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3")); //$NON-NLS-1$
- assertEquals(5, p.size());
+ assertEquals(4, p.size());
}
@Test public void testParseURL3() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;autoCommitTxn=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT@/metamatrix/dqp/dqp.properties;version=4;autoCommitTxn=ON;partialResultsMode=YES;", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("YES")); //$NON-NLS-1$
- assertEquals(7, p.size());
+ assertEquals(6, p.size());
}
@Test public void testParseURL4() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT at testdata/dqp/dqp.properties;partialResultsMode=true", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;partialResultsMode=true", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertEquals("testdata/dqp/dqp.properties", p.getProperty(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE)); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
- assertEquals(4, p.size());
+ assertEquals(3, p.size());
}
@Test public void testParseURL5() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
}
@Test public void testParseURL55() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT;", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
}
@Test public void testParseURL6() throws SQLException{
Properties p = new Properties();
- org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:metamatrix:BQT;partialResultsMode=true;version=1", p); //$NON-NLS-1$
+ org.teiid.jdbc.EmbeddedProfile.parseURL("jdbc:teiid:BQT;partialResultsMode=true;version=1", p); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
- assertTrue(p.get(DQPEmbeddedProperties.DQP_BOOTSTRAP_FILE).equals("classpath:/deploy.properties")); //$NON-NLS-1$
assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("1")); //$NON-NLS-1$
- assertTrue(p.getProperty("vdb.definition").equals("BQT.vdb")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(7, p.size());
+ assertEquals(5, p.size());
}
@Test public void test() throws Exception {
try {
Class.forName("org.teiid.jdbc.TeiidDriver"); //$NON-NLS-1$
- DriverManager.getConnection("jdbc:metamatrix:Parts at invalidConfig.properties;version=1"); //$NON-NLS-1$
+ DriverManager.getConnection("jdbc:teiid:Parts at invalidConfig.properties;version=1"); //$NON-NLS-1$
fail();
} catch (SQLException e) {
}
Modified: branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/client-jdbc/src/test/java/org/teiid/jdbc/TestTeiidDriver.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -24,6 +24,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import java.sql.DriverPropertyInfo;
@@ -35,19 +36,19 @@
@Test public void testGetPropertyInfo1() throws Exception {
DriverPropertyInfo info[] = drv.getPropertyInfo("jdbc:teiid:vdb at mm://localhost:12345", null); //$NON-NLS-1$
- assertEquals(18, info.length);
+ assertEquals(17, info.length);
}
@Test public void testAccepts() throws Exception {
assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:12345")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
+ assertFalse(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb at mm://localhost:12345")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb at mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb")); //$NON-NLS-1$
- assertTrue(drv.acceptsURL("jdbc:metamatrix:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:12345")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb at mm://localhost:12345;user=foo;password=bar")); //$NON-NLS-1$
+ assertTrue(drv.acceptsURL("jdbc:teiid:vdb")); //$NON-NLS-1$
+ assertFalse(drv.acceptsURL("jdbc:teiid:vdb@/foo/blah/deploy.properties")); //$NON-NLS-1$
}
Modified: branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -111,6 +111,7 @@
@Test public void testSessions() throws Exception{
Collection<Session> sessions = admin.getSessions();
+ System.out.println(sessions);
assertTrue(sessions.size() >= 1);
for (Session s: sessions) {
assertEquals("ramesh at teiid-security", s.getUserName());
Deleted: branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -1,283 +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.jdbc;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Date;
-import java.util.Properties;
-
-import javax.resource.ResourceException;
-import javax.resource.spi.ConnectionManager;
-
-import org.teiid.ConnectionInfo;
-import org.teiid.ContainerHelper;
-import org.teiid.ContainerUtil;
-import org.teiid.TeiidManagedConnectionFactory;
-import org.teiid.TeiidResourceAdapter;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.impl.BaseAdmin;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPManagementView;
-import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
-import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-import org.teiid.dqp.internal.transaction.XidFactory;
-import org.teiid.transport.AdminAuthorizationInterceptor;
-import org.teiid.transport.LogonImpl;
-import org.teiid.transport.SocketListenerStats;
-import org.teiid.transport.SocketTransport;
-
-import com.metamatrix.admin.objects.MMProcess;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.comm.ClientServiceRegistry;
-import com.metamatrix.common.comm.ClientServiceRegistryImpl;
-import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
-import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.NetUtils;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.client.ClientSideDQP;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.platform.security.api.ILogon;
-import com.metamatrix.platform.security.api.service.SessionService;
-
-
-/**
- * A factory class which creates the connections to the embedded DQP instance.
- * This is also responsible for initializing the DQP if the DQP instance is not
- * already alive.
- */
-public class EmbeddedConnectionFactoryImpl implements ServerConnectionFactory {
- private DQPCore dqp;
-
- private TeiidResourceAdapter ra;
- private TeiidManagedConnectionFactory mcf;
- private ConnectionManager cxManager;
- private Properties bootProperties;
- private SocketTransport socketTransport;
- private long starttime = -1L;
- private InetAddress address;
-
- public EmbeddedConnectionFactoryImpl(TeiidResourceAdapter ra, TeiidManagedConnectionFactory mcf, ConnectionManager cxmanager) {
- this.ra = ra;
- this.mcf = mcf;
- this.cxManager = cxmanager;
- LogManager.setLogConfiguration(new LogConfigurationProvider().get());
- LogManager.setLogListener(new LogListernerProvider().get());
- }
-
- @Override
- public ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException {
- // unfortunately we can only offer the managed connections for the Embedded, for socket connections those requests come
- // directly to this class and will not be managed
- try {
- return (ServerConnection)cxManager.allocateConnection(this.mcf, new ConnectionInfo(connectionProperties, createClientServices(), this.dqp.getSessionService()));
- } catch (ResourceException e) {
- throw new ConnectionException(e);
- }
- }
-
- /**
- * When the DQP is restarted using the admin API, it only shuts it down, it gets
- * restarted when the next time connection is made, however this factory may be
- * holding on to a previous transport handler, so we need to check if the DQP is
- * still alive and create a new one if necessary.
- * @param props
- * @throws ApplicationInitializationException
- * @since 4.3
- */
- public void initialize(Properties props) throws MetaMatrixCoreException {
- this.bootProperties = props;
- this.address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
-
- // Since the loading of the engine connection factory and all required services can not tied to load
- // in a dependent manner, provide a proxy until such time.
- ClientServiceRegistry clientServices = (ClientServiceRegistry)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {ClientServiceRegistry.class}, new InvocationHandler() {
- ClientServiceRegistry clientServices = null;
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if (clientServices == null) {
- clientServices = createClientServices();
- }
- return method.invoke(clientServices, args);
- }
- });
-
- // start socket transport
- boolean enableSocketTransport = PropertiesUtils.getBooleanProperty(this.bootProperties, DQPEmbeddedProperties.ENABLE_SOCKETS, false);
- if (enableSocketTransport) {
- this.socketTransport = new SocketTransport(this.bootProperties, clientServices, this.ra.getWorkManager(), this.address);
- this.socketTransport.start();
- }
-
- this.starttime = System.currentTimeMillis();
- DQPEmbeddedPlugin.logInfo("DQPEmbeddedManager.start_dqp", new Object[] {new Date(System.currentTimeMillis()).toString()}); //$NON-NLS-1$
-
- }
-
- private TransactionService getTransactionService(String processName) {
- TransactionServerImpl txnService = new TransactionServerImpl();
- txnService.setTransactionProvider(new ContainerTransactionProvider(this.ra.getXATerminator()));
- txnService.setProcessName(processName);
- txnService.setXidFactory(new XidFactory());
- return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
- }
-
- public synchronized boolean isAlive() {
- return (dqp != null);
- }
-
- public synchronized DQPCore getDQP() {
- if (!isAlive()) {
- throw new MetaMatrixRuntimeException(JDBCPlugin.Util.getString("LocalTransportHandler.Transport_shutdown")); //$NON-NLS-1$
- }
- return this.dqp;
- }
-
- public void shutdown() {
- // shutdown the socket transport.
- if (this.socketTransport != null) {
- this.socketTransport.stop();
- this.socketTransport = null;
- }
- }
-
- /**
- * ConnectionFactory and DQPCore lifecycles can be tied together, however by the time a user
- * logs in all the services will be up. So, send a proxy if this service starts first then during
- * the connection fe
- * @param clusterName
- * @return
- */
- private ClientServiceRegistry createClientServices() {
- // start the DQP
- String processName = bootProperties.getProperty(DQPEmbeddedProperties.PROCESSNAME, "embedded"); //$NON-NLS-1$
- String clusterName = this.bootProperties.getProperty(DQPEmbeddedProperties.CLUSTERNAME, "teiid-cluster"); //$NON-NLS-1$
- ContainerHelper helper = ContainerUtil.lookup("teiid/container-helper");
-
- DQPManagementView holder = helper.getService(DQPManagementView.class);
- this.dqp = new DQPCore();
- this.dqp.setTransactionService(getTransactionService(processName));
- this.dqp.setWorkManager(this.ra.getWorkManager());
- this.dqp.setAuthorizationService(helper.getService(AuthorizationService.class));
- this.dqp.setBufferService(helper.getService(BufferService.class));
- this.dqp.setSessionService(helper.getService(SessionService.class));
- this.dqp.setConnectorManagerRepository(helper.getService(ConnectorManagerRepository.class));
- this.dqp.start(bootProperties);
- holder.setDQP(this.dqp);
-
- ClientServiceRegistry services = new ClientServiceRegistryImpl();
- services.registerClientService(ILogon.class, new LogonImpl(this.dqp.getSessionService(), this.dqp, clusterName), com.metamatrix.common.util.LogConstants.CTX_SERVER);
-
- Admin roleCheckedServerAdmin = wrapAdminService(Admin.class, getAdminAPI(), this.dqp.getAuthorizationService());
- services.registerClientService(Admin.class, roleCheckedServerAdmin, com.metamatrix.common.util.LogConstants.CTX_ADMIN);
-
- services.registerClientService(ClientSideDQP.class, this.dqp, LogConstants.CTX_QUERY_SERVICE);
-
- return services;
- }
-
- private Admin getAdminAPI() {
- Admin admin = ContainerUtil.lookup("teiid/admin");
- if (admin instanceof BaseAdmin) {
- ((BaseAdmin) admin).setManager(this);
- }
- return admin;
- }
-
- @SuppressWarnings("unchecked")
- private <T> T wrapAdminService(Class<T> iface, T impl, AuthorizationService authService) {
- return (T)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {iface}, new AdminAuthorizationInterceptor(authService, impl));
- }
-
- private InetAddress resolveHostAddress(String bindAddress) {
- try {
- if (bindAddress == null) {
- return NetUtils.getInstance().getInetAddress();
- }
- return NetUtils.resolveHostByName(bindAddress);
- } catch (UnknownHostException e) {
- throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
- }
- }
-
- public InetAddress getAddress() {
- return address;
- }
-
- public long getStartTime() {
- return this.starttime;
- }
-
- public MMProcess getProcess() {
-
- Properties props = this.bootProperties;
-
- String hostName = getAddress().getHostName();
- String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
-
- String[] identifierParts = new String[] {hostName, processName};
- MMProcess process = new MMProcess(identifierParts);
-
- Runtime rt = Runtime.getRuntime();
-
- process.setEnabled(true);
- process.setCreated(new Date(getStartTime()));
- process.setInetAddress(getAddress());
- process.setFreeMemory(rt.freeMemory());
- process.setTotalMemory(rt.totalMemory());
- process.setProperties(PropertiesUtils.clone(props));
- process.setStartTime(new Date(this.starttime));
-
- if (this.socketTransport != null) {
- SocketListenerStats socketStats = this.socketTransport.getStats();
- if (socketStats != null) {
- process.setSockets(socketStats.sockets);
- process.setMaxSockets(socketStats.maxSockets);
- process.setObjectsRead(socketStats.objectsRead);
- process.setObjectsWritten(socketStats.objectsWritten);
- }
-
- WorkerPoolStatisticsMetadata workerStats = this.socketTransport.getProcessPoolStats();
- process.setQueueWorkerPool(workerStats);
-
- process.setPort(this.socketTransport.getPort());
- }
- return process;
- }
-}
Modified: branches/JCA/runtime/src/main/java/org/teiid/Server.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/Server.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/Server.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -36,9 +36,8 @@
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-public class Server extends EmbeddedConnectionFactoryImpl implements ServerMBean {
+public class Server extends TeiidConnectionFactory implements ServerMBean {
private Properties props;
Copied: branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java (from rev 1721, branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java)
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -0,0 +1,282 @@
+/*
+ * 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.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.impl.BaseAdmin;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DQPManagementView;
+import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
+import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+import org.teiid.dqp.internal.transaction.XidFactory;
+import org.teiid.transport.AdminAuthorizationInterceptor;
+import org.teiid.transport.LogonImpl;
+import org.teiid.transport.SocketListenerStats;
+import org.teiid.transport.SocketTransport;
+
+import com.metamatrix.admin.objects.MMProcess;
+import com.metamatrix.common.application.exception.ApplicationInitializationException;
+import com.metamatrix.common.comm.ClientServiceRegistry;
+import com.metamatrix.common.comm.ClientServiceRegistryImpl;
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.api.ServerConnectionFactory;
+import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.common.comm.exception.ConnectionException;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.NetUtils;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+import com.metamatrix.dqp.service.AuthorizationService;
+import com.metamatrix.dqp.service.BufferService;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.jdbc.JDBCPlugin;
+import com.metamatrix.jdbc.LogConfigurationProvider;
+import com.metamatrix.jdbc.LogListernerProvider;
+import com.metamatrix.platform.security.api.ILogon;
+import com.metamatrix.platform.security.api.service.SessionService;
+
+
+/**
+ * A factory class which creates the connections to the embedded DQP instance.
+ * This is also responsible for initializing the DQP if the DQP instance is not
+ * already alive.
+ */
+public class TeiidConnectionFactory implements ServerConnectionFactory {
+ private DQPCore dqp;
+
+ private TeiidResourceAdapter ra;
+ private TeiidManagedConnectionFactory mcf;
+ private ConnectionManager cxManager;
+ private Properties bootProperties;
+ private SocketTransport socketTransport;
+ private long starttime = -1L;
+ private InetAddress address;
+ ClientServiceRegistry clientServices = null;
+
+
+ public TeiidConnectionFactory(TeiidResourceAdapter ra, TeiidManagedConnectionFactory mcf, ConnectionManager cxmanager) {
+ this.ra = ra;
+ this.mcf = mcf;
+ this.cxManager = cxmanager;
+ LogManager.setLogConfiguration(new LogConfigurationProvider().get());
+ LogManager.setLogListener(new LogListernerProvider().get());
+ }
+
+ @Override
+ public ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException {
+ // unfortunately we can only offer the managed connections for the Embedded, for socket connections those requests come
+ // directly to this class and will not be managed
+ try {
+ if (clientServices == null) {
+ clientServices = createClientServices();
+ }
+ return (ServerConnection)cxManager.allocateConnection(this.mcf, new ConnectionInfo(connectionProperties, clientServices, this.dqp.getSessionService()));
+ } catch (ResourceException e) {
+ throw new ConnectionException(e);
+ }
+ }
+
+ /**
+ * When the DQP is restarted using the admin API, it only shuts it down, it gets
+ * restarted when the next time connection is made, however this factory may be
+ * holding on to a previous transport handler, so we need to check if the DQP is
+ * still alive and create a new one if necessary.
+ * @param props
+ * @throws ApplicationInitializationException
+ * @since 4.3
+ */
+ public void initialize(Properties props) {
+ this.bootProperties = props;
+ this.address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
+
+ // Since the loading of the engine connection factory and all required services can not tied to load
+ // in a dependent manner, provide a proxy until such time.
+ ClientServiceRegistry clientServicesProxy = (ClientServiceRegistry)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {ClientServiceRegistry.class}, new InvocationHandler() {
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (clientServices == null) {
+ clientServices = createClientServices();
+ }
+ return method.invoke(clientServices, args);
+ }
+ });
+
+ // start socket transport
+ boolean enableSocketTransport = PropertiesUtils.getBooleanProperty(this.bootProperties, DQPEmbeddedProperties.ENABLE_SOCKETS, false);
+ if (enableSocketTransport) {
+ this.socketTransport = new SocketTransport(this.bootProperties, clientServicesProxy, this.ra.getWorkManager(), this.address);
+ this.socketTransport.start();
+ }
+
+ this.starttime = System.currentTimeMillis();
+ DQPEmbeddedPlugin.logInfo("DQPEmbeddedManager.start_dqp", new Object[] {new Date(System.currentTimeMillis()).toString()}); //$NON-NLS-1$
+
+ }
+
+ private TransactionService getTransactionService(String processName) {
+ TransactionServerImpl txnService = new TransactionServerImpl();
+ txnService.setTransactionProvider(new ContainerTransactionProvider(this.ra.getXATerminator()));
+ txnService.setProcessName(processName);
+ txnService.setXidFactory(new XidFactory());
+ return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
+ }
+
+ public synchronized boolean isAlive() {
+ return (dqp != null);
+ }
+
+ public synchronized DQPCore getDQP() {
+ if (!isAlive()) {
+ throw new MetaMatrixRuntimeException(JDBCPlugin.Util.getString("LocalTransportHandler.Transport_shutdown")); //$NON-NLS-1$
+ }
+ return this.dqp;
+ }
+
+ public void shutdown() {
+ // shutdown the socket transport.
+ if (this.socketTransport != null) {
+ this.socketTransport.stop();
+ this.socketTransport = null;
+ }
+ }
+
+ /**
+ * ConnectionFactory and DQPCore lifecycles need to be tied together, but when this class starts
+ * all services may not be up, however by the time a user logs in for a connection all the services will be up.
+ * So, send a proxy of this service first and replace with actual one later.
+ */
+ private ClientServiceRegistry createClientServices() {
+ // start the DQP
+ String processName = bootProperties.getProperty(DQPEmbeddedProperties.PROCESSNAME, "embedded"); //$NON-NLS-1$
+ String clusterName = this.bootProperties.getProperty(DQPEmbeddedProperties.CLUSTERNAME, "teiid-cluster"); //$NON-NLS-1$
+ ContainerHelper helper = ContainerUtil.lookup("teiid/container-helper");
+
+ DQPManagementView holder = helper.getService(DQPManagementView.class);
+ this.dqp = new DQPCore();
+ this.dqp.setTransactionService(getTransactionService(processName));
+ this.dqp.setWorkManager(this.ra.getWorkManager());
+ this.dqp.setAuthorizationService(helper.getService(AuthorizationService.class));
+ this.dqp.setBufferService(helper.getService(BufferService.class));
+ this.dqp.setSessionService(helper.getService(SessionService.class));
+ this.dqp.setConnectorManagerRepository(helper.getService(ConnectorManagerRepository.class));
+ this.dqp.start(bootProperties);
+ holder.setDQP(this.dqp);
+
+ ClientServiceRegistry services = new ClientServiceRegistryImpl();
+ services.registerClientService(ILogon.class, new LogonImpl(this.dqp.getSessionService(), clusterName), com.metamatrix.common.util.LogConstants.CTX_SERVER);
+
+ Admin roleCheckedServerAdmin = wrapAdminService(Admin.class, getAdminAPI(), this.dqp.getAuthorizationService());
+ services.registerClientService(Admin.class, roleCheckedServerAdmin, com.metamatrix.common.util.LogConstants.CTX_ADMIN);
+
+ services.registerClientService(ClientSideDQP.class, this.dqp, LogConstants.CTX_QUERY_SERVICE);
+
+ return services;
+ }
+
+ private Admin getAdminAPI() {
+ Admin admin = ContainerUtil.lookup("teiid/admin");
+ if (admin instanceof BaseAdmin) {
+ ((BaseAdmin) admin).setManager(this);
+ }
+ return admin;
+ }
+
+ @SuppressWarnings("unchecked")
+ private <T> T wrapAdminService(Class<T> iface, T impl, AuthorizationService authService) {
+ return (T)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {iface}, new AdminAuthorizationInterceptor(authService, impl));
+ }
+
+ private InetAddress resolveHostAddress(String bindAddress) {
+ try {
+ if (bindAddress == null) {
+ return NetUtils.getInstance().getInetAddress();
+ }
+ return NetUtils.resolveHostByName(bindAddress);
+ } catch (UnknownHostException e) {
+ throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
+ }
+ }
+
+ public InetAddress getAddress() {
+ return address;
+ }
+
+ public long getStartTime() {
+ return this.starttime;
+ }
+
+ public MMProcess getProcess() {
+
+ Properties props = this.bootProperties;
+
+ String hostName = getAddress().getHostName();
+ String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
+
+ String[] identifierParts = new String[] {hostName, processName};
+ MMProcess process = new MMProcess(identifierParts);
+
+ Runtime rt = Runtime.getRuntime();
+
+ process.setEnabled(true);
+ process.setCreated(new Date(getStartTime()));
+ process.setInetAddress(getAddress());
+ process.setFreeMemory(rt.freeMemory());
+ process.setTotalMemory(rt.totalMemory());
+ process.setProperties(PropertiesUtils.clone(props));
+ process.setStartTime(new Date(this.starttime));
+
+ if (this.socketTransport != null) {
+ SocketListenerStats socketStats = this.socketTransport.getStats();
+ if (socketStats != null) {
+ process.setSockets(socketStats.sockets);
+ process.setMaxSockets(socketStats.maxSockets);
+ process.setObjectsRead(socketStats.objectsRead);
+ process.setObjectsWritten(socketStats.objectsWritten);
+ }
+
+ WorkerPoolStatisticsMetadata workerStats = this.socketTransport.getProcessPoolStats();
+ process.setQueueWorkerPool(workerStats);
+
+ process.setPort(this.socketTransport.getPort());
+ }
+ return process;
+ }
+}
Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -37,7 +37,6 @@
import javax.transaction.xa.XAResource;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.basic.WrappedConnection;
import org.teiid.transport.LocalServerConnection;
import com.metamatrix.common.comm.exception.CommunicationException;
@@ -46,7 +45,7 @@
public class TeiidManagedConnection implements ManagedConnection {
protected final Collection<ConnectionEventListener> listeners = new ArrayList<ConnectionEventListener>();
private PrintWriter log;
- private WrappedTeiidConnection conn;
+ private WrappedConnection conn;
public TeiidManagedConnection() {
@@ -57,25 +56,30 @@
if (!(handle instanceof WrappedConnection)) {
throw new ConnectorException("Wrong connection supplied to assosiate");
}
- conn = (WrappedTeiidConnection)handle;
+ conn = (WrappedConnection)handle;
conn.setManagedConnection(this);
}
@Override
public void cleanup() throws ResourceException {
+ if (this.conn != null) {
+ this.conn.close();
+ this.conn = null;
+ }
}
@Override
public void destroy() throws ResourceException {
+ cleanup();
}
@Override
public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
ConnectionInfo ci = (ConnectionInfo)arg1;
try {
- this.conn = new WrappedTeiidConnection(new LocalServerConnection(ci.properties, ci.clientServices, ci.sessionService));
+ this.conn = new WrappedConnection(new LocalServerConnection(ci.properties, ci.clientServices, ci.sessionService));
this.conn.setManagedConnection(this);
- return this;
+ return this.conn;
} catch (CommunicationException e) {
throw new ResourceException(e);
} catch (ConnectionException e) {
@@ -130,12 +134,6 @@
* remove the managed connection from the pool
*/
void connectionClosed() {
- synchronized (listeners) {
- for (ConnectionEventListener ce: listeners) {
- ce.connectionClosed(new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED));
- }
- }
-
ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
ce.setConnectionHandle(this.conn);
Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -40,16 +40,14 @@
import javax.security.auth.Subject;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
public class TeiidManagedConnectionFactory implements ManagedConnectionFactory,ResourceAdapterAssociation {
- TeiidResourceAdapter ra;
- PrintWriter log;
- String deployPropertiesFile;
- EmbeddedConnectionFactoryImpl connFactory;
- String teiidHome;
+ private TeiidResourceAdapter ra;
+ private PrintWriter log;
+ private String deployPropertiesFile;
+ private TeiidConnectionFactory connFactory;
+ private String teiidHome;
@Override
public Object createConnectionFactory() throws ResourceException {
@@ -59,13 +57,11 @@
@Override
public Object createConnectionFactory(ConnectionManager arg0) throws ResourceException {
try {
- connFactory = new EmbeddedConnectionFactoryImpl(this.ra, this, arg0);
+ connFactory = new TeiidConnectionFactory(this.ra, this, arg0);
connFactory.initialize(getDeployProperties());
return connFactory;
- } catch (MetaMatrixCoreException e) {
+ } catch (IOException e) {
throw new ResourceException(e);
- } catch (IOException e) {
- throw new ResourceException(e);
}
}
Copied: branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java (from rev 1684, branches/JCA/runtime/src/main/java/org/teiid/WrappedTeiidConnection.java)
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -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 org.teiid;
+
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.platform.security.api.LogonResult;
+
+public class WrappedConnection implements ServerConnection {
+
+ private ServerConnection delegate;
+ private TeiidManagedConnection mc;
+ private boolean closed = false;
+
+ public WrappedConnection(ServerConnection conn) {
+ this.delegate = conn;
+ }
+
+ @Override
+ public LogonResult getLogonResult() {
+ return delegate.getLogonResult();
+ }
+
+ @Override
+ public <T> T getService(Class<T> iface) {
+ return delegate.getService(iface);
+ }
+
+ @Override
+ public boolean isOpen() {
+ return delegate.isOpen();
+ }
+
+ @Override
+ public boolean isSameInstance(ServerConnection conn)
+ throws CommunicationException {
+ return delegate.isSameInstance(conn);
+ }
+
+ @Override
+ public void close() {
+ if (!this.closed && this.mc != null) {
+ this.closed = true;
+ this.mc.connectionClosed();
+ this.mc = null;
+ }
+ }
+
+ void setManagedConnection(TeiidManagedConnection teiidManagedConnection) {
+ this.mc = teiidManagedConnection;
+ }
+
+ @Override
+ public void reallyClose() {
+ close();
+ if (this.delegate != null) {
+ delegate.close();
+ delegate = null;
+ }
+ }
+}
Property changes on: branches/JCA/runtime/src/main/java/org/teiid/WrappedConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/JCA/runtime/src/main/java/org/teiid/WrappedTeiidConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/WrappedTeiidConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/WrappedTeiidConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -1,73 +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 com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.exception.CommunicationException;
-import com.metamatrix.platform.security.api.LogonResult;
-
-public class WrappedTeiidConnection implements ServerConnection {
-
- ServerConnection delegate;
- TeiidManagedConnection mc;
- boolean closed = false;
-
- public WrappedTeiidConnection(ServerConnection conn) {
- this.delegate = conn;
- }
-
- @Override
- public LogonResult getLogonResult() {
- return delegate.getLogonResult();
- }
-
- @Override
- public <T> T getService(Class<T> iface) {
- return delegate.getService(iface);
- }
-
- @Override
- public boolean isOpen() {
- return delegate.isOpen();
- }
-
- @Override
- public boolean isSameInstance(ServerConnection conn)
- throws CommunicationException {
- return delegate.isSameInstance(conn);
- }
-
- @Override
- public void close() {
- if (!this.closed && this.mc != null) {
- this.closed = true;
- delegate.close();
- this.mc.connectionClosed();
- this.mc = null;
- }
- }
-
- void setManagedConnection(TeiidManagedConnection teiidManagedConnection) {
- this.mc = teiidManagedConnection;
- }
-}
Modified: branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -24,16 +24,16 @@
import java.util.ArrayList;
import java.util.Collection;
+import org.teiid.TeiidConnectionFactory;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.ProcessObject;
import org.teiid.adminapi.TeiidAdmin;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
public abstract class BaseAdmin extends TeiidAdmin {
- private EmbeddedConnectionFactoryImpl manager;
+ private TeiidConnectionFactory manager;
- public void setManager(EmbeddedConnectionFactoryImpl manager) {
+ public void setManager(TeiidConnectionFactory manager) {
this.manager = manager;
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -53,7 +53,6 @@
private final LogonResult result;
private boolean shutdown;
private DQPWorkContext workContext;
- private ClassLoader classLoader;
private ClientServiceRegistry clientServices;
private SessionService sessionService;
private ILogon logon;
@@ -61,10 +60,10 @@
public LocalServerConnection(Properties connectionProperties, ClientServiceRegistry clientServices, SessionService sessionService) throws CommunicationException, ConnectionException{
this.clientServices = clientServices;
this.sessionService = sessionService;
- this.classLoader = Thread.currentThread().getContextClassLoader();
+ this.workContext = new DQPWorkContext();
+ DQPWorkContext.setWorkContext(this.workContext);
this.logon = this.getService(ILogon.class);
this.result = authenticate(connectionProperties);
- this.workContext = DQPWorkContext.getWorkContext();
}
public synchronized LogonResult authenticate(Properties connProps) throws ConnectionException, CommunicationException {
@@ -97,11 +96,9 @@
Throwable exception = null;
ClassLoader current = Thread.currentThread().getContextClassLoader();
try {
- Thread.currentThread().setContextClassLoader(classLoader);
DQPWorkContext.setWorkContext(workContext);
-
if (!(iface.equals(ILogon.class))) {
- sessionService.validateSession(workContext.getSessionId());
+ sessionService.validateSession(result.getSessionID());
}
return arg1.invoke(clientServices.getClientService(iface), arg2);
} catch (InvocationTargetException e) {
@@ -122,6 +119,11 @@
}
public void close() {
+ // no-op managed connection close
+ }
+
+ @Override
+ public void reallyClose() {
shutdown(true);
}
@@ -147,6 +149,7 @@
//ignore
}
}
+ this.workContext = null;
this.shutdown = true;
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -40,7 +40,6 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
import com.metamatrix.core.CoreConstants;
-import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.Credentials;
import com.metamatrix.platform.security.api.ILogon;
@@ -52,12 +51,10 @@
private SessionService service;
private String clusterName;
- private ClientSideDQP dqpService;
- public LogonImpl(SessionService service, ClientSideDQP dqp, String clusterName) {
+ public LogonImpl(SessionService service, String clusterName) {
this.service = service;
this.clusterName = clusterName;
- this.dqpService = dqp;
}
public LogonResult logon(Properties connProps) throws LogonException,
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -72,7 +72,7 @@
@Test public void testFailedConnect() throws Exception {
ClientServiceRegistry csr = new ClientServiceRegistryImpl();
SessionService sessionService = mock(SessionService.class);
- csr.registerClientService(ILogon.class, new LogonImpl(sessionService, null, "fakeCluster"), "foo"); //$NON-NLS-1$ //$NON-NLS-2$
+ csr.registerClientService(ILogon.class, new LogonImpl(sessionService, "fakeCluster"), "foo"); //$NON-NLS-1$ //$NON-NLS-2$
listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(),
csr, 1024, 1024, 1, null, true, new FakeWorkManager());
@@ -143,7 +143,7 @@
if (listener == null) {
SessionService sessionService = mock(SessionService.class);
ClientServiceRegistry csr = new ClientServiceRegistryImpl();
- csr.registerClientService(ILogon.class, new LogonImpl(sessionService, null, "fakeCluster") { //$NON-NLS-1$
+ csr.registerClientService(ILogon.class, new LogonImpl(sessionService, "fakeCluster") { //$NON-NLS-1$
@Override
public LogonResult logon(Properties connProps)
throws LogonException, ComponentNotFoundException {
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-01-12 18:22:29 UTC (rev 1730)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-01-12 21:02:10 UTC (rev 1731)
@@ -55,7 +55,7 @@
Mockito.stub(ssi.createSession(userName, null, applicationName,p)).toReturn(session);
- LogonImpl impl = new LogonImpl(ssi, null, "fakeCluster"); //$NON-NLS-1$
+ LogonImpl impl = new LogonImpl(ssi, "fakeCluster"); //$NON-NLS-1$
LogonResult result = impl.logon(p);
assertEquals(userName, result.getUserName());
More information about the teiid-commits
mailing list