本文整理汇总了Java中org.eclipse.wst.server.core.util.PublishHelper类的典型用法代码示例。如果您正苦于以下问题:Java PublishHelper类的具体用法?Java PublishHelper怎么用?Java PublishHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PublishHelper类属于org.eclipse.wst.server.core.util包,在下文中一共展示了PublishHelper类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: publishModule
import org.eclipse.wst.server.core.util.PublishHelper; //导入依赖的package包/类
@Override
protected void publishModule(int kind, int deltaKind, IModule[] moduleTree, IProgressMonitor monitor) throws CoreException
{
if (getServer().getServerState() != IServer.STATE_STOPPED)
{
if (deltaKind == ServerBehaviourDelegate.ADDED || deltaKind == ServerBehaviourDelegate.REMOVED)
setServerRestartState(true);
}
if (getJettyServer().isTestEnvironment())
return;
Properties p = loadModulePublishLocations();
PublishHelper helper = new PublishHelper(getRuntimeBaseDirectory().append("temp").toFile());
// If parent web module
if (moduleTree.length == 1)
{
publishDir(deltaKind,p,moduleTree,helper,monitor);
}
// Else a child module
else
{
// Try to determine the URI for the child module
IWebModule webModule = (IWebModule)moduleTree[0].loadAdapter(IWebModule.class,monitor);
String childURI = null;
if (webModule != null)
{
childURI = webModule.getURI(moduleTree[1]);
}
// Try to determine if child is binary
IJ2EEModule childModule = (IJ2EEModule)moduleTree[1].loadAdapter(IJ2EEModule.class,monitor);
boolean isBinary = false;
if (childModule != null)
{
isBinary = childModule.isBinary();
}
if (isBinary)
{
publishArchiveModule(childURI,kind,deltaKind,p,moduleTree,helper,monitor);
}
else
{
publishJar(childURI,kind,deltaKind,p,moduleTree,helper,monitor);
}
}
setModulePublishState(moduleTree,IServer.PUBLISH_STATE_NONE);
saveModulePublishLocations(p);
}
示例2: publishJar
import org.eclipse.wst.server.core.util.PublishHelper; //导入依赖的package包/类
/**
* Publish a jar file.
*
* @param deltaKind
* @param p
* @param module
* @param monitor
* @throws CoreException
*/
private void publishJar(String jarURI, int kind, int deltaKind, Properties p, IModule[] module, PublishHelper helper, IProgressMonitor monitor)
throws CoreException
{
// Remove if requested or if previously published and are now serving
// without publishing
if (deltaKind == REMOVED || getJettyServer().isServeModulesWithoutPublish())
{
try
{
String publishPath = (String)p.get(module[1].getId());
if (publishPath != null)
{
new File(publishPath).delete();
p.remove(module[1].getId());
}
}
catch (Exception e)
{
throw new CoreException(new Status(IStatus.WARNING,JettyPlugin.PLUGIN_ID,0,"Could not remove module",e));
}
}
else
{
IPath path = getModuleDeployDirectory(module[0]);
if (jarURI == null)
{
jarURI = "WEB-INF/lib" + module[1].getName() + ".jar";
}
IPath jarPath = path.append(jarURI);
path = jarPath.removeLastSegments(1);
if (!path.toFile().exists())
{
path.toFile().mkdirs();
}
else
{
// If file still exists and we are not forcing a new one to be
// built
if (jarPath.toFile().exists() && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL)
{
// avoid changes if no changes to module since last publish
IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
if (delta == null || delta.length == 0)
return;
}
}
IModuleResource[] mr = getResources(module);
IStatus[] stat = helper.publishZip(mr,jarPath,monitor);
List<IStatus> status = new ArrayList<IStatus>();
PublishOperation2.addArrayToList(status,stat);
PublishOperation2.throwException(status);
p.put(module[1].getId(),jarPath.toOSString());
}
}
示例3: publishArchiveModule
import org.eclipse.wst.server.core.util.PublishHelper; //导入依赖的package包/类
private void publishArchiveModule(String jarURI, int kind, int deltaKind, Properties p, IModule[] module, PublishHelper helper, IProgressMonitor monitor)
throws CoreException
{
// Remove if requested or if previously published and are now serving
// without publishing
if (deltaKind == REMOVED || getJettyServer().isServeModulesWithoutPublish())
{
try
{
String publishPath = (String)p.get(module[1].getId());
if (publishPath != null)
{
new File(publishPath).delete();
p.remove(module[1].getId());
}
}
catch (Exception e)
{
throw new CoreException(new Status(IStatus.WARNING,JettyPlugin.PLUGIN_ID,0,"Could not remove archive module",e));
}
}
else
{
List<IStatus> status = new ArrayList<IStatus>();
IPath path = getModuleDeployDirectory(module[0]);
if (jarURI == null)
{
jarURI = "WEB-INF/lib" + module[1].getName();
}
IPath jarPath = path.append(jarURI);
path = jarPath.removeLastSegments(1);
if (!path.toFile().exists())
{
path.toFile().mkdirs();
}
else
{
// If file still exists and we are not forcing a new one to be
// built
if (jarPath.toFile().exists() && kind != IServer.PUBLISH_CLEAN && kind != IServer.PUBLISH_FULL)
{
// avoid changes if no changes to module since last publish
IModuleResourceDelta[] delta = getPublishedResourceDelta(module);
if (delta == null || delta.length == 0)
return;
}
}
IModuleResource[] mr = getResources(module);
IStatus[] stat = helper.publishToPath(mr,jarPath,monitor);
PublishOperation2.addArrayToList(status,stat);
PublishOperation2.throwException(status);
p.put(module[1].getId(),jarPath.toOSString());
}
}