Merge remote-tracking branch 'refs/remotes/iluwatar/master'

This commit is contained in:
gwildor28 2016-03-29 13:36:56 +01:00
commit 474f2658ee
112 changed files with 643 additions and 173 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

@ -4,7 +4,7 @@
<class id="1" language="java" name="com.iluwatar.eda.model.User" project="event-driven-architecture" <class id="1" language="java" name="com.iluwatar.eda.model.User" project="event-driven-architecture"
file="/event-driven-architecture/src/main/java/com/iluwatar/eda/model/User.java" binary="false" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/model/User.java" binary="false"
corner="BOTTOM_RIGHT"> corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="937" y="618"/> <position height="-1" width="-1" x="437" y="535"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
@ -15,7 +15,7 @@
project="event-driven-architecture" project="event-driven-architecture"
file="/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserUpdatedEventHandler.java" binary="false" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserUpdatedEventHandler.java" binary="false"
corner="BOTTOM_RIGHT"> corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="936" y="90"/> <position height="-1" width="-1" x="763" y="379"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
@ -26,17 +26,17 @@
project="event-driven-architecture" project="event-driven-architecture"
file="/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserCreatedEventHandler.java" binary="false" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/handler/UserCreatedEventHandler.java" binary="false"
corner="BOTTOM_RIGHT"> corner="BOTTOM_RIGHT">
<position height="101" width="200" x="41" y="37"/> <position height="-1" width="-1" x="596" y="272"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/> <operations public="true" package="true" protected="true" private="true" static="true"/>
</display> </display>
</class> </class>
<interface id="4" language="java" name="com.iluwatar.eda.framework.Message" project="event-driven-architecture" <interface id="4" language="java" name="com.iluwatar.eda.framework.Event" project="event-driven-architecture"
file="/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Message.java" binary="false" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Event.java" binary="false"
corner="BOTTOM_RIGHT"> corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="298" y="189"/> <position height="-1" width="-1" x="188" y="121"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
@ -46,7 +46,7 @@
<interface id="5" language="java" name="com.iluwatar.eda.framework.Handler" project="event-driven-architecture" <interface id="5" language="java" name="com.iluwatar.eda.framework.Handler" project="event-driven-architecture"
file="/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Handler.java" binary="false" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/Handler.java" binary="false"
corner="BOTTOM_RIGHT"> corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="532" y="89"/> <position height="-1" width="-1" x="755" y="58"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
@ -56,7 +56,7 @@
<class id="6" language="java" name="com.iluwatar.eda.framework.EventDispatcher" project="event-driven-architecture" <class id="6" language="java" name="com.iluwatar.eda.framework.EventDispatcher" project="event-driven-architecture"
file="/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/EventDispatcher.java" binary="false" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/framework/EventDispatcher.java" binary="false"
corner="BOTTOM_RIGHT"> corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="613" y="292"/> <position height="-1" width="-1" x="499" y="122"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
@ -66,7 +66,7 @@
<class id="7" language="java" name="com.iluwatar.eda.event.UserCreatedEvent" project="event-driven-architecture" <class id="7" language="java" name="com.iluwatar.eda.event.UserCreatedEvent" project="event-driven-architecture"
file="/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserCreatedEvent.java" binary="false" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserCreatedEvent.java" binary="false"
corner="BOTTOM_RIGHT"> corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="145" y="618"/> <position height="-1" width="-1" x="102" y="380"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
@ -76,17 +76,17 @@
<class id="8" language="java" name="com.iluwatar.eda.event.UserUpdatedEvent" project="event-driven-architecture" <class id="8" language="java" name="com.iluwatar.eda.event.UserUpdatedEvent" project="event-driven-architecture"
file="/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserUpdatedEvent.java" binary="false" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/event/UserUpdatedEvent.java" binary="false"
corner="BOTTOM_RIGHT"> corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="769" y="455"/> <position height="-1" width="-1" x="320" y="382"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/> <operations public="true" package="true" protected="true" private="true" static="true"/>
</display> </display>
</class> </class>
<class id="9" language="java" name="com.iluwatar.eda.event.Event" project="event-driven-architecture" <class id="9" language="java" name="com.iluwatar.eda.event.AbstractEvent" project="event-driven-architecture"
file="/event-driven-architecture/src/main/java/com/iluwatar/eda/event/Event.java" binary="false" file="/event-driven-architecture/src/main/java/com/iluwatar/eda/event/AbstractEvent.java" binary="false"
corner="BOTTOM_RIGHT"> corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="299" y="460"/> <position height="-1" width="-1" x="188" y="240"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
@ -94,99 +94,87 @@
</display> </display>
</class> </class>
<dependency id="10"> <dependency id="10">
<bendpoint x="869" y="253"/> <end type="SOURCE" refId="3"/>
<end type="TARGET" refId="1"/>
</dependency>
<dependency id="11">
<end type="SOURCE" refId="2"/>
<end type="TARGET" refId="1"/>
</dependency>
<dependency id="12">
<end type="SOURCE" refId="2"/> <end type="SOURCE" refId="2"/>
<end type="TARGET" refId="8"/> <end type="TARGET" refId="8"/>
</dependency> </dependency>
<dependency id="11"> <realization id="13">
<bendpoint x="140" y="196"/>
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="9"/>
</dependency>
<dependency id="12">
<bendpoint x="17" y="90"/>
<bendpoint x="17" y="708"/>
<bendpoint x="939" y="703"/>
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="1"/>
</dependency>
<dependency id="13">
<bendpoint x="935" y="318"/>
<bendpoint x="936" y="417"/>
<end type="SOURCE" refId="2"/>
<end type="TARGET" refId="1"/>
</dependency>
<dependency id="14">
<bendpoint x="757" y="378"/>
<end type="SOURCE" refId="2"/>
<end type="TARGET" refId="9"/>
</dependency>
<generalization id="15">
<end type="SOURCE" refId="7"/>
<end type="TARGET" refId="9"/>
</generalization>
<association id="16">
<end type="SOURCE" refId="8" navigable="false">
<attribute id="17" name="user"/>
<multiplicity id="18" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="1" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="19">
<end type="SOURCE" refId="2"/> <end type="SOURCE" refId="2"/>
<end type="TARGET" refId="5"/> <end type="TARGET" refId="5"/>
</realization> </realization>
<dependency id="20"> <generalization id="14">
<end type="SOURCE" refId="5"/> <end type="SOURCE" refId="7"/>
<end type="TARGET" refId="9"/>
</dependency>
<dependency id="21">
<bendpoint x="301" y="114"/>
<end type="SOURCE" refId="5"/>
<end type="TARGET" refId="4"/>
</dependency>
<realization id="22">
<end type="SOURCE" refId="9"/>
<end type="TARGET" refId="4"/>
</realization>
<dependency id="23">
<end type="SOURCE" refId="6"/>
<end type="TARGET" refId="9"/>
</dependency>
<generalization id="24">
<end type="SOURCE" refId="8"/>
<end type="TARGET" refId="9"/> <end type="TARGET" refId="9"/>
</generalization> </generalization>
<dependency id="25"> <realization id="15">
<bendpoint x="141" y="250"/>
<end type="SOURCE" refId="3"/> <end type="SOURCE" refId="3"/>
<end type="TARGET" refId="7"/> <end type="TARGET" refId="5"/>
</dependency> </realization>
<association id="26"> <association id="16">
<end type="SOURCE" refId="6" navigable="false"> <end type="SOURCE" refId="6" navigable="false">
<attribute id="27" name="handlers"> <attribute id="17" name="handlers">
<position height="19" width="56" x="449" y="175"/> <position height="19" width="56" x="672" y="144"/>
</attribute> </attribute>
<multiplicity id="28" minimum="0" maximum="2147483647"> <multiplicity id="18" minimum="0" maximum="2147483647">
<position height="17" width="23" x="574" y="173"/> <position height="17" width="23" x="797" y="142"/>
</multiplicity> </multiplicity>
</end> </end>
<end type="TARGET" refId="5" navigable="true"/> <end type="TARGET" refId="5" navigable="true"/>
<display labels="true" multiplicity="true"/> <display labels="true" multiplicity="true"/>
</association> </association>
<association id="29"> <realization id="19">
<end type="SOURCE" refId="7" navigable="false"> <end type="SOURCE" refId="9"/>
<attribute id="30" name="user"/> <end type="TARGET" refId="4"/>
<multiplicity id="31" minimum="0" maximum="1"/> </realization>
<dependency id="20">
<end type="SOURCE" refId="6"/>
<end type="TARGET" refId="4"/>
</dependency>
<dependency id="21">
<bendpoint x="187" y="57"/>
<end type="SOURCE" refId="5"/>
<end type="TARGET" refId="4"/>
</dependency>
<association id="22">
<end type="SOURCE" refId="8" navigable="false">
<attribute id="23" name="user">
<position height="0" width="0" x="-500" y="-83"/>
</attribute>
<multiplicity id="24" minimum="0" maximum="1">
<position height="0" width="0" x="-500" y="-83"/>
</multiplicity>
</end> </end>
<end type="TARGET" refId="1" navigable="true"/> <end type="TARGET" refId="1" navigable="true"/>
<display labels="true" multiplicity="true"/> <display labels="true" multiplicity="true"/>
</association> </association>
<realization id="32"> <generalization id="25">
<end type="SOURCE" refId="8"/>
<end type="TARGET" refId="9"/>
</generalization>
<association id="26">
<end type="SOURCE" refId="7" navigable="false">
<attribute id="27" name="user">
<position height="0" width="0" x="-500" y="-83"/>
</attribute>
<multiplicity id="28" minimum="0" maximum="1">
<position height="0" width="0" x="-500" y="-83"/>
</multiplicity>
</end>
<end type="TARGET" refId="1" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<dependency id="29">
<bendpoint x="308" y="303"/>
<end type="SOURCE" refId="3"/> <end type="SOURCE" refId="3"/>
<end type="TARGET" refId="5"/> <end type="TARGET" refId="7"/>
</realization> </dependency>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="true" signature="true" <classifier-display autosize="true" stereotype="true" package="true" initial-value="true" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>

View File

@ -22,9 +22,9 @@
*/ */
package com.iluwatar.eda; package com.iluwatar.eda;
import com.iluwatar.eda.event.Event;
import com.iluwatar.eda.event.UserCreatedEvent; import com.iluwatar.eda.event.UserCreatedEvent;
import com.iluwatar.eda.event.UserUpdatedEvent; import com.iluwatar.eda.event.UserUpdatedEvent;
import com.iluwatar.eda.framework.Event;
import com.iluwatar.eda.framework.EventDispatcher; import com.iluwatar.eda.framework.EventDispatcher;
import com.iluwatar.eda.handler.UserCreatedEventHandler; import com.iluwatar.eda.handler.UserCreatedEventHandler;
import com.iluwatar.eda.handler.UserUpdatedEventHandler; import com.iluwatar.eda.handler.UserUpdatedEventHandler;
@ -53,12 +53,12 @@ public class App {
public static void main(String[] args) { public static void main(String[] args) {
EventDispatcher dispatcher = new EventDispatcher(); EventDispatcher dispatcher = new EventDispatcher();
dispatcher.registerChannel(UserCreatedEvent.class, new UserCreatedEventHandler()); dispatcher.registerHandler(UserCreatedEvent.class, new UserCreatedEventHandler());
dispatcher.registerChannel(UserUpdatedEvent.class, new UserUpdatedEventHandler()); dispatcher.registerHandler(UserUpdatedEvent.class, new UserUpdatedEventHandler());
User user = new User("iluwatar"); User user = new User("iluwatar");
dispatcher.onEvent(new UserCreatedEvent(user)); dispatcher.dispatch(new UserCreatedEvent(user));
dispatcher.onEvent(new UserUpdatedEvent(user)); dispatcher.dispatch(new UserUpdatedEvent(user));
} }
} }

View File

@ -23,10 +23,10 @@
package com.iluwatar.eda.event; package com.iluwatar.eda.event;
import com.iluwatar.eda.framework.EventDispatcher; import com.iluwatar.eda.framework.EventDispatcher;
import com.iluwatar.eda.framework.Message; import com.iluwatar.eda.framework.Event;
/** /**
* The {@link Event} class serves as a base class for defining custom events happening with your * The {@link AbstractEvent} class serves as a base class for defining custom events happening with your
* system. In this example we have two types of events defined. * system. In this example we have two types of events defined.
* <ul> * <ul>
* <li>{@link UserCreatedEvent} - used when a user is created</li> * <li>{@link UserCreatedEvent} - used when a user is created</li>
@ -34,16 +34,16 @@ import com.iluwatar.eda.framework.Message;
* </ul> * </ul>
* Events can be distinguished using the {@link #getType() getType} method. * Events can be distinguished using the {@link #getType() getType} method.
*/ */
public class Event implements Message { public abstract class AbstractEvent implements Event {
/** /**
* Returns the event type as a {@link Class} object * Returns the event type as a {@link Class} object
* In this example, this method is used by the {@link EventDispatcher} to * In this example, this method is used by the {@link EventDispatcher} to
* dispatch events depending on their type. * dispatch events depending on their type.
* *
* @return the Event type as a {@link Class}. * @return the AbstractEvent type as a {@link Class}.
*/ */
public Class<? extends Message> getType() { public Class<? extends Event> getType() {
return getClass(); return getClass();
} }
} }

View File

@ -29,7 +29,7 @@ import com.iluwatar.eda.model.User;
* This class can be extended to contain details about the user has been created. In this example, * This class can be extended to contain details about the user has been created. In this example,
* the entire {@link User} object is passed on as data with the event. * the entire {@link User} object is passed on as data with the event.
*/ */
public class UserCreatedEvent extends Event { public class UserCreatedEvent extends AbstractEvent {
private User user; private User user;

View File

@ -29,7 +29,7 @@ import com.iluwatar.eda.model.User;
* This class can be extended to contain details about the user has been updated. In this example, * This class can be extended to contain details about the user has been updated. In this example,
* the entire {@link User} object is passed on as data with the event. * the entire {@link User} object is passed on as data with the event.
*/ */
public class UserUpdatedEvent extends Event { public class UserUpdatedEvent extends AbstractEvent {
private User user; private User user;

View File

@ -23,15 +23,15 @@
package com.iluwatar.eda.framework; package com.iluwatar.eda.framework;
/** /**
* A {@link Message} is an object with a specific type that is associated * A {@link Event} is an object with a specific type that is associated
* to a specific {@link Handler}. * to a specific {@link Handler}.
*/ */
public interface Message { public interface Event {
/** /**
* Returns the message type as a {@link Class} object. In this example the message type is * Returns the message type as a {@link Class} object. In this example the message type is
* used to handle events by their type. * used to handle events by their type.
* @return the message type as a {@link Class}. * @return the message type as a {@link Class}.
*/ */
Class<? extends Message> getType(); Class<? extends Event> getType();
} }

View File

@ -22,19 +22,16 @@
*/ */
package com.iluwatar.eda.framework; package com.iluwatar.eda.framework;
import com.iluwatar.eda.event.Event;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* Handles the routing of {@link Event} messages to associated handlers. * Handles the routing of {@link Event} messages to associated handlers.
* A {@link HashMap} is used to store the association between events and their respective handlers. * A {@link HashMap} is used to store the association between events and their respective handlers.
*
*/ */
public class EventDispatcher { public class EventDispatcher {
private Map<Class<? extends Event>, Handler<?>> handlers; private Map<Class<? extends Event>, Handler<? extends Event>> handlers;
public EventDispatcher() { public EventDispatcher() {
handlers = new HashMap<>(); handlers = new HashMap<>();
@ -46,8 +43,8 @@ public class EventDispatcher {
* @param eventType The {@link Event} to be registered * @param eventType The {@link Event} to be registered
* @param handler The {@link Handler} that will be handling the {@link Event} * @param handler The {@link Handler} that will be handling the {@link Event}
*/ */
public void registerChannel(Class<? extends Event> eventType, public <E extends Event> void registerHandler(Class<E> eventType,
Handler<?> handler) { Handler<E> handler) {
handlers.put(eventType, handler); handlers.put(eventType, handler);
} }
@ -56,8 +53,12 @@ public class EventDispatcher {
* *
* @param event The {@link Event} to be dispatched * @param event The {@link Event} to be dispatched
*/ */
public void onEvent(Event event) { @SuppressWarnings("unchecked")
handlers.get(event.getClass()).onEvent(event); public <E extends Event> void dispatch(E event) {
Handler<E> handler = (Handler<E>) handlers.get(event.getClass());
if (handler != null) {
handler.onEvent(event);
}
} }
} }

View File

@ -22,13 +22,11 @@
*/ */
package com.iluwatar.eda.framework; package com.iluwatar.eda.framework;
import com.iluwatar.eda.event.Event;
/** /**
* This interface can be implemented to handle different types of messages. * This interface can be implemented to handle different types of messages.
* Every handler is responsible for a single of type message * Every handler is responsible for a single of type message
*/ */
public interface Handler<E extends Message> { public interface Handler<E extends Event> {
/** /**
* The onEvent method should implement and handle behavior related to the event. * The onEvent method should implement and handle behavior related to the event.
@ -36,5 +34,5 @@ public interface Handler<E extends Message> {
* a queue to be consumed by other sub systems. * a queue to be consumed by other sub systems.
* @param event the {@link Event} object to be handled. * @param event the {@link Event} object to be handled.
*/ */
void onEvent(Event event); void onEvent(E event);
} }

View File

@ -22,7 +22,6 @@
*/ */
package com.iluwatar.eda.handler; package com.iluwatar.eda.handler;
import com.iluwatar.eda.event.Event;
import com.iluwatar.eda.event.UserCreatedEvent; import com.iluwatar.eda.event.UserCreatedEvent;
import com.iluwatar.eda.framework.Handler; import com.iluwatar.eda.framework.Handler;
@ -32,9 +31,10 @@ import com.iluwatar.eda.framework.Handler;
public class UserCreatedEventHandler implements Handler<UserCreatedEvent> { public class UserCreatedEventHandler implements Handler<UserCreatedEvent> {
@Override @Override
public void onEvent(Event message) { public void onEvent(UserCreatedEvent event) {
UserCreatedEvent userCreatedEvent = (UserCreatedEvent) message; System.out.println(String.format(
System.out.printf("User with %s has been Created!", userCreatedEvent.getUser().getUsername()); "User '%s' has been Created!", event.getUser().getUsername()));
} }
} }

View File

@ -22,7 +22,6 @@
*/ */
package com.iluwatar.eda.handler; package com.iluwatar.eda.handler;
import com.iluwatar.eda.event.Event;
import com.iluwatar.eda.event.UserUpdatedEvent; import com.iluwatar.eda.event.UserUpdatedEvent;
import com.iluwatar.eda.framework.Handler; import com.iluwatar.eda.framework.Handler;
@ -32,9 +31,9 @@ import com.iluwatar.eda.framework.Handler;
public class UserUpdatedEventHandler implements Handler<UserUpdatedEvent> { public class UserUpdatedEventHandler implements Handler<UserUpdatedEvent> {
@Override @Override
public void onEvent(Event message) { public void onEvent(UserUpdatedEvent event) {
UserUpdatedEvent userUpdatedEvent = (UserUpdatedEvent) message; System.out.println(String.format(
System.out.printf("User with %s has been Updated!", userUpdatedEvent.getUser().getUsername()); "User '%s' has been Updated!", event.getUser().getUsername()));
} }
} }

View File

@ -29,13 +29,13 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
/** /**
* {@link UserCreatedEventTest} tests and verifies {@link Event} behaviour. * {@link UserCreatedEventTest} tests and verifies {@link AbstractEvent} behaviour.
*/ */
public class UserCreatedEventTest { public class UserCreatedEventTest {
/** /**
* This unit test should correctly return the {@link Event} class type when calling the * This unit test should correctly return the {@link AbstractEvent} class type when calling the
* {@link Event#getType() getType} method. * {@link AbstractEvent#getType() getType} method.
*/ */
@Test @Test
public void testGetEventType() { public void testGetEventType() {

View File

@ -22,7 +22,6 @@
*/ */
package com.iluwatar.eda.framework; package com.iluwatar.eda.framework;
import com.iluwatar.eda.framework.EventDispatcher;
import com.iluwatar.eda.event.UserCreatedEvent; import com.iluwatar.eda.event.UserCreatedEvent;
import com.iluwatar.eda.event.UserUpdatedEvent; import com.iluwatar.eda.event.UserUpdatedEvent;
import com.iluwatar.eda.handler.UserCreatedEventHandler; import com.iluwatar.eda.handler.UserCreatedEventHandler;
@ -49,8 +48,8 @@ public class EventDispatcherTest {
EventDispatcher dispatcher = spy(new EventDispatcher()); EventDispatcher dispatcher = spy(new EventDispatcher());
UserCreatedEventHandler userCreatedEventHandler = spy(new UserCreatedEventHandler()); UserCreatedEventHandler userCreatedEventHandler = spy(new UserCreatedEventHandler());
UserUpdatedEventHandler userUpdatedEventHandler = spy(new UserUpdatedEventHandler()); UserUpdatedEventHandler userUpdatedEventHandler = spy(new UserUpdatedEventHandler());
dispatcher.registerChannel(UserCreatedEvent.class, userCreatedEventHandler); dispatcher.registerHandler(UserCreatedEvent.class, userCreatedEventHandler);
dispatcher.registerChannel(UserUpdatedEvent.class, userUpdatedEventHandler); dispatcher.registerHandler(UserUpdatedEvent.class, userUpdatedEventHandler);
User user = new User("iluwatar"); User user = new User("iluwatar");
@ -58,15 +57,14 @@ public class EventDispatcherTest {
UserUpdatedEvent userUpdatedEvent = new UserUpdatedEvent(user); UserUpdatedEvent userUpdatedEvent = new UserUpdatedEvent(user);
//fire a userCreatedEvent and verify that userCreatedEventHandler has been invoked. //fire a userCreatedEvent and verify that userCreatedEventHandler has been invoked.
dispatcher.onEvent(userCreatedEvent); dispatcher.dispatch(userCreatedEvent);
verify(userCreatedEventHandler).onEvent(userCreatedEvent); verify(userCreatedEventHandler).onEvent(userCreatedEvent);
verify(dispatcher).onEvent(userCreatedEvent); verify(dispatcher).dispatch(userCreatedEvent);
//fire a userCreatedEvent and verify that userUpdatedEventHandler has been invoked. //fire a userCreatedEvent and verify that userUpdatedEventHandler has been invoked.
dispatcher.onEvent(userUpdatedEvent); dispatcher.dispatch(userUpdatedEvent);
verify(userUpdatedEventHandler).onEvent(userUpdatedEvent); verify(userUpdatedEventHandler).onEvent(userUpdatedEvent);
verify(dispatcher).onEvent(userUpdatedEvent); verify(dispatcher).dispatch(userUpdatedEvent);
} }
} }

View File

@ -60,7 +60,7 @@ public class DwarvenGoldmineFacade {
makeActions(workers, DwarvenMineWorker.Action.GO_HOME, DwarvenMineWorker.Action.GO_TO_SLEEP); makeActions(workers, DwarvenMineWorker.Action.GO_HOME, DwarvenMineWorker.Action.GO_TO_SLEEP);
} }
private void makeActions(Collection<DwarvenMineWorker> workers, private static void makeActions(Collection<DwarvenMineWorker> workers,
DwarvenMineWorker.Action... actions) { DwarvenMineWorker.Action... actions) {
for (DwarvenMineWorker worker : workers) { for (DwarvenMineWorker worker : workers) {
worker.action(actions); worker.action(actions);

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
/** /**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
public class Axe implements Weapon { public class Axe implements Weapon {

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
public class Bow implements Weapon { public class Bow implements Weapon {

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
import java.util.function.Supplier; import java.util.function.Supplier;

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
public class Spear implements Weapon { public class Spear implements Weapon {

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
public class Sword implements Weapon { public class Sword implements Weapon {

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
/** /**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit; package com.iluwatar.factorykit;
/** /**

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit.app; package com.iluwatar.factorykit.app;
import com.iluwatar.factorykit.App; import com.iluwatar.factorykit.App;

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.factorykit.factorykit; package com.iluwatar.factorykit.factorykit;
import com.iluwatar.factorykit.*; import com.iluwatar.factorykit.*;

View File

@ -44,7 +44,7 @@ public class FrontController {
} }
} }
private Class getCommandClass(String request) { private static Class getCommandClass(String request) {
Class result; Class result;
try { try {
result = Class.forName("com.iluwatar.front.controller." + request + "Command"); result = Class.forName("com.iluwatar.front.controller." + request + "Command");

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.monad; package com.iluwatar.monad;
import java.util.Objects; import java.util.Objects;

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.monad; package com.iluwatar.monad;
public enum Sex { public enum Sex {

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.monad; package com.iluwatar.monad;
public class User { public class User {

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.monad; package com.iluwatar.monad;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.monad; package com.iluwatar.monad;
import org.junit.Test; import org.junit.Test;

View File

@ -1,3 +1,25 @@
/**
* The MIT License
* Copyright (c) 2014 Ilkka Seppälä
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.iluwatar.monad; package com.iluwatar.monad;

View File

@ -58,7 +58,7 @@ public class LoggingHandler implements ChannelHandler {
} }
} }
private void sendReply(AbstractNioChannel channel, DatagramPacket incomingPacket, SelectionKey key) { private static void sendReply(AbstractNioChannel channel, DatagramPacket incomingPacket, SelectionKey key) {
/* /*
* Create a reply acknowledgement datagram packet setting the receiver to the sender of incoming * Create a reply acknowledgement datagram packet setting the receiver to the sender of incoming
* message. * message.
@ -69,12 +69,12 @@ public class LoggingHandler implements ChannelHandler {
channel.write(replyPacket, key); channel.write(replyPacket, key);
} }
private void sendReply(AbstractNioChannel channel, SelectionKey key) { private static void sendReply(AbstractNioChannel channel, SelectionKey key) {
ByteBuffer buffer = ByteBuffer.wrap(ACK); ByteBuffer buffer = ByteBuffer.wrap(ACK);
channel.write(buffer, key); channel.write(buffer, key);
} }
private void doLogging(ByteBuffer data) { private static void doLogging(ByteBuffer data) {
// assuming UTF-8 :( // assuming UTF-8 :(
System.out.println(new String(data.array(), 0, data.limit())); System.out.println(new String(data.array(), 0, data.limit()));
} }

View File

@ -186,7 +186,7 @@ public class NioReactor {
} }
} }
private void onChannelWritable(SelectionKey key) throws IOException { private static void onChannelWritable(SelectionKey key) throws IOException {
AbstractNioChannel channel = (AbstractNioChannel) key.attachment(); AbstractNioChannel channel = (AbstractNioChannel) key.attachment();
channel.flush(key); channel.flush(key);
} }

View File

@ -89,7 +89,7 @@ public class ReaderWriterLock implements ReadWriteLock {
return globalMutex.isEmpty(); return globalMutex.isEmpty();
} }
private void waitUninterruptibly(Object o) { private static void waitUninterruptibly(Object o) {
try { try {
o.wait(); o.wait();
} catch (InterruptedException e) { } catch (InterruptedException e) {

View File

@ -76,7 +76,7 @@ public class AppConfig {
/** /**
* Properties for Jpa * Properties for Jpa
*/ */
private Properties jpaProperties() { private static Properties jpaProperties() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect"); properties.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
properties.setProperty("hibernate.hbm2ddl.auto", "create-drop"); properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");

Some files were not shown because too many files have changed in this diff Show More