use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.
the class AbstractModuleAssembler method copyModule.
protected IPath copyModule(IModule module, IProgressMonitor monitor) throws CoreException {
ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, monitor);
IStatus[] status = publishHelper.publishSmart(pm.members(), fAssembleRoot, monitor);
if (status != null && status.length > 0)
throw new CoreException(status[0]);
return fAssembleRoot;
}
use of org.eclipse.wst.server.core.util.ProjectModule 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.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.
the class ModuleHelper method listModule.
public static void listModule(IModule module) throws CoreException {
System.out.println("--- Contents of " + module.getName() + "/" + module.getId() + "---");
ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
IModuleResource[] mr = pm.members();
for (IModuleResource m : mr) {
if (m instanceof IModuleFile) {
System.out.println(m.getName());
} else {
System.out.println(m.getName() + "/");
listFolder((IModuleFolder) m, " ");
}
}
System.out.println("------");
}
use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.sourceediting by eclipse.
the class FlatComponentDeployable method getURI.
/**
* Returns the URI of the given contained CHILD module.
*
* SOFT requirements (NOT API!!) in use by some adopters
* If the passed in module is equal to this module, return our own deployed name
*
* @param module a module
* @return the URI of the given module, or <code>null</code> if the URI could
* not be found
*/
public String getURI(IModule module) {
ProjectModule md = (ProjectModule) module.loadAdapter(ProjectModule.class, new NullProgressMonitor());
if (md == this) {
// guess my own name
return VirtualReferenceUtilities.INSTANCE.getDefaultProjectArchiveName(this.component);
}
try {
FlatComponentDeployable cd = (FlatComponentDeployable) module.loadAdapter(FlatComponentDeployable.class, new NullProgressMonitor());
if (cd != null) {
IFlatVirtualComponent em = getFlatComponent();
IChildModuleReference[] children = em.getChildModules();
for (int i = 0; i < children.length; i++) {
IModule child = gatherModuleReference(component, children[i]);
if (child != null && child.getId().equals(module.getId()))
return children[i].getRelativeURI().toString();
}
}
} catch (CoreException ce) {
}
return null;
}
use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.
the class AbstractModuleAssembler method packModule.
protected void packModule(IModule module, String deploymentUnitName, IPath destination) throws CoreException {
String dest = destination.append(deploymentUnitName).toString();
ModulePackager packager = null;
try {
packager = new ModulePackager(dest, false);
ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
IModuleResource[] resources = pm.members();
for (int i = 0; i < resources.length; i++) {
doPackModule(resources[i], packager);
}
} catch (IOException e) {
IStatus status = new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, "unable to assemble module", // $NON-NLS-1$
e);
throw new CoreException(status);
} finally {
try {
packager.finished();
} catch (IOException e) {
// unhandled
}
}
}
Aggregations