[jboss-cvs] JBossAS SVN: r95770 - in projects/metadata/common/trunk/src/main/java: javax and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 29 13:09:06 EDT 2009


Author: remy.maucherat at jboss.com
Date: 2009-10-29 13:09:06 -0400 (Thu, 29 Oct 2009)
New Revision: 95770

Added:
   projects/metadata/common/trunk/src/main/java/javax/
   projects/metadata/common/trunk/src/main/java/javax/annotation/
   projects/metadata/common/trunk/src/main/java/javax/annotation/sql/
   projects/metadata/common/trunk/src/main/java/javax/annotation/sql/DataSourceDefinition.java
   projects/metadata/common/trunk/src/main/java/javax/annotation/sql/DataSourceDefinitions.java
   projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionProcessor.java
   projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionsProcessor.java
Removed:
   projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionProcessor.jav
   projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionsProcessor.jav
Modified:
   projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java
Log:
- Add the two annotations for now. Will remove when they are integrated in a better location.

Added: projects/metadata/common/trunk/src/main/java/javax/annotation/sql/DataSourceDefinition.java
===================================================================
--- projects/metadata/common/trunk/src/main/java/javax/annotation/sql/DataSourceDefinition.java	                        (rev 0)
+++ projects/metadata/common/trunk/src/main/java/javax/annotation/sql/DataSourceDefinition.java	2009-10-29 17:09:06 UTC (rev 95770)
@@ -0,0 +1,278 @@
+/*
+ * The contents of this file are subject to the terms 
+ * of the Common Development and Distribution License 
+ * (the "License").  You may not use this file except 
+ * in compliance with the License.
+ * 
+ * You can obtain a copy of the license at 
+ * glassfish/bootstrap/legal/CDDLv1.0.txt or 
+ * https://glassfish.dev.java.net/public/CDDLv1.0.html. 
+ * See the License for the specific language governing 
+ * permissions and limitations under the License.
+ * 
+ * When distributing Covered Code, include this CDDL 
+ * HEADER in each file and include the License file at 
+ * glassfish/bootstrap/legal/CDDLv1.0.txt.  If applicable, 
+ * add the following below this CDDL HEADER, with the 
+ * fields enclosed by brackets "[]" replaced with your 
+ * own identifying information: Portions Copyright [yyyy] 
+ * [name of copyright owner]
+ */
+
+/*
+ *
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
+ */
+
+
+package javax.annotation.sql;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Annotation used to define a container <code>DataSource</code> and
+ * be registered with JNDI. The <code>DataSource</code> may be configured by
+ * setting the annotation elements for commonly used <code>DataSource</code>
+ * properties.  Additional standard and vendor-specific properties may be
+ * specified using the <code>properties</code> element.
+ * <p>
+ *
+ * The data source will be registered under the name specified in the
+ * <code>name</code> element. It may be defined to be in any valid
+ * <code>Java EE</code> namespace, and will determine the accessibility of
+ * the data source from other components.
+ * <p>
+ * A JDBC driver implementation class of the appropriate type, either
+ * <code>DataSource</code>, <code>ConnectionPoolDataSource</code>, or
+ * <code>XADataSource</code>, must be indicated by the <code>className</code>
+ * element. The availability of the driver class will be assumed at runtime.
+ *<p>
+ * The <code>url</code> property should not be specified in conjunction with
+ * other standard properties for defining the connectivity to the database.
+ * If the <code>url</code> property is specified along with other standard
+ * <code>DataSource</code> properties
+ * such as <code>serverName</code> and <code>portNumber</code>, the more
+ * specific properties will take precedence and <code>url</code> will be
+ * ignored.
+ * <p>
+ * Vendors are not required to support properties that do not normally
+ * apply to a specific data source type. For example, specifying the
+ * <code>transactional</code> property to be <code>true</code> but supplying
+ * a value for <code>className</code> that implements a data source class
+ * other than <code>XADataSource</code> may not be supported.
+ * <p>
+ * Vendor-specific properties may be combined with or used to
+ *  override standard data source properties defined using this annotation.
+ * <p>
+ * <code>DataSource</code> properties that are specified and are not supported
+ * in a given configuration or cannot be mapped to a vendor specific
+ * configuration property may be ignored.
+ * <p>
+ * Examples:
+ * <br>
+ *  <pre>
+ *   &#064;DataSourceDefinition(name="java:global/MyApp/MyDataSource",
+ *      className="com.foobar.MyDataSource",
+ *      portNumber=6689,
+ *      serverName="myserver.com",
+ *      user="lance",
+ *      password="secret"
+ *   )
+ * 
+ * </pre>
+ * <p>
+ * Using a <code>URL</code>:
+ * <br>
+ * <pre>
+ *  &#064;DataSourceDefinition(name="java:global/MyApp/MyDataSource",
+ *    className="org.apache.derby.jdbc.ClientDataSource",
+ *    url="jdbc:derby://localhost:1527/myDB",
+ *    user="lance",
+ *    password="secret"
+ * )
+ * </pre>
+ * <p>
+ * An example lookup of the {@link DataSource} from an EJB:
+ * <pre>
+ * &#064;Stateless
+ * public class MyStatelessEJB {
+ *   &#064;Resource(lookup="java:global/MyApp/myDataSource")
+ *    DataSource myDB;
+ *      ...
+ * }
+ * </pre>
+ * <p>
+ * @see javax.sql.DataSource
+ * @see javax.sql.XADataSource
+ * @see javax.sql.ConnectionPoolDataSource
+ * @since Common Annotations 1.1
+ */
+ at Target({ElementType.TYPE})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface DataSourceDefinition {
+
+    /**
+     * JNDI name by which the data source will be registered.
+     * @since 1.1
+     */
+     String name();
+
+    /**
+     * DataSource implementation class name which implements:
+     *  <code>javax.sql.DataSource</code> or <code>javax.sql.XADataSource</code>
+     * or <code>javax.sql.ConnectionPoolDataSource</code>.
+     * @since 1.1
+     */
+    String className();
+
+    /**
+     * Description of this data source
+     * @since 1.1
+     */
+    String description() default "";
+
+    /**
+     * A JDBC URL.  If the <code>url</code> property is specified along with
+     * other standard <code>DataSource</code> properties
+     * such as <code>serverName</code> and <code>portNumber</code>, the more
+     * specific properties will take precedence and <code>url</code> will be
+     * ignored.
+     * @since 1.1
+     */
+    String url() default "";
+
+    /**
+     * User name to use for connection authentication.
+     * @since 1.1
+     */
+    String user() default "";
+
+    /**
+     * Password to use for connection authentication.
+     * @since 1.1
+     */
+    String password() default "";
+
+    /**
+     * Name of a database on a server.
+     * @since 1.1
+     */
+    String databaseName() default "";
+
+    /**
+     * Port number where a server is listening for requests.
+     * @since 1.1
+     */
+    int portNumber() default -1;
+
+    /**
+     * Database server name.
+     * @since 1.1
+     */
+    String serverName() default "localhost";
+
+    /**
+     * Isolation level for connections. The Isolation level 
+     * must be one of the following:
+     * <p>
+     * <ul>
+     * <li>Connection.TRANSACTION_NONE,
+     * <li>Connection.TRANSACTION_READ_ UNCOMMITTED,
+     * <li>Connection.TRANSACTION_READ_COMMITTED,
+     * <li>Connection.TRANSACTION_REPEATABLE_READ,
+     * <li>Connection.TRANSACTION_SERIALIZABLE
+     *</ul>
+     * <p>
+     * Default is vendor-specific.
+     * @since 1.1
+     */
+    int isolationLevel() default -1;
+
+    /**
+     * Set to <code>false</code> if connections should not participate
+     * in transactions.
+     * <p>
+     * Default is to enlist in a transaction when one is active or becomes
+     * active.
+     * @since 1.1
+     */
+    boolean transactional() default true;
+
+    /**
+     * Number of connections that should be created when a connection pool
+     * is initialized.
+     * <p>
+     * Default is vendor-specific
+     * @since 1.1
+     */
+    int initialPoolSize() default -1;
+
+    /**
+     * Maximum number of connections that should be concurrently allocated for a
+     * connection pool.
+     * <p>
+     * Default is vendor-specific.
+     * @since 1.1
+     */
+    int maxPoolSize() default -1;
+
+    /**
+     * Minimum number of connections that should be allocated for a
+     * connection pool.
+     * <p>
+     * Default is vendor-specific.
+     * @since 1.1
+     */
+    int minPoolSize() default -1;
+
+    /**
+     * The number of seconds that a physical connection
+     * should remain unused in the pool before the
+     * connection is closed for a connection pool.
+     * <p>
+     * Default is vendor-specific
+     * @since 1.1
+     */
+    int maxIdleTime() default -1;
+
+    /**
+     * The total number of statements that a connection pool should keep open.
+     * A value of 0 indicates that the caching of statements is disabled for
+     * a connection pool.
+     * <p>
+     * Default is vendor-specific
+     * @since 1.1
+     */
+    int maxStatements() default -1;
+    /**
+     *  Used to specify  Vendor specific properties and less commonly
+     * used <code>DataSource</code> properties such as:
+     * <p>
+     * <ul>
+     * <li>dataSourceName
+     * <li>networkProtocol
+     * <li>propertyCycle
+     * <li>roleName
+     * </ul>
+     * <p>
+     *  Properties are specified using the format:
+     *  <i>propertyName=propertyValue</i>  with one property per array element.
+     * @since 1.1
+     */
+    String[] properties() default {};
+
+
+    /**
+     * Sets the maximum time in seconds that this data source will wait while
+     * attempting to connect to a database. A value of zero specifies that
+     * the timeout is the default system timeout if there is one; otherwise,
+     * it specifies that there is no timeout.
+     * <p>
+     * Default is vendor-specific.
+     * @since 1.1
+     */
+    int loginTimeout() default 0;
+}

Added: projects/metadata/common/trunk/src/main/java/javax/annotation/sql/DataSourceDefinitions.java
===================================================================
--- projects/metadata/common/trunk/src/main/java/javax/annotation/sql/DataSourceDefinitions.java	                        (rev 0)
+++ projects/metadata/common/trunk/src/main/java/javax/annotation/sql/DataSourceDefinitions.java	2009-10-29 17:09:06 UTC (rev 95770)
@@ -0,0 +1,46 @@
+/*
+ * The contents of this file are subject to the terms 
+ * of the Common Development and Distribution License 
+ * (the "License").  You may not use this file except 
+ * in compliance with the License.
+ * 
+ * You can obtain a copy of the license at 
+ * glassfish/bootstrap/legal/CDDLv1.0.txt or 
+ * https://glassfish.dev.java.net/public/CDDLv1.0.html. 
+ * See the License for the specific language governing 
+ * permissions and limitations under the License.
+ * 
+ * When distributing Covered Code, include this CDDL 
+ * HEADER in each file and include the License file at 
+ * glassfish/bootstrap/legal/CDDLv1.0.txt.  If applicable, 
+ * add the following below this CDDL HEADER, with the 
+ * fields enclosed by brackets "[]" replaced with your 
+ * own identifying information: Portions Copyright [yyyy] 
+ * [name of copyright owner]
+ */
+
+/*
+ *
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
+ */
+
+
+package javax.annotation.sql;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Declares one or more <code>DataSourceDefinition</code> annotations.
+ * 
+ * @see javax.annotation.sql.DataSourceDefinition
+ * @since Common Annotations 1.1
+ */
+ at Target({ElementType.TYPE})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface DataSourceDefinitions {
+    DataSourceDefinition[] value ();
+
+}

Modified: projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java
===================================================================
--- projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java	2009-10-29 16:58:22 UTC (rev 95769)
+++ projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/AbstractComponentProcessor.java	2009-10-29 17:09:06 UTC (rev 95770)
@@ -81,8 +81,8 @@
       addTypeProcessor(new WebServiceRefClassProcessor(finder));
       addTypeProcessor(new WebServiceRefsClassProcessor(finder));
       // @DataSourceDefinitions/@DataSourceDefinition
-      //addTypeProcessor(new DataSourceDefinitionProcessor(finder));
-      //addTypeProcessor(new DataSourceDefinitionsProcessor(finder));
+      addTypeProcessor(new DataSourceDefinitionProcessor(finder));
+      addTypeProcessor(new DataSourceDefinitionsProcessor(finder));
    }
 
    /**

Deleted: projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionProcessor.jav
===================================================================
--- projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionProcessor.jav	2009-10-29 16:58:22 UTC (rev 95769)
+++ projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionProcessor.jav	2009-10-29 17:09:06 UTC (rev 95770)
@@ -1,151 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt 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.metadata.annotation.creator;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.sql.Connection;
-import java.util.Collection;
-
-import javax.annotation.sql.DataSourceDefinition;
-
-import org.jboss.annotation.javaee.Descriptions;
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.javaee.spec.DataSourceMetaData;
-import org.jboss.metadata.javaee.spec.DataSourcesMetaData;
-import org.jboss.metadata.javaee.spec.IsolationLevelType;
-import org.jboss.metadata.javaee.spec.PropertiesMetaData;
-import org.jboss.metadata.javaee.spec.PropertyMetaData;
-
-/**
- * Processor for DataSourceDefinition
- * @author Remy Maucherat
- * @version $Revision: 67218 $
- */
-public class DataSourceDefinitionProcessor extends AbstractFinderUser
-   implements Processor<DataSourcesMetaData, Class<?>>, Creator<Class<?>, DataSourceMetaData>
-{
-   public DataSourceDefinitionProcessor(AnnotationFinder<AnnotatedElement> finder)
-   {
-      super(finder);
-   }
-
-   public void process(DataSourcesMetaData metaData, Class<?> type)
-   {
-      DataSourceDefinition annotation = finder.getAnnotation(type, DataSourceDefinition.class);
-      if(annotation == null)
-         return;
-
-      process(metaData, type, annotation);
-   }
-   
-   public void process(DataSourcesMetaData metaData, Class<?> type, DataSourceDefinition annotation)
-   {
-      DataSourceMetaData dataSource = create(type);
-      metaData.add(dataSource);
-   }
-   
-   public DataSourceMetaData create(Class<?> element)
-   {
-      DataSourceDefinition dataSource = finder.getAnnotation(element, DataSourceDefinition.class);
-      if (dataSource == null)
-         return null;
-
-      DataSourceMetaData metaData = new DataSourceMetaData();
-      metaData.setName(dataSource.name());
-      metaData.setClassName(dataSource.className());
-      Descriptions descriptions = ProcessorUtils.getDescription(dataSource.description());
-      if (descriptions != null)
-         metaData.setDescriptions(descriptions);
-      if (dataSource.url().length() > 0)
-         metaData.setUrl(dataSource.url());
-      if (dataSource.user().length() > 0)
-         metaData.setUser(dataSource.user());
-      if (dataSource.password().length() > 0)
-         metaData.setPassword(dataSource.password());
-      if (dataSource.databaseName().length() > 0)
-         metaData.setDatabaseName(dataSource.databaseName());
-      if (dataSource.portNumber() != -1)
-         metaData.setPortNumber(dataSource.portNumber());
-      if (!dataSource.serverName().equals("localhost"))
-         metaData.setServerName(dataSource.serverName());
-      if (dataSource.isolationLevel() != -1)
-      {
-         switch (dataSource.isolationLevel())
-         {
-         case Connection.TRANSACTION_NONE:
-            break;
-         case Connection.TRANSACTION_READ_UNCOMMITTED:
-            metaData.setIsolationLevel(IsolationLevelType.TRANSACTION_READ_UNCOMMITTED);
-            break;
-         case Connection.TRANSACTION_READ_COMMITTED:
-            metaData.setIsolationLevel(IsolationLevelType.TRANSACTION_READ_COMMITTED);
-            break;
-         case Connection.TRANSACTION_REPEATABLE_READ:
-            metaData.setIsolationLevel(IsolationLevelType.TRANSACTION_REPEATABLE_READ);
-            break;
-         case Connection.TRANSACTION_SERIALIZABLE:
-            metaData.setIsolationLevel(IsolationLevelType.TRANSACTION_SERIALIZABLE);
-            break;
-         default:
-            break;
-         }
-      }
-      metaData.setTransactional(dataSource.transactional());
-      if (dataSource.initialPoolSize() != -1)
-         metaData.setInitialPoolSize(dataSource.initialPoolSize());
-      if (dataSource.maxPoolSize() != -1)
-         metaData.setMaxPoolSize(dataSource.maxPoolSize());
-      if (dataSource.minPoolSize() != -1)
-         metaData.setMinPoolSize(dataSource.minPoolSize());
-      if (dataSource.maxIdleTime() != -1)
-         metaData.setMaxIdleTime(dataSource.maxIdleTime());
-      if (dataSource.maxStatements() != -1)
-         metaData.setMaxStatements(dataSource.maxStatements());
-      if (dataSource.properties().length > 0)
-      {
-         PropertiesMetaData properties = new PropertiesMetaData();
-         for (String propertyString : dataSource.properties())
-         {
-            int pos = propertyString.indexOf('=');
-            if (pos != -1)
-            {
-               PropertyMetaData property = new PropertyMetaData();
-               property.setName(propertyString.substring(0, pos));
-               property.setValue(propertyString.substring(pos + 1));
-               properties.add(property);
-            }
-         }
-         metaData.setProperties(properties);
-      }
-      if (dataSource.loginTimeout() != 0)
-         metaData.setLoginTimeout(dataSource.loginTimeout());
-      return metaData;
-      
-   }
-
-   public Collection<Class<? extends Annotation>> getAnnotationTypes()
-   {
-      return ProcessorUtils.createAnnotationSet(DataSourceDefinition.class);
-   }
-   
-}

Added: projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionProcessor.java
===================================================================
--- projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionProcessor.java	                        (rev 0)
+++ projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionProcessor.java	2009-10-29 17:09:06 UTC (rev 95770)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.metadata.annotation.creator;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.sql.Connection;
+import java.util.Collection;
+
+import javax.annotation.sql.DataSourceDefinition;
+
+import org.jboss.annotation.javaee.Descriptions;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.DataSourceMetaData;
+import org.jboss.metadata.javaee.spec.DataSourcesMetaData;
+import org.jboss.metadata.javaee.spec.IsolationLevelType;
+import org.jboss.metadata.javaee.spec.PropertiesMetaData;
+import org.jboss.metadata.javaee.spec.PropertyMetaData;
+
+/**
+ * Processor for DataSourceDefinition
+ * @author Remy Maucherat
+ * @version $Revision: 67218 $
+ */
+public class DataSourceDefinitionProcessor extends AbstractFinderUser
+   implements Processor<DataSourcesMetaData, Class<?>>, Creator<Class<?>, DataSourceMetaData>
+{
+   public DataSourceDefinitionProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+
+   public void process(DataSourcesMetaData metaData, Class<?> type)
+   {
+      DataSourceDefinition annotation = finder.getAnnotation(type, DataSourceDefinition.class);
+      if(annotation == null)
+         return;
+
+      process(metaData, type, annotation);
+   }
+   
+   public void process(DataSourcesMetaData metaData, Class<?> type, DataSourceDefinition annotation)
+   {
+      DataSourceMetaData dataSource = create(type);
+      metaData.add(dataSource);
+   }
+   
+   public DataSourceMetaData create(Class<?> element)
+   {
+      DataSourceDefinition dataSource = finder.getAnnotation(element, DataSourceDefinition.class);
+      if (dataSource == null)
+         return null;
+
+      DataSourceMetaData metaData = new DataSourceMetaData();
+      metaData.setName(dataSource.name());
+      metaData.setClassName(dataSource.className());
+      Descriptions descriptions = ProcessorUtils.getDescription(dataSource.description());
+      if (descriptions != null)
+         metaData.setDescriptions(descriptions);
+      if (dataSource.url().length() > 0)
+         metaData.setUrl(dataSource.url());
+      if (dataSource.user().length() > 0)
+         metaData.setUser(dataSource.user());
+      if (dataSource.password().length() > 0)
+         metaData.setPassword(dataSource.password());
+      if (dataSource.databaseName().length() > 0)
+         metaData.setDatabaseName(dataSource.databaseName());
+      if (dataSource.portNumber() != -1)
+         metaData.setPortNumber(dataSource.portNumber());
+      if (!dataSource.serverName().equals("localhost"))
+         metaData.setServerName(dataSource.serverName());
+      if (dataSource.isolationLevel() != -1)
+      {
+         switch (dataSource.isolationLevel())
+         {
+         case Connection.TRANSACTION_NONE:
+            break;
+         case Connection.TRANSACTION_READ_UNCOMMITTED:
+            metaData.setIsolationLevel(IsolationLevelType.TRANSACTION_READ_UNCOMMITTED);
+            break;
+         case Connection.TRANSACTION_READ_COMMITTED:
+            metaData.setIsolationLevel(IsolationLevelType.TRANSACTION_READ_COMMITTED);
+            break;
+         case Connection.TRANSACTION_REPEATABLE_READ:
+            metaData.setIsolationLevel(IsolationLevelType.TRANSACTION_REPEATABLE_READ);
+            break;
+         case Connection.TRANSACTION_SERIALIZABLE:
+            metaData.setIsolationLevel(IsolationLevelType.TRANSACTION_SERIALIZABLE);
+            break;
+         default:
+            break;
+         }
+      }
+      metaData.setTransactional(dataSource.transactional());
+      if (dataSource.initialPoolSize() != -1)
+         metaData.setInitialPoolSize(dataSource.initialPoolSize());
+      if (dataSource.maxPoolSize() != -1)
+         metaData.setMaxPoolSize(dataSource.maxPoolSize());
+      if (dataSource.minPoolSize() != -1)
+         metaData.setMinPoolSize(dataSource.minPoolSize());
+      if (dataSource.maxIdleTime() != -1)
+         metaData.setMaxIdleTime(dataSource.maxIdleTime());
+      if (dataSource.maxStatements() != -1)
+         metaData.setMaxStatements(dataSource.maxStatements());
+      if (dataSource.properties().length > 0)
+      {
+         PropertiesMetaData properties = new PropertiesMetaData();
+         for (String propertyString : dataSource.properties())
+         {
+            int pos = propertyString.indexOf('=');
+            if (pos != -1)
+            {
+               PropertyMetaData property = new PropertyMetaData();
+               property.setName(propertyString.substring(0, pos));
+               property.setValue(propertyString.substring(pos + 1));
+               properties.add(property);
+            }
+         }
+         metaData.setProperties(properties);
+      }
+      if (dataSource.loginTimeout() != 0)
+         metaData.setLoginTimeout(dataSource.loginTimeout());
+      return metaData;
+      
+   }
+
+   public Collection<Class<? extends Annotation>> getAnnotationTypes()
+   {
+      return ProcessorUtils.createAnnotationSet(DataSourceDefinition.class);
+   }
+   
+}

Deleted: projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionsProcessor.jav
===================================================================
--- projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionsProcessor.jav	2009-10-29 16:58:22 UTC (rev 95769)
+++ projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionsProcessor.jav	2009-10-29 17:09:06 UTC (rev 95770)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt 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.metadata.annotation.creator;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.util.Collection;
-
-import javax.annotation.sql.DataSourceDefinition;
-import javax.annotation.sql.DataSourceDefinitions;
-
-import org.jboss.metadata.annotation.finder.AnnotationFinder;
-import org.jboss.metadata.javaee.spec.DataSourcesMetaData;
-
-/**
- * Processor for DataSourceDefinitions
- * @author Remy Maucherat
- * @version $Revision: 67218 $
- */
-public class DataSourceDefinitionsProcessor extends DataSourceDefinitionProcessor
-{
-   public DataSourceDefinitionsProcessor(AnnotationFinder<AnnotatedElement> finder)
-   {
-      super(finder);
-   }
-
-   public void process(DataSourcesMetaData metaData, Class<?> type)
-   {
-      DataSourceDefinitions annotation = finder.getAnnotation(type, DataSourceDefinitions.class);
-      if(annotation == null)
-         return;
-
-      DataSourceDefinition[] dataSources = annotation.value();
-      if(dataSources != null)
-      {
-         for(DataSourceDefinition res : dataSources)
-            super.process(metaData, type, res);
-      }
-   }
-
-   public Collection<Class<? extends Annotation>> getAnnotationTypes()
-   {
-      return ProcessorUtils.createAnnotationSet(DataSourceDefinitions.class);
-   }
-   
-}

Added: projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionsProcessor.java
===================================================================
--- projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionsProcessor.java	                        (rev 0)
+++ projects/metadata/common/trunk/src/main/java/org/jboss/metadata/annotation/creator/DataSourceDefinitionsProcessor.java	2009-10-29 17:09:06 UTC (rev 95770)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.metadata.annotation.creator;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+
+import javax.annotation.sql.DataSourceDefinition;
+import javax.annotation.sql.DataSourceDefinitions;
+
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.javaee.spec.DataSourcesMetaData;
+
+/**
+ * Processor for DataSourceDefinitions
+ * @author Remy Maucherat
+ * @version $Revision: 67218 $
+ */
+public class DataSourceDefinitionsProcessor extends DataSourceDefinitionProcessor
+{
+   public DataSourceDefinitionsProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+
+   public void process(DataSourcesMetaData metaData, Class<?> type)
+   {
+      DataSourceDefinitions annotation = finder.getAnnotation(type, DataSourceDefinitions.class);
+      if(annotation == null)
+         return;
+
+      DataSourceDefinition[] dataSources = annotation.value();
+      if(dataSources != null)
+      {
+         for(DataSourceDefinition res : dataSources)
+            super.process(metaData, type, res);
+      }
+   }
+
+   public Collection<Class<? extends Annotation>> getAnnotationTypes()
+   {
+      return ProcessorUtils.createAnnotationSet(DataSourceDefinitions.class);
+   }
+   
+}




More information about the jboss-cvs-commits mailing list