| 1 | /* |
|---|
| 2 | * $Id$ |
|---|
| 3 | * |
|---|
| 4 | * Copyright 2006, The jCoderZ.org Project. All rights reserved. |
|---|
| 5 | * |
|---|
| 6 | * Redistribution and use in source and binary forms, with or without |
|---|
| 7 | * modification, are permitted provided that the following conditions are |
|---|
| 8 | * met: |
|---|
| 9 | * |
|---|
| 10 | * * Redistributions of source code must retain the above copyright |
|---|
| 11 | * notice, this list of conditions and the following disclaimer. |
|---|
| 12 | * * Redistributions in binary form must reproduce the above |
|---|
| 13 | * copyright notice, this list of conditions and the following |
|---|
| 14 | * disclaimer in the documentation and/or other materials |
|---|
| 15 | * provided with the distribution. |
|---|
| 16 | * * Neither the name of the jCoderZ.org Project nor the names of |
|---|
| 17 | * its contributors may be used to endorse or promote products |
|---|
| 18 | * derived from this software without specific prior written |
|---|
| 19 | * permission. |
|---|
| 20 | * |
|---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND |
|---|
| 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|---|
| 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS |
|---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
|---|
| 28 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|---|
| 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
|---|
| 30 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
|---|
| 31 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 32 | */ |
|---|
| 33 | package org.jcoderz.commons.connector; |
|---|
| 34 | |
|---|
| 35 | import java.io.Serializable; |
|---|
| 36 | |
|---|
| 37 | import javax.naming.NamingException; |
|---|
| 38 | import javax.naming.Reference; |
|---|
| 39 | import javax.resource.Referenceable; |
|---|
| 40 | import javax.resource.ResourceException; |
|---|
| 41 | import javax.resource.cci.Connection; |
|---|
| 42 | import javax.resource.cci.ConnectionFactory; |
|---|
| 43 | import javax.resource.cci.ConnectionSpec; |
|---|
| 44 | import javax.resource.cci.RecordFactory; |
|---|
| 45 | import javax.resource.cci.ResourceAdapterMetaData; |
|---|
| 46 | import javax.resource.spi.ConnectionManager; |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | /** |
|---|
| 50 | * This Factory implements the {@link javax.resource.cci.ConnectionFactory} |
|---|
| 51 | * interface and provides methods for getting connections to the File System. |
|---|
| 52 | * |
|---|
| 53 | */ |
|---|
| 54 | class ConnectionFactoryBase |
|---|
| 55 | implements ConnectionFactory, Serializable, Referenceable |
|---|
| 56 | { |
|---|
| 57 | public static final long serialVersionUID = 1L; |
|---|
| 58 | |
|---|
| 59 | /** Reference to this ConnectionFactory. */ |
|---|
| 60 | private Reference mReference; |
|---|
| 61 | |
|---|
| 62 | /** |
|---|
| 63 | * The ConnectionManager to use. |
|---|
| 64 | * In case of <b>two tier scenario</b> the ConnectionManager is an instance |
|---|
| 65 | * of the DefaultConnectionManager. |
|---|
| 66 | * In case of <b>three tier scenario</b> this Manager is provided by |
|---|
| 67 | * the Application Server. |
|---|
| 68 | */ |
|---|
| 69 | private final ConnectionManager mConnectionManager; |
|---|
| 70 | |
|---|
| 71 | /** |
|---|
| 72 | * Constructs a ConnectionFactory. |
|---|
| 73 | * |
|---|
| 74 | * @param cm The ConnectionManager to use. |
|---|
| 75 | */ |
|---|
| 76 | public ConnectionFactoryBase (final ConnectionManager cm) |
|---|
| 77 | { |
|---|
| 78 | mConnectionManager = cm; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | /** {@inheritDoc} */ |
|---|
| 82 | public Connection getConnection () |
|---|
| 83 | throws ResourceException |
|---|
| 84 | { |
|---|
| 85 | return null; |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | /** {@inheritDoc} */ |
|---|
| 89 | public Connection getConnection (ConnectionSpec cs) |
|---|
| 90 | throws ResourceException |
|---|
| 91 | { |
|---|
| 92 | return null; |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | /** {@inheritDoc} */ |
|---|
| 96 | public RecordFactory getRecordFactory () |
|---|
| 97 | throws ResourceException |
|---|
| 98 | { |
|---|
| 99 | return null; |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | /** {@inheritDoc} */ |
|---|
| 103 | public ResourceAdapterMetaData getMetaData () |
|---|
| 104 | throws ResourceException |
|---|
| 105 | { |
|---|
| 106 | return null; |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | /** |
|---|
| 110 | * Sets the reference for this ConnectionFactory. |
|---|
| 111 | * This method is called by deployment code. |
|---|
| 112 | * |
|---|
| 113 | * @param reference The reference for this ConnectionFactory. |
|---|
| 114 | * |
|---|
| 115 | * @see javax.resource.Referenceable#setReference(javax.naming.Reference) |
|---|
| 116 | */ |
|---|
| 117 | public void setReference (Reference reference) |
|---|
| 118 | { |
|---|
| 119 | mReference = reference; |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | /** |
|---|
| 123 | * Returns the non-null Reference of this for this ConnectionFactory. |
|---|
| 124 | * |
|---|
| 125 | * @return The non-null Reference of this for this ConnectionFactory. |
|---|
| 126 | * |
|---|
| 127 | * @exception NamingException If a naming exception was encountered |
|---|
| 128 | * while retrieving the reference. |
|---|
| 129 | * |
|---|
| 130 | * @see javax.naming.Referenceable#getReference() |
|---|
| 131 | * |
|---|
| 132 | */ |
|---|
| 133 | public Reference getReference () |
|---|
| 134 | throws NamingException |
|---|
| 135 | { |
|---|
| 136 | return mReference; |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | } |
|---|