Search in sources :

Example 6 with IEnterpriseApplication

use of org.eclipse.jst.server.core.IEnterpriseApplication in project webtools.servertools by eclipse.

the class J2EEUtil method getEnterpriseApplications.

/**
 * Returns the enterprise applications that the module is contained within.
 *
 * @param module a J2EE module
 * @param monitor a progress monitor, or <code>null</code> if progress
 *    reporting and cancellation are not desired
 * @return a possibly empty array of enterprise applications
 */
public static IModule[] getEnterpriseApplications(IJ2EEModule module, IProgressMonitor monitor) {
    if (shouldUseCache()) {
        List<IModule> list = earCache2.get(module);
        if (list == null)
            return EMPTY_LIST;
        return list.toArray(new IModule[list.size()]);
    }
    List<IModule> list = new ArrayList<IModule>();
    IModule[] modules = ServerUtil.getModules(EAR_MODULE);
    if (modules != null) {
        for (IModule module2 : modules) {
            IEnterpriseApplication ear = (IEnterpriseApplication) module2.loadAdapter(IEnterpriseApplication.class, monitor);
            if (ear != null) {
                IModule[] modules2 = ear.getModules();
                if (modules2 != null) {
                    for (IModule m : modules2) {
                        if (module.equals(m.loadAdapter(IJ2EEModule.class, monitor)))
                            list.add(module2);
                    }
                }
            }
        }
    }
    return list.toArray(new IModule[list.size()]);
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IJ2EEModule(org.eclipse.jst.server.core.IJ2EEModule) ArrayList(java.util.ArrayList) IEnterpriseApplication(org.eclipse.jst.server.core.IEnterpriseApplication)

Aggregations

IEnterpriseApplication (org.eclipse.jst.server.core.IEnterpriseApplication)6 IModule (org.eclipse.wst.server.core.IModule)6 ArrayList (java.util.ArrayList)4 IJ2EEModule (org.eclipse.jst.server.core.IJ2EEModule)3 List (java.util.List)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Status (org.eclipse.core.runtime.Status)1 IWebModule (org.eclipse.jst.server.core.IWebModule)1 IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)1 ProjectModule (org.eclipse.wst.server.core.util.ProjectModule)1