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.enterprisemodel.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.BOInvalidOperationForReadOnlyObjectException;
023: import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
024: import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
025: import com.metaboss.enterprise.ps.PSException;
026: import com.metaboss.sdlctools.domains.enterprisemodel.BOService;
027: import com.metaboss.sdlctools.domains.enterprisemodel.BOServiceServiceimplementationList;
028: import com.metaboss.sdlctools.domains.enterprisemodel.BOServiceimplementation;
029: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSService;
030: import com.metaboss.sdlctools.domains.enterprisemodel.storage.STServiceimplementation;
031: import com.oldboss.framework.bo.impl.BOObjectImpl;
032:
033: public class BOServiceServiceimplementationListImpl extends
034: BOObjectImpl implements BOServiceServiceimplementationList {
035: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
036: private BOService mService = null;
037:
038: /* Instance creator */
039: public static BOServiceServiceimplementationList createInstanceForExisting(
040: BOMetaBossDomainImpl pMetaBossDomainImpl, BOService pService)
041: throws BOException {
042: BOServiceServiceimplementationListImpl lImpl = new BOServiceServiceimplementationListImpl();
043: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
044: lImpl.mService = pService;
045: lImpl.setupForExisting();
046: return lImpl;
047: }
048:
049: /* Private constructor restricts instance creation from outside */
050: private BOServiceServiceimplementationListImpl() throws BOException {
051: }
052:
053: /* Retrieves the service this implementation list belongs to */
054: public BOService getService() throws BOException {
055: return mService;
056: }
057:
058: /* Retrieves an operation object by it's name */
059: public BOServiceimplementation getImplementation(
060: String pServiceimplementationRef) throws BOException {
061: try {
062: // Get the instance of the enterprise ps home via jndi
063: Context ctx = new InitialContext();
064: PSService lPs = (PSService) ctx
065: .lookup(PSService.COMPONENT_URL);
066:
067: STServiceimplementation lServiceimplementation = lPs
068: .getImplementation(mService.getRef(),
069: pServiceimplementationRef);
070: if (lServiceimplementation == null)
071: return null;
072: return BOServiceimplementationImpl
073: .createInstanceForExisting(mMetaBossDomainImpl,
074: mService, lServiceimplementation);
075: } catch (NamingException e) {
076: throw new BONamingAndDirectoryServiceInvocationException(
077: "", e);
078: } catch (PSException e) {
079: throw new BOPersistenceServiceInvocationException("", e);
080: }
081: }
082:
083: /* Retrieves all implementations defined in this list */
084: public BOServiceimplementation[] getAllImplementations()
085: throws BOException {
086: try {
087: // Get the instance of the enterprise ps home via jndi
088: Context ctx = new InitialContext();
089: PSService lPs = (PSService) ctx
090: .lookup(PSService.COMPONENT_URL);
091:
092: STServiceimplementation[] lImplementations = lPs
093: .getImplementations(mService.getRef());
094: if (lImplementations == null
095: || lImplementations.length == 0)
096: return new BOServiceimplementation[0];
097: BOServiceimplementation[] lReturn = new BOServiceimplementation[lImplementations.length];
098: for (int i = 0; i < lImplementations.length; i++) {
099: lReturn[i] = BOServiceimplementationImpl
100: .createInstanceForExisting(mMetaBossDomainImpl,
101: mService, lImplementations[i]);
102: }
103: return lReturn;
104: } catch (NamingException e) {
105: throw new BONamingAndDirectoryServiceInvocationException(
106: "", e);
107: } catch (PSException e) {
108: throw new BOPersistenceServiceInvocationException("", e);
109: }
110: }
111:
112: /** Creates new implementation with given reference */
113: public BOServiceimplementation createImplementation(
114: String pImplementationRef) throws BOException {
115: if (!isBeingEdited())
116: throw new BOInvalidOperationForReadOnlyObjectException();
117: return BOServiceimplementationImpl.createInstanceForNew(
118: fetchTransaction(), mMetaBossDomainImpl, mService,
119: pImplementationRef);
120: }
121: }
|