Browse Source
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@486 50f2f4bb-b051-0410-bef5-90022cba6387pull/1/head
82 changed files with 888 additions and 1939 deletions
@ -1,99 +0,0 @@
@@ -1,99 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
import org.springframework.beans.IndexedTestBean; |
||||
import org.springframework.beans.TestBean; |
||||
|
||||
/** |
||||
* Simple bean used to check constructor dependency checking. |
||||
* |
||||
* @author Juergen Hoeller |
||||
* @since 09.11.2003 |
||||
*/ |
||||
public class ConstructorDependenciesBean implements Serializable { |
||||
|
||||
private int age; |
||||
|
||||
private String name; |
||||
|
||||
private TestBean spouse1; |
||||
|
||||
private TestBean spouse2; |
||||
|
||||
private IndexedTestBean other; |
||||
|
||||
public ConstructorDependenciesBean(int age) { |
||||
this.age = age; |
||||
} |
||||
|
||||
public ConstructorDependenciesBean(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public ConstructorDependenciesBean(TestBean spouse1) { |
||||
this.spouse1 = spouse1; |
||||
} |
||||
|
||||
public ConstructorDependenciesBean(TestBean spouse1, TestBean spouse2) { |
||||
this.spouse1 = spouse1; |
||||
this.spouse2 = spouse2; |
||||
} |
||||
|
||||
public ConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, int age) { |
||||
this.spouse1 = spouse1; |
||||
this.spouse2 = spouse2; |
||||
this.age = age; |
||||
} |
||||
|
||||
public ConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, IndexedTestBean other) { |
||||
this.spouse1 = spouse1; |
||||
this.spouse2 = spouse2; |
||||
this.other = other; |
||||
} |
||||
|
||||
public int getAge() { |
||||
return age; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public TestBean getSpouse1() { |
||||
return spouse1; |
||||
} |
||||
|
||||
public TestBean getSpouse2() { |
||||
return spouse2; |
||||
} |
||||
|
||||
public IndexedTestBean getOther() { |
||||
return other; |
||||
} |
||||
|
||||
public void setAge(int age) { |
||||
this.age = age; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
} |
||||
@ -1,58 +0,0 @@
@@ -1,58 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import org.springframework.beans.ITestBean; |
||||
|
||||
/** |
||||
* Bean testing the ability to use both lookup method overrides |
||||
* and constructor injection. |
||||
* There is also a property ("setterString") to be set via |
||||
* Setter Injection. |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
public abstract class ConstructorInjectedOverrides { |
||||
|
||||
private ITestBean tb; |
||||
|
||||
private String setterString; |
||||
|
||||
public ConstructorInjectedOverrides(ITestBean tb) { |
||||
this.tb = tb; |
||||
} |
||||
|
||||
public ITestBean getTestBean() { |
||||
return this.tb; |
||||
} |
||||
|
||||
|
||||
protected abstract FactoryMethods createFactoryMethods(); |
||||
|
||||
/** |
||||
* @return Returns the setterString. |
||||
*/ |
||||
public String getSetterString() { |
||||
return setterString; |
||||
} |
||||
/** |
||||
* @param setterString The setterString to set. |
||||
*/ |
||||
public void setSetterString(String setterString) { |
||||
this.setterString = setterString; |
||||
} |
||||
} |
||||
@ -1,59 +0,0 @@
@@ -1,59 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import org.springframework.beans.IndexedTestBean; |
||||
import org.springframework.beans.TestBean; |
||||
|
||||
/** |
||||
* Simple bean used to check constructor dependency checking. |
||||
* |
||||
* @author Juergen Hoeller |
||||
* @since 09.11.2003 |
||||
*/ |
||||
class DerivedConstructorDependenciesBean extends ConstructorDependenciesBean { |
||||
|
||||
boolean initialized; |
||||
boolean destroyed; |
||||
|
||||
DerivedConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, IndexedTestBean other) { |
||||
super(spouse1, spouse2, other); |
||||
} |
||||
|
||||
private DerivedConstructorDependenciesBean(TestBean spouse1, Object spouse2, IndexedTestBean other) { |
||||
super(spouse1, null, other); |
||||
} |
||||
|
||||
protected DerivedConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, IndexedTestBean other, int age, int otherAge) { |
||||
super(spouse1, spouse2, other); |
||||
} |
||||
|
||||
public DerivedConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, IndexedTestBean other, int age, String name) { |
||||
super(spouse1, spouse2, other); |
||||
setAge(age); |
||||
setName(name); |
||||
} |
||||
|
||||
private void init() { |
||||
this.initialized = true; |
||||
} |
||||
|
||||
private void destroy() { |
||||
this.destroyed = true; |
||||
} |
||||
|
||||
} |
||||
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
/** |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
public interface DummyBo { |
||||
|
||||
void something(); |
||||
|
||||
} |
||||
@ -1,35 +0,0 @@
@@ -1,35 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
/** |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
public class DummyBoImpl implements DummyBo { |
||||
|
||||
DummyDao dao; |
||||
|
||||
public DummyBoImpl(DummyDao dao) { |
||||
this.dao = dao; |
||||
} |
||||
|
||||
public void something() { |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -1,33 +0,0 @@
@@ -1,33 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import javax.sql.DataSource; |
||||
|
||||
/** |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
public class DummyDao { |
||||
|
||||
DataSource ds; |
||||
|
||||
public DummyDao(DataSource ds) { |
||||
this.ds = ds; |
||||
} |
||||
|
||||
} |
||||
@ -1,66 +0,0 @@
@@ -1,66 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import org.springframework.beans.TestBean; |
||||
import org.springframework.beans.factory.DummyFactory; |
||||
|
||||
/** |
||||
* @author Juergen Hoeller |
||||
* @since 21.07.2003 |
||||
*/ |
||||
public class DummyReferencer { |
||||
|
||||
private TestBean testBean1; |
||||
|
||||
private TestBean testBean2; |
||||
|
||||
private DummyFactory dummyFactory; |
||||
|
||||
|
||||
public DummyReferencer() { |
||||
} |
||||
|
||||
public DummyReferencer(DummyFactory dummyFactory) { |
||||
this.dummyFactory = dummyFactory; |
||||
} |
||||
|
||||
public void setDummyFactory(DummyFactory dummyFactory) { |
||||
this.dummyFactory = dummyFactory; |
||||
} |
||||
|
||||
public DummyFactory getDummyFactory() { |
||||
return dummyFactory; |
||||
} |
||||
|
||||
public void setTestBean1(TestBean testBean1) { |
||||
this.testBean1 = testBean1; |
||||
} |
||||
|
||||
public TestBean getTestBean1() { |
||||
return testBean1; |
||||
} |
||||
|
||||
public void setTestBean2(TestBean testBean2) { |
||||
this.testBean2 = testBean2; |
||||
} |
||||
|
||||
public TestBean getTestBean2() { |
||||
return testBean2; |
||||
} |
||||
|
||||
} |
||||
@ -1,120 +0,0 @@
@@ -1,120 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2006 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
|
||||
import org.springframework.beans.TestBean; |
||||
|
||||
/** |
||||
* Test class for Spring's ability to create objects using static |
||||
* factory methods, rather than constructors. |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Juergen Hoeller |
||||
*/ |
||||
public class FactoryMethods { |
||||
|
||||
public static FactoryMethods nullInstance() { |
||||
return null; |
||||
} |
||||
|
||||
public static FactoryMethods defaultInstance() { |
||||
TestBean tb = new TestBean(); |
||||
tb.setName("defaultInstance"); |
||||
return new FactoryMethods(tb, "default", 0); |
||||
} |
||||
|
||||
/** |
||||
* Note that overloaded methods are supported. |
||||
*/ |
||||
public static FactoryMethods newInstance(TestBean tb) { |
||||
return new FactoryMethods(tb, "default", 0); |
||||
} |
||||
|
||||
protected static FactoryMethods newInstance(TestBean tb, int num, String name) { |
||||
if (name == null) { |
||||
throw new IllegalStateException("Should never be called with null value"); |
||||
} |
||||
return new FactoryMethods(tb, name, num); |
||||
} |
||||
|
||||
static FactoryMethods newInstance(TestBean tb, int num, Integer something) { |
||||
if (something != null) { |
||||
throw new IllegalStateException("Should never be called with non-null value"); |
||||
} |
||||
return new FactoryMethods(tb, null, num); |
||||
} |
||||
|
||||
private static List listInstance() { |
||||
return Collections.EMPTY_LIST; |
||||
} |
||||
|
||||
|
||||
private int num = 0; |
||||
private String name = "default"; |
||||
private TestBean tb; |
||||
private String stringValue; |
||||
|
||||
|
||||
/** |
||||
* Constructor is private: not for use outside this class, |
||||
* even by IoC container. |
||||
*/ |
||||
private FactoryMethods(TestBean tb, String name, int num) { |
||||
this.tb = tb; |
||||
this.name = name; |
||||
this.num = num; |
||||
} |
||||
|
||||
public void setStringValue(String stringValue) { |
||||
this.stringValue = stringValue; |
||||
} |
||||
|
||||
public String getStringValue() { |
||||
return this.stringValue; |
||||
} |
||||
|
||||
public TestBean getTestBean() { |
||||
return this.tb; |
||||
} |
||||
|
||||
protected TestBean protectedGetTestBean() { |
||||
return this.tb; |
||||
} |
||||
|
||||
private TestBean privateGetTestBean() { |
||||
return this.tb; |
||||
} |
||||
|
||||
public int getNum() { |
||||
return num; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
/** |
||||
* Set via Setter Injection once instance is created. |
||||
*/ |
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
} |
||||
@ -1,35 +0,0 @@
@@ -1,35 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import java.lang.reflect.Method; |
||||
|
||||
import org.springframework.beans.factory.support.MethodReplacer; |
||||
|
||||
/** |
||||
* Fixed method replacer for String return types |
||||
* @author Rod Johnson |
||||
*/ |
||||
public class FixedMethodReplacer implements MethodReplacer { |
||||
|
||||
public static final String VALUE = "fixedMethodReplacer"; |
||||
|
||||
public Object reimplement(Object obj, Method method, Object[] args) throws Throwable { |
||||
return VALUE; |
||||
} |
||||
|
||||
} |
||||
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2006 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @author Chris Beams |
||||
*/ |
||||
public class MapAndSet { |
||||
|
||||
private Object obj; |
||||
|
||||
public MapAndSet(Map map) { |
||||
this.obj = map; |
||||
} |
||||
|
||||
public MapAndSet(Set set) { |
||||
this.obj = set; |
||||
} |
||||
|
||||
public Object getObject() { |
||||
return obj; |
||||
} |
||||
} |
||||
@ -1,29 +0,0 @@
@@ -1,29 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
/** |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
public class MethodReplaceCandidate { |
||||
|
||||
public String replaceMe(String echo) { |
||||
return echo; |
||||
} |
||||
|
||||
} |
||||
@ -1,41 +0,0 @@
@@ -1,41 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2006 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import java.util.Collection; |
||||
|
||||
/** |
||||
* Bean that exposes a simple property that can be set |
||||
* to a mix of references and individual values. |
||||
* |
||||
* @author Rod Johnson |
||||
* @since 27.05.2003 |
||||
*/ |
||||
public class MixedCollectionBean { |
||||
|
||||
private Collection jumble; |
||||
|
||||
|
||||
public void setJumble(Collection jumble) { |
||||
this.jumble = jumble; |
||||
} |
||||
|
||||
public Collection getJumble() { |
||||
return jumble; |
||||
} |
||||
|
||||
} |
||||
@ -1,30 +0,0 @@
@@ -1,30 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2006 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import org.springframework.beans.TestBean; |
||||
|
||||
/** |
||||
* @author Juergen Hoeller |
||||
*/ |
||||
public interface OverrideInterface { |
||||
|
||||
TestBean getPrototypeDependency(); |
||||
|
||||
TestBean getPrototypeDependency(Object someParam); |
||||
|
||||
} |
||||
@ -1,56 +0,0 @@
@@ -1,56 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2006 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import org.springframework.beans.TestBean; |
||||
|
||||
/** |
||||
* @author Rod Johnson |
||||
* @author Juergen Hoeller |
||||
*/ |
||||
public abstract class OverrideOneMethod extends MethodReplaceCandidate implements OverrideInterface { |
||||
|
||||
protected abstract TestBean protectedOverrideSingleton(); |
||||
|
||||
public TestBean getPrototypeDependency(Object someParam) { |
||||
return new TestBean(); |
||||
} |
||||
|
||||
public TestBean invokesOverridenMethodOnSelf() { |
||||
return getPrototypeDependency(); |
||||
} |
||||
|
||||
public String echo(String echo) { |
||||
return echo; |
||||
} |
||||
|
||||
/** |
||||
* Overloaded form of replaceMe. |
||||
*/ |
||||
public String replaceMe() { |
||||
return "replaceMe"; |
||||
} |
||||
|
||||
/** |
||||
* Another overloaded form of replaceMe, not getting replaced. |
||||
* Must not cause errors when the other replaceMe methods get replaced. |
||||
*/ |
||||
public String replaceMe(int someParam) { |
||||
return "replaceMe:" + someParam; |
||||
} |
||||
|
||||
} |
||||
@ -1,32 +0,0 @@
@@ -1,32 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
/** |
||||
* Subclass of OverrideOneMethod, to check that overriding is |
||||
* supported for inherited methods. |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
public abstract class OverrideOneMethodSubclass extends OverrideOneMethod { |
||||
|
||||
protected void doSomething(String arg) { |
||||
// This implementation does nothing!
|
||||
// It's not overloaded
|
||||
} |
||||
|
||||
} |
||||
@ -1,162 +0,0 @@
@@ -1,162 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2007 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import org.springframework.beans.BeansException; |
||||
import org.springframework.beans.factory.BeanFactory; |
||||
import org.springframework.beans.factory.BeanFactoryAware; |
||||
import org.springframework.beans.factory.BeanNameAware; |
||||
import org.springframework.beans.factory.DisposableBean; |
||||
import org.springframework.beans.factory.InitializingBean; |
||||
import org.springframework.beans.factory.config.BeanPostProcessor; |
||||
|
||||
/** |
||||
* Simple test of BeanFactory initialization and lifecycle callbacks. |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Juergen Hoeller |
||||
*/ |
||||
class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean { |
||||
|
||||
protected boolean initMethodDeclared = false; |
||||
|
||||
protected String beanName; |
||||
|
||||
protected BeanFactory owningFactory; |
||||
|
||||
protected boolean postProcessedBeforeInit; |
||||
|
||||
protected boolean inited; |
||||
|
||||
protected boolean initedViaDeclaredInitMethod; |
||||
|
||||
protected boolean postProcessedAfterInit; |
||||
|
||||
protected boolean destroyed; |
||||
|
||||
|
||||
public void setInitMethodDeclared(boolean initMethodDeclared) { |
||||
this.initMethodDeclared = initMethodDeclared; |
||||
} |
||||
|
||||
public boolean isInitMethodDeclared() { |
||||
return initMethodDeclared; |
||||
} |
||||
|
||||
public void setBeanName(String name) { |
||||
this.beanName = name; |
||||
} |
||||
|
||||
public String getBeanName() { |
||||
return beanName; |
||||
} |
||||
|
||||
public void setBeanFactory(BeanFactory beanFactory) { |
||||
this.owningFactory = beanFactory; |
||||
} |
||||
|
||||
public void postProcessBeforeInit() { |
||||
if (this.inited || this.initedViaDeclaredInitMethod) { |
||||
throw new RuntimeException("Factory called postProcessBeforeInit after afterPropertiesSet"); |
||||
} |
||||
if (this.postProcessedBeforeInit) { |
||||
throw new RuntimeException("Factory called postProcessBeforeInit twice"); |
||||
} |
||||
this.postProcessedBeforeInit = true; |
||||
} |
||||
|
||||
public void afterPropertiesSet() { |
||||
if (this.owningFactory == null) { |
||||
throw new RuntimeException("Factory didn't call setBeanFactory before afterPropertiesSet on lifecycle bean"); |
||||
} |
||||
if (!this.postProcessedBeforeInit) { |
||||
throw new RuntimeException("Factory didn't call postProcessBeforeInit before afterPropertiesSet on lifecycle bean"); |
||||
} |
||||
if (this.initedViaDeclaredInitMethod) { |
||||
throw new RuntimeException("Factory initialized via declared init method before initializing via afterPropertiesSet"); |
||||
} |
||||
if (this.inited) { |
||||
throw new RuntimeException("Factory called afterPropertiesSet twice"); |
||||
} |
||||
this.inited = true; |
||||
} |
||||
|
||||
public void declaredInitMethod() { |
||||
if (!this.inited) { |
||||
throw new RuntimeException("Factory didn't call afterPropertiesSet before declared init method"); |
||||
} |
||||
|
||||
if (this.initedViaDeclaredInitMethod) { |
||||
throw new RuntimeException("Factory called declared init method twice"); |
||||
} |
||||
this.initedViaDeclaredInitMethod = true; |
||||
} |
||||
|
||||
public void postProcessAfterInit() { |
||||
if (!this.inited) { |
||||
throw new RuntimeException("Factory called postProcessAfterInit before afterPropertiesSet"); |
||||
} |
||||
if (this.initMethodDeclared && !this.initedViaDeclaredInitMethod) { |
||||
throw new RuntimeException("Factory called postProcessAfterInit before calling declared init method"); |
||||
} |
||||
if (this.postProcessedAfterInit) { |
||||
throw new RuntimeException("Factory called postProcessAfterInit twice"); |
||||
} |
||||
this.postProcessedAfterInit = true; |
||||
} |
||||
|
||||
/** |
||||
* Dummy business method that will fail unless the factory |
||||
* managed the bean's lifecycle correctly |
||||
*/ |
||||
public void businessMethod() { |
||||
if (!this.inited || (this.initMethodDeclared && !this.initedViaDeclaredInitMethod) || |
||||
!this.postProcessedAfterInit) { |
||||
throw new RuntimeException("Factory didn't initialize lifecycle object correctly"); |
||||
} |
||||
} |
||||
|
||||
public void destroy() { |
||||
if (this.destroyed) { |
||||
throw new IllegalStateException("Already destroyed"); |
||||
} |
||||
this.destroyed = true; |
||||
} |
||||
|
||||
public boolean isDestroyed() { |
||||
return destroyed; |
||||
} |
||||
|
||||
|
||||
public static class PostProcessor implements BeanPostProcessor { |
||||
|
||||
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { |
||||
if (bean instanceof ProtectedLifecycleBean) { |
||||
((ProtectedLifecycleBean) bean).postProcessBeforeInit(); |
||||
} |
||||
return bean; |
||||
} |
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { |
||||
if (bean instanceof ProtectedLifecycleBean) { |
||||
((ProtectedLifecycleBean) bean).postProcessAfterInit(); |
||||
} |
||||
return bean; |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -1,23 +0,0 @@
@@ -1,23 +0,0 @@
|
||||
/* |
||||
* The Spring Framework is published under the terms |
||||
* of the Apache Software License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import java.io.Serializable; |
||||
import java.lang.reflect.Method; |
||||
|
||||
import org.springframework.beans.factory.support.MethodReplacer; |
||||
|
||||
/** |
||||
* @author Rod Johnson |
||||
*/ |
||||
public class ReverseMethodReplacer implements MethodReplacer, Serializable { |
||||
|
||||
public Object reimplement(Object obj, Method method, Object[] args) throws Throwable { |
||||
String s = (String) args[0]; |
||||
return new StringBuffer(s).reverse().toString(); |
||||
} |
||||
|
||||
} |
||||
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* @author Rod Johnson |
||||
*/ |
||||
public abstract class SerializableMethodReplacerCandidate extends MethodReplaceCandidate implements Serializable { |
||||
|
||||
//public abstract Point getPoint();
|
||||
|
||||
} |
||||
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
/* |
||||
* Copyright 2002-2005 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
/** |
||||
* @author Juergen Hoeller |
||||
* @since 23.10.2004 |
||||
*/ |
||||
public class SingleSimpleTypeConstructorBean { |
||||
|
||||
private boolean singleBoolean; |
||||
|
||||
private boolean secondBoolean; |
||||
|
||||
private String testString; |
||||
|
||||
public SingleSimpleTypeConstructorBean(boolean singleBoolean) { |
||||
this.singleBoolean = singleBoolean; |
||||
} |
||||
|
||||
public SingleSimpleTypeConstructorBean(String testString, boolean secondBoolean) { |
||||
this.testString = testString; |
||||
this.secondBoolean = secondBoolean; |
||||
} |
||||
|
||||
public boolean isSingleBoolean() { |
||||
return singleBoolean; |
||||
} |
||||
|
||||
public boolean isSecondBoolean() { |
||||
return secondBoolean; |
||||
} |
||||
|
||||
public String getTestString() { |
||||
return testString; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,732 @@
@@ -0,0 +1,732 @@
|
||||
/* |
||||
* Copyright 2002-2008 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
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.beans.factory.xml; |
||||
|
||||
import java.io.Serializable; |
||||
import java.lang.reflect.Method; |
||||
import java.util.Collection; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
import javax.sql.DataSource; |
||||
|
||||
import org.springframework.beans.BeansException; |
||||
import org.springframework.beans.ITestBean; |
||||
import org.springframework.beans.IndexedTestBean; |
||||
import org.springframework.beans.TestBean; |
||||
import org.springframework.beans.factory.BeanFactory; |
||||
import org.springframework.beans.factory.BeanFactoryAware; |
||||
import org.springframework.beans.factory.BeanNameAware; |
||||
import org.springframework.beans.factory.DisposableBean; |
||||
import org.springframework.beans.factory.DummyFactory; |
||||
import org.springframework.beans.factory.InitializingBean; |
||||
import org.springframework.beans.factory.config.BeanPostProcessor; |
||||
import org.springframework.beans.factory.support.MethodReplacer; |
||||
|
||||
|
||||
/** |
||||
* Types used by {@link XmlBeanFactoryTests} and its attendant XML config files. |
||||
* |
||||
* @author Chris Beams |
||||
*/ |
||||
final class XmlBeanFactoryTestTypes { } |
||||
|
||||
/** |
||||
* Simple bean used to check constructor dependency checking. |
||||
* |
||||
* @author Juergen Hoeller |
||||
* @since 09.11.2003 |
||||
*/ |
||||
@SuppressWarnings("serial") |
||||
class ConstructorDependenciesBean implements Serializable { |
||||
|
||||
private int age; |
||||
|
||||
private String name; |
||||
|
||||
private TestBean spouse1; |
||||
|
||||
private TestBean spouse2; |
||||
|
||||
private IndexedTestBean other; |
||||
|
||||
public ConstructorDependenciesBean(int age) { |
||||
this.age = age; |
||||
} |
||||
|
||||
public ConstructorDependenciesBean(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public ConstructorDependenciesBean(TestBean spouse1) { |
||||
this.spouse1 = spouse1; |
||||
} |
||||
|
||||
public ConstructorDependenciesBean(TestBean spouse1, TestBean spouse2) { |
||||
this.spouse1 = spouse1; |
||||
this.spouse2 = spouse2; |
||||
} |
||||
|
||||
public ConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, int age) { |
||||
this.spouse1 = spouse1; |
||||
this.spouse2 = spouse2; |
||||
this.age = age; |
||||
} |
||||
|
||||
public ConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, IndexedTestBean other) { |
||||
this.spouse1 = spouse1; |
||||
this.spouse2 = spouse2; |
||||
this.other = other; |
||||
} |
||||
|
||||
public int getAge() { |
||||
return age; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public TestBean getSpouse1() { |
||||
return spouse1; |
||||
} |
||||
|
||||
public TestBean getSpouse2() { |
||||
return spouse2; |
||||
} |
||||
|
||||
public IndexedTestBean getOther() { |
||||
return other; |
||||
} |
||||
|
||||
public void setAge(int age) { |
||||
this.age = age; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* Bean testing the ability to use both lookup method overrides |
||||
* and constructor injection. |
||||
* There is also a property ("setterString") to be set via |
||||
* Setter Injection. |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
abstract class ConstructorInjectedOverrides { |
||||
|
||||
private ITestBean tb; |
||||
|
||||
private String setterString; |
||||
|
||||
public ConstructorInjectedOverrides(ITestBean tb) { |
||||
this.tb = tb; |
||||
} |
||||
|
||||
public ITestBean getTestBean() { |
||||
return this.tb; |
||||
} |
||||
|
||||
|
||||
protected abstract FactoryMethods createFactoryMethods(); |
||||
|
||||
/** |
||||
* @return Returns the setterString. |
||||
*/ |
||||
public String getSetterString() { |
||||
return setterString; |
||||
} |
||||
/** |
||||
* @param setterString The setterString to set. |
||||
*/ |
||||
public void setSetterString(String setterString) { |
||||
this.setterString = setterString; |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Simple bean used to check constructor dependency checking. |
||||
* |
||||
* @author Juergen Hoeller |
||||
* @since 09.11.2003 |
||||
*/ |
||||
@SuppressWarnings("serial") |
||||
class DerivedConstructorDependenciesBean extends ConstructorDependenciesBean { |
||||
|
||||
boolean initialized; |
||||
boolean destroyed; |
||||
|
||||
DerivedConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, IndexedTestBean other) { |
||||
super(spouse1, spouse2, other); |
||||
} |
||||
|
||||
private DerivedConstructorDependenciesBean(TestBean spouse1, Object spouse2, IndexedTestBean other) { |
||||
super(spouse1, null, other); |
||||
} |
||||
|
||||
protected DerivedConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, IndexedTestBean other, int age, int otherAge) { |
||||
super(spouse1, spouse2, other); |
||||
} |
||||
|
||||
public DerivedConstructorDependenciesBean(TestBean spouse1, TestBean spouse2, IndexedTestBean other, int age, String name) { |
||||
super(spouse1, spouse2, other); |
||||
setAge(age); |
||||
setName(name); |
||||
} |
||||
|
||||
private void init() { |
||||
this.initialized = true; |
||||
} |
||||
|
||||
private void destroy() { |
||||
this.destroyed = true; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
interface DummyBo { |
||||
|
||||
void something(); |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
class DummyBoImpl implements DummyBo { |
||||
|
||||
DummyDao dao; |
||||
|
||||
public DummyBoImpl(DummyDao dao) { |
||||
this.dao = dao; |
||||
} |
||||
|
||||
public void something() { |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* @author Rod Johnson |
||||
*/ |
||||
class DummyDao { |
||||
|
||||
DataSource ds; |
||||
|
||||
public DummyDao(DataSource ds) { |
||||
this.ds = ds; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* @author Juergen Hoeller |
||||
* @since 21.07.2003 |
||||
*/ |
||||
class DummyReferencer { |
||||
|
||||
private TestBean testBean1; |
||||
|
||||
private TestBean testBean2; |
||||
|
||||
private DummyFactory dummyFactory; |
||||
|
||||
|
||||
public DummyReferencer() { |
||||
} |
||||
|
||||
public DummyReferencer(DummyFactory dummyFactory) { |
||||
this.dummyFactory = dummyFactory; |
||||
} |
||||
|
||||
public void setDummyFactory(DummyFactory dummyFactory) { |
||||
this.dummyFactory = dummyFactory; |
||||
} |
||||
|
||||
public DummyFactory getDummyFactory() { |
||||
return dummyFactory; |
||||
} |
||||
|
||||
public void setTestBean1(TestBean testBean1) { |
||||
this.testBean1 = testBean1; |
||||
} |
||||
|
||||
public TestBean getTestBean1() { |
||||
return testBean1; |
||||
} |
||||
|
||||
public void setTestBean2(TestBean testBean2) { |
||||
this.testBean2 = testBean2; |
||||
} |
||||
|
||||
public TestBean getTestBean2() { |
||||
return testBean2; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* Test class for Spring's ability to create objects using static |
||||
* factory methods, rather than constructors. |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Juergen Hoeller |
||||
*/ |
||||
class FactoryMethods { |
||||
|
||||
public static FactoryMethods nullInstance() { |
||||
return null; |
||||
} |
||||
|
||||
public static FactoryMethods defaultInstance() { |
||||
TestBean tb = new TestBean(); |
||||
tb.setName("defaultInstance"); |
||||
return new FactoryMethods(tb, "default", 0); |
||||
} |
||||
|
||||
/** |
||||
* Note that overloaded methods are supported. |
||||
*/ |
||||
public static FactoryMethods newInstance(TestBean tb) { |
||||
return new FactoryMethods(tb, "default", 0); |
||||
} |
||||
|
||||
protected static FactoryMethods newInstance(TestBean tb, int num, String name) { |
||||
if (name == null) { |
||||
throw new IllegalStateException("Should never be called with null value"); |
||||
} |
||||
return new FactoryMethods(tb, name, num); |
||||
} |
||||
|
||||
static FactoryMethods newInstance(TestBean tb, int num, Integer something) { |
||||
if (something != null) { |
||||
throw new IllegalStateException("Should never be called with non-null value"); |
||||
} |
||||
return new FactoryMethods(tb, null, num); |
||||
} |
||||
|
||||
private static List<?> listInstance() { |
||||
return Collections.EMPTY_LIST; |
||||
} |
||||
|
||||
|
||||
private int num = 0; |
||||
private String name = "default"; |
||||
private TestBean tb; |
||||
private String stringValue; |
||||
|
||||
|
||||
/** |
||||
* Constructor is private: not for use outside this class, |
||||
* even by IoC container. |
||||
*/ |
||||
private FactoryMethods(TestBean tb, String name, int num) { |
||||
this.tb = tb; |
||||
this.name = name; |
||||
this.num = num; |
||||
} |
||||
|
||||
public void setStringValue(String stringValue) { |
||||
this.stringValue = stringValue; |
||||
} |
||||
|
||||
public String getStringValue() { |
||||
return this.stringValue; |
||||
} |
||||
|
||||
public TestBean getTestBean() { |
||||
return this.tb; |
||||
} |
||||
|
||||
protected TestBean protectedGetTestBean() { |
||||
return this.tb; |
||||
} |
||||
|
||||
private TestBean privateGetTestBean() { |
||||
return this.tb; |
||||
} |
||||
|
||||
public int getNum() { |
||||
return num; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
/** |
||||
* Set via Setter Injection once instance is created. |
||||
*/ |
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Fixed method replacer for String return types |
||||
* @author Rod Johnson |
||||
*/ |
||||
class FixedMethodReplacer implements MethodReplacer { |
||||
|
||||
public static final String VALUE = "fixedMethodReplacer"; |
||||
|
||||
public Object reimplement(Object obj, Method method, Object[] args) throws Throwable { |
||||
return VALUE; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* @author Chris Beams |
||||
*/ |
||||
class MapAndSet { |
||||
|
||||
private Object obj; |
||||
|
||||
public MapAndSet(Map<?, ?> map) { |
||||
this.obj = map; |
||||
} |
||||
|
||||
public MapAndSet(Set<?> set) { |
||||
this.obj = set; |
||||
} |
||||
|
||||
public Object getObject() { |
||||
return obj; |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @author Rod Johnson |
||||
*/ |
||||
class MethodReplaceCandidate { |
||||
|
||||
public String replaceMe(String echo) { |
||||
return echo; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* Bean that exposes a simple property that can be set |
||||
* to a mix of references and individual values. |
||||
* |
||||
* @author Rod Johnson |
||||
* @since 27.05.2003 |
||||
*/ |
||||
class MixedCollectionBean { |
||||
|
||||
private Collection<?> jumble; |
||||
|
||||
|
||||
public void setJumble(Collection<?> jumble) { |
||||
this.jumble = jumble; |
||||
} |
||||
|
||||
public Collection<?> getJumble() { |
||||
return jumble; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* @author Juergen Hoeller |
||||
*/ |
||||
interface OverrideInterface { |
||||
|
||||
TestBean getPrototypeDependency(); |
||||
|
||||
TestBean getPrototypeDependency(Object someParam); |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* @author Rod Johnson |
||||
* @author Juergen Hoeller |
||||
*/ |
||||
abstract class OverrideOneMethod extends MethodReplaceCandidate implements OverrideInterface { |
||||
|
||||
protected abstract TestBean protectedOverrideSingleton(); |
||||
|
||||
public TestBean getPrototypeDependency(Object someParam) { |
||||
return new TestBean(); |
||||
} |
||||
|
||||
public TestBean invokesOverridenMethodOnSelf() { |
||||
return getPrototypeDependency(); |
||||
} |
||||
|
||||
public String echo(String echo) { |
||||
return echo; |
||||
} |
||||
|
||||
/** |
||||
* Overloaded form of replaceMe. |
||||
*/ |
||||
public String replaceMe() { |
||||
return "replaceMe"; |
||||
} |
||||
|
||||
/** |
||||
* Another overloaded form of replaceMe, not getting replaced. |
||||
* Must not cause errors when the other replaceMe methods get replaced. |
||||
*/ |
||||
public String replaceMe(int someParam) { |
||||
return "replaceMe:" + someParam; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* Subclass of OverrideOneMethod, to check that overriding is |
||||
* supported for inherited methods. |
||||
* |
||||
* @author Rod Johnson |
||||
*/ |
||||
abstract class OverrideOneMethodSubclass extends OverrideOneMethod { |
||||
|
||||
protected void doSomething(String arg) { |
||||
// This implementation does nothing!
|
||||
// It's not overloaded
|
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* Simple test of BeanFactory initialization and lifecycle callbacks. |
||||
* |
||||
* @author Rod Johnson |
||||
* @author Juergen Hoeller |
||||
*/ |
||||
class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean { |
||||
|
||||
protected boolean initMethodDeclared = false; |
||||
|
||||
protected String beanName; |
||||
|
||||
protected BeanFactory owningFactory; |
||||
|
||||
protected boolean postProcessedBeforeInit; |
||||
|
||||
protected boolean inited; |
||||
|
||||
protected boolean initedViaDeclaredInitMethod; |
||||
|
||||
protected boolean postProcessedAfterInit; |
||||
|
||||
protected boolean destroyed; |
||||
|
||||
|
||||
public void setInitMethodDeclared(boolean initMethodDeclared) { |
||||
this.initMethodDeclared = initMethodDeclared; |
||||
} |
||||
|
||||
public boolean isInitMethodDeclared() { |
||||
return initMethodDeclared; |
||||
} |
||||
|
||||
public void setBeanName(String name) { |
||||
this.beanName = name; |
||||
} |
||||
|
||||
public String getBeanName() { |
||||
return beanName; |
||||
} |
||||
|
||||
public void setBeanFactory(BeanFactory beanFactory) { |
||||
this.owningFactory = beanFactory; |
||||
} |
||||
|
||||
public void postProcessBeforeInit() { |
||||
if (this.inited || this.initedViaDeclaredInitMethod) { |
||||
throw new RuntimeException("Factory called postProcessBeforeInit after afterPropertiesSet"); |
||||
} |
||||
if (this.postProcessedBeforeInit) { |
||||
throw new RuntimeException("Factory called postProcessBeforeInit twice"); |
||||
} |
||||
this.postProcessedBeforeInit = true; |
||||
} |
||||
|
||||
public void afterPropertiesSet() { |
||||
if (this.owningFactory == null) { |
||||
throw new RuntimeException("Factory didn't call setBeanFactory before afterPropertiesSet on lifecycle bean"); |
||||
} |
||||
if (!this.postProcessedBeforeInit) { |
||||
throw new RuntimeException("Factory didn't call postProcessBeforeInit before afterPropertiesSet on lifecycle bean"); |
||||
} |
||||
if (this.initedViaDeclaredInitMethod) { |
||||
throw new RuntimeException("Factory initialized via declared init method before initializing via afterPropertiesSet"); |
||||
} |
||||
if (this.inited) { |
||||
throw new RuntimeException("Factory called afterPropertiesSet twice"); |
||||
} |
||||
this.inited = true; |
||||
} |
||||
|
||||
public void declaredInitMethod() { |
||||
if (!this.inited) { |
||||
throw new RuntimeException("Factory didn't call afterPropertiesSet before declared init method"); |
||||
} |
||||
|
||||
if (this.initedViaDeclaredInitMethod) { |
||||
throw new RuntimeException("Factory called declared init method twice"); |
||||
} |
||||
this.initedViaDeclaredInitMethod = true; |
||||
} |
||||
|
||||
public void postProcessAfterInit() { |
||||
if (!this.inited) { |
||||
throw new RuntimeException("Factory called postProcessAfterInit before afterPropertiesSet"); |
||||
} |
||||
if (this.initMethodDeclared && !this.initedViaDeclaredInitMethod) { |
||||
throw new RuntimeException("Factory called postProcessAfterInit before calling declared init method"); |
||||
} |
||||
if (this.postProcessedAfterInit) { |
||||
throw new RuntimeException("Factory called postProcessAfterInit twice"); |
||||
} |
||||
this.postProcessedAfterInit = true; |
||||
} |
||||
|
||||
/** |
||||
* Dummy business method that will fail unless the factory |
||||
* managed the bean's lifecycle correctly |
||||
*/ |
||||
public void businessMethod() { |
||||
if (!this.inited || (this.initMethodDeclared && !this.initedViaDeclaredInitMethod) || |
||||
!this.postProcessedAfterInit) { |
||||
throw new RuntimeException("Factory didn't initialize lifecycle object correctly"); |
||||
} |
||||
} |
||||
|
||||
public void destroy() { |
||||
if (this.destroyed) { |
||||
throw new IllegalStateException("Already destroyed"); |
||||
} |
||||
this.destroyed = true; |
||||
} |
||||
|
||||
public boolean isDestroyed() { |
||||
return destroyed; |
||||
} |
||||
|
||||
|
||||
public static class PostProcessor implements BeanPostProcessor { |
||||
|
||||
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { |
||||
if (bean instanceof ProtectedLifecycleBean) { |
||||
((ProtectedLifecycleBean) bean).postProcessBeforeInit(); |
||||
} |
||||
return bean; |
||||
} |
||||
|
||||
public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { |
||||
if (bean instanceof ProtectedLifecycleBean) { |
||||
((ProtectedLifecycleBean) bean).postProcessAfterInit(); |
||||
} |
||||
return bean; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* @author Rod Johnson |
||||
*/ |
||||
@SuppressWarnings("serial") |
||||
class ReverseMethodReplacer implements MethodReplacer, Serializable { |
||||
|
||||
public Object reimplement(Object obj, Method method, Object[] args) throws Throwable { |
||||
String s = (String) args[0]; |
||||
return new StringBuffer(s).reverse().toString(); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* @author Rod Johnson |
||||
*/ |
||||
@SuppressWarnings("serial") |
||||
abstract class SerializableMethodReplacerCandidate extends MethodReplaceCandidate implements Serializable { |
||||
|
||||
//public abstract Point getPoint();
|
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* @author Juergen Hoeller |
||||
* @since 23.10.2004 |
||||
*/ |
||||
class SingleSimpleTypeConstructorBean { |
||||
|
||||
private boolean singleBoolean; |
||||
|
||||
private boolean secondBoolean; |
||||
|
||||
private String testString; |
||||
|
||||
public SingleSimpleTypeConstructorBean(boolean singleBoolean) { |
||||
this.singleBoolean = singleBoolean; |
||||
} |
||||
|
||||
public SingleSimpleTypeConstructorBean(String testString, boolean secondBoolean) { |
||||
this.testString = testString; |
||||
this.secondBoolean = secondBoolean; |
||||
} |
||||
|
||||
public boolean isSingleBoolean() { |
||||
return singleBoolean; |
||||
} |
||||
|
||||
public boolean isSecondBoolean() { |
||||
return secondBoolean; |
||||
} |
||||
|
||||
public String getTestString() { |
||||
return testString; |
||||
} |
||||
|
||||
} |
||||
@ -1,22 +0,0 @@
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> |
||||
|
||||
<beans> |
||||
|
||||
<bean id="rob" class="org.springframework.beans.TestBean" scope="prototype" autowire="constructor"/> |
||||
|
||||
<bean id="sally" class="org.springframework.beans.TestBean" scope="prototype"/> |
||||
|
||||
<bean id="props1" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> |
||||
<property name="properties"> |
||||
<value>name=props1</value> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="props2" class="org.springframework.beans.factory.config.PropertiesFactoryBean" autowire-candidate="false"> |
||||
<property name="properties"> |
||||
<value>name=props2</value> |
||||
</property> |
||||
</bean> |
||||
|
||||
</beans> |
||||
@ -1,34 +0,0 @@
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> |
||||
|
||||
<beans default-lazy-init="true" default-autowire="constructor" default-dependency-check="objects" |
||||
default-init-method="myInit" default-destroy-method="myDestroy" default-merge="true"> |
||||
|
||||
<import resource="beanEventsImported.xml"/> |
||||
|
||||
<alias name="testBean" alias="testBeanAlias1"/> |
||||
|
||||
<alias name="testBean" alias="testBeanAlias2"/> |
||||
|
||||
<bean id="testBean" class="org.springframework.beans.TestBean"> |
||||
<constructor-arg type="java.lang.String" value="Rob Harrop"/> |
||||
<property name="friends"> |
||||
<ref bean="testBean2"/> |
||||
</property> |
||||
<property name="doctor"> |
||||
<bean class="org.springframework.beans.NestedTestBean"> |
||||
<constructor-arg type="java.lang.String" value="ACME"/> |
||||
</bean> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="testBean2" class="org.springframework.beans.TestBean"> |
||||
<property name="name" value="Juergen Hoeller"/> |
||||
<property name="spouse"> |
||||
<bean class="org.springframework.beans.TestBean"> |
||||
<property name="name" value="Eva Schallmeiner"/> |
||||
</bean> |
||||
</property> |
||||
</bean> |
||||
|
||||
</beans> |
||||
@ -1,6 +0,0 @@
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> |
||||
|
||||
<beans> |
||||
|
||||
</beans> |
||||
@ -1,18 +0,0 @@
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> |
||||
|
||||
<beans> |
||||
|
||||
<bean class="org.springframework.beans.factory.xml.GeneratedNameBean"> |
||||
<property name="child"> |
||||
<bean class="org.springframework.beans.factory.xml.GeneratedNameBean"/> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean class="org.springframework.beans.factory.xml.GeneratedNameBean"> |
||||
<property name="child"> |
||||
<bean class="org.springframework.beans.factory.xml.GeneratedNameBean"/> |
||||
</property> |
||||
</bean> |
||||
|
||||
</beans> |
||||
@ -1,205 +0,0 @@
@@ -1,205 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> |
||||
|
||||
<beans> |
||||
|
||||
<bean id="parentWithList" class="org.springframework.beans.TestBean"> |
||||
<property name="someList"> |
||||
<list> |
||||
<value>Rob Harrop</value> |
||||
<value>Rod Johnson</value> |
||||
</list> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="childWithList" parent="parentWithList"> |
||||
<property name="someList"> |
||||
<list merge="true"> |
||||
<value>Juergen Hoeller</value> |
||||
</list> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="childWithListOfRefs" parent="parentWithList"> |
||||
<property name="someList"> |
||||
<list merge="true"> |
||||
<bean class="org.springframework.beans.TestBean"/> |
||||
</list> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="parentWithSet" class="org.springframework.beans.TestBean"> |
||||
<property name="someSet"> |
||||
<set> |
||||
<value>Rob Harrop</value> |
||||
</set> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="childWithSet" parent="parentWithSet"> |
||||
<property name="someSet"> |
||||
<set merge="true"> |
||||
<value>Sally Greenwood</value> |
||||
</set> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="childWithSetOfRefs" parent="parentWithSet"> |
||||
<property name="someSet"> |
||||
<set merge="true"> |
||||
<bean class="org.springframework.beans.TestBean"> |
||||
<property name="name" value="Sally"/> |
||||
</bean> |
||||
</set> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="parentWithMap" class="org.springframework.beans.TestBean"> |
||||
<property name="someMap"> |
||||
<map> |
||||
<entry key="Rob" value="Sall"/> |
||||
<entry key="Juergen" value="Eva"/> |
||||
</map> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="childWithMap" parent="parentWithMap"> |
||||
<property name="someMap"> |
||||
<map merge="true"> |
||||
<entry key="Rod" value="Kerry"/> |
||||
<entry key="Rob" value="Sally"/> |
||||
</map> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="childWithMapOfRefs" parent="parentWithMap"> |
||||
<property name="someMap"> |
||||
<map merge="true"> |
||||
<entry key="Rob"> |
||||
<bean class="org.springframework.beans.TestBean"> |
||||
<property name="name" value="Sally"/> |
||||
</bean> |
||||
</entry> |
||||
</map> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="parentWithProps" class="org.springframework.beans.TestBean"> |
||||
<property name="someProperties"> |
||||
<props> |
||||
<prop key="Rob">Sall</prop> |
||||
<prop key="Rod">Kerry</prop> |
||||
</props> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="childWithProps" parent="parentWithProps"> |
||||
<property name="someProperties"> |
||||
<props merge="true"> |
||||
<prop key="Juergen">Eva</prop> |
||||
<prop key="Rob">Sally</prop> |
||||
</props> |
||||
</property> |
||||
</bean> |
||||
|
||||
|
||||
<bean id="parentWithListInConstructor" class="org.springframework.beans.TestBean"> |
||||
<constructor-arg index="0"> |
||||
<list> |
||||
<value>Rob Harrop</value> |
||||
<value>Rod Johnson</value> |
||||
</list> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="childWithListInConstructor" parent="parentWithListInConstructor"> |
||||
<constructor-arg index="0"> |
||||
<list merge="true"> |
||||
<value>Juergen Hoeller</value> |
||||
</list> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="childWithListOfRefsInConstructor" parent="parentWithListInConstructor"> |
||||
<constructor-arg index="0"> |
||||
<list merge="true"> |
||||
<bean class="org.springframework.beans.TestBean"/> |
||||
</list> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="parentWithSetInConstructor" class="org.springframework.beans.TestBean"> |
||||
<constructor-arg index="0"> |
||||
<set> |
||||
<value>Rob Harrop</value> |
||||
</set> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="childWithSetInConstructor" parent="parentWithSetInConstructor"> |
||||
<constructor-arg index="0"> |
||||
<set merge="true"> |
||||
<value>Sally Greenwood</value> |
||||
</set> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="childWithSetOfRefsInConstructor" parent="parentWithSetInConstructor"> |
||||
<constructor-arg index="0"> |
||||
<set merge="true"> |
||||
<bean class="org.springframework.beans.TestBean"> |
||||
<property name="name" value="Sally"/> |
||||
</bean> |
||||
</set> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="parentWithMapInConstructor" class="org.springframework.beans.TestBean"> |
||||
<constructor-arg index="0"> |
||||
<map> |
||||
<entry key="Rob" value="Sall"/> |
||||
<entry key="Juergen" value="Eva"/> |
||||
</map> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="childWithMapInConstructor" parent="parentWithMapInConstructor"> |
||||
<constructor-arg index="0"> |
||||
<map merge="true"> |
||||
<entry key="Rod" value="Kerry"/> |
||||
<entry key="Rob" value="Sally"/> |
||||
</map> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="childWithMapOfRefsInConstructor" parent="parentWithMapInConstructor"> |
||||
<constructor-arg index="0"> |
||||
<map merge="true"> |
||||
<entry key="Rob"> |
||||
<bean class="org.springframework.beans.TestBean"> |
||||
<property name="name" value="Sally"/> |
||||
</bean> |
||||
</entry> |
||||
</map> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="parentWithPropsInConstructor" class="org.springframework.beans.TestBean"> |
||||
<constructor-arg index="0"> |
||||
<props> |
||||
<prop key="Rob">Sall</prop> |
||||
<prop key="Rod">Kerry</prop> |
||||
</props> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="childWithPropsInConstructor" parent="parentWithPropsInConstructor"> |
||||
<constructor-arg index="0"> |
||||
<props merge="true"> |
||||
<prop key="Juergen">Eva</prop> |
||||
<prop key="Rob">Sally</prop> |
||||
</props> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
</beans> |
||||
@ -1,61 +0,0 @@
@@ -1,61 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" |
||||
"http://www.springframework.org/dtd/spring-beans-2.0.dtd"> |
||||
|
||||
<beans> |
||||
<bean id="testBean" class="org.springframework.beans.TestBean"> |
||||
<property name="someList"> |
||||
<list value-type="java.lang.Integer"> |
||||
<value>1</value> |
||||
<value>2</value> |
||||
<value>3</value> |
||||
</list> |
||||
</property> |
||||
<property name="someSet"> |
||||
<set value-type="java.lang.Integer"> |
||||
<value>1</value> |
||||
<value>2</value> |
||||
<value>3</value> |
||||
</set> |
||||
</property> |
||||
<property name="someMap"> |
||||
<map key-type="java.lang.Integer" value-type="java.lang.Boolean"> |
||||
<entry key="1" value="true"/> |
||||
<entry key="2" value="false"/> |
||||
<entry key="3" value="false"/> |
||||
<entry key="4" value="true"/> |
||||
</map> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="testBean2" class="org.springframework.beans.TestBean"> |
||||
<property name="someMap"> |
||||
<map key-type="java.lang.Integer" value-type="java.lang.Boolean"> |
||||
<entry> |
||||
<key> |
||||
<value>1</value> |
||||
</key> |
||||
<value>true</value> |
||||
</entry> |
||||
<entry> |
||||
<key> |
||||
<value>2</value> |
||||
</key> |
||||
<value>false</value> |
||||
</entry> |
||||
<entry> |
||||
<key> |
||||
<value>3</value> |
||||
</key> |
||||
<value>false</value> |
||||
</entry> |
||||
<entry> |
||||
<key> |
||||
<value>4</value> |
||||
</key> |
||||
<value>true</value> |
||||
</entry> |
||||
</map> |
||||
</property> |
||||
</bean> |
||||
</beans> |
||||
@ -1,14 +0,0 @@
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> |
||||
|
||||
<beans default-init-method="init" default-destroy-method="destroy"> |
||||
|
||||
<bean id="lifecycleAware" class="org.springframework.beans.factory.xml.DefaultLifecycleMethodsTests$LifecycleAwareBean"/> |
||||
|
||||
<bean id="lifecycleMethodsDisabled" class="org.springframework.beans.factory.xml.DefaultLifecycleMethodsTests$LifecycleAwareBean" |
||||
init-method="" destroy-method=""/> |
||||
|
||||
<bean id="overrideLifecycleMethods" class="org.springframework.beans.factory.xml.DefaultLifecycleMethodsTests$LifecycleAwareBean" |
||||
init-method="customInit" destroy-method="customDestroy"/> |
||||
|
||||
</beans> |
||||
@ -1,8 +0,0 @@
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> |
||||
|
||||
<beans default-init-method="foo" default-destroy-method="bar"> |
||||
|
||||
<bean id="foo" class="org.springframework.beans.factory.xml.DefaultLifecycleMethodsTests$LifecycleAwareBean"/> |
||||
|
||||
</beans> |
||||
@ -1,10 +0,0 @@
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> |
||||
|
||||
<beans> |
||||
|
||||
<bean id="invalidFactory" class="org.springframework.beans.factory.DummyFactory" scope="prototype"> |
||||
<property name="singleton"><value>false</value></property> |
||||
</bean> |
||||
|
||||
</beans> |
||||
@ -1,8 +0,0 @@
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> |
||||
|
||||
<foobar/> |
||||
|
||||
</beans> |
||||
@ -1,20 +0,0 @@
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> |
||||
|
||||
<bean xml:lang="en" id="testBean" class="org.springframework.beans.TestBean"/> |
||||
|
||||
<bean id="fooBean" class="org.springframework.beans.TestBean"> |
||||
<property name="spouse"> |
||||
<bean class="org.springframework.beans.TestBean"/> |
||||
</property> |
||||
<property name="friends"> |
||||
<list> |
||||
<bean class="org.springframework.beans.TestBean"/> |
||||
<bean class="org.springframework.beans.TestBean"/> |
||||
</list> |
||||
</property> |
||||
</bean> |
||||
|
||||
</beans> |
||||
@ -1,27 +0,0 @@
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xmlns:aop="http://www.springframework.org/schema/aop" |
||||
xmlns:tx="http://www.springframework.org/schema/tx" |
||||
xmlns:p="http://www.springframework.org/schema/p" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd |
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> |
||||
|
||||
<bean id="rob" class="org.springframework.beans.TestBean" p:name="Rob Harrop" p:spouse-ref="sally"> |
||||
<property name="age" value="24"/> |
||||
</bean> |
||||
|
||||
<bean id="sally" class="org.springframework.beans.TestBean" p:name="Sally Greenwood" p:spouse-ref="rob"/> |
||||
|
||||
<bean id="sally2" class="org.springframework.beans.TestBean"> |
||||
<property name="spouse"> |
||||
<bean id="rob2" class="org.springframework.beans.TestBean" p:name="Rob Harrop" p:spouse-ref="sally2"> |
||||
<property name="age" value="24"/> |
||||
</bean> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="derivedSally" class="org.springframework.beans.DerivedTestBean" p:name="Sally Greenwood" p:spouseRef="r"/> |
||||
|
||||
</beans> |
||||
@ -1,17 +0,0 @@
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xmlns:aop="http://www.springframework.org/schema/aop" |
||||
xmlns:tx="http://www.springframework.org/schema/tx" |
||||
xmlns:p="http://www.springframework.org/schema/p" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd |
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> |
||||
|
||||
<bean id="rob" class="org.springframework.beans.TestBean" p:name="Rob Harrop" p:spouse-ref="sally"> |
||||
<property name="name" value="Rob Harrop"/> |
||||
</bean> |
||||
|
||||
<bean id="sally" class="org.springframework.beans.TestBean" p:name="Sally Greenwood" p:spouse-ref="rob"/> |
||||
|
||||
</beans> |
||||
@ -1,127 +0,0 @@
@@ -1,127 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> |
||||
|
||||
<beans> |
||||
|
||||
<bean id="validEmptyWithDescription" class="org.springframework.beans.TestBean"> |
||||
<description> |
||||
I have no properties and I'm happy without them. |
||||
</description> |
||||
</bean> |
||||
|
||||
<!-- |
||||
Check automatic creation of alias, to allow for names that are illegal as XML ids. |
||||
--> |
||||
<bean id="aliased" class=" org.springframework.beans.TestBean " name="myalias"> |
||||
<property name="name"><value>aliased</value></property> |
||||
</bean> |
||||
|
||||
<alias name="aliased" alias="youralias"/> |
||||
|
||||
<alias name="multiAliased" alias="alias3"/> |
||||
|
||||
<bean id="multiAliased" class="org.springframework.beans.TestBean" name="alias1,alias2"> |
||||
<property name="name"><value>aliased</value></property> |
||||
</bean> |
||||
|
||||
<alias name="multiAliased" alias="alias4"/> |
||||
|
||||
<bean class="org.springframework.beans.TestBean" name="aliasWithoutId1,aliasWithoutId2,aliasWithoutId3"> |
||||
<property name="name"><value>aliased</value></property> |
||||
</bean> |
||||
|
||||
<bean class="org.springframework.beans.TestBean"> |
||||
<property name="name"><null/></property> |
||||
</bean> |
||||
|
||||
<bean class="org.springframework.beans.factory.xml.DummyReferencer"/> |
||||
|
||||
<bean class="org.springframework.beans.factory.xml.DummyReferencer"/> |
||||
|
||||
<bean class="org.springframework.beans.factory.xml.DummyReferencer"/> |
||||
|
||||
<bean id="rod" class="org.springframework.beans.TestBean"> |
||||
<property name="name"><value><!-- a comment -->Rod</value></property> |
||||
<property name="age"><value>31</value></property> |
||||
<property name="spouse"><ref bean="father"/></property> |
||||
<property name="touchy"><value/></property> |
||||
</bean> |
||||
|
||||
<bean id="roderick" parent="rod"> |
||||
<property name="name"><value>Roderick<!-- a comment --></value></property> |
||||
<!-- Should inherit age --> |
||||
</bean> |
||||
|
||||
<bean id="kerry" class="org.springframework.beans.TestBean"> |
||||
<property name="name"><value>Ker<!-- a comment -->ry</value></property> |
||||
<property name="age"><value>34</value></property> |
||||
<property name="spouse"><ref local="rod"/></property> |
||||
<property name="touchy"><value></value></property> |
||||
</bean> |
||||
|
||||
<bean id="kathy" class="org.springframework.beans.TestBean" scope="prototype"> |
||||
<property name="name"><value>Kathy</value></property> |
||||
<property name="age"><value>28</value></property> |
||||
<property name="spouse"><ref bean="father"/></property> |
||||
</bean> |
||||
|
||||
<bean id="typeMismatch" class="org.springframework.beans.TestBean" scope="prototype"> |
||||
<property name="name"><value>typeMismatch</value></property> |
||||
<property name="age"><value>34x</value></property> |
||||
<property name="spouse"><ref local="rod"/></property> |
||||
</bean> |
||||
|
||||
<!-- Test of lifecycle callbacks --> |
||||
<bean id="mustBeInitialized" class="org.springframework.beans.factory.MustBeInitialized"/> |
||||
|
||||
<bean id="lifecycle" class="org.springframework.beans.factory.LifecycleBean" |
||||
init-method="declaredInitMethod"> |
||||
<property name="initMethodDeclared"><value>true</value></property> |
||||
</bean> |
||||
|
||||
<bean id="protectedLifecycle" class="org.springframework.beans.factory.xml.ProtectedLifecycleBean" |
||||
init-method="declaredInitMethod"> |
||||
<property name="initMethodDeclared"><value>true</value></property> |
||||
</bean> |
||||
|
||||
<!-- Factory beans are automatically treated differently --> |
||||
<bean id="singletonFactory" class="org.springframework.beans.factory.DummyFactory"> |
||||
</bean> |
||||
|
||||
<bean id="prototypeFactory" class="org.springframework.beans.factory.DummyFactory"> |
||||
<property name="singleton"><value>false</value></property> |
||||
</bean> |
||||
|
||||
<!-- Check that the circular reference resolution mechanism doesn't break |
||||
repeated references to the same FactoryBean --> |
||||
<bean id="factoryReferencer" class="org.springframework.beans.factory.xml.DummyReferencer"> |
||||
<property name="testBean1"><ref bean="singletonFactory"/></property> |
||||
<property name="testBean2"><ref local="singletonFactory"/></property> |
||||
<property name="dummyFactory"><ref bean="&singletonFactory"/></property> |
||||
</bean> |
||||
|
||||
<bean id="factoryReferencerWithConstructor" class="org.springframework.beans.factory.xml.DummyReferencer"> |
||||
<constructor-arg><ref bean="&singletonFactory"/></constructor-arg> |
||||
<property name="testBean1"><ref bean="singletonFactory"/></property> |
||||
<property name="testBean2"><ref local="singletonFactory"/></property> |
||||
</bean> |
||||
|
||||
<!-- Check that the circular reference resolution mechanism doesn't break |
||||
prototype instantiation --> |
||||
<bean id="prototypeReferencer" class="org.springframework.beans.factory.xml.DummyReferencer" scope="prototype"> |
||||
<property name="testBean1"><ref local="kathy"/></property> |
||||
<property name="testBean2"><ref bean="kathy"/></property> |
||||
</bean> |
||||
|
||||
<bean id="listenerVeto" class="org.springframework.beans.TestBean"> |
||||
<property name="name"><value>listenerVeto</value></property> |
||||
<property name="age"><value>66</value></property> |
||||
</bean> |
||||
|
||||
<bean id="validEmpty" class="org.springframework.beans.TestBean"/> |
||||
|
||||
<bean id="commentsInValue" class="org.springframework.beans.TestBean"> |
||||
<property name="name"><value>this is<!-- don't mind me --> a <![CDATA[<!--comment-->]]></value></property> |
||||
</bean> |
||||
|
||||
</beans> |
||||
@ -1,184 +0,0 @@
@@ -1,184 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xmlns:util="http://www.springframework.org/schema/util" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd |
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd"> |
||||
|
||||
<util:constant id="min" static-field=" |
||||
java.lang.Integer. |
||||
MIN_VALUE |
||||
"/> |
||||
|
||||
<util:constant static-field="java.lang.Integer.MAX_VALUE"/> |
||||
|
||||
<util:property-path id="name" path=" |
||||
configuredBean. |
||||
name |
||||
"/> |
||||
|
||||
<bean id="testBean" class="org.springframework.beans.TestBean" scope="prototype"> |
||||
<property name="name"> |
||||
<util:property-path path="configuredBean.name"/> |
||||
</property> |
||||
<property name="someProperties"> |
||||
<util:properties location="classpath:/org/springframework/beans/factory/config/util.properties"/> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="constructedTestBean" class="org.springframework.beans.TestBean"> |
||||
<constructor-arg index="0"> |
||||
<util:property-path path="configuredBean.name"/> |
||||
</constructor-arg> |
||||
</bean> |
||||
|
||||
<bean id="configuredBean" class="org.springframework.beans.TestBean"> |
||||
<property name="name" value="Rob Harrop"/> |
||||
</bean> |
||||
|
||||
<util:map id="simpleMap"> |
||||
<entry key="foo" value="bar"/> |
||||
</util:map> |
||||
|
||||
<util:map id="scopedMap" scope="prototype"> |
||||
<description>My scoped Map</description> |
||||
<entry key="foo" value="bar"/> |
||||
</util:map> |
||||
|
||||
<util:map id="mapWithRef" map-class="java.util.TreeMap"> |
||||
<entry key="bean" value-ref="testBean"/> |
||||
</util:map> |
||||
|
||||
<util:list id="simpleList"> |
||||
<value>Rob Harrop</value> |
||||
</util:list> |
||||
|
||||
<util:list id="scopedList" scope="prototype"> |
||||
<description>My scoped List</description> |
||||
<value>Rob Harrop</value> |
||||
</util:list> |
||||
|
||||
<util:set id="simpleSet"> |
||||
<value>Rob Harrop</value> |
||||
</util:set> |
||||
|
||||
<util:set id="scopedSet" scope="prototype"> |
||||
<description>My scoped Set</description> |
||||
<value>Rob Harrop</value> |
||||
</util:set> |
||||
|
||||
<bean id="nestedCollectionsBean" class="org.springframework.beans.TestBean"> |
||||
<property name="someList"> |
||||
<util:list> |
||||
<value>foo</value> |
||||
</util:list> |
||||
</property> |
||||
<property name="someSet"> |
||||
<util:set> |
||||
<value>bar</value> |
||||
</util:set> |
||||
</property> |
||||
<property name="someMap"> |
||||
<util:map> |
||||
<entry key="foo"> |
||||
<util:set> |
||||
<value>bar</value> |
||||
</util:set> |
||||
</entry> |
||||
</util:map> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="nestedCustomTagBean" class="org.springframework.beans.TestBean" scope="prototype"> |
||||
<property name="someList"> |
||||
<list> |
||||
<util:constant static-field="java.lang.Integer.MIN_VALUE"/> |
||||
</list> |
||||
</property> |
||||
<property name="someSet"> |
||||
<set> |
||||
<util:constant static-field="java.lang.Integer.MIN_VALUE"/> |
||||
</set> |
||||
</property> |
||||
<property name="someMap"> |
||||
<map> |
||||
<entry> |
||||
<key><value>min</value></key> |
||||
<util:constant static-field="java.lang.Integer.MIN_VALUE"/> |
||||
</entry> |
||||
</map> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="circularCollectionsBean" class="org.springframework.beans.TestBean"> |
||||
<property name="someList"> |
||||
<util:list> |
||||
<ref bean="circularCollectionsBean"/> |
||||
</util:list> |
||||
</property> |
||||
<property name="someSet"> |
||||
<util:set> |
||||
<ref bean="circularCollectionsBean"/> |
||||
</util:set> |
||||
</property> |
||||
<property name="someMap"> |
||||
<util:map> |
||||
<entry key="foo" value-ref="circularCollectionsBean"/> |
||||
</util:map> |
||||
</property> |
||||
</bean> |
||||
|
||||
<util:list id="circularList"> |
||||
<ref bean="circularCollectionBeansBean"/> |
||||
</util:list> |
||||
|
||||
<util:set id="circularSet"> |
||||
<ref bean="circularCollectionBeansBean"/> |
||||
</util:set> |
||||
|
||||
<util:map id="circularMap"> |
||||
<entry key="foo" value-ref="circularCollectionBeansBean"/> |
||||
</util:map> |
||||
|
||||
<bean id="circularCollectionBeansBean" class="org.springframework.beans.TestBean"> |
||||
<property name="someList" ref="circularList"/> |
||||
<property name="someSet" ref="circularSet"/> |
||||
<property name="someMap" ref="circularMap"/> |
||||
</bean> |
||||
|
||||
<util:properties id="myProperties" |
||||
location="classpath:/org/springframework/beans/factory/config/util.properties"/> |
||||
|
||||
<util:properties id="myScopedProperties" |
||||
location="classpath:/org/springframework/beans/factory/config/util.properties" scope="prototype"/> |
||||
|
||||
<util:properties id="myLocalProperties"> |
||||
<prop key="foo2">bar2</prop> |
||||
</util:properties> |
||||
|
||||
<util:properties id="myMergedProperties" |
||||
location="classpath:/org/springframework/beans/factory/config/util.properties"> |
||||
<prop key="foo2">bar2</prop> |
||||
</util:properties> |
||||
|
||||
<util:properties id="defaultLocalOverrideProperties" |
||||
location="classpath:/org/springframework/beans/factory/config/util.properties"> |
||||
<prop key="foo">local</prop> |
||||
<prop key="foo2">local2</prop> |
||||
</util:properties> |
||||
|
||||
<util:properties id="trueLocalOverrideProperties" |
||||
location="classpath:/org/springframework/beans/factory/config/util.properties" |
||||
local-override="true"> |
||||
<prop key="foo">local</prop> |
||||
<prop key="foo2">local2</prop> |
||||
</util:properties> |
||||
|
||||
<util:properties id="falseLocalOverrideProperties" |
||||
location="classpath:/org/springframework/beans/factory/config/util.properties" |
||||
local-override="false"> |
||||
<prop key="foo">local</prop> |
||||
<prop key="foo2">local2</prop> |
||||
</util:properties> |
||||
|
||||
</beans> |
||||
@ -1,13 +0,0 @@
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
This is a top level block comment |
||||
--> |
||||
<!-- here is a line comment --> |
||||
<!-- trying --> <!-- to trick --> <!-- |
||||
the parser now --> <!-- <beans> |
||||
--> |
||||
<!-- more trickery--> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"><!-- some nasty stuff --> |
||||
|
||||
<beans> |
||||
<bean id="testBean" class="org.springframework.beans.TestBean"/> |
||||
</beans> |
||||
@ -1,11 +0,0 @@
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
This is a top level block comment |
||||
--> |
||||
<!-- here is a line comment --> |
||||
<!-- trying --> <!-- to trick --> <!-- |
||||
the parser now --> <!-- <beans> |
||||
--> |
||||
<!-- more trickery--><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"><!-- end --> |
||||
<bean id="testBean" class="org.springframework.beans.TestBean"/> |
||||
</beans> |
||||
@ -1,21 +0,0 @@
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<spring:beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xmlns:spring="http://www.springframework.org/schema/beans" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> |
||||
|
||||
<spring:bean id="testBean1" class="org.springframework.beans.TestBean"> |
||||
<spring:meta key="foo" value="bar"/> |
||||
</spring:bean> |
||||
|
||||
<spring:bean id="testBean2" class="org.springframework.beans.TestBean" parent="testBean1"> |
||||
<spring:meta key="abc" value="123"/> |
||||
</spring:bean> |
||||
|
||||
<spring:bean id="testBean3" class="org.springframework.beans.TestBean"> |
||||
<spring:property name="name" value="Rob"> |
||||
<spring:meta key="surname" value="Harrop"/> |
||||
</spring:property> |
||||
</spring:bean> |
||||
|
||||
</spring:beans> |
||||
Loading…
Reference in new issue