001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.sdlctools.domains.storagemodel.impl;
016:
017: import javax.naming.Context;
018: import javax.naming.InitialContext;
019: import javax.naming.NamingException;
020:
021: import com.metaboss.enterprise.bo.BOException;
022: import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
023: import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
024: import com.metaboss.enterprise.ps.PSException;
025: import com.metaboss.sdlctools.domains.storagemodel.BORelationalDomainAssociationTableList;
026: import com.metaboss.sdlctools.domains.storagemodel.BORelationalDomainEntityTableList;
027: import com.metaboss.sdlctools.domains.storagemodel.BORelationalDomainReferenceTableList;
028: import com.metaboss.sdlctools.domains.storagemodel.BORelationalDomainStorage;
029: import com.metaboss.sdlctools.domains.storagemodel.BORelationalStorageTechnology;
030: import com.metaboss.sdlctools.domains.storagemodel.storage.PSRelationalDomainStorage;
031: import com.oldboss.framework.bo.BOTransaction;
032:
033: public class BORelationalDomainStorageImpl extends BODomainStorageImpl
034: implements BORelationalDomainStorage {
035: /* Instance creator */
036: public static BORelationalDomainStorage createInstanceForExisting(
037: BOMetaBossDomainImpl pMetaBossDomainImpl,
038: BORelationalStorageTechnology pStorageTechnology,
039: String pDomainRef) throws BOException {
040: BORelationalDomainStorageImpl lImpl = new BORelationalDomainStorageImpl();
041: lImpl.setupInstanceForExisting(pMetaBossDomainImpl,
042: pStorageTechnology, pDomainRef);
043: lImpl.setupForExisting();
044: return lImpl;
045: }
046:
047: /* Instance creator */
048: public static BORelationalDomainStorage createInstanceForNew(
049: BOTransaction pTransaction,
050: BOMetaBossDomainImpl pMetaBossDomainImpl,
051: BORelationalStorageTechnology pStorageTechnology,
052: String pDomainRef) throws BOException {
053: BORelationalDomainStorageImpl lImpl = new BORelationalDomainStorageImpl();
054: lImpl.setupInstanceForNew(pMetaBossDomainImpl,
055: pStorageTechnology, pDomainRef);
056: lImpl.setupForNew(pTransaction);
057: return lImpl;
058: }
059:
060: // Sets up the instance to represent existing object
061: protected void setupInstanceForExisting(
062: BOMetaBossDomainImpl pMetaBossDomainImpl,
063: BORelationalStorageTechnology pStorageTechnology,
064: String pDomainRef) throws BOException {
065: super .setupInstanceForExisting(pMetaBossDomainImpl,
066: pStorageTechnology, pDomainRef);
067: }
068:
069: // Sets up the instance to represent new object
070: protected void setupInstanceForNew(
071: BOMetaBossDomainImpl pMetaBossDomainImpl,
072: BORelationalStorageTechnology pStorageTechnology,
073: String pDomainRef) throws BOException {
074: super .setupInstanceForNew(pMetaBossDomainImpl,
075: pStorageTechnology, pDomainRef);
076: }
077:
078: /* Protect an access to this constructor */
079: protected BORelationalDomainStorageImpl() throws BOException {
080: }
081:
082: /* Retrieves list of entity table definitions */
083: public BORelationalDomainEntityTableList getEntityTables()
084: throws BOException {
085: return BORelationalDomainEntityTableListImpl
086: .createInstanceForExisting(mMetaBossDomainImpl, this );
087: }
088:
089: /* Retrieves list of association table definitions */
090: public BORelationalDomainAssociationTableList getAssociationTables()
091: throws BOException {
092: return BORelationalDomainAssociationTableListImpl
093: .createInstanceForExisting(mMetaBossDomainImpl, this );
094: }
095:
096: /* Retrieves list of reference table definitions */
097: public BORelationalDomainReferenceTableList getReferenceTables()
098: throws BOException {
099: return BORelationalDomainReferenceTableListImpl
100: .createInstanceForExisting(mMetaBossDomainImpl, this );
101: }
102:
103: /* Encapsulates commit action by this object */
104: protected void onCommitCreation() throws BOException {
105: try {
106: // Get the instance of the enterprise ps home via jndi
107: Context ctx = new InitialContext();
108: PSRelationalDomainStorage lPs = (PSRelationalDomainStorage) ctx
109: .lookup(PSRelationalDomainStorage.COMPONENT_URL);
110: lPs.insertDomainStorage(mDomainStorageDetails);
111: } catch (NamingException e) {
112: throw new BONamingAndDirectoryServiceInvocationException(
113: "", e);
114: } catch (PSException e) {
115: throw new BOPersistenceServiceInvocationException("", e);
116: }
117: }
118: }
|