/** * Scan the given resource specifier for external resource dependencies and whenever a dependency * with a compatible type is found, the resource will be bound. * * @param aDesc * a description. * @param aRes * the resource to bind. * @param aParams * parameters passed to the resource when it is created. * @throws InvalidXMLException * if import resolution failed * @throws ClassNotFoundException * if the resource implementation class or interface class could not be accessed * @see CustomResourceSpecifier */ public static void bindResource(ResourceSpecifier aDesc, Class<? extends Resource> aRes, String... aParams) throws InvalidXMLException, ClassNotFoundException { bindResource(aDesc, aRes, aRes, aParams); }
/** * Scan the given resource specifier for external resource dependencies and whenever a dependency * is encountered that has a key equal to the API class name, the resource will be bound. * * @param aDesc * a description. * @param aApi * the resource interface. * @param aRes * the resource to bind. * @param aUrl * the URL from which the resource is initialized. * @param aParams * parameters passed to the resource when it is created. * @throws InvalidXMLException * if import resolution failed * @see SharedResourceObject */ public static void bindResource(ResourceSpecifier aDesc, Class<?> aApi, Class<? extends SharedResourceObject> aRes, String aUrl, Object... aParams) throws InvalidXMLException { bindResource(aDesc, aApi.getName(), aRes, aUrl, aParams); }
/** * Scan the given resource specifier for external resource dependencies and whenever a dependency * is encounter that has the specified key, the resource will be bound. * <p> * <b>Caveat</b>: If you use this method, you may expect that {@link DataResource#getUrl()} or * {@link DataResource#getUri()} will return the same URL that you have specified here. This may * <b>NOT</b> be the case. UIMA will internally try to resolve the URL via a * {@link ResourceManager}. If it cannot resolve a remove URL, this mechanism will think it may be * a local file and will return some local path - or it may redirect it to some location as though * fit by the {@link ResourceManager}. * * @param aDesc * a description. * @param aKey * the key to bind to. * @param aUrl * a URL. * @throws InvalidXMLException * if import resolution failed * @see FileResourceSpecifier */ public static void bindResource(ResourceSpecifier aDesc, String aKey, URL aUrl) throws InvalidXMLException { bindResource(aDesc, aKey, aUrl.toString()); }
throws InvalidXMLException { try { bindResource(aDesc, aKey, aFile.toURI().toURL()); } catch (MalformedURLException e) {
/** * Create a new dependency for the specified resource and bind it. This method is helpful for UIMA * components that do not use the uimaFIT {@link ExternalResource} annotation, because no external * resource dependencies can be automatically generated by uimaFIT for such components. * * @param aDesc * a description. * @param aKey * the key to bind to. * @param aImpl * the resource implementation. * @param aApi * the resource interface * @param aParams * additional parameters supported by the resource. * @throws InvalidXMLException * if import resolution failed */ public static void createDependencyAndBind(ResourceSpecifier aDesc, String aKey, Class<? extends Resource> aImpl, Class<?> aApi, String... aParams) throws InvalidXMLException { createDependency(aDesc, aKey, aApi); bindResource(aDesc, aKey, aImpl, aParams); }
/** * Scan the given resource specifier for external resource dependencies and whenever a dependency * is encounter that has the specified key, the resource will be bound. * <p> * <b>Caveat</b>: If you use this method, you may expect that {@link DataResource#getUrl()} or * {@link DataResource#getUri()} will return the same URL that you have specified here. This is * may <b>NOT</b> be the case. UIMA will internally try to resolve the URL via a * {@link ResourceManager}. If it cannot resolve a remove URL, this mechanism will think it may be * a local file and will return some local path - or it may redirect it to some location as though * fit by the {@link ResourceManager}. * * @param aDesc * a description. * @param aKey * the key to bind to. * @param aUrl * a URL. * @throws InvalidXMLException * if import resolution failed * @see FileResourceSpecifier */ public static void bindResource(ResourceSpecifier aDesc, String aKey, String aUrl) throws InvalidXMLException { ExternalResourceDescription extRes = createExternalResourceDescription(aKey, aUrl); bindResource(aDesc, aKey, extRes); }
/** * Scan the given resource specifier for external resource dependencies and whenever a dependency * with a compatible type is found, the resource will be bound. * * @param aDesc * a description. * @param aApi * the resource interface. * @param aRes * the resource to bind. * @param aParams * parameters passed to the resource when it is created. * @throws InvalidXMLException * if import resolution failed * @throws ClassNotFoundException * if the resource implementation class or interface class could not be accessed * @see CustomResourceSpecifier */ public static void bindResource(ResourceSpecifier aDesc, Class<?> aApi, Class<? extends Resource> aRes, String... aParams) throws InvalidXMLException, ClassNotFoundException { // Appending a disambiguation suffix it possible to have multiple instances of the same // resource with different settings to different keys. ExternalResourceDescription extRes = createExternalResourceDescription( uniqueResourceKey(aRes.getName()), aRes, (Object[]) aParams); bindResource(aDesc, extRes); }
/** * Scan the given resource specifier for external resource dependencies and whenever a dependency * with the given key is encountered, the given resource is bound to it. * * @param aDesc * a description. * @param aKey * the key to bind to. * @param aRes * the resource to bind. * @param aParams * parameters passed to the resource when it is created. * @throws InvalidXMLException * if import resolution failed * @see CustomResourceSpecifier */ public static void bindResource(ResourceSpecifier aDesc, String aKey, Class<? extends Resource> aRes, String... aParams) throws InvalidXMLException { if (ParameterizedDataResource.class.isAssignableFrom(aRes)) { createDependency(aDesc, aKey, DataResource.class); } // Appending a disambiguation suffix it possible to have multiple instances of the same // resource with different settings to different keys. ExternalResourceDescription extRes = createExternalResourceDescription( uniqueResourceKey(aRes.getName()), aRes, (Object[]) aParams); bindResource(aDesc, aKey, extRes); }
/** * Scan the given resource specifier for external resource dependencies and whenever a dependency * a compatible type is found, the given resource is bound to it. * * @param aDesc * a description. * @param aResDesc * the resource description. */ private static void bind(AnalysisEngineDescription aDesc, ExternalResourceDescription aResDesc) throws InvalidXMLException, ClassNotFoundException { // Recursively address delegates if (!aDesc.isPrimitive()) { for (Object delegate : aDesc.getDelegateAnalysisEngineSpecifiers().values()) { bindResource((ResourceSpecifier) delegate, aResDesc); } } // Bind if necessary Class<?> resClass = Class.forName(getImplementationName(aResDesc)); for (ExternalResourceDependency dep : aDesc.getExternalResourceDependencies()) { Class<?> apiClass = Class.forName(dep.getInterfaceName()); // Never bind fields of type Object. See also ExternalResourceInitializer#getApi() if (apiClass.equals(Object.class)) { continue; } if (apiClass.isAssignableFrom(resClass)) { bindExternalResource(aDesc, dep.getKey(), aResDesc); } } }
/** * Scan the given resource specifier for external resource dependencies and whenever a dependency * with the given key is encountered, the given resource is bound to it. * * @param aDesc * a description. * @param aKey * the key to bind to. * @param aResDesc * the resource description. */ private static void bind(AnalysisEngineDescription aDesc, String aKey, ExternalResourceDescription aResDesc) throws InvalidXMLException { // Recursively address delegates if (!aDesc.isPrimitive()) { for (Object delegate : aDesc.getDelegateAnalysisEngineSpecifiers().values()) { bindResource((ResourceSpecifier) delegate, aKey, aResDesc); } } // Bind if necessary for (ExternalResourceDependency dep : aDesc.getExternalResourceDependencies()) { if (aKey.equals(dep.getKey())) { bindExternalResource(aDesc, aKey, aResDesc); } } }
createExternalResourceDependency(aKey, aImpl, false, null))); bindResource(aDesc, aKey, aImpl, aUrl, aParams);
bindResource(analysisDesc, TaskContext.class, TaskContextProvider.class, TaskContextProvider.PARAM_FACTORY_NAME, contextFactory.getId(), TaskContextProvider.PARAM_CONTEXT_ID, ctx.getId());
bindResource(analysisDesc, TaskContext.class, TaskContextProvider.class, TaskContextProvider.PARAM_FACTORY_NAME, contextFactory.getId(), TaskContextProvider.PARAM_CONTEXT_ID, ctx.getId());
bindResource(analysisDesc, TaskContext.class, TaskContextProvider.class, TaskContextProvider.PARAM_FACTORY_NAME, contextFactory.getId(), TaskContextProvider.PARAM_CONTEXT_ID, ctx.getId());