/*
* Copyright 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.
*/
package org.wamblee.system.container;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
import org.wamblee.system.core.AbstractComponent;
import org.wamblee.system.core.DefaultRequiredInterface;
import org.wamblee.system.core.ProvidedInterface;
import org.wamblee.system.core.RequiredInterface;
import org.wamblee.system.core.Scope;
+
import org.wamblee.test.EventTracker;
+
+/**
+ * DOCUMENT ME!
+ *
+ * @author $author$
+ * @version $Revision$
+ */
public class Application extends AbstractComponent<Object> {
- public static RequiredInterface[] required(boolean aOptional,
- String aPrefix) {
- return new RequiredInterface[] {
- new DefaultRequiredInterface(aPrefix + "string", String.class,
- aOptional),
- new DefaultRequiredInterface(aPrefix + "integer",
- Integer.class, aOptional) };
- }
+ /**
+ * DOCUMENT ME!
+ */
+ private EventTracker<String> tracker;
- public static RequiredInterface[] required(boolean aOptional) {
- return required(aOptional, "");
- }
+ /**
+ * DOCUMENT ME!
+ */
+ private String string;
- private EventTracker<String> _tracker;
- private String _string;
- private Integer _integer;
- private double _random;
+ /**
+ * DOCUMENT ME!
+ */
+ private Integer integer;
+ /**
+ * DOCUMENT ME!
+ */
+ private double random;
+
+ /**
+ * Creates a new Application object.
+ */
public Application() {
this("application");
}
+ /**
+ * Creates a new Application object.
+ *
+ * @param aName DOCUMENT ME!
+ */
public Application(String aName) {
this(aName, "");
}
+ /**
+ * Creates a new Application object.
+ *
+ * @param aName DOCUMENT ME!
+ * @param aPrefix DOCUMENT ME!
+ */
public Application(String aName, String aPrefix) {
- super(aName, new ProvidedInterface[0], required(false,
- aPrefix));
- _random = Math.random();
+ super(aName, new ProvidedInterface[0], required(false, aPrefix));
+ random = Math.random();
}
+ /**
+ * Creates a new Application object.
+ *
+ * @param aIsOptinal DOCUMENT ME!
+ */
public Application(boolean aIsOptinal) {
super("application", new ProvidedInterface[0], required(true, ""));
}
+ /**
+ * Creates a new Application object.
+ *
+ * @param aTracker DOCUMENT ME!
+ */
public Application(EventTracker<String> aTracker) {
this();
- _tracker = aTracker;
+ tracker = aTracker;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param aOptional DOCUMENT ME!
+ * @param aPrefix DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public static RequiredInterface[] required(boolean aOptional, String aPrefix) {
+ return new RequiredInterface[] {
+ new DefaultRequiredInterface(aPrefix + "string", String.class,
+ aOptional),
+ new DefaultRequiredInterface(aPrefix + "integer", Integer.class,
+ aOptional)
+ };
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param aOptional DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
+ public static RequiredInterface[] required(boolean aOptional) {
+ return required(aOptional, "");
+ }
+
+ /**
+ * DOCUMENT ME!
+ *
+ * @param aScope DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
@Override
public Object doStart(Scope aScope) {
track("start." + getName());
- _string = aScope.getInterfaceImplementation(getRequiredInterfaces()
+ string = aScope.getInterfaceImplementation(getRequiredInterfaces()
.get(0).getProvider(), String.class);
- _integer = aScope.getInterfaceImplementation(getRequiredInterfaces()
+ integer = aScope.getInterfaceImplementation(getRequiredInterfaces()
.get(1).getProvider(), Integer.class);
- return _random;
+
+ return random;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public String getString() {
- return _string;
+ return string;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @return DOCUMENT ME!
+ */
public Integer getInteger() {
- return _integer;
+ return integer;
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param aRuntime DOCUMENT ME!
+ */
@Override
public void doStop(Object aRuntime) {
track("stop." + getName());
- if (_random != (Double) aRuntime) {
+
+ if (random != (Double) aRuntime) {
throw new IllegalArgumentException("Wrong runtime: expected "
- + _random + " but got " + aRuntime);
+ + random + " but got " + aRuntime);
}
}
+ /**
+ * DOCUMENT ME!
+ *
+ * @param aString DOCUMENT ME!
+ */
private void track(String aString) {
- if (_tracker == null) {
+ if (tracker == null) {
return;
}
- _tracker.eventOccurred(aString);
+
+ tracker.eventOccurred(aString);
}
}