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.BOServicemodule;
027: import com.metaboss.sdlctools.domains.enterprisemodel.BOServicemoduleStructureList;
028: import com.metaboss.sdlctools.domains.enterprisemodel.BOStructure;
029: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSServicemodule;
030: import com.oldboss.framework.bo.impl.BOObjectImpl;
031:
032: public class BOServicemoduleStructureListImpl extends BOObjectImpl
033: implements BOServicemoduleStructureList {
034: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
035: private BOServicemodule mServicemodule = null;
036:
037: /* Instance creator */
038: public static BOServicemoduleStructureList createInstanceForExisting(
039: BOMetaBossDomainImpl pMetaBossDomainImpl,
040: BOServicemodule pServicemodule) throws BOException {
041: BOServicemoduleStructureListImpl lImpl = new BOServicemoduleStructureListImpl();
042: lImpl
043: .initialiseForExisting(pMetaBossDomainImpl,
044: pServicemodule);
045: return lImpl;
046: }
047:
048: /* Private constructor restricts instance creation from outside */
049: private BOServicemoduleStructureListImpl() throws BOException {
050: }
051:
052: /* Instance initialisation */
053: private void initialiseForExisting(
054: BOMetaBossDomainImpl pMetaBossDomainImpl,
055: BOServicemodule pServicemodule) throws BOException {
056: mMetaBossDomainImpl = pMetaBossDomainImpl;
057: mServicemodule = pServicemodule;
058: setupForExisting();
059: }
060:
061: /** Retrieves all services defined in this domain */
062: public BOStructure[] getAllStructures() throws BOException {
063: try {
064: // Get the instance of the enterprise ps home via jndi
065: Context ctx = new InitialContext();
066: PSServicemodule lPs = (PSServicemodule) ctx
067: .lookup(PSServicemodule.COMPONENT_URL);
068:
069: String[] lStructureRefs = lPs
070: .getServicemoduleStructureRefs(mServicemodule
071: .getRef());
072: if (lStructureRefs == null || lStructureRefs.length == 0)
073: return new BOStructure[0];
074: BOStructure[] lReturn = new BOStructure[lStructureRefs.length];
075: for (int i = 0; i < lStructureRefs.length; i++) {
076: lReturn[i] = BOStructureImpl.createInstanceForExisting(
077: mMetaBossDomainImpl, lStructureRefs[i]);
078: }
079: return lReturn;
080: } catch (NamingException e) {
081: throw new BONamingAndDirectoryServiceInvocationException(
082: "", e);
083: } catch (PSException e) {
084: throw new BOPersistenceServiceInvocationException("", e);
085: }
086: }
087:
088: /** Creates new structure */
089: public BOStructure get(String pStructureRef) throws BOException {
090: return BOStructureImpl.createInstanceForExisting(
091: mMetaBossDomainImpl, pStructureRef);
092: }
093:
094: /** Creates new structure */
095: public BOStructure create(String pStructureRef) throws BOException {
096: if (!isBeingEdited())
097: throw new BOInvalidOperationForReadOnlyObjectException();
098: return BOStructureImpl.createInstanceForNew(fetchTransaction(),
099: mMetaBossDomainImpl, pStructureRef);
100: }
101: }
|