Search in sources :

Example 6 with IJ2EEModule

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

the class J2EEUtil method fillCache.

private static void fillCache(IProgressMonitor monitor) {
    earCache = new HashMap<IModule, List<IModule>>();
    earCache2 = new HashMap<IJ2EEModule, List<IModule>>();
    webCache = new HashMap<IModule, List<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 mm : modules2) {
                        List<IModule> m = earCache.get(mm);
                        if (m == null) {
                            m = new ArrayList<IModule>(2);
                            earCache.put(mm, m);
                        }
                        m.add(module2);
                        IJ2EEModule mod = (IJ2EEModule) mm.loadAdapter(IJ2EEModule.class, monitor);
                        if (mod != null) {
                            m = earCache2.get(mod);
                            if (m == null) {
                                m = new ArrayList<IModule>(2);
                                earCache2.put(mod, m);
                            }
                            m.add(module2);
                        }
                    }
                }
            }
        }
    }
    modules = ServerUtil.getModules(WEB_MODULE);
    if (modules != null) {
        for (IModule module2 : modules) {
            IWebModule web = (IWebModule) module2.loadAdapter(IWebModule.class, monitor);
            if (web != null) {
                IModule[] modules2 = web.getModules();
                if (modules2 != null) {
                    for (IModule mm : modules2) {
                        List<IModule> m = webCache.get(mm);
                        if (m == null) {
                            m = new ArrayList<IModule>(2);
                            webCache.put(mm, m);
                        }
                        m.add(module2);
                    }
                }
            }
        }
    }
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IJ2EEModule(org.eclipse.jst.server.core.IJ2EEModule) List(java.util.List) ArrayList(java.util.ArrayList) IWebModule(org.eclipse.jst.server.core.IWebModule) IEnterpriseApplication(org.eclipse.jst.server.core.IEnterpriseApplication)

Example 7 with IJ2EEModule

use of org.eclipse.jst.server.core.IJ2EEModule 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)

Example 8 with IJ2EEModule

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

the class PublishOperation2 method execute.

/**
 * @see PublishOperation#execute(IProgressMonitor, IAdaptable)
 */
public void execute(IProgressMonitor monitor, IAdaptable info) throws CoreException {
    List<IStatus> status = new ArrayList<IStatus>();
    // If parent web module
    if (module.length == 1) {
        publishDir(module[0], status, monitor);
    } else // Else a child module
    {
        Properties p = server.loadModulePublishLocations();
        // Try to determine the URI for the child module
        IWebModule webModule = (IWebModule) module[0].loadAdapter(IWebModule.class, monitor);
        String childURI = null;
        if (webModule != null) {
            childURI = webModule.getURI(module[1]);
        }
        // Try to determine if child is binary
        IJ2EEModule childModule = (IJ2EEModule) module[1].loadAdapter(IJ2EEModule.class, monitor);
        boolean isBinary = false;
        if (childModule != null) {
            isBinary = childModule.isBinary();
        }
        if (isBinary) {
            publishArchiveModule(childURI, p, status, monitor);
        } else {
            publishJar(childURI, p, status, monitor);
        }
        server.saveModulePublishLocations(p);
    }
    throwException(status);
    server.setModulePublishState2(module, IServer.PUBLISH_STATE_NONE);
}
Also used : IJ2EEModule(org.eclipse.jst.server.core.IJ2EEModule) ArrayList(java.util.ArrayList) IWebModule(org.eclipse.jst.server.core.IWebModule) Properties(java.util.Properties)

Aggregations

IJ2EEModule (org.eclipse.jst.server.core.IJ2EEModule)8 IWebModule (org.eclipse.jst.server.core.IWebModule)6 ArrayList (java.util.ArrayList)5 IModule (org.eclipse.wst.server.core.IModule)4 Properties (java.util.Properties)3 IEnterpriseApplication (org.eclipse.jst.server.core.IEnterpriseApplication)3 List (java.util.List)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPath (org.eclipse.core.runtime.IPath)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)2 ProjectModule (org.eclipse.wst.server.core.util.ProjectModule)2 File (java.io.File)1 IOException (java.io.IOException)1 IModulePublishHelper (org.eclipse.wst.server.core.internal.IModulePublishHelper)1 PublishHelper (org.eclipse.wst.server.core.util.PublishHelper)1