01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.sdlctools.domains.enterprisemodel.impl;
16:
17: import javax.naming.Context;
18: import javax.naming.InitialContext;
19: import javax.naming.NamingException;
20:
21: import com.metaboss.enterprise.bo.BOException;
22: import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
23: import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
24: import com.metaboss.enterprise.ps.PSException;
25: import com.metaboss.sdlctools.domains.enterprisemodel.BOApplication;
26: import com.metaboss.sdlctools.domains.enterprisemodel.BOSystem;
27: import com.metaboss.sdlctools.domains.enterprisemodel.BOSystemApplicationList;
28: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSSystem;
29: import com.oldboss.framework.bo.impl.BOObjectImpl;
30:
31: public class BOSystemApplicationListImpl extends BOObjectImpl implements
32: BOSystemApplicationList {
33: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
34: private BOSystem mSystem = null;
35:
36: /* Instance creator */
37: public static BOSystemApplicationList createInstanceForExisting(
38: BOMetaBossDomainImpl pMetaBossDomainImpl, BOSystem pSystem)
39: throws BOException {
40: BOSystemApplicationListImpl lImpl = new BOSystemApplicationListImpl();
41: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
42: lImpl.mSystem = pSystem;
43: lImpl.setupForExisting();
44: return lImpl;
45: }
46:
47: /* Private constructor restricts instance creation from outside */
48: private BOSystemApplicationListImpl() throws BOException {
49: }
50:
51: /* Retrieves applications for this enteprise */
52: public BOApplication[] getAllApplications() throws BOException {
53: try {
54: // Get the instance of the enterprise ps home via jndi
55: Context ctx = new InitialContext();
56: PSSystem lPs = (PSSystem) ctx
57: .lookup(PSSystem.COMPONENT_URL);
58:
59: String[] lApplicationRefs = lPs
60: .getAllApplicationRefs(mSystem.getRef());
61: if (lApplicationRefs == null
62: || lApplicationRefs.length == 0)
63: return new BOApplication[0];
64: BOApplication[] lReturn = new BOApplication[lApplicationRefs.length];
65: for (int i = 0; i < lApplicationRefs.length; i++) {
66: lReturn[i] = BOApplicationImpl
67: .createInstanceForExisting(mMetaBossDomainImpl,
68: lApplicationRefs[i]);
69: }
70: return lReturn;
71: } catch (NamingException e) {
72: throw new BONamingAndDirectoryServiceInvocationException(
73: "Error while loading all applications. SystemRef: "
74: + mSystem.getRef(), e);
75: } catch (PSException e) {
76: throw new BOPersistenceServiceInvocationException(
77: "Error while loading all applications. SystemRef: "
78: + mSystem.getRef(), e);
79: }
80: }
81: }
|