Skip to content

Commit 637d75f

Browse files
committed
Polishing
1 parent 0efc4a6 commit 637d75f

File tree

3 files changed

+36
-89
lines changed

3 files changed

+36
-89
lines changed

pom.xml

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -195,35 +195,11 @@
195195
<scope>provided</scope>
196196
</dependency>
197197
<dependency>
198-
<groupId>javax.mail</groupId>
199-
<artifactId>mail</artifactId>
200-
<version>1.4.1</version>
201-
<scope>provided</scope>
202-
</dependency>
203-
<dependency>
204-
<groupId>javax.activation</groupId>
205-
<artifactId>activation</artifactId>
198+
<groupId>org.apache.geronimo.specs</groupId>
199+
<artifactId>geronimo-jms_1.1_spec</artifactId>
206200
<version>1.1.1</version>
207201
<scope>provided</scope>
208202
</dependency>
209-
<dependency>
210-
<groupId>javax.jms</groupId>
211-
<artifactId>jms</artifactId>
212-
<version>1.1</version>
213-
<scope>provided</scope>
214-
</dependency>
215-
<dependency>
216-
<groupId>javax.ejb</groupId>
217-
<artifactId>ejb</artifactId>
218-
<version>2.1</version>
219-
<scope>provided</scope>
220-
</dependency>
221-
<dependency>
222-
<groupId>javax.persistence</groupId>
223-
<artifactId>persistence-api</artifactId>
224-
<version>1.0</version>
225-
<scope>provided</scope>
226-
</dependency>
227203
<!-- Logging dependencies -->
228204
<dependency>
229205
<groupId>commons-logging</groupId>
@@ -306,6 +282,10 @@
306282
<artifactId>easymock</artifactId>
307283
<scope>test</scope>
308284
</dependency>
285+
<dependency>
286+
<groupId>org.springframework</groupId>
287+
<artifactId>spring-core</artifactId>
288+
</dependency>
309289
<dependency>
310290
<groupId>org.springframework</groupId>
311291
<artifactId>spring-beans</artifactId>
@@ -336,8 +316,9 @@
336316
<artifactId>javax.servlet-api</artifactId>
337317
</dependency>
338318
<dependency>
339-
<groupId>javax.jms</groupId>
340-
<artifactId>jms</artifactId>
319+
<groupId>org.apache.geronimo.specs</groupId>
320+
<artifactId>geronimo-jms_1.1_spec</artifactId>
321+
<version>1.1.1</version>
341322
</dependency>
342323
<dependency>
343324
<groupId>junit</groupId>

src/main/scala/org/springframework/scala/beans/factory/function/InitDestroyFunctionBeanPostProcessor.scala

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ package org.springframework.scala.beans.factory.function
1919
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
2020
import org.springframework.core.PriorityOrdered
2121
import scala.reflect.BeanProperty
22-
import org.springframework.util.Assert
23-
import scala.collection.mutable.{Set, MultiMap, SynchronizedMap, HashMap}
22+
import org.springframework.util.{StringUtils, Assert}
23+
import scala.collection.mutable.{ListBuffer, SynchronizedMap, HashMap}
24+
import scala.Predef._
25+
import scala.AnyRef
26+
import scala.Some
2427

2528
/**
2629
* [[org.springframework.beans.factory.config.BeanPostProcessor]] implementation
@@ -39,13 +42,11 @@ import scala.collection.mutable.{Set, MultiMap, SynchronizedMap, HashMap}
3942
class InitDestroyFunctionBeanPostProcessor
4043
extends DestructionAwareBeanPostProcessor with PriorityOrdered {
4144

42-
val initFunctions = new HashMap[String, Set[Function1[Any, Unit]]]
43-
with MultiMap[String, Function1[Any, Unit]]
44-
with SynchronizedMap[String, Set[Function1[Any, Unit]]]
45+
val initFunctions = new HashMap[String, ListBuffer[Function1[Any, Unit]]]
46+
with SynchronizedMap[String, ListBuffer[Function1[Any, Unit]]]
4547

46-
val destroyFunctions = new HashMap[String, Set[Function1[Any, Unit]]]
47-
with MultiMap[String, Function1[Any, Unit]]
48-
with SynchronizedMap[String, Set[Function1[Any, Unit]]]
48+
val destroyFunctions = new HashMap[String, ListBuffer[Function1[Any, Unit]]]
49+
with SynchronizedMap[String, ListBuffer[Function1[Any, Unit]]]
4950

5051
@BeanProperty
5152
var order: Int = org.springframework.core.Ordered.LOWEST_PRECEDENCE
@@ -61,10 +62,10 @@ class InitDestroyFunctionBeanPostProcessor
6162
* @tparam T the bean type
6263
*/
6364
def registerInitFunction[T](beanName: String, initFunction: (T) => Unit) {
64-
Assert.hasLength(beanName, "'beanName' must not be empty")
65-
Assert.notNull(initFunction, "'initFunction' must not be null")
65+
assert(StringUtils.hasLength(beanName), "'beanName' must not be empty")
66+
assert(initFunction != null, "'initFunction' must not be null")
6667

67-
initFunctions.addBinding(beanName, initFunction.asInstanceOf[Function1[Any, Unit]])
68+
addFunction(initFunctions, beanName, initFunction.asInstanceOf[Function1[Any, Unit]])
6869
}
6970

7071
/**
@@ -81,8 +82,21 @@ class InitDestroyFunctionBeanPostProcessor
8182
Assert.hasLength(beanName, "'beanName' must not be empty")
8283
Assert.notNull(destroyFunction, "'destroyFunction' must not be null")
8384

84-
destroyFunctions
85-
.addBinding(beanName, destroyFunction.asInstanceOf[Function1[Any, Unit]])
85+
addFunction(destroyFunctions, beanName, destroyFunction.asInstanceOf[Function1[Any, Unit]])
86+
}
87+
88+
private def addFunction(functionsMap: HashMap[String, ListBuffer[Function1[Any, Unit]]],
89+
beanName: String,
90+
function: (Any) => Unit) {
91+
92+
functionsMap.get(beanName) match {
93+
case None =>
94+
val list = new ListBuffer[Function1[Any, Unit]]
95+
list += function
96+
functionsMap(beanName) = list
97+
case Some(list) =>
98+
list += function
99+
}
86100
}
87101

88102
def postProcessBeforeInitialization(bean: AnyRef, beanName: String): AnyRef = {

src/test/scala/org/springframework/scala/beans/factory/RichBeanFactoryTests.scala

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)