Skip to content

Commit d1873e5

Browse files
committed
one step back and CGLIB no more included in the final bundle, marked with logging libraries as optional in OSGi imports
1 parent 6b6c246 commit d1873e5

File tree

2 files changed

+14
-81
lines changed

2 files changed

+14
-81
lines changed

pom.xml

Lines changed: 5 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<properties>
2525
<findbugs.onlyAnalyze>org.apache.ibatis.*</findbugs.onlyAnalyze>
2626
<clirr.comparisonVersion>3.0.2</clirr.comparisonVersion>
27-
<osgi.import>!net.sf.cglib.proxy,!org.apache.commons.logging,!org.apache.log4j,!org.slf4j,*</osgi.import>
27+
<osgi.import>net.sf.cglib.proxy;resolution:=optional,org.apache.commons.logging;resolution:=optional,org.apache.log4j;resolution:=optional,org.slf4j;resolution:=optional,javax.naming,javax.sql,javax.xml.namespace,javax.xml.parsers,javax.xml.xpath,org.w3c.dom,org.xml.sax</osgi.import>
2828
</properties>
2929
<reporting>
3030
<plugins>
@@ -43,81 +43,6 @@
4343
</reporting>
4444
<build>
4545
<plugins>
46-
<plugin>
47-
<groupId>org.sonatype.plugins</groupId>
48-
<artifactId>jarjar-maven-plugin</artifactId>
49-
<version>1.3</version>
50-
<configuration>
51-
<includes>
52-
<include>*:asm</include>
53-
<include>*:cglib</include>
54-
</includes>
55-
<rules>
56-
<!--
57-
| relocate CGLIB + ASM as internal stuff
58-
-->
59-
<rule>
60-
<pattern>net.sf.cglib.*</pattern>
61-
<result>org.apache.ibatis.internal.cglib.$@1</result>
62-
</rule>
63-
<rule>
64-
<pattern>net.sf.cglib.**.*</pattern>
65-
<result>org.apache.ibatis.internal.cglib.@1.$@2</result>
66-
</rule>
67-
<rule>
68-
<pattern>org.objectweb.asm.*</pattern>
69-
<result>org.apache.ibatis.internal.asm.$@1</result>
70-
</rule>
71-
<rule>
72-
<pattern>org.objectweb.asm.**.*</pattern>
73-
<result>org.apache.ibatis.internal.asm.@1.$@2</result>
74-
</rule>
75-
<!--
76-
| keep original source
77-
-->
78-
<keep>
79-
<pattern>org.apache.ibatis.**</pattern>
80-
</keep>
81-
<!--
82-
| keep test source
83-
-->
84-
<keep>
85-
<pattern>com.**</pattern>
86-
</keep>
87-
<keep>
88-
<pattern>databases.**</pattern>
89-
</keep>
90-
<keep>
91-
<pattern>domain.**</pattern>
92-
</keep>
93-
</rules>
94-
</configuration>
95-
<!--
96-
| JarJar all classes before running tests
97-
-->
98-
<executions>
99-
<execution>
100-
<id>jarjar-classes</id>
101-
<phase>process-test-classes</phase>
102-
<goals>
103-
<goal>jarjar</goal>
104-
</goals>
105-
<configuration>
106-
<input>{classes}</input>
107-
</configuration>
108-
</execution>
109-
<execution>
110-
<id>jarjar-test-classes</id>
111-
<phase>process-test-classes</phase>
112-
<goals>
113-
<goal>jarjar</goal>
114-
</goals>
115-
<configuration>
116-
<input>{test-classes}</input>
117-
</configuration>
118-
</execution>
119-
</executions>
120-
</plugin>
12146
<plugin>
12247
<groupId>org.apache.maven.plugins</groupId>
12348
<artifactId>maven-assembly-plugin</artifactId>
@@ -282,16 +207,16 @@
282207
<optional>true</optional>
283208
</dependency>
284209
<dependency>
285-
<groupId>org.sonatype.sisu.inject</groupId>
210+
<groupId>cglib</groupId>
286211
<artifactId>cglib</artifactId>
287-
<version>2.2.1</version>
288-
<scope>provided</scope>
212+
<version>2.1_3</version>
213+
<optional>true</optional>
289214
</dependency>
290215
<!-- Test dependencies -->
291216
<dependency>
292217
<groupId>junit</groupId>
293218
<artifactId>junit</artifactId>
294-
<version>4.3.1</version>
219+
<version>4.8.2</version>
295220
<scope>test</scope>
296221
</dependency>
297222
<dependency>

src/main/java/org/apache/ibatis/builder/xml/XMLConfigBuilder.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private void settingsElement(XNode context) throws Exception {
153153
}
154154
configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(stringValueOf(props.getProperty("autoMappingBehavior"), "PARTIAL")));
155155
configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
156-
configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
156+
configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), safeCglibCheck()));
157157
configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true));
158158
configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
159159
configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
@@ -163,6 +163,14 @@ private void settingsElement(XNode context) throws Exception {
163163
}
164164
}
165165

166+
private boolean safeCglibCheck() {
167+
try {
168+
return Resources.classForName("net.sf.cglib.proxy.Enhancer") != null;
169+
} catch (Exception e) {
170+
return false;
171+
}
172+
}
173+
166174
private void environmentsElement(XNode context) throws Exception {
167175
if (context != null) {
168176
if (environment == null) {

0 commit comments

Comments
 (0)