Commit ac57304b authored by Munilla Christophe's avatar Munilla Christophe

- fix equinox in FraSCAti bug : remove dependency to the deployer module

- trial fix jboss in FraSCAti bug : remove inherited dependency to osgi-core artifact (update all modules which were using this dependency)

- lighten AbstractResourceClassLoader 

- remove frascati-osgi-context reference from binding-osgi and binding-factory-osgi modules
   
parent ed043b2a
......@@ -64,5 +64,11 @@
<version>2.0.1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
......@@ -70,9 +70,9 @@ public interface FraSCAtiOSGiContext
*/
File getCacheDir();
/**
* This method alerts the FraSCAtiOSGiContext that a binding has been initialized.
* It's used to clean up some memorized data
*/
void bindingHintsInitialized();
// /**
// * This method alerts the FraSCAtiOSGiContext that a binding has been initialized.
// * It's used to clean up some memorized data
// */
// void bindingHintsInitialized();
}
......@@ -41,13 +41,6 @@
<packaging>jar</packaging>
<dependencies>
<!--
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
</dependency>
-->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.enterprise</artifactId>
......
......@@ -44,5 +44,13 @@
<module>introspector-sca</module>
<module>log</module>
</modules>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
......@@ -43,10 +43,10 @@ import org.osgi.framework.ServiceReference;
import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.Reference;
import org.ow2.frascati.assembly.factory.api.ClassLoaderManager;
import org.ow2.frascati.starter.api.AbstractInitializable;
import org.ow2.frascati.osgi.api.FraSCAtiOSGiContext;
import org.ow2.frascati.osgi.security.FraSCAtiOSGiSecurityManager;
import org.ow2.frascati.osgi.util.io.OSGiIOUtils;
import org.ow2.frascati.starter.api.AbstractInitializable;
import org.ow2.frascati.util.FrascatiClassLoader;
import org.ow2.frascati.util.io.IOUtils;
import org.ow2.frascati.util.reflect.ReflectionHelper;
......@@ -65,6 +65,7 @@ extends AbstractInitializable implements FraSCAtiOSGiContext
* The BundleContext assiciated to the FraSCAti instance
*/
private BundleContext bundleContext;
/**
* The ClassLoader Manager used for bindings
*/
......@@ -79,17 +80,19 @@ extends AbstractInitializable implements FraSCAtiOSGiContext
* The cache directory
*/
private File cache;
/**
* The logger
*/
private final Logger log = Logger.getLogger(FraSCAtiOSGiContextImpl.class
.getCanonicalName());
private final Logger log = Logger.getLogger(
FraSCAtiOSGiContextImpl.class.getCanonicalName());
/**
* The required classloader manager.
*/
@Reference(name = "frascati-loader")
private ClassLoaderManager classLoaderManager;
// ---------------------------------------------------------------------------
// Internal methods.
// --------------------------------------------------------------------------
......@@ -127,14 +130,15 @@ extends AbstractInitializable implements FraSCAtiOSGiContext
private void initClassLoader()
{
parentClassLoader = (FrascatiClassLoader)
classLoaderManager.getClassLoader();
classLoaderManager.getClassLoader();
log.log(Level.CONFIG, "ClassLoader parentClassLoader : " +
parentClassLoader);
log.log(Level.INFO, "ClassLoader parentClassLoader : "
+ parentClassLoader);
try
{
clManager = new AbstractResourceClassLoaderManager(
parentClassLoader);
parentClassLoader);
classLoaderManager.setClassLoader(clManager);
......@@ -150,8 +154,7 @@ extends AbstractInitializable implements FraSCAtiOSGiContext
new Object[] { clManager });
} else
{
log.log(Level.CONFIG,
"No FrascatiExplorerClassResolver class "
log.log(Level.CONFIG, "No FrascatiExplorerClassResolver class "
+ "found : Errors could occure using FraSCAti's Explorer "
+ "in Equinox");
}
......@@ -220,16 +223,12 @@ extends AbstractInitializable implements FraSCAtiOSGiContext
*/
public ClassLoader createClassLoader(AbstractResource resource)
{
if(clManager == null)
{
initClassLoader();
}
try
{
AbstractResourceClassLoader cl = new AbstractResourceClassLoader(
clManager, clManager, resource, null);
return cl;
} catch (ResourceAlreadyManagedException e)
{
log.log(Level.WARNING,e.getMessage(),e);
......@@ -250,52 +249,44 @@ extends AbstractInitializable implements FraSCAtiOSGiContext
public void registerBindedInterface(String interfaceName, String filter,
ClassLoader bindingCl)
{
if(clManager == null)
{
initClassLoader();
}
clManager.setResourceLoader(null);
try
{
{
String normalizedFilter = normalizeFilter(filter);
ServiceReference[] references = bundleContext
.getAllServiceReferences(interfaceName, normalizedFilter);
ServiceReference[] references = bundleContext.getAllServiceReferences(
interfaceName, normalizedFilter);
if (references != null && references.length > 0)
{
Bundle bundle = references[0].getBundle();
Class<?> interfaceClass = bundle.loadClass(interfaceName);
if (bundle != null)
// needed by JDTCompiler
String jarFilePath = OSGiIOUtils.cacheBundle(bundle,
getCacheDir());
log.log(Level.CONFIG, "bundle cached : " + jarFilePath);
try
{
// needed by JDTCompiler
String jarFilePath = OSGiIOUtils.cacheBundle(bundle,
getCacheDir());
log.log(Level.CONFIG, "bundle cached : " + jarFilePath);
try
{
URL jarURL = new URL("jar", "", new StringBuilder(
"file:").append(jarFilePath).append("!/")
.toString());
AbstractResource jarResource = AbstractResource.newResource(jarURL);
AbstractResourceClassLoader resourceLoader = new AbstractResourceClassLoader(
parentClassLoader, clManager, jarResource, null);
URL jarURL = new URL("jar", "", new StringBuilder("file:")
.append(jarFilePath).append("!/").toString());
clManager.addLoaded(interfaceName, interfaceClass);
clManager.setResourceLoader(resourceLoader);
} catch (ResourceAlreadyManagedException e)
{
log.log(Level.WARNING,e.getMessage(), e);
} catch (MalformedURLException e)
{
log.log(Level.WARNING,e.getMessage(), e);
}
AbstractResource jarResource = AbstractResource.newResource(jarURL);
AbstractResourceClassLoader resourceLoader = new AbstractResourceClassLoader(
parentClassLoader, clManager, jarResource, null);
clManager.addLoaded(interfaceName, interfaceClass);
clManager.setResourceLoader(resourceLoader);
} catch (ResourceAlreadyManagedException e)
{
log.log(Level.WARNING, e.getMessage(), e);
} catch (MalformedURLException e)
{
log.log(Level.WARNING, e.getMessage(), e);
}
} else
{
log.warning("Binded interface has not been found in the "
+ "BundleContext");
}
} catch (InvalidSyntaxException e)
{
......@@ -316,10 +307,7 @@ extends AbstractInitializable implements FraSCAtiOSGiContext
public void registerExportedInterface(String interfaceName,
String properties, ClassLoader bindingCl)
{
if(clManager == null)
{
initClassLoader();
}
clManager.setResourceLoader(null);
String interfaceSimpleName = interfaceName.substring(interfaceName
.lastIndexOf('.') + 1);
String interfacePackageName = interfaceName.substring(0,
......@@ -360,13 +348,13 @@ extends AbstractInitializable implements FraSCAtiOSGiContext
}
}
/**
* Cleans memorized data after a binding
*/
public void bindingHintsInitialized()
{
clManager.setResourceLoader(null);
}
// /**
// * Cleans memorized data after a binding
// */
// public void bindingHintsInitialized()
// {
// clManager.setResourceLoader(null);
// }
/**
* {@inheritDoc}
......@@ -410,10 +398,6 @@ extends AbstractInitializable implements FraSCAtiOSGiContext
*/
public ClassLoader getClassLoader()
{
if(clManager == null)
{
initClassLoader();
}
return clManager;
}
}
......@@ -138,8 +138,9 @@ public class FraSCAtiOSGiRegistryImpl implements FraSCAtiOSGiRegistry
Class<?> serviceClass = null;
try
{
serviceClass = classLoader.loadClass(serviceType
.getFcItfSignature());
serviceClass = classLoader.loadClass(
serviceType.getFcItfSignature());
} catch (ClassNotFoundException e)
{
log.log(Level.WARNING,e.getMessage(),e);
......@@ -202,8 +203,8 @@ public class FraSCAtiOSGiRegistryImpl implements FraSCAtiOSGiRegistry
{
String[] compositeNames = null;
Map<String, Component> registeredComposites = composites
.remove(new Long(id));
Map<String, Component> registeredComposites = composites.remove(
new Long(id));
if (registeredComposites != null)
{
compositeNames = (String[]) registeredComposites.keySet().toArray(
......@@ -225,14 +226,11 @@ public class FraSCAtiOSGiRegistryImpl implements FraSCAtiOSGiRegistry
*/
public String[] unregisterAll()
{
Bag<String> compositeNames = new Bag<String>()
{
@Override
public String[] EArray(int size)
{
return (String[]) Array.newInstance(String.class, size);
}
};
......@@ -286,9 +284,9 @@ public class FraSCAtiOSGiRegistryImpl implements FraSCAtiOSGiRegistry
*/
public String[] getComposites(long id)
{
Map<String, Component> registeredComposites = composites.get(new Long(
id));
Map<String, Component> registeredComposites = composites.get(
new Long(id));
if (registeredComposites == null)
{
return new String[0];
......@@ -304,7 +302,6 @@ public class FraSCAtiOSGiRegistryImpl implements FraSCAtiOSGiRegistry
*/
public Map<String, Class<?>> getServices(String compositeName)
{
return services.get(compositeName);
}
......@@ -316,9 +313,11 @@ public class FraSCAtiOSGiRegistryImpl implements FraSCAtiOSGiRegistry
*/
public Class<?> getService(String compositeName, String serviceName)
{
Class<?> serviceClass = null;
Map<String, Class<?>> registeredServices = services.get(compositeName);
Map<String, Class<?>> registeredServices = services.get(
compositeName);
if (registeredServices != null)
{
serviceClass = (Class<?>) registeredServices.get(serviceName);
......
......@@ -363,17 +363,15 @@ public class FraSCAtiOSGiServiceImpl extends AbstractInitializable implements
{
ClassLoader compositeClassLoader = foContext.createClassLoader(
resource);
//Thread.currentThread().setContextClassLoader(foContext.getClassLoader());
//Thread.currentThread().setContextClassLoader(foContext.getClassLoader());
Component composite = compositeManager.getComposite(compositeName,
compositeClassLoader);
long bundleId = -1;
try
{
bundleId = ((Bundle) resource.getResourceObject())
.getBundleId();
bundleId = ((Bundle) resource.getResourceObject()).getBundleId();
} catch (ClassCastException e)
{
log.log(Level.CONFIG,e.getMessage(),e);
......
......@@ -43,7 +43,7 @@
</component>
<wire source="sca-parser/frascati-osgi-context" target="frascati-osgi/frascati-osgi-context" />
<wire source="assembly-factory/frascati-osgi-context" target="frascati-osgi/frascati-osgi-context" />
<!-- <wire source="assembly-factory/frascati-osgi-context" target="frascati-osgi/frascati-osgi-context" /> -->
<wire source="assembly-factory/initializable" target="frascati-osgi/frascati-osgi-starter" />
</composite>
......@@ -44,4 +44,13 @@
<module>from-osgi-to-frascati</module>
<module>from-frascati-to-osgi</module>
</modules>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -49,13 +49,6 @@
<artifactId>fractal-bf-connectors-common</artifactId>
<version>${fractal-bf.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
</dependency>
-->
<!-- tests -->
<dependency>
<groupId>junit</groupId>
......
......@@ -38,9 +38,10 @@ import org.osgi.framework.ServiceRegistration;
public class OSGiSkeletonContent extends AbstractSkeletonContent implements
OSGiSkeletonContentAttributes
{
// ---------------------------------------------------------------------------
// --------------------------------------------------------------------------
// Internal state.
// --------------------------------------------------------------------------
private BundleContext bundleContext;
private ServiceRegistration registration;
private Hashtable<String, String> properties;
......@@ -60,6 +61,7 @@ public class OSGiSkeletonContent extends AbstractSkeletonContent implements
public String getProperties()
{
StringBuilder propertiesBuilder = new StringBuilder();
if (properties != null)
{
while (properties.keys().hasMoreElements())
......@@ -68,8 +70,7 @@ public class OSGiSkeletonContent extends AbstractSkeletonContent implements
String value = (String) properties.get(key);
if (value != null)
{
propertiesBuilder
.append(propertiesBuilder.length() > 0 ? "," : "");
propertiesBuilder.append(propertiesBuilder.length() > 0 ? "," : "");
propertiesBuilder.append(key);
propertiesBuilder.append("=");
propertiesBuilder.append(value);
......
......@@ -65,6 +65,7 @@ public class OSGiStubContent extends AbstractStubContent implements
{
ServiceReference[] references = bundleContext.getAllServiceReferences(
getServiceClass().getCanonicalName(), filter);
if (references != null && references.length > 0)
{
serviceObject = bundleContext.getService(references[0]);
......@@ -98,8 +99,7 @@ public class OSGiStubContent extends AbstractStubContent implements
if (filter != null)
{
// The sca syntax is not the same has the osgi one : '!', '|', and
// '&'
// are replaced by 'not', 'or', and 'and' respectively.
// '&' are replaced by 'not', 'or', and 'and' respectively.
this.filter = filter.replaceAll(
"(^|[^a-zA-Z\\-\\.\\_])and([^a-zA-Z\\-\\.\\_])", "$1&$2");
this.filter = this.filter.replaceAll(
......@@ -117,6 +117,7 @@ public class OSGiStubContent extends AbstractStubContent implements
public void serviceChanged(ServiceEvent event)
{
ServiceReference ref = event.getServiceReference();
if (bundleContext.getService(ref) == serviceObject)
{
if (event.getType() == ServiceEvent.UNREGISTERING)
......@@ -134,6 +135,7 @@ public class OSGiStubContent extends AbstractStubContent implements
{
stopFc();
startFc();
} else if (LifeCycleController.STOPPED.equals(fcState))
{
startFc();
......@@ -166,7 +168,9 @@ public class OSGiStubContent extends AbstractStubContent implements
.append(getServiceClass().getCanonicalName())
.append(")").append(filter).append(")")
.toString();
Filter f = bundleContext.createFilter(filter);
} catch (InvalidSyntaxException e)
{
log.info("filter " + filter + " is not valid");
......@@ -181,6 +185,7 @@ public class OSGiStubContent extends AbstractStubContent implements
}
log.info("filter :" + filter);
bundleContext.addServiceListener(this, filter);
} catch (InvalidSyntaxException e)
{
log.log(Level.WARNING,e.getMessage(),e);
......
......@@ -45,14 +45,4 @@
<module>runtime-light</module>
</modules>
<dependencies>
<!--
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
</dependency>
-->
</dependencies>
</project>
......@@ -45,19 +45,11 @@
<name>OW2 FraSCAti OSGi : Runtime Light for FraSCAti in OSGi</name>
<dependencies>
<!--
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
</dependency>
-->
<dependency>
<groupId>org.objectweb.fractal.juliac.osgi</groupId>
<artifactId>juliac-osgi-runtime-core</artifactId>
<version>${juliac.version}</version>
</dependency>
</dependencies>
</project>
......@@ -48,7 +48,6 @@ public class PlatformImpl implements PlatformItf
*/
public static void setBundleContext(BundleContext context)
{
PlatformImpl.context = context;
}
......@@ -59,7 +58,6 @@ public class PlatformImpl implements PlatformItf
*/
public BundleContext getBundleContext() throws IOException, BundleException
{
return context;
}
......@@ -70,7 +68,6 @@ public class PlatformImpl implements PlatformItf
*/
public void stop() throws IOException, BundleException
{
// do nothing
}
}
......@@ -45,5 +45,12 @@
<module>juliac</module>
</modules>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
......@@ -81,6 +81,13 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.objectweb.fractal.juliac.osgi</groupId>
<artifactId>juliac-osgi-runtime-core</artifactId>
<version>${juliac.version}</version>
<scope>provided</scope>
</dependency>
<!-- OW2 FraSCAti OSGI Apis and Resource-->