// Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 3997371687805128093L;
// 
// 	public SherpaRuntimeException() {
// 		super();
// 	}
// 
// 	public SherpaRuntimeException(String arg0, Throwable arg1) {
// 		super(arg0, arg1);
// 	}
// 
// 	public SherpaRuntimeException(String arg0) {
// 		super(arg0);
// 	}
// 
// 	public SherpaRuntimeException(Throwable arg0) {
// 		super(arg0);
// 	}
// 
// }
// 
// Path: src/main/java/com/khs/sherpa/util/Util.java
// public class Util {
// 
// 	public static String msg(String msg) {
// 		return SHERPA_SERVER+msg;	
// 	}
// 	
// 	public static String errmsg(String msg) {
// 		return SHERPA_NOT_INITIALIZED+msg;	
// 	}
// 	
// 	public static URL getResource(String resource) {
// 		ClassLoader cl = Thread.currentThread().getContextClassLoader();
// 		return cl.getResource(resource);
// 	}
// 	
// 	public static Properties getProperties(String resource) throws IOException {
// 		return getProperties(Util.getResource(resource));
// 	}
// 	
// 	public static Properties getProperties(URL url) throws IOException {
// 		Properties properties = new Properties();
// 		properties.load(url.openStream());
// 		return properties;
// 	}
// 	
// 	public static <T> T[] append(T[] arr, T element) {
// 	    final int N = arr.length;
// 	    arr = Arrays.copyOf(arr, N + 1);
// 	    arr[N] = element;
// 	    return arr;
// 	}
// 	
// 	public static String getObjectName(Class<?> type) {
// 		String name = null;
// 		if(type.isAnnotationPresent(Endpoint.class)) {
// 			name = type.getAnnotation(Endpoint.class).value();
// 		}
// 		
// 		if(StringUtils.isEmpty(name)) {
// 			name = type.getSimpleName();
// 		}
// 		return name;
// 	}
// 	
// }


import com.khs.sherpa.exception.SherpaRuntimeException;
import com.khs.sherpa.util.Util;
package com.khs.sherpa.context.factory;

/*
 * Copyright 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


abstract class ManagedBean {

	private Class<?> type;
	private String name;

	public abstract boolean isSingletone();
	public abstract boolean isPrototype();
	public abstract Object getInstance();
	
	public ManagedBean(Class<?> type) {
		this.type = type;
		this.name = Util.getObjectName(type);
	}
	
	public Class<?> getType() {
		return type;
	}
	
	public void setType(Class<?> type) {
		this.type = type;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	protected Object createInstance() {
		try {
			return type.newInstance();
		} catch (Exception e) {
// Path: src/main/java/com/khs/sherpa/exception/SherpaRuntimeException.java
// public class SherpaRuntimeException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 3997371687805128093L;
// 
// 	public SherpaRuntimeException() {
// 		super();
// 	}
// 
// 	public SherpaRuntimeException(String arg0, Throwable arg1) {
// 		super(arg0, arg1);
// 	}
// 
// 	public SherpaRuntimeException(String arg0) {
// 		super(arg0);
// 	}
// 
// 	public SherpaRuntimeException(Throwable arg0) {
// 		super(arg0);
// 	}
// 
// }
// 
// Path: src/main/java/com/khs/sherpa/util/Util.java
// public class Util {
// 
// 	public static String msg(String msg) {
// 		return SHERPA_SERVER+msg;	
// 	}
// 	
// 	public static String errmsg(String msg) {
// 		return SHERPA_NOT_INITIALIZED+msg;	
// 	}
// 	
// 	public static URL getResource(String resource) {
// 		ClassLoader cl = Thread.currentThread().getContextClassLoader();
// 		return cl.getResource(resource);
// 	}
// 	
// 	public static Properties getProperties(String resource) throws IOException {
// 		return getProperties(Util.getResource(resource));
// 	}
// 	
// 	public static Properties getProperties(URL url) throws IOException {
// 		Properties properties = new Properties();
// 		properties.load(url.openStream());
// 		return properties;
// 	}
// 	
// 	public static <T> T[] append(T[] arr, T element) {
// 	    final int N = arr.length;
// 	    arr = Arrays.copyOf(arr, N + 1);
// 	    arr[N] = element;
// 	    return arr;
// 	}
// 	
// 	public static String getObjectName(Class<?> type) {
// 		String name = null;
// 		if(type.isAnnotationPresent(Endpoint.class)) {
// 			name = type.getAnnotation(Endpoint.class).value();
// 		}
// 		
// 		if(StringUtils.isEmpty(name)) {
// 			name = type.getSimpleName();
// 		}
// 		return name;
// 	}
// 	
// }


// Path: src/main/java/com/khs/sherpa/context/factory/ManagedBean.java
import com.khs.sherpa.exception.SherpaRuntimeException;
import com.khs.sherpa.util.Util;

package com.khs.sherpa.context.factory;

/*
 * Copyright 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


abstract class ManagedBean {

	private Class<?> type;
	private String name;

	public abstract boolean isSingletone();
	public abstract boolean isPrototype();
	public abstract Object getInstance();
	
	public ManagedBean(Class<?> type) {
		this.type = type;
		this.name = Util.getObjectName(type);
	}
	
	public Class<?> getType() {
		return type;
	}
	
	public void setType(Class<?> type) {
		this.type = type;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	protected Object createInstance() {
		try {
			return type.newInstance();
		} catch (Exception e) {
			throw new SherpaRuntimeException("Unable to create Managed Bean [" + type + "]");