Author: rareddy
Date: 2009-11-17 08:31:34 -0500 (Tue, 17 Nov 2009)
New Revision: 1569
Added:
branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdminMBean.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingImpl.java
branches/JCA/jboss-integration/src/main/java/org/
branches/JCA/jboss-integration/src/main/java/org/teiid/
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
branches/JCA/runtime/src/main/java/org/teiid/adminapi/
branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/
branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java
Removed:
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMConnectorBinding.java
branches/JCA/common-core/src/main/java/com/metamatrix/common/util/JMXUtil.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java
Modified:
branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml
branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
branches/JCA/client/pom.xml
branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/AdminObject.java
branches/JCA/client/src/main/java/org/teiid/adminapi/ConfigurationAdmin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/ConnectorBinding.java
branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
branches/JCA/jboss-integration/pom.xml
branches/JCA/pom.xml
branches/JCA/runtime/pom.xml
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
branches/JCA/runtime/src/main/java/org/teiid/Server.java
branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java
branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java
branches/JCA/test-integration/db/src/main/resources/ddl/derby/create_tables.sql
branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql
Log:
TEIID-833: Adding basic framework for adding the admin api. Added support for connector
types.
Added: branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
(rev 0)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <interceptor xmlns="urn:jboss:aop-beans:1.0" name="JndiAspect"
class="org.jboss.aop.microcontainer.aspects.jndi.JndiIntroduction">
+ <property name="env">
+ <map class="java.util.Properties"
keyClass="java.lang.String" valueClass="java.lang.String">
+
<entry><key>java.naming.factory.initial</key><value>org.jnp.interfaces.NamingContextFactory</value></entry>
+ </map>
+ </property>
+ </interceptor>
+
+ <introduction xmlns="urn:jboss:aop-beans:1.0"
class="(a)org.jboss.aop.microcontainer.aspects.jndi.JndiBinding">
+
<interfaces>org.jboss.kernel.spi.dependency.KernelControllerContextAware</interfaces>
+ </introduction>
+
+ <bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(*
$instanceof{org.jboss.kernel.spi.dependency.KernelControllerContextAware}->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+ <interceptor-ref name="JndiAspect"/>
+ </bind>
+
+
+ <!-- Add User specific beans here -->
+ <bean name="teiid-admin"
class="org.teiid.adminapi.jboss.Admin">
+
<annotation>(a)org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="teiid/admin")</annotation>
+ </bean>
+
+
+ <!-- Connector Types -->
+ <bean name="connector-jdbc-template"
class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <property name="info"><inject
bean="connector-jdbc-templateinfo"/></property>
+ <property name="targetTemplate"><inject
bean="NoTxConnectionFactoryTemplate"/></property>
+ </bean>
+ <bean name="connector-jdbc-templateinfo"
class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter
class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter
class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+ <parameter
class="java.lang.String">connector-jdbc-template</parameter>
+ <parameter
class="java.lang.String">connector-jdbc-6.3.0-SNAPSHOT.rar</parameter>
+ </constructor>
+ </bean>
+</deployment>
Property changes on: branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml 2009-11-17 13:11:25
UTC (rev 1568)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml 2009-11-17 13:31:34
UTC (rev 1569)
@@ -10,7 +10,7 @@
</no-tx-connection-factory>
<no-tx-connection-factory>
- <jndi-name>teiid-runtime-engine</jndi-name>
+ <jndi-name>teiid/runtime-engine</jndi-name>
<rar-name>teiid-runtime.rar</rar-name>
<connection-definition>com.metamatrix.common.comm.api.ServerConnectionFactory</connection-definition>
<config-property name="DeployPropertiesFile"
type="java.lang.String">/home/rareddy/teiid/teiid-6.3.0/deploy.properties</config-property>
Modified:
branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
===================================================================
---
branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -46,14 +46,12 @@
import com.metamatrix.cache.CacheFactory;
import com.metamatrix.cache.Cache.Type;
import com.metamatrix.cache.CacheConfiguration.Policy;
-import com.metamatrix.common.util.JMXUtil;
-import com.metamatrix.common.util.JMXUtil.FailedToRegisterException;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
@Singleton
public class JBossCacheFactory implements CacheFactory {
- private static final String NAME = "Cache"; //$NON-NLS-1$
+ //private static final String NAME = "Cache"; //$NON-NLS-1$
private org.jboss.cache.Cache cacheStore;
private volatile boolean destroyed = false;
JmxRegistrationManager jmxManager;
@@ -61,19 +59,19 @@
private Properties props;
@Inject
- public JBossCacheFactory(@Named("jmx") JMXUtil jmx,
@Named("DQPProperties") Properties props) {
+ public JBossCacheFactory(@Named("DQPProperties") Properties props) {
this.props = props;
if (this.cacheStore == null) {
this.cacheStore = initCache();
}
- try {
- jmxManager = new JmxRegistrationManager(jmx.getMBeanServer(), cacheStore,
jmx.buildName(JMXUtil.MBeanType.SERVICE, NAME));
- jmxManager.registerAllMBeans();
- } catch (FailedToRegisterException e) {
- throw new MetaMatrixRuntimeException(e.getCause());
- }
+// try {
+// jmxManager = new JmxRegistrationManager(jmx.getMBeanServer(), cacheStore,
jmx.buildName(JMXUtil.MBeanType.SERVICE, NAME));
+// jmxManager.registerAllMBeans();
+// } catch (FailedToRegisterException e) {
+// throw new MetaMatrixRuntimeException(e.getCause());
+// }
}
private org.jboss.cache.Cache initCache() {
Modified: branches/JCA/client/pom.xml
===================================================================
--- branches/JCA/client/pom.xml 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/client/pom.xml 2009-11-17 13:31:34 UTC (rev 1569)
@@ -22,5 +22,10 @@
<artifactId>teiid-common-core</artifactId>
<type>test-jar</type>
</dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Deleted:
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMConnectorBinding.java
===================================================================
---
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMConnectorBinding.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMConnectorBinding.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -1,231 +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.admin.objects;
-
-import java.util.Date;
-
-import org.teiid.adminapi.ConnectorBinding;
-
-import com.metamatrix.admin.AdminPlugin;
-
-
-/**
- * A Connector Binding is a Connector Type with properties that have been
- * bond to a Connector.
- *
- * May are may not be assigned to a VDB
- */
-public class MMConnectorBinding extends MMAdminObject implements ConnectorBinding {
-
- private static final long serialVersionUID = 6919562861762280546L;
- private String routingUUID = ""; //$NON-NLS-1$
- private String description = ""; //$NON-NLS-1$
- private String connectorTypeName = ""; //$NON-NLS-1$
- private int currentState;
- private Date stateChangedTime;
- private long serviceID = -1;
-
-
- /**
- * Constructor.
- * @param identifierParts
- * @since 4.3
- */
- public MMConnectorBinding(String[] identifierParts) {
- super(identifierParts);
- }
-
-
-
-
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.MMConnectorBinding")).append(getIdentifier());
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMConnectorBinding.Description")).append(description);
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMConnectorBinding.Created")).append(getCreatedDate());
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMConnectorBinding.Created_By")).append(getCreatedBy());
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMConnectorBinding.Updated")).append(getLastChangedDate());
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMConnectorBinding.Updated_By")).append(getLastChangedBy());
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMConnectorBinding.State")).append(getState());
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMConnectorBinding.State_Changed")).append(getStateChangedTime());
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMConnectorBinding.IsRegistered")).append(isRegistered());
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMConnectorBinding.Properties")).append(getPropertiesAsString());
//$NON-NLS-1$
- return result.toString();
- }
-
-
-
- /**
- * Returns the description
- * @return description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Set the description
- * @param description
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
-
-
- /**
- * Returns the String globally unique routing UUID for this
- * Connector Binding
- * @return Returns the routingUUID.
- * @since 4.3
- */
- public String getRoutingUUID() {
- return this.routingUUID;
- }
-
- /**
- * @param routingUUID The routingUUID to set.
- * @since 4.3
- */
- public void setRoutingUUID(String routingUUID) {
- this.routingUUID = routingUUID;
- }
-
- /**
- * @return the current state of this connector binding.
- */
- public int getState() {
- return this.currentState;
- }
-
- /**
- * @return Returns the currentState as String.
- * @since 4.3
- */
- public String getStateAsString() {
- switch (currentState) {
- case STATE_OPEN:
- return AdminPlugin.Util.getString("MMConnectorBinding.open");
//$NON-NLS-1$
- case STATE_CLOSED:
- return AdminPlugin.Util.getString("MMConnectorBinding.closed");
//$NON-NLS-1$
- case STATE_FAILED:
- return AdminPlugin.Util.getString("MMConnectorBinding.failed");
//$NON-NLS-1$
- case STATE_INIT_FAILED:
- return
AdminPlugin.Util.getString("MMConnectorBinding.initializationFailed");
//$NON-NLS-1$
- case STATE_NOT_INITIALIZED:
- return
AdminPlugin.Util.getString("MMConnectorBinding.notInitialized"); //$NON-NLS-1$
- case STATE_NOT_REGISTERED:
- return
AdminPlugin.Util.getString("MMConnectorBinding.notRegistered"); //$NON-NLS-1$
- case STATE_DATA_SOURCE_UNAVAILABLE:
- return
AdminPlugin.Util.getString("MMConnectorBinding.dataSourceUnavailable");
//$NON-NLS-1$
- default:
- return
AdminPlugin.Util.getString("MMConnectorBinding.unknown"); //$NON-NLS-1$
- }
- }
-
- /**
- * Set the state
- * @param state
- * @since 4.3
- */
- public void setState(int state) {
- this.currentState = state;
-
- //check on what states mean "registered"
- setRegistered(currentState==STATE_OPEN || currentState==STATE_FAILED ||
currentState==STATE_DATA_SOURCE_UNAVAILABLE);
- }
-
-
- /**
- * @return Returns time of last state change.
- * @since 4.3
- */
- public Date getStateChangedTime() {
- return stateChangedTime;
- }
-
- /**
- * Set the state changed time
- * @param stateChangedTime
- * @since 4.3
- */
- public void setStateChangedTime(Date stateChangedTime) {
- this.stateChangedTime = stateChangedTime;
- }
-
-
- /**
- * @return Returns the serviceID.
- * @since 4.3
- */
- public long getServiceID() {
- return this.serviceID;
- }
-
- /**
- * @param serviceID The serviceID to set.
- * @since 4.3
- */
- public void setServiceID(long serviceID) {
- this.serviceID = serviceID;
- }
-
-
- /**
- * @return Returns the processID.
- * @since 4.3
- */
- public String getProcessName() {
- return identifierParts[1];
- }
-
-
- /**
- * @return Returns the hostName.
- * @since 4.3
- */
- public String getHostName() {
- return identifierParts[0];
- }
-
-
- /**
- * @param connectorTypeName the identifier for a connector type
- * @since 4.3
- */
- public void setConnectorTypeName(String connectorTypeName) {
- this.connectorTypeName = connectorTypeName;
- }
-
- /**
- * @see org.teiid.adminapi.ConnectorBinding#getConnectorTypeName()
- * @since 4.3
- */
- public String getConnectorTypeName() {
- return this.connectorTypeName;
- }
-}
\ No newline at end of file
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java 2009-11-17 13:11:25
UTC (rev 1568)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java 2009-11-17 13:31:34
UTC (rev 1569)
@@ -22,10 +22,5 @@
package org.teiid.adminapi;
-/**
- * Marker interface for all MetaMatrix administration - core.
- *
- * @since 4.3
- */
public interface Admin extends ConfigurationAdmin, MonitoringAdmin, RuntimeStateAdmin,
SecurityAdmin {
}
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/AdminObject.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/AdminObject.java 2009-11-17
13:11:25 UTC (rev 1568)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/AdminObject.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -22,6 +22,7 @@
package org.teiid.adminapi;
+import java.io.Serializable;
import java.util.Properties;
/**
@@ -36,7 +37,7 @@
*
* @since 4.3
*/
-public interface AdminObject {
+public interface AdminObject extends Serializable {
/**
* The character that delimits the atomic components of the identifier.
@@ -76,17 +77,7 @@
*/
public static final String ESCAPED_WILDCARD = "\\" + WILDCARD;
//$NON-NLS-1$
-
/**
- * Get the Full Name for this AdminObject. This identifier will uniquely identify
this object in the Teiid
- * system.
- *
- * @return String the unique Identifier
- * @since 4.3
- */
- String getIdentifier();
-
- /**
* Get the name for this AdminObject, usually the last component of the identifier.
*
* @return String Name
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/ConfigurationAdmin.java
===================================================================
---
branches/JCA/client/src/main/java/org/teiid/adminapi/ConfigurationAdmin.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/client/src/main/java/org/teiid/adminapi/ConfigurationAdmin.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -107,63 +107,21 @@
/**
* Deploy a {@link ConnectorBinding} to Configuration
*
- * @param name
- * is the Connector Binding name that will be added to Configuration
- * @param connectorTypeIdentifier
- * Name of the Connector Type
- * @param properties
- * Name & Value pair need to deploy the Connector Binding
- * @param options The perferred options when executing this method. There are choices
about
- * what to do when a connector binding with the given identifier already exists in
the system.
- * See the interface {@link AdminOptions.OnConflict} for details.
- * <p>
- * Another option is to ignore a binding connection password decrypt error, when
adding a connector
- * binding whose password was encrypted with a different keystore, so that the new
password property
- * can be set after the connector binding has been added.</p>
- * @throws AdminException
- * if there's a system error.
- * @return the {@link ConnectorBinding} representing the current property values and
runtime state.
- * Note that if this is a system with multiple Processes, this method may actually
create multiple deployed
- * Connector Bindings (one for each process). This method will return one of them,
arbitrarily.
- * @since 4.3
- */
- ConnectorBinding addConnectorBinding(String name,
- String connectorTypeIdentifier,
- Properties properties, AdminOptions options) throws
AdminException;
+ * @param deployedName Connector Binding name that will be added to Configuration
+ * @param typeName Connector type name.
+ * @param properties Name & Value pair need to deploy the Connector Binding
- /**
- * Import a {@link ConnectorBinding} into the Configuration.
- *
- * @param name
- * is the Connector Binding name that will be added to Configuration
- * @param xmlFile
- * contents of XML file that will be sent to the server.
- * @param options The perferred options when executing this method. There are choices
about
- * what to do when a connector binding with the given identifier already exists in
the system.
- * See the interface {@link AdminOptions.OnConflict} for details.
- * <p>
- * Another option is to ignore a binding connection password decrypt error, when
adding a connector
- * binding whose password was encrypted with a different keystore, so that the new
password property
- * can be set after the connector binding has been added.</p>
- * @throws AdminException
- * if there's a system error.
- * @return the {@link ConnectorBinding} representing the current property values and
runtime state.
- * Note that if this is a system with multiple Processes, this method may actually
create multiple deployed
- * Connector Bindings (one for each process). This method will return one of them,
arbitrarily.
- * @since 4.3
+ * @throws AdminException if there's a system error.
*/
- ConnectorBinding addConnectorBinding(String name,
- char[] xmlFile, AdminOptions options) throws
AdminException;
+ void addConnectorBinding(String deployedName, String typeName, Properties properties)
throws AdminException;
/**
* Delete the {@link ConnectorBinding} from the Configuration
*
- * @param connectorBindingIdentifier
- * @throws AdminException
- * if there's a system error.
- * @since 4.3
+ * @param deployedName - deployed name of the connector binding
+ * @throws AdminException if there's a system error.
*/
- void deleteConnectorBinding(String connectorBindingIdentifier) throws
AdminException;
+ void deleteConnectorBinding(String deployedName) throws AdminException;
/**
* Import a {@link VDB} file.
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/ConnectorBinding.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/ConnectorBinding.java 2009-11-17
13:11:25 UTC (rev 1568)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/ConnectorBinding.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -22,83 +22,21 @@
package org.teiid.adminapi;
-import java.util.Date;
/**
- * Represents a connector binding (the instance of a connector type) in the MetaMatrix
system.
- *
- * <p>The unique identifier pattern is [host]<{@link
#DELIMITER}>[process]<{@link #DELIMITER}>[Connector Binding Name]
- * when running against a MetaMatrix server. The [Connector Binding Name] can itself have
spaces in the name.
- * In the case of the MM Query, the [host] and [process] do not apply as MM Query is
always local.</p>
- *
- * @since 4.3
+ * Represents a connector binding (the instance of a connector type) in the Teiid
system.
*/
-public interface ConnectorBinding extends
- AdminObject {
- /**Registered by not initialized*/
- public static final int STATE_NOT_INITIALIZED = 0;
- /**Open and running*/
- public static final int STATE_OPEN = 1;
- /**Registered but closed*/
- public static final int STATE_CLOSED = 2;
- /**Failed after running successfully*/
- public static final int STATE_FAILED = 3;
- /**Failed during initialization*/
- public static final int STATE_INIT_FAILED = 4;
- /**Not registered*/
- public static final int STATE_NOT_REGISTERED = 5;
- /**Running, but the underlying data source is unavailable*/
- public static final int STATE_DATA_SOURCE_UNAVAILABLE = 6;
- /**Running, not deployed*/
- public static final int STATE_NOT_DEPLOYED = 7;
- /** failed to check the status */
- public static final int STATE_FAILED_TO_CHECK = 8;
+public interface ConnectorBinding extends AdminObject {
- /** Password connector property name */
- public static final String PASSWORD = "Password"; //$NON-NLS-1$
-
-
/**
- * Retrieve the current connector state. This will be one of the constants:
- * {@link ConnectorBinding#STATE_OPEN DQP.STATE_OPEN}.
- * {@link ConnectorBinding#STATE_NOT_INITIALIZED DQP.STATE_NOT_INITIALIZED}.
- * {@link ConnectorBinding#STATE_CLOSED DQP.STATE_CLOSED}.
- * {@link ConnectorBinding#STATE_FAILED DQP.STATE_FAILED}.
- * {@link ConnectorBinding#STATE_INIT_FAILED DQP.STATE_INIT_FAILED}.
- * {@link ConnectorBinding#STATE_NOT_REGISTERED DQP.STATE_NOT_REGISTERED}.
- * {@link ConnectorBinding#STATE_DATA_SOURCE_UNAVAILABLE
DQP.STATE_DATA_SOURCE_UNAVAILABLE}.
- * {@link ConnectorBinding#STATE_NOT_DEPLOYED DQP.STATE_NOT_DEPLOYED}.
- * @return current connector state.
+ * Get the identifier for this connector binding's RAR file name
+ * @return Name of the RAR file used to create this binding
*/
- int getState();
+ String getRARFileName();
/**
- * Retrieve the current connector state as a printable
<code>String</code>.
- * @return current connector state in String form.
+ * Get the JNDI Name of this connector
+ * @return
*/
- String getStateAsString();
-
- /**
- * Returns time of last state change.
- *
- * @return time of last state change.
- * @since 4.3
- */
- Date getStateChangedTime();
-
- /**
- * Returns the description
- *
- * @return description
- */
- String getDescription();
-
- /**
- * Get the identifier for this connector binding's {@link ConnectorType}.
- * @return the Connector Type identifier which can be used to
- * find the ConnectorType.
- * @since 4.3
- */
- String getConnectorTypeName();
-
+ String getJNDIName();
}
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java 2009-11-17
13:11:25 UTC (rev 1568)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -23,6 +23,7 @@
package org.teiid.adminapi;
import java.util.Collection;
+import java.util.Set;
import com.metamatrix.admin.RolesAllowed;
@@ -39,19 +40,12 @@
public interface MonitoringAdmin {
/**
- * Get the Connector Types that correspond to the specified identifier pattern.
+ * Get the Connector Types available in the configuration.
*
- * @param connectorTypeIdentifier the unique identifier for for a {@link
ConnectorType}
- * <ul>
- * <li> <code>"*"</code> - for all connector types
in the system
- * <li> <code>"name*"</code> - for all the connector
types that begin with given name
- * <li> <code>"name"</code> - for the single
connector type identified by name
- * </ul>
- * @return Collection of {@link ConnectorType}
+ * @return Set of connector types.
* @throws AdminException if there's a system error.
- * @since 4.3
*/
- Collection<ConnectorType> getConnectorTypes(String connectorTypeIdentifier)
throws AdminException;
+ Set<String> getConnectorTypes() throws AdminException;
/**
* Get the VDBs that correspond to the specified identifier pattern.
@@ -71,19 +65,20 @@
Collection<VDB> getVDBs(String vdbIdentifier) throws AdminException;
/**
- * Get the Connector Bindings that correspond to the specified identifier pattern.
+ * Get the Connector Bindings that are available in the configuration
*
- * @param connectorBindingIdentifier the unique identifier pattern of {@link
ConnectorBinding}
- * <ul>
- * <li> <code>"*"</code> - for all connector
bindings in the system
- * <li> <code>"name*"</code> - for all connector
bindings that begin with given name
- * <li><code>"name"</code> - for single connector
binding by the given name
- * </ul>
* @return Collection of {@link ConnectorBinding}
* @throws AdminException if there's a system error.
- * @since 4.3
*/
- Collection<ConnectorBinding> getConnectorBindings(String
connectorBindingIdentifier) throws AdminException;
+ Collection<ConnectorBinding> getConnectorBindings() throws AdminException;
+
+ /**
+ * Get the connector binding by the given the deployed name.
+ * @param deployedName - name of the deplyed connector binding
+ * @return null if not found a connector binding by the given name
+ * @throws AdminException if there's a system error.
+ */
+ ConnectorBinding getConnectorBinding(String deployedName) throws AdminException;
/**
* Get all the Connector Bindings for the given VDB identifier pattern
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
(rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,402 @@
+/*
+ * 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.adminapi;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+
+import javax.transaction.xa.Xid;
+
+
+public abstract class TeiidAdmin implements TeiidAdminMBean, Serializable {
+
+ @Override
+ public void addConnectorArchive(byte[] archiveContents, AdminOptions options)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+
+ @Override
+ public void addConnectorType(String name, char[] cdkFile)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void addExtensionModule(String type, String sourceName,
+ byte[] source, String description) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void addUDF(byte[] modelFileContents, String classpath)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public VDB addVDB(String name, byte[] vdbFile, AdminOptions options)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void assignBindingToModel(String connectorBindingName,
+ String vdbName, String vdbVersion, String modelName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void assignBindingsToModel(String[] connectorBindingName,
+ String vdbName, String vdbVersion, String modelName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteConnectorBinding(String connectorBindingIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteConnectorType(String name) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteExtensionModule(String sourceName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteUDF() throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteVDB(String vdbName, String version) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public char[] exportConfiguration() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] exportConnectorArchive(String connectorTypeIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public char[] exportConnectorBinding(String connectorBindingIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public char[] exportConnectorType(String connectorTypeIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] exportExtensionModule(String sourceName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] exportVDB(String name, String version) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void extensionModuleModified(String name) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public LogConfiguration getLogConfiguration() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setConnectorBindingProperty(String deployedName,
+ String propertyName, String propertyValue) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setLogConfiguration(LogConfiguration config)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setLogListener(EmbeddedLogger listener) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setProcessProperty(String processIdentifier,
+ String propertyName, String propertyValue) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Collection<Cache> getCaches(String identifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<? extends ConnectionPool> getConnectionPoolStats(
+ String identifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<ConnectorBinding> getConnectorBindingsInVDB(
+ String vdbName, String vdbVersion) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<PropertyDefinition> getConnectorTypePropertyDefinitions(
+ String connectorTypeIdentifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<ExtensionModule> getExtensionModules(
+ String extensionModuleIdentifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ public Collection<QueueWorkerPool> getQueueWorkerPools(String identifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Request> getRequests(String identifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Session> getSessions(String identifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Request> getSourceRequests(String identifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Transaction> getTransactions() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<VDB> getVDBs(String vdbIdentifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void cancelRequest(String identifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void cancelSourceRequest(String identifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void changeVDBStatus(String name, String version, int status)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearCache(String cacheIdentifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void restart() throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void shutdown(int millisToWait) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void startConnectorBinding(String connectorBindingIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stopConnectorBinding(String connectorBindingIdentifier,
+ boolean stopNow) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void terminateSession(String identifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void terminateTransaction(Xid transactionId) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void terminateTransaction(String transactionId, String sessionId)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void assignRoleToGroup(String roleIdentifier, String groupIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public char[] exportDataRoles(String vdbName, String vdbVersion)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> getDomainNames() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Group> getGroups(String groupIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Group> getGroupsForDomain(String domainName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Group> getGroupsForUser(String userIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Role> getRolesForGroup(String groupIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String importDataRoles(String vdbName, String vdbVersion,
+ char[] data, AdminOptions options) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void removeRoleFromGroup(String roleIdentifier,
+ String groupIdentifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+}
Property changes on: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdminMBean.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdminMBean.java
(rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdminMBean.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,27 @@
+/*
+ * 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.adminapi;
+
+
+public interface TeiidAdminMBean extends Admin {
+}
Property changes on:
branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdminMBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
(rev 0)
+++
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,64 @@
+/*
+ * 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.adminapi.impl;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+import org.teiid.adminapi.AdminObject;
+
+public class AdminObjectImpl implements AdminObject, Serializable {
+
+ private static final long serialVersionUID = -6381303538713462682L;
+ String name;
+ Properties properties;
+
+ public AdminObjectImpl(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public Properties getProperties() {
+ return this.properties;
+ }
+
+ @Override
+ public String getPropertyValue(String name) {
+ return this.properties.getProperty(name);
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = new Properties(properties);
+ }
+
+ public void addProperty(String key, String value) {
+ if (this.properties == null) {
+ this.properties = new Properties();
+ }
+ this.properties.setProperty(key, value);
+ }
+}
Property changes on:
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingImpl.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingImpl.java
(rev 0)
+++
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * 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.adminapi.impl;
+
+import org.teiid.adminapi.ConnectorBinding;
+
+public class ConnectorBindingImpl extends AdminObjectImpl implements ConnectorBinding {
+
+ private static final long serialVersionUID = -4865836616882247016L;
+ private transient Object type;
+
+ public ConnectorBindingImpl(String name) {
+ super(name);
+ }
+
+ @Override
+ public String getRARFileName() {
+ return getPropertyValue("rar-name");
+ }
+
+ @Override
+ public String getJNDIName() {
+ return getPropertyValue("jndi-name");
+ }
+
+ public void setComponentType(Object type) {
+ this.type = type;
+ }
+
+ public Object getComponentType() {
+ return this.type;
+ }
+}
Property changes on:
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/JCA/common-core/src/main/java/com/metamatrix/common/util/JMXUtil.java
===================================================================
---
branches/JCA/common-core/src/main/java/com/metamatrix/common/util/JMXUtil.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/common-core/src/main/java/com/metamatrix/common/util/JMXUtil.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package com.metamatrix.common.util;
-
-import java.lang.management.ManagementFactory;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-
-import com.metamatrix.core.MetaMatrixCoreException;
-
-public class JMXUtil {
- public enum MBeanType {SERVICE, SERVER, UTIL, ADMINAPI};
-
- String processName;
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-
- public JMXUtil(String processName) {
- this.processName = processName;
- }
-
- public ObjectName buildName(MBeanType type, String name) throws
FailedToRegisterException {
- try {
- return new
ObjectName("Teiid["+processName+"]:type="+type+",name="+name);
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (MalformedObjectNameException e) {
- throw new FailedToRegisterException(e);
- }
- }
-
- public void register(MBeanType type, String name, Object anObj) throws
FailedToRegisterException {
- try {
- mbs.registerMBean(anObj, buildName(type, name));
- } catch (InstanceAlreadyExistsException e) {
- throw new FailedToRegisterException(e);
- } catch (MBeanRegistrationException e) {
- throw new FailedToRegisterException(e);
- } catch (NotCompliantMBeanException e) {
- throw new FailedToRegisterException(e);
- }
- }
-
- public void unregister(MBeanType type, String name) throws FailedToRegisterException {
- try {
- mbs.unregisterMBean(buildName(type, name));
- } catch (InstanceNotFoundException e) {
- throw new FailedToRegisterException(e);
- } catch (MBeanRegistrationException e) {
- throw new FailedToRegisterException(e);
- }
- }
-
- public MBeanServer getMBeanServer() {
- return mbs;
- }
-
- public static class FailedToRegisterException extends MetaMatrixCoreException{
- public FailedToRegisterException(Throwable e) {
- super(e);
- }
- }
-
-}
Modified:
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
---
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -174,7 +174,7 @@
private void enqueueRequest(ConnectorWorkItem work) throws ConnectorException {
try {
- // the connector is immutable, then we do not want pass-on the transaction
context.
+ // if connector is immutable, then we do not want pass-on the transaction
context.
if (work.securityContext.isTransactional()) {
this.workManager.scheduleWork(work, 0, work.requestMsg.getTransactionContext(),
work);
}
Modified:
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
===================================================================
---
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -87,11 +87,11 @@
this.notify();
}
- private void acquireTransactionLock() throws InterruptedException {
- TransactionContext tc = this.requestMsg.getTransactionContext();
- if ( tc == null) {
+ private void acquireTransactionLock() throws InterruptedException {
+ if (!this.requestMsg.isTransactional()) {
return;
}
+ TransactionContext tc = this.requestMsg.getTransactionContext();
Xid key = tc.getXid();
TransactionLock existing = null;
@@ -110,10 +110,10 @@
}
private void releaseTxnLock() {
+ if (!this.requestMsg.isTransactional() || this.lock == null) {
+ return;
+ }
TransactionContext tc = this.requestMsg.getTransactionContext();
- if ( tc == null || this.lock == null) {
- return;
- }
synchronized (TRANSACTION_LOCKS) {
lock.pendingCount--;
if (lock.pendingCount == 0) {
Modified: branches/JCA/jboss-integration/pom.xml
===================================================================
--- branches/JCA/jboss-integration/pom.xml 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/jboss-integration/pom.xml 2009-11-17 13:31:34 UTC (rev 1569)
@@ -18,12 +18,37 @@
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-internal</artifactId>
+ <artifactId>teiid-engine</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-engine</artifactId>
+ <artifactId>teiid-runtime</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-profileservice-spi</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-connector</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-aop-mc-int</artifactId>
+ <version>2.0.6.GA</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Deleted:
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -1,657 +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.dqp.embedded.admin;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminObject;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Cache;
-import org.teiid.adminapi.ExtensionModule;
-import org.teiid.adminapi.Session;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.dqp.internal.process.Util;
-
-import com.metamatrix.admin.objects.MMConnectorBinding;
-import com.metamatrix.admin.objects.MMConnectorType;
-import com.metamatrix.admin.objects.MMExtensionModule;
-import com.metamatrix.admin.objects.MMLogConfiguration;
-import com.metamatrix.admin.objects.MMModel;
-import com.metamatrix.admin.objects.MMPropertyDefinition;
-import com.metamatrix.admin.objects.MMRequest;
-import com.metamatrix.admin.objects.MMSession;
-import com.metamatrix.admin.objects.MMVDB;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.security.SessionServiceException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ComponentTypeDefn;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.log.LogConfigurationImpl;
-import com.metamatrix.common.object.PropertyDefinition;
-import com.metamatrix.common.util.crypto.CryptoException;
-import com.metamatrix.common.util.crypto.CryptoUtil;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.ConfigurationService;
-import com.metamatrix.dqp.service.ConnectorStatus;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-import com.metamatrix.platform.security.api.SessionToken;
-import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
-import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-import com.metamatrix.platform.util.ProductInfoConstants;
-import com.metamatrix.server.serverapi.RequestInfo;
-
-
-/**
- * @since 4.3
- */
-abstract class BaseAdmin {
- static final String DOT = "."; //$NON-NLS-1$
- static final String STAR = "*"; //$NON-NLS-1$
- static final String FILE_NAME_REGEX="\\w+\\.\\w+"; //$NON-NLS-1$
- static final String MULTIPLE_WORDS_REGEX = "\\w+([\\s|-]*\\w)*";
//$NON-NLS-1$
- static final String SINGLE_WORD_REGEX = "\\w+"; //$NON-NLS-1$
- static final String MULTIPLE_WORD_WILDCARD_REGEX =
"\\w*((\\.)?\\s*\\w)*(\\*)?"; //$NON-NLS-1$
- static final String SINGLE_WORD_WILDCARD_REGEX = "\\w*(\\*)?";
//$NON-NLS-1$
- // This should find word.word.* or word.* kind of patterns (ugly, you can rewrite)
- static final String WORD_AND_DOT_WILDCARD_REGEX =
"\\w+((\\.\\*)|(\\.\\w+)|(\\.\\w*\\*))*|\\w*(\\*){1}"; //$NON-NLS-1$
-
- static final String VDB_REGEX = "\\w*(\\*)?(\\.\\d+)?"; //$NON-NLS-1$
- static final String NUMBER_DOT_REGEX =
"\\d+((\\.\\*)|(\\.\\d+)|(\\.\\d*\\*))*|\\d*(\\*){1}"; //$NON-NLS-1$
- static final String NUMBER_REGEX = "\\d*(\\*)?"; //$NON-NLS-1$
-
- static final String[] cacheTypes = {Cache.CODE_TABLE_CACHE,
- Cache.CONNECTOR_RESULT_SET_CACHE,
- Cache.PREPARED_PLAN_CACHE,
- Cache.QUERY_SERVICE_RESULT_SET_CACHE
- };
-
- private EmbeddedConnectionFactoryImpl manager = null;
-
- BaseAdmin(EmbeddedConnectionFactoryImpl manager){
- this.manager = manager;
- }
-
- protected AdminException accumulateSystemException(AdminException parent, Exception
e) {
- if (parent == null) {
- return new AdminComponentException(e);
- }
- parent.addChild(new AdminComponentException(e));
- return parent;
- }
-
- protected AdminException accumulateProcessingException(AdminException parent,
Exception e) {
- if (parent == null) {
- return new AdminProcessingException(e);
- }
- parent.addChild(new AdminProcessingException(e));
- return parent;
- }
-
- protected String prettyPrintBindingNames(List bindings) {
- StringBuffer buffer = new StringBuffer();
- for (Iterator iter = bindings.iterator(); iter.hasNext();) {
- ConnectorBinding binding = (ConnectorBinding) iter.next();
- buffer.append(binding.getDeployedName());
- if (iter.hasNext()) {
- buffer.append(", "); //$NON-NLS-1$
- }
- }
-
- return buffer.toString();
- }
-
- /**
- * @return Returns the manager.
- * @since 4.3
- */
- public EmbeddedConnectionFactoryImpl getManager() {
- return this.manager;
- }
-
- VDBService getVDBService() {
- return (VDBService)getManager().findService(DQPServiceNames.VDB_SERVICE);
- }
-
- DataService getDataService() {
- return (DataService)getManager().findService(DQPServiceNames.DATA_SERVICE);
- }
-
- TransactionService getTransactionService() {
- return
(TransactionService)getManager().findService(DQPServiceNames.TRANSACTION_SERVICE);
- }
-
- MembershipServiceInterface getMembershipService() {
- return
(MembershipServiceInterface)getManager().findService(DQPServiceNames.MEMBERSHIP_SERVICE);
- }
-
- AuthorizationService getAuthorizationService() {
- return
(AuthorizationService)getManager().findService(DQPServiceNames.AUTHORIZATION_SERVICE);
- }
-
- ConfigurationService getConfigurationService() {
- return
(ConfigurationService)getManager().findService(DQPServiceNames.CONFIGURATION_SERVICE);
- }
-
- SessionServiceInterface getSessionService() {
- return
(SessionServiceInterface)getManager().findService(DQPServiceNames.SESSION_SERVICE);
- }
-
- protected Object convertToAdminObjects(Object src) {
- return convertToAdminObjects(src,null);
- }
-
- protected Object convertToAdminObjects(Object src, Object parent) {
- if (src == null) {
- return src;
- }
-
- if (src instanceof List) {
- List modified = new ArrayList();
- List list = (List)src;
- for (final Iterator i = list.iterator(); i.hasNext();) {
- final Object e = i.next();
- Object converted = convertToAdminObject(e, parent);
- modified.add(converted);
- }
- return modified;
- }
- else if (src instanceof Collection) {
- List modified = new ArrayList();
- for (Iterator i = ((Collection)src).iterator(); i.hasNext();) {
- final Object e = i.next();
- Object converted = convertToAdminObject(e, parent);
- modified.add(converted);
- }
- return modified;
- }
- else if (src instanceof Object[] ) {
- List modified = new ArrayList();
- Object[] srcArray = (Object[])src;
- for (int i = 0; i < srcArray.length; i++) {
- final Object converted = convertToAdminObject(srcArray[i], parent);
- modified.add(converted);
- }
- return modified;
- }
- return convertToAdminObject(src, parent);
- }
-
-
- private Object convertToAdminObject(Object src, Object parent) {
- if (src != null && src instanceof
com.metamatrix.common.config.api.ConnectorBinding) {
- com.metamatrix.common.config.api.ConnectorBinding binding =
(com.metamatrix.common.config.api.ConnectorBinding)src;
- return convertConnectorType(binding, parent);
- }
- else if (src != null && src instanceof
com.metamatrix.common.config.api.ConnectorBindingType) {
- com.metamatrix.common.config.api.ConnectorBindingType type =
(com.metamatrix.common.config.api.ConnectorBindingType)src;
- return convertConnectorType(type, parent);
- }
- else if (src != null && src instanceof
com.metamatrix.common.vdb.api.VDBDefn) {
- com.metamatrix.common.vdb.api.VDBDefn vdb =
(com.metamatrix.common.vdb.api.VDBDefn)src;
- return convertVDB(vdb, parent);
- }
- else if (src != null && src instanceof VDBArchive) {
- VDBArchive vdb = (VDBArchive)src;
- return convertVDB(vdb.getConfigurationDef(), parent);
- }
- else if (src != null && src instanceof
com.metamatrix.common.vdb.api.ModelInfo) {
- com.metamatrix.common.vdb.api.ModelInfo model =
(com.metamatrix.common.vdb.api.ModelInfo)src;
- return convertModel(model, parent);
- }
- else if (src != null && src instanceof
com.metamatrix.common.log.LogConfiguration) {
- com.metamatrix.common.log.LogConfiguration config =
(com.metamatrix.common.log.LogConfiguration)src;
- return covertLogConfiguration(config);
- }
- else if (src != null && src instanceof
com.metamatrix.server.serverapi.RequestInfo) {
- com.metamatrix.server.serverapi.RequestInfo request =
(com.metamatrix.server.serverapi.RequestInfo)src;
- return convertRequest(request);
- }
- else if (src != null && src instanceof
com.metamatrix.common.queue.WorkerPoolStats) {
- com.metamatrix.common.queue.WorkerPoolStats stats =
(com.metamatrix.common.queue.WorkerPoolStats)src;
- return Util.convertStats(stats, stats.getQueueName());
- }
- else if (src != null && src instanceof MetaMatrixSessionInfo) {
- MetaMatrixSessionInfo conn = (MetaMatrixSessionInfo)src;
- return convertConnection(conn);
- }
- else if (src != null && src instanceof
com.metamatrix.common.config.api.ExtensionModule) {
- com.metamatrix.common.config.api.ExtensionModule extModule =
(com.metamatrix.common.config.api.ExtensionModule)src;
- return convertExtensionModule(extModule);
- }
- else {
- if (src == null) {
- return null;
- }
- throw new
UnsupportedOperationException(DQPEmbeddedPlugin.Util.getString("UnSupported_object_conversion"));
//$NON-NLS-1$
- }
- }
-
- Object convertToNativeObjects(Object src) {
- if (src instanceof org.teiid.adminapi.LogConfiguration) {
- org.teiid.adminapi.LogConfiguration config =
(org.teiid.adminapi.LogConfiguration)src;
- return covertToNativeLogConfiguration(config);
- }
- throw new
UnsupportedOperationException(DQPEmbeddedPlugin.Util.getString("UnSupported_object_conversion"));
//$NON-NLS-1$
- }
-
-
- private ExtensionModule
convertExtensionModule(com.metamatrix.common.config.api.ExtensionModule src) {
- MMExtensionModule module = new MMExtensionModule(new String[]
{src.getFullName()}) ;
- module.setDescription(src.getDescription());
- module.setFileContents(src.getFileContents());
- module.setModuleType(src.getModuleType());
- return module;
- }
-
- private Session convertConnection(MetaMatrixSessionInfo src) {
- MMSession session = new MMSession(new String[] {src.getSessionID().toString()});
- session.setVDBName(src.getProductInfo(ProductInfoConstants.VIRTUAL_DB));
- session.setVDBVersion(src.getProductInfo(ProductInfoConstants.VDB_VERSION));
- session.setApplicationName(src.getApplicationName());
- session.setIPAddress(src.getClientIp());
- session.setHostName(src.getClientHostname());
- session.setUserName(src.getUserName());
- session.setLastPingTime(src.getLastPingTime());
- session.setCreated(new Date(src.getTimeCreated()));
- return session;
- }
-
- /**
- * Convert LogConfiguration to Admin Object
- */
- private org.teiid.adminapi.LogConfiguration covertLogConfiguration(final
com.metamatrix.common.log.LogConfiguration src) {
- Map<String, Integer> contextMap = new HashMap<String, Integer>();
- for(String context:src.getContexts()) {
- contextMap.put(context, src.getLogLevel(context));
- }
- return new MMLogConfiguration(contextMap);
- }
-
- /**
- * Convert LogConfiguration to Admin Object
- */
- private com.metamatrix.common.log.LogConfiguration
covertToNativeLogConfiguration(final org.teiid.adminapi.LogConfiguration src) {
- Map<String, Integer> contextMap = new HashMap<String, Integer>();
- for(String context:src.getContexts()) {
- contextMap.put(context, src.getLogLevel(context));
- }
- return new LogConfigurationImpl(contextMap);
- }
-
- /**
- * @param binding
- * @return
- * @since 4.3
- */
- private org.teiid.adminapi.ConnectorBinding convertConnectorType(final
com.metamatrix.common.config.api.ConnectorBinding src, final Object parent) {
- MMConnectorBinding binding = new MMConnectorBinding(new String[]
{src.getDeployedName()});
-
- binding.setConnectorTypeName(src.getComponentTypeID().getFullName());
- binding.setCreated(src.getCreatedDate());
- binding.setCreatedBy(src.getCreatedBy());
- binding.setDescription(src.getDescription());
- binding.setEnabled(src.isEnabled());
- binding.setLastUpdated(src.getLastChangedDate());
- binding.setLastUpdatedBy(src.getLastChangedBy());
- binding.setProperties(src.getProperties());
- binding.setRegistered(true);
- binding.setRoutingUUID(src.getRoutingUUID());
- binding.setServiceID(0); // TODO:
-
- // Binding state needs to be converted into pool state; until then we use
- // binding state as pool state.
-// try {
-// ConnectorStatus status =
getDataService().getConnectorBindingState(src.getDeployedName());
-// switch(status) {
-// case OPEN:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_OPEN);
-// break;
-// case NOT_INITIALIZED:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_NOT_INITIALIZED);
-// break;
-// case CLOSED:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_CLOSED);
-// break;
-// case DATA_SOURCE_UNAVAILABLE:
-//
binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_DATA_SOURCE_UNAVAILABLE);
-// break;
-// case INIT_FAILED:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_INIT_FAILED);
-// break;
-// case UNABLE_TO_CHECK:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_FAILED_TO_CHECK);
-// break;
-// }
-// }catch(MetaMatrixComponentException e) {
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_NOT_DEPLOYED);
-// }
- binding.setStateChangedTime(src.getLastChangedDate());
- return binding;
- }
-
- /**
- * @param type
- * @return
- * @since 4.3
- */
- private org.teiid.adminapi.ConnectorType convertConnectorType(final
com.metamatrix.common.config.api.ConnectorBindingType src, final Object parent) {
- MMConnectorType type = new MMConnectorType(new String[] {src.getName()});
- type.setCreated(src.getCreatedDate());
- type.setCreatedBy(src.getCreatedBy());
- type.setEnabled(true);
- type.setLastUpdated(src.getLastChangedDate());
- type.setRegistered(true);
-
- return type;
- }
-
- /**
- * @param vdb
- * @return
- * @since 4.3
- */
- private org.teiid.adminapi.VDB convertVDB(final com.metamatrix.common.vdb.api.VDBDefn
src, final Object parent) {
-
- MMVDB vdb = new MMVDB(new String[] {src.getName(), src.getVersion()});
- vdb.setCreated(src.getDateCreated());
- vdb.setCreatedBy(src.getCreatedBy());
- vdb.setEnabled(src.isActiveStatus());
- vdb.setLastUpdated(src.getDateCreated());
- vdb.setLastUpdatedBy(src.getCreatedBy());
- vdb.setMaterializedViews(src.getMatertializationModel() != null);
- vdb.setModels((Collection)convertToAdminObjects(src.getModels(), src));
- vdb.setProperties(null);
- vdb.setRegistered(true);
- vdb.setStatus(src.getStatus());
- vdb.setUID(0); // TODO: src.getUUID());
- vdb.setVersionedBy(src.getCreatedBy());
- vdb.setVersionedDate(src.getDateCreated());
- vdb.setHasWSDL(src.hasWSDLDefined());
-
- return vdb;
- }
-
- private org.teiid.adminapi.Model convertModel(final
com.metamatrix.common.vdb.api.ModelInfo src, final Object parent) {
- final com.metamatrix.common.vdb.api.VDBDefn vdb =
(com.metamatrix.common.vdb.api.VDBDefn)parent;
- MMModel model = new MMModel(new String[] {src.getName()});
- model.setCreated(vdb.getDateCreated());
- model.setCreatedBy(vdb.getCreatedBy());
- model.setEnabled(vdb.isActiveStatus());
- model.setLastUpdated(vdb.getDateCreated());
- model.setLastUpdatedBy(vdb.getCreatedBy());
- model.setModelType(src.getModelTypeName());
- model.setModelURI(src.getModelURI());
- model.setMaterialization(src.isMaterialization());
- model.setPhysical(src.isPhysical());
- model.setRegistered(true);
- model.setSupportsMultiSourceBindings(src.isMultiSourceBindingEnabled());
- model.setVisible(src.isVisible());
- if (src.isPhysical()) {
- List bindings = src.getConnectorBindingNames();
- if (bindings != null && !bindings.isEmpty()) {
- List names = new ArrayList();
- for (int i=0; i<bindings.size();i++) {
-
names.add(convertToAdminObject(vdb.getConnectorBindingByName((String)bindings.get(i)),
parent));
- }
- model.setConnectorBindingNames(names);
- }
- }
- return model;
- }
-
- private org.teiid.adminapi.Request convertRequest(final RequestInfo src) {
-
- String connId = src.getRequestID().getConnectionID();
-
- MMRequest request = null;
- if (src.getConnectorBindingUUID() != null) {
- request = new MMRequest(new String[] {connId,
String.valueOf(src.getRequestID().getExecutionID()), String.valueOf(src.getNodeID()),
String.valueOf(src.getExecutionID())});
- }
- else {
- request = new MMRequest(new String[] {connId,
String.valueOf(src.getRequestID().getExecutionID())});
- }
-
- request.setSqlCommand(src.getCommand());
-
- request.setCreated(src.getProcessingTimestamp());
-
- if (src.getConnectorBindingUUID() != null) {
- request.setSource(true);
- request.setNodeID(String.valueOf(src.getNodeID()));
- }
- return request;
- }
-
- /**
- * Get the connection connection object for the given id.
- * @param identifier
- * @return
- * @since 4.3
- */
- MetaMatrixSessionInfo getClientConnection(String identifier) throws AdminException {
- Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
- for (MetaMatrixSessionInfo info:sessions) {
- if (info.getSessionID().toString().equals(identifier)) {
- return info;
- }
- }
- return null;
- }
-
- /**
- * Get all the available connections
- * @return
- * @throws AdminException
- */
- Collection<MetaMatrixSessionInfo> getClientConnections() throws AdminException
{
- try {
- return getSessionService().getActiveSessions();
- } catch (SessionServiceException e) {
- // SessionServiceException not in the client known exception (in common-internal)
- throw new AdminComponentException(e.getMessage(), e.getCause());
- }
- }
-
- boolean matches(String regEx, String value) {
- regEx = regEx.replaceAll(AdminObject.ESCAPED_WILDCARD, ".*");
//$NON-NLS-1$
- regEx = regEx.replaceAll(AdminObject.ESCAPED_DELIMITER, "");
//$NON-NLS-1$
- return value.matches(regEx);
- }
-
- List matchedCollection(String identifier, List adminObjects) {
- ArrayList matched = new ArrayList();
- for (Iterator i = adminObjects.iterator(); i.hasNext();) {
- AdminObject aObj = (AdminObject)i.next();
- if (matches(identifier, aObj.getName()) || matches(identifier,
aObj.getIdentifier())) {
- matched.add(aObj);
- }
- }
- return matched;
- }
-
- /**
- * Get list of available connector bindings
- * @param identifier
- */
- Collection getConnectorBindings(String identifier) throws AdminException{
-// try {
-// List connectorBindings = getDataService().getConnectorBindings();
-// connectorBindings = (List)convertToAdminObjects(connectorBindings);
-// return matchedCollection(identifier, connectorBindings);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return Collections.EMPTY_LIST;
- }
-
-
- /**
- * Get list of available connector types
- * @param identifier
- */
- Collection getConnectorTypes(String identifier) throws AdminException{
-
- try {
- List connectorTypes = getConfigurationService().getConnectorTypes();
- connectorTypes = (List)convertToAdminObjects(connectorTypes);
- return matchedCollection(identifier, connectorTypes);
- } catch (MetaMatrixComponentException err) {
- throw new AdminComponentException(err);
- }
- }
-
- boolean isMaskedProperty(String propName, ComponentType type) {
- if (type != null) {
- ComponentTypeDefn typeDef = type.getComponentTypeDefinition(propName);
- if (typeDef != null && typeDef.getPropertyDefinition().isMasked()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Encrypt a string
- * @param value
- * @return
- * @throws AdminException
- * @since 4.3
- */
- String encryptString(String value) throws AdminException {
- try {
- return CryptoUtil.stringEncrypt(value);
- } catch (CryptoException e) {
- throw new AdminComponentException(e);
- }
- }
-
-
-
- /**
- * Convert a ComponentType and a set of properties into a Collection of
- * com.metamatrix.admin.api.objects.PropertyDefinition objects
- * @param ctype
- * @param properties
- * @return
- * @since 4.3
- */
- protected Collection convertPropertyDefinitions(ComponentType ctype, Properties
properties) {
- ArrayList results = new ArrayList();
- for (Iterator iter = ctype.getComponentTypeDefinitions().iterator();
iter.hasNext(); ) {
- ComponentTypeDefn cdefn = (ComponentTypeDefn) iter.next();
- PropertyDefinition pdefn = cdefn.getPropertyDefinition();
-
- MMPropertyDefinition result = new MMPropertyDefinition(new String[]
{pdefn.getName()});
- result.setAllowedValues(pdefn.getAllowedValues());
- result.setDefaultValue(pdefn.getDefaultValue());
- result.setDescription(pdefn.getShortDescription());
- result.setDisplayName(pdefn.getDisplayName());
- result.setExpert(pdefn.isExpert());
- result.setMasked(pdefn.isMasked());
- result.setModifiable(pdefn.isModifiable());
- result.setPropertyType(pdefn.getPropertyType().getDisplayName());
- result.setPropertyTypeClassName(pdefn.getPropertyType().getClassName());
- result.setRequired(pdefn.isRequired());
- result.setRequiresRestart(pdefn.getRequiresRestart());
-
- String value = properties.getProperty(pdefn.getName());
- result.setValue(value);
-
- results.add(result);
- }
-
-
- return results;
- }
-
-
- /**
- * Convert a set of properties into a Collection of
- * com.metamatrix.admin.api.objects.PropertyDefinition objects
- *
- * @param ctype
- * @param properties
- * @return
- * @since 4.3
- */
- protected Collection convertPropertyDefinitions(Properties properties) {
- ArrayList results = new ArrayList();
- for (Iterator iter = properties.keySet().iterator(); iter.hasNext(); ) {
- String key = (String) iter.next();
- String value = properties.getProperty(key);
-
- MMPropertyDefinition result = new MMPropertyDefinition(new String[] {key});
- result.setDisplayName(key);
- result.setValue(value);
-
- results.add(result);
- }
-
-
- return results;
- }
-
- protected SessionToken validateSession() {
- return DQPWorkContext.getWorkContext().getSessionToken();
- }
-
- protected void changeVDBStatus(String name, String version, int status)
- throws AdminException {
- try {
-
- if (name == null || version == null || !name.matches(SINGLE_WORD_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name"));
//$NON-NLS-1$
- }
-
- // Now change the VDB status it self
- this.getVDBService().changeVDBStatus(name, version, status);
-
- // If the VDB is modified and if its status changed to DELETED, then
- // we can remove all the connector bindings associated with this VDB
- // the above delete will also remove them
- } catch (ApplicationLifecycleException e) {
- throw new AdminComponentException(e);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
-}
Deleted:
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -1,1063 +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.dqp.embedded.admin;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminOptions;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.ConfigurationAdmin;
-import org.teiid.adminapi.EmbeddedLogger;
-import org.teiid.adminapi.LogConfiguration;
-import org.teiid.adminapi.VDB;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ComponentTypeDefn;
-import com.metamatrix.common.config.api.ComponentTypeID;
-import com.metamatrix.common.config.api.ConnectorArchive;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.ConnectorBindingType;
-import com.metamatrix.common.config.api.ExtensionModule;
-import com.metamatrix.common.config.model.BasicConnectorArchive;
-import com.metamatrix.common.config.model.BasicExtensionModule;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.crypto.CryptoException;
-import com.metamatrix.common.util.crypto.CryptoUtil;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.common.vdb.api.VDBDefn;
-import com.metamatrix.core.vdb.VDBStatus;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.embedded.configuration.ConnectorConfigurationReader;
-import com.metamatrix.dqp.embedded.configuration.ConnectorConfigurationWriter;
-import com.metamatrix.dqp.embedded.configuration.VDBConfigurationReader;
-import com.metamatrix.dqp.service.ConfigurationService;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-
-
-/**
- * DQP implementation of the Config Admin API
- * @since 4.3
- */
-public class DQPConfigAdminImpl extends BaseAdmin implements ConfigurationAdmin {
-
- public DQPConfigAdminImpl(EmbeddedConnectionFactoryImpl manager) {
- super(manager);
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#setProperty(java.lang.String,
java.lang.String, java.lang.String, java.lang.String)
- * @since 4.3
- */
- public void setConnectorBindingProperty(String deployedName, String propertyName,
String propertyValue)
- throws AdminException {
-
-// try {
-// ConnectorBinding binding =
getConfigurationService().getConnectorBinding(deployedName);
-// if (binding == null) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.cb_doesnot_exist",
deployedName)); //$NON-NLS-1$
-// }
-//
-// ComponentTypeID id = binding.getComponentTypeID();
-// ConnectorBindingType type =
getConfigurationService().getConnectorType(id.getName());
-//
-// boolean needsEncryption = isMaskedProperty(propertyName, type);
-// if (needsEncryption) {
-// propertyValue = encryptString(propertyValue);
-// }
-//
-// Properties p = new Properties();
-// p.setProperty(propertyName, propertyValue);
-//
-// //update the configuration
-// binding = ConnectorConfigurationReader.addConnectorBindingProperties(binding, p);
-// getConfigurationService().updateConnectorBinding(binding);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorType(java.lang.String,
char[])
- * @since 4.3
- */
- public void addConnectorType(String deployName, char[] cdkFile)
- throws AdminException {
-// try {
-// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
-// }
-// if (cdkFile == null || cdkFile.length == 0) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_source"));
//$NON-NLS-1$
-// }
-//
-// // This is only place we check the existence in admin. Generally the Admin
is not the
-// // guy to decide, if it can take in or not, it should be the service. I did
not
-// // want add in the configuration service beacuse, it may need to allow this
behavior
-// // in case we are updating.
-// if (getConfigurationService().getConnectorType(deployName) == null) {
-// ConnectorBindingType type =
ConnectorConfigurationReader.loadConnectorType(cdkFile);
-// saveConnectorType(type);
-// }
-// else {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_exists",
deployName)); //$NON-NLS-1$
-// }
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#deleteConnectorType(java.lang.String)
- * @since 4.3
- */
- public void deleteConnectorType(String deployName)
- throws AdminException {
-// try {
-// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
-// }
-// getConfigurationService().deleteConnectorType(deployName);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorBinding(java.lang.String,
java.lang.String, java.util.Properties, AdminOptions)
- * @since 4.3
- */
- public org.teiid.adminapi.ConnectorBinding addConnectorBinding(String deployName,
String type, Properties properties, AdminOptions options)
- throws AdminException {
-// // if the options object is null treat as if it is IGNORE as default
-// if (options == null) {
-// options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
-// }
-//
-// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
-// }
-//
-// if (type == null || !type.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
-// }
-//
-// ConnectorBinding binding = null;
-// try {
-// // Check if the binding exists already, if does take action based on user
-// // preferences in the admin options
-// if (bindingExists(deployName)) {
-// // Based on users preference, either add or replace or ignore
-// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists",
deployName)); //$NON-NLS-1$
-// }
-// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
-// binding = getDataService().getConnectorBinding(deployName);
-// return (org.teiid.adminapi.ConnectorBinding)
convertToAdminObjects(binding);
-// }
-// }
-//
-// // Get the connector type
-// ConnectorBindingType ctype =
getConfigurationService().getConnectorType(type);
-// if (ctype == null) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_type_not_exists",
type)); //$NON-NLS-1$
-// }
-//
-// // Build the connector binding with informatin we know.
-// binding = ConnectorConfigurationReader.loadConnectorBinding(deployName,
properties, ctype);
-//
-// // Check that the connector binding passwords can be decrypted
-// try {
-// checkDecryption(binding, ctype);
-// } catch(CryptoException e) {
-// if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR))
{
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED",
binding.getFullName())); //$NON-NLS-1$
-// }
-// }
-//
-// // now that all of the input parameters validated, add the connector
binding
-// binding = addConnectorBinding(deployName, binding, ctype, false);
-//
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
-// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
-
- return null;
- }
-
- boolean bindingExists(String name) throws MetaMatrixComponentException {
-// ConnectorBinding binding = getDataService().getConnectorBinding(name);
-// return (binding != null);
- return false;
- }
-
- boolean bindingTypeExists(String name) throws MetaMatrixComponentException {
- ConnectorBindingType type = getConfigurationService().getConnectorType(name);
- return (type != null);
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorBinding(java.lang.String,
char[], AdminOptions)
- * @since 4.3
- */
- public org.teiid.adminapi.ConnectorBinding addConnectorBinding(String deployName,
char[] xmlFile, AdminOptions options)
- throws AdminException {
-
-// // if the options object is null treat as if it is IGNORE as default
-// if (options == null) {
-// options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
-// }
-//
-// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
-// }
-// if (xmlFile == null || xmlFile.length == 0) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_source"));
//$NON-NLS-1$
-// }
-//
-// ConnectorBinding binding = null;
-// try {
-// // Check if the binding exists already, if does take action based on user
-// // preferences in the admin options
-// if (bindingExists(deployName)) {
-// // Based on users preference, either add or replace or ignore
-// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists",
deployName)); //$NON-NLS-1$
-// }
-// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
-// binding = getDataService().getConnectorBinding(deployName);
-// return (org.teiid.adminapi.ConnectorBinding)
convertToAdminObjects(binding);
-// }
-// }
-//
-// // now we are in situation we do have the connector or overwriting it.
-// // before we add the connector binding we need to add the connector type
-// // as the connector binding only references to type by identifier.
-// ConnectorBindingType type =
ConnectorConfigurationReader.loadConnectorType(xmlFile);
-//
-// // Check if the binding type exists already, if does take action based on
user
-// // preferences in the admin options, same rules apply as binding.
-// boolean addType = true;
-// if (bindingTypeExists(type.getName())) {
-// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBinding_type_exists",
deployName, type.getName())); //$NON-NLS-1$
-// }
-// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
-// addType = false;
-// }
-// }
-//
-// binding = ConnectorConfigurationReader.loadConnectorBinding(deployName,
xmlFile);
-//
-// // Check that the connector binding passwords can be decrypted
-// try {
-// checkDecryption(binding, type);
-// } catch(CryptoException e) {
-// if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR))
{
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED",
binding.getFullName())); //$NON-NLS-1$
-// }
-// }
-//
-// // now that all of the input parameters validated, add the connector
binding
-// binding = addConnectorBinding(deployName, binding, type, addType);
-//
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
-//
-// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
- return null;
- }
-
- /**
- * Helper method to add the connector binding..
- * @param deployName
- * @param binding
- * @param type
- * @param options
- * @throws AdminException
- */
- ConnectorBinding addConnectorBinding(String deployName, ConnectorBinding binding,
ConnectorBindingType type, boolean addType)
- throws AdminException {
- // Make sure we have both correctly configured
- if (type != null && binding != null) {
- if (binding.getComponentTypeID().getName().equals(type.getName())) {
- try {
-
- // First add the connector type if one is not already in here.
- if (getConfigurationService().getConnectorType(type.getName()) ==
null || addType) {
- saveConnectorType(type);
- }
- // Now add the connector binding.
- binding = getConfigurationService().addConnectorBinding(deployName,
binding, true);
- return binding;
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_load_failed_wrong_type",
deployName)); //$NON-NLS-1$
- }
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_load_failed_wrong_contents",
deployName)); //$NON-NLS-1$
- }
-
- /**
- * @see
org.teiid.adminapi.ConfigurationAdmin#deleteConnectorBinding(java.lang.String)
- * @since 4.3
- */
- public void deleteConnectorBinding(String identifier)
- throws AdminException {
-// try {
-// if (identifier == null ||
!identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
-// }
-// getConfigurationService().deleteConnectorBinding(identifier);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addVDB(java.lang.String, byte[],
char[], AdminOptions)
- * @since 4.3
- */
- private VDB addVDB(String deployName, byte[] vdbFile, char[] defFile, AdminOptions
options)
- throws AdminException {
-
- // if the options object is null treat as if it is BINDINGS_ADD as default
- if (options == null) {
- options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
- }
-
- if (deployName == null || !deployName.matches(SINGLE_WORD_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name"));
//$NON-NLS-1$
- }
- if (vdbFile == null || vdbFile.length == 0) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_source"));
//$NON-NLS-1$
- }
-
- if (defFile == null) {
- DQPEmbeddedPlugin.logInfo("Admin.load_combined_vdb", new Object[]
{deployName}); //$NON-NLS-1$
- }
-
- VDBArchive vdb = null;
- try {
- // Load the VDB from the files
- if (defFile == null) {
- vdb = VDBConfigurationReader.loadVDB(deployName, vdbFile);
- }
- else {
- vdb = VDBConfigurationReader.loadVDB(deployName, defFile, vdbFile);
- }
-
- // Add the connector binding in the VDB to the system
- validateConnectorBindingsInVdb(vdb, options);
-
- // now deploy the VDB into the system. Flag is to
- VDBArchive deployedVDB = getConfigurationService().addVDB(vdb,
!options.containsOption(AdminOptions.OnConflict.IGNORE));
-
- // If the connector bindings are correctly initialized and VDB is active
- // start the bindings automatically.
- if ( (deployedVDB.getStatus() == VDBStatus.ACTIVE) ||
- (deployedVDB.getStatus() == VDBStatus.ACTIVE_DEFAULT) ) {
- try {
- startVDBConnectorBindings(deployedVDB);
- } catch (MetaMatrixComponentException e) {
- } catch (ApplicationLifecycleException e) {
- // we can safely ignore these because the cause of the not starting
is already recorded
- // and more likely VDB deployment succeeded.
- }
- }
-
- return (VDB) convertToAdminObjects(deployedVDB);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * Start the connector bindings in the given VDB
- * @param vdb
- */
- private void startVDBConnectorBindings(VDBArchive vdb) throws
MetaMatrixComponentException,
- ApplicationLifecycleException {
-//
-// VDBDefn def = vdb.getConfigurationDef();
-// Collection<ConnectorBinding> bindings =
def.getConnectorBindings().values();
-// for (ConnectorBinding binding:bindings) {
-// getDataService().startConnectorBinding(binding.getDeployedName());
-// }
- }
-
- /**
- * Validate the connector bindings in a VDB. Since the connector bindings in VDB
- * are VDB scoped there is no meaning for the admin options provided. Just check
- * the decrypt properties.
- */
- void validateConnectorBindingsInVdb(VDBArchive vdb, AdminOptions options)
- throws MetaMatrixComponentException, AdminProcessingException, AdminException {
-
- VDBDefn def = vdb.getConfigurationDef();
-
- int version = 0;
- VDBArchive existing = null;
- do {
- version++;
- existing = getConfigurationService().getVDB(def.getName(),
String.valueOf(version));
- } while(existing != null);
-
- // Look for the connector bindings in the VDB
- // Based on users preference, either add or replace or throw exception
- List vdbbindings = new ArrayList(def.getConnectorBindings().values());
-
- for (Iterator i = vdbbindings.iterator(); i.hasNext();) {
- ConnectorBinding binding = (ConnectorBinding)i.next();
-
- String deployName = binding.getDeployedName();
- if (deployName == null) {
- deployName = binding.getFullName();
- }
-
- if (bindingExists(deployName)) {
- if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists",
binding.getDeployedName())); //$NON-NLS-1$
- }
- }
-
- // when the binding is not found it falls in "add",
"overwrite" or "ignore"
- // first two cases we need to add.
- ConnectorBindingType type =
(ConnectorBindingType)def.getConnectorType(binding.getComponentTypeID().getName());
-
- // Check that the connector binding passwords can be decrypted
- try {
- checkDecryption(binding, type);
- } catch(CryptoException e) {
- if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED",
binding.getFullName())); //$NON-NLS-1$
- }
- }
- }
- }
-
- /**
- * Check that the properties of the specified ConnectorBinding can be decrypted.
- * @param
- * @return
- * @since 4.3
- */
- private void checkDecryption(ConnectorBinding binding, ConnectorBindingType type)
throws CryptoException {
- Properties props = binding.getProperties();
- Iterator it = props.keySet().iterator();
- while (it.hasNext()) {
- String name = (String)it.next();
- if (isMaskedProperty(name, type)) {
- decryptProperty(props.getProperty(name));
- }
- }
- }
-
- /**
- * Check to see if the property read is a masked/encoded property
- * @param propName
- * @param type
- * @return
- */
- boolean isMaskedProperty(String propName, ComponentType type) {
- if (type != null) {
- ComponentTypeDefn typeDef = type.getComponentTypeDefinition(propName);
- if (typeDef != null && typeDef.getPropertyDefinition().isMasked()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Decrypt the given property using the Crypto libraries.
- * @param value
- * @return decrypted property.
- */
- String decryptProperty(String value) throws CryptoException{
- if (value != null && value.length() > 0 &&
CryptoUtil.isValueEncrypted(value)) {
- return CryptoUtil.stringDecrypt(value);
- }
- return value;
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addVDB(java.lang.String, byte[],
AdminOptions)
- * @since 4.3
- */
- public VDB addVDB(String deployName, byte[] vdbFile, AdminOptions options)
- throws AdminException {
- return addVDB(deployName, vdbFile, null, options);
- }
-
- @Override
- public void deleteVDB(String vdbName, String vdbVersion) throws AdminException {
- super.changeVDBStatus(vdbName, vdbVersion, VDB.DELETED);
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addExtensionModule(java.lang.String,
java.lang.String, byte[], java.lang.String)
- * @since 4.3
- */
- public void addExtensionModule(String type, String sourceName, byte[] source, String
description)
- throws AdminException {
-// try {
-// if (sourceName == null) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name"));
//$NON-NLS-1$
-// }
-// if (source == null || source.length == 0) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source"));
//$NON-NLS-1$
-// }
-// if (!sourceName.endsWith(".jar") &&
!sourceName.endsWith(".xmi")) { //$NON-NLS-1$ //$NON-NLS-2$
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_module"));
//$NON-NLS-1$
-// }
-// ExtensionModule previousModule = null;
-//
-// try {
-// previousModule =
getConfigurationService().getExtensionModule(sourceName);
-// }catch(MetaMatrixComponentException e) {
-// // this is OK, we did not find any thing
-// }
-//
-// if ( previousModule == null) {
-// // Now add it.
-// BasicExtensionModule extModule = new BasicExtensionModule(sourceName,
type, description, source);
-// getConfigurationService().saveExtensionModule(extModule);
-// }
-// else {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.extension_module_exists",
sourceName)); //$NON-NLS-1$
-// }
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see
org.teiid.adminapi.ConfigurationAdmin#deleteExtensionModule(java.lang.String)
- * @since 4.3
- */
- public void deleteExtensionModule(String sourceName)
- throws AdminException {
-// try {
-// if (sourceName == null) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name"));
//$NON-NLS-1$
-// }
-// getConfigurationService().deleteExtensionModule(sourceName);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#assignBindingToModel(java.lang.String,
java.lang.String, java.lang.String, java.lang.String)
- * @since 4.3
- */
- public void assignBindingToModel(String deployedConnectorBindingName, String vdbName,
String vdbVersion, String modelName)
- throws AdminException {
-
- if (deployedConnectorBindingName == null ||
!deployedConnectorBindingName.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
- }
-
- if (vdbName == null || vdbVersion == null || !vdbName.matches(SINGLE_WORD_REGEX))
{
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name"));
//$NON-NLS-1$
- }
-
- if (modelName == null || !modelName.matches(MULTIPLE_WORDS_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_model_name"));
//$NON-NLS-1$
- }
-
- // find the connector binding if found in the configuration service
- // add to the vdb binding.
- try {
- ConnectorBinding binding =
null;//getDataService().getConnectorBinding(deployedConnectorBindingName);
- if (binding != null) {
- List list = new ArrayList();
- list.add(binding);
- getConfigurationService().assignConnectorBinding(vdbName, vdbVersion,
modelName, (ConnectorBinding[])list.toArray(new ConnectorBinding[list.size()]));
- }
- else {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Vdb_or_Model_notfound"));
//$NON-NLS-1$
- }
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- public void assignBindingsToModel(String[] deployedConnectorBindingName, String
vdbName, String vdbVersion, String modelName) throws AdminException {
- if (deployedConnectorBindingName == null || deployedConnectorBindingName.length
== 0) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
- }
-
- if (vdbName == null || vdbVersion == null || !vdbName.matches(SINGLE_WORD_REGEX))
{
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name"));
//$NON-NLS-1$
- }
-
- if (modelName == null || !modelName.matches(MULTIPLE_WORDS_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_model_name"));
//$NON-NLS-1$
- }
-
- // find the connector binding if found in the configuration service
- // add to the vdb binding.
- try {
- List list = new ArrayList();
- for (int i = 0; i < deployedConnectorBindingName.length; i++) {
- ConnectorBinding binding = null;
//getDataService().getConnectorBinding(deployedConnectorBindingName[i]);
- if (binding != null) {
- list.add(binding);
- }
- }
-
- if (!list.isEmpty()) {
- getConfigurationService().assignConnectorBinding(vdbName, vdbVersion,
modelName, (ConnectorBinding[])list.toArray(new ConnectorBinding[list.size()]));
- }
- else {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Vdb_or_Model_notfound"));
//$NON-NLS-1$
- }
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
-
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#getLogConfiguration()
- * @since 4.3
- */
- public LogConfiguration getLogConfiguration()
- throws AdminException {
- return
(LogConfiguration)convertToAdminObjects(LogManager.getLogConfigurationCopy());
- }
-
- /**
- * @see
org.teiid.adminapi.ConfigurationAdmin#setLogConfiguration(org.teiid.adminapi.LogConfiguration)
- * @since 4.3
- */
- public void setLogConfiguration(LogConfiguration config)
- throws AdminException {
-
LogManager.setLogConfiguration((com.metamatrix.common.log.LogConfiguration)convertToNativeObjects(config));
- }
-
- /**
- * @see
com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#setLogListener(java.lang.Object)
- * @since 4.3
- */
- public void setLogListener(EmbeddedLogger listener)
- throws AdminException {
- if(listener != null) {
- LogManager.setLogListener(new DQPLogListener(listener));
- }
- else {
- throw new AdminProcessingException("Admin_invalid_log_listener");
//$NON-NLS-1$
- }
- }
-
- /**
- * @see
org.teiid.adminapi.ConfigurationAdmin#exportExtensionModule(java.lang.String)
- * @since 4.3
- */
- public byte[] exportExtensionModule(String sourceName) throws AdminException {
-// try {
-// if (sourceName == null) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name"));
//$NON-NLS-1$
-// }
-//
-// ExtensionModule extModule =
getConfigurationService().getExtensionModule(sourceName);
-// return extModule.getFileContents();
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return null;
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#exportConfiguration()
- * @since 4.3
- */
- public char[] exportConfiguration() throws AdminException {
- try {
- StringWriter sw = new StringWriter();
- Properties props = getConfigurationService().getSystemProperties();
- props.store(sw, "Export of Teiid Configuration Properties");
//$NON-NLS-1$
- return sw.toString().toCharArray();
- } catch (IOException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see
org.teiid.adminapi.ConfigurationAdmin#exportConnectorBinding(java.lang.String)
- * @since 4.3
- */
- public char[] exportConnectorBinding(String identifier)
- throws AdminException {
-// try {
-// if (identifier == null ||
!identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
-// }
-//
-// List bindingList = getDataService().getConnectorBindings();
-// List matchedList = new ArrayList();
-// for (Iterator i = bindingList.iterator(); i.hasNext();) {
-// ConnectorBinding binding = (ConnectorBinding)i.next();
-// if (matches(identifier, binding.getDeployedName())) {
-// matchedList.add(binding);
-// }
-// }
-//
-// if (!matchedList.isEmpty()) {
-// ConnectorBinding[] bindings =
(ConnectorBinding[])matchedList.toArray(new ConnectorBinding[matchedList.size()]);
-// ConnectorBindingType[] types = new
ConnectorBindingType[bindings.length];
-//
-// for (int i = 0; i < bindings.length; i++) {
-// types[i] =
getConfigurationService().getConnectorType(bindings[i].getComponentTypeID().getName());
-// }
-// return ConnectorConfigurationWriter.writeToCharArray(bindings, types);
-// }
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists",
identifier)); //$NON-NLS-1$
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return null;
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#exportConnectorType(java.lang.String)
- * @since 4.3
- */
- public char[] exportConnectorType(String identifier)
- throws AdminException {
-// try {
-// if (identifier == null || !identifier.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
-// }
-//
-// List typesList = getConfigurationService().getConnectorTypes();
-// List matchedList = new ArrayList();
-// for (Iterator i = typesList.iterator(); i.hasNext();) {
-// ConnectorBindingType type = (ConnectorBindingType)i.next();
-// if (matches(identifier, type.getName())) {
-// matchedList.add(type);
-// }
-// }
-//
-// if (!matchedList.isEmpty()) {
-// ConnectorBindingType[] types =
(ConnectorBindingType[])matchedList.toArray(new
ConnectorBindingType[matchedList.size()]);
-// return ConnectorConfigurationWriter.writeToCharArray(types);
-// }
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_does_not_exists",
identifier)); //$NON-NLS-1$
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return null;
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#exportVDB(java.lang.String,
java.lang.String)
- * @since 4.3
- */
- public byte[] exportVDB(String name, String version)
- throws AdminException {
-
- try {
- if (name == null || version == null || !name.matches(SINGLE_WORD_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name"));
//$NON-NLS-1$
- }
-
- VDBArchive vdb = getConfigurationService().getVDB(name, version);
- if (vdb != null) {
- return VDBArchive.writeToByteArray(vdb);
- }
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.vdb_does_not_exists",
name, version)); //$NON-NLS-1$
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorArchive(byte[],
org.teiid.adminapi.AdminOptions)
- * @since 4.3.2
- */
- public void addConnectorArchive(byte[] contents, AdminOptions options) throws
AdminException {
-
- // if the options object is null treat as if it is IGNORE as default
- if (options == null) {
- options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
- }
-
- if (contents == null || contents.length == 0) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_source"));
//$NON-NLS-1$
- }
-
- try {
- // Load the connector Archive from the file
- HashSet previouslyAddedModules = new HashSet();
- ConnectorArchive archive =
ConnectorConfigurationReader.loadConnectorArchive(contents);
- ConnectorBindingType[] connectorTypes = archive.getConnectorTypes();
-
- // Loop through each type and add all of them based on the option.
- for (int typeIndex = 0; typeIndex < connectorTypes.length; typeIndex++) {
-
- // first make sure we do not already have this connector type
- String connectorName = connectorTypes[typeIndex].getName();
- ConnectorBindingType type =
getConfigurationService().getConnectorType(connectorName);
- if (type == null) {
- type = connectorTypes[typeIndex];
- ExtensionModule[] extModules = archive.getExtensionModules(type);
- checkDuplicateExtensionModules(extModules, options,
previouslyAddedModules);
- saveConnectorType(type);
-
- } else {
-
- // if not asked to overwrite/skip writing them
- if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_exists",
connectorName)); //$NON-NLS-1$
- } else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
- continue;
- } else if
(options.containsOption(AdminOptions.OnConflict.OVERWRITE)){
- deleteConnectorType(connectorName);
- // Now that we know we need to add this to configuration;
let's get on with it
- type = connectorTypes[typeIndex];
- ExtensionModule[] extModules =
archive.getExtensionModules(type);
- checkDuplicateExtensionModules(extModules, options,
previouslyAddedModules);
- saveConnectorType(type);
- }
- }
- // Now that we know we need to add this to configuration; let's get
on with it
- type = connectorTypes[typeIndex];
- ExtensionModule[] extModules = archive.getExtensionModules(type);
- checkDuplicateExtensionModules(extModules, options,
previouslyAddedModules);
- }
-
- // Now add the extension modules
- for (Iterator i = previouslyAddedModules.iterator(); i.hasNext();) {
- ExtensionModule extModule = (ExtensionModule)i.next();
- addExtensionModule(extModule.getModuleType(), extModule.getFullName(),
extModule.getFileContents(), extModule.getDescription());
- }
-
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * This method checks the passed in connector type's extension module is not
already in the
- * system, if it there takes the appropriate action. Otherwise keeps tracks of all
modules
- * to add.
- * @param type - connector type
- * @param extModules - Extension modules for the Connector Type
- * @param options - Admin Options
- * @param ignorableModules - Modules which are already added, can be ignored for
adding
- */
- void checkDuplicateExtensionModules(ExtensionModule[] extModules, AdminOptions
options, HashSet ignorableModules)
- throws AdminException {
-
- // Now check if the the extension modules are already there
- for (int i = 0; i < extModules.length; i++) {
- boolean add = true;
-
- String moduleName = extModules[i].getFullName();
- ExtensionModule previousModule = null;
-
- // see if we can ignore this, because we may have just added this during
import of
- // another connector type through this archive
- if (ignorableModules.contains(extModules[i])) {
- continue;
- }
-
- // we have not already added this this time around, now check if this
available
- // from configuration service
- try {
- previousModule =
getConfigurationService().getExtensionModule(moduleName);
- }catch(MetaMatrixComponentException e) {
- // this is OK, we did not find any thing
- }
-
- // if we found it take appropriate action.
- if(previousModule != null &&
options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.extension_module_exists",
previousModule.getFullName())); //$NON-NLS-1$
- }
- else if (previousModule != null &&
options.containsOption(AdminOptions.OnConflict.IGNORE)) {
- add = false;
- }
- else if (previousModule != null &&
options.containsOption(AdminOptions.OnConflict.OVERWRITE)) {
- // since we are overwrite, first delete and then add, there is no safe
way to overwrite
- deleteExtensionModule(previousModule.getFullName());
- }
-
- // Now keep track what extension modules to add; also to ignore in future
- // adds
- if (add) {
- ignorableModules.add(extModules[i]);
- }
- }
- }
-
- /**
- * @see
org.teiid.adminapi.ConfigurationAdmin#exportConnectorArchive(java.lang.String)
- * @since 4.3
- */
- public byte[] exportConnectorArchive(String identifier) throws AdminException {
-// try {
-// if (identifier == null ||
!identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
-// }
-//
-// // first build the connector archive object
-// BasicConnectorArchive archive = new BasicConnectorArchive();
-// List connectorTypes = getConfigurationService().getConnectorTypes();
-//
-// for (Iterator i = connectorTypes.iterator(); i.hasNext();) {
-// ConnectorBindingType type = (ConnectorBindingType)i.next();
-//
-// // If the types name matches with the pattern sent in add to archive
-// if (type != null && matches(identifier, type.getName())) {
-//
-// // Add connector type first
-// archive.addConnectorType(type);
-//
-// // Get the extension modules required for the type
-// String[] extModules = type.getExtensionModules();
-// for (int m = 0; m < extModules.length; m++) {
-// // Get the extension module from the configuration and add to
the archive
-// ExtensionModule extModule =
getConfigurationService().getExtensionModule(extModules[m]);
-// if (extModule != null) {
-// archive.addExtensionModule(type, extModule);
-// }
-// else {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("DataService.ext_module_not_found",
extModules[m])); //$NON-NLS-1$
-// }
-// }
-// }
-// }
-//
-// // if no types found to the identifier pattern, then throw an exception
-// if (archive.getConnectorTypes().length == 0) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_does_not_exists",
identifier)); //$NON-NLS-1$
-// }
-//
-// // now convert the object into file form
-// return ConnectorConfigurationWriter.writeToByteArray(archive);
-//
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return null;
- }
-
- private void saveConnectorType(ConnectorBindingType type) throws
MetaMatrixComponentException {
- getConfigurationService().saveConnectorType(type);
- }
-
-
- @Override
- public void addUDF(byte[] modelFileContents, String classpath)
- throws AdminException {
- if (modelFileContents == null || modelFileContents.length == 0) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_UDF_contents"));
//$NON-NLS-1$
- }
-
- try {
-
- getConfigurationService().unloadUDF();
-
- // delete any extension module by the same name first
- try {
- deleteExtensionModule(ConfigurationService.USER_DEFINED_FUNCTION_MODEL);
- } catch (AdminException e) {
- // if not found then it is OK to fail
- }
-
- // add the function definitions as extension modules
- addExtensionModule(ExtensionModule.FUNCTION_DEFINITION_TYPE,ConfigurationService.USER_DEFINED_FUNCTION_MODEL,modelFileContents,
"User Defined Functions File"); //$NON-NLS-1$
-
- String commonpath =
getConfigurationService().getSystemProperties().getProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH,
""); //$NON-NLS-1$
-
- StringBuilder sb = new StringBuilder();
- if (classpath != null && classpath.length() > 0 ) {
- StringTokenizer st = new StringTokenizer(classpath, ";");
//$NON-NLS-1$
- while (st.hasMoreTokens()) {
- String partpath = st.nextToken();
- if (commonpath.indexOf(partpath) == -1) {
- sb.append(partpath).append(";"); //$NON-NLS-1$
- }
- }
- }
-
getConfigurationService().setSystemProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH,
sb.toString()+commonpath);
-
-
- // then update the properties
- Properties p = new Properties();
- p.setProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH, classpath);
- getConfigurationService().updateSystemProperties(p);
- // reload the new UDF
- getConfigurationService().loadUDF();
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public void deleteUDF() throws AdminException {
- try {
- getConfigurationService().unloadUDF();
- deleteExtensionModule(ConfigurationService.USER_DEFINED_FUNCTION_MODEL);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public void extensionModuleModified(String name) throws AdminException {
- try {
- getConfigurationService().clearClassLoaderCache();
- getConfigurationService().loadUDF();
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public void setProcessProperty(String processIdentifier, String propertyName, String
propertyValue) throws AdminException{
- try {
- getConfigurationService().setSystemProperty(propertyName, propertyValue);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-}
Deleted:
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -1,76 +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.dqp.embedded.admin;
-
-import org.teiid.adminapi.EmbeddedLogger;
-import org.teiid.adminapi.LogConfiguration;
-
-import com.metamatrix.core.log.LogListener;
-import com.metamatrix.core.log.MessageLevel;
-
-
-public class DQPLogListener implements LogListener {
-
- private EmbeddedLogger logger;
-
- public DQPLogListener(EmbeddedLogger logger) {
- this.logger = logger;
- }
-
- public void log(int level, String context, Object msg) {
- logger.log(convertLevel(level), System.currentTimeMillis(), context,
Thread.currentThread().getName(), msg.toString(), null);
- }
-
- public void log(int level, String context, Throwable t, Object msg) {
- logger.log(convertLevel(level), System.currentTimeMillis(), context,
Thread.currentThread().getName(), msg.toString(), t);
- }
-
- private int convertLevel(int level) {
- int logLevel = LogConfiguration.INFO;
-
- switch(level) {
- case MessageLevel.WARNING:
- logLevel = LogConfiguration.WARNING;
- break;
- case MessageLevel.ERROR:
- logLevel = LogConfiguration.ERROR;
- break;
- case MessageLevel.DETAIL:
- logLevel = LogConfiguration.DETAIL;
- break;
- case MessageLevel.TRACE:
- logLevel = LogConfiguration.TRACE;
- break;
- case MessageLevel.NONE:
- logLevel = LogConfiguration.NONE;
- break;
-
- default:
- logLevel = LogConfiguration.INFO;
- }
- return logLevel;
- }
-
- public void shutdown() {
- }
-}
Deleted:
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -1,327 +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.dqp.embedded.admin;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Cache;
-import org.teiid.adminapi.ConnectionPool;
-import org.teiid.adminapi.ConnectorBinding;
-import org.teiid.adminapi.ConnectorType;
-import org.teiid.adminapi.ExtensionModule;
-import org.teiid.adminapi.MonitoringAdmin;
-import org.teiid.adminapi.ProcessObject;
-import org.teiid.adminapi.PropertyDefinition;
-import org.teiid.adminapi.QueueWorkerPool;
-import org.teiid.adminapi.Request;
-import org.teiid.adminapi.Session;
-import org.teiid.adminapi.Transaction;
-import org.teiid.adminapi.VDB;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.config.api.ConnectorBindingType;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.server.serverapi.RequestInfo;
-
-
-/**
- * DQP implementation of the Monitoring API
- * @since 4.3
- */
-public class DQPMonitoringAdminImpl extends BaseAdmin implements MonitoringAdmin {
-
- public DQPMonitoringAdminImpl(EmbeddedConnectionFactoryImpl manager) {
- super(manager);
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getConnectorTypes(java.lang.String)
- * @since 4.3
- */
- public Collection<ConnectorType> getConnectorTypes(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
-
- return super.getConnectorTypes(identifier);
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getVDBs(java.lang.String)
- * @since 4.3
- */
- public Collection<VDB> getVDBs(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(VDB_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
-
- // if . and * not specified, add a STAR at the end to compensate for the
- // version number matching.
- if (identifier.indexOf(DOT) == -1 && identifier.indexOf(STAR) == -1) {
- identifier = identifier +DOT+STAR;
- }
-
- try {
- List<VDBArchive> vdbs = getVDBService().getAvailableVDBs();
- List matchedVdbs = new ArrayList();
- for (VDBArchive vdb:vdbs) {
- if (matches(identifier, vdb.getName()+"."+vdb.getVersion())) {
//$NON-NLS-1$
- matchedVdbs.add(vdb);
- }
- }
- return (List)convertToAdminObjects(matchedVdbs);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getConnectorBindings(java.lang.String)
- * @since 4.3
- */
- public Collection<ConnectorBinding> getConnectorBindings(String identifier)
- throws AdminException {
-
- if (identifier == null) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
- return super.getConnectorBindings(identifier);
- }
-
-
- @Override
- public Collection<ConnectorBinding> getConnectorBindingsInVDB(String vdbName,
String vdbVersion) throws AdminException{
- try {
- VDBArchive vdb = getConfigurationService().getVDB(vdbName, vdbVersion);
- if (vdb != null) {
- return
(List)convertToAdminObjects(vdb.getConfigurationDef().getConnectorBindings().values());
- }
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.vdb_does_not_exists",
vdbVersion, vdbVersion)); //$NON-NLS-1$
-
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getExtensionModules(java.lang.String)
- * @since 4.3
- */
- public Collection<ExtensionModule> getExtensionModules(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(WORD_AND_DOT_WILDCARD_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
-
- try {
- List extModules = getConfigurationService().getExtensionModules();
- extModules = (List)convertToAdminObjects(extModules);
- return matchedCollection(identifier, extModules);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getQueueWorkerPools(java.lang.String)
- * @since 4.3
- */
- public Collection<QueueWorkerPool> getQueueWorkerPools(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
-
- List results = new ArrayList();
- if (matches(identifier, "dqp")) { //$NON-NLS-1$
- // First get the queue statistics for the DQP
- Collection c = getManager().getDQP().getQueueStatistics();;
- if (c != null && !c.isEmpty()) {
- results.addAll(c);
- }
- }
-
- try {
- // Now get for all the connector bindings
- Collection bindings = super.getConnectorBindings(identifier);
- for (Iterator i = bindings.iterator(); i.hasNext();) {
- ConnectorBinding binding = (ConnectorBinding)i.next();
- Collection c =
getDataService().getConnectorStatistics(binding.getName());
- if (c != null && !c.isEmpty()) {
- results.addAll(c);
- }
- }
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
-
- if (!results.isEmpty()) {
- return (List)convertToAdminObjects(results);
- }
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getCaches(java.lang.String)
- * @since 4.3
- */
- public Collection<Cache> getCaches(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(SINGLE_WORD_WILDCARD_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
-
- List cacheList = new ArrayList();
- for (int i =0; i < cacheTypes.length; i++) {
- if (matches(identifier, cacheTypes[i])) {
- cacheList.add(cacheTypes[i]);
- }
- }
- return cacheList;
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getSessions(java.lang.String)
- * @since 4.3
- */
- public Collection<Session> getSessions(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(NUMBER_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
- return matchedCollection(identifier,
(List)convertToAdminObjects(getClientConnections()));
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getRequests(java.lang.String)
- * @since 4.3
- */
- public Collection<Request> getRequests(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(NUMBER_DOT_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
-
- ArrayList requestList = new ArrayList();
- // List contains both top and atomic requests, only add the top requests
- List<RequestInfo> requests = getManager().getDQP().getRequests();
- for(RequestInfo request:requests) {
- if (request.getConnectorBindingUUID() == null) {
- requestList.add(request);
- }
- }
- return matchedCollection(identifier, (List)convertToAdminObjects(requestList));
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getSourceRequests(java.lang.String)
- * @since 4.3
- */
- public Collection<Request> getSourceRequests(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(NUMBER_DOT_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
-
- ArrayList atomicRequestList = new ArrayList();
- List<RequestInfo> requests = getManager().getDQP().getRequests();
- for (RequestInfo request:requests) {
- if (request.getConnectorBindingUUID() != null) {
- atomicRequestList.add(request);
- }
- }
- return matchedCollection(identifier,
(List)convertToAdminObjects(atomicRequestList));
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getPropertyDefinitions(java.lang.String,
java.lang.String)
- * @since 4.3
- */
- public Collection<PropertyDefinition>
getConnectorTypePropertyDefinitions(String typeName) throws AdminException {
-
- if (typeName == null || !typeName.matches(MULTIPLE_WORDS_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
- }
-
- try {
- ConnectorBindingType type = getConfigurationService().getConnectorType(typeName);
- if (type == null) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.ct_doesnot_exist",
typeName)); //$NON-NLS-1$
- }
-
- return convertPropertyDefinitions(type, new Properties());
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public Collection<Transaction> getTransactions()
- throws AdminException {
- TransactionService ts = getTransactionService();
- if (ts == null) {
- return Collections.emptyList();
- }
- return ts.getTransactions();
- }
-
- @Override
- public Collection<? extends ConnectionPool> getConnectionPoolStats(String
identifier)
- throws AdminException {
-
-// try {
-// return this.getDataService().getConnectionPoolStatistics(identifier);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return Collections.EMPTY_LIST;
- }
-
- @Override
- public Collection<ProcessObject> getProcesses(String processIdentifier) throws
AdminException {
- ArrayList<ProcessObject> list = new ArrayList<ProcessObject>();
- list.add(getManager().getProcess());
- return list;
- }
-}
Deleted:
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -1,302 +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.dqp.embedded.admin;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.transaction.xa.Xid;
-
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminObject;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Cache;
-import org.teiid.adminapi.ConnectorBinding;
-import org.teiid.adminapi.Request;
-import org.teiid.adminapi.RuntimeStateAdmin;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.admin.objects.MMRequest;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-
-
-/**
- * @since 4.3
- */
-public class DQPRuntimeStateAdminImpl extends BaseAdmin implements RuntimeStateAdmin {
-
- public DQPRuntimeStateAdminImpl(EmbeddedConnectionFactoryImpl manager) {
- super(manager);
- }
-
- /**
- * @see com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#stop(int)
- * @since 4.3
- */
- public void shutdown(int millisToWait) throws AdminException {
- // TODO: rreddy need to implement the time to wait.
- // First terminate all the sessions to the DQP currently have
- terminateSession(AdminObject.WILDCARD);
-
- getManager().shutdown(false);
- }
-
- /**
- * @see com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#restart()
- * @since 4.3
- */
- public void restart() throws AdminException {
- // First terminate all the sessions to the DQP currently have
- terminateSession(AdminObject.WILDCARD);
-
- // Now shutdown the DQP, it will automatically start next timea new connection is
- // requested.
- getManager().shutdown(true);
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#startConnectorBinding(java.lang.String)
- * @since 4.3
- */
- public void startConnectorBinding(String identifier)
- throws AdminException {
-
-// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
-// }
-//
-// AdminException exceptionWrapper = null;
-// // Get all matching connector bindings
-// Collection bindings = getConnectorBindings(identifier);
-// if (bindings != null && !bindings.isEmpty()) {
-// for (Iterator i = bindings.iterator(); i.hasNext();) {
-// try {
-// AdminObject binding = (AdminObject)i.next();
-// getDataService().startConnectorBinding(binding.getName());
-// } catch (ApplicationLifecycleException e) {
-// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
-// } catch (MetaMatrixComponentException e) {
-// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
-// }
-// }
-// }
-// else {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists",
new Object[] {identifier})); //$NON-NLS-1$
-// }
-//
-// // If any errors occurred then thow the exception.
-// if (exceptionWrapper != null) {
-// throw exceptionWrapper;
-// }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#stopConnectorBinding(java.lang.String,
boolean)
- * @since 4.3
- */
- public void stopConnectorBinding(String identifier, boolean stopNow)
- throws AdminException {
-// // TODO: need to implement "now" part
-// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
-// }
-//
-// AdminException exceptionWrapper = null;
-// // Get all matching connector bindings
-// Collection bindings = getConnectorBindings(identifier);
-// if (bindings != null && !bindings.isEmpty()) {
-// for (Iterator i = bindings.iterator(); i.hasNext();) {
-// try {
-// AdminObject binding = (AdminObject)i.next();
-// getDataService().stopConnectorBinding(binding.getName());
-// } catch (ApplicationLifecycleException e) {
-// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
-// } catch (MetaMatrixComponentException e) {
-// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
-// }
-// }
-// }
-// else {
-// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists",
new Object[] {identifier})); //$NON-NLS-1$
-// }
-//
-// // If any errors occurred then thow the exception.
-// if (exceptionWrapper != null) {
-// throw exceptionWrapper;
-// }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#clearCache(java.lang.String)
- * @since 4.3
- */
- public void clearCache(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(SINGLE_WORD_WILDCARD_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
- boolean processed = false;
-
- for (int i = 0; i < cacheTypes.length; i++) {
- if (matches(identifier, cacheTypes[i])) {
- if(cacheTypes[i].equals(Cache.CODE_TABLE_CACHE)) {
- processed = true;
- getManager().getDQP().clearCodeTableCache();
- } else if(cacheTypes[i].equals(Cache.PREPARED_PLAN_CACHE)) {
- processed = true;
- getManager().getDQP().clearPlanCache();
- } else if(cacheTypes[i].equals( Cache.QUERY_SERVICE_RESULT_SET_CACHE)) {
- processed = true;
- getManager().getDQP().clearResultSetCache();
- } else if (cacheTypes[i].equals(Cache.CONNECTOR_RESULT_SET_CACHE)) {
- processed = true;
- try {
- // Now get for all the connector bindings
- Collection bindings = super.getConnectorBindings("*");
//$NON-NLS-1$
- for (Iterator iter = bindings.iterator(); iter.hasNext();) {
- ConnectorBinding binding = (ConnectorBinding)iter.next();
-
getDataService().clearConnectorBindingCache(binding.getName());
- }
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
- }
- }
-
- if (!processed) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.invalid_request",
new Object[] {identifier})); //$NON-NLS-1$
- }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#terminateSession(java.lang.String)
- * @since 4.3
- */
- public void terminateSession(String identifier)
- throws AdminException {
-
- Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
- ArrayList<MetaMatrixSessionInfo> matchedConnections = new
ArrayList<MetaMatrixSessionInfo>();
-
- for (MetaMatrixSessionInfo info:sessions) {
- String id = info.getSessionID().toString();
- if (matches(identifier, id)) {
- matchedConnections.add(info);
- }
- }
-
- // terminate the sessions.
- for (MetaMatrixSessionInfo info: matchedConnections) {
- getSessionService().terminateSession(info.getSessionID(),
DQPWorkContext.getWorkContext().getSessionId());
- }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#cancelRequest(java.lang.String)
- * @since 4.3
- */
- public void cancelRequest(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches("\\d+\\" +
Request.DELIMITER + "\\d+")) { //$NON-NLS-1$ //$NON-NLS-2$
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
-
- String[] identifierParts = MMRequest.buildIdentifierArray(identifier);
- String connId = identifierParts[0];
- long requestId = Long.parseLong(identifierParts[1]);
-
- // get the client connection
- RequestID id = new RequestID(connId, requestId);
-
- try {
- getManager().getDQP().cancelRequest(id);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#cancelSourceRequest(java.lang.String)
- * @since 4.3
- */
- public void cancelSourceRequest(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches("\\d+\\" +
Request.DELIMITER + "\\d+\\" + Request.DELIMITER + "\\d+" +
Request.DELIMITER + "\\d+")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
-
- String[] identifierParts = MMRequest.buildIdentifierArray(identifier);
-
- String connId = identifierParts[0];
- long requestId = Long.parseLong(identifierParts[1]);
- int nodeId = Integer.parseInt(identifierParts[2]);
- int executionId = Integer.parseInt(identifierParts[3]);
- AtomicRequestID id = new AtomicRequestID(new RequestID(connId, requestId),
nodeId, executionId);
-
- try {
- getManager().getDQP().cancelAtomicRequest(id);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#changeVDBStatus(java.lang.String,
java.lang.String, int)
- * @since 4.3
- */
- public void changeVDBStatus(String name, String version, int status)
- throws AdminException {
- super.changeVDBStatus(name, version, status);
- }
-
-
- @Override
- public void terminateTransaction(String transactionId, String sessionId)
- throws AdminException {
-// TransactionService ts = getTransactionService();
-// if (ts != null) {
-// ts.terminateTransaction(transactionId, sessionId);
-// }
- }
-
- @Override
- public void terminateTransaction(Xid transactionId) throws AdminException {
- TransactionService ts = getTransactionService();
- if (ts != null) {
- ts.terminateTransaction(transactionId);
- }
- }
-
-}
Deleted:
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -1,275 +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.dqp.embedded.admin;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminObject;
-import org.teiid.adminapi.AdminOptions;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Group;
-import org.teiid.adminapi.SecurityAdmin;
-import org.xml.sax.SAXException;
-
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-import com.metamatrix.admin.objects.MMGroup;
-import com.metamatrix.admin.objects.MMRole;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.api.exception.security.AuthorizationMgmtException;
-import com.metamatrix.api.exception.security.MembershipServiceException;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
-import com.metamatrix.platform.security.api.AuthorizationPolicy;
-import com.metamatrix.platform.security.api.AuthorizationPolicyFactory;
-import com.metamatrix.platform.security.api.AuthorizationRealm;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
-
-
-/**
- * @since 4.3
- */
-public class DQPSecurityAdminImpl extends BaseAdmin implements SecurityAdmin {
-
- public DQPSecurityAdminImpl(EmbeddedConnectionFactoryImpl manager) {
- super(manager);
- }
-
- /**
- * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#addRoleToGroup(java.lang.String,
java.lang.String)
- * @since 4.3
- */
- public void assignRoleToGroup(String roleIdentifier, String groupIdentifier) throws
AdminException {
- throw new
AdminComponentException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.not_implemented"));
//$NON-NLS-1$
- }
-
- /**
- * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#removeRoleFromGroup(java.lang.String,
java.lang.String)
- * @since 4.3
- */
- public void removeRoleFromGroup(String roleIdentifier, String groupIdentifier) throws
AdminException {
- throw new
AdminComponentException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.not_implemented"));
//$NON-NLS-1$
- }
-
- /**
- * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#getGroupsForUser(java.lang.String,
boolean)
- * @since 4.3
- */
- public Collection<Group> getGroupsForUser(String userIdentifier) throws
AdminException {
- if (userIdentifier == null) {
- throwProcessingException("AdminImpl.requiredparameter", new
Object[] {}); //$NON-NLS-1$
- }
-
- if ( userIdentifier.equals(AdminObject.WILDCARD) ) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.Cant_use_wildcard"));
//$NON-NLS-1$
- }
- Collection groups = new ArrayList();
- // Get all memberships - explicit and implicit
- Set allMemberships = null;
- try {
- allMemberships = getMembershipService().getGroupsForUser(userIdentifier);
- } catch (MetaMatrixSecurityException e) {
- throw new AdminComponentException(e);
- }
- Iterator allMembershipsItr = allMemberships.iterator();
- while ( allMembershipsItr.hasNext() ) {
- groups.add(new MMGroup(new String[] {(String)allMembershipsItr.next()}));
- }
- return groups;
- }
-
- /**
- * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#getGroups(java.lang.String)
- * @since 4.3
- */
- public Collection<Group> getGroups(String groupIdentifier) throws
AdminException {
- if (groupIdentifier == null) {
- throwProcessingException("AdminImpl.requiredparameter", new
Object[] {}); //$NON-NLS-1$
- }
-
- Collection<Group> groups = new ArrayList<Group>();
- Collection allGroups = null;
- // Add all groups from internal membership domain
- try {
- allGroups = getMembershipService().getGroupNames();
- } catch (MetaMatrixSecurityException e) {
- throw new AdminComponentException(e);
- }
-
- Iterator groupItr = allGroups.iterator();
- while ( groupItr.hasNext() ) {
- String groupName = (String) groupItr.next();
-
- if (!groupIdentifier.equals(AdminObject.WILDCARD) &&
!groupName.equals(groupIdentifier)) {
- continue;
- }
-
- groups.add(new MMGroup(new String[] {groupName}));
- }
- return groups;
- }
-
-
- /**
- * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#getRolesForGroup(java.lang.String)
- * @since 4.3
- */
- public Collection getRolesForGroup(String groupIdentifier) throws AdminException {
- if (groupIdentifier == null) {
- throwProcessingException("AdminImpl.requiredparameter", new
Object[] {}); //$NON-NLS-1$
- }
-
- if ( groupIdentifier.equals(AdminObject.WILDCARD) ) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.Cant_use_wildcard"));
//$NON-NLS-1$
- }
- Collection roleNames = null;
- try {
- roleNames = getAuthorizationService().getRoleNamesForPrincipal(new
MetaMatrixPrincipalName(groupIdentifier, MetaMatrixPrincipal.TYPE_GROUP));
- } catch (InvalidSessionException e) {
- throw new AdminComponentException(e);
- } catch (AuthorizationMgmtException e) {
- throw new AdminComponentException(e);
- } catch (AuthorizationException e) {
- throw new AdminComponentException(e);
- }
- Collection roles = new ArrayList();
- Iterator roleNameItr = roleNames.iterator();
- while ( roleNameItr.hasNext() ) {
- String roleName = (String)roleNameItr.next();
- roles.add(new MMRole(new String[] {roleName}));
- }
- return roles;
- }
-
- /**
- * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#importDataRoles(java.lang.String,
java.lang.String, char[], org.teiid.adminapi.AdminOptions)
- */
- public String importDataRoles(String vdbName, String vdbVersion, char[] xmlContents,
AdminOptions options)
- throws AdminException{
-
- if (vdbName == null) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbName_can_not_be_null"));
//$NON-NLS-1$
- }
-
- if (vdbVersion == null) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbVersion_can_not_be_null"));
//$NON-NLS-1$
- }
-
- if (options == null) {
-
- options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
- }
-
- try {
- EntitlementMigrationReport rpt = new EntitlementMigrationReport("from
file", vdbName + " " + vdbVersion); //$NON-NLS-1$ //$NON-NLS-2$
-
- Collection<AuthorizationPolicy> roles =
AuthorizationPolicyFactory.buildPolicies(vdbName, vdbVersion, xmlContents);
-
- AuthorizationRealm realm = new AuthorizationRealm(vdbName, vdbVersion);
-
- getAuthorizationService().updatePoliciesInRealm(realm, roles);
-
- return rpt.toString();
- } catch (AuthorizationMgmtException e) {
- throw new AdminProcessingException(e);
- } catch (SAXException e) {
- throw new AdminComponentException(e);
- } catch (IOException e) {
- throw new AdminComponentException(e);
- } catch (ParserConfigurationException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#exportDataRoles(java.lang.String,
java.lang.String)
- */
- public char[] exportDataRoles(String vdbName, String vdbVersion) throws
AdminException {
-
- if (vdbName == null) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbName_can_not_be_null"));
//$NON-NLS-1$
- }
-
- if (vdbVersion == null) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbVersion_can_not_be_null"));
//$NON-NLS-1$
- }
-
- Collection roles = null;
- try {
- roles = getAuthorizationService().getPoliciesInRealm(new AuthorizationRealm(vdbName,
vdbVersion));
- if (roles != null && !roles.isEmpty()) {
- return AuthorizationPolicyFactory.exportPolicies(roles);
- }
- return null;
- } catch (AuthorizationMgmtException e) {
- throw new AdminProcessingException(e);
- } catch (AuthorizationException e) {
- throw new AdminProcessingException(e);
- } catch (IOException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public List<String> getDomainNames() throws AdminException {
- try {
- return this.getMembershipService().getDomainNames();
- } catch (MembershipServiceException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public Collection<Group> getGroupsForDomain(String domainName)
- throws AdminException {
- if (domainName == null) {
- throwProcessingException("AdminImpl.requiredparameter", new
Object[] {}); //$NON-NLS-1$
- }
- try {
- Collection<String> groupNames =
this.getMembershipService().getGroupsForDomain(domainName);
- List<Group> result = new ArrayList<Group>(groupNames.size());
- for (String groupName : groupNames) {
- result.add(new MMGroup(new String[] {groupName}));
- }
- return result;
- } catch (MembershipServiceException e) {
- throw new AdminComponentException(e);
- }
- }
-
- void throwProcessingException(String key, Object[] objects) throws AdminException {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString(key,
objects));
- }
-
-}
Added: branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
(rev 0)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,229 @@
+/*
+ * 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.adminapi.jboss;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.ManagedOperation.Impact;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementParameter;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.TeiidAdminMBean;
+import org.teiid.adminapi.impl.BaseAdmin;
+import org.teiid.adminapi.impl.ConnectorBindingImpl;
+
+@ManagementObject(description="Teiid Admin Interface",
componentType=@ManagementComponent(type="teiid",subtype="admin"),
properties=ManagementProperties.EXPLICIT, isRuntime=true)
+@JMX(name="jboss.teiid:service=teiid-admin",
exposedInterface=TeiidAdminMBean.class, registerDirectly=true)
+public class Admin extends BaseAdmin implements TeiidAdminMBean{
+
+ private static final long serialVersionUID = 7081309086056911304L;
+ private ManagementView managementView = null;
+
+ private ManagementView getView() throws AdminComponentException {
+ if (this.managementView == null) {
+ try {
+ InitialContext context = new InitialContext();
+ this.managementView =
(ManagementView)context.lookup("java:ManagementView");
+ this.managementView.load();
+ } catch (NamingException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+ return this.managementView;
+ }
+
+ @Override
+ @ManagementOperation(description="Get names of avaialable connector bindings",
impact=Impact.ReadOnly)
+ public Collection<ConnectorBinding> getConnectorBindings() throws AdminException
{
+ ArrayList<ConnectorBinding> bindings = new ArrayList<ConnectorBinding>();
+ findConnectorBindings(bindings, "NoTx");
+ findConnectorBindings(bindings, "Tx");
+ return bindings;
+ }
+
+ @Override
+ @ManagementOperation(description="Get names of avaialable connector bindings",
impact=Impact.ReadOnly)
+ public ConnectorBinding getConnectorBinding(String deployedName) throws AdminException
{
+ Collection<ConnectorBinding> bindings = getConnectorBindings();
+ for(ConnectorBinding cb:bindings) {
+ if (cb.getName().equals(deployedName)) {
+ return cb;
+ }
+ }
+ return null;
+ }
+
+ private void findConnectorBindings(ArrayList<ConnectorBinding> bindings, String
subType) throws AdminException {
+ try {
+ ComponentType type = new ComponentType("ConnectionFactory", subType);
+ Set<ManagedComponent> jcaConnectors = getView().getComponentsForType(type);
+
+ for(ManagedComponent mc:jcaConnectors) {
+ ManagedProperty mp = mc.getProperty("connection-definition");
+ SimpleValueSupport v = (SimpleValueSupport)mp.getValue();
+ if (v.getValue().equals("org.teiid.connector.api.Connector")){
+
+ ConnectorBindingImpl cb = new ConnectorBindingImpl(mc.getName());
+ cb.setComponentType(type);
+ for (String key:mc.getProperties().keySet()) {
+ ManagedProperty property = mc.getProperty(key);
+ MetaValue value = property.getValue();
+
+ //TODO: All properties need to be added
+ if (value != null) {
+ if(value instanceof SimpleValueSupport) {
+ cb.addProperty(key, ManagedUtil.stringValue(value));
+ }
+ else if (value.getMetaType() instanceof MapCompositeValueSupport) {
+ MapCompositeValueSupport v1 = (MapCompositeValueSupport)value;
+ MapCompositeMetaType metaType = v1.getMetaType();
+ for (String configProperty:metaType.keySet()) {
+ cb.addProperty(configProperty,
ManagedUtil.stringValue(v1.get(configProperty)));
+ }
+ }
+ }
+ }
+ bindings.add(cb);
+ }
+ }
+ }catch(Exception e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ @ManagementOperation(description="Add a new Connector Binding",
+ impact=Impact.WriteOnly,
+ params={@ManagementParameter(name="deploymentName", description="Name
of the Connector Binding"),
+ @ManagementParameter(name="typeName", description="Connector Type
Template name"),
+ @ManagementParameter(name="properties", description="Properties for
the Connector Binding")})
+ public void addConnectorBinding(String deploymentName, String typeName, Properties
properties) throws AdminException{
+ try {
+ if (getConnectorBinding(deploymentName) != null) {
+ throw new AdminProcessingException("Connector binding with name
"+deploymentName+" already exists.");
+ }
+
+ DeploymentTemplateInfo info = getView().getTemplate(typeName);
+ if(info == null) {
+ throw new AdminProcessingException("Connector Type template supplied not found
in the configuration."+typeName);
+ }
+
+ // override these properties always.
+ info.getProperties().get("connection-definition").setValue(SimpleValueSupport.wrap("org.teiid.connector.api.Connector"));
+
+ //config-properties list
+ Map<String, String> configProps = new HashMap<String, String>();
+
+ // template properties specific to the template
+ Map<String, ManagedProperty> propertyMap = info.getProperties();
+
+ // walk through the supplied properties and assign properly to either template
+ // of config-properties.
+ for (String key:properties.stringPropertyNames()) {
+ ManagedProperty mp = propertyMap.get(key);
+ if (mp != null) {
+ String value = properties.getProperty(key);
+ if (!ManagedUtil.sameValue(mp.getDefaultValue(), value)){
+ mp.setValue(SimpleValueSupport.wrap(value));
+ }
+ }
+ else {
+ configProps.put(key, properties.getProperty(key));
+ configProps.put(key+".type", "java.lang.String");
+ }
+ }
+
+ if (configProps.size() > 0) {
+ MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
+ info.getProperties().get("config-property").setValue(metaValue);
+ }
+
+ getView().applyTemplate(deploymentName, info);
+
+ } catch (NoSuchDeploymentException e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ } catch(Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void deleteConnectorBinding(String deployedName) throws AdminException {
+ ConnectorBindingImpl cb = (ConnectorBindingImpl)getConnectorBinding(deployedName);
+ if (cb != null) {
+ try {
+ ManagedComponent mc = getView().getComponent(cb.getName(),
(ComponentType)cb.getComponentType());
+ if (mc != null) {
+ getView().removeComponent(mc);
+ }
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+ }
+
+ @Override
+ public Set<String> getConnectorTypes() throws AdminException{
+ Set<String> names = getView().getTemplateNames();
+ HashSet<String> matched = new HashSet<String>();
+ for(String name:names) {
+ if (name.startsWith("connector-")) {
+ matched.add(name);
+ }
+ }
+ return matched;
+ }
+
+ boolean matches(String regEx, String value) {
+ regEx = regEx.replaceAll(AdminObject.ESCAPED_WILDCARD, ".*");
//$NON-NLS-1$
+ regEx = regEx.replaceAll(AdminObject.ESCAPED_DELIMITER, "");
//$NON-NLS-1$
+ return value.matches(regEx);
+ }
+}
Property changes on:
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
(rev 0)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,139 @@
+/*
+ * 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.adminapi.jboss;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Map;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class ManagedUtil {
+
+ public static boolean sameValue(MetaValue v1, String v2) {
+ if (v1 == null || v2 == null) {
+ return false;
+ }
+
+ MetaType type = v1.getMetaType();
+ if (v1 instanceof SimpleValue && type instanceof SimpleMetaType) {
+ SimpleMetaType st = (SimpleMetaType)type;
+ SimpleValue sv = wrap(st, v2);
+ return sv.compareTo((SimpleValue)v1) == 0;
+ }
+ return false;
+ }
+
+ public static boolean sameValue(MetaValue v1, MetaValue v2) {
+ if (v1 == null || v2 == null) {
+ return false;
+ }
+
+ if (v1 instanceof SimpleValue && v2 instanceof SimpleValue) {
+ return ((SimpleValue)v1).compareTo((SimpleValue)v2) == 0;
+ }
+ return false;
+ }
+
+ public static MapCompositeValueSupport compositeValueMap(Map<String, String> map)
{
+ MapCompositeValueSupport metaValue = new
MapCompositeValueSupport(SimpleMetaType.STRING);
+ for (String key : map.keySet()) {
+ MetaValue value = SimpleValueSupport.wrap(map.get(key));
+ metaValue.put(key, value);
+ }
+ return metaValue;
+ }
+
+ public static String stringValue(MetaValue v1) {
+ if (v1 != null) {
+ MetaType type = v1.getMetaType();
+ if (type instanceof SimpleMetaType) {
+ SimpleValue simple = (SimpleValue)v1;
+ return simple.getValue().toString();
+ }
+ throw new MetaMatrixRuntimeException("Failed to convert value to string
value");
+ }
+ return null;
+ }
+
+ public static SimpleValue wrap(MetaType type, String value) {
+ if (type instanceof SimpleMetaType) {
+ SimpleMetaType st = (SimpleMetaType)type;
+
+ if (SimpleMetaType.BIGDECIMAL.equals(st)) {
+ return new SimpleValueSupport(st, new BigDecimal(value));
+ } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
+ return new SimpleValueSupport(st, new BigInteger(value));
+ } else if (SimpleMetaType.BOOLEAN.equals(st)) {
+ return new SimpleValueSupport(st, Boolean.valueOf(value));
+ } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Boolean.valueOf(value).booleanValue());
+ } else if (SimpleMetaType.BYTE.equals(st)) {
+ return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
+ } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, value.getBytes()[0]);
+ } else if (SimpleMetaType.CHARACTER.equals(st)) {
+ return new SimpleValueSupport(st, new Character(value.charAt(0)));
+ } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st,value.charAt(0));
+ } else if (SimpleMetaType.DATE.equals(st)) {
+ try {
+ return new SimpleValueSupport(st, new SimpleDateFormat().parse(value));
+ } catch (ParseException e) {
+ throw new MetaMatrixRuntimeException("Failed to convert the String to date
value");
+ }
+ } else if (SimpleMetaType.DOUBLE.equals(st)) {
+ return new SimpleValueSupport(st, Double.valueOf(value));
+ } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Double.parseDouble(value));
+ } else if (SimpleMetaType.FLOAT.equals(st)) {
+ return new SimpleValueSupport(st, Float.parseFloat(value));
+ } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Float.valueOf(value));
+ } else if (SimpleMetaType.INTEGER.equals(st)) {
+ return new SimpleValueSupport(st, Integer.valueOf(value));
+ } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Integer.parseInt(value));
+ } else if (SimpleMetaType.LONG.equals(st)) {
+ return new SimpleValueSupport(st, Long.valueOf(value));
+ } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Long.parseLong(value));
+ } else if (SimpleMetaType.SHORT.equals(st)) {
+ return new SimpleValueSupport(st, Short.valueOf(value));
+ } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Short.parseShort(value));
+ } else if (SimpleMetaType.STRING.equals(st)) {
+ return new SimpleValueSupport(st,value);
+ }
+ }
+ throw new MetaMatrixRuntimeException("Failed to convert from String value to
\""+ type.getClassName() +"\" type");
+ }
+}
Property changes on:
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
(rev 0)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,143 @@
+/*
+ * 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.templates.connector;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.spi.management.DeploymentTemplate;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.jboss.ManagedUtil;
+
+/**
+ * The connection factory template implementation.
+ */
+public class ConnectorTypeTemplate implements DeploymentTemplate {
+
+ /** The deployment template info. */
+ private DeploymentTemplateInfo info;
+ private DeploymentTemplate targetTemplate;
+
+ /** The file suffix. */
+ private static final String FILE_SUFFIX = "-ds.xml";
+
+
+ public String getDeploymentName(String deploymentBaseName) {
+ if (deploymentBaseName == null)
+ throw new IllegalArgumentException("Null base name.");
+
+ if(deploymentBaseName.endsWith(FILE_SUFFIX) == false)
+ deploymentBaseName = deploymentBaseName + FILE_SUFFIX;
+
+ return deploymentBaseName;
+ }
+
+ public VirtualFile applyTemplate(DeploymentTemplateInfo connectorInfo) throws Exception
{
+ try {
+
+ ManagedProperty rar = connectorInfo.getProperties().get("rar-name");
+ String rarName = ManagedUtil.stringValue(rar.getValue());
+ if (!isValidRar(rarName)) {
+ throw new AdminProcessingException("Invalid RAR specified; please supply correct
RAR file. "+rarName);
+ }
+
+ DeploymentTemplateInfo targetInfo = getTargetTemplate().getInfo();
+
+ // override these properties always.
+ targetInfo.getProperties().get("connection-definition").setValue(SimpleValueSupport.wrap("org.teiid.connector.api.Connector"));
+ connectorInfo.getProperties().get("connection-definition").setValue(SimpleValueSupport.wrap("org.teiid.connector.api.Connector"));
+
+ //config-properties list
+ Map<String, String> configProps = new HashMap<String, String>();
+
+ // template properties specific to the template
+ Map<String, ManagedProperty> propertyMap = targetInfo.getProperties();
+
+ // walk through the supplied properties and assign properly to either template
+ // or config-properties.
+ for (String key:connectorInfo.getProperties().keySet()) {
+ ManagedProperty mp = propertyMap.get(key);
+
+ if (mp != null) {
+ MetaValue value = connectorInfo.getProperties().get(key).getValue();
+ if (ManagedUtil.sameValue(mp.getDefaultValue(), value)) {
+ continue;
+ }
+
+ if (value != null) {
+ mp.setValue(value);
+ }
+ }
+ else {
+ mp = connectorInfo.getProperties().get(key);
+ if (ManagedUtil.sameValue(mp.getDefaultValue(), mp.getValue())) {
+ continue;
+ }
+
+ if (mp.getValue() != null) {
+ configProps.put(key, ManagedUtil.stringValue(mp.getValue()));
+ configProps.put(key+".type",
mp.getValue().getMetaType().getClassName());
+ }
+ }
+ }
+
+ if (configProps.size() > 0) {
+ MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
+ targetInfo.getProperties().get("config-property").setValue(metaValue);
+ }
+ return getTargetTemplate().applyTemplate(targetInfo);
+
+ } catch (NoSuchDeploymentException e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ } catch(Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ private boolean isValidRar(String rarName) {
+ return true;
+ }
+
+ @Override
+ public DeploymentTemplateInfo getInfo() {
+ return info;
+ }
+
+ public void setInfo(DeploymentTemplateInfo info) {
+ this.info = info;
+ }
+
+ private DeploymentTemplate getTargetTemplate() {
+ return this.targetTemplate;
+ }
+
+ public void setTargetTemplate(DeploymentTemplate target) {
+ this.targetTemplate = target;
+ }
+}
Property changes on:
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
(rev 0)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,110 @@
+/*
+ * 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.templates.connector;
+
+import java.util.Collection;
+import java.util.Map;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.BasicDeploymentTemplateInfo;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.resource.metadata.ConfigPropertyMetaData;
+import org.jboss.resource.metadata.ConnectionDefinitionMetaData;
+import org.jboss.resource.metadata.ConnectorMetaData;
+import org.teiid.adminapi.jboss.ManagedUtil;
+
+/**
+ * This class some magic in it. First off all through the configuration it extends the
+ * NoTxConnectionFactoryTemplate. Then using the JMX adds the properties defined inside a
connector
+ * RAR file's ra.xml dynamically the above template. The RAR file name is supplied in
the "description"
+ * field of the configuration. Also, it uses the NoTxConnectionFactoryTemplate
"applyTemplate" to write
+ * the custom properties that have been added thru JMX as "config-property" in
the eventual "-ds.xml" file.
+ */
+public class ConnectorTypeTemplateInfo extends BasicDeploymentTemplateInfo {
+
+ private static final long serialVersionUID = 9066758787789280783L;
+
+ public ConnectorTypeTemplateInfo(String arg0, String arg1, Map<String,
ManagedProperty> arg2) {
+ super(arg0, arg1, arg2);
+ }
+
+ public void start() {
+ populate();
+ }
+
+ @Override
+ public ConnectorTypeTemplateInfo copy() {
+ ConnectorTypeTemplateInfo copy = new ConnectorTypeTemplateInfo(getName(),
getDescription(), getProperties());
+ super.copy(copy);
+ copy.populate();
+ return copy;
+ }
+
+
+ private void populate() {
+ try {
+ MBeanServer server = MBeanServerFactory.findMBeanServer(null).get(0);
+ ObjectName on = new
ObjectName("jboss.jca:service=RARDeployment,name='"+getDescription()+"'");
+ ConnectorMetaData obj = (ConnectorMetaData)server.getAttribute(on,
"MetaData");
+ ConnectionDefinitionMetaData metadata =
obj.getConnectionDefinition("org.teiid.connector.api.Connector");
+ Collection<ConfigPropertyMetaData> props = metadata.getProperties();
+ for (ConfigPropertyMetaData p:props) {
+ addConnectorProperty(p.getName(), p.getType(), p.getDescription().getDescription(),
p.getValue(), false);
+ }
+ } catch (MalformedObjectNameException e) {
+ //ignore
+ } catch (AttributeNotFoundException e) {
+ //ignore
+ } catch (InstanceNotFoundException e) {
+ //ignore
+ } catch (MBeanException e) {
+ //ignore
+ } catch (ReflectionException e) {
+ //ignore
+ }
+ }
+
+ private void addConnectorProperty(String name, String type, String description, String
value, boolean readOnly) {
+ SimpleMetaType metaType = SimpleMetaType.resolve(type);
+
+ DefaultFieldsImpl fields = new DefaultFieldsImpl(name);
+ fields.setDescription(description);
+ fields.setMetaType(metaType);
+ fields.setField(Fields.DEFAULT_VALUE, ManagedUtil.wrap(metaType, value));
+ fields.setField(Fields.READ_ONLY, readOnly);
+ ManagedPropertyImpl dsTypeMP = new ManagedPropertyImpl(fields);
+ addProperty(dsTypeMP);
+ }
+
+}
Property changes on:
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java
===================================================================
---
branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -1,101 +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.dqp.embedded.admin;
-
-import junit.framework.TestCase;
-
-
-/**
- * @since 4.3
- */
-public class TestBaseAdmin extends TestCase {
-
- public void testRegexStuff() {
- assertTrue("RegEx Failed",
"one".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed", "one
two".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one two three
".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed",
"one9_two_Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
"one9_two*Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed", "#one9_two
Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertTrue("RegEx Failed",
"one".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one
".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed",
"one*".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one
two".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed",
"one_TWO_three".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
-
- assertTrue("RegEx Failed",
"one*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed", "one
two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one two
*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "*one
two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed",
"*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
"#two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
"one.*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed",
"one.two".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed",
"one.two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
-
-
- assertTrue("RegEx Failed",
"*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed",
"one*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed",
"one_TWO_three*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
"*one".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed", "*
one".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed",
"*.*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
"one.*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
-
-
- assertTrue("RegEx Failed",
"*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed",
"one.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed",
"one".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed",
"one.two".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
"*.one".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed", "one_two
*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed",
"one.two*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed",
"one.two*.three*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
"one.two**".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed",
"one.two.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed",
"one*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
"one.".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertTrue("RegEx Failed",
"0.10.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
"0.10..*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
"0.10..".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
".one*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- assertFalse("RegEx Failed",
".one_two".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
-
- assertTrue("RegEx Failed",
"One".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed",
"One.1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed",
"*.1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed",
"One.One".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed",
"One*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed",
"One*.101".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed",
"*.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed",
"100.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed",
".1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- //assertTrue("RegEx Failed",
"V0.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertTrue("RegEx Failed", "XML-Relational File
Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "XML
Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "XML&Relational
Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- //assertTrue("RegEx Failed",
"".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
- }
-}
Modified: branches/JCA/pom.xml
===================================================================
--- branches/JCA/pom.xml 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/pom.xml 2009-11-17 13:31:34 UTC (rev 1569)
@@ -353,7 +353,12 @@
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-jboss-integration</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-runtime</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- External dependencies -->
<dependency>
@@ -400,6 +405,30 @@
<artifactId>jbosscache-core</artifactId>
<version>3.1.0.GA</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <version>2.1.0.SP1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-profileservice-spi</artifactId>
+ <version>5.1.0.GA</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <version>2.1.2.GA</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-connector</artifactId>
+ <version>5.1.0.GA</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>com.google.code.guice</groupId>
<artifactId>guice</artifactId>
@@ -442,7 +471,6 @@
<module>txn-jbossts</module>
<module>connector-sdk</module>
<module>test-integration</module>
- <module>jboss-integration</module>
-->
<module>common-core</module>
<module>common-internal</module>
@@ -457,6 +485,7 @@
<module>connector-metadata</module>
<module>cache-jbosscache</module>
<module>hibernate-dialect</module>
+ <module>jboss-integration</module>
</modules>
<distributionManagement>
Modified: branches/JCA/runtime/pom.xml
===================================================================
--- branches/JCA/runtime/pom.xml 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/runtime/pom.xml 2009-11-17 13:31:34 UTC (rev 1569)
@@ -84,9 +84,9 @@
</dependency>
<dependency>
- <groupId>javax.resource</groupId>
- <artifactId>connector-api</artifactId>
- <scope>provided</scope>
- </dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Copied:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java (from
rev 1544,
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java)
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
(rev 0)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,657 @@
+/*
+ * 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.dqp.embedded.admin;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.Cache;
+import org.teiid.adminapi.ExtensionModule;
+import org.teiid.adminapi.Session;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.process.Util;
+
+import com.metamatrix.admin.objects.MMConnectorType;
+import com.metamatrix.admin.objects.MMExtensionModule;
+import com.metamatrix.admin.objects.MMLogConfiguration;
+import com.metamatrix.admin.objects.MMModel;
+import com.metamatrix.admin.objects.MMPropertyDefinition;
+import com.metamatrix.admin.objects.MMRequest;
+import com.metamatrix.admin.objects.MMSession;
+import com.metamatrix.admin.objects.MMVDB;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.security.SessionServiceException;
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.config.api.ComponentType;
+import com.metamatrix.common.config.api.ComponentTypeDefn;
+import com.metamatrix.common.config.api.ConnectorBinding;
+import com.metamatrix.common.log.LogConfigurationImpl;
+import com.metamatrix.common.object.PropertyDefinition;
+import com.metamatrix.common.util.crypto.CryptoException;
+import com.metamatrix.common.util.crypto.CryptoUtil;
+import com.metamatrix.common.vdb.api.VDBArchive;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.service.AuthorizationService;
+import com.metamatrix.dqp.service.ConfigurationService;
+import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.dqp.service.DataService;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+import com.metamatrix.platform.security.api.SessionToken;
+import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
+import com.metamatrix.platform.security.api.service.SessionServiceInterface;
+import com.metamatrix.platform.util.ProductInfoConstants;
+import com.metamatrix.server.serverapi.RequestInfo;
+
+
+/**
+ * @since 4.3
+ */
+abstract class BaseAdmin {
+ static final String DOT = "."; //$NON-NLS-1$
+ static final String STAR = "*"; //$NON-NLS-1$
+ static final String FILE_NAME_REGEX="\\w+\\.\\w+"; //$NON-NLS-1$
+ static final String MULTIPLE_WORDS_REGEX = "\\w+([\\s|-]*\\w)*";
//$NON-NLS-1$
+ static final String SINGLE_WORD_REGEX = "\\w+"; //$NON-NLS-1$
+ static final String MULTIPLE_WORD_WILDCARD_REGEX =
"\\w*((\\.)?\\s*\\w)*(\\*)?"; //$NON-NLS-1$
+ static final String SINGLE_WORD_WILDCARD_REGEX = "\\w*(\\*)?";
//$NON-NLS-1$
+ // This should find word.word.* or word.* kind of patterns (ugly, you can rewrite)
+ static final String WORD_AND_DOT_WILDCARD_REGEX =
"\\w+((\\.\\*)|(\\.\\w+)|(\\.\\w*\\*))*|\\w*(\\*){1}"; //$NON-NLS-1$
+
+ static final String VDB_REGEX = "\\w*(\\*)?(\\.\\d+)?"; //$NON-NLS-1$
+ static final String NUMBER_DOT_REGEX =
"\\d+((\\.\\*)|(\\.\\d+)|(\\.\\d*\\*))*|\\d*(\\*){1}"; //$NON-NLS-1$
+ static final String NUMBER_REGEX = "\\d*(\\*)?"; //$NON-NLS-1$
+
+ static final String[] cacheTypes = {Cache.CODE_TABLE_CACHE,
+ Cache.CONNECTOR_RESULT_SET_CACHE,
+ Cache.PREPARED_PLAN_CACHE,
+ Cache.QUERY_SERVICE_RESULT_SET_CACHE
+ };
+
+ private EmbeddedConnectionFactoryImpl manager = null;
+
+ BaseAdmin(EmbeddedConnectionFactoryImpl manager){
+ this.manager = manager;
+ }
+
+ protected AdminException accumulateSystemException(AdminException parent, Exception
e) {
+ if (parent == null) {
+ return new AdminComponentException(e);
+ }
+ parent.addChild(new AdminComponentException(e));
+ return parent;
+ }
+
+ protected AdminException accumulateProcessingException(AdminException parent,
Exception e) {
+ if (parent == null) {
+ return new AdminProcessingException(e);
+ }
+ parent.addChild(new AdminProcessingException(e));
+ return parent;
+ }
+
+ protected String prettyPrintBindingNames(List bindings) {
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator iter = bindings.iterator(); iter.hasNext();) {
+ ConnectorBinding binding = (ConnectorBinding) iter.next();
+ buffer.append(binding.getDeployedName());
+ if (iter.hasNext()) {
+ buffer.append(", "); //$NON-NLS-1$
+ }
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * @return Returns the manager.
+ * @since 4.3
+ */
+ public EmbeddedConnectionFactoryImpl getManager() {
+ return this.manager;
+ }
+
+ VDBService getVDBService() {
+ return (VDBService)getManager().findService(DQPServiceNames.VDB_SERVICE);
+ }
+
+ DataService getDataService() {
+ return (DataService)getManager().findService(DQPServiceNames.DATA_SERVICE);
+ }
+
+ TransactionService getTransactionService() {
+ return
(TransactionService)getManager().findService(DQPServiceNames.TRANSACTION_SERVICE);
+ }
+
+ MembershipServiceInterface getMembershipService() {
+ return
(MembershipServiceInterface)getManager().findService(DQPServiceNames.MEMBERSHIP_SERVICE);
+ }
+
+ AuthorizationService getAuthorizationService() {
+ return
(AuthorizationService)getManager().findService(DQPServiceNames.AUTHORIZATION_SERVICE);
+ }
+
+ ConfigurationService getConfigurationService() {
+ return
(ConfigurationService)getManager().findService(DQPServiceNames.CONFIGURATION_SERVICE);
+ }
+
+ SessionServiceInterface getSessionService() {
+ return
(SessionServiceInterface)getManager().findService(DQPServiceNames.SESSION_SERVICE);
+ }
+
+ protected Object convertToAdminObjects(Object src) {
+ return convertToAdminObjects(src,null);
+ }
+
+ protected Object convertToAdminObjects(Object src, Object parent) {
+ if (src == null) {
+ return src;
+ }
+
+ if (src instanceof List) {
+ List modified = new ArrayList();
+ List list = (List)src;
+ for (final Iterator i = list.iterator(); i.hasNext();) {
+ final Object e = i.next();
+ Object converted = convertToAdminObject(e, parent);
+ modified.add(converted);
+ }
+ return modified;
+ }
+ else if (src instanceof Collection) {
+ List modified = new ArrayList();
+ for (Iterator i = ((Collection)src).iterator(); i.hasNext();) {
+ final Object e = i.next();
+ Object converted = convertToAdminObject(e, parent);
+ modified.add(converted);
+ }
+ return modified;
+ }
+ else if (src instanceof Object[] ) {
+ List modified = new ArrayList();
+ Object[] srcArray = (Object[])src;
+ for (int i = 0; i < srcArray.length; i++) {
+ final Object converted = convertToAdminObject(srcArray[i], parent);
+ modified.add(converted);
+ }
+ return modified;
+ }
+ return convertToAdminObject(src, parent);
+ }
+
+
+ private Object convertToAdminObject(Object src, Object parent) {
+ if (src != null && src instanceof
com.metamatrix.common.config.api.ConnectorBinding) {
+ com.metamatrix.common.config.api.ConnectorBinding binding =
(com.metamatrix.common.config.api.ConnectorBinding)src;
+ return convertConnectorType(binding, parent);
+ }
+ else if (src != null && src instanceof
com.metamatrix.common.config.api.ConnectorBindingType) {
+ com.metamatrix.common.config.api.ConnectorBindingType type =
(com.metamatrix.common.config.api.ConnectorBindingType)src;
+ return convertConnectorType(type, parent);
+ }
+ else if (src != null && src instanceof
com.metamatrix.common.vdb.api.VDBDefn) {
+ com.metamatrix.common.vdb.api.VDBDefn vdb =
(com.metamatrix.common.vdb.api.VDBDefn)src;
+ return convertVDB(vdb, parent);
+ }
+ else if (src != null && src instanceof VDBArchive) {
+ VDBArchive vdb = (VDBArchive)src;
+ return convertVDB(vdb.getConfigurationDef(), parent);
+ }
+ else if (src != null && src instanceof
com.metamatrix.common.vdb.api.ModelInfo) {
+ com.metamatrix.common.vdb.api.ModelInfo model =
(com.metamatrix.common.vdb.api.ModelInfo)src;
+ return convertModel(model, parent);
+ }
+ else if (src != null && src instanceof
com.metamatrix.common.log.LogConfiguration) {
+ com.metamatrix.common.log.LogConfiguration config =
(com.metamatrix.common.log.LogConfiguration)src;
+ return covertLogConfiguration(config);
+ }
+ else if (src != null && src instanceof
com.metamatrix.server.serverapi.RequestInfo) {
+ com.metamatrix.server.serverapi.RequestInfo request =
(com.metamatrix.server.serverapi.RequestInfo)src;
+ return convertRequest(request);
+ }
+ else if (src != null && src instanceof
com.metamatrix.common.queue.WorkerPoolStats) {
+ com.metamatrix.common.queue.WorkerPoolStats stats =
(com.metamatrix.common.queue.WorkerPoolStats)src;
+ return Util.convertStats(stats, stats.getQueueName());
+ }
+ else if (src != null && src instanceof MetaMatrixSessionInfo) {
+ MetaMatrixSessionInfo conn = (MetaMatrixSessionInfo)src;
+ return convertConnection(conn);
+ }
+ else if (src != null && src instanceof
com.metamatrix.common.config.api.ExtensionModule) {
+ com.metamatrix.common.config.api.ExtensionModule extModule =
(com.metamatrix.common.config.api.ExtensionModule)src;
+ return convertExtensionModule(extModule);
+ }
+ else {
+ if (src == null) {
+ return null;
+ }
+ throw new
UnsupportedOperationException(DQPEmbeddedPlugin.Util.getString("UnSupported_object_conversion"));
//$NON-NLS-1$
+ }
+ }
+
+ Object convertToNativeObjects(Object src) {
+ if (src instanceof org.teiid.adminapi.LogConfiguration) {
+ org.teiid.adminapi.LogConfiguration config =
(org.teiid.adminapi.LogConfiguration)src;
+ return covertToNativeLogConfiguration(config);
+ }
+ throw new
UnsupportedOperationException(DQPEmbeddedPlugin.Util.getString("UnSupported_object_conversion"));
//$NON-NLS-1$
+ }
+
+
+ private ExtensionModule
convertExtensionModule(com.metamatrix.common.config.api.ExtensionModule src) {
+ MMExtensionModule module = new MMExtensionModule(new String[]
{src.getFullName()}) ;
+ module.setDescription(src.getDescription());
+ module.setFileContents(src.getFileContents());
+ module.setModuleType(src.getModuleType());
+ return module;
+ }
+
+ private Session convertConnection(MetaMatrixSessionInfo src) {
+ MMSession session = new MMSession(new String[] {src.getSessionID().toString()});
+ session.setVDBName(src.getProductInfo(ProductInfoConstants.VIRTUAL_DB));
+ session.setVDBVersion(src.getProductInfo(ProductInfoConstants.VDB_VERSION));
+ session.setApplicationName(src.getApplicationName());
+ session.setIPAddress(src.getClientIp());
+ session.setHostName(src.getClientHostname());
+ session.setUserName(src.getUserName());
+ session.setLastPingTime(src.getLastPingTime());
+ session.setCreated(new Date(src.getTimeCreated()));
+ return session;
+ }
+
+ /**
+ * Convert LogConfiguration to Admin Object
+ */
+ private org.teiid.adminapi.LogConfiguration covertLogConfiguration(final
com.metamatrix.common.log.LogConfiguration src) {
+ Map<String, Integer> contextMap = new HashMap<String, Integer>();
+ for(String context:src.getContexts()) {
+ contextMap.put(context, src.getLogLevel(context));
+ }
+ return new MMLogConfiguration(contextMap);
+ }
+
+ /**
+ * Convert LogConfiguration to Admin Object
+ */
+ private com.metamatrix.common.log.LogConfiguration
covertToNativeLogConfiguration(final org.teiid.adminapi.LogConfiguration src) {
+ Map<String, Integer> contextMap = new HashMap<String, Integer>();
+ for(String context:src.getContexts()) {
+ contextMap.put(context, src.getLogLevel(context));
+ }
+ return new LogConfigurationImpl(contextMap);
+ }
+
+ /**
+ * @param binding
+ * @return
+ * @since 4.3
+ */
+ private org.teiid.adminapi.ConnectorBinding convertConnectorType(final
com.metamatrix.common.config.api.ConnectorBinding src, final Object parent) {
+// MMConnectorBinding binding = new MMConnectorBinding(new String[]
{src.getDeployedName()});
+//
+// binding.setConnectorTypeName(src.getComponentTypeID().getFullName());
+// binding.setCreated(src.getCreatedDate());
+// binding.setCreatedBy(src.getCreatedBy());
+// binding.setDescription(src.getDescription());
+// binding.setEnabled(src.isEnabled());
+// binding.setLastUpdated(src.getLastChangedDate());
+// binding.setLastUpdatedBy(src.getLastChangedBy());
+// binding.setProperties(src.getProperties());
+// binding.setRegistered(true);
+// binding.setRoutingUUID(src.getRoutingUUID());
+// binding.setServiceID(0); // TODO:
+
+ // Binding state needs to be converted into pool state; until then we use
+ // binding state as pool state.
+// try {
+// ConnectorStatus status =
getDataService().getConnectorBindingState(src.getDeployedName());
+// switch(status) {
+// case OPEN:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_OPEN);
+// break;
+// case NOT_INITIALIZED:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_NOT_INITIALIZED);
+// break;
+// case CLOSED:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_CLOSED);
+// break;
+// case DATA_SOURCE_UNAVAILABLE:
+//
binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_DATA_SOURCE_UNAVAILABLE);
+// break;
+// case INIT_FAILED:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_INIT_FAILED);
+// break;
+// case UNABLE_TO_CHECK:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_FAILED_TO_CHECK);
+// break;
+// }
+// }catch(MetaMatrixComponentException e) {
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_NOT_DEPLOYED);
+// }
+// binding.setStateChangedTime(src.getLastChangedDate());
+// return binding;
+ return null;
+ }
+
+ /**
+ * @param type
+ * @return
+ * @since 4.3
+ */
+ private org.teiid.adminapi.ConnectorType convertConnectorType(final
com.metamatrix.common.config.api.ConnectorBindingType src, final Object parent) {
+ MMConnectorType type = new MMConnectorType(new String[] {src.getName()});
+ type.setCreated(src.getCreatedDate());
+ type.setCreatedBy(src.getCreatedBy());
+ type.setEnabled(true);
+ type.setLastUpdated(src.getLastChangedDate());
+ type.setRegistered(true);
+
+ return type;
+ }
+
+ /**
+ * @param vdb
+ * @return
+ * @since 4.3
+ */
+ private org.teiid.adminapi.VDB convertVDB(final com.metamatrix.common.vdb.api.VDBDefn
src, final Object parent) {
+
+ MMVDB vdb = new MMVDB(new String[] {src.getName(), src.getVersion()});
+ vdb.setCreated(src.getDateCreated());
+ vdb.setCreatedBy(src.getCreatedBy());
+ vdb.setEnabled(src.isActiveStatus());
+ vdb.setLastUpdated(src.getDateCreated());
+ vdb.setLastUpdatedBy(src.getCreatedBy());
+ vdb.setMaterializedViews(src.getMatertializationModel() != null);
+ vdb.setModels((Collection)convertToAdminObjects(src.getModels(), src));
+ vdb.setProperties(null);
+ vdb.setRegistered(true);
+ vdb.setStatus(src.getStatus());
+ vdb.setUID(0); // TODO: src.getUUID());
+ vdb.setVersionedBy(src.getCreatedBy());
+ vdb.setVersionedDate(src.getDateCreated());
+ vdb.setHasWSDL(src.hasWSDLDefined());
+
+ return vdb;
+ }
+
+ private org.teiid.adminapi.Model convertModel(final
com.metamatrix.common.vdb.api.ModelInfo src, final Object parent) {
+ final com.metamatrix.common.vdb.api.VDBDefn vdb =
(com.metamatrix.common.vdb.api.VDBDefn)parent;
+ MMModel model = new MMModel(new String[] {src.getName()});
+ model.setCreated(vdb.getDateCreated());
+ model.setCreatedBy(vdb.getCreatedBy());
+ model.setEnabled(vdb.isActiveStatus());
+ model.setLastUpdated(vdb.getDateCreated());
+ model.setLastUpdatedBy(vdb.getCreatedBy());
+ model.setModelType(src.getModelTypeName());
+ model.setModelURI(src.getModelURI());
+ model.setMaterialization(src.isMaterialization());
+ model.setPhysical(src.isPhysical());
+ model.setRegistered(true);
+ model.setSupportsMultiSourceBindings(src.isMultiSourceBindingEnabled());
+ model.setVisible(src.isVisible());
+ if (src.isPhysical()) {
+ List bindings = src.getConnectorBindingNames();
+ if (bindings != null && !bindings.isEmpty()) {
+ List names = new ArrayList();
+ for (int i=0; i<bindings.size();i++) {
+
names.add(convertToAdminObject(vdb.getConnectorBindingByName((String)bindings.get(i)),
parent));
+ }
+ model.setConnectorBindingNames(names);
+ }
+ }
+ return model;
+ }
+
+ private org.teiid.adminapi.Request convertRequest(final RequestInfo src) {
+
+ String connId = src.getRequestID().getConnectionID();
+
+ MMRequest request = null;
+ if (src.getConnectorBindingUUID() != null) {
+ request = new MMRequest(new String[] {connId,
String.valueOf(src.getRequestID().getExecutionID()), String.valueOf(src.getNodeID()),
String.valueOf(src.getExecutionID())});
+ }
+ else {
+ request = new MMRequest(new String[] {connId,
String.valueOf(src.getRequestID().getExecutionID())});
+ }
+
+ request.setSqlCommand(src.getCommand());
+
+ request.setCreated(src.getProcessingTimestamp());
+
+ if (src.getConnectorBindingUUID() != null) {
+ request.setSource(true);
+ request.setNodeID(String.valueOf(src.getNodeID()));
+ }
+ return request;
+ }
+
+ /**
+ * Get the connection connection object for the given id.
+ * @param identifier
+ * @return
+ * @since 4.3
+ */
+ MetaMatrixSessionInfo getClientConnection(String identifier) throws AdminException {
+ Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
+ for (MetaMatrixSessionInfo info:sessions) {
+ if (info.getSessionID().toString().equals(identifier)) {
+ return info;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get all the available connections
+ * @return
+ * @throws AdminException
+ */
+ Collection<MetaMatrixSessionInfo> getClientConnections() throws AdminException
{
+ try {
+ return getSessionService().getActiveSessions();
+ } catch (SessionServiceException e) {
+ // SessionServiceException not in the client known exception (in common-internal)
+ throw new AdminComponentException(e.getMessage(), e.getCause());
+ }
+ }
+
+ boolean matches(String regEx, String value) {
+ regEx = regEx.replaceAll(AdminObject.ESCAPED_WILDCARD, ".*");
//$NON-NLS-1$
+ regEx = regEx.replaceAll(AdminObject.ESCAPED_DELIMITER, "");
//$NON-NLS-1$
+ return value.matches(regEx);
+ }
+
+ List matchedCollection(String identifier, List adminObjects) {
+ ArrayList matched = new ArrayList();
+ for (Iterator i = adminObjects.iterator(); i.hasNext();) {
+ AdminObject aObj = (AdminObject)i.next();
+ if (matches(identifier, aObj.getName()) || matches(identifier,
aObj.getName())) {
+ matched.add(aObj);
+ }
+ }
+ return matched;
+ }
+
+ /**
+ * Get list of available connector bindings
+ * @param identifier
+ */
+ Collection getConnectorBindings(String identifier) throws AdminException{
+// try {
+// List connectorBindings = getDataService().getConnectorBindings();
+// connectorBindings = (List)convertToAdminObjects(connectorBindings);
+// return matchedCollection(identifier, connectorBindings);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return Collections.EMPTY_LIST;
+ }
+
+
+ /**
+ * Get list of available connector types
+ * @param identifier
+ */
+ Collection getConnectorTypes(String identifier) throws AdminException{
+
+// try {
+// List connectorTypes = getConfigurationService().getConnectorTypes();
+// connectorTypes = (List)convertToAdminObjects(connectorTypes);
+// return matchedCollection(identifier, connectorTypes);
+// } catch (MetaMatrixComponentException err) {
+// throw new AdminComponentException(err);
+// }
+ return null;
+ }
+
+ boolean isMaskedProperty(String propName, ComponentType type) {
+ if (type != null) {
+ ComponentTypeDefn typeDef = type.getComponentTypeDefinition(propName);
+ if (typeDef != null && typeDef.getPropertyDefinition().isMasked()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Encrypt a string
+ * @param value
+ * @return
+ * @throws AdminException
+ * @since 4.3
+ */
+ String encryptString(String value) throws AdminException {
+ try {
+ return CryptoUtil.stringEncrypt(value);
+ } catch (CryptoException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+
+
+ /**
+ * Convert a ComponentType and a set of properties into a Collection of
+ * com.metamatrix.admin.api.objects.PropertyDefinition objects
+ * @param ctype
+ * @param properties
+ * @return
+ * @since 4.3
+ */
+ protected Collection convertPropertyDefinitions(ComponentType ctype, Properties
properties) {
+ ArrayList results = new ArrayList();
+ for (Iterator iter = ctype.getComponentTypeDefinitions().iterator();
iter.hasNext(); ) {
+ ComponentTypeDefn cdefn = (ComponentTypeDefn) iter.next();
+ PropertyDefinition pdefn = cdefn.getPropertyDefinition();
+
+ MMPropertyDefinition result = new MMPropertyDefinition(new String[]
{pdefn.getName()});
+ result.setAllowedValues(pdefn.getAllowedValues());
+ result.setDefaultValue(pdefn.getDefaultValue());
+ result.setDescription(pdefn.getShortDescription());
+ result.setDisplayName(pdefn.getDisplayName());
+ result.setExpert(pdefn.isExpert());
+ result.setMasked(pdefn.isMasked());
+ result.setModifiable(pdefn.isModifiable());
+ result.setPropertyType(pdefn.getPropertyType().getDisplayName());
+ result.setPropertyTypeClassName(pdefn.getPropertyType().getClassName());
+ result.setRequired(pdefn.isRequired());
+ result.setRequiresRestart(pdefn.getRequiresRestart());
+
+ String value = properties.getProperty(pdefn.getName());
+ result.setValue(value);
+
+ results.add(result);
+ }
+
+
+ return results;
+ }
+
+
+ /**
+ * Convert a set of properties into a Collection of
+ * com.metamatrix.admin.api.objects.PropertyDefinition objects
+ *
+ * @param ctype
+ * @param properties
+ * @return
+ * @since 4.3
+ */
+ protected Collection convertPropertyDefinitions(Properties properties) {
+ ArrayList results = new ArrayList();
+ for (Iterator iter = properties.keySet().iterator(); iter.hasNext(); ) {
+ String key = (String) iter.next();
+ String value = properties.getProperty(key);
+
+ MMPropertyDefinition result = new MMPropertyDefinition(new String[] {key});
+ result.setDisplayName(key);
+ result.setValue(value);
+
+ results.add(result);
+ }
+
+
+ return results;
+ }
+
+ protected SessionToken validateSession() {
+ return DQPWorkContext.getWorkContext().getSessionToken();
+ }
+
+ protected void changeVDBStatus(String name, String version, int status)
+ throws AdminException {
+ try {
+
+ if (name == null || version == null || !name.matches(SINGLE_WORD_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name"));
//$NON-NLS-1$
+ }
+
+ // Now change the VDB status it self
+ this.getVDBService().changeVDBStatus(name, version, status);
+
+ // If the VDB is modified and if its status changed to DELETED, then
+ // we can remove all the connector bindings associated with this VDB
+ // the above delete will also remove them
+ } catch (ApplicationLifecycleException e) {
+ throw new AdminComponentException(e);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+}
Property changes on:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
(from rev 1544,
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java)
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
(rev 0)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,1058 @@
+/*
+ * 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.dqp.embedded.admin;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.ConfigurationAdmin;
+import org.teiid.adminapi.EmbeddedLogger;
+import org.teiid.adminapi.LogConfiguration;
+import org.teiid.adminapi.VDB;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.config.api.ComponentType;
+import com.metamatrix.common.config.api.ComponentTypeDefn;
+import com.metamatrix.common.config.api.ConnectorArchive;
+import com.metamatrix.common.config.api.ConnectorBinding;
+import com.metamatrix.common.config.api.ConnectorBindingType;
+import com.metamatrix.common.config.api.ExtensionModule;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.crypto.CryptoException;
+import com.metamatrix.common.util.crypto.CryptoUtil;
+import com.metamatrix.common.vdb.api.VDBArchive;
+import com.metamatrix.common.vdb.api.VDBDefn;
+import com.metamatrix.core.vdb.VDBStatus;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.embedded.configuration.ConnectorConfigurationReader;
+import com.metamatrix.dqp.embedded.configuration.VDBConfigurationReader;
+import com.metamatrix.dqp.service.ConfigurationService;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+
+
+/**
+ * DQP implementation of the Config Admin API
+ * @since 4.3
+ */
+public abstract class DQPConfigAdminImpl extends BaseAdmin implements ConfigurationAdmin
{
+
+ public DQPConfigAdminImpl(EmbeddedConnectionFactoryImpl manager) {
+ super(manager);
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#setProperty(java.lang.String,
java.lang.String, java.lang.String, java.lang.String)
+ * @since 4.3
+ */
+ public void setConnectorBindingProperty(String deployedName, String propertyName,
String propertyValue)
+ throws AdminException {
+
+// try {
+// ConnectorBinding binding =
getConfigurationService().getConnectorBinding(deployedName);
+// if (binding == null) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.cb_doesnot_exist",
deployedName)); //$NON-NLS-1$
+// }
+//
+// ComponentTypeID id = binding.getComponentTypeID();
+// ConnectorBindingType type =
getConfigurationService().getConnectorType(id.getName());
+//
+// boolean needsEncryption = isMaskedProperty(propertyName, type);
+// if (needsEncryption) {
+// propertyValue = encryptString(propertyValue);
+// }
+//
+// Properties p = new Properties();
+// p.setProperty(propertyName, propertyValue);
+//
+// //update the configuration
+// binding = ConnectorConfigurationReader.addConnectorBindingProperties(binding, p);
+// getConfigurationService().updateConnectorBinding(binding);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorType(java.lang.String,
char[])
+ * @since 4.3
+ */
+ public void addConnectorType(String deployName, char[] cdkFile)
+ throws AdminException {
+// try {
+// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
+// }
+// if (cdkFile == null || cdkFile.length == 0) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_source"));
//$NON-NLS-1$
+// }
+//
+// // This is only place we check the existence in admin. Generally the Admin
is not the
+// // guy to decide, if it can take in or not, it should be the service. I did
not
+// // want add in the configuration service beacuse, it may need to allow this
behavior
+// // in case we are updating.
+// if (getConfigurationService().getConnectorType(deployName) == null) {
+// ConnectorBindingType type =
ConnectorConfigurationReader.loadConnectorType(cdkFile);
+// saveConnectorType(type);
+// }
+// else {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_exists",
deployName)); //$NON-NLS-1$
+// }
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#deleteConnectorType(java.lang.String)
+ * @since 4.3
+ */
+ public void deleteConnectorType(String deployName)
+ throws AdminException {
+// try {
+// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
+// }
+// getConfigurationService().deleteConnectorType(deployName);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorBinding(java.lang.String,
java.lang.String, java.util.Properties, AdminOptions)
+ * @since 4.3
+ */
+ public org.teiid.adminapi.ConnectorBinding addConnectorBinding(String deployName,
String type, Properties properties, AdminOptions options)
+ throws AdminException {
+// // if the options object is null treat as if it is IGNORE as default
+// if (options == null) {
+// options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
+// }
+//
+// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
+// }
+//
+// if (type == null || !type.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
+// }
+//
+// ConnectorBinding binding = null;
+// try {
+// // Check if the binding exists already, if does take action based on user
+// // preferences in the admin options
+// if (bindingExists(deployName)) {
+// // Based on users preference, either add or replace or ignore
+// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists",
deployName)); //$NON-NLS-1$
+// }
+// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
+// binding = getDataService().getConnectorBinding(deployName);
+// return (org.teiid.adminapi.ConnectorBinding)
convertToAdminObjects(binding);
+// }
+// }
+//
+// // Get the connector type
+// ConnectorBindingType ctype =
getConfigurationService().getConnectorType(type);
+// if (ctype == null) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_type_not_exists",
type)); //$NON-NLS-1$
+// }
+//
+// // Build the connector binding with informatin we know.
+// binding = ConnectorConfigurationReader.loadConnectorBinding(deployName,
properties, ctype);
+//
+// // Check that the connector binding passwords can be decrypted
+// try {
+// checkDecryption(binding, ctype);
+// } catch(CryptoException e) {
+// if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR))
{
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED",
binding.getFullName())); //$NON-NLS-1$
+// }
+// }
+//
+// // now that all of the input parameters validated, add the connector
binding
+// binding = addConnectorBinding(deployName, binding, ctype, false);
+//
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
+
+ return null;
+ }
+
+ boolean bindingExists(String name) throws MetaMatrixComponentException {
+// ConnectorBinding binding = getDataService().getConnectorBinding(name);
+// return (binding != null);
+ return false;
+ }
+
+ boolean bindingTypeExists(String name) throws MetaMatrixComponentException {
+// ConnectorBindingType type = getConfigurationService().getConnectorType(name);
+// return (type != null);
+ return false;
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorBinding(java.lang.String,
char[], AdminOptions)
+ * @since 4.3
+ */
+ public org.teiid.adminapi.ConnectorBinding addConnectorBinding(String deployName,
char[] xmlFile, AdminOptions options)
+ throws AdminException {
+
+// // if the options object is null treat as if it is IGNORE as default
+// if (options == null) {
+// options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
+// }
+//
+// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
+// }
+// if (xmlFile == null || xmlFile.length == 0) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_source"));
//$NON-NLS-1$
+// }
+//
+// ConnectorBinding binding = null;
+// try {
+// // Check if the binding exists already, if does take action based on user
+// // preferences in the admin options
+// if (bindingExists(deployName)) {
+// // Based on users preference, either add or replace or ignore
+// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists",
deployName)); //$NON-NLS-1$
+// }
+// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
+// binding = getDataService().getConnectorBinding(deployName);
+// return (org.teiid.adminapi.ConnectorBinding)
convertToAdminObjects(binding);
+// }
+// }
+//
+// // now we are in situation we do have the connector or overwriting it.
+// // before we add the connector binding we need to add the connector type
+// // as the connector binding only references to type by identifier.
+// ConnectorBindingType type =
ConnectorConfigurationReader.loadConnectorType(xmlFile);
+//
+// // Check if the binding type exists already, if does take action based on
user
+// // preferences in the admin options, same rules apply as binding.
+// boolean addType = true;
+// if (bindingTypeExists(type.getName())) {
+// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBinding_type_exists",
deployName, type.getName())); //$NON-NLS-1$
+// }
+// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
+// addType = false;
+// }
+// }
+//
+// binding = ConnectorConfigurationReader.loadConnectorBinding(deployName,
xmlFile);
+//
+// // Check that the connector binding passwords can be decrypted
+// try {
+// checkDecryption(binding, type);
+// } catch(CryptoException e) {
+// if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR))
{
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED",
binding.getFullName())); //$NON-NLS-1$
+// }
+// }
+//
+// // now that all of the input parameters validated, add the connector
binding
+// binding = addConnectorBinding(deployName, binding, type, addType);
+//
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+//
+// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
+ return null;
+ }
+
+ /**
+ * Helper method to add the connector binding..
+ * @param deployName
+ * @param binding
+ * @param type
+ * @param options
+ * @throws AdminException
+ */
+ ConnectorBinding addConnectorBinding(String deployName, ConnectorBinding binding,
ConnectorBindingType type, boolean addType)
+ throws AdminException {
+ // Make sure we have both correctly configured
+ if (type != null && binding != null) {
+ if (binding.getComponentTypeID().getName().equals(type.getName())) {
+ try {
+
+ // First add the connector type if one is not already in here.
+// if (getConfigurationService().getConnectorType(type.getName()) ==
null || addType) {
+// saveConnectorType(type);
+// }
+ // Now add the connector binding.
+ binding = getConfigurationService().addConnectorBinding(deployName,
binding, true);
+ return binding;
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_load_failed_wrong_type",
deployName)); //$NON-NLS-1$
+ }
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_load_failed_wrong_contents",
deployName)); //$NON-NLS-1$
+ }
+
+ /**
+ * @see
org.teiid.adminapi.ConfigurationAdmin#deleteConnectorBinding(java.lang.String)
+ * @since 4.3
+ */
+ public void deleteConnectorBinding(String identifier)
+ throws AdminException {
+// try {
+// if (identifier == null ||
!identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
+// }
+// getConfigurationService().deleteConnectorBinding(identifier);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addVDB(java.lang.String, byte[],
char[], AdminOptions)
+ * @since 4.3
+ */
+ private VDB addVDB(String deployName, byte[] vdbFile, char[] defFile, AdminOptions
options)
+ throws AdminException {
+
+ // if the options object is null treat as if it is BINDINGS_ADD as default
+ if (options == null) {
+ options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
+ }
+
+ if (deployName == null || !deployName.matches(SINGLE_WORD_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name"));
//$NON-NLS-1$
+ }
+ if (vdbFile == null || vdbFile.length == 0) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_source"));
//$NON-NLS-1$
+ }
+
+ if (defFile == null) {
+ DQPEmbeddedPlugin.logInfo("Admin.load_combined_vdb", new Object[]
{deployName}); //$NON-NLS-1$
+ }
+
+ VDBArchive vdb = null;
+ try {
+ // Load the VDB from the files
+ if (defFile == null) {
+ vdb = VDBConfigurationReader.loadVDB(deployName, vdbFile);
+ }
+ else {
+ vdb = VDBConfigurationReader.loadVDB(deployName, defFile, vdbFile);
+ }
+
+ // Add the connector binding in the VDB to the system
+ validateConnectorBindingsInVdb(vdb, options);
+
+ // now deploy the VDB into the system. Flag is to
+ VDBArchive deployedVDB = getConfigurationService().addVDB(vdb,
!options.containsOption(AdminOptions.OnConflict.IGNORE));
+
+ // If the connector bindings are correctly initialized and VDB is active
+ // start the bindings automatically.
+ if ( (deployedVDB.getStatus() == VDBStatus.ACTIVE) ||
+ (deployedVDB.getStatus() == VDBStatus.ACTIVE_DEFAULT) ) {
+ try {
+ startVDBConnectorBindings(deployedVDB);
+ } catch (MetaMatrixComponentException e) {
+ } catch (ApplicationLifecycleException e) {
+ // we can safely ignore these because the cause of the not starting
is already recorded
+ // and more likely VDB deployment succeeded.
+ }
+ }
+
+ return (VDB) convertToAdminObjects(deployedVDB);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * Start the connector bindings in the given VDB
+ * @param vdb
+ */
+ private void startVDBConnectorBindings(VDBArchive vdb) throws
MetaMatrixComponentException,
+ ApplicationLifecycleException {
+//
+// VDBDefn def = vdb.getConfigurationDef();
+// Collection<ConnectorBinding> bindings =
def.getConnectorBindings().values();
+// for (ConnectorBinding binding:bindings) {
+// getDataService().startConnectorBinding(binding.getDeployedName());
+// }
+ }
+
+ /**
+ * Validate the connector bindings in a VDB. Since the connector bindings in VDB
+ * are VDB scoped there is no meaning for the admin options provided. Just check
+ * the decrypt properties.
+ */
+ void validateConnectorBindingsInVdb(VDBArchive vdb, AdminOptions options)
+ throws MetaMatrixComponentException, AdminProcessingException, AdminException {
+
+ VDBDefn def = vdb.getConfigurationDef();
+
+ int version = 0;
+ VDBArchive existing = null;
+ do {
+ version++;
+ existing = getConfigurationService().getVDB(def.getName(),
String.valueOf(version));
+ } while(existing != null);
+
+ // Look for the connector bindings in the VDB
+ // Based on users preference, either add or replace or throw exception
+ List vdbbindings = new ArrayList(def.getConnectorBindings().values());
+
+ for (Iterator i = vdbbindings.iterator(); i.hasNext();) {
+ ConnectorBinding binding = (ConnectorBinding)i.next();
+
+ String deployName = binding.getDeployedName();
+ if (deployName == null) {
+ deployName = binding.getFullName();
+ }
+
+ if (bindingExists(deployName)) {
+ if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists",
binding.getDeployedName())); //$NON-NLS-1$
+ }
+ }
+
+ // when the binding is not found it falls in "add",
"overwrite" or "ignore"
+ // first two cases we need to add.
+ ConnectorBindingType type =
(ConnectorBindingType)def.getConnectorType(binding.getComponentTypeID().getName());
+
+ // Check that the connector binding passwords can be decrypted
+ try {
+ checkDecryption(binding, type);
+ } catch(CryptoException e) {
+ if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED",
binding.getFullName())); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ /**
+ * Check that the properties of the specified ConnectorBinding can be decrypted.
+ * @param
+ * @return
+ * @since 4.3
+ */
+ private void checkDecryption(ConnectorBinding binding, ConnectorBindingType type)
throws CryptoException {
+ Properties props = binding.getProperties();
+ Iterator it = props.keySet().iterator();
+ while (it.hasNext()) {
+ String name = (String)it.next();
+ if (isMaskedProperty(name, type)) {
+ decryptProperty(props.getProperty(name));
+ }
+ }
+ }
+
+ /**
+ * Check to see if the property read is a masked/encoded property
+ * @param propName
+ * @param type
+ * @return
+ */
+ boolean isMaskedProperty(String propName, ComponentType type) {
+ if (type != null) {
+ ComponentTypeDefn typeDef = type.getComponentTypeDefinition(propName);
+ if (typeDef != null && typeDef.getPropertyDefinition().isMasked()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Decrypt the given property using the Crypto libraries.
+ * @param value
+ * @return decrypted property.
+ */
+ String decryptProperty(String value) throws CryptoException{
+ if (value != null && value.length() > 0 &&
CryptoUtil.isValueEncrypted(value)) {
+ return CryptoUtil.stringDecrypt(value);
+ }
+ return value;
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addVDB(java.lang.String, byte[],
AdminOptions)
+ * @since 4.3
+ */
+ public VDB addVDB(String deployName, byte[] vdbFile, AdminOptions options)
+ throws AdminException {
+ return addVDB(deployName, vdbFile, null, options);
+ }
+
+ @Override
+ public void deleteVDB(String vdbName, String vdbVersion) throws AdminException {
+ super.changeVDBStatus(vdbName, vdbVersion, VDB.DELETED);
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addExtensionModule(java.lang.String,
java.lang.String, byte[], java.lang.String)
+ * @since 4.3
+ */
+ public void addExtensionModule(String type, String sourceName, byte[] source, String
description)
+ throws AdminException {
+// try {
+// if (sourceName == null) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name"));
//$NON-NLS-1$
+// }
+// if (source == null || source.length == 0) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source"));
//$NON-NLS-1$
+// }
+// if (!sourceName.endsWith(".jar") &&
!sourceName.endsWith(".xmi")) { //$NON-NLS-1$ //$NON-NLS-2$
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_module"));
//$NON-NLS-1$
+// }
+// ExtensionModule previousModule = null;
+//
+// try {
+// previousModule =
getConfigurationService().getExtensionModule(sourceName);
+// }catch(MetaMatrixComponentException e) {
+// // this is OK, we did not find any thing
+// }
+//
+// if ( previousModule == null) {
+// // Now add it.
+// BasicExtensionModule extModule = new BasicExtensionModule(sourceName,
type, description, source);
+// getConfigurationService().saveExtensionModule(extModule);
+// }
+// else {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.extension_module_exists",
sourceName)); //$NON-NLS-1$
+// }
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see
org.teiid.adminapi.ConfigurationAdmin#deleteExtensionModule(java.lang.String)
+ * @since 4.3
+ */
+ public void deleteExtensionModule(String sourceName)
+ throws AdminException {
+// try {
+// if (sourceName == null) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name"));
//$NON-NLS-1$
+// }
+// getConfigurationService().deleteExtensionModule(sourceName);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#assignBindingToModel(java.lang.String,
java.lang.String, java.lang.String, java.lang.String)
+ * @since 4.3
+ */
+ public void assignBindingToModel(String deployedConnectorBindingName, String vdbName,
String vdbVersion, String modelName)
+ throws AdminException {
+
+ if (deployedConnectorBindingName == null ||
!deployedConnectorBindingName.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
+ }
+
+ if (vdbName == null || vdbVersion == null || !vdbName.matches(SINGLE_WORD_REGEX))
{
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name"));
//$NON-NLS-1$
+ }
+
+ if (modelName == null || !modelName.matches(MULTIPLE_WORDS_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_model_name"));
//$NON-NLS-1$
+ }
+
+ // find the connector binding if found in the configuration service
+ // add to the vdb binding.
+ try {
+ ConnectorBinding binding =
null;//getDataService().getConnectorBinding(deployedConnectorBindingName);
+ if (binding != null) {
+ List list = new ArrayList();
+ list.add(binding);
+ getConfigurationService().assignConnectorBinding(vdbName, vdbVersion,
modelName, (ConnectorBinding[])list.toArray(new ConnectorBinding[list.size()]));
+ }
+ else {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Vdb_or_Model_notfound"));
//$NON-NLS-1$
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ public void assignBindingsToModel(String[] deployedConnectorBindingName, String
vdbName, String vdbVersion, String modelName) throws AdminException {
+ if (deployedConnectorBindingName == null || deployedConnectorBindingName.length
== 0) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
+ }
+
+ if (vdbName == null || vdbVersion == null || !vdbName.matches(SINGLE_WORD_REGEX))
{
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name"));
//$NON-NLS-1$
+ }
+
+ if (modelName == null || !modelName.matches(MULTIPLE_WORDS_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_model_name"));
//$NON-NLS-1$
+ }
+
+ // find the connector binding if found in the configuration service
+ // add to the vdb binding.
+ try {
+ List list = new ArrayList();
+ for (int i = 0; i < deployedConnectorBindingName.length; i++) {
+ ConnectorBinding binding = null;
//getDataService().getConnectorBinding(deployedConnectorBindingName[i]);
+ if (binding != null) {
+ list.add(binding);
+ }
+ }
+
+ if (!list.isEmpty()) {
+ getConfigurationService().assignConnectorBinding(vdbName, vdbVersion,
modelName, (ConnectorBinding[])list.toArray(new ConnectorBinding[list.size()]));
+ }
+ else {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Vdb_or_Model_notfound"));
//$NON-NLS-1$
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#getLogConfiguration()
+ * @since 4.3
+ */
+ public LogConfiguration getLogConfiguration()
+ throws AdminException {
+ return
(LogConfiguration)convertToAdminObjects(LogManager.getLogConfigurationCopy());
+ }
+
+ /**
+ * @see
org.teiid.adminapi.ConfigurationAdmin#setLogConfiguration(org.teiid.adminapi.LogConfiguration)
+ * @since 4.3
+ */
+ public void setLogConfiguration(LogConfiguration config)
+ throws AdminException {
+
LogManager.setLogConfiguration((com.metamatrix.common.log.LogConfiguration)convertToNativeObjects(config));
+ }
+
+ /**
+ * @see
com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#setLogListener(java.lang.Object)
+ * @since 4.3
+ */
+ public void setLogListener(EmbeddedLogger listener)
+ throws AdminException {
+ if(listener != null) {
+ LogManager.setLogListener(new DQPLogListener(listener));
+ }
+ else {
+ throw new AdminProcessingException("Admin_invalid_log_listener");
//$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @see
org.teiid.adminapi.ConfigurationAdmin#exportExtensionModule(java.lang.String)
+ * @since 4.3
+ */
+ public byte[] exportExtensionModule(String sourceName) throws AdminException {
+// try {
+// if (sourceName == null) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name"));
//$NON-NLS-1$
+// }
+//
+// ExtensionModule extModule =
getConfigurationService().getExtensionModule(sourceName);
+// return extModule.getFileContents();
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#exportConfiguration()
+ * @since 4.3
+ */
+ public char[] exportConfiguration() throws AdminException {
+ try {
+ StringWriter sw = new StringWriter();
+ Properties props = getConfigurationService().getSystemProperties();
+ props.store(sw, "Export of Teiid Configuration Properties");
//$NON-NLS-1$
+ return sw.toString().toCharArray();
+ } catch (IOException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see
org.teiid.adminapi.ConfigurationAdmin#exportConnectorBinding(java.lang.String)
+ * @since 4.3
+ */
+ public char[] exportConnectorBinding(String identifier)
+ throws AdminException {
+// try {
+// if (identifier == null ||
!identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name"));
//$NON-NLS-1$
+// }
+//
+// List bindingList = getDataService().getConnectorBindings();
+// List matchedList = new ArrayList();
+// for (Iterator i = bindingList.iterator(); i.hasNext();) {
+// ConnectorBinding binding = (ConnectorBinding)i.next();
+// if (matches(identifier, binding.getDeployedName())) {
+// matchedList.add(binding);
+// }
+// }
+//
+// if (!matchedList.isEmpty()) {
+// ConnectorBinding[] bindings =
(ConnectorBinding[])matchedList.toArray(new ConnectorBinding[matchedList.size()]);
+// ConnectorBindingType[] types = new
ConnectorBindingType[bindings.length];
+//
+// for (int i = 0; i < bindings.length; i++) {
+// types[i] =
getConfigurationService().getConnectorType(bindings[i].getComponentTypeID().getName());
+// }
+// return ConnectorConfigurationWriter.writeToCharArray(bindings, types);
+// }
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists",
identifier)); //$NON-NLS-1$
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#exportConnectorType(java.lang.String)
+ * @since 4.3
+ */
+ public char[] exportConnectorType(String identifier)
+ throws AdminException {
+// try {
+// if (identifier == null || !identifier.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
+// }
+//
+// List typesList = getConfigurationService().getConnectorTypes();
+// List matchedList = new ArrayList();
+// for (Iterator i = typesList.iterator(); i.hasNext();) {
+// ConnectorBindingType type = (ConnectorBindingType)i.next();
+// if (matches(identifier, type.getName())) {
+// matchedList.add(type);
+// }
+// }
+//
+// if (!matchedList.isEmpty()) {
+// ConnectorBindingType[] types =
(ConnectorBindingType[])matchedList.toArray(new
ConnectorBindingType[matchedList.size()]);
+// return ConnectorConfigurationWriter.writeToCharArray(types);
+// }
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_does_not_exists",
identifier)); //$NON-NLS-1$
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#exportVDB(java.lang.String,
java.lang.String)
+ * @since 4.3
+ */
+ public byte[] exportVDB(String name, String version)
+ throws AdminException {
+
+ try {
+ if (name == null || version == null || !name.matches(SINGLE_WORD_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name"));
//$NON-NLS-1$
+ }
+
+ VDBArchive vdb = getConfigurationService().getVDB(name, version);
+ if (vdb != null) {
+ return VDBArchive.writeToByteArray(vdb);
+ }
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.vdb_does_not_exists",
name, version)); //$NON-NLS-1$
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorArchive(byte[],
org.teiid.adminapi.AdminOptions)
+ * @since 4.3.2
+ */
+ public void addConnectorArchive(byte[] contents, AdminOptions options) throws
AdminException {
+
+ // if the options object is null treat as if it is IGNORE as default
+ if (options == null) {
+ options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
+ }
+
+ if (contents == null || contents.length == 0) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_source"));
//$NON-NLS-1$
+ }
+
+ try {
+ // Load the connector Archive from the file
+ HashSet previouslyAddedModules = new HashSet();
+ ConnectorArchive archive =
ConnectorConfigurationReader.loadConnectorArchive(contents);
+ ConnectorBindingType[] connectorTypes = archive.getConnectorTypes();
+
+ // Loop through each type and add all of them based on the option.
+ for (int typeIndex = 0; typeIndex < connectorTypes.length; typeIndex++) {
+
+ // first make sure we do not already have this connector type
+ String connectorName = connectorTypes[typeIndex].getName();
+// ConnectorBindingType type =
getConfigurationService().getConnectorType(connectorName);
+ ConnectorBindingType type = null;
+ if (type == null) {
+ type = connectorTypes[typeIndex];
+ ExtensionModule[] extModules = archive.getExtensionModules(type);
+ checkDuplicateExtensionModules(extModules, options,
previouslyAddedModules);
+ saveConnectorType(type);
+
+ } else {
+
+ // if not asked to overwrite/skip writing them
+ if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_exists",
connectorName)); //$NON-NLS-1$
+ } else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
+ continue;
+ } else if
(options.containsOption(AdminOptions.OnConflict.OVERWRITE)){
+ deleteConnectorType(connectorName);
+ // Now that we know we need to add this to configuration;
let's get on with it
+ type = connectorTypes[typeIndex];
+ ExtensionModule[] extModules =
archive.getExtensionModules(type);
+ checkDuplicateExtensionModules(extModules, options,
previouslyAddedModules);
+ saveConnectorType(type);
+ }
+ }
+ // Now that we know we need to add this to configuration; let's get
on with it
+ type = connectorTypes[typeIndex];
+ ExtensionModule[] extModules = archive.getExtensionModules(type);
+ checkDuplicateExtensionModules(extModules, options,
previouslyAddedModules);
+ }
+
+ // Now add the extension modules
+ for (Iterator i = previouslyAddedModules.iterator(); i.hasNext();) {
+ ExtensionModule extModule = (ExtensionModule)i.next();
+ addExtensionModule(extModule.getModuleType(), extModule.getFullName(),
extModule.getFileContents(), extModule.getDescription());
+ }
+
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * This method checks the passed in connector type's extension module is not
already in the
+ * system, if it there takes the appropriate action. Otherwise keeps tracks of all
modules
+ * to add.
+ * @param type - connector type
+ * @param extModules - Extension modules for the Connector Type
+ * @param options - Admin Options
+ * @param ignorableModules - Modules which are already added, can be ignored for
adding
+ */
+ void checkDuplicateExtensionModules(ExtensionModule[] extModules, AdminOptions
options, HashSet ignorableModules)
+ throws AdminException {
+
+// // Now check if the the extension modules are already there
+// for (int i = 0; i < extModules.length; i++) {
+// boolean add = true;
+//
+// String moduleName = extModules[i].getFullName();
+// ExtensionModule previousModule = null;
+//
+// // see if we can ignore this, because we may have just added this during
import of
+// // another connector type through this archive
+// if (ignorableModules.contains(extModules[i])) {
+// continue;
+// }
+//
+// // we have not already added this this time around, now check if this
available
+// // from configuration service
+// try {
+// previousModule =
getConfigurationService().getExtensionModule(moduleName);
+// }catch(MetaMatrixComponentException e) {
+// // this is OK, we did not find any thing
+// }
+//
+// // if we found it take appropriate action.
+// if(previousModule != null &&
options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.extension_module_exists",
previousModule.getFullName())); //$NON-NLS-1$
+// }
+// else if (previousModule != null &&
options.containsOption(AdminOptions.OnConflict.IGNORE)) {
+// add = false;
+// }
+// else if (previousModule != null &&
options.containsOption(AdminOptions.OnConflict.OVERWRITE)) {
+// // since we are overwrite, first delete and then add, there is no safe
way to overwrite
+// deleteExtensionModule(previousModule.getFullName());
+// }
+//
+// // Now keep track what extension modules to add; also to ignore in future
+// // adds
+// if (add) {
+// ignorableModules.add(extModules[i]);
+// }
+// }
+ }
+
+ /**
+ * @see
org.teiid.adminapi.ConfigurationAdmin#exportConnectorArchive(java.lang.String)
+ * @since 4.3
+ */
+ public byte[] exportConnectorArchive(String identifier) throws AdminException {
+// try {
+// if (identifier == null ||
!identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
+// }
+//
+// // first build the connector archive object
+// BasicConnectorArchive archive = new BasicConnectorArchive();
+// List connectorTypes = getConfigurationService().getConnectorTypes();
+//
+// for (Iterator i = connectorTypes.iterator(); i.hasNext();) {
+// ConnectorBindingType type = (ConnectorBindingType)i.next();
+//
+// // If the types name matches with the pattern sent in add to archive
+// if (type != null && matches(identifier, type.getName())) {
+//
+// // Add connector type first
+// archive.addConnectorType(type);
+//
+// // Get the extension modules required for the type
+// String[] extModules = type.getExtensionModules();
+// for (int m = 0; m < extModules.length; m++) {
+// // Get the extension module from the configuration and add to
the archive
+// ExtensionModule extModule =
getConfigurationService().getExtensionModule(extModules[m]);
+// if (extModule != null) {
+// archive.addExtensionModule(type, extModule);
+// }
+// else {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("DataService.ext_module_not_found",
extModules[m])); //$NON-NLS-1$
+// }
+// }
+// }
+// }
+//
+// // if no types found to the identifier pattern, then throw an exception
+// if (archive.getConnectorTypes().length == 0) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_does_not_exists",
identifier)); //$NON-NLS-1$
+// }
+//
+// // now convert the object into file form
+// return ConnectorConfigurationWriter.writeToByteArray(archive);
+//
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ private void saveConnectorType(ConnectorBindingType type) throws
MetaMatrixComponentException {
+ // getConfigurationService().saveConnectorType(type);
+ }
+
+
+ @Override
+ public void addUDF(byte[] modelFileContents, String classpath)
+ throws AdminException {
+// if (modelFileContents == null || modelFileContents.length == 0) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_UDF_contents"));
//$NON-NLS-1$
+// }
+//
+// try {
+//
+// getConfigurationService().unloadUDF();
+//
+// // delete any extension module by the same name first
+// try {
+// deleteExtensionModule(ConfigurationService.USER_DEFINED_FUNCTION_MODEL);
+// } catch (AdminException e) {
+// // if not found then it is OK to fail
+// }
+//
+// // add the function definitions as extension modules
+// addExtensionModule(ExtensionModule.FUNCTION_DEFINITION_TYPE,ConfigurationService.USER_DEFINED_FUNCTION_MODEL,modelFileContents,
"User Defined Functions File"); //$NON-NLS-1$
+//
+// String commonpath =
getConfigurationService().getSystemProperties().getProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH,
""); //$NON-NLS-1$
+//
+// StringBuilder sb = new StringBuilder();
+// if (classpath != null && classpath.length() > 0 ) {
+// StringTokenizer st = new StringTokenizer(classpath, ";");
//$NON-NLS-1$
+// while (st.hasMoreTokens()) {
+// String partpath = st.nextToken();
+// if (commonpath.indexOf(partpath) == -1) {
+// sb.append(partpath).append(";"); //$NON-NLS-1$
+// }
+// }
+// }
+//
getConfigurationService().setSystemProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH,
sb.toString()+commonpath);
+//
+//
+// // then update the properties
+// Properties p = new Properties();
+// p.setProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH, classpath);
+// getConfigurationService().updateSystemProperties(p);
+// // reload the new UDF
+// getConfigurationService().loadUDF();
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ @Override
+ public void deleteUDF() throws AdminException {
+ try {
+ getConfigurationService().unloadUDF();
+ deleteExtensionModule(ConfigurationService.USER_DEFINED_FUNCTION_MODEL);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ public void extensionModuleModified(String name) throws AdminException {
+// try {
+// getConfigurationService().clearClassLoaderCache();
+// getConfigurationService().loadUDF();
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ @Override
+ public void setProcessProperty(String processIdentifier, String propertyName, String
propertyValue) throws AdminException{
+// try {
+// getConfigurationService().setSystemProperty(propertyName, propertyValue);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+}
Property changes on:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
(from rev 1544,
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java)
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
(rev 0)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,76 @@
+/*
+ * 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.dqp.embedded.admin;
+
+import org.teiid.adminapi.EmbeddedLogger;
+import org.teiid.adminapi.LogConfiguration;
+
+import com.metamatrix.core.log.LogListener;
+import com.metamatrix.core.log.MessageLevel;
+
+
+public class DQPLogListener implements LogListener {
+
+ private EmbeddedLogger logger;
+
+ public DQPLogListener(EmbeddedLogger logger) {
+ this.logger = logger;
+ }
+
+ public void log(int level, String context, Object msg) {
+ logger.log(convertLevel(level), System.currentTimeMillis(), context,
Thread.currentThread().getName(), msg.toString(), null);
+ }
+
+ public void log(int level, String context, Throwable t, Object msg) {
+ logger.log(convertLevel(level), System.currentTimeMillis(), context,
Thread.currentThread().getName(), msg.toString(), t);
+ }
+
+ private int convertLevel(int level) {
+ int logLevel = LogConfiguration.INFO;
+
+ switch(level) {
+ case MessageLevel.WARNING:
+ logLevel = LogConfiguration.WARNING;
+ break;
+ case MessageLevel.ERROR:
+ logLevel = LogConfiguration.ERROR;
+ break;
+ case MessageLevel.DETAIL:
+ logLevel = LogConfiguration.DETAIL;
+ break;
+ case MessageLevel.TRACE:
+ logLevel = LogConfiguration.TRACE;
+ break;
+ case MessageLevel.NONE:
+ logLevel = LogConfiguration.NONE;
+ break;
+
+ default:
+ logLevel = LogConfiguration.INFO;
+ }
+ return logLevel;
+ }
+
+ public void shutdown() {
+ }
+}
Property changes on:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
(from rev 1544,
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java)
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
(rev 0)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,320 @@
+/*
+ * 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.dqp.embedded.admin;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.Cache;
+import org.teiid.adminapi.ConnectionPool;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.ConnectorType;
+import org.teiid.adminapi.ExtensionModule;
+import org.teiid.adminapi.MonitoringAdmin;
+import org.teiid.adminapi.PropertyDefinition;
+import org.teiid.adminapi.QueueWorkerPool;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.Transaction;
+import org.teiid.adminapi.VDB;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.vdb.api.VDBArchive;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+import com.metamatrix.server.serverapi.RequestInfo;
+
+
+/**
+ * DQP implementation of the Monitoring API
+ * @since 4.3
+ */
+public abstract class DQPMonitoringAdminImpl extends BaseAdmin implements MonitoringAdmin
{
+
+ public DQPMonitoringAdminImpl(EmbeddedConnectionFactoryImpl manager) {
+ super(manager);
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getConnectorTypes(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<ConnectorType> getConnectorTypes(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+
+ return super.getConnectorTypes(identifier);
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getVDBs(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<VDB> getVDBs(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(VDB_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+
+ // if . and * not specified, add a STAR at the end to compensate for the
+ // version number matching.
+ if (identifier.indexOf(DOT) == -1 && identifier.indexOf(STAR) == -1) {
+ identifier = identifier +DOT+STAR;
+ }
+
+ try {
+ List<VDBArchive> vdbs = getVDBService().getAvailableVDBs();
+ List matchedVdbs = new ArrayList();
+ for (VDBArchive vdb:vdbs) {
+ if (matches(identifier, vdb.getName()+"."+vdb.getVersion())) {
//$NON-NLS-1$
+ matchedVdbs.add(vdb);
+ }
+ }
+ return (List)convertToAdminObjects(matchedVdbs);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getConnectorBindings(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<ConnectorBinding> getConnectorBindings(String identifier)
+ throws AdminException {
+
+ if (identifier == null) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+ return super.getConnectorBindings(identifier);
+ }
+
+
+ @Override
+ public Collection<ConnectorBinding> getConnectorBindingsInVDB(String vdbName,
String vdbVersion) throws AdminException{
+ try {
+ VDBArchive vdb = getConfigurationService().getVDB(vdbName, vdbVersion);
+ if (vdb != null) {
+ return
(List)convertToAdminObjects(vdb.getConfigurationDef().getConnectorBindings().values());
+ }
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.vdb_does_not_exists",
vdbVersion, vdbVersion)); //$NON-NLS-1$
+
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getExtensionModules(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<ExtensionModule> getExtensionModules(String identifier)
+ throws AdminException {
+
+// if (identifier == null || !identifier.matches(WORD_AND_DOT_WILDCARD_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+// }
+//
+// try {
+// List extModules = getConfigurationService().getExtensionModules();
+// extModules = (List)convertToAdminObjects(extModules);
+// return matchedCollection(identifier, extModules);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getQueueWorkerPools(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<QueueWorkerPool> getQueueWorkerPools(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+
+ List results = new ArrayList();
+ if (matches(identifier, "dqp")) { //$NON-NLS-1$
+ // First get the queue statistics for the DQP
+ Collection c = getManager().getDQP().getQueueStatistics();;
+ if (c != null && !c.isEmpty()) {
+ results.addAll(c);
+ }
+ }
+
+ try {
+ // Now get for all the connector bindings
+ Collection bindings = super.getConnectorBindings(identifier);
+ for (Iterator i = bindings.iterator(); i.hasNext();) {
+ ConnectorBinding binding = (ConnectorBinding)i.next();
+ Collection c =
getDataService().getConnectorStatistics(binding.getName());
+ if (c != null && !c.isEmpty()) {
+ results.addAll(c);
+ }
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+
+ if (!results.isEmpty()) {
+ return (List)convertToAdminObjects(results);
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getCaches(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<Cache> getCaches(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(SINGLE_WORD_WILDCARD_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+
+ List cacheList = new ArrayList();
+ for (int i =0; i < cacheTypes.length; i++) {
+ if (matches(identifier, cacheTypes[i])) {
+ cacheList.add(cacheTypes[i]);
+ }
+ }
+ return cacheList;
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getSessions(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<Session> getSessions(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(NUMBER_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+ return matchedCollection(identifier,
(List)convertToAdminObjects(getClientConnections()));
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getRequests(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<Request> getRequests(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(NUMBER_DOT_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+
+ ArrayList requestList = new ArrayList();
+ // List contains both top and atomic requests, only add the top requests
+ List<RequestInfo> requests = getManager().getDQP().getRequests();
+ for(RequestInfo request:requests) {
+ if (request.getConnectorBindingUUID() == null) {
+ requestList.add(request);
+ }
+ }
+ return matchedCollection(identifier, (List)convertToAdminObjects(requestList));
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getSourceRequests(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<Request> getSourceRequests(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(NUMBER_DOT_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+
+ ArrayList atomicRequestList = new ArrayList();
+ List<RequestInfo> requests = getManager().getDQP().getRequests();
+ for (RequestInfo request:requests) {
+ if (request.getConnectorBindingUUID() != null) {
+ atomicRequestList.add(request);
+ }
+ }
+ return matchedCollection(identifier,
(List)convertToAdminObjects(atomicRequestList));
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getPropertyDefinitions(java.lang.String,
java.lang.String)
+ * @since 4.3
+ */
+ public Collection<PropertyDefinition>
getConnectorTypePropertyDefinitions(String typeName) throws AdminException {
+
+// if (typeName == null || !typeName.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name"));
//$NON-NLS-1$
+// }
+//
+// try {
+// ConnectorBindingType type = getConfigurationService().getConnectorType(typeName);
+// if (type == null) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.ct_doesnot_exist",
typeName)); //$NON-NLS-1$
+// }
+//
+// return convertPropertyDefinitions(type, new Properties());
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ @Override
+ public Collection<Transaction> getTransactions()
+ throws AdminException {
+ TransactionService ts = getTransactionService();
+ if (ts == null) {
+ return Collections.emptyList();
+ }
+ return ts.getTransactions();
+ }
+
+ @Override
+ public Collection<? extends ConnectionPool> getConnectionPoolStats(String
identifier)
+ throws AdminException {
+
+// try {
+// return this.getDataService().getConnectionPoolStatistics(identifier);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return Collections.EMPTY_LIST;
+ }
+
+}
Property changes on:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
(from rev 1544,
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java)
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
(rev 0)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,302 @@
+/*
+ * 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.dqp.embedded.admin;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.transaction.xa.Xid;
+
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.Cache;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.RuntimeStateAdmin;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
+import com.metamatrix.admin.objects.MMRequest;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.message.AtomicRequestID;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+
+
+/**
+ * @since 4.3
+ */
+public abstract class DQPRuntimeStateAdminImpl extends BaseAdmin implements
RuntimeStateAdmin {
+
+ public DQPRuntimeStateAdminImpl(EmbeddedConnectionFactoryImpl manager) {
+ super(manager);
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#stop(int)
+ * @since 4.3
+ */
+ public void shutdown(int millisToWait) throws AdminException {
+ // TODO: rreddy need to implement the time to wait.
+ // First terminate all the sessions to the DQP currently have
+ terminateSession(AdminObject.WILDCARD);
+
+ getManager().shutdown(false);
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#restart()
+ * @since 4.3
+ */
+ public void restart() throws AdminException {
+ // First terminate all the sessions to the DQP currently have
+ terminateSession(AdminObject.WILDCARD);
+
+ // Now shutdown the DQP, it will automatically start next timea new connection is
+ // requested.
+ getManager().shutdown(true);
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#startConnectorBinding(java.lang.String)
+ * @since 4.3
+ */
+ public void startConnectorBinding(String identifier)
+ throws AdminException {
+
+// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+// }
+//
+// AdminException exceptionWrapper = null;
+// // Get all matching connector bindings
+// Collection bindings = getConnectorBindings(identifier);
+// if (bindings != null && !bindings.isEmpty()) {
+// for (Iterator i = bindings.iterator(); i.hasNext();) {
+// try {
+// AdminObject binding = (AdminObject)i.next();
+// getDataService().startConnectorBinding(binding.getName());
+// } catch (ApplicationLifecycleException e) {
+// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
+// } catch (MetaMatrixComponentException e) {
+// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
+// }
+// }
+// }
+// else {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists",
new Object[] {identifier})); //$NON-NLS-1$
+// }
+//
+// // If any errors occurred then thow the exception.
+// if (exceptionWrapper != null) {
+// throw exceptionWrapper;
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#stopConnectorBinding(java.lang.String,
boolean)
+ * @since 4.3
+ */
+ public void stopConnectorBinding(String identifier, boolean stopNow)
+ throws AdminException {
+// // TODO: need to implement "now" part
+// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+// }
+//
+// AdminException exceptionWrapper = null;
+// // Get all matching connector bindings
+// Collection bindings = getConnectorBindings(identifier);
+// if (bindings != null && !bindings.isEmpty()) {
+// for (Iterator i = bindings.iterator(); i.hasNext();) {
+// try {
+// AdminObject binding = (AdminObject)i.next();
+// getDataService().stopConnectorBinding(binding.getName());
+// } catch (ApplicationLifecycleException e) {
+// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
+// } catch (MetaMatrixComponentException e) {
+// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
+// }
+// }
+// }
+// else {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists",
new Object[] {identifier})); //$NON-NLS-1$
+// }
+//
+// // If any errors occurred then thow the exception.
+// if (exceptionWrapper != null) {
+// throw exceptionWrapper;
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#clearCache(java.lang.String)
+ * @since 4.3
+ */
+ public void clearCache(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(SINGLE_WORD_WILDCARD_REGEX)) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+ boolean processed = false;
+
+ for (int i = 0; i < cacheTypes.length; i++) {
+ if (matches(identifier, cacheTypes[i])) {
+ if(cacheTypes[i].equals(Cache.CODE_TABLE_CACHE)) {
+ processed = true;
+ getManager().getDQP().clearCodeTableCache();
+ } else if(cacheTypes[i].equals(Cache.PREPARED_PLAN_CACHE)) {
+ processed = true;
+ getManager().getDQP().clearPlanCache();
+ } else if(cacheTypes[i].equals( Cache.QUERY_SERVICE_RESULT_SET_CACHE)) {
+ processed = true;
+ getManager().getDQP().clearResultSetCache();
+ } else if (cacheTypes[i].equals(Cache.CONNECTOR_RESULT_SET_CACHE)) {
+ processed = true;
+ try {
+ // Now get for all the connector bindings
+ Collection bindings = super.getConnectorBindings("*");
//$NON-NLS-1$
+ for (Iterator iter = bindings.iterator(); iter.hasNext();) {
+ ConnectorBinding binding = (ConnectorBinding)iter.next();
+
getDataService().clearConnectorBindingCache(binding.getName());
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+ }
+ }
+
+ if (!processed) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.invalid_request",
new Object[] {identifier})); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#terminateSession(java.lang.String)
+ * @since 4.3
+ */
+ public void terminateSession(String identifier)
+ throws AdminException {
+
+ Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
+ ArrayList<MetaMatrixSessionInfo> matchedConnections = new
ArrayList<MetaMatrixSessionInfo>();
+
+ for (MetaMatrixSessionInfo info:sessions) {
+ String id = info.getSessionID().toString();
+ if (matches(identifier, id)) {
+ matchedConnections.add(info);
+ }
+ }
+
+ // terminate the sessions.
+ for (MetaMatrixSessionInfo info: matchedConnections) {
+ getSessionService().terminateSession(info.getSessionID(),
DQPWorkContext.getWorkContext().getSessionId());
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#cancelRequest(java.lang.String)
+ * @since 4.3
+ */
+ public void cancelRequest(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches("\\d+\\" +
Request.DELIMITER + "\\d+")) { //$NON-NLS-1$ //$NON-NLS-2$
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+
+ String[] identifierParts = MMRequest.buildIdentifierArray(identifier);
+ String connId = identifierParts[0];
+ long requestId = Long.parseLong(identifierParts[1]);
+
+ // get the client connection
+ RequestID id = new RequestID(connId, requestId);
+
+ try {
+ getManager().getDQP().cancelRequest(id);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#cancelSourceRequest(java.lang.String)
+ * @since 4.3
+ */
+ public void cancelSourceRequest(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches("\\d+\\" +
Request.DELIMITER + "\\d+\\" + Request.DELIMITER + "\\d+" +
Request.DELIMITER + "\\d+")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+ }
+
+ String[] identifierParts = MMRequest.buildIdentifierArray(identifier);
+
+ String connId = identifierParts[0];
+ long requestId = Long.parseLong(identifierParts[1]);
+ int nodeId = Integer.parseInt(identifierParts[2]);
+ int executionId = Integer.parseInt(identifierParts[3]);
+ AtomicRequestID id = new AtomicRequestID(new RequestID(connId, requestId),
nodeId, executionId);
+
+ try {
+ getManager().getDQP().cancelAtomicRequest(id);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#changeVDBStatus(java.lang.String,
java.lang.String, int)
+ * @since 4.3
+ */
+ public void changeVDBStatus(String name, String version, int status)
+ throws AdminException {
+ super.changeVDBStatus(name, version, status);
+ }
+
+
+ @Override
+ public void terminateTransaction(String transactionId, String sessionId)
+ throws AdminException {
+// TransactionService ts = getTransactionService();
+// if (ts != null) {
+// ts.terminateTransaction(transactionId, sessionId);
+// }
+ }
+
+ @Override
+ public void terminateTransaction(Xid transactionId) throws AdminException {
+ TransactionService ts = getTransactionService();
+ if (ts != null) {
+ ts.terminateTransaction(transactionId);
+ }
+ }
+
+}
Property changes on:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
(from rev 1544,
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java)
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
(rev 0)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,275 @@
+/*
+ * 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.dqp.embedded.admin;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.Group;
+import org.teiid.adminapi.SecurityAdmin;
+import org.xml.sax.SAXException;
+
+import com.metamatrix.admin.api.exception.security.InvalidSessionException;
+import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
+import com.metamatrix.admin.objects.MMGroup;
+import com.metamatrix.admin.objects.MMRole;
+import com.metamatrix.api.exception.security.AuthorizationException;
+import com.metamatrix.api.exception.security.AuthorizationMgmtException;
+import com.metamatrix.api.exception.security.MembershipServiceException;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
+import com.metamatrix.platform.security.api.AuthorizationPolicy;
+import com.metamatrix.platform.security.api.AuthorizationPolicyFactory;
+import com.metamatrix.platform.security.api.AuthorizationRealm;
+import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
+import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
+
+
+/**
+ * @since 4.3
+ */
+public abstract class DQPSecurityAdminImpl extends BaseAdmin implements SecurityAdmin {
+
+ public DQPSecurityAdminImpl(EmbeddedConnectionFactoryImpl manager) {
+ super(manager);
+ }
+
+ /**
+ * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#addRoleToGroup(java.lang.String,
java.lang.String)
+ * @since 4.3
+ */
+ public void assignRoleToGroup(String roleIdentifier, String groupIdentifier) throws
AdminException {
+ throw new
AdminComponentException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.not_implemented"));
//$NON-NLS-1$
+ }
+
+ /**
+ * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#removeRoleFromGroup(java.lang.String,
java.lang.String)
+ * @since 4.3
+ */
+ public void removeRoleFromGroup(String roleIdentifier, String groupIdentifier) throws
AdminException {
+ throw new
AdminComponentException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.not_implemented"));
//$NON-NLS-1$
+ }
+
+ /**
+ * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#getGroupsForUser(java.lang.String,
boolean)
+ * @since 4.3
+ */
+ public Collection<Group> getGroupsForUser(String userIdentifier) throws
AdminException {
+ if (userIdentifier == null) {
+ throwProcessingException("AdminImpl.requiredparameter", new
Object[] {}); //$NON-NLS-1$
+ }
+
+ if ( userIdentifier.equals(AdminObject.WILDCARD) ) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.Cant_use_wildcard"));
//$NON-NLS-1$
+ }
+ Collection groups = new ArrayList();
+ // Get all memberships - explicit and implicit
+ Set allMemberships = null;
+ try {
+ allMemberships = getMembershipService().getGroupsForUser(userIdentifier);
+ } catch (MetaMatrixSecurityException e) {
+ throw new AdminComponentException(e);
+ }
+ Iterator allMembershipsItr = allMemberships.iterator();
+ while ( allMembershipsItr.hasNext() ) {
+ groups.add(new MMGroup(new String[] {(String)allMembershipsItr.next()}));
+ }
+ return groups;
+ }
+
+ /**
+ * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#getGroups(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<Group> getGroups(String groupIdentifier) throws
AdminException {
+ if (groupIdentifier == null) {
+ throwProcessingException("AdminImpl.requiredparameter", new
Object[] {}); //$NON-NLS-1$
+ }
+
+ Collection<Group> groups = new ArrayList<Group>();
+ Collection allGroups = null;
+ // Add all groups from internal membership domain
+ try {
+ allGroups = getMembershipService().getGroupNames();
+ } catch (MetaMatrixSecurityException e) {
+ throw new AdminComponentException(e);
+ }
+
+ Iterator groupItr = allGroups.iterator();
+ while ( groupItr.hasNext() ) {
+ String groupName = (String) groupItr.next();
+
+ if (!groupIdentifier.equals(AdminObject.WILDCARD) &&
!groupName.equals(groupIdentifier)) {
+ continue;
+ }
+
+ groups.add(new MMGroup(new String[] {groupName}));
+ }
+ return groups;
+ }
+
+
+ /**
+ * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#getRolesForGroup(java.lang.String)
+ * @since 4.3
+ */
+ public Collection getRolesForGroup(String groupIdentifier) throws AdminException {
+ if (groupIdentifier == null) {
+ throwProcessingException("AdminImpl.requiredparameter", new
Object[] {}); //$NON-NLS-1$
+ }
+
+ if ( groupIdentifier.equals(AdminObject.WILDCARD) ) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.Cant_use_wildcard"));
//$NON-NLS-1$
+ }
+ Collection roleNames = null;
+ try {
+ roleNames = getAuthorizationService().getRoleNamesForPrincipal(new
MetaMatrixPrincipalName(groupIdentifier, MetaMatrixPrincipal.TYPE_GROUP));
+ } catch (InvalidSessionException e) {
+ throw new AdminComponentException(e);
+ } catch (AuthorizationMgmtException e) {
+ throw new AdminComponentException(e);
+ } catch (AuthorizationException e) {
+ throw new AdminComponentException(e);
+ }
+ Collection roles = new ArrayList();
+ Iterator roleNameItr = roleNames.iterator();
+ while ( roleNameItr.hasNext() ) {
+ String roleName = (String)roleNameItr.next();
+ roles.add(new MMRole(new String[] {roleName}));
+ }
+ return roles;
+ }
+
+ /**
+ * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#importDataRoles(java.lang.String,
java.lang.String, char[], org.teiid.adminapi.AdminOptions)
+ */
+ public String importDataRoles(String vdbName, String vdbVersion, char[] xmlContents,
AdminOptions options)
+ throws AdminException{
+
+ if (vdbName == null) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbName_can_not_be_null"));
//$NON-NLS-1$
+ }
+
+ if (vdbVersion == null) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbVersion_can_not_be_null"));
//$NON-NLS-1$
+ }
+
+ if (options == null) {
+
+ options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
+ }
+
+ try {
+ EntitlementMigrationReport rpt = new EntitlementMigrationReport("from
file", vdbName + " " + vdbVersion); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Collection<AuthorizationPolicy> roles =
AuthorizationPolicyFactory.buildPolicies(vdbName, vdbVersion, xmlContents);
+
+ AuthorizationRealm realm = new AuthorizationRealm(vdbName, vdbVersion);
+
+ getAuthorizationService().updatePoliciesInRealm(realm, roles);
+
+ return rpt.toString();
+ } catch (AuthorizationMgmtException e) {
+ throw new AdminProcessingException(e);
+ } catch (SAXException e) {
+ throw new AdminComponentException(e);
+ } catch (IOException e) {
+ throw new AdminComponentException(e);
+ } catch (ParserConfigurationException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see
com.metamatrix.admin.api.server.ServerSecurityAdmin#exportDataRoles(java.lang.String,
java.lang.String)
+ */
+ public char[] exportDataRoles(String vdbName, String vdbVersion) throws
AdminException {
+
+ if (vdbName == null) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbName_can_not_be_null"));
//$NON-NLS-1$
+ }
+
+ if (vdbVersion == null) {
+ throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbVersion_can_not_be_null"));
//$NON-NLS-1$
+ }
+
+ Collection roles = null;
+ try {
+ roles = getAuthorizationService().getPoliciesInRealm(new AuthorizationRealm(vdbName,
vdbVersion));
+ if (roles != null && !roles.isEmpty()) {
+ return AuthorizationPolicyFactory.exportPolicies(roles);
+ }
+ return null;
+ } catch (AuthorizationMgmtException e) {
+ throw new AdminProcessingException(e);
+ } catch (AuthorizationException e) {
+ throw new AdminProcessingException(e);
+ } catch (IOException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ public List<String> getDomainNames() throws AdminException {
+ try {
+ return this.getMembershipService().getDomainNames();
+ } catch (MembershipServiceException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ public Collection<Group> getGroupsForDomain(String domainName)
+ throws AdminException {
+ if (domainName == null) {
+ throwProcessingException("AdminImpl.requiredparameter", new
Object[] {}); //$NON-NLS-1$
+ }
+ try {
+ Collection<String> groupNames =
this.getMembershipService().getGroupsForDomain(domainName);
+ List<Group> result = new ArrayList<Group>(groupNames.size());
+ for (String groupName : groupNames) {
+ result.add(new MMGroup(new String[] {groupName}));
+ }
+ return result;
+ } catch (MembershipServiceException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ void throwProcessingException(String key, Object[] objects) throws AdminException {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString(key,
objects));
+ }
+
+}
Property changes on:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -26,8 +26,6 @@
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.InetAddress;
import java.net.URL;
@@ -35,6 +33,8 @@
import java.util.Date;
import java.util.Properties;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
@@ -42,7 +42,7 @@
import org.teiid.TeiidManagedConnectionFactory;
import org.teiid.TeiidResourceAdapter;
import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.impl.BaseAdmin;
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.transport.AdminAuthorizationInterceptor;
import org.teiid.transport.LogonImpl;
@@ -63,12 +63,10 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.queue.WorkerPoolStats;
-import com.metamatrix.common.util.JMXUtil;
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.util.MixinProxy;
import com.metamatrix.dqp.ResourceFinder;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
@@ -94,7 +92,6 @@
private ClientServiceRegistry clientServices;
private String workspaceDirectory;
private SocketTransport socketTransport;
- private JMXUtil jmxServer;
private boolean restart = false;
private InetAddress address;
private TeiidResourceAdapter ra;
@@ -164,10 +161,9 @@
throw new ApplicationInitializationException(e);
}
- this.jmxServer = new JMXUtil(processName);
- address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
+ this.address =
resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
- EmbeddedGuiceModule config = new EmbeddedGuiceModule(bootstrapURL, props,
this.jmxServer, address, this.ra);
+ EmbeddedGuiceModule config = new EmbeddedGuiceModule(bootstrapURL, props,
address, this.ra);
Injector injector = Guice.createInjector(config);
ResourceFinder.setInjector(injector);
config.setInjector(injector);
@@ -221,7 +217,7 @@
SessionServiceInterface sessionService =
(SessionServiceInterface)this.dqp.getEnvironment().findService(DQPServiceNames.SESSION_SERVICE);
services.registerClientService(ILogon.class, new LogonImpl(sessionService,
configService.getClusterName()), com.metamatrix.common.util.LogConstants.CTX_SERVER);
- Admin roleCheckedServerAdmin = wrapAdminService(Admin.class, getAdminAPI());
+ Admin roleCheckedServerAdmin = wrapAdminService(Admin.class, getAdminAPI());
services.registerClientService(Admin.class, roleCheckedServerAdmin,
com.metamatrix.common.util.LogConstants.CTX_ADMIN);
services.registerClientService(ClientSideDQP.class, this.dqp,
LogConstants.CTX_QUERY_SERVICE);
@@ -364,38 +360,17 @@
this.restart = restart;
}
- private Admin getAdminAPI() {
-
- InvocationHandler handler = new MixinProxy(new Object[] {
-// TODO: This is hook for the admin API - NEEDS TO BE FIXED
-// new DQPConfigAdminImpl(this),
-// new DQPMonitoringAdminImpl(this),
-// new DQPRuntimeStateAdminImpl(this),
-// new DQPSecurityAdminImpl(this)
- }) {
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
- // We we perform any DQP functions check if the DQP is still alive
- if (!isAlive()) {
- throw new
AdminProcessingException(JDBCPlugin.Util.getString("EmbeddedConnection.DQP_shutDown"));
//$NON-NLS-1$
- }
-
- ClassLoader callingClassLoader =
Thread.currentThread().getContextClassLoader();
- try {
- // Set the class loader to current class classloader so that the this
classe's class loader gets used
-
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
- return super.invoke(proxy, method, args);
- }
- finally {
- Thread.currentThread().setContextClassLoader(callingClassLoader);
- }
- }
- };
- return (Admin) Proxy.newProxyInstance(this.getClass().getClassLoader(),new
Class[] {Admin.class}, handler);
- }
-
- public JMXUtil getJMXServer() {
- return this.jmxServer;
+ private Admin getAdminAPI() {
+ try {
+ InitialContext ic = new InitialContext();
+ Admin admin = (Admin)ic.lookup("teiid/admin");
+ if (admin instanceof BaseAdmin) {
+ ((BaseAdmin) admin).setManager(this);
+ }
+ return admin;
+ } catch (NamingException e) {
+ throw new MetaMatrixRuntimeException("admin implementation not found");
+ }
}
public MMProcess getProcess() {
Modified: branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -48,7 +48,6 @@
import com.metamatrix.common.application.DQPConfigSource;
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.JMXUtil;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.LogListener;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
@@ -69,15 +68,13 @@
private Properties props;
private URL bootstrapURL;
- private JMXUtil jmx;
private InetAddress bindAddress;
Injector injector;
TeiidResourceAdapter ra;
- public EmbeddedGuiceModule(URL bootstrapURL, Properties props, JMXUtil jmxUtil,
InetAddress bindAddress, TeiidResourceAdapter ra) {
+ public EmbeddedGuiceModule(URL bootstrapURL, Properties props, InetAddress bindAddress,
TeiidResourceAdapter ra) {
this.bootstrapURL = bootstrapURL;
this.props = props;
- this.jmx = jmxUtil;
this.bindAddress = bindAddress;
this.ra = ra;
}
@@ -93,7 +90,6 @@
bind(URL.class).annotatedWith(Names.named("BootstrapURL")).toInstance(bootstrapURL);
//$NON-NLS-1$
bind(Properties.class).annotatedWith(Names.named("DQPProperties")).toInstance(this.props);
//$NON-NLS-1$
- bind(JMXUtil.class).annotatedWith(Names.named("jmx")).toInstance(this.jmx);
//$NON-NLS-1$
bind(InetAddress.class).annotatedWith(Names.named(DQPEmbeddedProperties.HOST_ADDRESS)).toInstance(bindAddress);
Modified: branches/JCA/runtime/src/main/java/org/teiid/Server.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/Server.java 2009-11-17 13:11:25 UTC (rev
1568)
+++ branches/JCA/runtime/src/main/java/org/teiid/Server.java 2009-11-17 13:31:34 UTC (rev
1569)
@@ -27,25 +27,14 @@
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
-import java.util.Iterator;
import java.util.Properties;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-import com.metamatrix.common.config.api.ExtensionModule;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.ApplicationInfo;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.common.util.JMXUtil.FailedToRegisterException;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.ZipFileUtil;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.embedded.services.EmbeddedConfigurationService;
-import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
@@ -58,31 +47,31 @@
this.props = props;
}
- private void start() {
- try {
- // start the engine.
- initialize(this.props);
-
- getJMXServer().register(TYPE, NAME, this);
-
- } catch (FailedToRegisterException e) {
- throw new MetaMatrixRuntimeException(e.getCause());
- } catch (MetaMatrixCoreException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
-
- private void stopS(boolean restart) {
- if (isAlive()) {
- shutdown(restart);
- }
-
- try {
- getJMXServer().unregister(TYPE, NAME);
- } catch (FailedToRegisterException e) {
- // ignore
- }
- }
+// private void start() {
+// try {
+// // start the engine.
+// initialize(this.props);
+//
+// getJMXServer().register(TYPE, NAME, this);
+//
+// } catch (FailedToRegisterException e) {
+// throw new MetaMatrixRuntimeException(e.getCause());
+// } catch (MetaMatrixCoreException e) {
+// throw new MetaMatrixRuntimeException(e);
+// }
+// }
+//
+// private void stopS(boolean restart) {
+// if (isAlive()) {
+// shutdown(restart);
+// }
+//
+// try {
+// getJMXServer().unregister(TYPE, NAME);
+// } catch (FailedToRegisterException e) {
+// // ignore
+// }
+// }
private static boolean duplicateProcess(Properties props) {
try {
@@ -128,12 +117,12 @@
@Override
public void shutdown() {
- new Thread(){
- public void run(){
- System.out.println("Server being shutdown..."); //$NON-NLS-1$
- stopS(false);
- }
- }.start();
+// new Thread(){
+// public void run(){
+// System.out.println("Server being shutdown..."); //$NON-NLS-1$
+// stopS(false);
+// }
+// }.start();
}
@Override
@@ -148,12 +137,12 @@
@Override
public void restart() {
- new Thread(){
- public void run(){
- System.out.println("Server being shutdown..."); //$NON-NLS-1$
- stopS(true);
- }
- }.start();
+// new Thread(){
+// public void run(){
+// System.out.println("Server being shutdown..."); //$NON-NLS-1$
+// stopS(true);
+// }
+// }.start();
}
/**
@@ -180,7 +169,7 @@
// load the server
Server s = new Server(props);
- s.start();
+ //s.start();
String port = props.getProperty(DQPEmbeddedProperties.SERVER_PORT);
long time = System.currentTimeMillis() - startTime;
@@ -202,7 +191,7 @@
// if for some reason engine is still alive kill it.
if (s.isAlive()) {
- s.stopS(false);
+ //s.stopS(false);
}
// exit code to restart the process.
Modified: branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java 2009-11-17 13:11:25 UTC
(rev 1568)
+++ branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java 2009-11-17 13:31:34 UTC
(rev 1569)
@@ -21,11 +21,10 @@
*/
package org.teiid;
-import com.metamatrix.common.util.JMXUtil;
public interface ServerMBean {
public static final String NAME = "Server"; //$NON-NLS-1$
- public static final JMXUtil.MBeanType TYPE = JMXUtil.MBeanType.SERVER;
+ //public static final JMXUtil.MBeanType TYPE = JMXUtil.MBeanType.SERVER;
boolean isAlive();
Modified: branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java 2009-11-17 13:11:25 UTC
(rev 1568)
+++ branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java 2009-11-17 13:31:34 UTC
(rev 1569)
@@ -2,7 +2,6 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.Properties;
@@ -12,9 +11,6 @@
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
-import com.metamatrix.common.util.JMXUtil;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-
public class Shutdown {
public static void main(String[] args) throws Exception {
@@ -25,17 +21,17 @@
Properties props = Server.loadConfiguration(args[0]);
- JMXUtil jmx = new JMXUtil(props.getProperty(DQPEmbeddedProperties.PROCESSNAME));
+// JMXUtil jmx = new JMXUtil(props.getProperty(DQPEmbeddedProperties.PROCESSNAME));
JMXServiceURL serviceURL = new
JMXServiceURL("service:jmx:rmi:///jndi/rmi://:"+args[1]+"/jmxrmi");
//$NON-NLS-1$ //$NON-NLS-2$
JMXConnector connector = JMXConnectorFactory.connect(serviceURL);
MBeanServerConnection mbsc = connector.getMBeanServerConnection();
- ServerProxyHandler handler = new ServerProxyHandler(mbsc,
jmx.buildName(ServerMBean.TYPE, ServerMBean.NAME));
- Class<?>[] ifaces = { ServerMBean.class };
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- ServerMBean server = (ServerMBean) Proxy.newProxyInstance(tcl, ifaces,handler);
- server.shutdown();
+// ServerProxyHandler handler = new ServerProxyHandler(mbsc,
jmx.buildName(ServerMBean.TYPE, ServerMBean.NAME));
+// Class<?>[] ifaces = { ServerMBean.class };
+// ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+// ServerMBean server = (ServerMBean) Proxy.newProxyInstance(tcl, ifaces,handler);
+// server.shutdown();
}
/**
Added: branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
(rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,46 @@
+/*
+ * 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.adminapi.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+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 {
+ EmbeddedConnectionFactoryImpl manager;
+
+ public void setManager(EmbeddedConnectionFactoryImpl manager) {
+ this.manager = manager;
+ }
+
+ @Override
+ public Collection<ProcessObject> getProcesses(String processIdentifier) throws
AdminException {
+ ArrayList<ProcessObject> list = new ArrayList<ProcessObject>();
+ list.add(manager.getProcess());
+ return list;
+ }
+}
Property changes on:
branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java
===================================================================
---
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -38,7 +38,6 @@
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.metamatrix.common.protocol.URLHelper;
-import com.metamatrix.common.util.JMXUtil;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.FakeAbstractService;
@@ -64,7 +63,7 @@
TeiidResourceAdapter ra = Mockito.mock(TeiidResourceAdapter.class);
Mockito.stub(ra.getWorkManager()).toReturn(new FakeWorkManager());
Mockito.stub(ra.getXATerminator()).toReturn(Mockito.mock(XATerminator.class));
- EmbeddedGuiceModule source = new EmbeddedGuiceModule(url, p, new
JMXUtil("test"), InetAddress.getLocalHost(), ra); //$NON-NLS-1$
+ EmbeddedGuiceModule source = new EmbeddedGuiceModule(url, p,
InetAddress.getLocalHost(), ra); //$NON-NLS-1$
Injector injector = Guice.createInjector(source);
source.setInjector(injector);
Copied:
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java
(from rev 1544,
branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java)
===================================================================
---
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java
(rev 0)
+++
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java 2009-11-17
13:31:34 UTC (rev 1569)
@@ -0,0 +1,101 @@
+/*
+ * 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.dqp.embedded.admin;
+
+import junit.framework.TestCase;
+
+
+/**
+ * @since 4.3
+ */
+public class TestBaseAdmin extends TestCase {
+
+ public void testRegexStuff() {
+ assertTrue("RegEx Failed",
"one".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed", "one
two".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one two three
".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one9_two_Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
"one9_two*Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed", "#one9_two
Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("RegEx Failed",
"one".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one
".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed",
"one*".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one
two".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one_TWO_three".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+
+ assertTrue("RegEx Failed",
"one*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed", "one
two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one two
*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "*one
two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed",
"*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
"#two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
"one.*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one.two".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one.two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+
+
+ assertTrue("RegEx Failed",
"*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one_TWO_three*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
"*one".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed", "*
one".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed",
"*.*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
"one.*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+
+
+ assertTrue("RegEx Failed",
"*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one.two".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
"*.one".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed", "one_two
*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one.two*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one.two*.three*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
"one.two**".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one.two.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed",
"one*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
"one.".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertTrue("RegEx Failed",
"0.10.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
"0.10..*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
"0.10..".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
".one*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ assertFalse("RegEx Failed",
".one_two".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+
+ assertTrue("RegEx Failed",
"One".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed",
"One.1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed",
"*.1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed",
"One.One".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed",
"One*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed",
"One*.101".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed",
"*.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed",
"100.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed",
".1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ //assertTrue("RegEx Failed",
"V0.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("RegEx Failed", "XML-Relational File
Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "XML
Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "XML&Relational
Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ //assertTrue("RegEx Failed",
"".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+}
Property changes on:
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/test-integration/db/src/main/resources/ddl/derby/create_tables.sql
===================================================================
---
branches/JCA/test-integration/db/src/main/resources/ddl/derby/create_tables.sql 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/test-integration/db/src/main/resources/ddl/derby/create_tables.sql 2009-11-17
13:31:34 UTC (rev 1569)
@@ -2,12 +2,12 @@
-- these tables are used by custom junit test for testing transactions
create Table g1 (
- e1 NUMERIC(5),
+ e1 INTEGER,
e2 varchar(50),
PRIMARY KEY (e1)
);
create Table g2 (
- e1 NUMERIC(5) REFERENCES g1 (e1),
+ e1 INTEGER REFERENCES g1 (e1),
e2 varchar(50)
);
-
\ No newline at end of file
+
Modified: branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql
===================================================================
---
branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql 2009-11-17
13:11:25 UTC (rev 1568)
+++
branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql 2009-11-17
13:31:34 UTC (rev 1569)
@@ -1,6 +1,6 @@
-- these tables are used by custom junit test for testing transactions
-create Table g1 (e1 NUMERIC(5) PRIMARY KEY, e2 varchar(50))ENGINE=InnoDB;
-create Table g2 (e1 NUMERIC(5), e2 varchar(50), FOREIGN KEY (e1) REFERENCES
g1(e1))ENGINE=InnoDB;
-
\ No newline at end of file
+create Table g1 (e1 INT PRIMARY KEY, e2 varchar(50))ENGINE=InnoDB;
+create Table g2 (e1 INT, e2 varchar(50), FOREIGN KEY (e1) REFERENCES
g1(e1))ENGINE=InnoDB;
+