hlship 2004/08/19 06:46:42
Modified: library/src/java/org/apache/hivemind/lib BeanFactory.java
. status.xml
library/src/java/org/apache/hivemind/lib/factory
BeanFactoryImpl.java
library/src/test/org/apache/hivemind/lib/factory
TestBeanFactoryImpl.java
Log:
[HIVEMIND-36] Add polling method to BeanFactory.
Revision Changes Path
1.3 +9 -0
jakarta-hivemind/library/src/java/org/apache/hivemind/lib/BeanFactory.java
Index: BeanFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-hivemind/library/src/java/org/apache/hivemind/lib/BeanFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BeanFactory.java 15 Jun 2004 13:42:33 -0000 1.2
+++ BeanFactory.java 19 Aug 2004 13:46:42 -0000 1.3
@@ -32,6 +32,15 @@
public interface BeanFactory
{
/**
+ * Returns true if a bean matching the provided locator has been
+ * defined.
+ *
+ * @param locator the name or name and initializer
+ * @return true if a bean matching the provided locator has ben defined
+ */
+ public boolean contains(String locator);
+
+ /**
* Gets a bean via its locator (it's name plus, optionally, an
initializer).
*
* @param locator the name or name and initializer
1.49 +3 -0 jakarta-hivemind/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/status.xml,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- status.xml 19 Aug 2004 13:35:54 -0000 1.48
+++ status.xml 19 Aug 2004 13:46:42 -0000 1.49
@@ -73,6 +73,9 @@
<action type="add" dev="HLS" due-to="Naresh Sikha"
fixes-bug="HIVEMIND-37">
Add polling methods to Registry.
</action>
+ <action type="add" dev="HLS" due-to="Naresh Sikha"
fixes-bug="HIVEMIND-36">
+ Add polling methods to BeanFactory.
+ </action>
</release>
<release version="1.0-beta-2" date="Aug 1 2004">
1.3 +11 -3
jakarta-hivemind/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryImpl.java
Index: BeanFactoryImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-hivemind/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BeanFactoryImpl.java 17 Jun 2004 15:16:12 -0000 1.2
+++ BeanFactoryImpl.java 19 Aug 2004 13:46:42 -0000 1.3
@@ -56,6 +56,15 @@
processContributions(contributions);
}
+ public boolean contains(String locator)
+ {
+ int commax = locator.indexOf(',');
+
+ String name = commax < 0 ? locator.trim() : locator.substring(0,
commax);
+
+ return _contributions.containsKey(name);
+ }
+
private void processContributions(List list)
{
Iterator i = list.iterator();
@@ -88,8 +97,7 @@
String name = c.getName();
- BeanFactoryContribution existing =
- (BeanFactoryContribution) _contributions.get(name);
+ BeanFactoryContribution existing = (BeanFactoryContribution)
_contributions.get(name);
if (existing != null)
{
@@ -162,4 +170,4 @@
}
}
-}
+}
\ No newline at end of file
1.6 +24 -1
jakarta-hivemind/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java
Index: TestBeanFactoryImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-hivemind/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestBeanFactoryImpl.java 18 Aug 2004 19:34:11 -0000 1.5
+++ TestBeanFactoryImpl.java 19 Aug 2004 13:46:42 -0000 1.6
@@ -223,7 +223,8 @@
"foo.bar",
BeanFactory.class,
null,
- null, Collections.singletonList(p));
+ null,
+ Collections.singletonList(p));
Integer i = (Integer) f.get("integer,5");
@@ -242,5 +243,27 @@
assertEquals(new Integer(27), f.get("int,27"));
assertEquals(new Double(-22.5), f.get("double,-22.5"));
+ }
+
+ public void testContains()
+ {
+ List l = Collections.singletonList(build("integer", Integer.class));
+
+ BeanFactoryImpl f = new BeanFactoryImpl(null, null, Integer.class,
l, true);
+
+ boolean contains = f.contains("integer");
+
+ assertTrue(contains);
+ }
+
+ public void testContainsFailure()
+ {
+ List l = Collections.singletonList(build("integer", Integer.class));
+
+ BeanFactoryImpl f = new BeanFactoryImpl(null, null, Integer.class,
l, true);
+
+ boolean contains = f.contains("not_found");
+
+ assertTrue(!contains);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]