@Override public SubscriberInfo getSuperSubscriberInfo() { if(superSubscriberInfoClass == null) { return null; } try { return superSubscriberInfoClass.newInstance(); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
@Override public Object run() throws Exception { return cl.newInstance(); } }, acc);
public static Object newInstance(String name) { try { return forName(name).newInstance(); } catch (InstantiationException e) { throw new IllegalStateException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new IllegalStateException(e.getMessage(), e); } }
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); } }
public static Object newInstance(String name) { try { return forName(name).newInstance(); } catch (InstantiationException e) { throw new IllegalStateException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new IllegalStateException(e.getMessage(), e); } }
public void setStatLoggerClassName(String className) { Class<?> clazz; try { clazz = Class.forName(className); DruidDataSourceStatLogger statLogger = (DruidDataSourceStatLogger) clazz.newInstance(); this.setStatLogger(statLogger); } catch (Exception e) { throw new IllegalArgumentException(className, e); } }
@SuppressWarnings("unchecked") private T createAdaptiveExtension() { try { return injectExtension((T) getAdaptiveExtensionClass().newInstance()); } catch (Exception e) { throw new IllegalStateException("Can't create adaptive extension " + type + ", cause: " + e.getMessage(), e); } }
@SuppressWarnings("unchecked") private T createAdaptiveExtension() { try { return injectExtension((T) getAdaptiveExtensionClass().newInstance()); } catch (Exception e) { throw new IllegalStateException("Can't create adaptive extension " + type + ", cause: " + e.getMessage(), e); } }
private Command getCommand(String request) { Class<?> commandClass = getCommandClass(request); try { return (Command) commandClass.newInstance(); } catch (Exception e) { throw new ApplicationException(e); } }
public static GdxTest newTest (String testName) { testName = originalToObfuscated.get(testName, testName); try { return forName(testName).newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return null; } }
/** Creates a new instance of the class represented by the supplied Class. */ static public <T> T newInstance (Class<T> c) throws ReflectionException { try { return c.newInstance(); } catch (InstantiationException e) { throw new ReflectionException("Could not instantiate instance of class: " + c.getName(), e); } catch (IllegalAccessException e) { throw new ReflectionException("Could not instantiate instance of class: " + c.getName(), e); } }
@Bean @Lazy public Object notLoadable() throws Exception { return Class.forName("does.not.exist").newInstance(); } }
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) { PropertyProcessable processable; try { processable = this.type.newInstance(); } catch (Exception e) { throw new JSONException("craete instance error"); } Object object =parser.parse(processable, fieldName); return (T) object; }
public void setPasswordCallbackClassName(String passwordCallbackClassName) throws Exception { Class<?> clazz = Utils.loadClass(passwordCallbackClassName); if (clazz != null) { this.passwordCallback = (PasswordCallback) clazz.newInstance(); } else { LOG.error("load passwordCallback error : " + passwordCallbackClassName); this.passwordCallback = null; } }
public void setValidConnectionCheckerClassName(String validConnectionCheckerClass) throws Exception { Class<?> clazz = Utils.loadClass(validConnectionCheckerClass); ValidConnectionChecker validConnectionChecker = null; if (clazz != null) { validConnectionChecker = (ValidConnectionChecker) clazz.newInstance(); this.validConnectionChecker = validConnectionChecker; } else { LOG.error("load validConnectionCheckerClass error : " + validConnectionCheckerClass); } }
private void runTestMethod(ClassLoader classLoader) throws Exception { Class<?> test = classLoader.loadClass(FuturesTest.class.getName()); Object testInstance = test.newInstance(); test.getMethod("setUp").invoke(testInstance); test.getMethod(getName()).invoke(testInstance); test.getMethod("tearDown").invoke(testInstance); }
private void runTestMethod(ClassLoader classLoader) throws Exception { Class<?> test = classLoader.loadClass(AbstractFutureTest.class.getName()); test.getMethod(getName()).invoke(test.newInstance()); }
public Object createInstance(BeanInfo beanInfo) { try { return beanInfo.getClazz().newInstance(); } catch (InstantiationException ex) { throw new DruidRuntimeException("create instance error", ex); } catch (IllegalAccessException ex) { throw new DruidRuntimeException("create instance error", ex); } }
private void makeInstance() throws Exception { String fullName = clsNode.getFullName(); instance = getClassLoader().loadClass(fullName).newInstance(); if (instance == null) { throw new NullPointerException("Instantiation failed"); } }
@Test public void testManualProxyJavaWithStaticPointcutAndTwoClassLoaders() throws Exception { LogUserAdvice logAdvice = new LogUserAdvice(); AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut(); pointcut.setExpression(String.format("execution(* %s.TestService.*(..))", getClass().getName())); // Test with default class loader first... testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, new TestServiceImpl(), "TestServiceImpl"); // Then try again with a different class loader on the target... SimpleThrowawayClassLoader loader = new SimpleThrowawayClassLoader(new TestServiceImpl().getClass().getClassLoader()); // Make sure the interface is loaded from the parent class loader loader.excludeClass(TestService.class.getName()); loader.excludeClass(TestException.class.getName()); TestService other = (TestService) loader.loadClass(TestServiceImpl.class.getName()).newInstance(); testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, other, "TestServiceImpl"); }