[teiid-commits] teiid SVN: r1922 - in trunk: jboss-integration and 24 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Fri Mar 5 13:10:15 EST 2010
Author: shawkins
Date: 2010-03-05 13:10:12 -0500 (Fri, 05 Mar 2010)
New Revision: 1922
Added:
trunk/jboss-integration/
trunk/jboss-integration/pom.xml
trunk/jboss-integration/src/
trunk/jboss-integration/src/main/
trunk/jboss-integration/src/main/java/
trunk/jboss-integration/src/main/java/com/
trunk/jboss-integration/src/main/java/com/metamatrix/
trunk/jboss-integration/src/main/java/org/
trunk/jboss-integration/src/main/java/org/teiid/
trunk/jboss-integration/src/main/java/org/teiid/adminapi/
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java
trunk/jboss-integration/src/main/java/org/teiid/templates/
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExtendedPropertyMetadata.java
trunk/jboss-integration/src/main/resources/
trunk/jboss-integration/src/test/
trunk/jboss-integration/src/test/java/
trunk/jboss-integration/src/test/java/com/
trunk/jboss-integration/src/test/java/com/metamatrix/
trunk/jboss-integration/src/test/java/com/metamatrix/dqp/
trunk/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/
trunk/jboss-integration/src/test/java/org/
trunk/jboss-integration/src/test/java/org/teiid/
trunk/jboss-integration/src/test/java/org/teiid/adminapi/
trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/
trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/BaseConnection.java
trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
trunk/jboss-integration/src/test/java/org/teiid/templates/
trunk/jboss-integration/src/test/java/org/teiid/templates/connector/
trunk/jboss-integration/src/test/java/org/teiid/templates/connector/TestExtendedPropertyMetadata.java
trunk/jboss-integration/src/test/resources/
trunk/jboss-integration/src/test/resources/TransactionsRevisited.vdb
trunk/jboss-integration/src/test/resources/connector-loopback.rar
trunk/jboss-integration/src/test/resources/log4j.xml
Removed:
trunk/jboss-integration/pom.xml
trunk/jboss-integration/src/
trunk/jboss-integration/src/main/
trunk/jboss-integration/src/main/java/
trunk/jboss-integration/src/main/java/com/
trunk/jboss-integration/src/main/java/com/metamatrix/
trunk/jboss-integration/src/main/java/org/
trunk/jboss-integration/src/main/java/org/teiid/
trunk/jboss-integration/src/main/java/org/teiid/adminapi/
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/
trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java
trunk/jboss-integration/src/main/java/org/teiid/templates/
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExtendedPropertyMetadata.java
trunk/jboss-integration/src/main/resources/
trunk/jboss-integration/src/test/
trunk/jboss-integration/src/test/java/
trunk/jboss-integration/src/test/java/com/
trunk/jboss-integration/src/test/java/com/metamatrix/
trunk/jboss-integration/src/test/java/com/metamatrix/dqp/
trunk/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/
trunk/jboss-integration/src/test/java/org/
trunk/jboss-integration/src/test/java/org/teiid/
trunk/jboss-integration/src/test/java/org/teiid/adminapi/
trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/
trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/BaseConnection.java
trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
trunk/jboss-integration/src/test/java/org/teiid/templates/
trunk/jboss-integration/src/test/java/org/teiid/templates/connector/
trunk/jboss-integration/src/test/java/org/teiid/templates/connector/TestExtendedPropertyMetadata.java
trunk/jboss-integration/src/test/resources/
trunk/jboss-integration/src/test/resources/TransactionsRevisited.vdb
trunk/jboss-integration/src/test/resources/connector-loopback.rar
trunk/jboss-integration/src/test/resources/log4j.xml
Log:
TEIID-833 committing JCA merge
Copied: trunk/jboss-integration (from rev 1899, branches/JCA/jboss-integration)
Property changes on: trunk/jboss-integration
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
Deleted: trunk/jboss-integration/pom.xml
===================================================================
--- branches/JCA/jboss-integration/pom.xml 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/pom.xml 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,176 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>teiid</artifactId>
- <groupId>org.jboss.teiid</groupId>
- <version>7.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-jboss-integration</artifactId>
- <name>teiid-jboss-integration</name>
- <version>7.0.0-SNAPSHOT</version>
- <description>JBoss specific integration layer for teiid</description>
-
- <build>
- <testResources>
- <testResource>
- <directory>target/test-classes/jboss-embedded</directory>
- </testResource>
- </testResources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>unpack</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>unpack</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-jboss-embedded</artifactId>
- <type>jar</type>
- <overWrite>true</overWrite>
- <outputDirectory>target/test-classes/jboss-embedded</outputDirectory>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
-
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-runtime</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-connector-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-client</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.resource</groupId>
- <artifactId>connector-api</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-reflect</artifactId>
- <scope>provided</scope>
- </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>
-
- <!-- these for just running profile service remotely -->
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-client-jdbc</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.naming</groupId>
- <artifactId>jnp-client</artifactId>
- <version>5.0.3.GA</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.aop</groupId>
- <artifactId>jboss-aop</artifactId>
- <classifier>client</classifier>
- <version>2.1.1.GA</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.remoting</groupId>
- <artifactId>jboss-remoting</artifactId>
- <version>2.5.1</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.aspects</groupId>
- <artifactId>jboss-security-aspects</artifactId>
- <version>1.0.0.GA</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.aspects</groupId>
- <artifactId>jboss-remoting-aspects</artifactId>
- <version>1.0.1.GA</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>oswego-concurrent</groupId>
- <artifactId>concurrent</artifactId>
- <version>1.3.4-jboss-update1</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-server</artifactId>
- <version>5.1.0.GA</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.jbossas</groupId>
- <artifactId>jboss-as-profileservice</artifactId>
- <version>5.1.0.GA</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
-</project>
Copied: trunk/jboss-integration/pom.xml (from rev 1899, branches/JCA/jboss-integration/pom.xml)
===================================================================
--- trunk/jboss-integration/pom.xml (rev 0)
+++ trunk/jboss-integration/pom.xml 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,176 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>teiid</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>7.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-jboss-integration</artifactId>
+ <name>teiid-jboss-integration</name>
+ <version>7.0.0-SNAPSHOT</version>
+ <description>JBoss specific integration layer for teiid</description>
+
+ <build>
+ <testResources>
+ <testResource>
+ <directory>target/test-classes/jboss-embedded</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-jboss-embedded</artifactId>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>target/test-classes/jboss-embedded</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-runtime</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-connector-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-reflect</artifactId>
+ <scope>provided</scope>
+ </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>
+
+ <!-- these for just running profile service remotely -->
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client-jdbc</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.naming</groupId>
+ <artifactId>jnp-client</artifactId>
+ <version>5.0.3.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.aop</groupId>
+ <artifactId>jboss-aop</artifactId>
+ <classifier>client</classifier>
+ <version>2.1.1.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.remoting</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ <version>2.5.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.aspects</groupId>
+ <artifactId>jboss-security-aspects</artifactId>
+ <version>1.0.0.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.aspects</groupId>
+ <artifactId>jboss-remoting-aspects</artifactId>
+ <version>1.0.1.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>1.3.4-jboss-update1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-server</artifactId>
+ <version>5.1.0.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-profileservice</artifactId>
+ <version>5.1.0.GA</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
Copied: trunk/jboss-integration/src (from rev 1899, branches/JCA/jboss-integration/src)
Copied: trunk/jboss-integration/src/main (from rev 1899, branches/JCA/jboss-integration/src/main)
Copied: trunk/jboss-integration/src/main/java (from rev 1899, branches/JCA/jboss-integration/src/main/java)
Copied: trunk/jboss-integration/src/main/java/com (from rev 1899, branches/JCA/jboss-integration/src/main/java/com)
Copied: trunk/jboss-integration/src/main/java/com/metamatrix (from rev 1899, branches/JCA/jboss-integration/src/main/java/com/metamatrix)
Copied: trunk/jboss-integration/src/main/java/org (from rev 1899, branches/JCA/jboss-integration/src/main/java/org)
Copied: trunk/jboss-integration/src/main/java/org/teiid (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid)
Copied: trunk/jboss-integration/src/main/java/org/teiid/adminapi (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi)
Copied: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss)
Deleted: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,907 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.adminapi.jboss;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ComponentType;
-import org.jboss.managed.api.DeploymentTemplateInfo;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
-import org.jboss.metatype.api.values.CollectionValueSupport;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.profileservice.spi.NoSuchDeploymentException;
-import org.jboss.profileservice.spi.ProfileKey;
-import org.jboss.virtual.VFS;
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminObject;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.ConnectionPoolStatistics;
-import org.teiid.adminapi.ConnectorBinding;
-import org.teiid.adminapi.PropertyDefinition;
-import org.teiid.adminapi.Request;
-import org.teiid.adminapi.Session;
-import org.teiid.adminapi.TeiidAdmin;
-import org.teiid.adminapi.Transaction;
-import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.WorkerPoolStatistics;
-import org.teiid.adminapi.impl.ConnectionPoolStatisticsMetadata;
-import org.teiid.adminapi.impl.ConnectorBindingMetaData;
-import org.teiid.adminapi.impl.ModelMetaData;
-import org.teiid.adminapi.impl.PropertyDefinitionMetadata;
-import org.teiid.adminapi.impl.RequestMetadata;
-import org.teiid.adminapi.impl.SessionMetadata;
-import org.teiid.adminapi.impl.TransactionMetadata;
-import org.teiid.adminapi.impl.VDBMetaData;
-import org.teiid.adminapi.impl.ModelMetaData.SourceMapping;
-import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
-import org.teiid.jboss.deployers.RuntimeEngineDeployer;
-
-public class Admin extends TeiidAdmin {
- protected Logger log = Logger.getLogger(getClass());
- private static final ProfileKey DEFAULT_PROFILE_KEY = new ProfileKey(ProfileKey.DEFAULT);
-
- private static final String XA_DATA_SOURCE_TEMPLATE = "XADataSourceTemplate";
- private static final long serialVersionUID = 7081309086056911304L;
- private static ComponentType VDBTYPE = new ComponentType("teiid", "vdb");
- private static ComponentType MODELTYPE = new ComponentType("teiid", "model");
- private static ComponentType NOTXTYPE = new ComponentType("ConnectionFactory", "NoTx");
- private static ComponentType TXTYPE = new ComponentType("ConnectionFactory", "Tx");
- private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp");
- private static ComponentType DSTYPE = new ComponentType("DataSource", "XA");
- private static String DQPNAME = RuntimeEngineDeployer.class.getName();
-
- private ManagementView view;
- private DeploymentManager deploymentMgr;
-
- static {
- VFS.init();
- }
-
- public Admin(ManagementView view, DeploymentManager deployMgr) {
- this.view = view;
- this.view.load();
-
- this.deploymentMgr = deployMgr;
- try {
- this.deploymentMgr.loadProfile(DEFAULT_PROFILE_KEY);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- private ManagementView getView() throws AdminProcessingException {
- if (this.view == null) {
- throw new AdminProcessingException("The admin connection is already closed");
- }
- this.view.load();
- return this.view;
- }
-
- private DeploymentManager getDeploymentManager() throws AdminProcessingException{
- if (this.deploymentMgr == null) {
- throw new AdminProcessingException("The admin connection is already closed");
- }
- return this.deploymentMgr;
- }
-
- public void close() {
- this.view = null;
- this.deploymentMgr = null;
- }
-
-// private DQPManagement getDQPManagement() throws Exception {
-// final ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(), DQPTYPE);
-//
-// return (DQPManagement)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {DQPManagement.class}, new InvocationHandler() {
-// @Override
-// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-//
-// MetaValue value = ManagedUtil.executeOperation(mc, method.getName());
-// Class returnType = method.getReturnType();
-// if (returnType.equals(Void.class)) {
-// return value;
-// }
-// return null;
-// }
-// });
-// }
-
- @Override
- public Collection<ConnectorBinding> getConnectorBindings() throws AdminException {
- ArrayList<ConnectorBinding> bindings = new ArrayList<ConnectorBinding>();
- findConnectorBindings(bindings, "NoTx");
- findConnectorBindings(bindings, "Tx");
- return bindings;
- }
-
- @Override
- public ConnectorBinding getConnectorBinding(String deployedName) throws AdminException {
- ManagedComponent mc = getConnectorBindingComponent(deployedName);
- if (mc != null) {
- return buildConnectorBinding(mc);
- }
- return null;
- }
-
- @Override
- public InputStream exportConnectorBinding(String deployedName) throws AdminException {
- ManagedComponent mc = getConnectorBindingComponent(deployedName);
- if (mc != null) {
- return exportDeployment(mc.getDeployment().getName());
- }
- return null;
- }
-
- private InputStream exportDeployment(String url) throws AdminComponentException {
- try {
- URL contentURL = new URL(url);
- return contentURL.openStream();
- } catch (MalformedURLException e) {
- throw new AdminComponentException(e);
- } catch (IOException e) {
- throw new AdminComponentException(e);
- }
- }
-
- private ManagedComponent getConnectorBindingComponent(String deployedName) throws AdminProcessingException {
- try {
- if (deployedName.startsWith("java:")) {
- deployedName = deployedName.substring(5);
- }
- ManagementView view = getView();
- ManagedComponent mc = view.getComponent(deployedName, NOTXTYPE);
- if (mc != null) {
- if (isConnectorBinding(mc)) {
- return mc;
- }
- }
-
- mc = view.getComponent(deployedName, TXTYPE);
- if (mc != null) {
- if (isConnectorBinding(mc)) {
- return mc;
- }
- }
- } catch(Exception e) {
- throw new AdminProcessingException(e.getMessage(), e);
- }
- return null;
- }
-
- private ConnectorBinding buildConnectorBinding(ManagedComponent mc) {
- ConnectorBindingMetaData connector = new ConnectorBindingMetaData();
- connector.setName(mc.getName());
- connector.setComponentType(mc.getType());
- connector.addProperty("deployer-name", mc.getDeployment().getName());
-
- 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.getMetaType().isSimple()) {
- connector.addProperty(key, ManagedUtil.stringValue(value));
- }
- else if (key.equals("config-property")) {
- MapCompositeValueSupport v1 = (MapCompositeValueSupport)value;
- MapCompositeMetaType metaType = v1.getMetaType();
- for (String configProperty:metaType.keySet()) {
- if (!configProperty.endsWith(".type")) {
- connector.addProperty(configProperty, ManagedUtil.stringValue(v1.get(configProperty)));
- }
- }
- }
- else {
- log.info(key+" property is not added to connector properties");
- }
- }
- }
- return connector;
- }
-
- private boolean isConnectorBinding(ManagedComponent mc) {
- String connectionDefinition = ManagedUtil.getSimpleValue(mc, "connection-definition", String.class);
- return "org.teiid.connector.api.Connector".equals(connectionDefinition);
- }
-
- 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")){
- bindings.add(buildConnectorBinding(mc));
- }
- }
- }catch(Exception e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public void addConnectorBinding(String deploymentName, String typeName, Properties properties) throws AdminException {
- if (getConnectorBinding(deploymentName) != null) {
- throw new AdminProcessingException("Connector binding with name "+deploymentName+" already exists.");
- }
- properties.setProperty("connection-definition", "org.teiid.connector.api.Connector");
- addConnectionfactory(deploymentName, typeName, properties);
- }
-
- @Override
- public void setConnectorBindingProperty(String deployedName, String propertyName, String propertyValue) throws AdminException{
- ManagedComponent mc = getConnectorBindingComponent(deployedName);
- if (mc == null) {
- throw new AdminProcessingException("Connector binding with name "+deployedName+" does not exist.");
- }
- if (mc.getProperty(propertyName) != null) {
- mc.getProperty(propertyName).setValue(SimpleValueSupport.wrap(propertyValue));
- }
- else {
- Map<String, String> configProps = new HashMap<String, String>();
- configProps.put(propertyName, propertyValue);
- configProps.put(propertyValue+".type", "java.lang.String");
- MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
- mc.getProperty("config-property").setValue(metaValue);
- }
- try {
- getView().updateComponent(mc);
- getView().load();
- } catch (Exception e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public void deleteConnectorBinding(String deployedName) throws AdminException {
- ManagedComponent mc = getConnectorBindingComponent(deployedName);
- if (mc != null) {
- ManagedUtil.removeArchive(getDeploymentManager(),mc.getDeployment().getName());
- }
- }
-
- @Override
- public void startConnectorBinding(ConnectorBinding binding) throws AdminException {
- try {
- String deployerName = binding.getPropertyValue("deployer-name");
- if (deployerName == null) {
- throw new AdminProcessingException("Failed to find deployer name of the connector. Can not start!");
- }
- ManagedUtil.execute(getDeploymentManager().start(deployerName), "Failed to start Connector Binding = " + binding.getName());
- } catch (Exception e) {
- ManagedUtil.handleException(e);
- }
- }
-
- @Override
- public void stopConnectorBinding(ConnectorBinding binding) throws AdminException {
- try {
- String deployerName = binding.getPropertyValue("deployer-name");
- if (deployerName == null) {
- throw new AdminProcessingException("Failed to find deployer name of the connector. Can not stop!");
- }
- ManagedUtil.execute(getDeploymentManager().stop(deployerName), "Failed to Stop Connector Binding = " + binding.getName());
- } catch (Exception e) {
- ManagedUtil.handleException(e);
- }
- }
-
- @Override
- public Collection<ConnectorBinding> getConnectorBindingsInVDB(String vdbName, int vdbVersion) throws AdminException {
- HashMap<String, ConnectorBinding> bindingMap = new HashMap<String, ConnectorBinding>();
- VDBMetaData vdb = (VDBMetaData) getVDB(vdbName, vdbVersion);
- if (vdb != null) {
- for (ModelMetaData model:vdb.getModels()) {
- if (model.isSource()) {
- for (String sourceName : model.getSourceNames()) {
- ConnectorBinding binding = getConnectorBinding(model.getSourceJndiName(sourceName));
- if (binding != null) {
- bindingMap.put(sourceName, binding);
- }
- }
- }
- }
- }
- return new ArrayList(bindingMap.values());
- }
-
-
- @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);
- }
-
- @Override
- public void deployVDB(String fileName, URL vdbURL) throws AdminException {
- if (!fileName.endsWith(".vdb") && !fileName.endsWith("-vdb.xml")) {
- throw new AdminProcessingException("The extension of the file name must be either .vdb designer vdbs or -vdb.xml for dynamic VDBs");
- }
- ManagedUtil.deployArchive(getDeploymentManager(), fileName, vdbURL, false);
- }
-
-
- @Override
- public void deleteVDB(String vdbName, int vdbVersion) throws AdminException {
- ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
- if (mc != null) {
- ManagedUtil.removeArchive(getDeploymentManager(), mc.getDeployment().getName());
- }
- }
-
- @Override
- public InputStream exportVDB(String vdbName, int vdbVersion) throws AdminException{
- ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
- if (mc != null) {
- return exportDeployment(mc.getDeployment().getName());
- }
- return null;
- }
-
- @Override
- public VDB getVDB(String vdbName, int vdbVersion) throws AdminException{
- ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
- if (mc != null) {
- return buildVDB(mc);
- }
- return null;
- }
-
- private ManagedComponent getVDBManagedComponent(String vdbName, int vdbVersion) throws AdminException{
- try {
- Set<ManagedComponent> vdbComponents = getView().getComponentsForType(VDBTYPE);
- for (ManagedComponent mc: vdbComponents) {
- String name = ManagedUtil.getSimpleValue(mc, "name", String.class);
- int version = ManagedUtil.getSimpleValue(mc, "version", Integer.class);
- if (name.equals(vdbName) && version == vdbVersion) {
- return mc;
- }
- }
- return null;
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public Set<VDB> getVDBs() throws AdminException {
- try {
- Set<VDB> vdbs = new HashSet<VDB>();
- Set<ManagedComponent> vdbComponents = getView().getComponentsForType(VDBTYPE);
- for (ManagedComponent mc: vdbComponents) {
- vdbs.add(buildVDB(mc));
- }
- return vdbs;
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- private VDBMetaData buildVDB(ManagedComponent mc) {
- VDBMetaData vdb = new VDBMetaData();
- vdb.setName(ManagedUtil.getSimpleValue(mc, "name", String.class));
- vdb.setDescription(ManagedUtil.getSimpleValue(mc, "description", String.class));
- String status = ManagedUtil.getSimpleValue(mc, "status", String.class);
- if (status != null) {
- vdb.setStatus(VDB.Status.valueOf(status));
- }
- vdb.setVersion(ManagedUtil.getSimpleValue(mc, "version", Integer.class));
- vdb.setUrl(mc.getDeployment().getName());
- vdb.setProperties(ManagedUtil.getPropertiesValue(mc, "properties"));
-
- // models
- ManagedProperty mp = mc.getProperty("models");
- List<ManagedObject> models = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(mp.getValue());
- for(ManagedObject mo:models) {
- vdb.addModel(buildModel(mo));
- }
-
- // TODO: add the following
- // SecurityRoleMappings
-
- return vdb;
- }
-
- private ModelMetaData buildModel(ManagedObject mc) {
- ModelMetaData model = new ModelMetaData();
- model.setName(ManagedUtil.getSimpleValue(mc, "name", String.class));
- model.setVisible(ManagedUtil.getSimpleValue(mc, "visible", Boolean.class));
- model.setModelType(ManagedUtil.getSimpleValue(mc, "modelType", String.class));
- model.setProperties(ManagedUtil.getPropertiesValue(mc, "properties"));
-
- List<SourceMapping> mappings = (List<SourceMapping>)MetaValueFactory.getInstance().unwrap(mc.getProperty("sourceMappings").getValue());
- for (SourceMapping s:mappings) {
- model.addSourceMapping(s.getName(), s.getJndiName());
- }
-
- List<ValidationError> errors = (List<ValidationError>)MetaValueFactory.getInstance().unwrap(mc.getProperty("errors").getValue());
- if (errors != null) {
- for (ValidationError error:errors) {
- model.addError(error.getSeverity(), error.getValue());
- }
- }
- return model;
- }
-
- @Override
- public Collection<Session> getSessions() throws AdminException {
- try {
- Collection<Session> sessionList = new ArrayList<Session>();
- ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- MetaValue value = ManagedUtil.executeOperation(mc, "getActiveSessions");
- MetaValue[] sessions = ((CollectionValueSupport)value).getElements();
- for (MetaValue mv:sessions) {
- sessionList.add((SessionMetadata)MetaValueFactory.getInstance().unwrap(mv, SessionMetadata.class));
- }
- return sessionList;
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public void terminateSession(long sessionId) throws AdminException {
- try {
- ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- ManagedUtil.executeOperation(mc, "terminateSession", SimpleValueSupport.wrap(sessionId));
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public Collection<Request> getRequests() throws AdminException {
- try {
- Collection<Request> requestList = new ArrayList<Request>();
- ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- MetaValue value = ManagedUtil.executeOperation(mc, "getRequests");
- MetaValue[] requests = ((CollectionValueSupport)value).getElements();
- for (MetaValue mv:requests) {
- requestList.add((RequestMetadata)MetaValueFactory.getInstance().unwrap(mv, RequestMetadata.class));
- }
- return requestList;
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public Collection<Request> getRequestsForSession(long sessionId) throws AdminException {
- try {
- Collection<Request> requestList = new ArrayList<Request>();
- ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- MetaValue value = ManagedUtil.executeOperation(mc, "getRequestsForSession", SimpleValueSupport.wrap(sessionId));
- MetaValue[] requests = ((CollectionValueSupport)value).getElements();
- for (MetaValue mv:requests) {
- requestList.add((RequestMetadata)MetaValueFactory.getInstance().unwrap(mv, RequestMetadata.class));
- }
- return requestList;
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public void cancelRequest(long sessionId, long requestId) throws AdminException{
- try {
- ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- ManagedUtil.executeOperation(mc, "cancelRequest", SimpleValueSupport.wrap(sessionId), SimpleValueSupport.wrap(requestId));
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- private String getRarDeployerName(String rarName) throws AdminException{
- try {
- Set<String> rarDeployments = getView().getDeploymentNamesForType("rar");
- for (String name: rarDeployments) {
- if (name.endsWith(rarName+"/")) {
- return name;
- }
- }
- return null;
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public void addConnectorType(String connectorName, URL rarURL) throws AdminException{
- if (!connectorName.startsWith("connector-")) {
- throw new AdminProcessingException("Teiid connector names must start with \"connector-\"");
- }
-
- if (!connectorName.endsWith(".rar")) {
- connectorName = connectorName + ".rar";
- }
-
- String deployerName = getRarDeployerName(connectorName);
- if (deployerName != null) {
- throw new AdminProcessingException("A Connectory with name:"+connectorName+" already exists!");
- }
-
- ManagedUtil.deployArchive(getDeploymentManager(), connectorName, rarURL, false);
-
- //also need to add a template for the properties
- try {
- String connectorNameWithoutExt = connectorName.substring(0, connectorName.length()-4);
- File jarFile = Admin.createConnectorTypeTemplate(connectorNameWithoutExt);
- ManagedUtil.deployArchive(getDeploymentManager(), connectorNameWithoutExt+"-template.jar", jarFile.toURI().toURL(), false);
- jarFile.delete();
- } catch (IOException e) {
- deleteConnectorType(connectorName);
- }
- }
-
- @Override
- public void deleteConnectorType(String connectorName) throws AdminException {
- if (!connectorName.endsWith(".rar")) {
- connectorName = connectorName + ".rar";
- }
- String deployerName = getRarDeployerName(connectorName);
- if (deployerName != null) {
- ManagedUtil.removeArchive(getDeploymentManager(), deployerName);
-
- //also need to delete template for the properties
- String connectorNameWithoutExt = connectorName.substring(0, connectorName.length()-4);
- ManagedUtil.removeArchive(getDeploymentManager(), connectorNameWithoutExt+"-template.jar");
- }
- }
-
- @Override
- public InputStream exportConnectorType(String connectorName) throws AdminException {
- if (!connectorName.endsWith(".rar")) {
- connectorName = connectorName + ".rar";
- }
- String deployerName = getRarDeployerName(connectorName);
- if (deployerName != null) {
- return exportDeployment(deployerName);
- }
- return null;
- }
-
-
-
- @Override
- public Collection<String> getCacheTypes() throws AdminException {
- try {
- Collection<String> requestList = new ArrayList<String>();
- ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- MetaValue value = ManagedUtil.executeOperation(mc, "getCacheTypes");
- MetaValue[] requests = ((CollectionValueSupport)value).getElements();
- for (MetaValue mv:requests) {
- requestList.add(ManagedUtil.stringValue(mv));
- }
- return requestList;
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public void clearCache(String cacheType) throws AdminException{
- try {
- ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- ManagedUtil.executeOperation(mc, "clearCache", SimpleValueSupport.wrap(cacheType));
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public Collection<Transaction> getTransactions() throws AdminException {
- try {
- Collection<Transaction> txnList = new ArrayList<Transaction>();
- ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- MetaValue value = ManagedUtil.executeOperation(mc, "getTransactions");
- MetaValue[] requests = ((CollectionValueSupport)value).getElements();
- for (MetaValue mv:requests) {
- txnList.add((TransactionMetadata)MetaValueFactory.getInstance().unwrap(mv, TransactionMetadata.class));
- }
- return txnList;
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public void terminateTransaction(String xid) throws AdminException {
- try {
- ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- ManagedUtil.executeOperation(mc, "terminateTransaction", MetaValueFactory.getInstance().create(xid));
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public WorkerPoolStatistics getWorkManagerStats(String identifier) throws AdminException {
- try {
- ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
- MetaValue value = ManagedUtil.executeOperation(mc, "getWorkManagerStatistics", SimpleValueSupport.wrap(identifier));
- return (WorkerPoolStatistics)MetaValueFactory.getInstance().unwrap(value, WorkerPoolStatistics.class);
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public ConnectionPoolStatistics getConnectorConnectionPoolStats(String deployedName) throws AdminException {
- ManagedComponent mc = getConnectorBindingComponent(deployedName);
- if (mc != null) {
- return buildConnectorConnectionPool(mc);
- }
- return null;
- }
-
- private ConnectionPoolStatistics buildConnectorConnectionPool(ManagedComponent mc) {
- ConnectionPoolStatisticsMetadata stats = new ConnectionPoolStatisticsMetadata();
- stats.setName(mc.getName());
- stats.setAvailableConnectionCount(ManagedUtil.getSimpleValue(mc, "availableConnectionCount", Long.class));
- stats.setConnectionCount(ManagedUtil.getSimpleValue(mc, "connectionCount", Integer.class));
- stats.setConnectionCreatedCount(ManagedUtil.getSimpleValue(mc, "connectionCreatedCount", Integer.class));
- stats.setConnectionDestroyedCount(ManagedUtil.getSimpleValue(mc, "connectionDestroyedCount", Integer.class));
- stats.setInUseConnectionCount(ManagedUtil.getSimpleValue(mc, "inUseConnectionCount", Long.class));
- stats.setMaxConnectionsInUseCount(ManagedUtil.getSimpleValue(mc, "maxConnectionsInUseCount", Long.class));
- stats.setMaxSize(ManagedUtil.getSimpleValue(mc, "maxSize", Integer.class));
- stats.setMinSize(ManagedUtil.getSimpleValue(mc, "minSize", Integer.class));
- return stats;
- }
-
- @Override
- public Collection<PropertyDefinition> getConnectorTypePropertyDefinitions(String typeName) throws AdminException {
- try {
- DeploymentTemplateInfo info = getView().getTemplate(typeName);
- if(info == null) {
- throw new AdminProcessingException("Connector Type template supplied not found in the configuration."+typeName);
- }
-
- ArrayList<PropertyDefinition> props = new ArrayList<PropertyDefinition>();
- Map<String, ManagedProperty> propertyMap = info.getProperties();
-
- for (ManagedProperty mp:propertyMap.values()) {
- PropertyDefinitionMetadata p = new PropertyDefinitionMetadata();
- p.setName(mp.getName());
- p.setDescription(mp.getDescription());
- p.setDisplayName(mp.getMappedName());
- if (mp.getDefaultValue() != null) {
- p.setDefaultValue(((SimpleValueSupport)mp.getDefaultValue()).getValue());
- }
- p.setPropertyTypeClassName(mp.getMetaType().getTypeName());
- p.setModifiable(!mp.isReadOnly());
-
- if (mp.getField("masked", Boolean.class) != null) {
- p.setMasked(mp.getField("masked", Boolean.class));
- }
- else {
- p.setMasked(false);
- }
-
- if (mp.getField("advanced", Boolean.class) != null) {
- p.setAdvanced(mp.getField("advanced", Boolean.class));
- }
- else {
- p.setAdvanced(true);
- }
- if (mp.getLegalValues() != null) {
- HashSet<String> values = new HashSet<String>();
- for (MetaValue value:mp.getLegalValues()) {
- values.add(ManagedUtil.stringValue(value));
- }
- p.setAllowedValues(values);
- }
-
- p.setRequired(mp.isMandatory());
- props.add(p);
- };
- return props;
- } catch (NoSuchDeploymentException e) {
- throw new AdminComponentException(e.getMessage(), e);
- } catch(Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public void addDataSource(String deploymentName, Properties properties) throws AdminException {
- addConnectionfactory(deploymentName, XA_DATA_SOURCE_TEMPLATE, properties);
- }
-
- private void addConnectionfactory(String deploymentName, String typeName, Properties properties) throws AdminException {
- try {
- DeploymentTemplateInfo info = getView().getTemplate(typeName);
- if(info == null) {
- throw new AdminProcessingException("Connector Type template supplied not found in the configuration."+typeName);
- }
-
- //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 deleteDataSource(String deployedName) throws AdminException {
- try {
- ManagementView view = getView();
- ManagedComponent mc = view.getComponent(deployedName, DSTYPE);
- if (mc != null) {
- ManagedUtil.removeArchive(getDeploymentManager(),mc.getDeployment().getName());
- }
- } catch (Exception e) {
- throw new AdminComponentException(e.getMessage(), e);
- }
- }
-
- @Override
- public Collection<PropertyDefinition> getDataSourcePropertyDefinitions() throws AdminException {
- return getConnectorTypePropertyDefinitions(XA_DATA_SOURCE_TEMPLATE);
- }
-
- private static final String connectorTemplate =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
- "<deployment xmlns=\"urn:jboss:bean-deployer:2.0\">\n" +
- "<!-- This is Teiid connector type template - DO NOT DELETE -->\n"+
- "<bean name=\"${name}\" class=\"org.teiid.templates.connector.ConnectorTypeTemplate\">\n" +
- " <property name=\"info\"><inject bean=\"${name}-templateinfo\"/></property>\n" +
- " <property name=\"targetTemplate\"><inject bean=\"NoTxConnectionFactoryTemplate\"/></property>\n" +
- "</bean>\n" +
- "<bean name=\"${name}-templateinfo\" class=\"org.teiid.templates.connector.ConnectorTypeTemplateInfo\">\n" +
- " <constructor factoryMethod=\"createTemplateInfo\">\n" +
- " <factory bean=\"DSDeploymentTemplateInfoFactory\"/>\n" +
- " <parameter class=\"java.lang.Class\">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>\n" +
- " <parameter class=\"java.lang.Class\">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>\n" +
- " <parameter class=\"java.lang.String\">${name}</parameter>\n" +
- " <parameter class=\"java.lang.String\">${name}</parameter>\n"+
- " </constructor>\n" +
- "</bean>\n"+
- "</deployment>";
-
- private static File createConnectorTypeTemplate(String name) throws IOException {
- String content = connectorTemplate.replace("${name}", name);
-
- File jarFile = File.createTempFile(name, ".jar");
- JarOutputStream jo = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(jarFile)));
-
- JarEntry je = new JarEntry("META-INF/jboss-beans.xml");
- jo.putNextEntry(je);
-
- jo.write(content.getBytes());
-
- jo.close();
- return jarFile;
- }
-
-
- @Override
- public void assignBindingsToModel(String vdbName, int vdbVersion, String modelName, String[] connectorBindingNames) throws AdminException {
-
-// ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
-// if (mc == null) {
-// throw new AdminProcessingException("VDB with name = "+vdbName + " version = "+ vdbVersion + " not found in configuration");
-// }
-// VDBMetaData vdb = buildVDB(mc);
-// ModelMetaData model = vdb.getModel(modelName);
-// if (model == null) {
-// throw new AdminProcessingException("Model name = "+modelName+" not found in the VDB with name = "+vdbName + " version = "+ vdbVersion);
-// }
-//
-// String referenceName = model.getConnectorReference();
-// ArrayList<MetaValue> newBindings = new ArrayList<MetaValue>();
-// for (String name:connectorBindingNames) {
-// newBindings.add(new SimpleValueSupport(SimpleMetaType.STRING, name));
-// }
-//
-// ManagedProperty mappings = mc.getProperty("connectorMappings");
-// MetaValue[] elements = ((CollectionValueSupport)mappings.getValue()).getElements();
-// ArrayList<MetaValue> modifiedElements = new ArrayList<MetaValue>();
-// for (MetaValue mv:elements) {
-// MetaValue value = ((CompositeValueSupport)mv).get("refName");
-// if (value != null && ManagedUtil.stringValue(value).equals(referenceName)) {
-// CollectionValueSupport bindings = (CollectionValueSupport)((CompositeValueSupport)mv).get("resourceNames");
-// bindings.setElements(newBindings.toArray(new MetaValue[newBindings.size()]));
-// }
-// else {
-// modifiedElements.add(mv);
-// }
-// }
-//
-// try {
-// getView().updateComponent(mc);
-// } catch (Exception e) {
-// throw new AdminComponentException(e.getMessage(), e);
-// }
- }
-
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,907 @@
+/*
+ * 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.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.virtual.VFS;
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.ConnectionPoolStatistics;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.PropertyDefinition;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.TeiidAdmin;
+import org.teiid.adminapi.Transaction;
+import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.WorkerPoolStatistics;
+import org.teiid.adminapi.impl.ConnectionPoolStatisticsMetadata;
+import org.teiid.adminapi.impl.ConnectorBindingMetaData;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.PropertyDefinitionMetadata;
+import org.teiid.adminapi.impl.RequestMetadata;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.adminapi.impl.TransactionMetadata;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.adminapi.impl.ModelMetaData.SourceMapping;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.jboss.deployers.RuntimeEngineDeployer;
+
+public class Admin extends TeiidAdmin {
+ protected Logger log = Logger.getLogger(getClass());
+ private static final ProfileKey DEFAULT_PROFILE_KEY = new ProfileKey(ProfileKey.DEFAULT);
+
+ private static final String XA_DATA_SOURCE_TEMPLATE = "XADataSourceTemplate";
+ private static final long serialVersionUID = 7081309086056911304L;
+ private static ComponentType VDBTYPE = new ComponentType("teiid", "vdb");
+ private static ComponentType MODELTYPE = new ComponentType("teiid", "model");
+ private static ComponentType NOTXTYPE = new ComponentType("ConnectionFactory", "NoTx");
+ private static ComponentType TXTYPE = new ComponentType("ConnectionFactory", "Tx");
+ private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp");
+ private static ComponentType DSTYPE = new ComponentType("DataSource", "XA");
+ private static String DQPNAME = RuntimeEngineDeployer.class.getName();
+
+ private ManagementView view;
+ private DeploymentManager deploymentMgr;
+
+ static {
+ VFS.init();
+ }
+
+ public Admin(ManagementView view, DeploymentManager deployMgr) {
+ this.view = view;
+ this.view.load();
+
+ this.deploymentMgr = deployMgr;
+ try {
+ this.deploymentMgr.loadProfile(DEFAULT_PROFILE_KEY);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private ManagementView getView() throws AdminProcessingException {
+ if (this.view == null) {
+ throw new AdminProcessingException("The admin connection is already closed");
+ }
+ this.view.load();
+ return this.view;
+ }
+
+ private DeploymentManager getDeploymentManager() throws AdminProcessingException{
+ if (this.deploymentMgr == null) {
+ throw new AdminProcessingException("The admin connection is already closed");
+ }
+ return this.deploymentMgr;
+ }
+
+ public void close() {
+ this.view = null;
+ this.deploymentMgr = null;
+ }
+
+// private DQPManagement getDQPManagement() throws Exception {
+// final ManagedComponent mc = getView().getComponent(DQPManagementView.class.getName(), DQPTYPE);
+//
+// return (DQPManagement)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {DQPManagement.class}, new InvocationHandler() {
+// @Override
+// public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+//
+// MetaValue value = ManagedUtil.executeOperation(mc, method.getName());
+// Class returnType = method.getReturnType();
+// if (returnType.equals(Void.class)) {
+// return value;
+// }
+// return null;
+// }
+// });
+// }
+
+ @Override
+ public Collection<ConnectorBinding> getConnectorBindings() throws AdminException {
+ ArrayList<ConnectorBinding> bindings = new ArrayList<ConnectorBinding>();
+ findConnectorBindings(bindings, "NoTx");
+ findConnectorBindings(bindings, "Tx");
+ return bindings;
+ }
+
+ @Override
+ public ConnectorBinding getConnectorBinding(String deployedName) throws AdminException {
+ ManagedComponent mc = getConnectorBindingComponent(deployedName);
+ if (mc != null) {
+ return buildConnectorBinding(mc);
+ }
+ return null;
+ }
+
+ @Override
+ public InputStream exportConnectorBinding(String deployedName) throws AdminException {
+ ManagedComponent mc = getConnectorBindingComponent(deployedName);
+ if (mc != null) {
+ return exportDeployment(mc.getDeployment().getName());
+ }
+ return null;
+ }
+
+ private InputStream exportDeployment(String url) throws AdminComponentException {
+ try {
+ URL contentURL = new URL(url);
+ return contentURL.openStream();
+ } catch (MalformedURLException e) {
+ throw new AdminComponentException(e);
+ } catch (IOException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ private ManagedComponent getConnectorBindingComponent(String deployedName) throws AdminProcessingException {
+ try {
+ if (deployedName.startsWith("java:")) {
+ deployedName = deployedName.substring(5);
+ }
+ ManagementView view = getView();
+ ManagedComponent mc = view.getComponent(deployedName, NOTXTYPE);
+ if (mc != null) {
+ if (isConnectorBinding(mc)) {
+ return mc;
+ }
+ }
+
+ mc = view.getComponent(deployedName, TXTYPE);
+ if (mc != null) {
+ if (isConnectorBinding(mc)) {
+ return mc;
+ }
+ }
+ } catch(Exception e) {
+ throw new AdminProcessingException(e.getMessage(), e);
+ }
+ return null;
+ }
+
+ private ConnectorBinding buildConnectorBinding(ManagedComponent mc) {
+ ConnectorBindingMetaData connector = new ConnectorBindingMetaData();
+ connector.setName(mc.getName());
+ connector.setComponentType(mc.getType());
+ connector.addProperty("deployer-name", mc.getDeployment().getName());
+
+ 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.getMetaType().isSimple()) {
+ connector.addProperty(key, ManagedUtil.stringValue(value));
+ }
+ else if (key.equals("config-property")) {
+ MapCompositeValueSupport v1 = (MapCompositeValueSupport)value;
+ MapCompositeMetaType metaType = v1.getMetaType();
+ for (String configProperty:metaType.keySet()) {
+ if (!configProperty.endsWith(".type")) {
+ connector.addProperty(configProperty, ManagedUtil.stringValue(v1.get(configProperty)));
+ }
+ }
+ }
+ else {
+ log.info(key+" property is not added to connector properties");
+ }
+ }
+ }
+ return connector;
+ }
+
+ private boolean isConnectorBinding(ManagedComponent mc) {
+ String connectionDefinition = ManagedUtil.getSimpleValue(mc, "connection-definition", String.class);
+ return "org.teiid.connector.api.Connector".equals(connectionDefinition);
+ }
+
+ 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")){
+ bindings.add(buildConnectorBinding(mc));
+ }
+ }
+ }catch(Exception e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ public void addConnectorBinding(String deploymentName, String typeName, Properties properties) throws AdminException {
+ if (getConnectorBinding(deploymentName) != null) {
+ throw new AdminProcessingException("Connector binding with name "+deploymentName+" already exists.");
+ }
+ properties.setProperty("connection-definition", "org.teiid.connector.api.Connector");
+ addConnectionfactory(deploymentName, typeName, properties);
+ }
+
+ @Override
+ public void setConnectorBindingProperty(String deployedName, String propertyName, String propertyValue) throws AdminException{
+ ManagedComponent mc = getConnectorBindingComponent(deployedName);
+ if (mc == null) {
+ throw new AdminProcessingException("Connector binding with name "+deployedName+" does not exist.");
+ }
+ if (mc.getProperty(propertyName) != null) {
+ mc.getProperty(propertyName).setValue(SimpleValueSupport.wrap(propertyValue));
+ }
+ else {
+ Map<String, String> configProps = new HashMap<String, String>();
+ configProps.put(propertyName, propertyValue);
+ configProps.put(propertyValue+".type", "java.lang.String");
+ MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
+ mc.getProperty("config-property").setValue(metaValue);
+ }
+ try {
+ getView().updateComponent(mc);
+ getView().load();
+ } catch (Exception e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ public void deleteConnectorBinding(String deployedName) throws AdminException {
+ ManagedComponent mc = getConnectorBindingComponent(deployedName);
+ if (mc != null) {
+ ManagedUtil.removeArchive(getDeploymentManager(),mc.getDeployment().getName());
+ }
+ }
+
+ @Override
+ public void startConnectorBinding(ConnectorBinding binding) throws AdminException {
+ try {
+ String deployerName = binding.getPropertyValue("deployer-name");
+ if (deployerName == null) {
+ throw new AdminProcessingException("Failed to find deployer name of the connector. Can not start!");
+ }
+ ManagedUtil.execute(getDeploymentManager().start(deployerName), "Failed to start Connector Binding = " + binding.getName());
+ } catch (Exception e) {
+ ManagedUtil.handleException(e);
+ }
+ }
+
+ @Override
+ public void stopConnectorBinding(ConnectorBinding binding) throws AdminException {
+ try {
+ String deployerName = binding.getPropertyValue("deployer-name");
+ if (deployerName == null) {
+ throw new AdminProcessingException("Failed to find deployer name of the connector. Can not stop!");
+ }
+ ManagedUtil.execute(getDeploymentManager().stop(deployerName), "Failed to Stop Connector Binding = " + binding.getName());
+ } catch (Exception e) {
+ ManagedUtil.handleException(e);
+ }
+ }
+
+ @Override
+ public Collection<ConnectorBinding> getConnectorBindingsInVDB(String vdbName, int vdbVersion) throws AdminException {
+ HashMap<String, ConnectorBinding> bindingMap = new HashMap<String, ConnectorBinding>();
+ VDBMetaData vdb = (VDBMetaData) getVDB(vdbName, vdbVersion);
+ if (vdb != null) {
+ for (ModelMetaData model:vdb.getModels()) {
+ if (model.isSource()) {
+ for (String sourceName : model.getSourceNames()) {
+ ConnectorBinding binding = getConnectorBinding(model.getSourceJndiName(sourceName));
+ if (binding != null) {
+ bindingMap.put(sourceName, binding);
+ }
+ }
+ }
+ }
+ }
+ return new ArrayList(bindingMap.values());
+ }
+
+
+ @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);
+ }
+
+ @Override
+ public void deployVDB(String fileName, URL vdbURL) throws AdminException {
+ if (!fileName.endsWith(".vdb") && !fileName.endsWith("-vdb.xml")) {
+ throw new AdminProcessingException("The extension of the file name must be either .vdb designer vdbs or -vdb.xml for dynamic VDBs");
+ }
+ ManagedUtil.deployArchive(getDeploymentManager(), fileName, vdbURL, false);
+ }
+
+
+ @Override
+ public void deleteVDB(String vdbName, int vdbVersion) throws AdminException {
+ ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
+ if (mc != null) {
+ ManagedUtil.removeArchive(getDeploymentManager(), mc.getDeployment().getName());
+ }
+ }
+
+ @Override
+ public InputStream exportVDB(String vdbName, int vdbVersion) throws AdminException{
+ ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
+ if (mc != null) {
+ return exportDeployment(mc.getDeployment().getName());
+ }
+ return null;
+ }
+
+ @Override
+ public VDB getVDB(String vdbName, int vdbVersion) throws AdminException{
+ ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
+ if (mc != null) {
+ return buildVDB(mc);
+ }
+ return null;
+ }
+
+ private ManagedComponent getVDBManagedComponent(String vdbName, int vdbVersion) throws AdminException{
+ try {
+ Set<ManagedComponent> vdbComponents = getView().getComponentsForType(VDBTYPE);
+ for (ManagedComponent mc: vdbComponents) {
+ String name = ManagedUtil.getSimpleValue(mc, "name", String.class);
+ int version = ManagedUtil.getSimpleValue(mc, "version", Integer.class);
+ if (name.equals(vdbName) && version == vdbVersion) {
+ return mc;
+ }
+ }
+ return null;
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public Set<VDB> getVDBs() throws AdminException {
+ try {
+ Set<VDB> vdbs = new HashSet<VDB>();
+ Set<ManagedComponent> vdbComponents = getView().getComponentsForType(VDBTYPE);
+ for (ManagedComponent mc: vdbComponents) {
+ vdbs.add(buildVDB(mc));
+ }
+ return vdbs;
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ private VDBMetaData buildVDB(ManagedComponent mc) {
+ VDBMetaData vdb = new VDBMetaData();
+ vdb.setName(ManagedUtil.getSimpleValue(mc, "name", String.class));
+ vdb.setDescription(ManagedUtil.getSimpleValue(mc, "description", String.class));
+ String status = ManagedUtil.getSimpleValue(mc, "status", String.class);
+ if (status != null) {
+ vdb.setStatus(VDB.Status.valueOf(status));
+ }
+ vdb.setVersion(ManagedUtil.getSimpleValue(mc, "version", Integer.class));
+ vdb.setUrl(mc.getDeployment().getName());
+ vdb.setProperties(ManagedUtil.getPropertiesValue(mc, "properties"));
+
+ // models
+ ManagedProperty mp = mc.getProperty("models");
+ List<ManagedObject> models = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(mp.getValue());
+ for(ManagedObject mo:models) {
+ vdb.addModel(buildModel(mo));
+ }
+
+ // TODO: add the following
+ // SecurityRoleMappings
+
+ return vdb;
+ }
+
+ private ModelMetaData buildModel(ManagedObject mc) {
+ ModelMetaData model = new ModelMetaData();
+ model.setName(ManagedUtil.getSimpleValue(mc, "name", String.class));
+ model.setVisible(ManagedUtil.getSimpleValue(mc, "visible", Boolean.class));
+ model.setModelType(ManagedUtil.getSimpleValue(mc, "modelType", String.class));
+ model.setProperties(ManagedUtil.getPropertiesValue(mc, "properties"));
+
+ List<SourceMapping> mappings = (List<SourceMapping>)MetaValueFactory.getInstance().unwrap(mc.getProperty("sourceMappings").getValue());
+ for (SourceMapping s:mappings) {
+ model.addSourceMapping(s.getName(), s.getJndiName());
+ }
+
+ List<ValidationError> errors = (List<ValidationError>)MetaValueFactory.getInstance().unwrap(mc.getProperty("errors").getValue());
+ if (errors != null) {
+ for (ValidationError error:errors) {
+ model.addError(error.getSeverity(), error.getValue());
+ }
+ }
+ return model;
+ }
+
+ @Override
+ public Collection<Session> getSessions() throws AdminException {
+ try {
+ Collection<Session> sessionList = new ArrayList<Session>();
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ MetaValue value = ManagedUtil.executeOperation(mc, "getActiveSessions");
+ MetaValue[] sessions = ((CollectionValueSupport)value).getElements();
+ for (MetaValue mv:sessions) {
+ sessionList.add((SessionMetadata)MetaValueFactory.getInstance().unwrap(mv, SessionMetadata.class));
+ }
+ return sessionList;
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void terminateSession(long sessionId) throws AdminException {
+ try {
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ ManagedUtil.executeOperation(mc, "terminateSession", SimpleValueSupport.wrap(sessionId));
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public Collection<Request> getRequests() throws AdminException {
+ try {
+ Collection<Request> requestList = new ArrayList<Request>();
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ MetaValue value = ManagedUtil.executeOperation(mc, "getRequests");
+ MetaValue[] requests = ((CollectionValueSupport)value).getElements();
+ for (MetaValue mv:requests) {
+ requestList.add((RequestMetadata)MetaValueFactory.getInstance().unwrap(mv, RequestMetadata.class));
+ }
+ return requestList;
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public Collection<Request> getRequestsForSession(long sessionId) throws AdminException {
+ try {
+ Collection<Request> requestList = new ArrayList<Request>();
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ MetaValue value = ManagedUtil.executeOperation(mc, "getRequestsForSession", SimpleValueSupport.wrap(sessionId));
+ MetaValue[] requests = ((CollectionValueSupport)value).getElements();
+ for (MetaValue mv:requests) {
+ requestList.add((RequestMetadata)MetaValueFactory.getInstance().unwrap(mv, RequestMetadata.class));
+ }
+ return requestList;
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void cancelRequest(long sessionId, long requestId) throws AdminException{
+ try {
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ ManagedUtil.executeOperation(mc, "cancelRequest", SimpleValueSupport.wrap(sessionId), SimpleValueSupport.wrap(requestId));
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ private String getRarDeployerName(String rarName) throws AdminException{
+ try {
+ Set<String> rarDeployments = getView().getDeploymentNamesForType("rar");
+ for (String name: rarDeployments) {
+ if (name.endsWith(rarName+"/")) {
+ return name;
+ }
+ }
+ return null;
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void addConnectorType(String connectorName, URL rarURL) throws AdminException{
+ if (!connectorName.startsWith("connector-")) {
+ throw new AdminProcessingException("Teiid connector names must start with \"connector-\"");
+ }
+
+ if (!connectorName.endsWith(".rar")) {
+ connectorName = connectorName + ".rar";
+ }
+
+ String deployerName = getRarDeployerName(connectorName);
+ if (deployerName != null) {
+ throw new AdminProcessingException("A Connectory with name:"+connectorName+" already exists!");
+ }
+
+ ManagedUtil.deployArchive(getDeploymentManager(), connectorName, rarURL, false);
+
+ //also need to add a template for the properties
+ try {
+ String connectorNameWithoutExt = connectorName.substring(0, connectorName.length()-4);
+ File jarFile = Admin.createConnectorTypeTemplate(connectorNameWithoutExt);
+ ManagedUtil.deployArchive(getDeploymentManager(), connectorNameWithoutExt+"-template.jar", jarFile.toURI().toURL(), false);
+ jarFile.delete();
+ } catch (IOException e) {
+ deleteConnectorType(connectorName);
+ }
+ }
+
+ @Override
+ public void deleteConnectorType(String connectorName) throws AdminException {
+ if (!connectorName.endsWith(".rar")) {
+ connectorName = connectorName + ".rar";
+ }
+ String deployerName = getRarDeployerName(connectorName);
+ if (deployerName != null) {
+ ManagedUtil.removeArchive(getDeploymentManager(), deployerName);
+
+ //also need to delete template for the properties
+ String connectorNameWithoutExt = connectorName.substring(0, connectorName.length()-4);
+ ManagedUtil.removeArchive(getDeploymentManager(), connectorNameWithoutExt+"-template.jar");
+ }
+ }
+
+ @Override
+ public InputStream exportConnectorType(String connectorName) throws AdminException {
+ if (!connectorName.endsWith(".rar")) {
+ connectorName = connectorName + ".rar";
+ }
+ String deployerName = getRarDeployerName(connectorName);
+ if (deployerName != null) {
+ return exportDeployment(deployerName);
+ }
+ return null;
+ }
+
+
+
+ @Override
+ public Collection<String> getCacheTypes() throws AdminException {
+ try {
+ Collection<String> requestList = new ArrayList<String>();
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ MetaValue value = ManagedUtil.executeOperation(mc, "getCacheTypes");
+ MetaValue[] requests = ((CollectionValueSupport)value).getElements();
+ for (MetaValue mv:requests) {
+ requestList.add(ManagedUtil.stringValue(mv));
+ }
+ return requestList;
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void clearCache(String cacheType) throws AdminException{
+ try {
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ ManagedUtil.executeOperation(mc, "clearCache", SimpleValueSupport.wrap(cacheType));
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public Collection<Transaction> getTransactions() throws AdminException {
+ try {
+ Collection<Transaction> txnList = new ArrayList<Transaction>();
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ MetaValue value = ManagedUtil.executeOperation(mc, "getTransactions");
+ MetaValue[] requests = ((CollectionValueSupport)value).getElements();
+ for (MetaValue mv:requests) {
+ txnList.add((TransactionMetadata)MetaValueFactory.getInstance().unwrap(mv, TransactionMetadata.class));
+ }
+ return txnList;
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void terminateTransaction(String xid) throws AdminException {
+ try {
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ ManagedUtil.executeOperation(mc, "terminateTransaction", MetaValueFactory.getInstance().create(xid));
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public WorkerPoolStatistics getWorkManagerStats(String identifier) throws AdminException {
+ try {
+ ManagedComponent mc = getView().getComponent(DQPNAME, DQPTYPE);
+ MetaValue value = ManagedUtil.executeOperation(mc, "getWorkManagerStatistics", SimpleValueSupport.wrap(identifier));
+ return (WorkerPoolStatistics)MetaValueFactory.getInstance().unwrap(value, WorkerPoolStatistics.class);
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public ConnectionPoolStatistics getConnectorConnectionPoolStats(String deployedName) throws AdminException {
+ ManagedComponent mc = getConnectorBindingComponent(deployedName);
+ if (mc != null) {
+ return buildConnectorConnectionPool(mc);
+ }
+ return null;
+ }
+
+ private ConnectionPoolStatistics buildConnectorConnectionPool(ManagedComponent mc) {
+ ConnectionPoolStatisticsMetadata stats = new ConnectionPoolStatisticsMetadata();
+ stats.setName(mc.getName());
+ stats.setAvailableConnectionCount(ManagedUtil.getSimpleValue(mc, "availableConnectionCount", Long.class));
+ stats.setConnectionCount(ManagedUtil.getSimpleValue(mc, "connectionCount", Integer.class));
+ stats.setConnectionCreatedCount(ManagedUtil.getSimpleValue(mc, "connectionCreatedCount", Integer.class));
+ stats.setConnectionDestroyedCount(ManagedUtil.getSimpleValue(mc, "connectionDestroyedCount", Integer.class));
+ stats.setInUseConnectionCount(ManagedUtil.getSimpleValue(mc, "inUseConnectionCount", Long.class));
+ stats.setMaxConnectionsInUseCount(ManagedUtil.getSimpleValue(mc, "maxConnectionsInUseCount", Long.class));
+ stats.setMaxSize(ManagedUtil.getSimpleValue(mc, "maxSize", Integer.class));
+ stats.setMinSize(ManagedUtil.getSimpleValue(mc, "minSize", Integer.class));
+ return stats;
+ }
+
+ @Override
+ public Collection<PropertyDefinition> getConnectorTypePropertyDefinitions(String typeName) throws AdminException {
+ try {
+ DeploymentTemplateInfo info = getView().getTemplate(typeName);
+ if(info == null) {
+ throw new AdminProcessingException("Connector Type template supplied not found in the configuration."+typeName);
+ }
+
+ ArrayList<PropertyDefinition> props = new ArrayList<PropertyDefinition>();
+ Map<String, ManagedProperty> propertyMap = info.getProperties();
+
+ for (ManagedProperty mp:propertyMap.values()) {
+ PropertyDefinitionMetadata p = new PropertyDefinitionMetadata();
+ p.setName(mp.getName());
+ p.setDescription(mp.getDescription());
+ p.setDisplayName(mp.getMappedName());
+ if (mp.getDefaultValue() != null) {
+ p.setDefaultValue(((SimpleValueSupport)mp.getDefaultValue()).getValue());
+ }
+ p.setPropertyTypeClassName(mp.getMetaType().getTypeName());
+ p.setModifiable(!mp.isReadOnly());
+
+ if (mp.getField("masked", Boolean.class) != null) {
+ p.setMasked(mp.getField("masked", Boolean.class));
+ }
+ else {
+ p.setMasked(false);
+ }
+
+ if (mp.getField("advanced", Boolean.class) != null) {
+ p.setAdvanced(mp.getField("advanced", Boolean.class));
+ }
+ else {
+ p.setAdvanced(true);
+ }
+ if (mp.getLegalValues() != null) {
+ HashSet<String> values = new HashSet<String>();
+ for (MetaValue value:mp.getLegalValues()) {
+ values.add(ManagedUtil.stringValue(value));
+ }
+ p.setAllowedValues(values);
+ }
+
+ p.setRequired(mp.isMandatory());
+ props.add(p);
+ };
+ return props;
+ } catch (NoSuchDeploymentException e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ } catch(Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void addDataSource(String deploymentName, Properties properties) throws AdminException {
+ addConnectionfactory(deploymentName, XA_DATA_SOURCE_TEMPLATE, properties);
+ }
+
+ private void addConnectionfactory(String deploymentName, String typeName, Properties properties) throws AdminException {
+ try {
+ DeploymentTemplateInfo info = getView().getTemplate(typeName);
+ if(info == null) {
+ throw new AdminProcessingException("Connector Type template supplied not found in the configuration."+typeName);
+ }
+
+ //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 deleteDataSource(String deployedName) throws AdminException {
+ try {
+ ManagementView view = getView();
+ ManagedComponent mc = view.getComponent(deployedName, DSTYPE);
+ if (mc != null) {
+ ManagedUtil.removeArchive(getDeploymentManager(),mc.getDeployment().getName());
+ }
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public Collection<PropertyDefinition> getDataSourcePropertyDefinitions() throws AdminException {
+ return getConnectorTypePropertyDefinitions(XA_DATA_SOURCE_TEMPLATE);
+ }
+
+ private static final String connectorTemplate =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"+
+ "<deployment xmlns=\"urn:jboss:bean-deployer:2.0\">\n" +
+ "<!-- This is Teiid connector type template - DO NOT DELETE -->\n"+
+ "<bean name=\"${name}\" class=\"org.teiid.templates.connector.ConnectorTypeTemplate\">\n" +
+ " <property name=\"info\"><inject bean=\"${name}-templateinfo\"/></property>\n" +
+ " <property name=\"targetTemplate\"><inject bean=\"NoTxConnectionFactoryTemplate\"/></property>\n" +
+ "</bean>\n" +
+ "<bean name=\"${name}-templateinfo\" class=\"org.teiid.templates.connector.ConnectorTypeTemplateInfo\">\n" +
+ " <constructor factoryMethod=\"createTemplateInfo\">\n" +
+ " <factory bean=\"DSDeploymentTemplateInfoFactory\"/>\n" +
+ " <parameter class=\"java.lang.Class\">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>\n" +
+ " <parameter class=\"java.lang.Class\">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>\n" +
+ " <parameter class=\"java.lang.String\">${name}</parameter>\n" +
+ " <parameter class=\"java.lang.String\">${name}</parameter>\n"+
+ " </constructor>\n" +
+ "</bean>\n"+
+ "</deployment>";
+
+ private static File createConnectorTypeTemplate(String name) throws IOException {
+ String content = connectorTemplate.replace("${name}", name);
+
+ File jarFile = File.createTempFile(name, ".jar");
+ JarOutputStream jo = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(jarFile)));
+
+ JarEntry je = new JarEntry("META-INF/jboss-beans.xml");
+ jo.putNextEntry(je);
+
+ jo.write(content.getBytes());
+
+ jo.close();
+ return jarFile;
+ }
+
+
+ @Override
+ public void assignBindingsToModel(String vdbName, int vdbVersion, String modelName, String[] connectorBindingNames) throws AdminException {
+
+// ManagedComponent mc = getVDBManagedComponent(vdbName, vdbVersion);
+// if (mc == null) {
+// throw new AdminProcessingException("VDB with name = "+vdbName + " version = "+ vdbVersion + " not found in configuration");
+// }
+// VDBMetaData vdb = buildVDB(mc);
+// ModelMetaData model = vdb.getModel(modelName);
+// if (model == null) {
+// throw new AdminProcessingException("Model name = "+modelName+" not found in the VDB with name = "+vdbName + " version = "+ vdbVersion);
+// }
+//
+// String referenceName = model.getConnectorReference();
+// ArrayList<MetaValue> newBindings = new ArrayList<MetaValue>();
+// for (String name:connectorBindingNames) {
+// newBindings.add(new SimpleValueSupport(SimpleMetaType.STRING, name));
+// }
+//
+// ManagedProperty mappings = mc.getProperty("connectorMappings");
+// MetaValue[] elements = ((CollectionValueSupport)mappings.getValue()).getElements();
+// ArrayList<MetaValue> modifiedElements = new ArrayList<MetaValue>();
+// for (MetaValue mv:elements) {
+// MetaValue value = ((CompositeValueSupport)mv).get("refName");
+// if (value != null && ManagedUtil.stringValue(value).equals(referenceName)) {
+// CollectionValueSupport bindings = (CollectionValueSupport)((CompositeValueSupport)mv).get("resourceNames");
+// bindings.setElements(newBindings.toArray(new MetaValue[newBindings.size()]));
+// }
+// else {
+// modifiedElements.add(mv);
+// }
+// }
+//
+// try {
+// getView().updateComponent(mc);
+// } catch (Exception e) {
+// throw new AdminComponentException(e.getMessage(), e);
+// }
+ }
+
+}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,189 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.jboss;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.login.Configuration;
-import javax.security.auth.login.LoginContext;
-import javax.security.auth.login.LoginException;
-
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.profileservice.spi.ProfileService;
-import org.teiid.adminapi.AdminComponentException;
-
-public class AdminProvider {
-
- public static Admin getLocal() throws AdminComponentException {
- ProfileConnection pc = new ProfileConnection();
- return new Admin(pc.getManagementView(), pc.getDeploymentManager());
- }
-
- public static Admin getRemote(String provideURL, String userid, String password) throws AdminComponentException {
- ProfileConnection pc = new ProfileConnection(provideURL, userid, password);
- return new Admin(pc.getManagementView(), pc.getDeploymentManager());
- }
-
- /**
- * Connection to profile service from a remote VM or local connection
- */
- static private class ProfileConnection {
- private static final String PROFILE_SERVICE_JNDI_NAME = "ProfileService";
- private static final String SECURE_PROFILE_SERVICE_JNDI_NAME = "SecureProfileService/remote";
- private static final String NAMING_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
- private static final String JNP_TIMEOUT_JNP_INIT_PROP = "jnp.timeout";
- private static final String JNP_SOTIMEOUT_JNP_INIT_PROP = "jnp.sotimeout";
- private static final String JNP_DISABLE_DISCOVERY_JNP_INIT_PROP = "jnp.disableDiscovery";
-
- /**
- * This is the timeout (in milliseconds) for the initial attempt to establish the remote connection.
- */
- private static final int JNP_TIMEOUT = 60 * 1000; // 60 seconds
-
- /**
- * This is the timeout (in milliseconds) for methods invoked on the remote ProfileService. NOTE: This timeout comes
- * into play if the JBossAS instance has gone down since the original JNP connection was made.
- */
- private static final int JNP_SO_TIMEOUT = 60 * 1000; // 60 seconds
-
- /**
- * A flag indicating that the discovery process should not attempt to automatically discover (via multicast) naming
- * servers running the JBoss HA-JNDI service if it fails to connect to the specified jnp URL.
- */
- private static final boolean JNP_DISABLE_DISCOVERY = true;
-
- private ProfileService profileService;
- private String userName;
- private String password;
-
-
- public ProfileConnection() throws AdminComponentException {
- this.profileService = connect(null, null, null);
- }
-
- public ProfileConnection(String providerURL, String user, String password) throws AdminComponentException {
- this.userName = user;
- this.password = password;
- this.profileService = connect(providerURL, user, password);
- }
-
- public ManagementView getManagementView() {
- return this.profileService.getViewManager();
- }
-
- public DeploymentManager getDeploymentManager() {
- return this.profileService.getDeploymentManager();
- }
-
- private ProfileService connect(String providerURL, String user, String password) throws AdminComponentException {
- ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- // local connection
- if (providerURL == null) {
- InitialContext ic = new InitialContext();
- return (ProfileService)ic.lookup(PROFILE_SERVICE_JNDI_NAME);
- }
-
- Properties env = new Properties();
- env.setProperty(Context.PROVIDER_URL, providerURL);
-
- // un-authenticated remote login
- env.setProperty(Context.INITIAL_CONTEXT_FACTORY, NAMING_CONTEXT_FACTORY);
- env.setProperty(Context.SECURITY_PRINCIPAL, user);
- env.setProperty(Context.SECURITY_CREDENTIALS, password);
- env.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
- env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, "true");
- env.setProperty(JNP_TIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_TIMEOUT));
- env.setProperty(JNP_SOTIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_SO_TIMEOUT));
- env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, String.valueOf(JNP_DISABLE_DISCOVERY));
- env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
- InitialContext ic = new InitialContext(env);
-
- try {
- return (ProfileService)ic.lookup(PROFILE_SERVICE_JNDI_NAME);
- } catch(NamingException e) {
- ProfileService ps = (ProfileService)ic.lookup(SECURE_PROFILE_SERVICE_JNDI_NAME);
- return (ProfileService)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {ProfileService.class}, new JaasSecurityHandler(ps, this.userName, this.password));
- }
- } catch(NamingException e) {
- throw new AdminComponentException(e);
- } finally {
- Thread.currentThread().setContextClassLoader(originalContextClassLoader);
- }
- }
- }
-
- static class JaasSecurityHandler implements InvocationHandler {
- private Object target;
- private LoginContext loginContext;
-
- public JaasSecurityHandler(Object target, final String username, final String password) {
- this.target = target;
- Configuration jaasConfig = new JBossConfiguration();
- try {
- this.loginContext = new LoginContext(JBossConfiguration.JBOSS_ENTRY_NAME, null, new CallbackHandler() {
-
- @Override
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
- for (Callback callback : callbacks) {
- if (callback instanceof NameCallback) {
- NameCallback nameCallback = (NameCallback)callback;
- nameCallback.setName(username);
- }
- else if (callback instanceof PasswordCallback) {
- PasswordCallback passwordCallback = (PasswordCallback)callback;
- passwordCallback.setPassword(password.toCharArray());
- }
- else {
- throw new UnsupportedCallbackException(callback, "Unrecognized Callback: " + callback);
- }
- }
-
- }
- }, jaasConfig);
- }
- catch (LoginException e) {
- throw new RuntimeException(e);
- }
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- this.loginContext.login();
- Object returnValue = method.invoke(this.target, args);
- this.loginContext.logout();
- return returnValue;
- }
- }
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminProvider.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,189 @@
+/*
+ * 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.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.profileservice.spi.ProfileService;
+import org.teiid.adminapi.AdminComponentException;
+
+public class AdminProvider {
+
+ public static Admin getLocal() throws AdminComponentException {
+ ProfileConnection pc = new ProfileConnection();
+ return new Admin(pc.getManagementView(), pc.getDeploymentManager());
+ }
+
+ public static Admin getRemote(String provideURL, String userid, String password) throws AdminComponentException {
+ ProfileConnection pc = new ProfileConnection(provideURL, userid, password);
+ return new Admin(pc.getManagementView(), pc.getDeploymentManager());
+ }
+
+ /**
+ * Connection to profile service from a remote VM or local connection
+ */
+ static private class ProfileConnection {
+ private static final String PROFILE_SERVICE_JNDI_NAME = "ProfileService";
+ private static final String SECURE_PROFILE_SERVICE_JNDI_NAME = "SecureProfileService/remote";
+ private static final String NAMING_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory";
+ private static final String JNP_TIMEOUT_JNP_INIT_PROP = "jnp.timeout";
+ private static final String JNP_SOTIMEOUT_JNP_INIT_PROP = "jnp.sotimeout";
+ private static final String JNP_DISABLE_DISCOVERY_JNP_INIT_PROP = "jnp.disableDiscovery";
+
+ /**
+ * This is the timeout (in milliseconds) for the initial attempt to establish the remote connection.
+ */
+ private static final int JNP_TIMEOUT = 60 * 1000; // 60 seconds
+
+ /**
+ * This is the timeout (in milliseconds) for methods invoked on the remote ProfileService. NOTE: This timeout comes
+ * into play if the JBossAS instance has gone down since the original JNP connection was made.
+ */
+ private static final int JNP_SO_TIMEOUT = 60 * 1000; // 60 seconds
+
+ /**
+ * A flag indicating that the discovery process should not attempt to automatically discover (via multicast) naming
+ * servers running the JBoss HA-JNDI service if it fails to connect to the specified jnp URL.
+ */
+ private static final boolean JNP_DISABLE_DISCOVERY = true;
+
+ private ProfileService profileService;
+ private String userName;
+ private String password;
+
+
+ public ProfileConnection() throws AdminComponentException {
+ this.profileService = connect(null, null, null);
+ }
+
+ public ProfileConnection(String providerURL, String user, String password) throws AdminComponentException {
+ this.userName = user;
+ this.password = password;
+ this.profileService = connect(providerURL, user, password);
+ }
+
+ public ManagementView getManagementView() {
+ return this.profileService.getViewManager();
+ }
+
+ public DeploymentManager getDeploymentManager() {
+ return this.profileService.getDeploymentManager();
+ }
+
+ private ProfileService connect(String providerURL, String user, String password) throws AdminComponentException {
+ ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ // local connection
+ if (providerURL == null) {
+ InitialContext ic = new InitialContext();
+ return (ProfileService)ic.lookup(PROFILE_SERVICE_JNDI_NAME);
+ }
+
+ Properties env = new Properties();
+ env.setProperty(Context.PROVIDER_URL, providerURL);
+
+ // un-authenticated remote login
+ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, NAMING_CONTEXT_FACTORY);
+ env.setProperty(Context.SECURITY_PRINCIPAL, user);
+ env.setProperty(Context.SECURITY_CREDENTIALS, password);
+ env.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
+ env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, "true");
+ env.setProperty(JNP_TIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_TIMEOUT));
+ env.setProperty(JNP_SOTIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_SO_TIMEOUT));
+ env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, String.valueOf(JNP_DISABLE_DISCOVERY));
+ env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
+ InitialContext ic = new InitialContext(env);
+
+ try {
+ return (ProfileService)ic.lookup(PROFILE_SERVICE_JNDI_NAME);
+ } catch(NamingException e) {
+ ProfileService ps = (ProfileService)ic.lookup(SECURE_PROFILE_SERVICE_JNDI_NAME);
+ return (ProfileService)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {ProfileService.class}, new JaasSecurityHandler(ps, this.userName, this.password));
+ }
+ } catch(NamingException e) {
+ throw new AdminComponentException(e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalContextClassLoader);
+ }
+ }
+ }
+
+ static class JaasSecurityHandler implements InvocationHandler {
+ private Object target;
+ private LoginContext loginContext;
+
+ public JaasSecurityHandler(Object target, final String username, final String password) {
+ this.target = target;
+ Configuration jaasConfig = new JBossConfiguration();
+ try {
+ this.loginContext = new LoginContext(JBossConfiguration.JBOSS_ENTRY_NAME, null, new CallbackHandler() {
+
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ for (Callback callback : callbacks) {
+ if (callback instanceof NameCallback) {
+ NameCallback nameCallback = (NameCallback)callback;
+ nameCallback.setName(username);
+ }
+ else if (callback instanceof PasswordCallback) {
+ PasswordCallback passwordCallback = (PasswordCallback)callback;
+ passwordCallback.setPassword(password.toCharArray());
+ }
+ else {
+ throw new UnsupportedCallbackException(callback, "Unrecognized Callback: " + callback);
+ }
+ }
+
+ }
+ }, jaasConfig);
+ }
+ catch (LoginException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ this.loginContext.login();
+ Object returnValue = method.invoke(this.target, args);
+ this.loginContext.logout();
+ return returnValue;
+ }
+ }
+}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,63 +0,0 @@
-/*
- * Jopr Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program 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 General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * 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.Map;
-import java.util.HashMap;
-
-import javax.security.auth.login.Configuration;
-import javax.security.auth.login.AppConfigurationEntry;
-
-/**
- * A JAAS configuration for a JBoss client. This is the programmatic equivalent of the following auth.conf file:
- *
- * <code>
- * jboss
- * {
- * org.jboss.security.ClientLoginModule required
- * multi-threaded=true;
- * };
- * </code>
- *
- * @author Ian Springer
- */
-public class JBossConfiguration extends Configuration {
- public static final String JBOSS_ENTRY_NAME = "profileservice";
-
- private static final String JBOSS_LOGIN_MODULE_CLASS_NAME = "org.jboss.security.ClientLoginModule";
- private static final String MULTI_THREADED_OPTION = "multi-threaded";
-
- public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
- if (JBOSS_ENTRY_NAME.equals(name)) {
- Map options = new HashMap(1);
- options.put(MULTI_THREADED_OPTION, Boolean.TRUE.toString());
- AppConfigurationEntry appConfigurationEntry = new AppConfigurationEntry(JBOSS_LOGIN_MODULE_CLASS_NAME, AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options);
- return new AppConfigurationEntry[] {appConfigurationEntry};
- }
- throw new IllegalArgumentException("Unknown entry name: " + name);
- }
-
- public void refresh() {
- return;
- }
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/JBossConfiguration.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,63 @@
+/*
+ * Jopr Management Platform
+ * Copyright (C) 2005-2009 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program 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 General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * 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.Map;
+import java.util.HashMap;
+
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.AppConfigurationEntry;
+
+/**
+ * A JAAS configuration for a JBoss client. This is the programmatic equivalent of the following auth.conf file:
+ *
+ * <code>
+ * jboss
+ * {
+ * org.jboss.security.ClientLoginModule required
+ * multi-threaded=true;
+ * };
+ * </code>
+ *
+ * @author Ian Springer
+ */
+public class JBossConfiguration extends Configuration {
+ public static final String JBOSS_ENTRY_NAME = "profileservice";
+
+ private static final String JBOSS_LOGIN_MODULE_CLASS_NAME = "org.jboss.security.ClientLoginModule";
+ private static final String MULTI_THREADED_OPTION = "multi-threaded";
+
+ public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
+ if (JBOSS_ENTRY_NAME.equals(name)) {
+ Map options = new HashMap(1);
+ options.put(MULTI_THREADED_OPTION, Boolean.TRUE.toString());
+ AppConfigurationEntry appConfigurationEntry = new AppConfigurationEntry(JBOSS_LOGIN_MODULE_CLASS_NAME, AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options);
+ return new AppConfigurationEntry[] {appConfigurationEntry};
+ }
+ throw new IllegalArgumentException("Unknown entry name: " + name);
+ }
+
+ public void refresh() {
+ return;
+ }
+}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,285 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.adminapi.jboss;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URL;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
-import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
-import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
-import org.jboss.managed.api.ManagedCommon;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.managed.api.ManagedProperty;
-import org.jboss.metatype.api.types.MapCompositeMetaType;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.CollectionValue;
-import org.jboss.metatype.api.values.EnumValue;
-import org.jboss.metatype.api.values.MapCompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.PropertiesMetaValue;
-import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.jboss.profileservice.spi.DeploymentOption;
-import org.teiid.adminapi.AdminProcessingException;
-
-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 <T> T getSimpleValue(ManagedCommon mc, String prop, Class<T> expectedType) {
- ManagedProperty mp = mc.getProperty(prop);
- if (mp != null) {
- MetaType metaType = mp.getMetaType();
- if (metaType.isSimple()) {
- SimpleValue simpleValue = (SimpleValue)mp.getValue();
- return expectedType.cast((simpleValue != null) ? simpleValue.getValue() : null);
- }
- else if (metaType.isEnum()) {
- EnumValue enumValue = (EnumValue)mp.getValue();
- return expectedType.cast((enumValue != null) ? enumValue.getValue() : null);
- }
- throw new IllegalStateException(prop+ " is not a simple type");
- }
- return null;
- }
-
- public static Properties getPropertiesValue(ManagedCommon mc, String prop) {
- ManagedProperty mp = mc.getProperty(prop);
- if (mp != null) {
- MetaType metaType = mp.getMetaType();
- if (metaType.isProperties()) {
- return (PropertiesMetaValue)mp.getValue();
- }
- else if (metaType.isComposite()) {
- Properties props = new Properties();
- MapCompositeValueSupport map = (MapCompositeValueSupport) mp.getValue();
- MapCompositeMetaType type = map.getMetaType();
- for (String key : type.keySet()) {
- MetaValue value = map.get(key);
- props.setProperty(key, stringValue(value));
- }
- return props;
- }
- throw new IllegalStateException(prop+ " is not a properties type");
- }
- return null;
- }
-
- public static <T> void getCollectionValue(ManagedCommon mc, String prop, Collection<T> list, Class<T> expectedType) {
- ManagedProperty mp = mc.getProperty(prop);
- if (mp != null) {
- MetaType metaType = mp.getMetaType();
- if (metaType.isCollection()) {
- CollectionValue collectionValue = (CollectionValue)mp.getValue();
- for(MetaValue value:collectionValue.getElements()) {
- if (value.getMetaType().isSimple()) {
- SimpleValue simpleValue = (SimpleValue)value;
- list.add(expectedType.cast(simpleValue.getValue()));
- }
- else {
- throw new IllegalStateException(prop+ " is not a simple type");
- }
- }
- }
- }
- }
-
- 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");
- }
-
-
- public static void deployArchive(DeploymentManager deploymentManager, String fileName, URL resourceURL, boolean deployExploded) throws AdminProcessingException {
-
- List<DeploymentOption> deploymentOptions = new ArrayList<DeploymentOption>();
- deploymentOptions.add(DeploymentOption.FailIfExists);
- if (deployExploded) {
- deploymentOptions.add(DeploymentOption.Explode);
- }
-
- // try to deploy
- DeploymentProgress progress = null;
- try {
- progress = deploymentManager.distribute(fileName, resourceURL, deploymentOptions.toArray(new DeploymentOption[deploymentOptions.size()]));
- execute(progress, fileName+" Distribute failed for unknown reason.");
- } catch (Exception e) {
- handleException(e);
- }
-
- // Now that we've successfully distributed the deployment, we need to
- // start it.
- String[] deploymentNames = progress.getDeploymentID().getRepositoryNames();
- try {
- progress = deploymentManager.start(deploymentNames);
- execute(progress, "Start of the deployment Failed");
- } catch(Exception e) {
- try {
- // if failed to start remove it.
- execute(deploymentManager.remove(deploymentNames), "Failed to remove the deployment");
- } catch (Exception e1) {
- handleException(e1);
- }
- handleException(e);
- }
- }
-
- public static void handleException(Exception e) throws AdminProcessingException {
- if (e instanceof AdminProcessingException) {
- throw (AdminProcessingException)e;
- }
- throw new AdminProcessingException(e.getMessage(), e);
- }
-
- public static void execute(DeploymentProgress progress, String errorMessage) throws AdminProcessingException {
- progress.run();
- DeploymentStatus status = progress.getDeploymentStatus();
-
- if (status.isFailed()) {
- if (status.getFailure() != null) {
- throw new AdminProcessingException(status.getFailure().getMessage(), status.getFailure());
- }
- throw new AdminProcessingException(errorMessage);
- }
- }
-
- public static void removeArchive(DeploymentManager deploymentManager, String... deploymentNames) throws AdminProcessingException{
- try {
- execute(deploymentManager.remove(deploymentNames), "Failed to remove the deployment");
- } catch (Exception e) {
- handleException(e);
- }
- }
-
- public static MetaValue executeOperation(ManagedCommon mc, String operation, MetaValue... args) {
- for (ManagedOperation mo:mc.getOperations()) {
- if (mo.getName().equals(operation)) {
- return mo.invoke(args);
- }
- }
- throw new MetaMatrixRuntimeException("No operation found with given name =" + operation);
- }
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,285 @@
+/*
+ * 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.net.URL;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.managed.api.ManagedCommon;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.PropertiesMetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.spi.DeploymentOption;
+import org.teiid.adminapi.AdminProcessingException;
+
+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 <T> T getSimpleValue(ManagedCommon mc, String prop, Class<T> expectedType) {
+ ManagedProperty mp = mc.getProperty(prop);
+ if (mp != null) {
+ MetaType metaType = mp.getMetaType();
+ if (metaType.isSimple()) {
+ SimpleValue simpleValue = (SimpleValue)mp.getValue();
+ return expectedType.cast((simpleValue != null) ? simpleValue.getValue() : null);
+ }
+ else if (metaType.isEnum()) {
+ EnumValue enumValue = (EnumValue)mp.getValue();
+ return expectedType.cast((enumValue != null) ? enumValue.getValue() : null);
+ }
+ throw new IllegalStateException(prop+ " is not a simple type");
+ }
+ return null;
+ }
+
+ public static Properties getPropertiesValue(ManagedCommon mc, String prop) {
+ ManagedProperty mp = mc.getProperty(prop);
+ if (mp != null) {
+ MetaType metaType = mp.getMetaType();
+ if (metaType.isProperties()) {
+ return (PropertiesMetaValue)mp.getValue();
+ }
+ else if (metaType.isComposite()) {
+ Properties props = new Properties();
+ MapCompositeValueSupport map = (MapCompositeValueSupport) mp.getValue();
+ MapCompositeMetaType type = map.getMetaType();
+ for (String key : type.keySet()) {
+ MetaValue value = map.get(key);
+ props.setProperty(key, stringValue(value));
+ }
+ return props;
+ }
+ throw new IllegalStateException(prop+ " is not a properties type");
+ }
+ return null;
+ }
+
+ public static <T> void getCollectionValue(ManagedCommon mc, String prop, Collection<T> list, Class<T> expectedType) {
+ ManagedProperty mp = mc.getProperty(prop);
+ if (mp != null) {
+ MetaType metaType = mp.getMetaType();
+ if (metaType.isCollection()) {
+ CollectionValue collectionValue = (CollectionValue)mp.getValue();
+ for(MetaValue value:collectionValue.getElements()) {
+ if (value.getMetaType().isSimple()) {
+ SimpleValue simpleValue = (SimpleValue)value;
+ list.add(expectedType.cast(simpleValue.getValue()));
+ }
+ else {
+ throw new IllegalStateException(prop+ " is not a simple type");
+ }
+ }
+ }
+ }
+ }
+
+ 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");
+ }
+
+
+ public static void deployArchive(DeploymentManager deploymentManager, String fileName, URL resourceURL, boolean deployExploded) throws AdminProcessingException {
+
+ List<DeploymentOption> deploymentOptions = new ArrayList<DeploymentOption>();
+ deploymentOptions.add(DeploymentOption.FailIfExists);
+ if (deployExploded) {
+ deploymentOptions.add(DeploymentOption.Explode);
+ }
+
+ // try to deploy
+ DeploymentProgress progress = null;
+ try {
+ progress = deploymentManager.distribute(fileName, resourceURL, deploymentOptions.toArray(new DeploymentOption[deploymentOptions.size()]));
+ execute(progress, fileName+" Distribute failed for unknown reason.");
+ } catch (Exception e) {
+ handleException(e);
+ }
+
+ // Now that we've successfully distributed the deployment, we need to
+ // start it.
+ String[] deploymentNames = progress.getDeploymentID().getRepositoryNames();
+ try {
+ progress = deploymentManager.start(deploymentNames);
+ execute(progress, "Start of the deployment Failed");
+ } catch(Exception e) {
+ try {
+ // if failed to start remove it.
+ execute(deploymentManager.remove(deploymentNames), "Failed to remove the deployment");
+ } catch (Exception e1) {
+ handleException(e1);
+ }
+ handleException(e);
+ }
+ }
+
+ public static void handleException(Exception e) throws AdminProcessingException {
+ if (e instanceof AdminProcessingException) {
+ throw (AdminProcessingException)e;
+ }
+ throw new AdminProcessingException(e.getMessage(), e);
+ }
+
+ public static void execute(DeploymentProgress progress, String errorMessage) throws AdminProcessingException {
+ progress.run();
+ DeploymentStatus status = progress.getDeploymentStatus();
+
+ if (status.isFailed()) {
+ if (status.getFailure() != null) {
+ throw new AdminProcessingException(status.getFailure().getMessage(), status.getFailure());
+ }
+ throw new AdminProcessingException(errorMessage);
+ }
+ }
+
+ public static void removeArchive(DeploymentManager deploymentManager, String... deploymentNames) throws AdminProcessingException{
+ try {
+ execute(deploymentManager.remove(deploymentNames), "Failed to remove the deployment");
+ } catch (Exception e) {
+ handleException(e);
+ }
+ }
+
+ public static MetaValue executeOperation(ManagedCommon mc, String operation, MetaValue... args) {
+ for (ManagedOperation mo:mc.getOperations()) {
+ if (mo.getName().equals(operation)) {
+ return mo.invoke(args);
+ }
+ }
+ throw new MetaMatrixRuntimeException("No operation found with given name =" + operation);
+ }
+}
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/jboss)
Deleted: trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.jboss;
-
-import java.io.Serializable;
-import java.security.Principal;
-
-import javax.security.auth.Subject;
-
-import org.jboss.security.SecurityContext;
-import org.teiid.SecurityHelper;
-
-public class JBossSecurityHelper implements SecurityHelper, Serializable {
-
- @Override
- public boolean assosiateSecurityContext(String securityDomain, Object newContext) {
- SecurityContext context = SecurityActions.getSecurityContext();
- if (context == null || (!context.getSecurityDomain().equals(securityDomain) && newContext != null)) {
- SecurityActions.setSecurityContext((SecurityContext)newContext);
- return true;
- }
- return false;
- }
-
- @Override
- public void clearSecurityContext(String securityDomain) {
- SecurityContext sc = SecurityActions.getSecurityContext();
- if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
- SecurityActions.clearSecurityContext();
- }
- }
-
- @Override
- public Object getSecurityContext(String securityDomain) {
- SecurityContext sc = SecurityActions.getSecurityContext();
- if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
- return sc;
- }
- return null;
- }
-
- @Override
- public Object createSecurityContext(String securityDomain, Principal p, Object credentials, Subject subject) {
- SecurityActions.pushSecurityContext(p, credentials, subject, securityDomain);
- return getSecurityContext(securityDomain);
- }
-
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/JBossSecurityHelper.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,68 @@
+/*
+ * 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.jboss;
+
+import java.io.Serializable;
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import org.jboss.security.SecurityContext;
+import org.teiid.SecurityHelper;
+
+public class JBossSecurityHelper implements SecurityHelper, Serializable {
+
+ @Override
+ public boolean assosiateSecurityContext(String securityDomain, Object newContext) {
+ SecurityContext context = SecurityActions.getSecurityContext();
+ if (context == null || (!context.getSecurityDomain().equals(securityDomain) && newContext != null)) {
+ SecurityActions.setSecurityContext((SecurityContext)newContext);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void clearSecurityContext(String securityDomain) {
+ SecurityContext sc = SecurityActions.getSecurityContext();
+ if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
+ SecurityActions.clearSecurityContext();
+ }
+ }
+
+ @Override
+ public Object getSecurityContext(String securityDomain) {
+ SecurityContext sc = SecurityActions.getSecurityContext();
+ if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
+ return sc;
+ }
+ return null;
+ }
+
+ @Override
+ public Object createSecurityContext(String securityDomain, Principal p, Object credentials, Subject subject) {
+ SecurityActions.pushSecurityContext(p, credentials, subject, securityDomain);
+ return getSecurityContext(securityDomain);
+ }
+
+}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.jboss;
-
-import java.security.AccessController;
-import java.security.Principal;
-import java.security.PrivilegedAction;
-
-import javax.security.auth.Subject;
-
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityContextAssociation;
-import org.jboss.security.SecurityContextFactory;
-
-class SecurityActions {
- static void setSecurityContext(final SecurityContext sc)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- SecurityContextAssociation.setSecurityContext(sc);
- return null;
- }
- });
- }
-
- static SecurityContext getSecurityContext()
- {
- return AccessController.doPrivileged(new PrivilegedAction<SecurityContext>()
- {
- public SecurityContext run()
- {
- return SecurityContextAssociation.getSecurityContext();
- }
- });
- }
-
- static SecurityContext clearSecurityContext()
- {
- return AccessController.doPrivileged(new PrivilegedAction<SecurityContext>()
- {
- public SecurityContext run()
- {
- SecurityContextAssociation.clearSecurityContext();
- return null;
- }
- });
- }
-
- static void pushSecurityContext(final Principal p, final Object cred, final Subject subject, final String securityDomain)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- SecurityContext sc;
- try {
- sc = SecurityContextFactory.createSecurityContext(p, cred, subject, securityDomain);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- setSecurityContext(sc);
- return null;
- }
- });
- }
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/SecurityActions.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,85 @@
+/*
+ * 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.jboss;
+
+import java.security.AccessController;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+
+import javax.security.auth.Subject;
+
+import org.jboss.security.SecurityContext;
+import org.jboss.security.SecurityContextAssociation;
+import org.jboss.security.SecurityContextFactory;
+
+class SecurityActions {
+ static void setSecurityContext(final SecurityContext sc)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ SecurityContextAssociation.setSecurityContext(sc);
+ return null;
+ }
+ });
+ }
+
+ static SecurityContext getSecurityContext()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<SecurityContext>()
+ {
+ public SecurityContext run()
+ {
+ return SecurityContextAssociation.getSecurityContext();
+ }
+ });
+ }
+
+ static SecurityContext clearSecurityContext()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<SecurityContext>()
+ {
+ public SecurityContext run()
+ {
+ SecurityContextAssociation.clearSecurityContext();
+ return null;
+ }
+ });
+ }
+
+ static void pushSecurityContext(final Principal p, final Object cred, final Subject subject, final String securityDomain)
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ SecurityContext sc;
+ try {
+ sc = SecurityContextFactory.createSecurityContext(p, cred, subject, securityDomain);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ setSecurityContext(sc);
+ return null;
+ }
+ });
+ }
+}
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers)
Deleted: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,139 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.jboss.deployers;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.managed.api.factory.ManagedObjectFactory;
-import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
-import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
-import org.teiid.SecurityHelper;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-
-public class ConnectorBindingDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> implements ManagedObjectCreator {
- protected Logger log = Logger.getLogger(getClass());
- private ManagedObjectFactory mof;
- private SecurityHelper securityHelper;
-
- private ConnectorManagerRepository connectorManagerRepository;
-
- public ConnectorBindingDeployer() {
- super(ManagedConnectionFactoryDeploymentGroup.class);
- setRelativeOrder(3000);
- }
-
- @Override
- public void deploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) throws DeploymentException {
- List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
-
- ConnectorManagerGroup cmGroup = new ConnectorManagerGroup();
-
- for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
- String connectorDefinition = data.getConnectionDefinition();
- if (connectorDefinition.equals("org.teiid.connector.api.Connector")) {
- String connectorName = data.getJndiName();
-
- ConnectorManager cm = null;
- try {
- cm = createConnectorManger("java:"+connectorName, data.getMaxSize());
- cm.start();
- cmGroup.addConnectorManager(cm);
- } catch (ConnectorException e) {
- throw new DeploymentException(e);
- }
-
- // Add the references to the mgr as loaded.
- this.connectorManagerRepository.addConnectorManager("java:"+connectorName, cm);
-
- log.info("Teiid Connector Started = " + connectorName); //$NON-NLS-1$
- }
- }
-
- if (!cmGroup.getConnectorManagers().isEmpty()) {
- unit.addAttachment(ConnectorManagerGroup.class, cmGroup);
- }
- }
-
-
- ConnectorManager createConnectorManger(String deployedConnectorName, int maxThreads) {
- ConnectorManager mgr = new ConnectorManager(deployedConnectorName, maxThreads, securityHelper);
- return mgr;
- }
-
- public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
- this.connectorManagerRepository = repo;
- }
-
- @Override
- public void undeploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) {
- super.undeploy(unit, group);
- List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
-
- for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
- String connectorDefinition = data.getConnectionDefinition();
- if (connectorDefinition.equals("org.teiid.connector.api.Connector")) {
- String connectorName = data.getJndiName();
- if (this.connectorManagerRepository != null) {
- ConnectorManager cm = this.connectorManagerRepository.removeConnectorManager("java:"+connectorName);
- if (cm != null) {
- cm.stop();
- }
- }
- log.info("Teiid Connector Stopped = " + connectorName); //$NON-NLS-1$
- }
- }
- }
-
- @Override
- public void build(DeploymentUnit unit, Set<String> attachmentNames, Map<String, ManagedObject> managedObjects)
- throws DeploymentException {
-
- ConnectorManagerGroup cmGroup = unit.removeAttachment(ConnectorManagerGroup.class);
- if (cmGroup != null) {
- for (ConnectorManager mgr:cmGroup.getConnectorManagers()) {
- ManagedObject mo = this.mof.initManagedObject(mgr, ConnectorManager.class, mgr.getName(), mgr.getName());
- if (mo == null) {
- throw new DeploymentException("could not create managed object");
- }
- managedObjects.put(mo.getName(), mo);
- }
- }
- }
-
- public void setManagedObjectFactory(ManagedObjectFactory mof) {
- this.mof = mof;
- }
-
- public void setSecurityHelper(SecurityHelper securityHelper) {
- this.securityHelper = securityHelper;
- }
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -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.jboss.deployers;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.spi.deployer.managed.ManagedObjectCreator;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.teiid.SecurityHelper;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+
+public class ConnectorBindingDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> implements ManagedObjectCreator {
+ protected Logger log = Logger.getLogger(getClass());
+ private ManagedObjectFactory mof;
+ private SecurityHelper securityHelper;
+
+ private ConnectorManagerRepository connectorManagerRepository;
+
+ public ConnectorBindingDeployer() {
+ super(ManagedConnectionFactoryDeploymentGroup.class);
+ setRelativeOrder(3000);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) throws DeploymentException {
+ List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+
+ ConnectorManagerGroup cmGroup = new ConnectorManagerGroup();
+
+ for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
+ String connectorDefinition = data.getConnectionDefinition();
+ if (connectorDefinition.equals("org.teiid.connector.api.Connector")) {
+ String connectorName = data.getJndiName();
+
+ ConnectorManager cm = null;
+ try {
+ cm = createConnectorManger("java:"+connectorName, data.getMaxSize());
+ cm.start();
+ cmGroup.addConnectorManager(cm);
+ } catch (ConnectorException e) {
+ throw new DeploymentException(e);
+ }
+
+ // Add the references to the mgr as loaded.
+ this.connectorManagerRepository.addConnectorManager("java:"+connectorName, cm);
+
+ log.info("Teiid Connector Started = " + connectorName); //$NON-NLS-1$
+ }
+ }
+
+ if (!cmGroup.getConnectorManagers().isEmpty()) {
+ unit.addAttachment(ConnectorManagerGroup.class, cmGroup);
+ }
+ }
+
+
+ ConnectorManager createConnectorManger(String deployedConnectorName, int maxThreads) {
+ ConnectorManager mgr = new ConnectorManager(deployedConnectorName, maxThreads, securityHelper);
+ return mgr;
+ }
+
+ public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
+ this.connectorManagerRepository = repo;
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) {
+ super.undeploy(unit, group);
+ List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+
+ for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
+ String connectorDefinition = data.getConnectionDefinition();
+ if (connectorDefinition.equals("org.teiid.connector.api.Connector")) {
+ String connectorName = data.getJndiName();
+ if (this.connectorManagerRepository != null) {
+ ConnectorManager cm = this.connectorManagerRepository.removeConnectorManager("java:"+connectorName);
+ if (cm != null) {
+ cm.stop();
+ }
+ }
+ log.info("Teiid Connector Stopped = " + connectorName); //$NON-NLS-1$
+ }
+ }
+ }
+
+ @Override
+ public void build(DeploymentUnit unit, Set<String> attachmentNames, Map<String, ManagedObject> managedObjects)
+ throws DeploymentException {
+
+ ConnectorManagerGroup cmGroup = unit.removeAttachment(ConnectorManagerGroup.class);
+ if (cmGroup != null) {
+ for (ConnectorManager mgr:cmGroup.getConnectorManagers()) {
+ ManagedObject mo = this.mof.initManagedObject(mgr, ConnectorManager.class, mgr.getName(), mgr.getName());
+ if (mo == null) {
+ throw new DeploymentException("could not create managed object");
+ }
+ managedObjects.put(mo.getName(), mo);
+ }
+ }
+ }
+
+ public void setManagedObjectFactory(ManagedObjectFactory mof) {
+ this.mof = mof;
+ }
+
+ public void setSecurityHelper(SecurityHelper securityHelper) {
+ this.securityHelper = securityHelper;
+ }
+}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.jboss.deployers;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-
-public class ConnectorManagerGroup {
- private List<ConnectorManager> mgrs = new ArrayList<ConnectorManager>();
-
- public void addConnectorManager(ConnectorManager cm) {
- this.mgrs.add(cm);
- }
-
- public List<ConnectorManager> getConnectorManagers(){
- return this.mgrs;
- }
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,40 @@
+/*
+ * 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.jboss.deployers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+
+public class ConnectorManagerGroup {
+ private List<ConnectorManager> mgrs = new ArrayList<ConnectorManager>();
+
+ public void addConnectorManager(ConnectorManager cm) {
+ this.mgrs.add(cm);
+ }
+
+ public List<ConnectorManager> getConnectorManagers(){
+ return this.mgrs;
+ }
+}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,350 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.jboss.deployers;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
-import javax.resource.spi.XATerminator;
-import javax.resource.spi.work.WorkManager;
-
-import org.jboss.logging.Logger;
-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.managed.api.annotation.ManagementProperty;
-import org.jboss.managed.api.annotation.ViewUse;
-import org.teiid.SecurityHelper;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.impl.RequestMetadata;
-import org.teiid.adminapi.impl.SessionMetadata;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-import org.teiid.adminapi.jboss.AdminProvider;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.process.DQPConfiguration;
-import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
-import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-import org.teiid.dqp.internal.transaction.XidFactory;
-import org.teiid.transport.ClientServiceRegistry;
-import org.teiid.transport.ClientServiceRegistryImpl;
-import org.teiid.transport.LogonImpl;
-import org.teiid.transport.SocketConfiguration;
-import org.teiid.transport.SocketTransport;
-
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.security.SessionServiceException;
-import com.metamatrix.client.ExceptionUtil;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.client.ClientSideDQP;
-import com.metamatrix.dqp.client.DQPManagement;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.jdbc.LogConfigurationProvider;
-import com.metamatrix.jdbc.LogListernerProvider;
-import com.metamatrix.platform.security.api.ILogon;
-import com.metamatrix.platform.security.api.SessionToken;
-import com.metamatrix.platform.security.api.service.SessionService;
-
- at ManagementObject(isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
-public class RuntimeEngineDeployer extends DQPConfiguration implements DQPManagement, Serializable , ClientServiceRegistry {
-
- protected Logger log = Logger.getLogger(getClass());
-
- private transient SocketConfiguration jdbcSocketConfiguration;
- private transient SocketConfiguration adminSocketConfiguration;
- private transient SocketTransport jdbcSocket;
- private transient SocketTransport adminSocket;
- private transient SecurityHelper securityHelper;
-
- private transient DQPCore dqpCore = new DQPCore();
- private transient ILogon logon;
- private transient Admin admin;
- private transient ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl();
-
- public RuntimeEngineDeployer() {
- // TODO: this does not belong here
- LogManager.setLogConfiguration(new LogConfigurationProvider().get());
- LogManager.setLogListener(new LogListernerProvider().get());
- }
-
-
- @Override
- public <T> T getClientService(Class<T> iface)
- throws ComponentNotFoundException {
- return this.csr.getClientService(iface);
- }
-
- public void start() {
-
- // create the necessary services
- createClientServices();
-
- this.csr.registerClientService(ILogon.class, proxyService(ILogon.class, logon), com.metamatrix.common.util.LogConstants.CTX_SERVER);
- this.csr.registerClientService(ClientSideDQP.class, proxyService(ClientSideDQP.class, this.dqpCore), LogConstants.CTX_QUERY_SERVICE);
- this.csr.registerClientService(Admin.class, proxyService(Admin.class, admin), LogConstants.CTX_ADMIN_API);
-
- if (this.jdbcSocketConfiguration.isEnabled()) {
- this.jdbcSocket = new SocketTransport(this.jdbcSocketConfiguration, csr);
- this.jdbcSocket.start();
- log.info("Teiid JDBC = " + (this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+this.jdbcSocketConfiguration.getPortNumber()); //$NON-NLS-1$
- } else {
- log.debug(DQPEmbeddedPlugin.Util.getString("SocketTransport.3")); //$NON-NLS-1$
- }
-
- if (this.adminSocketConfiguration.isEnabled()) {
- this.adminSocket = new SocketTransport(this.adminSocketConfiguration, csr);
- this.adminSocket.start();
- log.info("Teiid Admin = " + (this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber()); //$NON-NLS-1$
- } else {
- log.debug(DQPEmbeddedPlugin.Util.getString("SocketTransport.3")); //$NON-NLS-1$
- }
- log.info("Teiid Engine Started = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
- }
-
- public void stop() {
-
- try {
- this.dqpCore.stop();
- } catch(MetaMatrixRuntimeException e) {
- // this bean is already shutdown
- }
-
- // Stop socket transport(s)
- if (this.jdbcSocket != null) {
- this.jdbcSocket.stop();
- this.jdbcSocket = null;
- }
-
- if (this.adminSocket != null) {
- this.adminSocket.stop();
- this.adminSocket = null;
- }
-
- log.info("Teiid Engine Stopped = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
- }
-
- private void createClientServices() {
-
- this.dqpCore.start(this);
-
- this.logon = new LogonImpl(this.dqpCore.getSessionService(), "teiid-cluster"); //$NON-NLS-1$
- try {
- this.admin = AdminProvider.getLocal();
- } catch (AdminComponentException e) {
- throw new MetaMatrixRuntimeException(e.getCause());
- }
- }
-
- private TransactionService getTransactionService(String processName, XATerminator terminator) {
- TransactionServerImpl txnService = new TransactionServerImpl();
- txnService.setTransactionProvider(new ContainerTransactionProvider(terminator));
- txnService.setProcessName(processName);
- txnService.setXidFactory(new XidFactory());
- return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
- }
-
- private <T> T proxyService(final Class<T> iface, final T instance) {
-
- return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {
-
- public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
-
- Throwable exception = null;
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- try {
- if (!(iface.equals(ILogon.class))) {
- logon.assertIdentity(SessionToken.getSession());
- assosiateSecurityContext();
- }
-
- return arg1.invoke(instance, arg2);
- } catch (InvocationTargetException e) {
- exception = e.getTargetException();
- } catch(Throwable t){
- exception = t;
- } finally {
- clearSecurityContext();
- DQPWorkContext.releaseWorkContext();
- Thread.currentThread().setContextClassLoader(current);
- }
- throw ExceptionUtil.convertException(arg1, exception);
- }
- }));
- }
-
- private boolean assosiateSecurityContext() {
- DQPWorkContext context = DQPWorkContext.getWorkContext();
- if (context.getSubject() != null) {
- return securityHelper.assosiateSecurityContext(context.getSecurityDomain(), context.getSecurityContext());
- }
- return false;
- }
-
- private void clearSecurityContext() {
- DQPWorkContext context = DQPWorkContext.getWorkContext();
- if (context.getSubject() != null) {
- securityHelper.clearSecurityContext(context.getSecurityDomain());
- }
- }
-
- public void setJdbcSocketConfiguration(SocketConfiguration socketConfig) {
- this.jdbcSocketConfiguration = socketConfig;
- }
-
- public void setAdminSocketConfiguration(SocketConfiguration socketConfig) {
- this.adminSocketConfiguration = socketConfig;
- }
-
- public void setXATerminator(XATerminator xaTerminator){
- this.dqpCore.setTransactionService(getTransactionService("localhost", xaTerminator));
- }
-
- public void setWorkManager(WorkManager mgr) {
- this.dqpCore.setWorkManager(mgr);
- }
-
- public void setAuthorizationService(AuthorizationService service) {
- this.dqpCore.setAuthorizationService(service);
- }
-
- public void setSessionService(SessionService service) {
- this.dqpCore.setSessionService(service);
- }
-
- public void setBufferService(BufferService service) {
- this.dqpCore.setBufferService(service);
- }
-
- public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
- this.dqpCore.setConnectorManagerRepository(repo);
- }
-
- public void setSecurityHelper(SecurityHelper helper) {
- this.securityHelper = helper;
- this.dqpCore.setSecurityHelper(helper);
- }
-
- @Override
- @ManagementOperation(description="Requests for perticular session", impact=Impact.ReadOnly,params={@ManagementParameter(name="sessionId",description="The session Identifier")})
- public List<RequestMetadata> getRequestsForSession(long sessionId) {
- return this.dqpCore.getRequestsForSession(sessionId);
- }
-
- @Override
- @ManagementOperation(description="Active requests", impact=Impact.ReadOnly)
- public List<RequestMetadata> getRequests() {
- return this.dqpCore.getRequests();
- }
-
- @Override
- @ManagementOperation(description="Get Runtime workmanager statistics", impact=Impact.ReadOnly,params={@ManagementParameter(name="identifier",description="Use \"runtime\" for engine, or connector name for connector")})
- public WorkerPoolStatisticsMetadata getWorkManagerStatistics(String identifier) {
- if ("runtime".equalsIgnoreCase(identifier)) {
- return this.dqpCore.getWorkManagerStatistics();
- }
- ConnectorManager cm = this.dqpCore.getConnectorManagerRepository().getConnectorManager(identifier);
- if (cm != null) {
- return cm.getWorkManagerStatistics();
- }
- return null;
- }
-
- @Override
- @ManagementOperation(description="Terminate a Session",params={@ManagementParameter(name="terminateeId",description="The session to be terminated")})
- public void terminateSession(long terminateeId) {
- this.dqpCore.getSessionService().terminateSession(terminateeId, SessionToken.getSession().getSessionID());
- }
-
- @Override
- @ManagementOperation(description="Cancel a Request",params={@ManagementParameter(name="sessionId",description="The session Identifier"), @ManagementParameter(name="requestId",description="The request Identifier")})
- public boolean cancelRequest(long sessionId, long requestId) throws AdminException {
- try {
- return this.dqpCore.cancelRequest(sessionId, requestId);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- @ManagementOperation(description="Get Cache types in the system", impact=Impact.ReadOnly)
- public Collection<String> getCacheTypes(){
- return this.dqpCore.getCacheTypes();
- }
-
- @Override
- @ManagementOperation(description="Clear the caches in the system", impact=Impact.ReadOnly)
- public void clearCache(String cacheType) {
- this.dqpCore.clearCache(cacheType);
- }
-
- @Override
- @ManagementOperation(description="Active sessions", impact=Impact.ReadOnly)
- public Collection<SessionMetadata> getActiveSessions() throws AdminException {
- try {
- return this.dqpCore.getActiveSessions();
- } catch (SessionServiceException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- @ManagementProperty(description="Active session count", use={ViewUse.STATISTIC}, readOnly=true)
- public int getActiveSessionsCount() throws AdminException{
- try {
- return this.dqpCore.getActiveSessionsCount();
- } catch (SessionServiceException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- @ManagementOperation(description="Active Transactions", impact=Impact.ReadOnly)
- public Collection<org.teiid.adminapi.Transaction> getTransactions() {
- return this.dqpCore.getTransactions();
- }
-
- @Override
- @ManagementOperation(description="Clear the caches in the system", impact=Impact.ReadOnly)
- public void terminateTransaction(String xid) throws AdminException {
- this.dqpCore.terminateTransaction(xid);
- }
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,350 @@
+/*
+ * 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.jboss.deployers;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.WorkManager;
+
+import org.jboss.logging.Logger;
+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.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.teiid.SecurityHelper;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.impl.RequestMetadata;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.adminapi.jboss.AdminProvider;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.process.DQPConfiguration;
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
+import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+import org.teiid.dqp.internal.transaction.XidFactory;
+import org.teiid.transport.ClientServiceRegistry;
+import org.teiid.transport.ClientServiceRegistryImpl;
+import org.teiid.transport.LogonImpl;
+import org.teiid.transport.SocketConfiguration;
+import org.teiid.transport.SocketTransport;
+
+import com.metamatrix.api.exception.ComponentNotFoundException;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.security.SessionServiceException;
+import com.metamatrix.client.ExceptionUtil;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQPManagement;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.service.AuthorizationService;
+import com.metamatrix.dqp.service.BufferService;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.jdbc.LogConfigurationProvider;
+import com.metamatrix.jdbc.LogListernerProvider;
+import com.metamatrix.platform.security.api.ILogon;
+import com.metamatrix.platform.security.api.SessionToken;
+import com.metamatrix.platform.security.api.service.SessionService;
+
+ at ManagementObject(isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
+public class RuntimeEngineDeployer extends DQPConfiguration implements DQPManagement, Serializable , ClientServiceRegistry {
+
+ protected Logger log = Logger.getLogger(getClass());
+
+ private transient SocketConfiguration jdbcSocketConfiguration;
+ private transient SocketConfiguration adminSocketConfiguration;
+ private transient SocketTransport jdbcSocket;
+ private transient SocketTransport adminSocket;
+ private transient SecurityHelper securityHelper;
+
+ private transient DQPCore dqpCore = new DQPCore();
+ private transient ILogon logon;
+ private transient Admin admin;
+ private transient ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl();
+
+ public RuntimeEngineDeployer() {
+ // TODO: this does not belong here
+ LogManager.setLogConfiguration(new LogConfigurationProvider().get());
+ LogManager.setLogListener(new LogListernerProvider().get());
+ }
+
+
+ @Override
+ public <T> T getClientService(Class<T> iface)
+ throws ComponentNotFoundException {
+ return this.csr.getClientService(iface);
+ }
+
+ public void start() {
+
+ // create the necessary services
+ createClientServices();
+
+ this.csr.registerClientService(ILogon.class, proxyService(ILogon.class, logon), com.metamatrix.common.util.LogConstants.CTX_SERVER);
+ this.csr.registerClientService(ClientSideDQP.class, proxyService(ClientSideDQP.class, this.dqpCore), LogConstants.CTX_QUERY_SERVICE);
+ this.csr.registerClientService(Admin.class, proxyService(Admin.class, admin), LogConstants.CTX_ADMIN_API);
+
+ if (this.jdbcSocketConfiguration.isEnabled()) {
+ this.jdbcSocket = new SocketTransport(this.jdbcSocketConfiguration, csr);
+ this.jdbcSocket.start();
+ log.info("Teiid JDBC = " + (this.jdbcSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.jdbcSocketConfiguration.getHostAddress().getHostName()+":"+this.jdbcSocketConfiguration.getPortNumber()); //$NON-NLS-1$
+ } else {
+ log.debug(DQPEmbeddedPlugin.Util.getString("SocketTransport.3")); //$NON-NLS-1$
+ }
+
+ if (this.adminSocketConfiguration.isEnabled()) {
+ this.adminSocket = new SocketTransport(this.adminSocketConfiguration, csr);
+ this.adminSocket.start();
+ log.info("Teiid Admin = " + (this.adminSocketConfiguration.getSSLConfiguration().isSslEnabled()?"mms://":"mm://")+this.adminSocketConfiguration.getHostAddress().getHostName()+":"+this.adminSocketConfiguration.getPortNumber()); //$NON-NLS-1$
+ } else {
+ log.debug(DQPEmbeddedPlugin.Util.getString("SocketTransport.3")); //$NON-NLS-1$
+ }
+ log.info("Teiid Engine Started = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
+ }
+
+ public void stop() {
+
+ try {
+ this.dqpCore.stop();
+ } catch(MetaMatrixRuntimeException e) {
+ // this bean is already shutdown
+ }
+
+ // Stop socket transport(s)
+ if (this.jdbcSocket != null) {
+ this.jdbcSocket.stop();
+ this.jdbcSocket = null;
+ }
+
+ if (this.adminSocket != null) {
+ this.adminSocket.stop();
+ this.adminSocket = null;
+ }
+
+ log.info("Teiid Engine Stopped = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
+ }
+
+ private void createClientServices() {
+
+ this.dqpCore.start(this);
+
+ this.logon = new LogonImpl(this.dqpCore.getSessionService(), "teiid-cluster"); //$NON-NLS-1$
+ try {
+ this.admin = AdminProvider.getLocal();
+ } catch (AdminComponentException e) {
+ throw new MetaMatrixRuntimeException(e.getCause());
+ }
+ }
+
+ private TransactionService getTransactionService(String processName, XATerminator terminator) {
+ TransactionServerImpl txnService = new TransactionServerImpl();
+ txnService.setTransactionProvider(new ContainerTransactionProvider(terminator));
+ txnService.setProcessName(processName);
+ txnService.setXidFactory(new XidFactory());
+ return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
+ }
+
+ private <T> T proxyService(final Class<T> iface, final T instance) {
+
+ return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {
+
+ public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
+
+ Throwable exception = null;
+ ClassLoader current = Thread.currentThread().getContextClassLoader();
+ try {
+ if (!(iface.equals(ILogon.class))) {
+ logon.assertIdentity(SessionToken.getSession());
+ assosiateSecurityContext();
+ }
+
+ return arg1.invoke(instance, arg2);
+ } catch (InvocationTargetException e) {
+ exception = e.getTargetException();
+ } catch(Throwable t){
+ exception = t;
+ } finally {
+ clearSecurityContext();
+ DQPWorkContext.releaseWorkContext();
+ Thread.currentThread().setContextClassLoader(current);
+ }
+ throw ExceptionUtil.convertException(arg1, exception);
+ }
+ }));
+ }
+
+ private boolean assosiateSecurityContext() {
+ DQPWorkContext context = DQPWorkContext.getWorkContext();
+ if (context.getSubject() != null) {
+ return securityHelper.assosiateSecurityContext(context.getSecurityDomain(), context.getSecurityContext());
+ }
+ return false;
+ }
+
+ private void clearSecurityContext() {
+ DQPWorkContext context = DQPWorkContext.getWorkContext();
+ if (context.getSubject() != null) {
+ securityHelper.clearSecurityContext(context.getSecurityDomain());
+ }
+ }
+
+ public void setJdbcSocketConfiguration(SocketConfiguration socketConfig) {
+ this.jdbcSocketConfiguration = socketConfig;
+ }
+
+ public void setAdminSocketConfiguration(SocketConfiguration socketConfig) {
+ this.adminSocketConfiguration = socketConfig;
+ }
+
+ public void setXATerminator(XATerminator xaTerminator){
+ this.dqpCore.setTransactionService(getTransactionService("localhost", xaTerminator));
+ }
+
+ public void setWorkManager(WorkManager mgr) {
+ this.dqpCore.setWorkManager(mgr);
+ }
+
+ public void setAuthorizationService(AuthorizationService service) {
+ this.dqpCore.setAuthorizationService(service);
+ }
+
+ public void setSessionService(SessionService service) {
+ this.dqpCore.setSessionService(service);
+ }
+
+ public void setBufferService(BufferService service) {
+ this.dqpCore.setBufferService(service);
+ }
+
+ public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
+ this.dqpCore.setConnectorManagerRepository(repo);
+ }
+
+ public void setSecurityHelper(SecurityHelper helper) {
+ this.securityHelper = helper;
+ this.dqpCore.setSecurityHelper(helper);
+ }
+
+ @Override
+ @ManagementOperation(description="Requests for perticular session", impact=Impact.ReadOnly,params={@ManagementParameter(name="sessionId",description="The session Identifier")})
+ public List<RequestMetadata> getRequestsForSession(long sessionId) {
+ return this.dqpCore.getRequestsForSession(sessionId);
+ }
+
+ @Override
+ @ManagementOperation(description="Active requests", impact=Impact.ReadOnly)
+ public List<RequestMetadata> getRequests() {
+ return this.dqpCore.getRequests();
+ }
+
+ @Override
+ @ManagementOperation(description="Get Runtime workmanager statistics", impact=Impact.ReadOnly,params={@ManagementParameter(name="identifier",description="Use \"runtime\" for engine, or connector name for connector")})
+ public WorkerPoolStatisticsMetadata getWorkManagerStatistics(String identifier) {
+ if ("runtime".equalsIgnoreCase(identifier)) {
+ return this.dqpCore.getWorkManagerStatistics();
+ }
+ ConnectorManager cm = this.dqpCore.getConnectorManagerRepository().getConnectorManager(identifier);
+ if (cm != null) {
+ return cm.getWorkManagerStatistics();
+ }
+ return null;
+ }
+
+ @Override
+ @ManagementOperation(description="Terminate a Session",params={@ManagementParameter(name="terminateeId",description="The session to be terminated")})
+ public void terminateSession(long terminateeId) {
+ this.dqpCore.getSessionService().terminateSession(terminateeId, SessionToken.getSession().getSessionID());
+ }
+
+ @Override
+ @ManagementOperation(description="Cancel a Request",params={@ManagementParameter(name="sessionId",description="The session Identifier"), @ManagementParameter(name="requestId",description="The request Identifier")})
+ public boolean cancelRequest(long sessionId, long requestId) throws AdminException {
+ try {
+ return this.dqpCore.cancelRequest(sessionId, requestId);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ @ManagementOperation(description="Get Cache types in the system", impact=Impact.ReadOnly)
+ public Collection<String> getCacheTypes(){
+ return this.dqpCore.getCacheTypes();
+ }
+
+ @Override
+ @ManagementOperation(description="Clear the caches in the system", impact=Impact.ReadOnly)
+ public void clearCache(String cacheType) {
+ this.dqpCore.clearCache(cacheType);
+ }
+
+ @Override
+ @ManagementOperation(description="Active sessions", impact=Impact.ReadOnly)
+ public Collection<SessionMetadata> getActiveSessions() throws AdminException {
+ try {
+ return this.dqpCore.getActiveSessions();
+ } catch (SessionServiceException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ @ManagementProperty(description="Active session count", use={ViewUse.STATISTIC}, readOnly=true)
+ public int getActiveSessionsCount() throws AdminException{
+ try {
+ return this.dqpCore.getActiveSessionsCount();
+ } catch (SessionServiceException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ @ManagementOperation(description="Active Transactions", impact=Impact.ReadOnly)
+ public Collection<org.teiid.adminapi.Transaction> getTransactions() {
+ return this.dqpCore.getTransactions();
+ }
+
+ @Override
+ @ManagementOperation(description="Clear the caches in the system", impact=Impact.ReadOnly)
+ public void terminateTransaction(String xid) throws AdminException {
+ this.dqpCore.terminateTransaction(xid);
+ }
+}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.jboss.deployers;
-
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
-import org.jboss.system.server.profileservice.persistence.component.AbstractComponentMapper;
-import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
-import org.teiid.adminapi.impl.VDBMetaData;
-
-public class VDBMetadataComponentMapper extends AbstractComponentMapper {
-
- public VDBMetadataComponentMapper(PersistenceFactory persistenceFactory) {
- super(persistenceFactory);
- }
-
- @Override
- protected ManagedObject getComponent(Object attachment, PersistedComponent component, boolean create) {
- VDBMetaData metadata = (VDBMetaData)attachment;
- String vdbName = metadata.getName()+"_"+metadata.getVersion();
- if (vdbName.equals(component.getOriginalName())) {
- return getMOF().initManagedObject(metadata, VDBMetaData.class, vdbName, vdbName);
- }
- throw new IllegalStateException("could not find deployment " + component.getOriginalName());
- }
-
- @Override
- protected void removeComponent(Object attachment,PersistedComponent component) {
- //TODO: What needs to be done here?
- }
-
- @Override
- protected void setComponentName(PersistedComponent component, ManagedObject mo) {
- VDBMetaData metadata = (VDBMetaData)mo.getAttachment();
- component.setName(metadata.getName()+"_"+metadata.getVersion());
- }
-
- @Override
- public String getType() {
- return VDBMetaData.class.getName();
- }
-
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/VDBMetadataComponentMapper.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,62 @@
+/*
+ * 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.jboss.deployers;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.system.server.profileservice.persistence.PersistenceFactory;
+import org.jboss.system.server.profileservice.persistence.component.AbstractComponentMapper;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedComponent;
+import org.teiid.adminapi.impl.VDBMetaData;
+
+public class VDBMetadataComponentMapper extends AbstractComponentMapper {
+
+ public VDBMetadataComponentMapper(PersistenceFactory persistenceFactory) {
+ super(persistenceFactory);
+ }
+
+ @Override
+ protected ManagedObject getComponent(Object attachment, PersistedComponent component, boolean create) {
+ VDBMetaData metadata = (VDBMetaData)attachment;
+ String vdbName = metadata.getName()+"_"+metadata.getVersion();
+ if (vdbName.equals(component.getOriginalName())) {
+ return getMOF().initManagedObject(metadata, VDBMetaData.class, vdbName, vdbName);
+ }
+ throw new IllegalStateException("could not find deployment " + component.getOriginalName());
+ }
+
+ @Override
+ protected void removeComponent(Object attachment,PersistedComponent component) {
+ //TODO: What needs to be done here?
+ }
+
+ @Override
+ protected void setComponentName(PersistedComponent component, ManagedObject mo) {
+ VDBMetaData metadata = (VDBMetaData)mo.getAttachment();
+ component.setName(metadata.getName()+"_"+metadata.getVersion());
+ }
+
+ @Override
+ public String getType() {
+ return VDBMetaData.class.getName();
+ }
+
+}
Copied: trunk/jboss-integration/src/main/java/org/teiid/templates (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/templates)
Copied: trunk/jboss-integration/src/main/java/org/teiid/templates/connector (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector)
Deleted: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,146 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.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. Here the idea is "targetTemplate" is the actual template we store
- * the information under, which is the "connection factory" that container generates. However, we have got data
- * passed under Teiid owned template. Now this classe'ss JOB is to transfer the properties from the source template
- * into target template and write the target template.
- *
- * When the properties are written to target template, and source has a new property that is not defined in target, that
- * property will be written as "config-property"
- */
-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 sourceInfo) throws Exception {
- try {
-
- ManagedProperty rar = sourceInfo.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 = this.targetTemplate.getInfo();
-
- // override these properties always.
- targetInfo.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:sourceInfo.getProperties().keySet()) {
- ManagedProperty mp = propertyMap.get(key);
-
- if (mp != null) {
- // property found in target, so just add as value
- MetaValue value = sourceInfo.getProperties().get(key).getValue();
- if (ManagedUtil.sameValue(mp.getDefaultValue(), value)) {
- continue;
- }
-
- if (value != null) {
- mp.setValue(value);
- }
- }
- else {
- // property not found in the target; add as "config-property"
- mp = sourceInfo.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 this.targetTemplate.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 rarName != null;
- }
-
- @Override
- public DeploymentTemplateInfo getInfo() {
- return info;
- }
-
- public void setInfo(DeploymentTemplateInfo info) {
- this.info = info;
- }
-
- public void setTargetTemplate(DeploymentTemplate target) {
- this.targetTemplate = target;
- }
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,146 @@
+/*
+ * 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. Here the idea is "targetTemplate" is the actual template we store
+ * the information under, which is the "connection factory" that container generates. However, we have got data
+ * passed under Teiid owned template. Now this classe'ss JOB is to transfer the properties from the source template
+ * into target template and write the target template.
+ *
+ * When the properties are written to target template, and source has a new property that is not defined in target, that
+ * property will be written as "config-property"
+ */
+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 sourceInfo) throws Exception {
+ try {
+
+ ManagedProperty rar = sourceInfo.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 = this.targetTemplate.getInfo();
+
+ // override these properties always.
+ targetInfo.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:sourceInfo.getProperties().keySet()) {
+ ManagedProperty mp = propertyMap.get(key);
+
+ if (mp != null) {
+ // property found in target, so just add as value
+ MetaValue value = sourceInfo.getProperties().get(key).getValue();
+ if (ManagedUtil.sameValue(mp.getDefaultValue(), value)) {
+ continue;
+ }
+
+ if (value != null) {
+ mp.setValue(value);
+ }
+ }
+ else {
+ // property not found in the target; add as "config-property"
+ mp = sourceInfo.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 this.targetTemplate.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 rarName != null;
+ }
+
+ @Override
+ public DeploymentTemplateInfo getInfo() {
+ return info;
+ }
+
+ public void setInfo(DeploymentTemplateInfo info) {
+ this.info = info;
+ }
+
+ public void setTargetTemplate(DeploymentTemplate target) {
+ this.targetTemplate = target;
+ }
+}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.templates.connector;
-
-import java.util.Collection;
-import java.util.HashSet;
-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.metatype.api.values.MetaValue;
-import org.jboss.resource.metadata.ConfigPropertyMetaData;
-import org.jboss.resource.metadata.ConnectionDefinitionMetaData;
-import org.jboss.resource.metadata.ConnectorMetaData;
-import org.jboss.resource.metadata.DescriptionMetaData;
-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='"+getName()+".rar'");
- 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);
- }
- } catch (MalformedObjectNameException e) {
- //ignore
- } catch (AttributeNotFoundException e) {
- //ignore
- } catch (InstanceNotFoundException e) {
- //ignore
- } catch (MBeanException e) {
- //ignore
- } catch (ReflectionException e) {
- //ignore
- }
- }
-
- private void addConnectorProperty(ConfigPropertyMetaData metadata) {
- SimpleMetaType metaType = SimpleMetaType.resolve(metadata.getType());
-
- DefaultFieldsImpl fields = new DefaultFieldsImpl(metadata.getName());
- DescriptionMetaData descMetadata = metadata.getDescription();
- String description = descMetadata.getDescription();
- if (description != null) {
- ExtendedPropertyMetadata extended = new ExtendedPropertyMetadata(description);
- if (extended.getDescription() != null) {
- fields.setDescription(description);
- }
-
- if (extended.getDisplayName() != null) {
- fields.setField(Fields.MAPPED_NAME, extended.getDisplayName());
- }
-
- if (extended.getAllowed() != null) {
- HashSet<MetaValue> values = new HashSet<MetaValue>();
- for (String value:extended.getAllowed()) {
- values.add(ManagedUtil.wrap(SimpleMetaType.STRING, value));
- }
- fields.setField(Fields.LEGAL_VALUES, values);
- }
- fields.setField(Fields.MANDATORY, ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isRequired())));
- fields.setField(Fields.READ_ONLY, ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(!extended.isEditable())));
- fields.setField("advanced", ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isAdvanced())));
- fields.setField("masked", ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isMasked())));
- }
-
- fields.setMetaType(metaType);
- if (metadata.getValue() != null && metadata.getValue().trim().length() > 0) {
- fields.setField(Fields.DEFAULT_VALUE, ManagedUtil.wrap(metaType, metadata.getValue()));
- }
-
- ManagedPropertyImpl dsTypeMP = new ManagedPropertyImpl(fields);
- addProperty(dsTypeMP);
- }
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,138 @@
+/*
+ * 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.HashSet;
+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.metatype.api.values.MetaValue;
+import org.jboss.resource.metadata.ConfigPropertyMetaData;
+import org.jboss.resource.metadata.ConnectionDefinitionMetaData;
+import org.jboss.resource.metadata.ConnectorMetaData;
+import org.jboss.resource.metadata.DescriptionMetaData;
+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='"+getName()+".rar'");
+ 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);
+ }
+ } catch (MalformedObjectNameException e) {
+ //ignore
+ } catch (AttributeNotFoundException e) {
+ //ignore
+ } catch (InstanceNotFoundException e) {
+ //ignore
+ } catch (MBeanException e) {
+ //ignore
+ } catch (ReflectionException e) {
+ //ignore
+ }
+ }
+
+ private void addConnectorProperty(ConfigPropertyMetaData metadata) {
+ SimpleMetaType metaType = SimpleMetaType.resolve(metadata.getType());
+
+ DefaultFieldsImpl fields = new DefaultFieldsImpl(metadata.getName());
+ DescriptionMetaData descMetadata = metadata.getDescription();
+ String description = descMetadata.getDescription();
+ if (description != null) {
+ ExtendedPropertyMetadata extended = new ExtendedPropertyMetadata(description);
+ if (extended.getDescription() != null) {
+ fields.setDescription(description);
+ }
+
+ if (extended.getDisplayName() != null) {
+ fields.setField(Fields.MAPPED_NAME, extended.getDisplayName());
+ }
+
+ if (extended.getAllowed() != null) {
+ HashSet<MetaValue> values = new HashSet<MetaValue>();
+ for (String value:extended.getAllowed()) {
+ values.add(ManagedUtil.wrap(SimpleMetaType.STRING, value));
+ }
+ fields.setField(Fields.LEGAL_VALUES, values);
+ }
+ fields.setField(Fields.MANDATORY, ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isRequired())));
+ fields.setField(Fields.READ_ONLY, ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(!extended.isEditable())));
+ fields.setField("advanced", ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isAdvanced())));
+ fields.setField("masked", ManagedUtil.wrap(SimpleMetaType.BOOLEAN_PRIMITIVE, String.valueOf(extended.isMasked())));
+ }
+
+ fields.setMetaType(metaType);
+ if (metadata.getValue() != null && metadata.getValue().trim().length() > 0) {
+ fields.setField(Fields.DEFAULT_VALUE, ManagedUtil.wrap(metaType, metadata.getValue()));
+ }
+
+ ManagedPropertyImpl dsTypeMP = new ManagedPropertyImpl(fields);
+ addProperty(dsTypeMP);
+ }
+}
Deleted: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExtendedPropertyMetadata.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ExtendedPropertyMetadata.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExtendedPropertyMetadata.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,145 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.templates.connector;
-
-import java.util.ArrayList;
-
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-public class ExtendedPropertyMetadata {
- private String displayName;
- private String description;
- private boolean advanced;
- private boolean masked;
- private boolean editable = true;
- private boolean required;
- private ArrayList<String> allowed;
-
-
- public ExtendedPropertyMetadata(String encodedData) {
- encodedData = encodedData.trim();
-
- // if not begins with { then treat as if just a simple description field.
- if (!encodedData.startsWith("{")) {
- this.displayName = encodedData;
- return;
- }
-
- if (!encodedData.endsWith("}")) {
- throw new MetaMatrixRuntimeException("The description field = "+encodedData+" does not end with \"}\"");
- }
- encodedData = encodedData.substring(1, encodedData.length()-1);
-
- int index = 0;
- int start = -1;
- boolean inQuotes = false;
- int inQuotesStart = -1;
- boolean inArray = false;
-
- String propertyName = null;
- ArrayList<String> values = new ArrayList<String>();
- for (char c:encodedData.toCharArray()) {
- if (c == '$' && start == -1) {
- start = index;
- }
- else if (c == '"') {
- inQuotes = !inQuotes;
- if (inQuotes && inQuotesStart == -1) {
- inQuotesStart = index;
- }
- else if (!inQuotes && inQuotesStart != -1) {
- if (inQuotesStart+1 != index) {
- values.add(encodedData.substring(inQuotesStart+1, index));
- }
- inQuotesStart = -1;
- }
- }
- else if (c == '[') {
- inArray = true;
- }
- else if (c == ']') {
- inArray = false;
- }
- else if (c == ':' && !inQuotes && !inArray && start != -1) {
- propertyName = encodedData.substring(start, index);
- }
- else if (c == ',' && !inQuotes && !inArray && start != -1) {
- addProperty(propertyName, values);
- propertyName = null;
- values = new ArrayList<String>();
- start = -1;
- }
- index++;
- }
- // add last property
- addProperty(propertyName, values);
- }
-
- private void addProperty(String name, ArrayList<String> values) {
- if (name.equals("$display")) {
- this.displayName = values.get(0);
- }
- else if (name.equals("$description")) {
- this.description = values.get(0);
- }
- else if (name.equals("$advanced")) {
- this.advanced = Boolean.parseBoolean(values.get(0));
- }
- else if (name.equals("$masked")) {
- this.masked = Boolean.parseBoolean(values.get(0));
- }
- else if (name.equals("$editable")) {
- this.editable = Boolean.parseBoolean(values.get(0));
- }
- else if (name.equals("$allowed")) {
- this.allowed = new ArrayList<String>(values);
- }
- else if (name.equals("$required")) {
- this.required = Boolean.parseBoolean(values.get(0));
- }
- }
-
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public String getDisplayName() {
- return displayName;
- }
- public boolean isAdvanced() {
- return advanced;
- }
- public boolean isMasked() {
- return masked;
- }
- public boolean isEditable() {
- return editable;
- }
- public boolean isRequired() {
- return required;
- }
- public ArrayList<String> getAllowed() {
- return allowed;
- }
-}
Copied: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExtendedPropertyMetadata.java (from rev 1899, branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ExtendedPropertyMetadata.java)
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExtendedPropertyMetadata.java (rev 0)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/ExtendedPropertyMetadata.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,145 @@
+/*
+ * 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.ArrayList;
+
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class ExtendedPropertyMetadata {
+ private String displayName;
+ private String description;
+ private boolean advanced;
+ private boolean masked;
+ private boolean editable = true;
+ private boolean required;
+ private ArrayList<String> allowed;
+
+
+ public ExtendedPropertyMetadata(String encodedData) {
+ encodedData = encodedData.trim();
+
+ // if not begins with { then treat as if just a simple description field.
+ if (!encodedData.startsWith("{")) {
+ this.displayName = encodedData;
+ return;
+ }
+
+ if (!encodedData.endsWith("}")) {
+ throw new MetaMatrixRuntimeException("The description field = "+encodedData+" does not end with \"}\"");
+ }
+ encodedData = encodedData.substring(1, encodedData.length()-1);
+
+ int index = 0;
+ int start = -1;
+ boolean inQuotes = false;
+ int inQuotesStart = -1;
+ boolean inArray = false;
+
+ String propertyName = null;
+ ArrayList<String> values = new ArrayList<String>();
+ for (char c:encodedData.toCharArray()) {
+ if (c == '$' && start == -1) {
+ start = index;
+ }
+ else if (c == '"') {
+ inQuotes = !inQuotes;
+ if (inQuotes && inQuotesStart == -1) {
+ inQuotesStart = index;
+ }
+ else if (!inQuotes && inQuotesStart != -1) {
+ if (inQuotesStart+1 != index) {
+ values.add(encodedData.substring(inQuotesStart+1, index));
+ }
+ inQuotesStart = -1;
+ }
+ }
+ else if (c == '[') {
+ inArray = true;
+ }
+ else if (c == ']') {
+ inArray = false;
+ }
+ else if (c == ':' && !inQuotes && !inArray && start != -1) {
+ propertyName = encodedData.substring(start, index);
+ }
+ else if (c == ',' && !inQuotes && !inArray && start != -1) {
+ addProperty(propertyName, values);
+ propertyName = null;
+ values = new ArrayList<String>();
+ start = -1;
+ }
+ index++;
+ }
+ // add last property
+ addProperty(propertyName, values);
+ }
+
+ private void addProperty(String name, ArrayList<String> values) {
+ if (name.equals("$display")) {
+ this.displayName = values.get(0);
+ }
+ else if (name.equals("$description")) {
+ this.description = values.get(0);
+ }
+ else if (name.equals("$advanced")) {
+ this.advanced = Boolean.parseBoolean(values.get(0));
+ }
+ else if (name.equals("$masked")) {
+ this.masked = Boolean.parseBoolean(values.get(0));
+ }
+ else if (name.equals("$editable")) {
+ this.editable = Boolean.parseBoolean(values.get(0));
+ }
+ else if (name.equals("$allowed")) {
+ this.allowed = new ArrayList<String>(values);
+ }
+ else if (name.equals("$required")) {
+ this.required = Boolean.parseBoolean(values.get(0));
+ }
+ }
+
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String description) {
+ this.description = description;
+ }
+ public String getDisplayName() {
+ return displayName;
+ }
+ public boolean isAdvanced() {
+ return advanced;
+ }
+ public boolean isMasked() {
+ return masked;
+ }
+ public boolean isEditable() {
+ return editable;
+ }
+ public boolean isRequired() {
+ return required;
+ }
+ public ArrayList<String> getAllowed() {
+ return allowed;
+ }
+}
Copied: trunk/jboss-integration/src/main/resources (from rev 1899, branches/JCA/jboss-integration/src/main/resources)
Copied: trunk/jboss-integration/src/test (from rev 1899, branches/JCA/jboss-integration/src/test)
Copied: trunk/jboss-integration/src/test/java (from rev 1899, branches/JCA/jboss-integration/src/test/java)
Copied: trunk/jboss-integration/src/test/java/com (from rev 1899, branches/JCA/jboss-integration/src/test/java/com)
Copied: trunk/jboss-integration/src/test/java/com/metamatrix (from rev 1899, branches/JCA/jboss-integration/src/test/java/com/metamatrix)
Copied: trunk/jboss-integration/src/test/java/com/metamatrix/dqp (from rev 1899, branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp)
Copied: trunk/jboss-integration/src/test/java/com/metamatrix/dqp/embedded (from rev 1899, branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded)
Copied: trunk/jboss-integration/src/test/java/org (from rev 1899, branches/JCA/jboss-integration/src/test/java/org)
Copied: trunk/jboss-integration/src/test/java/org/teiid (from rev 1899, branches/JCA/jboss-integration/src/test/java/org/teiid)
Copied: trunk/jboss-integration/src/test/java/org/teiid/adminapi (from rev 1899, branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi)
Copied: trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss (from rev 1899, branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss)
Deleted: trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/BaseConnection.java
===================================================================
--- branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/BaseConnection.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/BaseConnection.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,66 +0,0 @@
-package org.teiid.adminapi.jboss;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import org.teiid.jdbc.TeiidDataSource;
-
-
-public class BaseConnection {
- static String user = "ramesh";
- static String password = "mm";
-
- interface ConnectionFactory{
- Connection getConnection(String vdbName) throws Exception;
- }
-
- static class ServerDatasourceConnection implements ConnectionFactory {
- public Connection getConnection(String vdbName) throws Exception {
- TeiidDataSource ds = new TeiidDataSource();
- ds.setUser(user);
- ds.setPassword(password);
- ds.setServerName("localhost");
- ds.setPortNumber(31000);
- ds.setDatabaseName(vdbName);
- ds.setAutoCommitTxn("AUTO");
- return ds.getConnection();
- }
- }
-
- public void execute(ConnectionFactory connF, String vdbName, String sql) throws Exception {
- Connection connection = connF.getConnection(vdbName);
- try {
- connection.getMetaData();
- Statement statement = connection.createStatement();
- boolean hasResults = statement.execute(sql);
- if (hasResults) {
- ResultSet results = statement.getResultSet();
- ResultSetMetaData metadata = results.getMetaData();
- int columns = metadata.getColumnCount();
-
- while(results.next()) {
- for (int i = 0; i < columns; i++) {
- System.out.print(results.getString(i+1));
- System.out.print(",");
- }
- System.out.println("");
- }
- System.out.println("Done getting results!");
- results.close();
- }
- else {
- System.out.println("update count is="+statement.getUpdateCount());
- }
- statement.close();
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- }
-}
Copied: trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/BaseConnection.java (from rev 1899, branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/BaseConnection.java)
===================================================================
--- trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/BaseConnection.java (rev 0)
+++ trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/BaseConnection.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,66 @@
+package org.teiid.adminapi.jboss;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.teiid.jdbc.TeiidDataSource;
+
+
+public class BaseConnection {
+ static String user = "ramesh";
+ static String password = "mm";
+
+ interface ConnectionFactory{
+ Connection getConnection(String vdbName) throws Exception;
+ }
+
+ static class ServerDatasourceConnection implements ConnectionFactory {
+ public Connection getConnection(String vdbName) throws Exception {
+ TeiidDataSource ds = new TeiidDataSource();
+ ds.setUser(user);
+ ds.setPassword(password);
+ ds.setServerName("localhost");
+ ds.setPortNumber(31000);
+ ds.setDatabaseName(vdbName);
+ ds.setAutoCommitTxn("AUTO");
+ return ds.getConnection();
+ }
+ }
+
+ public void execute(ConnectionFactory connF, String vdbName, String sql) throws Exception {
+ Connection connection = connF.getConnection(vdbName);
+ try {
+ connection.getMetaData();
+ Statement statement = connection.createStatement();
+ boolean hasResults = statement.execute(sql);
+ if (hasResults) {
+ ResultSet results = statement.getResultSet();
+ ResultSetMetaData metadata = results.getMetaData();
+ int columns = metadata.getColumnCount();
+
+ while(results.next()) {
+ for (int i = 0; i < columns; i++) {
+ System.out.print(results.getString(i+1));
+ System.out.print(",");
+ }
+ System.out.println("");
+ }
+ System.out.println("Done getting results!");
+ results.close();
+ }
+ else {
+ System.out.println("update count is="+statement.getUpdateCount());
+ }
+ statement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+}
Deleted: trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,315 +0,0 @@
-package org.teiid.adminapi.jboss;
-
-
-import static junit.framework.Assert.*;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminFactory;
-import org.teiid.adminapi.ConnectionPoolStatistics;
-import org.teiid.adminapi.ConnectorBinding;
-import org.teiid.adminapi.PropertyDefinition;
-import org.teiid.adminapi.Request;
-import org.teiid.adminapi.Session;
-import org.teiid.adminapi.Transaction;
-import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.WorkerPoolStatistics;
-
-import com.metamatrix.core.util.ObjectConverterUtil;
-import com.metamatrix.core.util.UnitTestUtil;
-
- at Ignore
-public class TestConnectorBindings extends BaseConnection {
- ServerDatasourceConnection ds;
- Admin admin;
-
- @Before
- public void setUp() throws Exception {
- //if (!Bootstrap.getInstance().isStarted()) Bootstrap.getInstance().bootstrap();
- ds = new ServerDatasourceConnection();
- //admin = AdminProvider.getRemote( "jnp://localhost:1099", "javaduke", "anotherduke");
- admin = AdminFactory.getInstance().createAdmin("admin", "admin".toCharArray(), "mm://localhost:31443");
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test public void testConnectorBinding() throws Exception {
- ConnectorBinding binding = admin.getConnectorBinding("test-mysql-cb");
-
- assertNull(binding);
-
- Properties p = new Properties();
- p.setProperty("jndi-name", "test-mysql-cb");
- p.setProperty("rar-name", "connector-jdbc-7.0.0-SNAPSHOT.rar");
- p.setProperty("CapabilitiesClass", "org.teiid.connector.jdbc.derby.DerbyCapabilities");
- p.setProperty("XaCapable", "true");
- p.setProperty("SourceJNDIName", "java:DerbyDS");
- admin.addConnectorBinding("test-mysql-cb","connector-jdbc-7.0.0-SNAPSHOT", p);
-
- binding = admin.getConnectorBinding("test-mysql-cb");
-
- assertNotNull(binding);
-
- assertEquals("java:DerbyDS", binding.getPropertyValue("SourceJNDIName"));
-
- admin.stopConnectorBinding(binding);
-
- admin.startConnectorBinding(binding);
-
- admin.setConnectorBindingProperty("test-mysql-cb", "SourceJNDIName", "DummyDS");
-
- binding = admin.getConnectorBinding("test-mysql-cb");
-
- assertEquals("DummyDS", binding.getPropertyValue("SourceJNDIName"));
-
- admin.deleteConnectorBinding("test-mysql-cb");
-
- binding = admin.getConnectorBinding("test-mysql-cb");
-
- assertNull(binding);
- }
-
- @Test public void testVDBDeploy() throws Exception {
-
- VDB vdb = admin.getVDB("TransactionsRevisited", 1);
- if (vdb != null) {
- admin.deleteVDB("TransactionsRevisited", 1);
- }
-
- assertNull(admin.getVDB("TransactionsRevisited", 1));
-
- File f = UnitTestUtil.getTestDataFile("TransactionsRevisited.vdb");
-
- admin.deployVDB(f.getName(), f.toURI().toURL());
-
- assertNotNull(admin.getVDB("TransactionsRevisited", 1));
-
- Set<VDB> vdbs = admin.getVDBs();
- assertTrue(vdbs.size() >= 1);
-
- Collection<ConnectorBinding> bindings = admin.getConnectorBindingsInVDB("TransactionsRevisited",1);
- assertEquals(2, bindings.size());
-
- admin.deleteVDB("TransactionsRevisited", 1);
-
- assertNull(admin.getVDB("TransactionsRevisited", 1));
- }
-
-
- @Test public void testSessions() throws Exception{
- Collection<Session> sessions = admin.getSessions();
- System.out.println(sessions);
- assertTrue(sessions.size() >= 1);
- for (Session s: sessions) {
- assertEquals("ramesh at teiid-security", s.getUserName());
- }
-
- for (Session s:sessions) {
- admin.terminateSession(s.getSessionId());
- }
-
- sessions = admin.getSessions();
- assertTrue(sessions.size() == 0);
- }
-
-
- @Test public void testRequests() throws Exception {
-
- VDB vdb = admin.getVDB("TransactionsRevisited", 1);
- if (vdb == null) {
- File f = UnitTestUtil.getTestDataFile("TransactionsRevisited.vdb");
- admin.deployVDB(f.getName(), f.toURI().toURL());
- }
-
- Runnable work = new Runnable() {
- public void run() {
- for (int i = 0; i < 5; i++) {
- try {
- execute(ds, "TransactionsRevisited", "select * from pm1.g1");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- };
- Thread t = new Thread(work);
- t.start();
-
- try {
- Collection<Request> requests = admin.getRequests();
- assertTrue(requests.size() > 0);
- }finally {
- t.join();
- }
-
- long sessionId = 0;
- Collection<Session> sessions = admin.getSessions();
- for (Session s:sessions) {
- sessionId = s.getSessionId();
- }
-
- t = new Thread(work);
- t.start();
-
- try {
- Collection<Request> requests = admin.getRequestsForSession(sessionId);
- assertTrue(requests.size() >= 0);
- } finally {
- t.join();
- admin.deleteVDB("TransactionsRevisited", 1);
- }
- }
-
- @Test
- public void testCache() throws Exception {
- Collection<String> caches = admin.getCacheTypes();
- assertEquals(4, caches.size());
-
- admin.clearCache("CODE_TABLE_CACHE");
- }
-
- @Test
- public void testTransactions() throws Exception {
-
- VDB vdb = admin.getVDB("TransactionsRevisited", 1);
- if (vdb == null) {
- File f = UnitTestUtil.getTestDataFile("TransactionsRevisited.vdb");
- admin.deployVDB(f.getName(), f.toURI().toURL());
- }
-
- Runnable work = new Runnable() {
- public void run() {
- try {
- for (int i = 0; i < 10; i++) {
- int v = i+200;
- execute(ds, "TransactionsRevisited", "insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values("+v+",'"+v+"',"+v+",'"+v+"')");
- }
- execute(ds, "TransactionsRevisited", "delete from vm.g1 where pm1e1 >= 200");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- };
-
- Thread t = new Thread(work);
- t.start();
- Thread.sleep(2000);
- try {
- Collection<Transaction> txns = admin.getTransactions();
- assertTrue(txns.size() >= 0);
- } finally {
- t.join();
- admin.deleteVDB("TransactionsRevisited", 1);
- }
- }
-
- @Test
- public void testWorkmanagerStats() throws Exception {
- WorkerPoolStatistics stats = admin.getWorkManagerStats("runtime");
- System.out.println(stats);
- }
-
- @Test
- public void testConnectionPool() throws Exception {
- ConnectionPoolStatistics stats = admin.getConnectorConnectionPoolStats("mysql-connector-binding");
- System.out.println(stats);
- }
-
- @Test
- public void testConnectorTypeProperties() throws Exception {
- Collection<PropertyDefinition> defs = admin.getConnectorTypePropertyDefinitions("connector-jdbc-7.0.0-SNAPSHOT");
- for (PropertyDefinition pd:defs) {
- System.out.println(pd.getName());
- if (pd.getName().equals("ExtensionTranslationClassName")) {
- assertEquals("Extension SQL Translation Class", pd.getDisplayName());
- assertEquals(true, pd.isAdvanced());
- assertEquals(true, pd.isRequired());
- assertEquals(false, pd.isMasked());
- assertEquals(true, pd.isModifiable());
-
- HashSet<String> values = new HashSet<String>();
- values.add("org.teiid.connector.jdbc.h2.H2Translator");
- values.add("org.teiid.connector.jdbc.sqlserver.SqlServerSQLTranslator");
- values.add("org.teiid.connector.jdbc.mysql.MySQL5Translator");
- values.add("org.teiid.connector.jdbc.derby.DerbySQLTranslator");
- values.add("org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator");
- values.add("org.teiid.connector.jdbc.db2.DB2SQLTranslator");
- values.add("org.teiid.connector.jdbc.access.AccessSQLTranslator");
- values.add("org.teiid.connector.jdbc.mysql.MySQLTranslator");
- values.add("org.teiid.connector.jdbc.translator.Translator");
- values.add("org.teiid.connector.jdbc.oracle.OracleSQLTranslator");
- assertEquals(values, pd.getAllowedValues());
- }
- }
- }
-
- @Test
- public void testConnectorTypes() throws Exception {
- Set<String> defs = admin.getConnectorTypes();
- assertTrue(defs.contains("connector-salesforce-7.0.0-SNAPSHOT"));
- assertTrue(defs.contains("connector-jdbc-7.0.0-SNAPSHOT"));
- assertTrue(defs.contains("connector-text-7.0.0-SNAPSHOT"));
- assertTrue(defs.contains("connector-loopback-7.0.0-SNAPSHOT"));
- assertTrue(defs.contains("connector-ldap-7.0.0-SNAPSHOT"));
- System.out.println(defs);
- }
-
- @Test
- public void testPropertyDefsForDS() throws Exception {
- Collection<PropertyDefinition> defs = admin.getDataSourcePropertyDefinitions();
- System.out.println(defs);
- }
-
- @Test
- public void testTemplate() throws Exception{
- File f = new File(UnitTestUtil.getTestDataPath()+"/connector-loopback.rar");
- admin.addConnectorType("connector-loopy", f.toURI().toURL());
-
- Set<String> names = admin.getConnectorTypes();
- assertTrue(names.contains("connector-loopy"));
-
- admin.deleteConnectorType("connector-loopy");
-
- names = admin.getConnectorTypes();
- assertTrue(!names.contains("connector-loopy"));
- }
-
- @Test
- public void testExportVDB() throws Exception{
- File f = new File(UnitTestUtil.getTestScratchPath()+"/Admin.vdb");
-
- assertTrue(!f.exists());
-
- InputStream in = admin.exportVDB("Admin", 1);
- if (in != null) {
- ObjectConverterUtil.write(in, f);
- }
-
- assertTrue(f.exists());
- f.delete();
- }
-
- @Test public void testAssignConnectorBinding() throws Exception {
-
- VDB vdb = admin.getVDB("TransactionsRevisited", 1);
- if (vdb == null) {
- admin.deleteVDB("TransactionsRevisited", 1);
- File f = UnitTestUtil.getTestDataFile("TransactionsRevisited.vdb");
- admin.deployVDB(f.getName(), f.toURI().toURL());
- }
-
- admin.assignBindingsToModel("TransactionsRevisited", 1, "pm1", new String[] {"java:foo", "java:bar"});
- }
-}
Copied: trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java (from rev 1899, branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java)
===================================================================
--- trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java (rev 0)
+++ trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,315 @@
+package org.teiid.adminapi.jboss;
+
+
+import static junit.framework.Assert.*;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminFactory;
+import org.teiid.adminapi.ConnectionPoolStatistics;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.PropertyDefinition;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.Transaction;
+import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.WorkerPoolStatistics;
+
+import com.metamatrix.core.util.ObjectConverterUtil;
+import com.metamatrix.core.util.UnitTestUtil;
+
+ at Ignore
+public class TestConnectorBindings extends BaseConnection {
+ ServerDatasourceConnection ds;
+ Admin admin;
+
+ @Before
+ public void setUp() throws Exception {
+ //if (!Bootstrap.getInstance().isStarted()) Bootstrap.getInstance().bootstrap();
+ ds = new ServerDatasourceConnection();
+ //admin = AdminProvider.getRemote( "jnp://localhost:1099", "javaduke", "anotherduke");
+ admin = AdminFactory.getInstance().createAdmin("admin", "admin".toCharArray(), "mm://localhost:31443");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test public void testConnectorBinding() throws Exception {
+ ConnectorBinding binding = admin.getConnectorBinding("test-mysql-cb");
+
+ assertNull(binding);
+
+ Properties p = new Properties();
+ p.setProperty("jndi-name", "test-mysql-cb");
+ p.setProperty("rar-name", "connector-jdbc-7.0.0-SNAPSHOT.rar");
+ p.setProperty("CapabilitiesClass", "org.teiid.connector.jdbc.derby.DerbyCapabilities");
+ p.setProperty("XaCapable", "true");
+ p.setProperty("SourceJNDIName", "java:DerbyDS");
+ admin.addConnectorBinding("test-mysql-cb","connector-jdbc-7.0.0-SNAPSHOT", p);
+
+ binding = admin.getConnectorBinding("test-mysql-cb");
+
+ assertNotNull(binding);
+
+ assertEquals("java:DerbyDS", binding.getPropertyValue("SourceJNDIName"));
+
+ admin.stopConnectorBinding(binding);
+
+ admin.startConnectorBinding(binding);
+
+ admin.setConnectorBindingProperty("test-mysql-cb", "SourceJNDIName", "DummyDS");
+
+ binding = admin.getConnectorBinding("test-mysql-cb");
+
+ assertEquals("DummyDS", binding.getPropertyValue("SourceJNDIName"));
+
+ admin.deleteConnectorBinding("test-mysql-cb");
+
+ binding = admin.getConnectorBinding("test-mysql-cb");
+
+ assertNull(binding);
+ }
+
+ @Test public void testVDBDeploy() throws Exception {
+
+ VDB vdb = admin.getVDB("TransactionsRevisited", 1);
+ if (vdb != null) {
+ admin.deleteVDB("TransactionsRevisited", 1);
+ }
+
+ assertNull(admin.getVDB("TransactionsRevisited", 1));
+
+ File f = UnitTestUtil.getTestDataFile("TransactionsRevisited.vdb");
+
+ admin.deployVDB(f.getName(), f.toURI().toURL());
+
+ assertNotNull(admin.getVDB("TransactionsRevisited", 1));
+
+ Set<VDB> vdbs = admin.getVDBs();
+ assertTrue(vdbs.size() >= 1);
+
+ Collection<ConnectorBinding> bindings = admin.getConnectorBindingsInVDB("TransactionsRevisited",1);
+ assertEquals(2, bindings.size());
+
+ admin.deleteVDB("TransactionsRevisited", 1);
+
+ assertNull(admin.getVDB("TransactionsRevisited", 1));
+ }
+
+
+ @Test public void testSessions() throws Exception{
+ Collection<Session> sessions = admin.getSessions();
+ System.out.println(sessions);
+ assertTrue(sessions.size() >= 1);
+ for (Session s: sessions) {
+ assertEquals("ramesh at teiid-security", s.getUserName());
+ }
+
+ for (Session s:sessions) {
+ admin.terminateSession(s.getSessionId());
+ }
+
+ sessions = admin.getSessions();
+ assertTrue(sessions.size() == 0);
+ }
+
+
+ @Test public void testRequests() throws Exception {
+
+ VDB vdb = admin.getVDB("TransactionsRevisited", 1);
+ if (vdb == null) {
+ File f = UnitTestUtil.getTestDataFile("TransactionsRevisited.vdb");
+ admin.deployVDB(f.getName(), f.toURI().toURL());
+ }
+
+ Runnable work = new Runnable() {
+ public void run() {
+ for (int i = 0; i < 5; i++) {
+ try {
+ execute(ds, "TransactionsRevisited", "select * from pm1.g1");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ };
+ Thread t = new Thread(work);
+ t.start();
+
+ try {
+ Collection<Request> requests = admin.getRequests();
+ assertTrue(requests.size() > 0);
+ }finally {
+ t.join();
+ }
+
+ long sessionId = 0;
+ Collection<Session> sessions = admin.getSessions();
+ for (Session s:sessions) {
+ sessionId = s.getSessionId();
+ }
+
+ t = new Thread(work);
+ t.start();
+
+ try {
+ Collection<Request> requests = admin.getRequestsForSession(sessionId);
+ assertTrue(requests.size() >= 0);
+ } finally {
+ t.join();
+ admin.deleteVDB("TransactionsRevisited", 1);
+ }
+ }
+
+ @Test
+ public void testCache() throws Exception {
+ Collection<String> caches = admin.getCacheTypes();
+ assertEquals(4, caches.size());
+
+ admin.clearCache("CODE_TABLE_CACHE");
+ }
+
+ @Test
+ public void testTransactions() throws Exception {
+
+ VDB vdb = admin.getVDB("TransactionsRevisited", 1);
+ if (vdb == null) {
+ File f = UnitTestUtil.getTestDataFile("TransactionsRevisited.vdb");
+ admin.deployVDB(f.getName(), f.toURI().toURL());
+ }
+
+ Runnable work = new Runnable() {
+ public void run() {
+ try {
+ for (int i = 0; i < 10; i++) {
+ int v = i+200;
+ execute(ds, "TransactionsRevisited", "insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values("+v+",'"+v+"',"+v+",'"+v+"')");
+ }
+ execute(ds, "TransactionsRevisited", "delete from vm.g1 where pm1e1 >= 200");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ Thread t = new Thread(work);
+ t.start();
+ Thread.sleep(2000);
+ try {
+ Collection<Transaction> txns = admin.getTransactions();
+ assertTrue(txns.size() >= 0);
+ } finally {
+ t.join();
+ admin.deleteVDB("TransactionsRevisited", 1);
+ }
+ }
+
+ @Test
+ public void testWorkmanagerStats() throws Exception {
+ WorkerPoolStatistics stats = admin.getWorkManagerStats("runtime");
+ System.out.println(stats);
+ }
+
+ @Test
+ public void testConnectionPool() throws Exception {
+ ConnectionPoolStatistics stats = admin.getConnectorConnectionPoolStats("mysql-connector-binding");
+ System.out.println(stats);
+ }
+
+ @Test
+ public void testConnectorTypeProperties() throws Exception {
+ Collection<PropertyDefinition> defs = admin.getConnectorTypePropertyDefinitions("connector-jdbc-7.0.0-SNAPSHOT");
+ for (PropertyDefinition pd:defs) {
+ System.out.println(pd.getName());
+ if (pd.getName().equals("ExtensionTranslationClassName")) {
+ assertEquals("Extension SQL Translation Class", pd.getDisplayName());
+ assertEquals(true, pd.isAdvanced());
+ assertEquals(true, pd.isRequired());
+ assertEquals(false, pd.isMasked());
+ assertEquals(true, pd.isModifiable());
+
+ HashSet<String> values = new HashSet<String>();
+ values.add("org.teiid.connector.jdbc.h2.H2Translator");
+ values.add("org.teiid.connector.jdbc.sqlserver.SqlServerSQLTranslator");
+ values.add("org.teiid.connector.jdbc.mysql.MySQL5Translator");
+ values.add("org.teiid.connector.jdbc.derby.DerbySQLTranslator");
+ values.add("org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator");
+ values.add("org.teiid.connector.jdbc.db2.DB2SQLTranslator");
+ values.add("org.teiid.connector.jdbc.access.AccessSQLTranslator");
+ values.add("org.teiid.connector.jdbc.mysql.MySQLTranslator");
+ values.add("org.teiid.connector.jdbc.translator.Translator");
+ values.add("org.teiid.connector.jdbc.oracle.OracleSQLTranslator");
+ assertEquals(values, pd.getAllowedValues());
+ }
+ }
+ }
+
+ @Test
+ public void testConnectorTypes() throws Exception {
+ Set<String> defs = admin.getConnectorTypes();
+ assertTrue(defs.contains("connector-salesforce-7.0.0-SNAPSHOT"));
+ assertTrue(defs.contains("connector-jdbc-7.0.0-SNAPSHOT"));
+ assertTrue(defs.contains("connector-text-7.0.0-SNAPSHOT"));
+ assertTrue(defs.contains("connector-loopback-7.0.0-SNAPSHOT"));
+ assertTrue(defs.contains("connector-ldap-7.0.0-SNAPSHOT"));
+ System.out.println(defs);
+ }
+
+ @Test
+ public void testPropertyDefsForDS() throws Exception {
+ Collection<PropertyDefinition> defs = admin.getDataSourcePropertyDefinitions();
+ System.out.println(defs);
+ }
+
+ @Test
+ public void testTemplate() throws Exception{
+ File f = new File(UnitTestUtil.getTestDataPath()+"/connector-loopback.rar");
+ admin.addConnectorType("connector-loopy", f.toURI().toURL());
+
+ Set<String> names = admin.getConnectorTypes();
+ assertTrue(names.contains("connector-loopy"));
+
+ admin.deleteConnectorType("connector-loopy");
+
+ names = admin.getConnectorTypes();
+ assertTrue(!names.contains("connector-loopy"));
+ }
+
+ @Test
+ public void testExportVDB() throws Exception{
+ File f = new File(UnitTestUtil.getTestScratchPath()+"/Admin.vdb");
+
+ assertTrue(!f.exists());
+
+ InputStream in = admin.exportVDB("Admin", 1);
+ if (in != null) {
+ ObjectConverterUtil.write(in, f);
+ }
+
+ assertTrue(f.exists());
+ f.delete();
+ }
+
+ @Test public void testAssignConnectorBinding() throws Exception {
+
+ VDB vdb = admin.getVDB("TransactionsRevisited", 1);
+ if (vdb == null) {
+ admin.deleteVDB("TransactionsRevisited", 1);
+ File f = UnitTestUtil.getTestDataFile("TransactionsRevisited.vdb");
+ admin.deployVDB(f.getName(), f.toURI().toURL());
+ }
+
+ admin.assignBindingsToModel("TransactionsRevisited", 1, "pm1", new String[] {"java:foo", "java:bar"});
+ }
+}
Copied: trunk/jboss-integration/src/test/java/org/teiid/templates (from rev 1899, branches/JCA/jboss-integration/src/test/java/org/teiid/templates)
Copied: trunk/jboss-integration/src/test/java/org/teiid/templates/connector (from rev 1899, branches/JCA/jboss-integration/src/test/java/org/teiid/templates/connector)
Deleted: trunk/jboss-integration/src/test/java/org/teiid/templates/connector/TestExtendedPropertyMetadata.java
===================================================================
--- branches/JCA/jboss-integration/src/test/java/org/teiid/templates/connector/TestExtendedPropertyMetadata.java 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/test/java/org/teiid/templates/connector/TestExtendedPropertyMetadata.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.templates.connector;
-
-import java.util.ArrayList;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-
-public class TestExtendedPropertyMetadata {
-
- @Test
- public void testDefault() {
- ExtendedPropertyMetadata metadata = new ExtendedPropertyMetadata("some-name");
-
- Assert.assertEquals("some-name", metadata.getDisplayName());
- Assert.assertEquals(null, metadata.getDescription());
- Assert.assertEquals(false, metadata.isAdvanced());
- Assert.assertEquals(false, metadata.isRequired());
- Assert.assertEquals(false, metadata.isMasked());
- Assert.assertEquals(true , metadata.isEditable());
- }
-
- @Test
- public void testFormatted() {
- ArrayList<String> allowed = new ArrayList<String>();
- allowed.add("get");
- allowed.add("post");
-
- ExtendedPropertyMetadata metadata = new ExtendedPropertyMetadata("{$display:\"Is Immutable\",$description:\"True if the source never changes.\",$allowed:[\"get\",\"post\"], $required:\"true\",$advanced:\"true\"}");
-
- Assert.assertEquals("Is Immutable", metadata.getDisplayName());
- Assert.assertEquals("True if the source never changes.", metadata.getDescription());
- Assert.assertEquals(true, metadata.isAdvanced());
- Assert.assertEquals(true, metadata.isRequired());
- Assert.assertEquals(false, metadata.isMasked());
- Assert.assertEquals(true , metadata.isEditable());
- Assert.assertEquals(allowed , metadata.getAllowed());
- }
-
- @Test
- public void testFormattedExtraCommasAndColons() {
- ArrayList<String> allowed = new ArrayList<String>();
- allowed.add("get");
- allowed.add("post");
-
- ExtendedPropertyMetadata metadata = new ExtendedPropertyMetadata("{$display:\"Is Immu:table\",$description:\"True if the, source never changes.\",$allowed:[\"get\",\"post\"], $required:\"true\",$advanced:\"true\"}");
-
- Assert.assertEquals("Is Immu:table", metadata.getDisplayName());
- Assert.assertEquals("True if the, source never changes.", metadata.getDescription());
- Assert.assertEquals(true, metadata.isAdvanced());
- Assert.assertEquals(true, metadata.isRequired());
- Assert.assertEquals(false, metadata.isMasked());
- Assert.assertEquals(true , metadata.isEditable());
- Assert.assertEquals(allowed , metadata.getAllowed());
- }
-}
Copied: trunk/jboss-integration/src/test/java/org/teiid/templates/connector/TestExtendedPropertyMetadata.java (from rev 1899, branches/JCA/jboss-integration/src/test/java/org/teiid/templates/connector/TestExtendedPropertyMetadata.java)
===================================================================
--- trunk/jboss-integration/src/test/java/org/teiid/templates/connector/TestExtendedPropertyMetadata.java (rev 0)
+++ trunk/jboss-integration/src/test/java/org/teiid/templates/connector/TestExtendedPropertyMetadata.java 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.templates.connector;
+
+import java.util.ArrayList;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+public class TestExtendedPropertyMetadata {
+
+ @Test
+ public void testDefault() {
+ ExtendedPropertyMetadata metadata = new ExtendedPropertyMetadata("some-name");
+
+ Assert.assertEquals("some-name", metadata.getDisplayName());
+ Assert.assertEquals(null, metadata.getDescription());
+ Assert.assertEquals(false, metadata.isAdvanced());
+ Assert.assertEquals(false, metadata.isRequired());
+ Assert.assertEquals(false, metadata.isMasked());
+ Assert.assertEquals(true , metadata.isEditable());
+ }
+
+ @Test
+ public void testFormatted() {
+ ArrayList<String> allowed = new ArrayList<String>();
+ allowed.add("get");
+ allowed.add("post");
+
+ ExtendedPropertyMetadata metadata = new ExtendedPropertyMetadata("{$display:\"Is Immutable\",$description:\"True if the source never changes.\",$allowed:[\"get\",\"post\"], $required:\"true\",$advanced:\"true\"}");
+
+ Assert.assertEquals("Is Immutable", metadata.getDisplayName());
+ Assert.assertEquals("True if the source never changes.", metadata.getDescription());
+ Assert.assertEquals(true, metadata.isAdvanced());
+ Assert.assertEquals(true, metadata.isRequired());
+ Assert.assertEquals(false, metadata.isMasked());
+ Assert.assertEquals(true , metadata.isEditable());
+ Assert.assertEquals(allowed , metadata.getAllowed());
+ }
+
+ @Test
+ public void testFormattedExtraCommasAndColons() {
+ ArrayList<String> allowed = new ArrayList<String>();
+ allowed.add("get");
+ allowed.add("post");
+
+ ExtendedPropertyMetadata metadata = new ExtendedPropertyMetadata("{$display:\"Is Immu:table\",$description:\"True if the, source never changes.\",$allowed:[\"get\",\"post\"], $required:\"true\",$advanced:\"true\"}");
+
+ Assert.assertEquals("Is Immu:table", metadata.getDisplayName());
+ Assert.assertEquals("True if the, source never changes.", metadata.getDescription());
+ Assert.assertEquals(true, metadata.isAdvanced());
+ Assert.assertEquals(true, metadata.isRequired());
+ Assert.assertEquals(false, metadata.isMasked());
+ Assert.assertEquals(true , metadata.isEditable());
+ Assert.assertEquals(allowed , metadata.getAllowed());
+ }
+}
Copied: trunk/jboss-integration/src/test/resources (from rev 1899, branches/JCA/jboss-integration/src/test/resources)
Deleted: trunk/jboss-integration/src/test/resources/TransactionsRevisited.vdb
===================================================================
(Binary files differ)
Copied: trunk/jboss-integration/src/test/resources/TransactionsRevisited.vdb (from rev 1899, branches/JCA/jboss-integration/src/test/resources/TransactionsRevisited.vdb)
===================================================================
(Binary files differ)
Deleted: trunk/jboss-integration/src/test/resources/connector-loopback.rar
===================================================================
(Binary files differ)
Copied: trunk/jboss-integration/src/test/resources/connector-loopback.rar (from rev 1899, branches/JCA/jboss-integration/src/test/resources/connector-loopback.rar)
===================================================================
(Binary files differ)
Deleted: trunk/jboss-integration/src/test/resources/log4j.xml
===================================================================
--- branches/JCA/jboss-integration/src/test/resources/log4j.xml 2010-03-04 05:02:09 UTC (rev 1899)
+++ trunk/jboss-integration/src/test/resources/log4j.xml 2010-03-05 18:10:12 UTC (rev 1922)
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
-
- <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out"/>
- <param name="Threshold" value="INFO"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %p [%t] %c - %m%n"/>
- </layout>
- </appender>
-
-
- <root>
- <priority value="WARN"/>
- <appender-ref ref="CONSOLE"/>
- </root>
-
-</log4j:configuration>
Copied: trunk/jboss-integration/src/test/resources/log4j.xml (from rev 1899, branches/JCA/jboss-integration/src/test/resources/log4j.xml)
===================================================================
--- trunk/jboss-integration/src/test/resources/log4j.xml (rev 0)
+++ trunk/jboss-integration/src/test/resources/log4j.xml 2010-03-05 18:10:12 UTC (rev 1922)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %p [%t] %c - %m%n"/>
+ </layout>
+ </appender>
+
+
+ <root>
+ <priority value="WARN"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
More information about the teiid-commits
mailing list