-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9ad0a47
Showing
8 changed files
with
591 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
build | ||
.gradle | ||
classloader.iml | ||
classloader.ipr | ||
classloader.iws |
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,30 @@ | ||
apply plugin: 'groovy' | ||
apply plugin: 'idea' | ||
|
||
slf4jVersion = '1.6.3' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
groovy 'org.codehaus.groovy:groovy-all:1.8.5' | ||
compile('log4j:log4j:1.2.16') { | ||
exclude group: 'ant', module: 'ant-nodeps' | ||
exclude group: 'ant', module: 'ant-junit' | ||
exclude group: 'ant-contrib', module: 'ant-contrib' | ||
} | ||
compile("org.slf4j:slf4j-log4j12:$slf4jVersion") { | ||
exclude group: 'org.slf4j', module: 'slf4j-api' | ||
exclude group: 'log4j', module: 'log4j' | ||
} | ||
compile("org.slf4j:slf4j-api:$slf4jVersion") | ||
compile("org.slf4j:jcl-over-slf4j:$slf4jVersion") { | ||
exclude group: 'org.slf4j', module: 'slf4j-api' | ||
} | ||
compile("org.slf4j:jul-to-slf4j:$slf4jVersion") { | ||
exclude group: 'org.slf4j', module: 'slf4j-api' | ||
} | ||
compile('commons-lang:commons-lang:2.6') | ||
testCompile 'junit:junit:4.10' | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/groovy/org/codehaus/griffon/classloader/ClasspathModule.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,50 @@ | ||
/* | ||
* Copyright 2012 the original author or authors. | ||
* | ||
* Licensed 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.griffon.classloader; | ||
|
||
/** | ||
* @author Andres Almiray | ||
*/ | ||
public class ClasspathModule { | ||
private final ClasspathModuleConfiguration configuration; | ||
private final ClassLoader classLoader; | ||
private boolean active = true; | ||
|
||
public ClasspathModule(ClasspathModuleConfiguration configuration, ClassLoader classLoader) { | ||
this.configuration = configuration; | ||
this.classLoader = classLoader; | ||
} | ||
|
||
public String getName() { | ||
return getConfiguration().getName(); | ||
} | ||
|
||
public ClasspathModuleConfiguration getConfiguration() { | ||
return configuration; | ||
} | ||
|
||
public ClassLoader getClassLoader() { | ||
return classLoader; | ||
} | ||
|
||
public boolean isActive() { | ||
return active; | ||
} | ||
|
||
public void setActive(boolean active) { | ||
this.active = active; | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
src/main/groovy/org/codehaus/griffon/classloader/ClasspathModuleConfiguration.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,79 @@ | ||
/* | ||
* Copyright 2012 the original author or authors. | ||
* | ||
* Licensed 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.griffon.classloader; | ||
|
||
import java.net.URL; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* @author Andres Almiray | ||
*/ | ||
public class ClasspathModuleConfiguration { | ||
private final String name; | ||
private final URL[] urls; | ||
private final String toStringValue; | ||
private final int hashCodeValue; | ||
|
||
public ClasspathModuleConfiguration(String name, URL[] urls) { | ||
this.urls = urls; | ||
this.name = name; | ||
this.toStringValue = "<" + name + ">" + Arrays.toString(urls); | ||
this.hashCodeValue = computeHashCode(); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public URL[] getUrls() { | ||
return urls; | ||
} | ||
|
||
public String toString() { | ||
return toStringValue; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof ClasspathModuleConfiguration)) return false; | ||
|
||
ClasspathModuleConfiguration that = (ClasspathModuleConfiguration) o; | ||
|
||
if (!name.equals(that.name)) return false; | ||
if (!Arrays.equals(sort(urls), sort(that.urls))) return false; | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return hashCodeValue; | ||
} | ||
|
||
private URL[] sort(URL[] urls) { | ||
URL[] copy = new URL[urls.length]; | ||
System.arraycopy(urls, 0, copy, 0, 0); | ||
Arrays.sort(copy); | ||
return copy; | ||
} | ||
|
||
private int computeHashCode() { | ||
int result = name.hashCode(); | ||
result = 31 * result + Arrays.hashCode(urls); | ||
return result; | ||
} | ||
} |
Oops, something went wrong.