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.BOOperation;
027: import com.metaboss.sdlctools.domains.enterprisemodel.BOService;
028: import com.metaboss.sdlctools.domains.enterprisemodel.BOServiceOperationList;
029: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSService;
030: import com.metaboss.sdlctools.domains.enterprisemodel.storage.STOperation;
031: import com.oldboss.framework.bo.impl.BOObjectImpl;
032:
033: public class BOServiceOperationListImpl extends BOObjectImpl implements
034: BOServiceOperationList {
035: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
036: private BOService mService = null;
037:
038: /* Instance creator */
039: public static BOServiceOperationList createInstanceForExisting(
040: BOMetaBossDomainImpl pMetaBossDomainImpl, BOService pService)
041: throws BOException {
042: BOServiceOperationListImpl lImpl = new BOServiceOperationListImpl();
043: lImpl.initialiseForExisting(pMetaBossDomainImpl, pService);
044: return lImpl;
045: }
046:
047: /* Private constructor restricts instance creation from outside */
048: private BOServiceOperationListImpl() throws BOException {
049: }
050:
051: /* Instance initialisation */
052: private void initialiseForExisting(
053: BOMetaBossDomainImpl pMetaBossDomainImpl, BOService pService)
054: throws BOException {
055: mMetaBossDomainImpl = pMetaBossDomainImpl;
056: mService = pService;
057: setupForExisting();
058: }
059:
060: /* Retrieves an operation object by it's name */
061: public BOOperation getOperation(String pName) throws BOException {
062: try {
063: // Get the instance of the enterprise ps home via jndi
064: Context ctx = new InitialContext();
065: PSService lPs = (PSService) ctx
066: .lookup(PSService.COMPONENT_URL);
067:
068: STOperation lOperation = lPs.getOperation(
069: mService.getRef(), pName);
070: if (lOperation == null)
071: return null;
072: return BOOperationImpl.createInstanceForExisting(
073: mMetaBossDomainImpl, mService, lOperation);
074: } catch (NamingException e) {
075: throw new BONamingAndDirectoryServiceInvocationException(
076: "", e);
077: } catch (PSException e) {
078: throw new BOPersistenceServiceInvocationException("", e);
079: }
080: }
081:
082: /* Retrieves all operations comprising this service */
083: public BOOperation[] getAllOperations() throws BOException {
084: try {
085: // Get the instance of the enterprise ps home via jndi
086: Context ctx = new InitialContext();
087: PSService lPs = (PSService) ctx
088: .lookup(PSService.COMPONENT_URL);
089:
090: STOperation[] lOperations = lPs.getOperations(mService
091: .getRef());
092: if (lOperations == null || lOperations.length == 0)
093: return new BOOperation[0];
094: BOOperation[] lReturn = new BOOperation[lOperations.length];
095: for (int i = 0; i < lOperations.length; i++) {
096: lReturn[i] = BOOperationImpl.createInstanceForExisting(
097: mMetaBossDomainImpl, mService, lOperations[i]);
098: }
099: return lReturn;
100: } catch (NamingException e) {
101: throw new BONamingAndDirectoryServiceInvocationException(
102: "", e);
103: } catch (PSException e) {
104: throw new BOPersistenceServiceInvocationException("", e);
105: }
106: }
107:
108: /** Creates the new instance of the operation */
109: public BOOperation create(String pOperationName) throws BOException {
110: if (!isBeingEdited())
111: throw new BOInvalidOperationForReadOnlyObjectException();
112: return BOOperationImpl.createInstanceForNew(fetchTransaction(),
113: mMetaBossDomainImpl, mService, pOperationName);
114: }
115: }
|