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);
}
}
}
}
}
}
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()]);
}
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);
}
Aggregations