private static <T extends XmlElement> T parseDocumentAtUri( URI uri, Class<T> clazz, XmlParseOptions options ) { try { if ( "local".equals( uri.getScheme() ) ) { ITypeInfo clientConnectorTypeInfo = TypeSystem.getByFullName("gw.internal.xml.ws.LocalWebservicesClientConnector").getTypeInfo(); IConstructorInfo ctor = clientConnectorTypeInfo.getCallableConstructor(TypeSystem.get(URI.class)); Object conn = ctor.getConstructor().newInstance(uri); ITypeInfo responseTypeInfo = TypeSystem.getByFullName("gw.internal.xml.ws.WebservicesResponse").getTypeInfo(); Object response = clientConnectorTypeInfo.getProperty("Response").getAccessor().getValue(conn); InputStream is = (InputStream) responseTypeInfo.getProperty("InputStream").getAccessor().getValue(response); //noinspection unchecked return (T) clazz.getMethod( "parse", InputStream.class, XmlParseOptions.class ).invoke( null, is, options ); } else { //noinspection unchecked return (T) clazz.getMethod( "parse", URL.class, XmlParseOptions.class ).invoke( null, uri.toURL(), options ); } } catch ( InvocationTargetException itex ) { throw GosuExceptionUtil.forceThrow( itex.getTargetException() ); } catch ( Exception ex ) { throw GosuExceptionUtil.forceThrow( ex ); } }
public static Object newInstance( IType type, Object ctx, Object[] args ) { ITypeInfo typeInfo = type.getTypeInfo(); IConstructorInfo method; IType[] runtimeTypes = ReflectUtil.extractRuntimeTypes( args ); method = typeInfo.getCallableConstructor( runtimeTypes ); args = ReflectUtil.coerceArgsIfNecessary( method.getParameters(), args ); args = maybeAddOuter( type, ctx, args ); return method.getConstructor().newInstance( args ); }
private IType getInitializableType() { IType typeToInit = getCurrentInitializableContextType(); if (typeToInit == AMBIGUOUS_TYPE) { return typeToInit; } if( typeToInit == null ) { return null; } else { if( typeToInit.isInterface() ) { typeToInit = findImpl( typeToInit ); } if( typeToInit != null && (typeToInit.isArray() || typeToInit.getTypeInfo().getCallableConstructor() != null) ) { return typeToInit; // we have an unambigous, concrete type with a default constructor } else { return null; } } }
IInitializerExpression initializerExpression = (IInitializerExpression)popExpression(); e.setInitializer( initializerExpression ); e.setConstructor( intrinsicType.getTypeInfo().getCallableConstructor() ); e.setConstructor( intrinsicType.getTypeInfo().getCallableConstructor() );