Search in sources :

Example 1 with IEnterpriseApplication

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

the class AntPublisher method publishNeeded.

/**
 * Checks if the Ant publisher actually needs to publish.
 * For ear modules it also checks if any of the children modules requires publishing.
 * @return true if ant publisher needs to publish.
 */
private boolean publishNeeded() {
    if (getKind() != IServer.PUBLISH_INCREMENTAL && getKind() != IServer.PUBLISH_AUTO)
        return true;
    if (getDeltaKind() != ServerBehaviourDelegate.NO_CHANGE)
        return true;
    if (isModuleType(getModule()[0], "jst.ear")) {
        // $NON-NLS-1$
        IEnterpriseApplication earModule = (IEnterpriseApplication) getModule()[0].loadAdapter(IEnterpriseApplication.class, new NullProgressMonitor());
        IModule[] childModules = earModule.getModules();
        for (int i = 0; i < childModules.length; i++) {
            IModule module = childModules[i];
            IModule[] modules = { getModule()[0], module };
            if (IServer.PUBLISH_STATE_NONE != this.getServer().getServer().getModulePublishState(modules))
                return true;
        }
    }
    return false;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IModule(org.eclipse.wst.server.core.IModule) IEnterpriseApplication(org.eclipse.jst.server.core.IEnterpriseApplication)

Example 2 with IEnterpriseApplication

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

the class EarModuleAssembler method assemble.

public IPath assemble(IProgressMonitor monitor) throws CoreException {
    // copy ear root to the temporary assembly directory
    IPath parent = fAssembleRoot;
    final IModule[] rootMod = { fModule };
    boolean shouldCopy = (IServer.PUBLISH_STATE_NONE != fServer.getServer().getModulePublishState(rootMod));
    if (shouldCopy)
        copyModule(fModule, monitor);
    IEnterpriseApplication earModule = (IEnterpriseApplication) fModule.loadAdapter(IEnterpriseApplication.class, monitor);
    IModule[] childModules = earModule.getModules();
    for (int i = 0; i < childModules.length; i++) {
        IModule module = childModules[i];
        String uri = earModule.getURI(module);
        if (uri == null) {
            // The bad memories of WTP 1.0
            // $NON-NLS-1$
            IStatus status = new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, "unable to assemble module null uri", null);
            throw new CoreException(status);
        }
        IJ2EEModule jeeModule = (IJ2EEModule) module.loadAdapter(IJ2EEModule.class, monitor);
        if (jeeModule != null && jeeModule.isBinary()) {
            // Binary module
            // just copy
            ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
            IModuleResource[] resources = pm.members();
            publishHelper.publishToPath(resources, parent.append(uri), monitor);
            // done! no need to go further
            continue;
        }
        if (shouldRepack(module)) {
            packModule(module, uri, parent);
        }
    }
    return parent;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModule(org.eclipse.wst.server.core.IModule) IStatus(org.eclipse.core.runtime.IStatus) IJ2EEModule(org.eclipse.jst.server.core.IJ2EEModule) IPath(org.eclipse.core.runtime.IPath) IEnterpriseApplication(org.eclipse.jst.server.core.IEnterpriseApplication) ProjectModule(org.eclipse.wst.server.core.util.ProjectModule) CoreException(org.eclipse.core.runtime.CoreException)

Example 3 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 or utility 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(IModule module, IProgressMonitor monitor) {
    if (shouldUseCache()) {
        List<IModule> list = earCache.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))
                            list.add(module2);
                    }
                }
            }
        }
    }
    return list.toArray(new IModule[list.size()]);
}
Also used : IModule(org.eclipse.wst.server.core.IModule) ArrayList(java.util.ArrayList) IEnterpriseApplication(org.eclipse.jst.server.core.IEnterpriseApplication)

Example 4 with IEnterpriseApplication

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

the class GenericServer method doGetParentModules.

private IModule[] doGetParentModules(IModule module) {
    // $NON-NLS-1$
    IModule[] ears = ServerUtil.getModules("jst.ear");
    ArrayList<IModule> list = new ArrayList<IModule>();
    for (int i = 0; i < ears.length; i++) {
        IEnterpriseApplication ear = (IEnterpriseApplication) ears[i].loadAdapter(IEnterpriseApplication.class, null);
        IModule[] childs = ear.getModules();
        for (int j = 0; j < childs.length; j++) {
            if (childs[j].equals(module))
                list.add(ears[i]);
        }
    }
    return list.toArray(new IModule[list.size()]);
}
Also used : IModule(org.eclipse.wst.server.core.IModule) ArrayList(java.util.ArrayList) IEnterpriseApplication(org.eclipse.jst.server.core.IEnterpriseApplication)

Example 5 with IEnterpriseApplication

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

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