Skip to content

Commit 7a9eba7

Browse files
committed
SWS-787 - MethodEndpoint.getBean is inconsistent with its API
1 parent b0b9e56 commit 7a9eba7

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2005-2010 the original author or authors.
2+
* Copyright 2005-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -91,7 +91,13 @@ public MethodEndpoint(String beanName, BeanFactory beanFactory, Method method) {
9191

9292
/** Returns the object bean for this method endpoint. */
9393
public Object getBean() {
94-
return this.bean;
94+
if (beanFactory != null && bean instanceof String) {
95+
String beanName = (String) bean;
96+
return beanFactory.getBean(beanName);
97+
}
98+
else {
99+
return bean;
100+
}
95101
}
96102

97103
/** Returns the method for this method endpoint. */

core/src/test/java/org/springframework/ws/server/endpoint/MethodEndpointTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2005-2010 the original author or authors.
2+
* Copyright 2005-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -46,7 +46,7 @@ public void testGetters() throws Exception {
4646
@Test
4747
public void testInvoke() throws Exception {
4848
Assert.assertFalse("Method invoked before invocation", myMethodInvoked);
49-
endpoint.invoke(new Object[]{"arg"});
49+
endpoint.invoke("arg");
5050
Assert.assertTrue("Method invoked before invocation", myMethodInvoked);
5151
}
5252

@@ -65,13 +65,13 @@ public void testHashCode() throws Exception {
6565
Assert.assertFalse("Equal", new MethodEndpoint(this, otherMethod).hashCode() == endpoint.hashCode());
6666
}
6767

68+
@Test
69+
public void testToString() throws Exception {
70+
Assert.assertNotNull("No valid toString", endpoint.toString());
71+
}
72+
6873
public void myMethod(String arg) {
6974
Assert.assertEquals("Invalid argument", "arg", arg);
7075
myMethodInvoked = true;
7176
}
72-
73-
@Test
74-
public void testToString() throws Exception {
75-
Assert.assertNotNull("Na valid toString", endpoint.toString());
76-
}
7777
}

0 commit comments

Comments
 (0)