((ServiceClassLoader)cl).addMetaData(p);
}
/* Add a boot-cookie, indicating that the JSB was booted by this utility */
sbConfig.addInitParameter("org.rioproject.boot", BOOT_COOKIE);
ServiceLevelAgreements sla = new ServiceLevelAgreements();
/* Get the export codebase from the ClassLoader which loaded us. The
* export codebase will be returned by the getURLs() method since
* getURLs() is overridden to return configured export codebase
*/
URL[] urls = ((URLClassLoader)loader).getURLs();
if(urls.length==0)
throw new RuntimeException("Unknown Export Codebase");
ClassBundle exportBundle;
String exportCodebase = urls[0].toExternalForm();
if(!exportCodebase.startsWith("artifact:")) {
if(exportCodebase.contains(".jar")) {
int index = exportCodebase.lastIndexOf('/');
if(index != -1)
exportCodebase = exportCodebase.substring(0, index+1);
} else {
throw new RuntimeException("Cannot determine export codebase from "+exportCodebase);
}
exportBundle = new ClassBundle("");
exportBundle.setCodebase(exportCodebase);
for (URL url : urls) {
String jar = url.getFile();
int index = jar.lastIndexOf('/');
if (index != -1)
jar = jar.substring(1);
exportBundle.addJAR(jar);
}
} else {
exportBundle = new ClassBundle("");
exportBundle.setArtifact(exportCodebase);
}
/* Default system threshold is the number of available processors.
* Since the system threshold is the summation of all depletion oriented
* resources, total utilization is =
* (num_available_processors * cpu_utilization * mem_utilization * diskspace_utilization) */
double defaultSystemThreshold = Runtime.getRuntime().availableProcessors();
double systemThreshold = (Double)config.getEntry(QOS_COMPONENT,
"systemThreshold",
double.class,
defaultSystemThreshold);
sla.getSystemRequirements().addSystemThreshold(SystemRequirements.SYSTEM,
new ThresholdValues(0.0, systemThreshold));
ServiceElement sElem = new ServiceElement(ServiceElement.ProvisionType.EXTERNAL,
sbConfig,
sla,