Author: rareddy
Date: 2009-12-14 11:45:10 -0500 (Mon, 14 Dec 2009)
New Revision: 1660
Added:
branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java
branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java
branches/JCA/connectors/connector-jdbc/src/test/resources/PartsSupplier.vdb
branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java
branches/JCA/engine/src/main/java/org/teiid/cache/
branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
Log:
TEIID-833: adding VDB deployer
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java
(rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Visibility.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi;
+
+import java.io.Serializable;
+
+public enum Visibility implements Serializable{
+ PUBLIC,PRIVATE;
+}
\ No newline at end of file
Added:
branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java
===================================================================
---
branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java
(rev 0)
+++
branches/JCA/common-internal/src/main/java/com/metamatrix/platform/security/api/AuthorizationPoliciesHolder.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package com.metamatrix.platform.security.api;
+
+import java.util.Collection;
+
+public class AuthorizationPoliciesHolder {
+ private Collection<AuthorizationPolicy> policies;
+
+ public void setAuthorizationPolicies(Collection<AuthorizationPolicy> policies) {
+ this.policies = policies;
+ }
+
+ public Collection<AuthorizationPolicy> getAuthorizationPolicies(){
+ return this.policies;
+ }
+}
Added: branches/JCA/connectors/connector-jdbc/src/test/resources/PartsSupplier.vdb
===================================================================
(Binary files differ)
Property changes on:
branches/JCA/connectors/connector-jdbc/src/test/resources/PartsSupplier.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java
===================================================================
---
branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java
(rev 0)
+++
branches/JCA/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistryImpl.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -0,0 +1,29 @@
+package com.metamatrix.common.comm;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+public class ClientServiceRegistryImpl implements ClientServiceRegistry{
+
+ private ConcurrentHashMap<String, Object> localServices = new
ConcurrentHashMap<String, Object>();
+ private ConcurrentHashMap<String, String> loggingContext = new
ConcurrentHashMap<String, String>();
+
+ public ClientServiceRegistryImpl() {
+ }
+
+ public <T> T getClientService(Class<T> iface) {
+ return (T)this.localServices.get(iface.getName());
+ }
+
+ public Object getClientService(String iface) {
+ return localServices.get(iface);
+ }
+
+ public <T> void registerClientService(Class<T> iface, T instance, String
loggingContext) {
+ this.localServices.put(iface.getName(), instance);
+ this.loggingContext.put(iface.getName(), loggingContext);
+ }
+
+ public String getLoggingContextForService(String iface) {
+ return this.loggingContext.get(iface);
+ }
+}
Added: branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
(rev 0)
+++ branches/JCA/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -0,0 +1,135 @@
+/*
+ * 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.cache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.metamatrix.cache.Cache;
+import com.metamatrix.cache.CacheConfiguration;
+import com.metamatrix.cache.CacheFactory;
+import com.metamatrix.cache.CacheListener;
+import com.metamatrix.cache.Cache.Type;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class DefaultCacheFactory implements CacheFactory, Serializable {
+ private static final long serialVersionUID = -5541424157695857527L;
+
+ DefaultCache cacheRoot = new DefaultCache("Teiid");
+ private volatile boolean destroyed = false;
+
+ @Override
+ public void destroy() {
+ this.destroyed = true;
+ }
+
+ @Override
+ public <K, V> Cache<K, V> get(Type type, CacheConfiguration config) {
+ if (!destroyed) {
+ Cache node = cacheRoot.addChild(type.location());
+ return node;
+ }
+ throw new MetaMatrixRuntimeException("Cache system has been shutdown");
//$NON-NLS-1$
+ }
+
+ class DefaultCache<K, V> implements Cache<K, V>, Serializable {
+ Map<K, V> map = new HashMap();
+ Map<String, Cache> children = new HashMap();
+ String name;
+
+ public DefaultCache(String name) {
+ this.name = name;
+ }
+ public void addListener(CacheListener listener) {
+ }
+
+ public void clear() {
+ map.clear();
+ }
+
+ public V get(K key) {
+ return map.get(key);
+ }
+
+ public Set<K> keySet() {
+ return map.keySet();
+ }
+
+ public V put(K key, V value) {
+ return map.put(key, value);
+ }
+
+ public V remove(K key) {
+ return map.remove(key);
+ }
+
+ public int size() {
+ return map.size();
+ }
+
+ public Collection<V> values() {
+ return map.values();
+ }
+
+ @Override
+ public void removeListener() {
+ }
+
+ @Override
+ public Cache addChild(String name) {
+ if (children.get(name) != null) {
+ return children.get(name);
+ }
+
+ Cache c = new DefaultCache(name);
+ children.put(name, c);
+ return c;
+ }
+
+ @Override
+ public Cache getChild(String name) {
+ return children.get(name);
+ }
+
+ @Override
+ public List<Cache> getChildren() {
+ return new ArrayList<Cache>(children.values());
+ }
+
+ @Override
+ public boolean removeChild(String name) {
+ Object obj = children.remove(name);
+ return obj != null;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+ }
+
+}
Added:
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
===================================================================
---
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java
(rev 0)
+++
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManagerRepository.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.dqp.internal.datamgr.impl;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+
+public class ConnectorManagerRepository implements Serializable{
+ private static final long serialVersionUID = -1611063218178314458L;
+
+ private Map<String, ConnectorManager> repo = new ConcurrentHashMap<String,
ConnectorManager>();
+
+ public void addConnectorManager(String connectorName, ConnectorManager mgr) {
+ this.repo.put(connectorName, mgr);
+ }
+
+ public ConnectorManager getConnectorManager(String connectorName) {
+ return this.repo.get(connectorName);
+ }
+
+ public ConnectorManager removeConnectorManager(String connectorName) {
+ return this.repo.remove(connectorName);
+ }
+}
Added:
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
(rev 0)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -0,0 +1,133 @@
+/*
+ * 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.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+
+public class ConnectorBindingDeployer extends
AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> implements
ManagedObjectCreator {
+ protected Logger log = Logger.getLogger(getClass());
+ private ManagedObjectFactory mof;
+
+ 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);
+ cm.start();
+ cmGroup.addConnectorManager(cm);
+ } catch (ApplicationLifecycleException 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) {
+ ConnectorManager mgr = new ConnectorManager(deployedConnectorName);
+ 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();
+ 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 {
+ //TODO: Need to link CM--> CB as management objects. rareddy
+ // 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;
+ }
+}
Added:
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java
(rev 0)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorManagerGroup.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -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;
+ }
+}
Added:
branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java
===================================================================
---
branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java
(rev 0)
+++
branches/JCA/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -0,0 +1,48 @@
+/*
+ * 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.internal.core.index;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.virtual.VirtualFile;
+
+import com.metamatrix.core.util.ObjectConverterUtil;
+
+public class VirtualRandomAccessFile {
+ File indexFile;
+ String mode;
+
+ public VirtualRandomAccessFile(VirtualFile file, String mode) throws IOException{
+ this.indexFile = File.createTempFile(file.getName(), null);
+ ObjectConverterUtil.write(file.openStream(), indexFile);
+ this.mode = mode;
+ }
+
+ public SafeRandomAccessFile getSafeRandomAccessFile() throws IOException {
+ return new SafeRandomAccessFile(indexFile, mode);
+ }
+
+ public void close() {
+ indexFile.delete();
+ }
+}
Added:
branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java
===================================================================
---
branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java
(rev 0)
+++
branches/JCA/runtime/src/main/java/org/teiid/deployers/BaseMultipleVFSParsingDeployer.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -0,0 +1,70 @@
+/*
+ * 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.deployers;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.vfs.spi.deployer.MultipleVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Overriding the base MultipleVFSParsingDeployer so that the parse method is supplied
with VFSDeploymentUnit.
+ * @param <T>
+ */
+public abstract class BaseMultipleVFSParsingDeployer<T>
extends MultipleVFSParsingDeployer<T> {
+
+ public BaseMultipleVFSParsingDeployer(Class<T> output,Map<String,
Class<?>> mappings, String suffix, Class<?> suffixClass) {
+ super(output, mappings, suffix, suffixClass);
+ }
+
+ public BaseMultipleVFSParsingDeployer(Class<T> output,Map<String,
Class<?>> mappings) {
+ super(output, mappings);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected T mergeFiles(VFSDeploymentUnit unit, T root,List<VirtualFile> files,
Set<String> missingFiles) throws Exception {
+ Map<Class<?>, List<Object>> metadata = new HashMap<Class<?>,
List<Object>>();
+ for (VirtualFile file : files) {
+ Class<?> clazz = matchFileToClass(unit, file);
+ List<Object> instances = metadata.get(clazz);
+ if (instances == null) {
+ instances = new ArrayList<Object>();
+ metadata.put(clazz, instances);
+ }
+ Object instance = parse(unit, clazz, file, root);
+ instances.add(instance);
+ }
+ return mergeMetaData(unit, root, metadata, missingFiles);
+ }
+
+ @Override
+ protected <U> U parse(Class<U> expectedType, VirtualFile file, Object root)
throws Exception{
+ throw new UnsupportedOperationException("This will be never invoked");
+ }
+ protected abstract <U> U parse(VFSDeploymentUnit unit, Class<U>
expectedType, VirtualFile file, Object root) throws Exception;
+}
Added: branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
(rev 0)
+++
branches/JCA/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -0,0 +1,55 @@
+/*
+ * 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.deployers;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.Visibility;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+
+import com.metamatrix.core.vdb.ModelType;
+
+public class DynamicVDBDeployer extends AbstractVFSParsingDeployer<VDBMetaData> {
+
+ public DynamicVDBDeployer() {
+ super(VDBMetaData.class);
+ setSuffix("-vdb.xml");
+ }
+
+ @Override
+ protected VDBMetaData parse(VFSDeploymentUnit unit, VirtualFile file, VDBMetaData root)
throws Exception {
+ VDBMetaData def = DefParser.load(file.openStream());
+
+ // Set the additional model properties which are traditionally on the VDB based
Models.
+ for(ModelMetaData model:def.getModels()) {
+ model.setModelType(ModelType.getString(ModelType.PHYSICAL));
+ model.setVisibility(Visibility.PUBLIC);
+ model.setSupportsMultiSourceBindings(false);
+ }
+
+ def.setUrl(unit.getRoot().toURL());
+ log.debug("VDB "+unit.getRoot().getName()+" has been parsed.");
+ return def;
+ }
+}
Added: branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
(rev 0)
+++
branches/JCA/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2009-12-14
16:45:10 UTC (rev 1660)
@@ -0,0 +1,96 @@
+/*
+ * 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.deployers;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.plugins.context.zip.ZipEntryContext;
+import org.teiid.adminapi.Visibility;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.metadata.index.IndexConstants;
+import org.teiid.metadata.index.IndexMetadataFactory;
+
+import com.metamatrix.core.CoreConstants;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class SystemVDBDeployer {
+ private VDBRepository vdbRepository;
+
+
+ public void start() {
+ ModelMetaData model = new ModelMetaData();
+ model.setName(CoreConstants.SYSTEM_MODEL);
+ model.setVisibility(Visibility.PUBLIC);
+
+ VDBMetaData deployment = new VDBMetaData();
+ deployment.setName(CoreConstants.SYSTEM_VDB);
+
+ deployment.addModel(model);
+
+ try {
+ URL url =
Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB);
+ if (url == null) {
+ throw new MetaMatrixRuntimeException("System.vdb not found in classpath");
+ }
+ SystemVDBContext systemVDB = new SystemVDBContext(url);
+ VirtualFile vdb = new VirtualFile(systemVDB.getRoot());
+ List<VirtualFile> children = vdb.getChildrenRecursively(new VirtualFileFilter()
{
+ @Override
+ public boolean accepts(VirtualFile file) {
+ return
file.getName().endsWith(IndexConstants.NAME_DELIM_CHAR+IndexConstants.INDEX_EXT);
+ }
+ });
+
+ IndexMetadataFactory imf = new IndexMetadataFactory();
+ for (VirtualFile f: children) {
+ imf.addIndexFile(f);
+ }
+ this.vdbRepository.addMetadataStore(deployment, imf.getMetadataStore());
+ } catch (URISyntaxException e) {
+ throw new MetaMatrixRuntimeException(e, "Failed to deploy
"+CoreConstants.SYSTEM_VDB);
+ } catch (IOException e) {
+ throw new MetaMatrixRuntimeException(e, "Failed to deploy
"+CoreConstants.SYSTEM_VDB);
+ }
+ }
+
+ public void stop() {
+ this.vdbRepository.removeVDB(CoreConstants.SYSTEM_VDB, 1);
+ }
+
+ public void setVDBRepository(VDBRepository repo) {
+ this.vdbRepository = repo;
+ }
+
+ private static class SystemVDBContext extends ZipEntryContext{
+ private static final long serialVersionUID = -6504988258841073415L;
+
+ protected SystemVDBContext(URL url) throws IOException, URISyntaxException {
+ super(url,true);
+ }
+ }
+}