Skip to content

Commit b3303dc

Browse files
author
Tomasz Lelek
committed
BAEL-633 craete cglib template
1 parent 491d36e commit b3303dc

4 files changed

Lines changed: 75 additions & 0 deletions

File tree

‎cglib/pom.xml‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>parent-modules</artifactId>
7+
<groupId>com.baeldung</groupId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>cglib</artifactId>
13+
<build>
14+
<plugins>
15+
<plugin>
16+
<groupId>org.apache.maven.plugins</groupId>
17+
<artifactId>maven-compiler-plugin</artifactId>
18+
<configuration>
19+
<source>1.8</source>
20+
<target>1.8</target>
21+
</configuration>
22+
</plugin>
23+
</plugins>
24+
</build>
25+
26+
<dependencies>
27+
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
28+
<dependency>
29+
<groupId>cglib</groupId>
30+
<artifactId>cglib</artifactId>
31+
<version>${cglib.version}</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>junit</groupId>
35+
<artifactId>junit</artifactId>
36+
<version>${junit.version}</version>
37+
<scope>test</scope>
38+
</dependency>
39+
</dependencies>
40+
41+
<properties>
42+
<cglib.version>3.2.4</cglib.version>
43+
<junit.version>4.12</junit.version>
44+
</properties>
45+
46+
47+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.baeldung.cglib.proxy;
2+
3+
public class SampleClass {
4+
public String test(String input) {
5+
return "Hello world!";
6+
}
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.baeldung.cglib.proxy;
2+
3+
import net.sf.cglib.proxy.Enhancer;
4+
import net.sf.cglib.proxy.FixedValue;
5+
import org.junit.Test;
6+
7+
import static org.junit.Assert.assertEquals;
8+
9+
public class SampleClassTest {
10+
@Test
11+
public void testFixedValue() throws Exception {
12+
Enhancer enhancer = new Enhancer();
13+
enhancer.setSuperclass(SampleClass.class);
14+
enhancer.setCallback((FixedValue) () -> "Hello cglib!");
15+
SampleClass proxy = (SampleClass) enhancer.create();
16+
assertEquals("Hello cglib!", proxy.test(null));
17+
18+
}
19+
20+
}

‎pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
<module>xstream</module>
192192

193193
<module>struts2</module>
194+
<module>cglib</module>
194195

195196
</modules>
196197

0 commit comments

Comments
 (0)