Skip to content

Commit 51166d9

Browse files
committed
Updated for 1.2.2
1 parent b41ed54 commit 51166d9

File tree

7 files changed

+668
-428
lines changed

7 files changed

+668
-428
lines changed

pom.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.red5</groupId>
55
<artifactId>red5-parent</artifactId>
6-
<version>1.2.1</version>
6+
<version>1.2.2</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>red5-service</artifactId>
@@ -82,6 +82,7 @@
8282
</plugin>
8383
<plugin>
8484
<artifactId>maven-dependency-plugin</artifactId>
85+
<version>2.10</version>
8586
<executions>
8687
<execution>
8788
<id>copy-dependencies</id>
@@ -126,9 +127,16 @@
126127
<plugin>
127128
<artifactId>maven-source-plugin</artifactId>
128129
</plugin>
130+
<plugin>
131+
<artifactId>maven-toolchains-plugin</artifactId>
132+
</plugin>
129133
<plugin>
130134
<artifactId>maven-javadoc-plugin</artifactId>
131135
</plugin>
136+
<plugin>
137+
<groupId>net.revelc.code.formatter</groupId>
138+
<artifactId>formatter-maven-plugin</artifactId>
139+
</plugin>
132140
</plugins>
133141
</build>
134142
<dependencies>

red5-eclipse-format.xml

Lines changed: 295 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 134 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,135 @@
1-
/*
2-
* RED5 Open Source Media Server - https://github.com/Red5/
3-
*
4-
* Copyright 2006-2016 by respective authors (see below). All rights reserved.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
17-
*/
18-
19-
package org.red5.classloading;
20-
21-
import java.net.URL;
22-
import java.net.URLClassLoader;
23-
24-
/**
25-
* An almost trivial no-fuss implementation of a class loader following the child-first delegation model. <i>Based on code from Ceki Gulcu</i>
26-
*
27-
* @author Paul Gregoire ([email protected])
28-
*/
29-
public final class ChildFirstClassLoader extends URLClassLoader {
30-
31-
private ClassLoader parent;
32-
33-
private ClassLoader parentParent;
34-
35-
private ClassLoader system;
36-
37-
public ChildFirstClassLoader(URL[] urls) {
38-
super(urls);
39-
this.parent = super.getParent();
40-
system = getSystemClassLoader();
41-
// if we have a parent of the parent and its not the system classloader
42-
parentParent = this.parent.getParent() != system ? this.parent.getParent() : null;
43-
dumpClassLoaderNames();
44-
}
45-
46-
public ChildFirstClassLoader(URL[] urls, ClassLoader parent) {
47-
super(urls, parent);
48-
this.parent = parent;
49-
system = getSystemClassLoader();
50-
if (parent != null) {
51-
// if we have a parent of the parent and its not the system
52-
// classloader
53-
parentParent = this.parent.getParent() != system ? this.parent.getParent() : null;
54-
}
55-
dumpClassLoaderNames();
56-
}
57-
58-
private void dumpClassLoaderNames() {
59-
System.out.printf("[ChildFirstClassLoader] Classloaders:\nSystem %s\nParents Parent %s\nParent %s\nThis class %s\nTCL %s\n\n", system, parentParent, this.parent, ChildFirstClassLoader.class.getClassLoader(), Thread.currentThread().getContextClassLoader());
60-
}
61-
62-
@Override
63-
public Class<?> loadClass(String name) throws ClassNotFoundException {
64-
return loadClass(name, false);
65-
}
66-
67-
/**
68-
* We override the parent-first behavior established by java.lang.Classloader.
69-
* <p>
70-
* The implementation is surprisingly straightforward.
71-
*
72-
* @param name the name of the class to load, should not be null
73-
* @param resolve flag that indicates whether the class should be resolved
74-
* @return the loaded class, never null
75-
* @throws ClassNotFoundException if the class could not be loaded
76-
*/
77-
@Override
78-
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
79-
80-
// First, check if the class has already been loaded
81-
Class<?> c = findLoadedClass(name);
82-
83-
// if not loaded, search the local (child) resources
84-
if (c == null) {
85-
try {
86-
c = findClass(name);
87-
} catch (ClassNotFoundException cnfe) {
88-
// ignore
89-
}
90-
}
91-
92-
// If we could not find it, delegate to parent
93-
// Note that we do not attempt to catch any ClassNotFoundException
94-
if (c == null) {
95-
try {
96-
c = this.parent.loadClass(name);
97-
} catch (Exception e) {
98-
// ignore the Spring "BeanInfo" class lookup errors
99-
// if (e.getMessage().indexOf("BeanInfo") == -1) {
100-
// log.warn("Exception {}", e);
101-
// }
102-
}
103-
if (c == null && parentParent != null) {
104-
try {
105-
c = parentParent.loadClass(name);
106-
} catch (Exception e) {
107-
// if (e.getMessage().indexOf("BeanInfo") == -1) {
108-
// log.warn("Exception {}", e);
109-
// }
110-
}
111-
}
112-
if (c == null) {
113-
try {
114-
c = system.loadClass(name);
115-
} catch (Exception e) {
116-
// if (e.getMessage().indexOf("BeanInfo") == -1) {
117-
// log.warn("Exception {}", e);
118-
// }
119-
}
120-
}
121-
}
122-
123-
// resolve if requested
124-
if (resolve) {
125-
resolveClass(c);
126-
}
127-
128-
return c;
129-
}
130-
131-
/**
132-
* Override the parent-first resource loading model established by java.lang.Classloader with child-first behavior.
133-
*
134-
* @param name the name of the resource to load, should not be null
135-
* @return a {@link URL} for the resource, or null if it could not be found
136-
*/
137-
@Override
138-
public URL getResource(String name) {
139-
URL url = findResource(name);
140-
// If local search failed, delegate to parent
141-
if (url == null) {
142-
url = this.parent.getResource(name);
143-
}
144-
return url;
145-
}
1+
/*
2+
* RED5 Open Source Media Server - https://github.com/Red5/ Copyright 2006-2016 by respective authors (see below). All rights reserved. Licensed under the Apache License, Version
3+
* 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
4+
* 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,
5+
* either express or implied. See the License for the specific language governing permissions and limitations under the License.
6+
*/
7+
8+
package org.red5.classloading;
9+
10+
import java.net.URL;
11+
import java.net.URLClassLoader;
12+
13+
/**
14+
* An almost trivial no-fuss implementation of a class loader following the child-first delegation model. <i>Based on code from Ceki Gulcu</i>
15+
*
16+
* @author Paul Gregoire ([email protected])
17+
*/
18+
public final class ChildFirstClassLoader extends URLClassLoader {
19+
20+
private ClassLoader parent;
21+
22+
private ClassLoader parentParent;
23+
24+
private ClassLoader system;
25+
26+
public ChildFirstClassLoader(URL[] urls) {
27+
super(urls);
28+
this.parent = super.getParent();
29+
system = getSystemClassLoader();
30+
// if we have a parent of the parent and its not the system classloader
31+
parentParent = this.parent.getParent() != system ? this.parent.getParent() : null;
32+
dumpClassLoaderNames();
33+
}
34+
35+
public ChildFirstClassLoader(URL[] urls, ClassLoader parent) {
36+
super(urls, parent);
37+
this.parent = parent;
38+
system = getSystemClassLoader();
39+
if (parent != null) {
40+
// if we have a parent of the parent and its not the system
41+
// classloader
42+
parentParent = this.parent.getParent() != system ? this.parent.getParent() : null;
43+
}
44+
dumpClassLoaderNames();
45+
}
46+
47+
private void dumpClassLoaderNames() {
48+
System.out.printf("[ChildFirstClassLoader] Classloaders:\nSystem %s\nParents Parent %s\nParent %s\nThis class %s\nTCL %s\n\n", system, parentParent, this.parent, ChildFirstClassLoader.class.getClassLoader(), Thread.currentThread().getContextClassLoader());
49+
}
50+
51+
@Override
52+
public Class<?> loadClass(String name) throws ClassNotFoundException {
53+
return loadClass(name, false);
54+
}
55+
56+
/**
57+
* We override the parent-first behavior established by java.lang.Classloader.
58+
* <p>
59+
* The implementation is surprisingly straightforward.
60+
*
61+
* @param name the name of the class to load, should not be null
62+
* @param resolve flag that indicates whether the class should be resolved
63+
* @return the loaded class, never null
64+
* @throws ClassNotFoundException if the class could not be loaded
65+
*/
66+
@Override
67+
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
68+
69+
// First, check if the class has already been loaded
70+
Class<?> c = findLoadedClass(name);
71+
72+
// if not loaded, search the local (child) resources
73+
if (c == null) {
74+
try {
75+
c = findClass(name);
76+
} catch (ClassNotFoundException cnfe) {
77+
// ignore
78+
}
79+
}
80+
81+
// If we could not find it, delegate to parent
82+
// Note that we do not attempt to catch any ClassNotFoundException
83+
if (c == null) {
84+
try {
85+
c = this.parent.loadClass(name);
86+
} catch (Exception e) {
87+
// ignore the Spring "BeanInfo" class lookup errors
88+
// if (e.getMessage().indexOf("BeanInfo") == -1) {
89+
// log.warn("Exception {}", e);
90+
// }
91+
}
92+
if (c == null && parentParent != null) {
93+
try {
94+
c = parentParent.loadClass(name);
95+
} catch (Exception e) {
96+
// if (e.getMessage().indexOf("BeanInfo") == -1) {
97+
// log.warn("Exception {}", e);
98+
// }
99+
}
100+
}
101+
if (c == null) {
102+
try {
103+
c = system.loadClass(name);
104+
} catch (Exception e) {
105+
// if (e.getMessage().indexOf("BeanInfo") == -1) {
106+
// log.warn("Exception {}", e);
107+
// }
108+
}
109+
}
110+
}
111+
112+
// resolve if requested
113+
if (resolve) {
114+
resolveClass(c);
115+
}
116+
117+
return c;
118+
}
119+
120+
/**
121+
* Override the parent-first resource loading model established by java.lang.Classloader with child-first behavior.
122+
*
123+
* @param name the name of the resource to load, should not be null
124+
* @return a {@link URL} for the resource, or null if it could not be found
125+
*/
126+
@Override
127+
public URL getResource(String name) {
128+
URL url = findResource(name);
129+
// If local search failed, delegate to parent
130+
if (url == null) {
131+
url = this.parent.getResource(name);
132+
}
133+
return url;
134+
}
146135
}

src/main/java/org/red5/classloading/ClassLoaderBuilder.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
/*
2-
* RED5 Open Source Media Server - https://github.com/Red5/
3-
*
4-
* Copyright 2006-2016 by respective authors (see below). All rights reserved.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
2+
* RED5 Open Source Media Server - https://github.com/Red5/ Copyright 2006-2016 by respective authors (see below). All rights reserved. Licensed under the Apache License, Version
3+
* 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
4+
* 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,
5+
* either express or implied. See the License for the specific language governing permissions and limitations under the License.
176
*/
187

198
package org.red5.classloading;
@@ -52,9 +41,7 @@
5241
public final class ClassLoaderBuilder {
5342

5443
/*
55-
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6500212
56-
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6516909
57-
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4976356
44+
* http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6500212 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6516909 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4976356
5845
*/
5946

6047
/**

src/main/java/org/red5/daemon/EngineLauncher.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
/*
2-
* RED5 Open Source Media Server - https://github.com/Red5/
3-
*
4-
* Copyright 2006-2016 by respective authors (see below). All rights reserved.
5-
*
6-
* Licensed under the Apache License, Version 2.0 (the "License");
7-
* you may not use this file except in compliance with the License.
8-
* You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0
11-
*
12-
* Unless required by applicable law or agreed to in writing, software
13-
* distributed under the License is distributed on an "AS IS" BASIS,
14-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
16-
* limitations under the License.
2+
* RED5 Open Source Media Server - https://github.com/Red5/ Copyright 2006-2016 by respective authors (see below). All rights reserved. Licensed under the Apache License, Version
3+
* 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
4+
* 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,
5+
* either express or implied. See the License for the specific language governing permissions and limitations under the License.
176
*/
187

198
package org.red5.daemon;

0 commit comments

Comments
 (0)