diff --git a/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageService.java b/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageService.java index 8c3618db8..f7a197326 100644 --- a/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageService.java +++ b/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageService.java @@ -31,7 +31,8 @@ import org.apache.isis.applib.annotation.NatureOfService; import org.apache.isis.applib.annotation.SemanticsOf; /** - * HomePage Domain Service + * HomePage Domain Service. + * * @see HomePageViewModel linked view to HomePage */ @DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY) diff --git a/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.java b/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.java index 9d845cbd6..d37879352 100644 --- a/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.java +++ b/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.java @@ -23,16 +23,14 @@ package domainapp.dom.app.homepage; -import java.util.List; - -import org.apache.isis.applib.annotation.ViewModel; - import domainapp.dom.modules.simple.SimpleObject; import domainapp.dom.modules.simple.SimpleObjects; +import java.util.List; +import org.apache.isis.applib.annotation.ViewModel; /** - * Model linked to the HomePage - * The underlying layout is specified by json + * Model linked to the HomePage The underlying layout is specified by json. + * * @see HomePageService - Service Linked to the HomePage */ @ViewModel diff --git a/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.layout.json b/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.layout.json index 34f78e0c3..638473eee 100644 --- a/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.layout.json +++ b/naked-objects/dom/src/main/java/domainapp/dom/app/homepage/HomePageViewModel.layout.json @@ -15,29 +15,29 @@ * limitations under the License. */ { - "columns": [ - { - "span": 0, - "memberGroups": {} - }, - { - "span": 0, - "memberGroups": {} - }, - { - "span": 0, - "memberGroups": {} - }, - { - "span": 12, - "collections": { - "objects": { - "collectionLayout": { - "render": "EAGERLY" - } - } - } + "columns": [ + { + "span": 0, + "memberGroups": {} + }, + { + "span": 0, + "memberGroups": {} + }, + { + "span": 0, + "memberGroups": {} + }, + { + "span": 12, + "collections": { + "objects": { + "collectionLayout": { + "render": "EAGERLY" + } } - ], - "actions": {} + } + } + ], + "actions": {} } \ No newline at end of file diff --git a/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.java b/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.java index 329c4c138..809da6d31 100644 --- a/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.java +++ b/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.java @@ -26,7 +26,6 @@ package domainapp.dom.modules.simple; import javax.jdo.JDOHelper; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.VersionStrategy; - import org.apache.isis.applib.DomainObjectContainer; import org.apache.isis.applib.Identifier; import org.apache.isis.applib.annotation.Action; @@ -43,7 +42,7 @@ import org.apache.isis.applib.services.i18n.TranslatableString; import org.apache.isis.applib.util.ObjectContracts; /** - * Definition of a Simple Object + * Definition of a Simple Object. */ @javax.jdo.annotations.PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "simple", table = "SimpleObject") @@ -87,11 +86,11 @@ public class SimpleObject implements Comparable { // region > updateName (action) /** - * Event used to update the Name in the Domain + * Event used to update the Name in the Domain. */ public static class UpdateNameDomainEvent extends ActionDomainEvent { public UpdateNameDomainEvent(final SimpleObject source, final Identifier identifier, - final Object... arguments) { + final Object... arguments) { super(source, identifier, arguments); } } diff --git a/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.layout.json b/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.layout.json index 3d5e23f7c..78b2ac096 100644 --- a/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.layout.json +++ b/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObject.layout.json @@ -15,42 +15,42 @@ * limitations under the License. */ { - "columns": [ - { - "span": 6, - "memberGroups": { - "General": { - "members": { - "name": { - "actions": { - "updateName": { - "actionLayout": { - "position": "BOTTOM" - } - } - } - }, - "versionSequence": { - "propertyLayout": { - "name": "version" - } - } - } + "columns": [ + { + "span": 6, + "memberGroups": { + "General": { + "members": { + "name": { + "actions": { + "updateName": { + "actionLayout": { + "position": "BOTTOM" + } } + } + }, + "versionSequence": { + "propertyLayout": { + "name": "version" + } } - }, - { - "span": 0, - "memberGroups": {} - }, - { - "span": 0, - "memberGroups": {} - }, - { - "span": 6, - "collections": {} + } } - ], - "actions": {} + } + }, + { + "span": 0, + "memberGroups": {} + }, + { + "span": 0, + "memberGroups": {} + }, + { + "span": 6, + "collections": {} + } + ], + "actions": {} } \ No newline at end of file diff --git a/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObjects.java b/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObjects.java index 506bda597..88a4666e0 100644 --- a/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObjects.java +++ b/naked-objects/dom/src/main/java/domainapp/dom/modules/simple/SimpleObjects.java @@ -24,7 +24,6 @@ package domainapp.dom.modules.simple; import java.util.List; - import org.apache.isis.applib.DomainObjectContainer; import org.apache.isis.applib.Identifier; import org.apache.isis.applib.annotation.Action; @@ -40,7 +39,7 @@ import org.apache.isis.applib.services.eventbus.ActionDomainEvent; import org.apache.isis.applib.services.i18n.TranslatableString; /** - * Domain Service for Simple Objects + * Domain Service for Simple Objects. */ @DomainService(repositoryFor = SimpleObject.class) @DomainServiceLayout(menuOrder = "10") @@ -82,18 +81,18 @@ public class SimpleObjects { // endregion /** - * Create Domain Event on SimpleObjects + * Create Domain Event on SimpleObjects. */ // region > create (action) public static class CreateDomainEvent extends ActionDomainEvent { public CreateDomainEvent(final SimpleObjects source, final Identifier identifier, - final Object... arguments) { + final Object... arguments) { super(source, identifier, arguments); } } /** - * Create simple object + * Create simple object. */ @Action(domainEvent = CreateDomainEvent.class) @MemberOrder(sequence = "3") diff --git a/naked-objects/fixture/src/main/java/domainapp/fixture/DomainAppFixturesProvider.java b/naked-objects/fixture/src/main/java/domainapp/fixture/DomainAppFixturesProvider.java index 7a7e8c4b7..d7da56858 100644 --- a/naked-objects/fixture/src/main/java/domainapp/fixture/DomainAppFixturesProvider.java +++ b/naked-objects/fixture/src/main/java/domainapp/fixture/DomainAppFixturesProvider.java @@ -23,14 +23,13 @@ package domainapp.fixture; +import domainapp.fixture.scenarios.RecreateSimpleObjects; import org.apache.isis.applib.annotation.DomainService; import org.apache.isis.applib.annotation.NatureOfService; import org.apache.isis.applib.fixturescripts.FixtureScripts; import org.apache.isis.applib.services.fixturespec.FixtureScriptsSpecification; import org.apache.isis.applib.services.fixturespec.FixtureScriptsSpecificationProvider; -import domainapp.fixture.scenarios.RecreateSimpleObjects; - /** * Specifies where to find fixtures, and other settings. */ diff --git a/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectCreate.java b/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectCreate.java index 4de9bfc9c..dc19195ac 100644 --- a/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectCreate.java +++ b/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectCreate.java @@ -23,13 +23,12 @@ package domainapp.fixture.modules.simple; -import org.apache.isis.applib.fixturescripts.FixtureScript; - import domainapp.dom.modules.simple.SimpleObject; import domainapp.dom.modules.simple.SimpleObjects; +import org.apache.isis.applib.fixturescripts.FixtureScript; /** - * Fixture to create a simple object + * Fixture to create a simple object. */ public class SimpleObjectCreate extends FixtureScript { @@ -46,7 +45,7 @@ public class SimpleObjectCreate extends FixtureScript { private String name; /** - * Name of the object (required) + * Name of the object (required). */ public String getName() { return name; diff --git a/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectsTearDown.java b/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectsTearDown.java index 8fc54d0ad..b3cea73c4 100644 --- a/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectsTearDown.java +++ b/naked-objects/fixture/src/main/java/domainapp/fixture/modules/simple/SimpleObjectsTearDown.java @@ -27,7 +27,7 @@ import org.apache.isis.applib.fixturescripts.FixtureScript; import org.apache.isis.applib.services.jdosupport.IsisJdoSupport; /** - * TearDown/Cleanup for SimpleObjects + * TearDown/Cleanup for SimpleObjects. */ public class SimpleObjectsTearDown extends FixtureScript { diff --git a/naked-objects/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java b/naked-objects/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java index 303dfda4f..847f15d01 100644 --- a/naked-objects/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java +++ b/naked-objects/fixture/src/main/java/domainapp/fixture/scenarios/RecreateSimpleObjects.java @@ -27,19 +27,18 @@ import com.google.common.collect.Lists; import domainapp.dom.modules.simple.SimpleObject; import domainapp.fixture.modules.simple.SimpleObjectCreate; import domainapp.fixture.modules.simple.SimpleObjectsTearDown; -import org.apache.isis.applib.fixturescripts.FixtureScript; - import java.util.Collections; import java.util.List; +import org.apache.isis.applib.fixturescripts.FixtureScript; /** - * Create a bunch of simple Objects + * Create a bunch of simple Objects. */ public class RecreateSimpleObjects extends FixtureScript { public final List names = Collections.unmodifiableList(List.of("Foo", "Bar", "Baz", - "Frodo", "Froyo", "Fizz", "Bip", "Bop", "Bang", "Boo")); + "Frodo", "Froyo", "Fizz", "Bip", "Bop", "Bang", "Boo")); // region > number (optional input) private Integer number; diff --git a/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java b/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java index 649aea7fd..8425712dc 100644 --- a/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java +++ b/naked-objects/webapp/src/main/java/domainapp/webapp/SimpleApplication.java @@ -23,13 +23,6 @@ package domainapp.webapp; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - import com.google.common.base.Joiner; import com.google.common.io.Resources; import com.google.inject.AbstractModule; @@ -37,30 +30,31 @@ import com.google.inject.Module; import com.google.inject.name.Names; import com.google.inject.util.Modules; import com.google.inject.util.Providers; - +import de.agilecoders.wicket.core.Bootstrap; +import de.agilecoders.wicket.core.settings.IBootstrapSettings; +import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchTheme; +import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchThemeProvider; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import org.apache.isis.viewer.wicket.viewer.IsisWicketApplication; +import org.apache.isis.viewer.wicket.viewer.integration.wicket.AuthenticatedWebSessionForIsis; import org.apache.wicket.Session; import org.apache.wicket.request.IRequestParameters; import org.apache.wicket.request.Request; import org.apache.wicket.request.Response; import org.apache.wicket.request.http.WebRequest; - -import org.apache.isis.viewer.wicket.viewer.IsisWicketApplication; -import org.apache.isis.viewer.wicket.viewer.integration.wicket.AuthenticatedWebSessionForIsis; - -import de.agilecoders.wicket.core.Bootstrap; -import de.agilecoders.wicket.core.settings.IBootstrapSettings; -import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchTheme; -import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchThemeProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * As specified in web.xml. - * - *

- * See: - * + * + *

See: + * *

  * <filter>
  *   <filter-name>wicket</filter-name>
@@ -71,7 +65,6 @@ import org.slf4j.LoggerFactory;
  *    </init-param>
  * </filter>
  * 
- * */ public class SimpleApplication extends IsisWicketApplication { @@ -80,11 +73,10 @@ public class SimpleApplication extends IsisWicketApplication { /** * uncomment for a (slightly hacky) way of allowing logins using query args, eg: - * + * * {@code ?user=sven&pass=pass} - * - *

- * for demos only, obvious. + * + *

for demos only, obvious. */ private static final boolean DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS = false; diff --git a/null-object/src/main/java/com/iluwatar/nullobject/App.java b/null-object/src/main/java/com/iluwatar/nullobject/App.java index 9e5a1412b..2826bafd0 100644 --- a/null-object/src/main/java/com/iluwatar/nullobject/App.java +++ b/null-object/src/main/java/com/iluwatar/nullobject/App.java @@ -24,18 +24,16 @@ package com.iluwatar.nullobject; /** - * * Null Object pattern replaces null values with neutral objects. Many times this simplifies * algorithms since no extra null checks are needed. - *

- * In this example we build a binary tree where the nodes are either normal or Null Objects. No null - * values are used in the tree making the traversal easy. * + *

In this example we build a binary tree where the nodes are either normal or Null Objects. No + * null values are used in the tree making the traversal easy. */ public class App { /** - * Program entry point - * + * Program entry point. + * * @param args command line args */ public static void main(String[] args) { @@ -44,7 +42,7 @@ public class App { new NodeImpl("1", new NodeImpl("11", new NodeImpl("111", NullNode.getInstance(), NullNode.getInstance()), NullNode.getInstance()), new NodeImpl("12", NullNode.getInstance(), new NodeImpl("122", NullNode.getInstance(), - NullNode.getInstance()))); + NullNode.getInstance()))); root.walk(); } diff --git a/null-object/src/main/java/com/iluwatar/nullobject/Node.java b/null-object/src/main/java/com/iluwatar/nullobject/Node.java index 61423778c..2abd4c304 100644 --- a/null-object/src/main/java/com/iluwatar/nullobject/Node.java +++ b/null-object/src/main/java/com/iluwatar/nullobject/Node.java @@ -24,9 +24,7 @@ package com.iluwatar.nullobject; /** - * * Interface for binary tree node. - * */ public interface Node { diff --git a/null-object/src/main/java/com/iluwatar/nullobject/NodeImpl.java b/null-object/src/main/java/com/iluwatar/nullobject/NodeImpl.java index c44c26fb9..41a3fe60b 100644 --- a/null-object/src/main/java/com/iluwatar/nullobject/NodeImpl.java +++ b/null-object/src/main/java/com/iluwatar/nullobject/NodeImpl.java @@ -27,9 +27,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * * Implementation for binary tree's normal nodes. - * */ public class NodeImpl implements Node { @@ -40,7 +38,7 @@ public class NodeImpl implements Node { private final Node right; /** - * Constructor + * Constructor. */ public NodeImpl(String name, Node left, Node right) { this.name = name; diff --git a/null-object/src/main/java/com/iluwatar/nullobject/NullNode.java b/null-object/src/main/java/com/iluwatar/nullobject/NullNode.java index c5085b03d..9b28c249b 100644 --- a/null-object/src/main/java/com/iluwatar/nullobject/NullNode.java +++ b/null-object/src/main/java/com/iluwatar/nullobject/NullNode.java @@ -24,17 +24,16 @@ package com.iluwatar.nullobject; /** - * * Null Object implementation for binary tree node. - *

- * Implemented as Singleton, since all the NullNodes are the same. * + *

Implemented as Singleton, since all the NullNodes are the same. */ public final class NullNode implements Node { private static NullNode instance = new NullNode(); - private NullNode() {} + private NullNode() { + } public static NullNode getInstance() { return instance; diff --git a/object-mother/src/main/java/com/iluwatar/objectmother/King.java b/object-mother/src/main/java/com/iluwatar/objectmother/King.java index cfebd2590..314d152fd 100644 --- a/object-mother/src/main/java/com/iluwatar/objectmother/King.java +++ b/object-mother/src/main/java/com/iluwatar/objectmother/King.java @@ -24,7 +24,7 @@ package com.iluwatar.objectmother; /** - * Defines all attributes and behaviour related to the King + * Defines all attributes and behaviour related to the King. */ public class King implements Royalty { boolean isDrunk = false; @@ -56,6 +56,7 @@ public class King implements Royalty { /** * Method to flirt to a queen. + * * @param queen Queen which should be flirted. */ public void flirt(Queen queen) { diff --git a/object-mother/src/main/java/com/iluwatar/objectmother/Queen.java b/object-mother/src/main/java/com/iluwatar/objectmother/Queen.java index 98a41a960..4c704f6b1 100644 --- a/object-mother/src/main/java/com/iluwatar/objectmother/Queen.java +++ b/object-mother/src/main/java/com/iluwatar/objectmother/Queen.java @@ -24,7 +24,7 @@ package com.iluwatar.objectmother; /** - * Defines all attributes and behaviour related to the Queen + * Defines all attributes and behaviour related to the Queen. */ public class Queen implements Royalty { private boolean isDrunk = false; @@ -61,6 +61,7 @@ public class Queen implements Royalty { /** * Method which is called when the king is flirting to a queen. + * * @param king King who initialized the flirt. * @return A value which describes if the flirt was successful or not. */ diff --git a/object-mother/src/main/java/com/iluwatar/objectmother/Royalty.java b/object-mother/src/main/java/com/iluwatar/objectmother/Royalty.java index 9abbbe75b..892a6301c 100644 --- a/object-mother/src/main/java/com/iluwatar/objectmother/Royalty.java +++ b/object-mother/src/main/java/com/iluwatar/objectmother/Royalty.java @@ -24,7 +24,7 @@ package com.iluwatar.objectmother; /** - * Interface contracting Royalty Behaviour + * Interface contracting Royalty Behaviour. */ public interface Royalty { void makeDrunk(); diff --git a/object-mother/src/main/java/com/iluwatar/objectmother/RoyaltyObjectMother.java b/object-mother/src/main/java/com/iluwatar/objectmother/RoyaltyObjectMother.java index 372f1166c..5650e5f48 100644 --- a/object-mother/src/main/java/com/iluwatar/objectmother/RoyaltyObjectMother.java +++ b/object-mother/src/main/java/com/iluwatar/objectmother/RoyaltyObjectMother.java @@ -24,12 +24,13 @@ package com.iluwatar.objectmother; /** - * Object Mother Pattern generating Royalty Types + * Object Mother Pattern generating Royalty Types. */ public final class RoyaltyObjectMother { /** * Method to create a sober and unhappy king. The standard parameters are set. + * * @return An instance of {@link com.iluwatar.objectmother.King} with the standard properties. */ public static King createSoberUnhappyKing() { @@ -38,6 +39,7 @@ public final class RoyaltyObjectMother { /** * Method of the object mother to create a drunk king. + * * @return A drunk {@link com.iluwatar.objectmother.King}. */ public static King createDrunkKing() { @@ -48,6 +50,7 @@ public final class RoyaltyObjectMother { /** * Method to create a happy king. + * * @return A happy {@link com.iluwatar.objectmother.King}. */ public static King createHappyKing() { @@ -58,6 +61,7 @@ public final class RoyaltyObjectMother { /** * Method to create a happy and drunk king. + * * @return A drunk and happy {@link com.iluwatar.objectmother.King}. */ public static King createHappyDrunkKing() { @@ -69,6 +73,7 @@ public final class RoyaltyObjectMother { /** * Method to create a flirty queen. + * * @return A flirty {@link com.iluwatar.objectmother.Queen}. */ public static Queen createFlirtyQueen() { @@ -79,6 +84,7 @@ public final class RoyaltyObjectMother { /** * Method to create a not flirty queen. + * * @return A not flirty {@link com.iluwatar.objectmother.Queen}. */ public static Queen createNotFlirtyQueen() { diff --git a/object-pool/src/main/java/com/iluwatar/object/pool/App.java b/object-pool/src/main/java/com/iluwatar/object/pool/App.java index 24923c1e9..3c1774fac 100644 --- a/object-pool/src/main/java/com/iluwatar/object/pool/App.java +++ b/object-pool/src/main/java/com/iluwatar/object/pool/App.java @@ -27,32 +27,30 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * * When it is necessary to work with a large number of objects that are particularly expensive to * instantiate and each object is only needed for a short period of time, the performance of an * entire application may be adversely affected. An object pool design pattern may be deemed * desirable in cases such as these. - *

- * The object pool design pattern creates a set of objects that may be reused. When a new object is - * needed, it is requested from the pool. If a previously prepared object is available it is + * + *

The object pool design pattern creates a set of objects that may be reused. When a new object + * is needed, it is requested from the pool. If a previously prepared object is available it is * returned immediately, avoiding the instantiation cost. If no objects are present in the pool, a * new item is created and returned. When the object has been used and is no longer needed, it is * returned to the pool, allowing it to be used again in the future without repeating the * computationally expensive instantiation process. It is important to note that once an object has * been used and returned, existing references will become invalid. - *

- * In this example we have created {@link OliphauntPool} inheriting from generic {@link ObjectPool}. - * {@link Oliphaunt}s can be checked out from the pool and later returned to it. The pool tracks - * created instances and their status (available, inUse). * + *

In this example we have created {@link OliphauntPool} inheriting from generic {@link + * ObjectPool}. {@link Oliphaunt}s can be checked out from the pool and later returned to it. The + * pool tracks created instances and their status (available, inUse). */ public class App { private static final Logger LOGGER = LoggerFactory.getLogger(App.class); /** - * Program entry point - * + * Program entry point. + * * @param args command line args */ public static void main(String[] args) { diff --git a/object-pool/src/main/java/com/iluwatar/object/pool/ObjectPool.java b/object-pool/src/main/java/com/iluwatar/object/pool/ObjectPool.java index e71e97f16..37009d44b 100644 --- a/object-pool/src/main/java/com/iluwatar/object/pool/ObjectPool.java +++ b/object-pool/src/main/java/com/iluwatar/object/pool/ObjectPool.java @@ -27,7 +27,8 @@ import java.util.HashSet; import java.util.Set; /** - * Generic object pool + * Generic object pool. + * * @param Type T of Object in the Pool */ public abstract class ObjectPool { @@ -38,7 +39,7 @@ public abstract class ObjectPool { protected abstract T create(); /** - * Checkout object from pool + * Checkout object from pool. */ public synchronized T checkOut() { if (available.isEmpty()) { diff --git a/object-pool/src/main/java/com/iluwatar/object/pool/Oliphaunt.java b/object-pool/src/main/java/com/iluwatar/object/pool/Oliphaunt.java index 0d9f85adc..42db07158 100644 --- a/object-pool/src/main/java/com/iluwatar/object/pool/Oliphaunt.java +++ b/object-pool/src/main/java/com/iluwatar/object/pool/Oliphaunt.java @@ -26,9 +26,7 @@ package com.iluwatar.object.pool; import java.util.concurrent.atomic.AtomicInteger; /** - * - * Oliphaunts are expensive to create - * + * Oliphaunts are expensive to create. */ public class Oliphaunt { @@ -37,7 +35,7 @@ public class Oliphaunt { private final int id; /** - * Constructor + * Constructor. */ public Oliphaunt() { id = counter.incrementAndGet(); diff --git a/object-pool/src/main/java/com/iluwatar/object/pool/OliphauntPool.java b/object-pool/src/main/java/com/iluwatar/object/pool/OliphauntPool.java index b2d92936f..8c038ce26 100644 --- a/object-pool/src/main/java/com/iluwatar/object/pool/OliphauntPool.java +++ b/object-pool/src/main/java/com/iluwatar/object/pool/OliphauntPool.java @@ -24,9 +24,7 @@ package com.iluwatar.object.pool; /** - * - * Oliphaunt object pool - * + * Oliphaunt object pool. */ public class OliphauntPool extends ObjectPool { diff --git a/observer/src/main/java/com/iluwatar/observer/App.java b/observer/src/main/java/com/iluwatar/observer/App.java index 07321ea6b..d0994b65c 100644 --- a/observer/src/main/java/com/iluwatar/observer/App.java +++ b/observer/src/main/java/com/iluwatar/observer/App.java @@ -30,25 +30,23 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * * The Observer pattern is a software design pattern in which an object, called the subject, * maintains a list of its dependents, called observers, and notifies them automatically of any * state changes, usually by calling one of their methods. It is mainly used to implement * distributed event handling systems. The Observer pattern is also a key part in the familiar * model–view–controller (MVC) architectural pattern. The Observer pattern is implemented in * numerous programming libraries and systems, including almost all GUI toolkits. - *

- * In this example {@link Weather} has a state that can be observed. The {@link Orcs} and - * {@link Hobbits} register as observers and receive notifications when the {@link Weather} changes. - * + * + *

In this example {@link Weather} has a state that can be observed. The {@link Orcs} and {@link + * Hobbits} register as observers and receive notifications when the {@link Weather} changes. */ public class App { private static final Logger LOGGER = LoggerFactory.getLogger(App.class); /** - * Program entry point - * + * Program entry point. + * * @param args command line args */ public static void main(String[] args) { @@ -64,13 +62,13 @@ public class App { // Generic observer inspired by Java Generics and Collection by Naftalin & Wadler LOGGER.info("--Running generic version--"); - GWeather gWeather = new GWeather(); - gWeather.addObserver(new GOrcs()); - gWeather.addObserver(new GHobbits()); + GWeather genericWeather = new GWeather(); + genericWeather.addObserver(new GOrcs()); + genericWeather.addObserver(new GHobbits()); - gWeather.timePasses(); - gWeather.timePasses(); - gWeather.timePasses(); - gWeather.timePasses(); + genericWeather.timePasses(); + genericWeather.timePasses(); + genericWeather.timePasses(); + genericWeather.timePasses(); } } diff --git a/observer/src/main/java/com/iluwatar/observer/Hobbits.java b/observer/src/main/java/com/iluwatar/observer/Hobbits.java index b718aa5e8..646ceebfd 100644 --- a/observer/src/main/java/com/iluwatar/observer/Hobbits.java +++ b/observer/src/main/java/com/iluwatar/observer/Hobbits.java @@ -27,9 +27,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * - * Hobbits - * + * Hobbits. */ public class Hobbits implements WeatherObserver { diff --git a/observer/src/main/java/com/iluwatar/observer/Orcs.java b/observer/src/main/java/com/iluwatar/observer/Orcs.java index 1420c7da7..a28ffbc5b 100644 --- a/observer/src/main/java/com/iluwatar/observer/Orcs.java +++ b/observer/src/main/java/com/iluwatar/observer/Orcs.java @@ -27,9 +27,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * - * Orcs - * + * Orcs. */ public class Orcs implements WeatherObserver { diff --git a/observer/src/main/java/com/iluwatar/observer/Weather.java b/observer/src/main/java/com/iluwatar/observer/Weather.java index b5f6d2e39..3369e8f63 100644 --- a/observer/src/main/java/com/iluwatar/observer/Weather.java +++ b/observer/src/main/java/com/iluwatar/observer/Weather.java @@ -23,17 +23,14 @@ package com.iluwatar.observer; +import java.util.ArrayList; +import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; - /** - * * Weather can be observed by implementing {@link WeatherObserver} interface and registering as * listener. - * */ public class Weather { @@ -56,7 +53,7 @@ public class Weather { } /** - * Makes time pass for weather + * Makes time pass for weather. */ public void timePasses() { WeatherType[] enumValues = WeatherType.values(); diff --git a/observer/src/main/java/com/iluwatar/observer/WeatherObserver.java b/observer/src/main/java/com/iluwatar/observer/WeatherObserver.java index deb4c15ed..53f331174 100644 --- a/observer/src/main/java/com/iluwatar/observer/WeatherObserver.java +++ b/observer/src/main/java/com/iluwatar/observer/WeatherObserver.java @@ -24,9 +24,7 @@ package com.iluwatar.observer; /** - * * Observer interface. - * */ public interface WeatherObserver { diff --git a/observer/src/main/java/com/iluwatar/observer/WeatherType.java b/observer/src/main/java/com/iluwatar/observer/WeatherType.java index 384f8ac58..75ee17d60 100644 --- a/observer/src/main/java/com/iluwatar/observer/WeatherType.java +++ b/observer/src/main/java/com/iluwatar/observer/WeatherType.java @@ -24,9 +24,7 @@ package com.iluwatar.observer; /** - * - * WeatherType enumeration - * + * WeatherType enumeration. */ public enum WeatherType { diff --git a/observer/src/main/java/com/iluwatar/observer/generic/GHobbits.java b/observer/src/main/java/com/iluwatar/observer/generic/GHobbits.java index 79669ef48..7a555d850 100644 --- a/observer/src/main/java/com/iluwatar/observer/generic/GHobbits.java +++ b/observer/src/main/java/com/iluwatar/observer/generic/GHobbits.java @@ -28,9 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * - * GHobbits - * + * GHobbits. */ public class GHobbits implements Race { diff --git a/observer/src/main/java/com/iluwatar/observer/generic/GOrcs.java b/observer/src/main/java/com/iluwatar/observer/generic/GOrcs.java index 5ba85b17f..d9adbf116 100644 --- a/observer/src/main/java/com/iluwatar/observer/generic/GOrcs.java +++ b/observer/src/main/java/com/iluwatar/observer/generic/GOrcs.java @@ -28,9 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * - * GOrcs - * + * GOrcs. */ public class GOrcs implements Race { diff --git a/observer/src/main/java/com/iluwatar/observer/generic/GWeather.java b/observer/src/main/java/com/iluwatar/observer/generic/GWeather.java index 3bf52f46b..13ba25534 100644 --- a/observer/src/main/java/com/iluwatar/observer/generic/GWeather.java +++ b/observer/src/main/java/com/iluwatar/observer/generic/GWeather.java @@ -28,9 +28,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * - * GWeather - * + * GWeather. */ public class GWeather extends Observable { @@ -43,7 +41,7 @@ public class GWeather extends Observable { } /** - * Makes time pass for weather + * Makes time pass for weather. */ public void timePasses() { WeatherType[] enumValues = WeatherType.values(); diff --git a/observer/src/main/java/com/iluwatar/observer/generic/Observable.java b/observer/src/main/java/com/iluwatar/observer/generic/Observable.java index 722915b92..29d350154 100644 --- a/observer/src/main/java/com/iluwatar/observer/generic/Observable.java +++ b/observer/src/main/java/com/iluwatar/observer/generic/Observable.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; /** - * Generic observer inspired by Java Generics and Collection by {@literal Naftalin & Wadler} + * Generic observer inspired by Java Generics and Collection by {@literal Naftalin & Wadler}. * * @param Subject * @param Observer @@ -50,7 +50,7 @@ public abstract class Observable, O extends Observ } /** - * Notify observers + * Notify observers. */ @SuppressWarnings("unchecked") public void notifyObservers(A argument) { diff --git a/observer/src/main/java/com/iluwatar/observer/generic/Observer.java b/observer/src/main/java/com/iluwatar/observer/generic/Observer.java index 819068b6e..043e4dbb0 100644 --- a/observer/src/main/java/com/iluwatar/observer/generic/Observer.java +++ b/observer/src/main/java/com/iluwatar/observer/generic/Observer.java @@ -24,7 +24,8 @@ package com.iluwatar.observer.generic; /** - * Observer + * Observer. + * * @param Observable * @param Observer * @param Action diff --git a/observer/src/main/java/com/iluwatar/observer/generic/Race.java b/observer/src/main/java/com/iluwatar/observer/generic/Race.java index 1cd3aa4a6..a6fc0a2a4 100644 --- a/observer/src/main/java/com/iluwatar/observer/generic/Race.java +++ b/observer/src/main/java/com/iluwatar/observer/generic/Race.java @@ -26,9 +26,7 @@ package com.iluwatar.observer.generic; import com.iluwatar.observer.WeatherType; /** - * - * Race - * + * Race. */ public interface Race extends Observer { } diff --git a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/App.java b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/App.java index 80fdc9462..ba7aac954 100644 --- a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/App.java +++ b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/App.java @@ -26,69 +26,69 @@ package com.iluwatar.queue.load.leveling; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * - * Many solutions in the cloud involve running tasks that invoke services. In this environment, - * if a service is subjected to intermittent heavy loads, it can cause performance or reliability issues. - *

- * A service could be a component that is part of the same solution as the tasks that utilize it, or it - * could be a third-party service providing access to frequently used resources such as a cache or a storage service. - * If the same service is utilized by a number of tasks running concurrently, it can be difficult to predict the - * volume of requests to which the service might be subjected at any given point in time. - *

- * We will build a queue-based-load-leveling to solve above problem. - * Refactor the solution and introduce a queue between the task and the service. - * The task and the service run asynchronously. The task posts a message containing the data required - * by the service to a queue. The queue acts as a buffer, storing the message until it is retrieved - * by the service. The service retrieves the messages from the queue and processes them. - * Requests from a number of tasks, which can be generated at a highly variable rate, can be passed - * to the service through the same message queue. - *

- * The queue effectively decouples the tasks from the service, and the service can handle the messages - * at its own pace irrespective of the volume of requests from concurrent tasks. Additionally, - * there is no delay to a task if the service is not available at the time it posts a message to the queue. - *

- * In this example we have a class {@link MessageQueue} to hold the message {@link Message} objects. - * All the worker threads {@link TaskGenerator} will submit the messages to the MessageQueue. - * The service executor class {@link ServiceExecutor} will pick up one task at a time from the Queue and - * execute them. - * + * Many solutions in the cloud involve running tasks that invoke services. In this environment, if a + * service is subjected to intermittent heavy loads, it can cause performance or reliability + * issues. + * + *

A service could be a component that is part of the same solution as the tasks that utilize + * it, or it could be a third-party service providing access to frequently used resources such as a + * cache or a storage service. If the same service is utilized by a number of tasks running + * concurrently, it can be difficult to predict the volume of requests to which the service might be + * subjected at any given point in time. + * + *

We will build a queue-based-load-leveling to solve above problem. Refactor the solution and + * introduce a queue between the task and the service. The task and the service run asynchronously. + * The task posts a message containing the data required by the service to a queue. The queue acts + * as a buffer, storing the message until it is retrieved by the service. The service retrieves the + * messages from the queue and processes them. Requests from a number of tasks, which can be + * generated at a highly variable rate, can be passed to the service through the same message + * queue. + * + *

The queue effectively decouples the tasks from the service, and the service can handle the + * messages at its own pace irrespective of the volume of requests from concurrent tasks. + * Additionally, there is no delay to a task if the service is not available at the time it posts a + * message to the queue. + * + *

In this example we have a class {@link MessageQueue} to hold the message {@link Message} + * objects. All the worker threads {@link TaskGenerator} will submit the messages to the + * MessageQueue. The service executor class {@link ServiceExecutor} will pick up one task at a time + * from the Queue and execute them. */ public class App { - + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); - + //Executor shut down time limit. private static final int SHUTDOWN_TIME = 15; - + /** - * Program entry point - * + * Program entry point. + * * @param args command line args */ public static void main(String[] args) { - + // An Executor that provides methods to manage termination and methods that can // produce a Future for tracking progress of one or more asynchronous tasks. ExecutorService executor = null; - + try { // Create a MessageQueue object. MessageQueue msgQueue = new MessageQueue(); - + LOGGER.info("Submitting TaskGenerators and ServiceExecutor threads."); - + // Create three TaskGenerator threads. Each of them will submit different number of jobs. - Runnable taskRunnable1 = new TaskGenerator(msgQueue, 5); - Runnable taskRunnable2 = new TaskGenerator(msgQueue, 1); - Runnable taskRunnable3 = new TaskGenerator(msgQueue, 2); - + final Runnable taskRunnable1 = new TaskGenerator(msgQueue, 5); + final Runnable taskRunnable2 = new TaskGenerator(msgQueue, 1); + final Runnable taskRunnable3 = new TaskGenerator(msgQueue, 2); + // Create e service which should process the submitted jobs. - Runnable srvRunnable = new ServiceExecutor(msgQueue); + final Runnable srvRunnable = new ServiceExecutor(msgQueue); // Create a ThreadPool of 2 threads and // submit all Runnable task for execution to executor.. @@ -96,17 +96,18 @@ public class App { executor.submit(taskRunnable1); executor.submit(taskRunnable2); executor.submit(taskRunnable3); - + // submitting serviceExecutor thread to the Executor service. executor.submit(srvRunnable); - + // Initiates an orderly shutdown. - LOGGER.info("Intiating shutdown. Executor will shutdown only after all the Threads are completed."); + LOGGER.info("Initiating shutdown." + + " Executor will shutdown only after all the Threads are completed."); executor.shutdown(); - + // Wait for SHUTDOWN_TIME seconds for all the threads to complete // their tasks and then shut down the executor and then exit. - if ( !executor.awaitTermination(SHUTDOWN_TIME, TimeUnit.SECONDS) ) { + if (!executor.awaitTermination(SHUTDOWN_TIME, TimeUnit.SECONDS)) { LOGGER.info("Executor was shut down and Exiting."); executor.shutdownNow(); } diff --git a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/Message.java b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/Message.java index 432d1fe40..686737389 100644 --- a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/Message.java +++ b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/Message.java @@ -24,12 +24,11 @@ package com.iluwatar.queue.load.leveling; /** - * Message class with only one parameter. - * -*/ + * Message class with only one parameter. + */ public class Message { private final String msg; - + // Parameter constructor. public Message(String msg) { this.msg = msg; @@ -39,7 +38,7 @@ public class Message { public String getMsg() { return msg; } - + @Override public String toString() { return msg; diff --git a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/MessageQueue.java b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/MessageQueue.java index b6059471f..6d55d026b 100644 --- a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/MessageQueue.java +++ b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/MessageQueue.java @@ -25,30 +25,27 @@ package com.iluwatar.queue.load.leveling; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * - * MessageQueue class. - * In this class we will create a Blocking Queue and - * submit/retrieve all the messages from it. + * MessageQueue class. In this class we will create a Blocking Queue and submit/retrieve all the + * messages from it. */ public class MessageQueue { - + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); - + private final BlockingQueue blkQueue; - + // Default constructor when called creates Blocking Queue object. public MessageQueue() { this.blkQueue = new ArrayBlockingQueue(1024); } - + /** - * All the TaskGenerator threads will call this method to insert the - * Messages in to the Blocking Queue. + * All the TaskGenerator threads will call this method to insert the Messages in to the Blocking + * Queue. */ public void submitMsg(Message msg) { try { @@ -59,11 +56,10 @@ public class MessageQueue { LOGGER.error(e.getMessage()); } } - + /** - * All the messages will be retrieved by the ServiceExecutor by - * calling this method and process them. - * Retrieves and removes the head of this queue, or returns null if this queue is empty. + * All the messages will be retrieved by the ServiceExecutor by calling this method and process + * them. Retrieves and removes the head of this queue, or returns null if this queue is empty. */ public Message retrieveMsg() { Message retrievedMsg = null; @@ -72,7 +68,7 @@ public class MessageQueue { } catch (Exception e) { LOGGER.error(e.getMessage()); } - + return retrievedMsg; } } \ No newline at end of file diff --git a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/ServiceExecutor.java b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/ServiceExecutor.java index 1ef27ff28..e490e9dd7 100644 --- a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/ServiceExecutor.java +++ b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/ServiceExecutor.java @@ -27,10 +27,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * - * ServiceExecuotr class. - * This class will pick up Messages one by one from - * the Blocking Queue and process them. + * ServiceExecuotr class. This class will pick up Messages one by one from the Blocking Queue and + * process them. */ public class ServiceExecutor implements Runnable { diff --git a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/Task.java b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/Task.java index fcdc3866f..88e9d21f8 100644 --- a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/Task.java +++ b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/Task.java @@ -22,10 +22,10 @@ */ package com.iluwatar.queue.load.leveling; + /** * Task Interface. - * -*/ + */ public interface Task { void submit(Message msg); } diff --git a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/TaskGenerator.java b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/TaskGenerator.java index cef9311fb..885e51652 100644 --- a/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/TaskGenerator.java +++ b/queue-load-leveling/src/main/java/com/iluwatar/queue/load/leveling/TaskGenerator.java @@ -27,28 +27,26 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * TaskGenerator class. - * Each TaskGenerator thread will be a Worker which submit's messages to the queue. - * We need to mention the message count for each of the TaskGenerator threads. - * -*/ + * TaskGenerator class. Each TaskGenerator thread will be a Worker which submit's messages to the + * queue. We need to mention the message count for each of the TaskGenerator threads. + */ public class TaskGenerator implements Task, Runnable { - + private static final Logger LOGGER = LoggerFactory.getLogger(App.class); - + // MessageQueue reference using which we will submit our messages. private final MessageQueue msgQueue; - + // Total message count that a TaskGenerator will submit. private final int msgCount; - + // Parameterized constructor. public TaskGenerator(MessageQueue msgQueue, int msgCount) { this.msgQueue = msgQueue; this.msgCount = msgCount; } - + /** * Submit messages to the Blocking Queue. */ @@ -59,25 +57,25 @@ public class TaskGenerator implements Task, Runnable { LOGGER.error(e.getMessage()); } } - + /** - * Each TaskGenerator thread will submit all the messages to the Queue. - * After every message submission TaskGenerator thread will sleep for 1 second. + * Each TaskGenerator thread will submit all the messages to the Queue. After every message + * submission TaskGenerator thread will sleep for 1 second. */ public void run() { - + int count = this.msgCount; - + try { while (count > 0) { String statusMsg = "Message-" + count + " submitted by " + Thread.currentThread().getName(); this.submit(new Message(statusMsg)); - + LOGGER.info(statusMsg); - + // reduce the message count. count--; - + // Make the current thread to sleep after every Message submission. Thread.sleep(1000); }