// Path: core/src/java/com/strategicgains/eventing/EventBusBuilder.java
// public interface EventBusBuilder<T  extends EventBus, B>
// {
// 	public B subscribe(EventHandler handler);
// 	public B unsubscribe(EventHandler handler);
// 	public T build();
// }
// 
// Path: core/src/java/com/strategicgains/eventing/EventHandler.java
// public interface EventHandler
// {
// 	/**
// 	 * Process the given event. Called by the EventMonitor when an event occurs.
// 	 * 
// 	 * @param event
// 	 * @throws Exception if something goes wrong
// 	 */
// 	public void handle(Object event)
// 	throws Exception;
// 	
// 	/**
// 	 * Answers whether this EventHandler can handle events of the given type.
// 	 * If true is returned, the EventMonitor will call handle(), otherwise,
// 	 * the EventMonitor will not ask this event handler to process the event.
// 	 * 
// 	 * @param eventClass
// 	 * @return
// 	 */
// 	public boolean handles(Class<?> eventClass);
// }


import java.io.Serializable;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import com.hazelcast.config.Config;
import com.strategicgains.eventing.EventBusBuilder;
import com.strategicgains.eventing.EventHandler;
/*
    Copyright 2012, Strategic Gains, Inc.

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

		http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
 */
package com.strategicgains.eventing.hazelcast;



/**
 * @author toddf
 * @since Oct 5, 2012
 */
public class HazelcastEventBusBuilder<T extends Serializable>
implements EventBusBuilder<HazelcastEventBus<T>, HazelcastEventBusBuilder<T>>
{
	private static final String DEFAULT_QUEUE_NAME = "domain-events";

	private Config config = null;
	private String queueName = DEFAULT_QUEUE_NAME;
	private Set<EventHandler> subscribers = new LinkedHashSet<EventHandler>();

	public HazelcastEventBusBuilder()
	{
		super();
	}

	/**
	 * Very 'thin' (as in not at all) veneer to set underlying Hazelcast
	 * configuration. Yes, this exposes the underlying implementation. Bummer.
	 * 
	 * @param configuration Hazelcast Config instance.
	 * @return this builder to facilitate method chainging.
	 */
	public HazelcastEventBusBuilder<T> setConfiguration(Config configuration)
	{
		this.config = configuration;
		return this;
	}

	@Override
	public HazelcastEventBusBuilder<T> subscribe(EventHandler handler)
	{
		subscribers.add(handler);
		return this;
	}

	@Override
// Path: core/src/java/com/strategicgains/eventing/EventBusBuilder.java
// public interface EventBusBuilder<T  extends EventBus, B>
// {
// 	public B subscribe(EventHandler handler);
// 	public B unsubscribe(EventHandler handler);
// 	public T build();
// }
// 
// Path: core/src/java/com/strategicgains/eventing/EventHandler.java
// public interface EventHandler
// {
// 	/**
// 	 * Process the given event. Called by the EventMonitor when an event occurs.
// 	 * 
// 	 * @param event
// 	 * @throws Exception if something goes wrong
// 	 */
// 	public void handle(Object event)
// 	throws Exception;
// 	
// 	/**
// 	 * Answers whether this EventHandler can handle events of the given type.
// 	 * If true is returned, the EventMonitor will call handle(), otherwise,
// 	 * the EventMonitor will not ask this event handler to process the event.
// 	 * 
// 	 * @param eventClass
// 	 * @return
// 	 */
// 	public boolean handles(Class<?> eventClass);
// }


// Path: hazelcast/src/java/com/strategicgains/eventing/hazelcast/HazelcastEventBusBuilder.java
import java.io.Serializable;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import com.hazelcast.config.Config;
import com.strategicgains.eventing.EventBusBuilder;
import com.strategicgains.eventing.EventHandler;

/*
    Copyright 2012, Strategic Gains, Inc.

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

		http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
 */
package com.strategicgains.eventing.hazelcast;



/**
 * @author toddf
 * @since Oct 5, 2012
 */
public class HazelcastEventBusBuilder<T extends Serializable>
implements EventBusBuilder<HazelcastEventBus<T>, HazelcastEventBusBuilder<T>>
{
	private static final String DEFAULT_QUEUE_NAME = "domain-events";

	private Config config = null;
	private String queueName = DEFAULT_QUEUE_NAME;
	private Set<EventHandler> subscribers = new LinkedHashSet<EventHandler>();

	public HazelcastEventBusBuilder()
	{
		super();
	}

	/**
	 * Very 'thin' (as in not at all) veneer to set underlying Hazelcast
	 * configuration. Yes, this exposes the underlying implementation. Bummer.
	 * 
	 * @param configuration Hazelcast Config instance.
	 * @return this builder to facilitate method chainging.
	 */
	public HazelcastEventBusBuilder<T> setConfiguration(Config configuration)
	{
		this.config = configuration;
		return this;
	}

	@Override
	public HazelcastEventBusBuilder<T> subscribe(EventHandler handler)
	{
		subscribers.add(handler);
		return this;
	}

	@Override
	public HazelcastEventBusBuilder<T> unsubscribe(EventHandler handler)