/** * 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 * 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); }