From 7a9eba760d885fbff42faf11d25bb5a76484929e Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 7 Aug 2012 09:51:53 +0000 Subject: [PATCH] SWS-787 - MethodEndpoint.getBean is inconsistent with its API --- .../ws/server/endpoint/MethodEndpoint.java | 12 +++++++++--- .../ws/server/endpoint/MethodEndpointTest.java | 16 ++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java b/core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java index 447d17d2..98563d0d 100644 --- a/core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java +++ b/core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2010 the original author or authors. + * Copyright 2005-2012 the original author or authors. * * Licensed under the Apache License, Version 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 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -91,7 +91,13 @@ public final class MethodEndpoint { /** Returns the object bean for this method endpoint. */ public Object getBean() { - return this.bean; + if (beanFactory != null && bean instanceof String) { + String beanName = (String) bean; + return beanFactory.getBean(beanName); + } + else { + return bean; + } } /** Returns the method for this method endpoint. */ diff --git a/core/src/test/java/org/springframework/ws/server/endpoint/MethodEndpointTest.java b/core/src/test/java/org/springframework/ws/server/endpoint/MethodEndpointTest.java index f1ddb233..29e47ad9 100644 --- a/core/src/test/java/org/springframework/ws/server/endpoint/MethodEndpointTest.java +++ b/core/src/test/java/org/springframework/ws/server/endpoint/MethodEndpointTest.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2010 the original author or authors. + * Copyright 2005-2012 the original author or authors. * * Licensed under the Apache License, Version 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 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -46,7 +46,7 @@ public class MethodEndpointTest { @Test public void testInvoke() throws Exception { Assert.assertFalse("Method invoked before invocation", myMethodInvoked); - endpoint.invoke(new Object[]{"arg"}); + endpoint.invoke("arg"); Assert.assertTrue("Method invoked before invocation", myMethodInvoked); } @@ -65,13 +65,13 @@ public class MethodEndpointTest { Assert.assertFalse("Equal", new MethodEndpoint(this, otherMethod).hashCode() == endpoint.hashCode()); } + @Test + public void testToString() throws Exception { + Assert.assertNotNull("No valid toString", endpoint.toString()); + } + public void myMethod(String arg) { Assert.assertEquals("Invalid argument", "arg", arg); myMethodInvoked = true; } - - @Test - public void testToString() throws Exception { - Assert.assertNotNull("Na valid toString", endpoint.toString()); - } }