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