Révision 3675
| TXM/trunk/bundles/org.txm.groovy.core/.classpath (revision 3675) | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
| 2 |
<classpath> |
|
| 3 |
<classpathentry kind="src" path="src/java" /> |
|
| 4 |
<classpathentry exported="true" kind="lib" path="bin/" /> |
|
| 5 |
<classpathentry kind="con" |
|
| 6 |
path="org.eclipse.jdt.launching.JRE_CONTAINER" /> |
|
| 7 |
<classpathentry kind="con" |
|
| 8 |
path="org.eclipse.pde.core.requiredPlugins"> |
|
| 9 |
<accessrules> |
|
| 10 |
<accessrule kind="accessible" pattern="**" /> |
|
| 11 |
</accessrules> |
|
| 12 |
</classpathentry> |
|
| 13 |
<classpathentry kind="con" path="GROOVY_DSL_SUPPORT" /> |
|
| 14 |
<classpathentry kind="output" path="bin" /> |
|
| 15 |
</classpath> |
|
| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
| 2 |
<classpath> |
|
| 3 |
<classpathentry kind="src" path="src/java"/> |
|
| 4 |
<classpathentry kind="lib" path="bin/"/> |
|
| 5 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> |
|
| 6 |
<attributes> |
|
| 7 |
<attribute name="module" value="true"/> |
|
| 8 |
</attributes> |
|
| 9 |
</classpathentry> |
|
| 10 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"> |
|
| 11 |
<accessrules> |
|
| 12 |
<accessrule kind="accessible" pattern="**"/> |
|
| 13 |
</accessrules> |
|
| 14 |
</classpathentry> |
|
| 15 |
<classpathentry kind="con" path="GROOVY_DSL_SUPPORT"/> |
|
| 16 |
<classpathentry kind="output" path="bin"/> |
|
| 17 |
</classpath> |
|
| TXM/trunk/bundles/org.txm.groovy.core/src/java/org/txm/groovy/core/TXMClassLoader.java (revision 3675) | ||
|---|---|---|
| 5 | 5 |
import java.util.HashSet; |
| 6 | 6 |
|
| 7 | 7 |
import org.eclipse.osgi.internal.loader.EquinoxClassLoader; |
| 8 |
import org.txm.utils.logger.Log; |
|
| 8 | 9 |
|
| 9 |
import cern.colt.Arrays; |
|
| 10 |
|
|
| 11 | 10 |
/** |
| 12 | 11 |
* Class loader that looking for a class in all installed RCP Bundle then load it. |
| 13 | 12 |
* |
| ... | ... | |
| 18 | 17 |
|
| 19 | 18 |
private HashMap<String, EquinoxClassLoader> loaders; |
| 20 | 19 |
|
| 21 |
private HashMap<String, HashSet<EquinoxClassLoader>> packageToLoaders = new HashMap<String, HashSet<EquinoxClassLoader>>();
|
|
| 20 |
private HashMap<String, HashSet<EquinoxClassLoader>> packageToLoaders; |
|
| 22 | 21 |
|
| 23 |
ClassLoader defaultLoader; |
|
| 22 |
private ClassLoader defaultLoader;
|
|
| 24 | 23 |
|
| 24 |
/** |
|
| 25 |
* |
|
| 26 |
* @param defaultLoader |
|
| 27 |
* @param loaders2 |
|
| 28 |
*/ |
|
| 25 | 29 |
public TXMClassLoader(ClassLoader defaultLoader, HashSet<EquinoxClassLoader> loaders2) {
|
| 26 | 30 |
this.loaders = new HashMap<>(); |
| 27 | 31 |
|
| 28 | 32 |
boolean useFastIndex = GroovyPreferences.getInstance().getBoolean(GroovyPreferences.FAST_PACKAGE_INDEX); |
| 29 | 33 |
|
| 34 |
if(useFastIndex) {
|
|
| 35 |
Log.finest("Fast package index option is activated."); //$NON-NLS-1$
|
|
| 36 |
this.packageToLoaders = new HashMap<String, HashSet<EquinoxClassLoader>>(); |
|
| 37 |
} |
|
| 38 |
|
|
| 30 | 39 |
for (EquinoxClassLoader loader : loaders2) {
|
| 31 | 40 |
|
| 32 | 41 |
String k = loader.getBundle().getSymbolicName(); |
| ... | ... | |
| 35 | 44 |
|
| 36 | 45 |
if (useFastIndex) {
|
| 37 | 46 |
Dictionary<String, String> d = loader.getBundle().getHeaders(); |
| 38 |
String packagesString = d.get("Export-Package");
|
|
| 47 |
String packagesString = d.get("Export-Package"); //$NON-NLS-1$
|
|
| 39 | 48 |
if (packagesString != null) {
|
| 40 |
packagesString = packagesString.replace("\n", "");
|
|
| 41 |
for (String p : packagesString.split(",")) {
|
|
| 49 |
packagesString = packagesString.replace("\n", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 50 |
for (String p : packagesString.split(",")) { //$NON-NLS-1$
|
|
| 42 | 51 |
p = p.trim(); |
| 43 |
if (p.contains(";")) p = p.substring(p.indexOf(";"));
|
|
| 52 |
if (p.contains(";")) p = p.substring(p.indexOf(";")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 44 | 53 |
if (!packageToLoaders.containsKey(p)) {
|
| 45 | 54 |
HashSet<EquinoxClassLoader> tmp = new HashSet<EquinoxClassLoader>(); |
| 46 | 55 |
packageToLoaders.put(p, tmp); |
| ... | ... | |
| 73 | 82 |
p = ""; |
| 74 | 83 |
} |
| 75 | 84 |
|
| 76 |
if (packageToLoaders.containsKey(p)) {
|
|
| 85 |
if (packageToLoaders != null && packageToLoaders.containsKey(p)) {
|
|
| 77 | 86 |
for (EquinoxClassLoader loader : packageToLoaders.get(p)) {
|
| 78 | 87 |
if (loader != null) {
|
| 79 | 88 |
Class<?> c = loader.loadClass(name); |
| 80 |
//System.out.println("load from "+loaderName+": "+name);
|
|
| 89 |
//System.out.println("load from " + loader.getName() + ": " + name);
|
|
| 81 | 90 |
return c; |
| 82 | 91 |
} |
| 83 | 92 |
} |
| TXM/trunk/bundles/org.txm.groovy.core/src/java/org/txm/groovy/core/GSERunner.java (revision 3675) | ||
|---|---|---|
| 61 | 61 |
* @return |
| 62 | 62 |
*/ |
| 63 | 63 |
public static GSERunner buildDefaultGSE() {
|
| 64 |
File rootDir = new File(Toolbox.getTxmHomePath(), "scripts/groovy/"); |
|
| 64 |
File rootDir = new File(Toolbox.getTxmHomePath(), "scripts/groovy/"); //$NON-NLS-1$
|
|
| 65 | 65 |
// check if script root dir was changed |
| 66 | 66 |
if (defaultScriptRootDir != null && defaultScriptRootDir.equals(rootDir) && defaultGSE != null) {
|
| 67 | 67 |
// try {
|
| ... | ... | |
| 80 | 80 |
|
| 81 | 81 |
try {
|
| 82 | 82 |
defaultScriptRootDir = rootDir; |
| 83 |
Log.fine("GSE roots: " + Arrays.toString(roots));
|
|
| 83 |
Log.fine("GSE roots: " + Arrays.toString(roots)); //$NON-NLS-1$
|
|
| 84 | 84 |
defaultGSE = new GSERunner(roots); |
| 85 | 85 |
} |
| 86 | 86 |
catch (IOException e) {
|
| ... | ... | |
| 89 | 89 |
} |
| 90 | 90 |
|
| 91 | 91 |
ImportCustomizer imports = new ImportCustomizer(); |
| 92 |
imports.addStarImports("org.txm.rcp.utils",
|
|
| 93 |
"org.txm.utils", |
|
| 94 |
"org.txm", |
|
| 95 |
"org.kohsuke.args4j", |
|
| 96 |
"org.txm.rcp.swt.widget.parameters"); |
|
| 97 |
imports.addImports("groovy.transform.Field");
|
|
| 92 |
imports.addStarImports("org.txm.rcp.utils", //$NON-NLS-1$
|
|
| 93 |
"org.txm.utils", //$NON-NLS-1$
|
|
| 94 |
"org.txm", //$NON-NLS-1$
|
|
| 95 |
"org.kohsuke.args4j", //$NON-NLS-1$
|
|
| 96 |
"org.txm.rcp.swt.widget.parameters"); //$NON-NLS-1$
|
|
| 97 |
imports.addImports("groovy.transform.Field"); //$NON-NLS-1$
|
|
| 98 | 98 |
CompilerConfiguration configuration = new CompilerConfiguration(); |
| 99 | 99 |
configuration.addCompilationCustomizers(imports); |
| 100 | 100 |
|
| ... | ... | |
| 122 | 122 |
|
| 123 | 123 |
@Override |
| 124 | 124 |
public boolean accept(File dir, String name) {
|
| 125 |
return name.endsWith(".jar") || name.endsWith(".so") || name.endsWith(".dylib") || name.endsWith(".dll"); //$NON-NLS-1$
|
|
| 125 |
return name.endsWith(".jar") || name.endsWith(".so") || name.endsWith(".dylib") || name.endsWith(".dll"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
| 126 | 126 |
} |
| 127 | 127 |
})) {
|
| 128 | 128 |
try {
|
| ... | ... | |
| 149 | 149 |
// get field sourceCache |
| 150 | 150 |
Field field; |
| 151 | 151 |
try {
|
| 152 |
field = gcl.getClass().getSuperclass().getDeclaredField("sourceCache");
|
|
| 152 |
field = gcl.getClass().getSuperclass().getDeclaredField("sourceCache"); //$NON-NLS-1$
|
|
| 153 | 153 |
field.setAccessible(true); |
| 154 | 154 |
Map<String, Class> sourceCache = (Map<String, Class>) field.get(gcl); |
| 155 | 155 |
|
| ... | ... | |
| 157 | 157 |
URLClassLoader classLoader = new URLClassLoader(new URL[]{target.toURI().toURL()}, Thread.currentThread().getContextClassLoader());
|
| 158 | 158 |
|
| 159 | 159 |
for (File clazzFile : DeleteDir.scanDirectory(target, true, true)) {
|
| 160 |
if (!clazzFile.getName().endsWith(".class")) continue;
|
|
| 160 |
if (!clazzFile.getName().endsWith(".class")) continue; //$NON-NLS-1$
|
|
| 161 | 161 |
String fullclassname = clazzFile.getAbsolutePath().substring(target.getAbsolutePath().length()+1); |
| 162 |
fullclassname = fullclassname.replace("/", ".");
|
|
| 163 |
fullclassname = fullclassname.replace("\\", ".");
|
|
| 162 |
fullclassname = fullclassname.replace("/", "."); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 163 |
fullclassname = fullclassname.replace("\\", "."); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 164 | 164 |
fullclassname = fullclassname.substring(0, fullclassname.length()-6); |
| 165 | 165 |
Class<?> clazz = Class.forName(fullclassname, true, classLoader); |
| 166 | 166 |
sourceCache.put(clazzFile.getAbsolutePath(), clazz); |
| ... | ... | |
| 183 | 183 |
|
| 184 | 184 |
Bundle rcpBundle = BundleUtils.getBundle(bundle); |
| 185 | 185 |
if (rcpBundle == null) return; |
| 186 |
String dependanciesString = rcpBundle.getHeaders().get("Require-Bundle");
|
|
| 186 |
String dependanciesString = rcpBundle.getHeaders().get("Require-Bundle"); //$NON-NLS-1$
|
|
| 187 | 187 |
if (dependanciesString == null) return; |
| 188 | 188 |
// System.out.println("Require-Bundle: "+dependanciesString);
|
| 189 | 189 |
for (String dependancy : dependanciesString.split(",")) {
|
| 190 |
String name = dependancy.split(";", 2)[0];
|
|
| 190 |
String name = dependancy.split(";", 2)[0]; //$NON-NLS-1$
|
|
| 191 | 191 |
defaultPlugins.add(name); |
| 192 | 192 |
getDependancies(name, defaultPlugins); |
| 193 | 193 |
} |
| ... | ... | |
| 233 | 233 |
loaders.remove(loader.getParent()); |
| 234 | 234 |
} |
| 235 | 235 |
|
| 236 |
if ("org.txm.rcp".equals(name)) {
|
|
| 236 |
if ("org.txm.rcp".equals(name)) { //$NON-NLS-1$
|
|
| 237 | 237 |
defaultLoader = loader; |
| 238 | 238 |
} |
| 239 | 239 |
// FIXME: debug |
Formats disponibles : Unified diff