Commit 0f41646b authored by Munilla Christophe's avatar Munilla Christophe
Browse files

osgi : trial changes to fix bug in windows os

nuxeo : cosmetic changes
parent a112fe4b
...@@ -87,9 +87,7 @@ public class FraSCAtiIsolated ...@@ -87,9 +87,7 @@ public class FraSCAtiIsolated
*/ */
public FraSCAtiIsolated(File frascatiRootDirectory, ClassLoader parentClassLoader) public FraSCAtiIsolated(File frascatiRootDirectory, ClassLoader parentClassLoader)
throws Exception throws Exception
{ {
char sep = File.separatorChar;
//if the librariesDirectory is null //if the librariesDirectory is null
if (frascatiRootDirectory == null) if (frascatiRootDirectory == null)
{ {
...@@ -294,6 +292,7 @@ public class FraSCAtiIsolated ...@@ -294,6 +292,7 @@ public class FraSCAtiIsolated
Object container = getComponent(component,servicePath); Object container = getComponent(component,servicePath);
@SuppressWarnings("unchecked")
T service = (T) frascatiClass.getDeclaredMethod( T service = (T) frascatiClass.getDeclaredMethod(
"getService", new Class<?>[] { componentClass, String.class, Class.class }) "getService", new Class<?>[] { componentClass, String.class, Class.class })
.invoke(frascati, new Object[] { container, serviceName, serviceClass}); .invoke(frascati, new Object[] { container, serviceName, serviceClass});
......
...@@ -31,7 +31,7 @@ import org.ow2.frascati.nuxeo.api.FraSCAtiInNuxeoServiceBaseItf; ...@@ -31,7 +31,7 @@ import org.ow2.frascati.nuxeo.api.FraSCAtiInNuxeoServiceBaseItf;
import org.ow2.frascati.nuxeo.exception.FraSCAtiInNuxeoException; import org.ow2.frascati.nuxeo.exception.FraSCAtiInNuxeoException;
/** /**
* Base FraSCAtiInNuxeoServiceProviderItf implmentation * Base FraSCAtiInNuxeoServiceProviderItf implementation
*/ */
public class FraSCAtiInNuxeoBase extends AbstractFraSCAtiInNuxeo<FraSCAtiInNuxeoServiceBaseItf> public class FraSCAtiInNuxeoBase extends AbstractFraSCAtiInNuxeo<FraSCAtiInNuxeoServiceBaseItf>
{ {
......
...@@ -39,6 +39,12 @@ public class FraSCAtiInNuxeoFactoryBase ...@@ -39,6 +39,12 @@ public class FraSCAtiInNuxeoFactoryBase
extends AbstractFraSCAtiInNuxeoFactory<FraSCAtiInNuxeoServiceBaseItf,FraSCAtiInNuxeoBase> extends AbstractFraSCAtiInNuxeoFactory<FraSCAtiInNuxeoServiceBaseItf,FraSCAtiInNuxeoBase>
{ {
/**
* {@inheritDoc}
*
* @see org.ow2.frascati.nuxeo.api.AbstractFraSCAtiInNuxeoFactory#
* getFraSCAtiInNuxeoInstance(java.lang.String, java.lang.ClassLoader)
*/
public FraSCAtiInNuxeoBase getFraSCAtiInNuxeoInstance(String libBaseDir, public FraSCAtiInNuxeoBase getFraSCAtiInNuxeoInstance(String libBaseDir,
ClassLoader parent) ClassLoader parent)
{ {
......
...@@ -25,19 +25,13 @@ ...@@ -25,19 +25,13 @@
*/ */
package org.ow2.frascati.util.resource.cobundle; package org.ow2.frascati.util.resource.cobundle;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.jar.JarFile;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.zip.ZipEntry;
import org.objectweb.fractal.juliac.osgi.concierge.Concierge;
import org.objectweb.fractal.juliac.osgi.revision.api.BundleRevisionItf; import org.objectweb.fractal.juliac.osgi.revision.api.BundleRevisionItf;
import org.ow2.frascati.osgi.util.io.OSGiIOUtils; import org.ow2.frascati.osgi.util.io.OSGiIOUtils;
import org.ow2.frascati.util.io.IOUtils;
import org.ow2.frascati.util.resource.AbstractResource; import org.ow2.frascati.util.resource.AbstractResource;
/** /**
...@@ -64,7 +58,8 @@ public class Resource extends AbstractResource ...@@ -64,7 +58,8 @@ public class Resource extends AbstractResource
@Override @Override
protected URL getEntry(String entry) protected URL getEntry(String entry)
{ {
String formatEntry = entry.startsWith("/")?entry.substring(1):entry; String formatEntry = (entry.startsWith("/") || entry.startsWith("\\"))?
entry.substring(1):entry;
URL entryURL = bundleResource.getEntry(formatEntry); URL entryURL = bundleResource.getEntry(formatEntry);
return entryURL; return entryURL;
} }
......
...@@ -351,10 +351,17 @@ public abstract class AbstractResource ...@@ -351,10 +351,17 @@ public abstract class AbstractResource
String entry = resourceEntries.nextElement(); String entry = resourceEntries.nextElement();
boolean newList = false; boolean newList = false;
entry = entry.endsWith("/")?entry.substring(0,entry.length()-1):entry; entry = (entry.endsWith("/") || entry.endsWith("\\"))?
entry = entry.startsWith("/")?entry.substring(1):entry; entry.substring(0,entry.length()-1):entry;
int index = entry.lastIndexOf('/');
entry = (entry.startsWith("/") || entry.startsWith("\\"))?
entry.substring(1):entry;
int index = entry.lastIndexOf('/');
if(index == -1 && File.separatorChar!='/')
{
index = entry.lastIndexOf('\\');
}
String packageName = index==-1? String packageName = index==-1?
"_root_":entry.substring(0,index).replace('/','.').replace('\\','.'); "_root_":entry.substring(0,index).replace('/','.').replace('\\','.');
String resourceName = index==-1?entry:entry.substring(index+1); String resourceName = index==-1?entry:entry.substring(index+1);
...@@ -408,9 +415,12 @@ public abstract class AbstractResource ...@@ -408,9 +415,12 @@ public abstract class AbstractResource
*/ */
public URL getResource(String packageName,String resourceName,String searched, boolean exact) public URL getResource(String packageName,String resourceName,String searched, boolean exact)
{ {
String entry = searched.endsWith("/")?searched.substring(0, String entry = (searched.endsWith("/") || searched.endsWith("\\"))?
searched.length()-1):searched; searched.substring(0,searched.length()-1):searched;
entry = entry.startsWith("/")?entry.substring(1):entry;
entry = (entry.startsWith("/") || entry.startsWith("\\"))?
entry.substring(1):entry;
if(exact) if(exact)
{ {
List<String> list = entries.get(packageName); List<String> list = entries.get(packageName);
...@@ -460,9 +470,11 @@ public abstract class AbstractResource ...@@ -460,9 +470,11 @@ public abstract class AbstractResource
*/ */
public void getResources(String packageName,String resourceName,String searched, List<URL> results) public void getResources(String packageName,String resourceName,String searched, List<URL> results)
{ {
String entry = searched.endsWith("/")?searched.substring(0, String entry = (searched.endsWith("/") || searched.endsWith("\\"))?
searched.length()-1):searched; searched.substring(0,searched.length()-1):searched;
entry = entry.startsWith("/")?entry.substring(1):entry;
entry = (entry.startsWith("/") || entry.startsWith("\\"))?
entry.substring(1):entry;
for(String packageNameItem : entries.keySet()) for(String packageNameItem : entries.keySet())
{ {
...@@ -611,8 +623,12 @@ public abstract class AbstractResource ...@@ -611,8 +623,12 @@ public abstract class AbstractResource
} }
try try
{ {
String resourceCopyName = embeddedResourceName int index = embeddedResourceName.lastIndexOf('/');
.substring(embeddedResourceName.lastIndexOf('/') + 1); if(index == -1 && File.separatorChar!='/')
{
index = embeddedResourceName.lastIndexOf('\\');
}
String resourceCopyName = embeddedResourceName.substring(index + 1);
String resourceCopyPath = new StringBuilder(cacheDirPath) String resourceCopyPath = new StringBuilder(cacheDirPath)
.append(File.separatorChar).append(resourceCopyName) .append(File.separatorChar).append(resourceCopyName)
.toString(); .toString();
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
*/ */
package org.ow2.frascati.util.resource.bundle; package org.ow2.frascati.util.resource.bundle;
import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.Enumeration; import java.util.Enumeration;
...@@ -117,14 +118,8 @@ public class Resource extends AbstractResource ...@@ -117,14 +118,8 @@ public class Resource extends AbstractResource
String location = bundleResource.getLocation(); String location = bundleResource.getLocation();
try try
{ {
if (!location.startsWith("file:")) resourceURL = new File(location).getAbsoluteFile().toURI().toURL();
{
resourceURL = new URL("file", "", location);
} else
{
resourceURL = new URL(location);
}
}catch (MalformedURLException e) }catch (MalformedURLException e)
{ {
log.log(Level.CONFIG,e.getMessage(),e); log.log(Level.CONFIG,e.getMessage(),e);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
*/ */
package org.ow2.frascati.util.resource.bundler; package org.ow2.frascati.util.resource.bundler;
import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.Enumeration; import java.util.Enumeration;
...@@ -113,14 +114,8 @@ public class Resource extends AbstractResource ...@@ -113,14 +114,8 @@ public class Resource extends AbstractResource
String location = bundleResource.getLocation(); String location = bundleResource.getLocation();
try try
{ {
if (!location.startsWith("file:")) resourceURL = new File(location).getAbsoluteFile().toURI().toURL();
{
resourceURL = new URL("file", "", location);
} else
{
resourceURL = new URL(location);
}
}catch (MalformedURLException e) }catch (MalformedURLException e)
{ {
log.log(Level.CONFIG,e.getMessage(),e); log.log(Level.CONFIG,e.getMessage(),e);
......
...@@ -220,16 +220,17 @@ public class Resource extends AbstractResource ...@@ -220,16 +220,17 @@ public class Resource extends AbstractResource
try try
{ {
File tmpDir = IOUtils.getTmpDir(); File tmpDir = IOUtils.getTmpDir();
String simpleResourceName = IOUtils String simpleResourceName = IOUtils.pathLastPart(embeddedResourceName);
.pathLastPart(embeddedResourceName);
File resourceCopy = new File(new StringBuilder( File resourceCopy = new File(new StringBuilder(
tmpDir.getAbsolutePath()).append(File.separatorChar) tmpDir.getAbsolutePath()).append(File.separatorChar
.append(simpleResourceName).toString()); ).append(simpleResourceName).toString());
String resourceCopyPath = resourceCopy.getAbsolutePath(); String resourceCopyPath = resourceCopy.getAbsolutePath();
IOUtils.copyFromStream(resURL.openStream(), resourceCopyPath); IOUtils.copyFromStream(resURL.openStream(), resourceCopyPath);
resURL = new URL("jar", "", new StringBuilder("file:") resURL = new URL("jar", "", new StringBuilder(new File(resourceCopyPath
.append(resourceCopyPath).append("!/").toString()); ).toURI().toURL().toExternalForm()).append("!/").toString());
return newResource(this,resURL); return newResource(this,resURL);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment