git://wamblee.org
/
utils
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(no commit message)
[utils]
/
system
/
general
/
src
/
test
/
java
/
org
/
wamblee
/
system
/
core
/
IntegerComponent.java
diff --git
a/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java
b/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java
index 547f831d4e9e4d14447965733728acd6fabc8d0f..20b5a625c1a857515a8628bbce3573db27e3873f 100644
(file)
--- a/
system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java
+++ b/
system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 200
7
the original author or authors.
+ * Copyright 200
5-2010
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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-12,71
+12,86
@@
* 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.
* 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.wamblee.system.core;
package org.wamblee.system.core;
-import javax.sql.DataSource;
-
-import org.wamblee.system.core.AbstractComponent;
-import org.wamblee.system.core.DefaultProvidedInterface;
-import org.wamblee.system.core.ProvidedInterface;
-import org.wamblee.system.core.RequiredInterface;
import org.wamblee.test.EventTracker;
import org.wamblee.test.EventTracker;
-public class IntegerComponent extends AbstractComponent {
+/**
+ *
+ * @author $author$
+ * @version $Revision$
+ */
+public class IntegerComponent extends AbstractComponent<Object> {
+ private EventTracker<String> tracker;
- private static final ProvidedInterface[] provided(String aPrefix) {
- return new ProvidedInterface[] {
- new DefaultProvidedInterface(aPrefix + "integer", Integer.class) };
- }
+ private double random;
- private EventTracker<String> _tracker;
- private double _random;
+ /**
+ * Creates a new IntegerComponent object.
+ */
+ public IntegerComponent() {
+ this("environment");
+ }
- public IntegerComponent() {
- this("environment");
- }
-
-
public IntegerComponent(String aName) {
- this(aName, "");
+ /**
+ * Creates a new IntegerComponent object.
+ *
+ */
+ public IntegerComponent(String aName) {
+
this(aName, "");
}
}
-
- public IntegerComponent(String aName, String aPrefix) {
+
+ /**
+ * Creates a new IntegerComponent object.
+ *
+ */
+ public IntegerComponent(String aName, String aPrefix) {
super(aName, provided(aPrefix), new RequiredInterface[0]);
super(aName, provided(aPrefix), new RequiredInterface[0]);
- _random = Math.random();
+ random = Math.random();
+ }
+
+ /**
+ * Creates a new IntegerComponent object.
+ *
+ */
+ public IntegerComponent(EventTracker aTracker) {
+ this();
+ tracker = aTracker;
}
}
+ private static final ProvidedInterface[] provided(String aPrefix) {
+ return new ProvidedInterface[] { new DefaultProvidedInterface(aPrefix +
+ "integer", Integer.class) };
+ }
+ public Integer getInteger() {
+ return 2;
+ }
- public IntegerComponent(EventTracker aTracker) {
- this();
-
_tracker = aTracker
;
- }
+ @Override
+ protected Object doStart(Scope aScope) {
+
addInterface(getProvidedInterfaces().get(1), getInteger(), aScope)
;
+ track("start." + getName());
- public Integer getInteger() {
- return 2;
- }
+ return random;
+ }
- @Override
- protected Object doStart(Scope aScope) {
- addInterface(getProvidedInterfaces().get(1), getInteger(), aScope);
- track("start." + getName());
- return _random;
- }
+ @Override
+ protected void doStop(Object aRuntime) {
+ track("stop." + getName());
- @Override
- protected void doStop(Object aRuntime) {
- track("stop." + getName());
- if (_random != (Double) aRuntime) {
- throw new IllegalArgumentException("Wrong runtime: expected "
- + _random + " but got " + aRuntime);
- }
- }
+ if (random != (Double) aRuntime) {
+ throw new IllegalArgumentException("Wrong runtime: expected " +
+ random + " but got " + aRuntime);
+ }
+ }
+
+ private void track(String aString) {
+ if (tracker == null) {
+ return;
+ }
- private void track(String aString) {
- if (_tracker == null) {
- return;
- }
- _tracker.eventOccurred(aString);
- }
+ tracker.eventOccurred(aString);
+ }
}
}