/** * * @param serviceClass * @param loaderClass * @return */ public static <T> Optional<T> loadSingle(Class<T> serviceClass, Class<?> loaderClass) { Iterator<T> iterator = ServiceLoader.load(serviceClass, WildFlySecurityManager.getClassLoaderPrivileged(loaderClass)).iterator(); T service = null; while (iterator.hasNext()) { if (service != null) { throw new IllegalStateException("Exactly one service provider is required for: " + serviceClass); } service = iterator.next(); } return Optional.ofNullable(service); }
private Object writeReplace() throws ObjectStreamException { return new WeldExceptionStringMessage(getAsString()); }
@Override public String getMessage() { return message.getAsString(); } }
public static void checkArgument(boolean condition, String message) { if (!condition) { throw new IllegalArgumentException(message); } }
/** * Creates a new exception with the given localized message. * * @param message */ public UnsatisfiedResolutionException(String message) { this.message = new WeldExceptionStringMessage(message); }
@Override public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { throw new UnsupportedOperationException(); } };
private Object writeReplace() throws ObjectStreamException { return new WeldExceptionStringMessage(getAsString()); }
@Override public String getMessage() { return message.getAsString(); } }
/** * Creates a new exception with the given localized message and the cause for this exception. * * @param message * @param throwable */ public CreationException(String message, Throwable throwable) { super(throwable); this.message = new WeldExceptionStringMessage(message); }
private Object writeReplace() throws ObjectStreamException { return new WeldExceptionStringMessage(getAsString()); }
@Override public String getMessage() { return message.getAsString(); } }
/** * Creates a new exception with the given localized message and the cause for this exception. * * @param message * @param throwable */ public IllegalStateException(String message, Throwable throwable) { super(throwable); this.message = new WeldExceptionStringMessage(message); }
private Object writeReplace() throws ObjectStreamException { return new WeldExceptionStringMessage(getAsString()); }
@Override public String getMessage() { return message.getAsString(); } }
/** * Creates a new exception with the given localized message and the cause for this exception. * * @param message * @param throwable */ public IllegalArgumentException(String message, Throwable throwable) { super(throwable); this.message = new WeldExceptionStringMessage(message); }
@Override public String getMessage() { return message.getAsString(); } }
/** * Creates a new exception with the given localized message and the cause for this exception. * * @param message * @param throwable */ public WeldException(String message, Throwable throwable) { super(throwable); this.message = new WeldExceptionStringMessage(message); }
@Override public String getMessage() { return message.getAsString(); } }
/** * Creates a new exception with an arbitrary message and the cause of the * exception. It is not recommended to use this constructor since the message * cannot be localized. * * @param message The error message * @param throwable The cause of the exception or wrapped throwable */ public InjectionException(String message, Throwable throwable) { super(throwable); this.message = new WeldExceptionStringMessage(message); }
@Override public String getMessage() { return message.getAsString(); } }