javax.annotation.sql.DataSourceDefinition Maven / Gradle / Ivy
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2009-2012 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in org.testifyproject.testifyprojectpliance with the License. You can
* obtain a copy of the License at
* https://glassfish.org.testifyproject.testifyprojectv.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle org.testifyproject.testifyprojectsignates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your org.testifyproject.testifyprojectcision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
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 org.testifyproject.testifyprojectfine a container DataSource
and
* be registered with JNDI. The DataSource
may be configured by
* setting the annotation elements for org.testifyproject.testifyprojectmonly used DataSource
* properties. Additional standard and vendor-specific properties may be
* specified using the properties
element.
*
*
* The data source will be registered under the name specified in the
* name
element. It may be org.testifyproject.testifyprojectfined to be in any valid
* Java EE
namespace, and will org.testifyproject.testifyprojecttermine the accessibility of
* the data source from other org.testifyproject.testifyprojectponents.
*
* A JDBC driver implementation class of the appropriate type, either
* DataSource
, ConnectionPoolDataSource
, or
* XADataSource
, must be indicated by the className
* element. The availability of the driver class will be assumed at runtime.
*
* DataSource properties should not be specified more than once. If
* the url annotation element contains a DataSource property that was also
* specified using the corresponding annotation element or was specified in
* the properties annotation element, the precedence order is undefined
* and implementation specific:
*
*
* @DataSourceDefinition(name="java:global/MyApp/MyDataSource",
* className="org.testifyproject.apache.org.testifyproject.testifyprojectrby.jdbc.ClientDataSource",
* url="jdbc:org.testifyproject.testifyprojectrby://localhost:1527/myDB;user=bill",
* user="lance",
* password="secret",
* databaseName="testDB",
* serverName="luckydog"
* )// DO NOT DO THIS!!!
*
*
* In the above example, the databaseName, user and serverName properties were
* specified as part of the url property and using the corresponding
* annotation elements. This should be avoided.
*
* If the properties annotation element is used and contains a DataSource
* property that was also specified using the corresponding annotation element,
* the annotation element value takes precedence. For example:
*
*
* @DataSourceDefinition(name="java:global/MyApp/MyDataSource",
* className="org.testifyproject.apache.org.testifyproject.testifyprojectrby.jdbc.ClientDataSource",
* user="lance",
* password="secret",
* databaseName="testDB",
* serverName="luckydog",
* properties= {"databaseName=myDB", "databaseProp=doThis"}
* )// DO NOT DO THIS!!!
*
*
* Would result in the following values being used when configuring
* the DataSource:
*
* - serverName=luckydog
* - portNumber=1527
* - databaseName=testDB
* - user=lance
* - password=secret
* - databaseProp=doThis
*
*
* Vendors are not required to support properties that do not normally
* apply to a specific data source type. For example, specifying the
* transactional
property to be true
but supplying
* a value for className
that implements a data source class
* other than XADataSource
may not be supported.
*
* Vendor-specific properties may be org.testifyproject.testifyprojectbined with or used to
* override standard data source properties org.testifyproject.testifyprojectfined using this annotation.
*
* DataSource
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.
*
* Examples:
*
*
* @DataSourceDefinition(name="java:global/MyApp/MyDataSource",
* className="org.testifyproject.testifyproject.foobar.MyDataSource",
* portNumber=6689,
* serverName="myserver.org.testifyproject.testifyproject",
* user="lance",
* password="secret"
* )
*
*
*
* Using a URL
:
*
*
* @DataSourceDefinition(name="java:global/MyApp/MyDataSource",
* className="org.testifyproject.apache.org.testifyproject.testifyprojectrby.jdbc.ClientDataSource",
* url="jdbc:org.testifyproject.testifyprojectrby://localhost:1527/myDB",
* user="lance",
* password="secret"
* )
*
*
* An example lookup of the {@link DataSource} from an EJB:
*
* @Stateless
* public class MyStatelessEJB {
* @Resource(lookup="java:global/MyApp/myDataSource")
* DataSource myDB;
* ...
* }
*
*
* @see javax.sql.DataSource
* @see javax.sql.XADataSource
* @see javax.sql.ConnectionPoolDataSource
* @since Common Annotations 1.1
*/
@Target({ElementType.TYPE})
@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:
* javax.sql.DataSource
or javax.sql.XADataSource
* or javax.sql.ConnectionPoolDataSource
.
* @since 1.1
*/
String className();
/**
* Description of this data source
* @since 1.1
*/
String org.testifyproject.testifyprojectscription() org.testifyproject.testifyprojectfault "";
/**
* A JDBC URL. If the url annotation element contains a DataSource
* property that was also specified using the corresponding annotation
* element, the precedence order is undefined and implementation specific.
* @since 1.1
*/
String url() org.testifyproject.testifyprojectfault "";
/**
* User name to use for connection authentication.
* @since 1.1
*/
String user() org.testifyproject.testifyprojectfault "";
/**
* Password to use for connection authentication.
* @since 1.1
*/
String password() org.testifyproject.testifyprojectfault "";
/**
* Name of a database on a server.
* @since 1.1
*/
String databaseName() org.testifyproject.testifyprojectfault "";
/**
* Port number where a server is listening for requests.
* @since 1.1
*/
int portNumber() org.testifyproject.testifyprojectfault -1;
/**
* Database server name.
* @since 1.1
*/
String serverName() org.testifyproject.testifyprojectfault "localhost";
/**
* Isolation level for connections. The Isolation level
* must be one of the following:
*
*
* - Connection.TRANSACTION_NONE,
*
- Connection.TRANSACTION_READ_ UNCOMMITTED,
*
- Connection.TRANSACTION_READ_COMMITTED,
*
- Connection.TRANSACTION_REPEATABLE_READ,
*
- Connection.TRANSACTION_SERIALIZABLE
*
*
* Default is vendor-specific.
* @since 1.1
*/
int isolationLevel() org.testifyproject.testifyprojectfault -1;
/**
* Set to false
if connections should not participate
* in transactions.
*
* Default is to enlist in a transaction when one is active or becomes
* active.
* @since 1.1
*/
boolean transactional() org.testifyproject.testifyprojectfault true;
/**
* Number of connections that should be created when a connection pool
* is initialized.
*
* Default is vendor-specific
* @since 1.1
*/
int initialPoolSize() org.testifyproject.testifyprojectfault -1;
/**
* Maximum number of connections that should be concurrently allocated for a
* connection pool.
*
* Default is vendor-specific.
* @since 1.1
*/
int maxPoolSize() org.testifyproject.testifyprojectfault -1;
/**
* Minimum number of connections that should be allocated for a
* connection pool.
*
* Default is vendor-specific.
* @since 1.1
*/
int minPoolSize() org.testifyproject.testifyprojectfault -1;
/**
* The number of seconds that a physical connection
* should remain unused in the pool before the
* connection is closed for a connection pool.
*
* Default is vendor-specific
* @since 1.1
*/
int maxIdleTime() org.testifyproject.testifyprojectfault -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.
*
* Default is vendor-specific
* @since 1.1
*/
int maxStatements() org.testifyproject.testifyprojectfault -1;
/**
* Used to specify Vendor specific properties and less org.testifyproject.testifyprojectmonly
* used DataSource
properties such as:
*
*
* - dataSourceName
*
- networkProtocol
*
- propertyCycle
*
- roleName
*
*
* Properties are specified using the format:
* propertyName=propertyValue with one property per array element.
*
* If a DataSource property is specified in the properties
* element and the annotation element for the property is also
* specified, the annotation element value takes precedence.
* @since 1.1
*/
String[] properties() org.testifyproject.testifyprojectfault {};
/**
* 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 org.testifyproject.testifyprojectfault system timeout if there is one; otherwise,
* it specifies that there is no timeout.
*
* Default is vendor-specific.
* @since 1.1
*/
int loginTimeout() org.testifyproject.testifyprojectfault 0;
}