use of org.eclipse.jst.server.generic.servertype.definition.ServerRuntime in project webtools.servertools by eclipse.
the class ServerTypeDefinitionUtil method getServerTypeDefinition.
/**
* Returns the server definition for runtime. Returns null
* if the runtime is null or not a Generic server type.
*
* @param runtime
* @return serverRuntime
*/
public static ServerRuntime getServerTypeDefinition(IRuntime runtime) {
if (runtime == null)
return null;
GenericServerRuntime delegate = (GenericServerRuntime) runtime.loadAdapter(GenericServerRuntime.class, null);
if (delegate == null)
return null;
String serverType = delegate.getRuntime().getRuntimeType().getId();
Map properties = delegate.getServerInstanceProperties();
ServerRuntime definition = CorePlugin.getDefault().getServerTypeDefinitionManager().getServerRuntimeDefinition(serverType, properties);
return definition;
}
use of org.eclipse.jst.server.generic.servertype.definition.ServerRuntime in project webtools.servertools by eclipse.
the class ServerTypeDefinitionUtil method getServerClassPathEntry.
/**
* Extracts the server classpath entry array.
*
* @param runtime
* @return classpathEntry
*/
@SuppressWarnings("unchecked")
public static IClasspathEntry[] getServerClassPathEntry(IRuntime runtime) {
ServerRuntime definition = getServerTypeDefinition(runtime);
if (definition == null)
return null;
String ref = definition.getProject().getClasspathReference();
ArrayList entryList = getClasspathEntries(ref, definition, false);
return (IClasspathEntry[]) entryList.toArray(new IClasspathEntry[entryList.size()]);
}
use of org.eclipse.jst.server.generic.servertype.definition.ServerRuntime in project webtools.servertools by eclipse.
the class GenericServer method setDefaults.
@SuppressWarnings("unchecked")
public void setDefaults(IProgressMonitor monitor) {
ServerRuntime serverRuntime = this.getServerDefinition();
// the runtime is not created yet and serverdef can not be determined.
if (serverRuntime == null) {
return;
}
List props = this.getServerDefinition().getProperty();
Map instancePropsMap = new HashMap();
for (Iterator iter = props.iterator(); iter.hasNext(); ) {
Property element = (Property) iter.next();
if (Property.CONTEXT_SERVER.equalsIgnoreCase(element.getContext())) {
// if the property type is this is a combo, parse the value and use the first token as the default
if (Property.TYPE_SELECT.equals(element.getType()) || Property.TYPE_SELECT_EDIT.equals(element.getType())) {
// $NON-NLS-1$
StringTokenizer tokenizer = new StringTokenizer(element.getDefault(), ",");
if (tokenizer.hasMoreTokens()) {
String firstToken = tokenizer.nextToken();
instancePropsMap.put(element.getId(), firstToken);
}
} else {
// not a combo, so just pass through the default value
instancePropsMap.put(element.getId(), element.getDefault());
}
}
}
setServerInstanceProperties(instancePropsMap);
}
use of org.eclipse.jst.server.generic.servertype.definition.ServerRuntime in project webtools.servertools by eclipse.
the class ExternalServerBehaviour method setupStopLaunchConfiguration.
/**
* Sets up the launch configuration for stopping the server.
*/
protected void setupStopLaunchConfiguration(GenericServerRuntime runtime, ILaunchConfigurationWorkingCopy wc) {
clearDebuggingConfig();
ServerRuntime serverDef = getServerDefinition();
Resolver resolver = serverDef.getResolver();
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, resolver.resolveProperties(serverDef.getStop().getWorkingDirectory()));
String external = resolver.resolveProperties(getExternalForOS(serverDef.getStop().getExternal()));
wc.setAttribute(ExternalLaunchConfigurationDelegate.COMMANDLINE, external);
// just use commandline for now
Map environVars = getEnvironmentVariables(getServerDefinition().getStop());
if (!environVars.isEmpty()) {
wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, environVars);
}
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, resolver.resolveProperties(serverDef.getStop().getProgramArgumentsAsString()));
wc.setAttribute(ExternalLaunchConfigurationDelegate.EXECUTABLE_NAME, external);
wc.setAttribute(ATTR_SERVER_ID, getServer().getId());
}
use of org.eclipse.jst.server.generic.servertype.definition.ServerRuntime in project webtools.servertools by eclipse.
the class XMLUtils method readFile.
private ServerRuntime readFile(java.net.URI file) {
// Create a resource set.
ResourceSet resourceSet = new ResourceSetImpl();
// Register the default resource factory -- only needed for
// stand-alone!
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new ServerTypeResourceFactoryImpl());
ServerTypePackage gstPack = ServerTypePackage.eINSTANCE;
// Get the URI of the model file.
URI fileURI = URI.createURI(file.toString());
// Demand load the resource for this file.
Resource resource = null;
try {
resource = resourceSet.getResource(fileURI, true);
} catch (WrappedException e) {
// sth wrong with this .server file.
CorePlugin.getDefault().getLog().log(new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 1, "Error loading the server type definition", // $NON-NLS-1$
e));
}
if (resource != null) {
ServerRuntime def = (ServerRuntime) resource.getContents().get(0);
if (def != null) {
def.setFilename(file.toString());
return def;
}
}
return null;
}
Aggregations