protected Object instantiate() throws Exception { return _constructor.newInstance(_constructorArgs); }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { Object retVal = invocation.proceed(); Assert.state(this.applicationEventClassConstructor != null, "No ApplicationEvent class set"); ApplicationEvent event = (ApplicationEvent) this.applicationEventClassConstructor.newInstance(invocation.getThis()); Assert.state(this.applicationEventPublisher != null, "No ApplicationEventPublisher available"); this.applicationEventPublisher.publishEvent(event); return retVal; }
public ClassLoader getThrowawayClassLoader() { try { Object classFinder = this.getClassFinderMethod.invoke(this.classLoader); Object parent = this.getParentMethod.invoke(this.classLoader); // arguments for 'clone'-like method return (ClassLoader) this.wlGenericClassLoaderConstructor.newInstance(classFinder, parent); } catch (InvocationTargetException ex) { throw new IllegalStateException("WebLogic GenericClassLoader constructor failed", ex.getCause()); } catch (Throwable ex) { throw new IllegalStateException("Could not construct WebLogic GenericClassLoader", ex); } }
public CertificateChainCleaner buildCertificateChainCleaner(X509TrustManager trustManager) { try { Class<?> extensionsClass = Class.forName("android.net.http.X509TrustManagerExtensions"); Constructor<?> constructor = extensionsClass.getConstructor(X509TrustManager.class); Object extensions = constructor.newInstance(trustManager); Method checkServerTrusted = extensionsClass.getMethod( "checkServerTrusted", X509Certificate[].class, String.class, String.class); return new AndroidCertificateChainCleaner(extensions, checkServerTrusted); } catch (Exception e) { throw new AssertionError(e); } }
@Override final Object invokeInternal(@Nullable Object receiver, Object[] args) throws InvocationTargetException, IllegalAccessException { try { return constructor.newInstance(args); } catch (InstantiationException e) { throw new RuntimeException(constructor + " failed.", e); } }
private Object createNewDelegate() { try { return ReflectionUtils.accessibleConstructor(this.defaultImplType).newInstance(); } catch (Throwable ex) { throw new IllegalArgumentException("Cannot create default implementation for '" + this.interfaceType.getName() + "' mixin (" + this.defaultImplType.getName() + "): " + ex); } }
private Writer newInstance(Object webSocket, boolean isProtected) { try { return (Writer) constructor.newInstance(webSocket, null, isProtected); } catch (Exception ex) { throw new HandshakeFailureException("Failed to create TyrusServletWriter", ex); } } }
private Writer newServletWriter(TyrusHttpUpgradeHandler handler) { try { return (Writer) constructor.newInstance(handler); } catch (Exception ex) { throw new HandshakeFailureException("Failed to instantiate TyrusServletWriter", ex); } }
protected Object instantiate() throws Exception { try { if (_constructor != null) return _constructor.newInstance(_constructorArgs); else return _type.newInstance(); } catch (Exception e) { throw new HessianProtocolException("'" + _type.getName() + "' could not be instantiated", e); } }
private Object create(long initValue) throws IOException { if (initValue == Long.MIN_VALUE) throw new IOException(_cl.getName() + " expects name."); try { return _constructor.newInstance(new Object[]{new Long(initValue)}); } catch (Exception e) { throw new IOExceptionWrapper(e); } } }
private Object create(String value) throws IOException { if (value == null) throw new IOException(_cl.getName() + " expects name."); try { return _constructor.newInstance(new Object[]{value}); } catch (Exception e) { throw new IOExceptionWrapper(e); } } }
static ByteBuffer newDirectBuffer(long address, int capacity) { ObjectUtil.checkPositiveOrZero(capacity, "capacity"); try { return (ByteBuffer) DIRECT_BUFFER_CONSTRUCTOR.newInstance(address, capacity); } catch (Throwable cause) { // Not expected to ever throw! if (cause instanceof Error) { throw (Error) cause; } throw new Error(cause); } }
@SuppressWarnings("unchecked") private static <T> T instantiateFactory(String instanceClassName, Class<T> factoryClass, ClassLoader classLoader) { try { Class<?> instanceClass = ClassUtils.forName(instanceClassName, classLoader); if (!factoryClass.isAssignableFrom(instanceClass)) { throw new IllegalArgumentException( "Class [" + instanceClassName + "] is not assignable to [" + factoryClass.getName() + "]"); } return (T) ReflectionUtils.accessibleConstructor(instanceClass).newInstance(); } catch (Throwable ex) { throw new IllegalArgumentException("Unable to instantiate factory class: " + factoryClass.getName(), ex); } }
public void setCustomSqlExceptionTranslatorClass(@Nullable Class<? extends SQLExceptionTranslator> customTranslatorClass) { if (customTranslatorClass != null) { try { this.customSqlExceptionTranslator = ReflectionUtils.accessibleConstructor(customTranslatorClass).newInstance(); } catch (Throwable ex) { throw new IllegalStateException("Unable to instantiate custom translator", ex); } } else { this.customSqlExceptionTranslator = null; } }
@Override public T newChannel() { try { return constructor.newInstance(); } catch (Throwable t) { throw new ChannelException("Unable to create Channel from class " + constructor.getDeclaringClass(), t); } }
public ClassLoader getThrowawayClassLoader() { try { ClassLoader loader = this.cloneConstructor.newInstance(getClassLoader()); // Clear out the transformers (copied as well) List<?> list = (List<?>) this.transformerList.get(loader); list.clear(); return loader; } catch (InvocationTargetException ex) { throw new IllegalStateException("WebSphere CompoundClassLoader constructor failed", ex.getCause()); } catch (Throwable ex) { throw new IllegalStateException("Could not construct WebSphere CompoundClassLoader", ex); } }
private Object newInstance(HttpServletRequest request, @Nullable Object httpSocket) { try { Object[] args = new Object[] {httpSocket, null, subjectHelper.getSubject(request)}; return constructor.newInstance(args); } catch (Exception ex) { throw new HandshakeFailureException("Failed to create TyrusMuxableWebSocket", ex); } }
@Override Object invokeDefaultMethod(Method method, Class<?> declaringClass, Object object, @Nullable Object... args) throws Throwable { // Because the service interface might not be public, we need to use a MethodHandle lookup // that ignores the visibility of the declaringClass. Constructor<Lookup> constructor = Lookup.class.getDeclaredConstructor(Class.class, int.class); constructor.setAccessible(true); return constructor.newInstance(declaringClass, -1 /* trusted */) .unreflectSpecial(method, declaringClass) .bindTo(object) .invokeWithArguments(args); }
/** * Initialize the wrapped Servlet instance. * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) */ @Override public void afterPropertiesSet() throws Exception { if (this.servletClass == null) { throw new IllegalArgumentException("'servletClass' is required"); } if (this.servletName == null) { this.servletName = this.beanName; } this.servletInstance = ReflectionUtils.accessibleConstructor(this.servletClass).newInstance(); this.servletInstance.init(new DelegatingServletConfig()); }
/** * Create an instance of the specified job class. * <p>Can be overridden to post-process the job instance. * @param bundle the TriggerFiredBundle from which the JobDetail * and other info relating to the trigger firing can be obtained * @return the job instance * @throws Exception if job instantiation failed */ protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { Class<?> jobClass = bundle.getJobDetail().getJobClass(); return ReflectionUtils.accessibleConstructor(jobClass).newInstance(); }