[dna-commits] DNA SVN: r663 - in trunk/extensions: dna-common-jdbc and 10 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Mon Dec 8 07:28:33 EST 2008


Author: lisbor
Date: 2008-12-08 07:28:33 -0500 (Mon, 08 Dec 2008)
New Revision: 663

Added:
   trunk/extensions/dna-connector-jdbc-metadata/
   trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/
   trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositoryLexicon.java
   trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java
   trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/
   trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/
   trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/
   trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/
   trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/jdbc/
   trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.properties
Removed:
   trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/sequencer/
   trunk/extensions/dna-sequencer-jdbc-metadata/
Modified:
   trunk/extensions/dna-common-jdbc/
   trunk/extensions/dna-connector-jdbc-metadata/.classpath
   trunk/extensions/dna-connector-jdbc-metadata/.project
   trunk/extensions/dna-connector-jdbc-metadata/pom.xml
   trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.java
Log:
DNA-37 Federate schema information from relational sources
https://jira.jboss.org/jira/browse/DNA-37
Repository Source


Property changes on: trunk/extensions/dna-common-jdbc
___________________________________________________________________
Name: svn:ignore
   + target


Copied: trunk/extensions/dna-connector-jdbc-metadata (from rev 662, trunk/extensions/dna-sequencer-jdbc-metadata)


Property changes on: trunk/extensions/dna-connector-jdbc-metadata
___________________________________________________________________
Name: svn:ignore
   + target

Name: svn:mergeinfo
   + 

Modified: trunk/extensions/dna-connector-jdbc-metadata/.classpath
===================================================================
--- trunk/extensions/dna-sequencer-jdbc-metadata/.classpath	2008-12-05 23:52:47 UTC (rev 662)
+++ trunk/extensions/dna-connector-jdbc-metadata/.classpath	2008-12-08 12:28:33 UTC (rev 663)
@@ -4,7 +4,7 @@
 	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
 	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
 	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
 	<classpathentry kind="output" path="target/classes"/>
 </classpath>

Modified: trunk/extensions/dna-connector-jdbc-metadata/.project
===================================================================
--- trunk/extensions/dna-sequencer-jdbc-metadata/.project	2008-12-05 23:52:47 UTC (rev 662)
+++ trunk/extensions/dna-connector-jdbc-metadata/.project	2008-12-08 12:28:33 UTC (rev 663)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>dna-sequencer-jdbc-metadata</name>
+	<name>dna-connector-jdbc-metadata</name>
 	<comment></comment>
 	<projects>
 	</projects>

Modified: trunk/extensions/dna-connector-jdbc-metadata/pom.xml
===================================================================
--- trunk/extensions/dna-sequencer-jdbc-metadata/pom.xml	2008-12-05 23:52:47 UTC (rev 662)
+++ trunk/extensions/dna-connector-jdbc-metadata/pom.xml	2008-12-08 12:28:33 UTC (rev 663)
@@ -7,10 +7,10 @@
     <relativePath>../..</relativePath>
   </parent>
   <!-- The groupId and version values are inherited from parent -->
-  <artifactId>dna-sequencer-jdbc-metadata</artifactId>
+  <artifactId>dna-connector-jdbc-metadata</artifactId>
   <packaging>jar</packaging>
-  <name>JBoss DNA JDBC Metadata Sequencer</name>
-  <description>JBoss DNA Sequencer that processes JDBC metadata</description>
+  <name>JBoss DNA Connector to JDBC</name>
+  <description>JBoss DNA Connector that processes JDBC metadata</description>
   <url>http://labs.jboss.org/dna</url>
   <dependencies>
     <dependency>

Copied: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector (from rev 662, trunk/extensions/dna-sequencer-jdbc-metadata/src/main/java/org/jboss/dna/sequencer)


Property changes on: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.java
===================================================================
--- trunk/extensions/dna-sequencer-jdbc-metadata/src/main/java/org/jboss/dna/sequencer/jdbc/JdbcMetadataI18n.java	2008-12-05 23:52:47 UTC (rev 662)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.java	2008-12-08 12:28:33 UTC (rev 663)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package org.jboss.dna.sequencer.jdbc;
+package org.jboss.dna.connector.jdbc;
 
 import java.util.Locale;
 import java.util.Set;
@@ -30,7 +30,13 @@
  * @author <a href="mailto:litsenko_sergey at yahoo.com">Sergiy Litsenko</a>
  */
 public class JdbcMetadataI18n {
-    public static I18n sequencerTaskName;
+    public static I18n connectorName;
+    public static I18n nodeDoesNotExist;
+    public static I18n nodeTypeIsNotSupported;
+    public static I18n propertyIsRequired;
+    public static I18n errorSerializingCachePolicyInSource;
+    public static I18n locationInRequestMustHavePath;
+    public static I18n sourceIsReadOnly;
 
     static {
         try {

Added: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositoryLexicon.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositoryLexicon.java	                        (rev 0)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositoryLexicon.java	2008-12-08 12:28:33 UTC (rev 663)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.jdbc;
+
+import org.jboss.dna.graph.properties.Name;
+import org.jboss.dna.graph.properties.basic.BasicName;
+
+
+/**
+ * The namespace and property names used within a {@link JdbcRepositorySource} to store internal information.
+ * 
+ * @author <a href="mailto:litsenko_sergey at yahoo.com">Sergiy Litsenko</a>
+ */
+public class JdbcRepositoryLexicon {
+
+    public static class Namespace {
+        public static final String URI = "http://www.jboss.org/dna/connector/jdbc";
+        public static final String PREFIX = "dnajdbc";
+    }
+
+    public static final Name CHILD_PATH_SEGMENT_LIST = new BasicName(Namespace.URI, "orderedChildNames");
+    public static final Name UUID = new BasicName(Namespace.URI, "uuid");
+}

Added: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java	                        (rev 0)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRepositorySource.java	2008-12-08 12:28:33 UTC (rev 663)
@@ -0,0 +1,310 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.connector.jdbc;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.naming.BinaryRefAddr;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+import javax.naming.spi.ObjectFactory;
+
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.graph.cache.CachePolicy;
+import org.jboss.dna.graph.connectors.RepositoryConnection;
+import org.jboss.dna.graph.connectors.RepositoryContext;
+import org.jboss.dna.graph.connectors.RepositorySource;
+import org.jboss.dna.graph.connectors.RepositorySourceCapabilities;
+import org.jboss.dna.graph.connectors.RepositorySourceException;
+
+/**
+ * A description of a JDBC resource that can be used to access database information. 
+ * 
+ * @author <a href="mailto:litsenko_sergey at yahoo.com">Sergiy Litsenko</a>
+ *
+ */
+public class JdbcRepositorySource implements RepositorySource, ObjectFactory {
+    private static final long serialVersionUID = 1L;
+    /**
+     * The default limit is {@value} for retrying {@link RepositoryConnection connection} calls to the underlying source.
+     */
+    public static final int DEFAULT_RETRY_LIMIT = 0;
+
+    /**
+     * This source supports updates by default, but each instance may be configured to {@link #setSupportsUpdates(boolean) be
+     * read-only or updateable}.
+     */
+    public static final boolean DEFAULT_SUPPORTS_UPDATES = true;
+
+    /**
+     * This source supports events.
+     */
+    protected static final boolean SUPPORTS_EVENTS = true;
+    /**
+     * This source does not support same-name-siblings.
+     */
+    protected static final boolean SUPPORTS_SAME_NAME_SIBLINGS = false;
+    
+    private final AtomicInteger retryLimit = new AtomicInteger(DEFAULT_RETRY_LIMIT);
+    protected String name;
+    protected final Capabilities capabilities = new Capabilities();
+    protected transient RepositoryContext repositoryContext;
+    protected CachePolicy defaultCachePolicy;
+
+    protected static final String SOURCE_NAME = "sourceName";
+    protected static final String DEFAULT_CACHE_POLICY = "defaultCachePolicy";
+    protected static final String REPO_JNDI_NAME = "jndiName";
+    protected static final String REPO_FACTORY_JNDI_NAME = "factoryJndiName";
+    protected static final String RETRY_LIMIT = "retryLimit";
+    
+    /**
+     * default constructor
+     */
+    public JdbcRepositorySource() {
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.jboss.dna.graph.connectors.RepositorySource#getCapabilities()
+     */
+    public RepositorySourceCapabilities getCapabilities() {
+        return capabilities;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.jboss.dna.graph.connectors.RepositorySource#getConnection()
+     */
+    public RepositoryConnection getConnection() throws RepositorySourceException {
+        // TODO create Jdbc connection
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.jboss.dna.graph.connectors.RepositorySource#getName()
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Set the name of this source
+     * 
+     * @param name the name for this source
+     */
+    public void setName( String name ) {
+        this.name = name;
+    }
+    
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.jboss.dna.graph.connectors.RepositorySource#getRetryLimit()
+     */
+    public int getRetryLimit() {
+        return retryLimit.get();
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.jboss.dna.graph.connectors.RepositorySource#initialize(org.jboss.dna.graph.connectors.RepositoryContext)
+     */
+    public void initialize( RepositoryContext context ) throws RepositorySourceException {
+        this.repositoryContext = context;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.jboss.dna.graph.connectors.RepositorySource#setRetryLimit(int)
+     */
+    public void setRetryLimit( int limit ) {
+        retryLimit.set(limit < 0 ? 0 : limit);
+    }
+
+    /**
+     * Get whether this source supports updates.
+     * 
+     * @return true if this source supports updates, or false if this source only supports reading content.
+     */
+    public boolean getSupportsUpdates() {
+        return capabilities.supportsUpdates();
+    }
+
+    /**
+     * Set whether this source supports updates.
+     * 
+     * @param supportsUpdates true if this source supports updating content, or false if this source only supports reading
+     *        content.
+     */
+    public synchronized void setSupportsUpdates( boolean supportsUpdates ) {
+        capabilities.setSupportsUpdates (supportsUpdates);
+    }
+
+    /**
+     * Get the default cache policy for this source, or null if the global default cache policy should be used
+     * 
+     * @return the default cache policy, or null if this source has no explicit default cache policy
+     */
+    public CachePolicy getDefaultCachePolicy() {
+        return defaultCachePolicy;
+    }
+
+    /**
+     * @param defaultCachePolicy Sets defaultCachePolicy to the specified value.
+     */
+    public synchronized void setDefaultCachePolicy( CachePolicy defaultCachePolicy ) {
+        this.defaultCachePolicy = defaultCachePolicy;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean equals( Object obj ) {
+        if (obj == this) return true;
+        if (obj instanceof JdbcRepositorySource) {
+            JdbcRepositorySource that = (JdbcRepositorySource)obj;
+            if (this.getName() == null) {
+                if (that.getName() != null) return false;
+            } else {
+                if (!this.getName().equals(that.getName())) return false;
+            }
+            return true;
+        }
+        return false;
+    }
+    
+    /**
+     * {@inheritDoc}
+     *
+     * @see javax.naming.Referenceable#getReference()
+     */
+    public Reference getReference() throws NamingException {
+        String className = getClass().getName();
+        String factoryClassName = this.getClass().getName();
+        Reference ref = new Reference(className, factoryClassName, null);
+
+        if (getName() != null) {
+            ref.add(new StringRefAddr(SOURCE_NAME, getName()));
+        }
+        if (getDefaultCachePolicy() != null) {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            CachePolicy policy = getDefaultCachePolicy();
+            try {
+                ObjectOutputStream oos = new ObjectOutputStream(baos);
+                oos.writeObject(policy);
+                ref.add(new BinaryRefAddr(DEFAULT_CACHE_POLICY, baos.toByteArray()));
+            } catch (IOException e) {
+                I18n msg = JdbcMetadataI18n.errorSerializingCachePolicyInSource;
+                throw new RepositorySourceException(getName(), msg.text(policy.getClass().getName(), getName()), e);
+            }
+        }
+        ref.add(new StringRefAddr(RETRY_LIMIT, Integer.toString(getRetryLimit())));
+        // return it
+        return ref;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)
+     */
+    public Object getObjectInstance( Object obj,
+                                     Name name,
+                                     Context nameCtx,
+                                     Hashtable<?, ?> environment ) throws Exception {
+        if (obj instanceof Reference) {
+            Map<String, Object> values = new HashMap<String, Object>();
+            Reference ref = (Reference)obj;
+            Enumeration<?> en = ref.getAll();
+            while (en.hasMoreElements()) {
+                RefAddr subref = (RefAddr)en.nextElement();
+                if (subref instanceof StringRefAddr) {
+                    String key = subref.getType();
+                    Object value = subref.getContent();
+                    if (value != null) values.put(key, value.toString());
+                } else if (subref instanceof BinaryRefAddr) {
+                    String key = subref.getType();
+                    Object value = subref.getContent();
+                    if (value instanceof byte[]) {
+                        // Deserialize ...
+                        ByteArrayInputStream bais = new ByteArrayInputStream((byte[])value);
+                        ObjectInputStream ois = new ObjectInputStream(bais);
+                        value = ois.readObject();
+                        values.put(key, value);
+                    }
+                }
+            }
+            String sourceName = (String)values.get(SOURCE_NAME);
+            Object defaultCachePolicy = values.get(DEFAULT_CACHE_POLICY);
+            String retryLimit = (String)values.get(RETRY_LIMIT);
+
+            // Create the source instance ...
+            JdbcRepositorySource source = new JdbcRepositorySource();
+            if (sourceName != null) source.setName(sourceName);
+            if (defaultCachePolicy instanceof CachePolicy) {
+                source.setDefaultCachePolicy((CachePolicy)defaultCachePolicy);
+            }
+            if (retryLimit != null) source.setRetryLimit(Integer.parseInt(retryLimit));
+            return source;
+        }
+        return null;
+    }
+
+    @ThreadSafe
+    protected class Capabilities extends RepositorySourceCapabilities {
+        private final AtomicBoolean supportsUpdates = new AtomicBoolean(DEFAULT_SUPPORTS_UPDATES);
+
+        /*package*/Capabilities() {
+            super(DEFAULT_SUPPORTS_UPDATES, SUPPORTS_EVENTS);
+        }
+
+        /*package*/void setSupportsUpdates( boolean supportsUpdates ) {
+            this.supportsUpdates.set(supportsUpdates);
+        }
+
+        @Override
+        public boolean supportsUpdates() {
+            return this.supportsUpdates.get();
+        }
+    }
+}

Added: trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.properties
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.properties	                        (rev 0)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/resources/org/jboss/dna/connector/jdbc/JdbcMetadataI18n.properties	2008-12-08 12:28:33 UTC (rev 663)
@@ -0,0 +1,29 @@
+#
+# JBoss, Home of Professional Open Source.
+# Copyright 2008, Red Hat Middleware LLC, and individual contributors
+# as indicated by the @author tags. See the copyright.txt file in the
+# distribution for a full listing of individual contributors.
+#
+# This 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 software 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 software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+
+connectorName = JDBC Connector
+nodeDoesNotExist = This node kind is missing at {0}
+nodeTypeIsNotSupported= The {0} node type is not supported
+locationInRequestMustHavePath = Location must have a path {0}
+propertyIsRequired = The {0} property is required but has no value
+errorSerializingCachePolicyInSource = Error serializing a {0} instance owned by the {1} JdbcRepositorySource
+sourceIsReadOnly = {0} is a read-only source; no updates are allowed
\ No newline at end of file




More information about the dna-commits mailing list