final Thread currentThread = Thread.currentThread();
ClassLoader currentClassLoader = currentThread.getContextClassLoader();
Uuid serviceIDToUse = serviceID;
try {
ClassBundle jsbBundle = sElem.getComponentBundle();
List<URL> urlList = new ArrayList<URL>();
/*
URL[] implJARs;
if(jsbBundle!=null && jsbBundle.getCodebase()!=null)
implJARs = jsbBundle.getJARs();
else
implJARs = new URL[0];
*/
urlList.addAll(Arrays.asList(implJARs));
/* Get matched PlatformCapability jars to load */
PlatformCapability[] pCaps = computeResource.getPlatformCapabilities();
PlatformCapability[] matched = ServiceElementUtil.getMatchedPlatformCapabilities(sElem, pCaps);
for (PlatformCapability pCap : matched) {
URL[] urls = PlatformCapabilityLoader.getLoadableClassPath(pCap);
for(URL url : urls) {
if(!urlList.contains(url))
urlList.add(url);
}
}
URL[] classpath = urlList.toArray(new URL[urlList.size()]);
Properties metaData = new Properties();
metaData.setProperty("opStringName", sElem.getOperationalStringName());
metaData.setProperty("serviceName", sElem.getName());
ServiceClassLoader jsbCL = new ServiceClassLoader(ServiceClassLoader.getURIs(classpath),
new ClassAnnotator(exports),
commonCL,
metaData);
/*
ServiceClassLoader jsbCL =
new ServiceClassLoader(classpath, annotator, commonCL);
*/
currentThread.setContextClassLoader(jsbCL);
if(logger.isDebugEnabled()) {
StringBuilder buffer = new StringBuilder();
if(implJARs.length==0) {
buffer.append("<empty>");
} else {
for(int i=0; i<implJARs.length; i++) {
if(i>0)
buffer.append(", ");
buffer.append(implJARs[i].toExternalForm());
}
}
String className = (jsbBundle==null?"<not defined>": jsbBundle.getClassName());
if(logger.isDebugEnabled()) {
logger.debug("Create ServiceClassLoader for {}, classpath {}, codebase {}",
className, buffer.toString(), jsbCL.getClassAnnotation());
}
}