/***
 * 
 * Copyright 2014 Andrew Hall
 *
 * 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 org.statefulj.framework.core.model.impl;

import org.statefulj.framework.core.model.Factory;

public class FactoryImpl<T, CT> implements Factory<T, CT> {

	@Override
	public T create(Class<T> clazz, String event, CT context) {
		T newInstance = null;
		try {
			newInstance = clazz.newInstance();
		} catch(IllegalAccessException e) {
			throw new RuntimeException(e);
		} catch (InstantiationException e) {
			throw new RuntimeException(e);
		}
		return newInstance;
	}

}

@@ -648,16 +648,140 @@
 .impl;%0A%0A
+import java.lang.reflect.Constructor;%0Aimport java.lang.reflect.InvocationTargetException;%0Aimport java.lang.reflect.Method;%0A%0A
 import o
@@ -963,60 +963,111 @@
 %7B%0A%09%09
-T newInstance = null;%0A%09%09try %7B%0A%09%09%09newInstance = clazz
+try %7B%0A%09%09%09Constructor%3CT%3E ctr = clazz.getDeclaredConstructor();%0A%09%09%09ctr.setAccessible(true);%0A%09%09%09return ctr
 .new
@@ -1230,30 +1230,363 @@
 %0A%09%09%7D
-%0A%09%09return newInstance;
+ catch (IllegalArgumentException e) %7B%0A%09%09%09throw new RuntimeException(e);%0A%09%09%7D catch (InvocationTargetException e) %7B%0A%09%09%09throw new RuntimeException(e);%0A%09%09%7D catch (SecurityException e) %7B%0A%09%09%09throw new RuntimeException(e);%0A%09%09%7D catch (NoSuchMethodException e) %7B%0A%09%09%09throw new RuntimeException(clazz.getCanonicalName() + %22 does not have a default constructor%22);%0A%09%09%7D
 %0A%09%7D%0A

Add in ability to instantiate non public default constructors