-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extension module error in event console
- Loading branch information
1 parent
94b892d
commit 7183c9d
Showing
8 changed files
with
320 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
base/org.codehaus.groovy30/src/org/codehaus/groovy/runtime/m12n/MetaInfExtensionModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.codehaus.groovy.runtime.m12n; | ||
|
||
import groovy.lang.GroovyRuntimeException; | ||
|
||
import java.util.ArrayList; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
/** | ||
* A {@link SimpleExtensionModule} implementation which reads extension classes | ||
* metadata from META-INF. | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
public class MetaInfExtensionModule extends SimpleExtensionModule { | ||
/* GRECLIPSE edit | ||
private static final Logger LOG = Logger.getLogger(MetaInfExtensionModule.class.getName()); | ||
*/ | ||
public static final String MODULE_INSTANCE_CLASSES_KEY = "extensionClasses"; | ||
public static final String MODULE_STATIC_CLASSES_KEY = "staticExtensionClasses"; | ||
|
||
private final List<Class> instanceExtensionClasses; | ||
private final List<Class> staticExtensionClasses; | ||
|
||
@Override | ||
public List<Class> getInstanceMethodsExtensionClasses() { | ||
return instanceExtensionClasses; | ||
} | ||
|
||
@Override | ||
public List<Class> getStaticMethodsExtensionClasses() { | ||
return staticExtensionClasses; | ||
} | ||
|
||
private MetaInfExtensionModule(final String moduleName, final String moduleVersion, final List<Class> instanceExtensionClasses, final List<Class> staticExtensionClasses) { | ||
super(moduleName, moduleVersion); | ||
this.instanceExtensionClasses = instanceExtensionClasses; | ||
this.staticExtensionClasses = staticExtensionClasses; | ||
} | ||
|
||
public static MetaInfExtensionModule newModule(final Properties properties, final ClassLoader loader) { | ||
String name = properties.getProperty(PropertiesModuleFactory.MODULE_NAME_KEY); | ||
if (name == null) | ||
throw new GroovyRuntimeException("Module file hasn't set the module name using key [" + PropertiesModuleFactory.MODULE_NAME_KEY + "]"); | ||
String version = properties.getProperty(PropertiesModuleFactory.MODULE_VERSION_KEY); | ||
if (version == null) | ||
throw new GroovyRuntimeException("Module file hasn't set the module version using key [" + PropertiesModuleFactory.MODULE_VERSION_KEY + "]"); | ||
String[] extensionClasses = properties.getProperty(MODULE_INSTANCE_CLASSES_KEY, "").trim().split("[,; ]"); | ||
String[] staticExtensionClasses = properties.getProperty(MODULE_STATIC_CLASSES_KEY, "").trim().split("[,; ]"); | ||
List<Class> instanceClasses = new ArrayList<Class>(extensionClasses.length); | ||
List<Class> staticClasses = new ArrayList<Class>(staticExtensionClasses.length); | ||
List<String> errors = new LinkedList<String>(); | ||
loadExtensionClass(loader, extensionClasses, instanceClasses, errors); | ||
loadExtensionClass(loader, staticExtensionClasses, staticClasses, errors); | ||
if (!errors.isEmpty()) { | ||
/* GRECLIPSE edit | ||
for (String error : errors) { | ||
LOG.warning("Module [" + name + "] - Unable to load extension class [" + error + "]"); | ||
} | ||
*/ | ||
org.codehaus.groovy.eclipse.GroovyLogManager.manager.log(org.codehaus.groovy.eclipse.TraceCategory.CLASSPATH, | ||
"Module [" + name + "] - Unable to load extension class" + (errors.size() > 1 ? "es" : "") + " " + errors); | ||
// GRECLIPSE end | ||
} | ||
return new MetaInfExtensionModule(name, version, instanceClasses, staticClasses); | ||
} | ||
|
||
private static void loadExtensionClass(ClassLoader loader, String[] extensionClasses, List<Class> instanceClasses, List<String> errors) { | ||
for (String extensionClass : extensionClasses) { | ||
try { | ||
extensionClass = extensionClass.trim(); | ||
if (extensionClass.length() > 0) { | ||
instanceClasses.add(loader.loadClass(extensionClass)); | ||
} | ||
} catch (ClassNotFoundException | NoClassDefFoundError | UnsupportedClassVersionError e) { | ||
errors.add(extensionClass); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
base/org.codehaus.groovy40/src/org/codehaus/groovy/runtime/m12n/MetaInfExtensionModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.codehaus.groovy.runtime.m12n; | ||
|
||
import groovy.lang.GroovyRuntimeException; | ||
|
||
import java.util.ArrayList; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
/** | ||
* A {@link SimpleExtensionModule} implementation which reads extension classes | ||
* metadata from META-INF. | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
public class MetaInfExtensionModule extends SimpleExtensionModule { | ||
/* GRECLIPSE edit | ||
private static final Logger LOG = Logger.getLogger(MetaInfExtensionModule.class.getName()); | ||
*/ | ||
public static final String MODULE_INSTANCE_CLASSES_KEY = "extensionClasses"; | ||
public static final String MODULE_STATIC_CLASSES_KEY = "staticExtensionClasses"; | ||
|
||
private final List<Class> instanceExtensionClasses; | ||
private final List<Class> staticExtensionClasses; | ||
|
||
@Override | ||
public List<Class> getInstanceMethodsExtensionClasses() { | ||
return instanceExtensionClasses; | ||
} | ||
|
||
@Override | ||
public List<Class> getStaticMethodsExtensionClasses() { | ||
return staticExtensionClasses; | ||
} | ||
|
||
private MetaInfExtensionModule(final String moduleName, final String moduleVersion, final List<Class> instanceExtensionClasses, final List<Class> staticExtensionClasses) { | ||
super(moduleName, moduleVersion); | ||
this.instanceExtensionClasses = instanceExtensionClasses; | ||
this.staticExtensionClasses = staticExtensionClasses; | ||
} | ||
|
||
public static MetaInfExtensionModule newModule(final Properties properties, final ClassLoader loader) { | ||
String name = properties.getProperty(PropertiesModuleFactory.MODULE_NAME_KEY); | ||
if (name == null) | ||
throw new GroovyRuntimeException("Module file hasn't set the module name using key [" + PropertiesModuleFactory.MODULE_NAME_KEY + "]"); | ||
String version = properties.getProperty(PropertiesModuleFactory.MODULE_VERSION_KEY); | ||
if (version == null) | ||
throw new GroovyRuntimeException("Module file hasn't set the module version using key [" + PropertiesModuleFactory.MODULE_VERSION_KEY + "]"); | ||
String[] extensionClasses = properties.getProperty(MODULE_INSTANCE_CLASSES_KEY, "").trim().split("[,; ]"); | ||
String[] staticExtensionClasses = properties.getProperty(MODULE_STATIC_CLASSES_KEY, "").trim().split("[,; ]"); | ||
List<Class> instanceClasses = new ArrayList<Class>(extensionClasses.length); | ||
List<Class> staticClasses = new ArrayList<Class>(staticExtensionClasses.length); | ||
List<String> errors = new LinkedList<String>(); | ||
loadExtensionClass(loader, extensionClasses, instanceClasses, errors); | ||
loadExtensionClass(loader, staticExtensionClasses, staticClasses, errors); | ||
if (!errors.isEmpty()) { | ||
/* GRECLIPSE edit | ||
for (String error : errors) { | ||
LOG.warning("Module [" + name + "] - Unable to load extension class [" + error + "]"); | ||
} | ||
*/ | ||
org.codehaus.groovy.eclipse.GroovyLogManager.manager.log(org.codehaus.groovy.eclipse.TraceCategory.CLASSPATH, | ||
"Module [" + name + "] - Unable to load extension class" + (errors.size() > 1 ? "es" : "") + " " + errors); | ||
// GRECLIPSE end | ||
} | ||
return new MetaInfExtensionModule(name, version, instanceClasses, staticClasses); | ||
} | ||
|
||
private static void loadExtensionClass(ClassLoader loader, String[] extensionClasses, List<Class> instanceClasses, List<String> errors) { | ||
for (String extensionClass : extensionClasses) { | ||
try { | ||
extensionClass = extensionClass.trim(); | ||
if (extensionClass.length() > 0) { | ||
instanceClasses.add(loader.loadClass(extensionClass)); | ||
} | ||
} catch (ClassNotFoundException | NoClassDefFoundError | UnsupportedClassVersionError e) { | ||
errors.add(extensionClass); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
base/org.codehaus.groovy50/src/org/codehaus/groovy/runtime/m12n/MetaInfExtensionModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.codehaus.groovy.runtime.m12n; | ||
|
||
import groovy.lang.GroovyRuntimeException; | ||
|
||
import java.util.ArrayList; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
/** | ||
* A {@link SimpleExtensionModule} implementation which reads extension classes | ||
* metadata from META-INF. | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
public class MetaInfExtensionModule extends SimpleExtensionModule { | ||
/* GRECLIPSE edit | ||
private static final Logger LOG = Logger.getLogger(MetaInfExtensionModule.class.getName()); | ||
*/ | ||
public static final String MODULE_INSTANCE_CLASSES_KEY = "extensionClasses"; | ||
public static final String MODULE_STATIC_CLASSES_KEY = "staticExtensionClasses"; | ||
|
||
private final List<Class> instanceExtensionClasses; | ||
private final List<Class> staticExtensionClasses; | ||
|
||
@Override | ||
public List<Class> getInstanceMethodsExtensionClasses() { | ||
return instanceExtensionClasses; | ||
} | ||
|
||
@Override | ||
public List<Class> getStaticMethodsExtensionClasses() { | ||
return staticExtensionClasses; | ||
} | ||
|
||
private MetaInfExtensionModule(final String moduleName, final String moduleVersion, final List<Class> instanceExtensionClasses, final List<Class> staticExtensionClasses) { | ||
super(moduleName, moduleVersion); | ||
this.instanceExtensionClasses = instanceExtensionClasses; | ||
this.staticExtensionClasses = staticExtensionClasses; | ||
} | ||
|
||
public static MetaInfExtensionModule newModule(final Properties properties, final ClassLoader loader) { | ||
String name = properties.getProperty(PropertiesModuleFactory.MODULE_NAME_KEY); | ||
if (name == null) | ||
throw new GroovyRuntimeException("Module file hasn't set the module name using key [" + PropertiesModuleFactory.MODULE_NAME_KEY + "]"); | ||
String version = properties.getProperty(PropertiesModuleFactory.MODULE_VERSION_KEY); | ||
if (version == null) | ||
throw new GroovyRuntimeException("Module file hasn't set the module version using key [" + PropertiesModuleFactory.MODULE_VERSION_KEY + "]"); | ||
String[] extensionClasses = properties.getProperty(MODULE_INSTANCE_CLASSES_KEY, "").trim().split("[,; ]"); | ||
String[] staticExtensionClasses = properties.getProperty(MODULE_STATIC_CLASSES_KEY, "").trim().split("[,; ]"); | ||
List<Class> instanceClasses = new ArrayList<Class>(extensionClasses.length); | ||
List<Class> staticClasses = new ArrayList<Class>(staticExtensionClasses.length); | ||
List<String> errors = new LinkedList<String>(); | ||
loadExtensionClass(loader, extensionClasses, instanceClasses, errors); | ||
loadExtensionClass(loader, staticExtensionClasses, staticClasses, errors); | ||
if (!errors.isEmpty()) { | ||
/* GRECLIPSE edit | ||
for (String error : errors) { | ||
LOG.warning("Module [" + name + "] - Unable to load extension class [" + error + "]"); | ||
} | ||
*/ | ||
org.codehaus.groovy.eclipse.GroovyLogManager.manager.log(org.codehaus.groovy.eclipse.TraceCategory.CLASSPATH, | ||
"Module [" + name + "] - Unable to load extension class" + (errors.size() > 1 ? "es" : "") + " " + errors); | ||
// GRECLIPSE end | ||
} | ||
return new MetaInfExtensionModule(name, version, instanceClasses, staticClasses); | ||
} | ||
|
||
private static void loadExtensionClass(ClassLoader loader, String[] extensionClasses, List<Class> instanceClasses, List<String> errors) { | ||
for (String extensionClass : extensionClasses) { | ||
try { | ||
extensionClass = extensionClass.trim(); | ||
if (extensionClass.length() > 0) { | ||
instanceClasses.add(loader.loadClass(extensionClass)); | ||
} | ||
} catch (ClassNotFoundException | NoClassDefFoundError | UnsupportedClassVersionError e) { | ||
errors.add(extensionClass); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters