@Test public void testAccessResourceFromAE() throws Exception { AnalysisEngine ae = createEngine( DummyAE3.class, DummyAE3.RES_KEY_1, createNamedResourceDescription( "lala", AnnotatedResource.class, AnnotatedResource.PARAM_VALUE, "1")); Object resourceInstance1 = ae.getUimaContext().getResourceObject(DummyAE3.RES_KEY_1); Object resourceInstance2 = ae.getResourceManager().getResource( ae.getUimaContextAdmin().getQualifiedContextName() + DummyAE3.RES_KEY_1); assertEquals(resourceInstance1, resourceInstance2); }
public static ExternalResourceDescription createNamedResourceDescription(final String aName, Class<? extends Resource> aInterface, Object... aParams) { ConfigurationParameterFactory.ensureParametersComeInPairs(aParams); List<ExternalResourceBinding> bindings = new ArrayList<ExternalResourceBinding>(); List<ExternalResourceDescription> descs = new ArrayList<ExternalResourceDescription>(); for (Entry<String, ExternalResourceDescription> res : extractResourceParameters(aParams) .entrySet()) { bindings.add(createResourceBinding(res.getKey(), res.getValue())); descs.add(res.getValue()); } ResourceSpecifier spec; if (ConfigurableDataResource_impl.class.isAssignableFrom(aInterface)) { ConfigurationData cfg = ConfigurationParameterFactory.createConfigurationData(aParams); ResourceMetaData_impl meta = new ResourceMetaData_impl(); ConfigurationData reflectedConfigurationData = createConfigurationData(aInterface); ResourceCreationSpecifierFactory.setConfigurationParameters(meta, reflectedConfigurationData.configurationParameters, reflectedConfigurationData.configurationValues); ResourceCreationSpecifierFactory.setConfigurationParameters(meta, cfg.configurationParameters, cfg.configurationValues); ConfigurableDataResourceSpecifier_impl spec1 = new ConfigurableDataResourceSpecifier_impl(); spec1.setUrl(""); spec1.setMetaData(meta); spec = spec1; } else { List<Parameter> params = new ArrayList<Parameter>(); if (aParams != null) { for (int i = 0; i < aParams.length / 2; i++) { if (ExternalResourceFactory.getResourceParameterType(aParams[i * 2 + 1]) != ResourceValueType.NO_RESOURCE) { continue; } Parameter param = new Parameter_impl(); param.setName((String) aParams[i * 2]); param.setValue((String) aParams[i * 2 + 1]); params.add(param); } } CustomResourceSpecifier spec1 = UIMAFramework.getResourceSpecifierFactory() .createCustomResourceSpecifier(); spec1.setResourceClassName(aInterface.getName()); spec1.setParameters(params.toArray(new Parameter[params.size()])); spec = spec1; } ExtendedExternalResourceDescription_impl extRes = new ExtendedExternalResourceDescription_impl(); extRes.setName(aName); extRes.setResourceSpecifier(spec); extRes.setExternalResourceBindings(bindings); extRes.setExternalResources(descs); return extRes; }
ExternalResourceFactory { public static ExternalResourceDescription createNamedResourceDescription(final String aName, Class<? extends Resource> aInterface, Object... aParams) { ConfigurationParameterFactory.ensureParametersComeInPairs(aParams); List<ExternalResourceBinding> bindings = new ArrayList<ExternalResourceBinding>(); List<ExternalResourceDescription> descs = new ArrayList<ExternalResourceDescription>(); for (Entry<String, ExternalResourceDescription> res : extractResourceParameters(aParams) .entrySet()) { bindings.add(createResourceBinding(res.getKey(), res.getValue())); descs.add(res.getValue()); } ResourceSpecifier spec; if (ConfigurableDataResource_impl.class.isAssignableFrom(aInterface)) { ConfigurationData cfg = ConfigurationParameterFactory.createConfigurationData(aParams); ResourceMetaData_impl meta = new ResourceMetaData_impl(); ConfigurationData reflectedConfigurationData = createConfigurationData(aInterface); ResourceCreationSpecifierFactory.setConfigurationParameters(meta, reflectedConfigurationData.configurationParameters, reflectedConfigurationData.configurationValues); ResourceCreationSpecifierFactory.setConfigurationParameters(meta, cfg.configurationParameters, cfg.configurationValues); ConfigurableDataResourceSpecifier_impl spec1 = new ConfigurableDataResourceSpecifier_impl(); spec1.setUrl(""); spec1.setMetaData(meta); spec = spec1; } else { List<Parameter> params = new ArrayList<Parameter>(); if (aParams != null) { for (int i = 0; i < aParams.length / 2; i++) { if (ExternalResourceFactory.getResourceParameterType(aParams[i * 2 + 1]) != ResourceValueType.NO_RESOURCE) { continue; } Parameter param = new Parameter_impl(); param.setName((String) aParams[i * 2]); param.setValue((String) aParams[i * 2 + 1]); params.add(param); } } CustomResourceSpecifier spec1 = UIMAFramework.getResourceSpecifierFactory() .createCustomResourceSpecifier(); spec1.setResourceClassName(aInterface.getName()); spec1.setParameters(params.toArray(new Parameter[params.size()])); spec = spec1; } ExtendedExternalResourceDescription_impl extRes = new ExtendedExternalResourceDescription_impl(); extRes.setName(aName); extRes.setResourceSpecifier(spec); extRes.setExternalResourceBindings(bindings); extRes.setExternalResources(descs); return extRes; } }
ExternalResourceFactory { public static ExternalResourceDescription createNamedResourceDescription(final String aName, Class<? extends Resource> aInterface, Object... aParams) { ConfigurationParameterFactory.ensureParametersComeInPairs(aParams); List<ExternalResourceBinding> bindings = new ArrayList<ExternalResourceBinding>(); List<ExternalResourceDescription> descs = new ArrayList<ExternalResourceDescription>(); for (Entry<String, ExternalResourceDescription> res : extractResourceParameters(aParams) .entrySet()) { bindings.add(createResourceBinding(res.getKey(), res.getValue())); descs.add(res.getValue()); } ResourceSpecifier spec; if (ConfigurableDataResource_impl.class.isAssignableFrom(aInterface)) { ConfigurationData cfg = ConfigurationParameterFactory.createConfigurationData(aParams); ResourceMetaData_impl meta = new ResourceMetaData_impl(); ConfigurationData reflectedConfigurationData = createConfigurationData(aInterface); ResourceCreationSpecifierFactory.setConfigurationParameters(meta, reflectedConfigurationData.configurationParameters, reflectedConfigurationData.configurationValues); ResourceCreationSpecifierFactory.setConfigurationParameters(meta, cfg.configurationParameters, cfg.configurationValues); ConfigurableDataResourceSpecifier_impl spec1 = new ConfigurableDataResourceSpecifier_impl(); spec1.setUrl(""); spec1.setMetaData(meta); spec = spec1; } else { List<Parameter> params = new ArrayList<Parameter>(); if (aParams != null) { for (int i = 0; i < aParams.length / 2; i++) { if (ExternalResourceFactory.getResourceParameterType(aParams[i * 2 + 1]) != ResourceValueType.NO_RESOURCE) { continue; } Parameter param = new Parameter_impl(); param.setName((String) aParams[i * 2]); param.setValue((String) aParams[i * 2 + 1]); params.add(param); } } CustomResourceSpecifier spec1 = UIMAFramework.getResourceSpecifierFactory() .createCustomResourceSpecifier(); spec1.setResourceClassName(aInterface.getName()); spec1.setParameters(params.toArray(new Parameter[params.size()])); spec = spec1; } ExtendedExternalResourceDescription_impl extRes = new ExtendedExternalResourceDescription_impl(); extRes.setName(aName); extRes.setResourceSpecifier(spec); extRes.setExternalResourceBindings(bindings); extRes.setExternalResources(descs); return extRes; } private  ExternalResourceFactory(); }
ExternalResourceFactory { public static ExternalResourceDescription createNamedResourceDescription(final String aName, Class<? extends Resource> aInterface, Object... aParams) { ConfigurationParameterFactory.ensureParametersComeInPairs(aParams); List<ExternalResourceBinding> bindings = new ArrayList<ExternalResourceBinding>(); List<ExternalResourceDescription> descs = new ArrayList<ExternalResourceDescription>(); for (Entry<String, ExternalResourceDescription> res : extractResourceParameters(aParams) .entrySet()) { bindings.add(createResourceBinding(res.getKey(), res.getValue())); descs.add(res.getValue()); } ResourceSpecifier spec; if (ConfigurableDataResource_impl.class.isAssignableFrom(aInterface)) { ConfigurationData cfg = ConfigurationParameterFactory.createConfigurationData(aParams); ResourceMetaData_impl meta = new ResourceMetaData_impl(); ConfigurationData reflectedConfigurationData = createConfigurationData(aInterface); ResourceCreationSpecifierFactory.setConfigurationParameters(meta, reflectedConfigurationData.configurationParameters, reflectedConfigurationData.configurationValues); ResourceCreationSpecifierFactory.setConfigurationParameters(meta, cfg.configurationParameters, cfg.configurationValues); ConfigurableDataResourceSpecifier_impl spec1 = new ConfigurableDataResourceSpecifier_impl(); spec1.setUrl(""); spec1.setMetaData(meta); spec = spec1; } else { List<Parameter> params = new ArrayList<Parameter>(); if (aParams != null) { for (int i = 0; i < aParams.length / 2; i++) { if (ExternalResourceFactory.getResourceParameterType(aParams[i * 2 + 1]) != ResourceValueType.NO_RESOURCE) { continue; } Parameter param = new Parameter_impl(); param.setName((String) aParams[i * 2]); param.setValue((String) aParams[i * 2 + 1]); params.add(param); } } CustomResourceSpecifier spec1 = UIMAFramework.getResourceSpecifierFactory() .createCustomResourceSpecifier(); spec1.setResourceClassName(aInterface.getName()); spec1.setParameters(params.toArray(new Parameter[params.size()])); spec = spec1; } ExtendedExternalResourceDescription_impl extRes = new ExtendedExternalResourceDescription_impl(); extRes.setName(aName); extRes.setResourceSpecifier(spec); extRes.setExternalResourceBindings(bindings); extRes.setExternalResources(descs); return extRes; } private  ExternalResourceFactory(); static boolean isExternalResourceField(Field field); static ExternalResourceDescription createResourceDescription(
          Class<? extends Resource> aInterface, Object... aParams); static ExternalResourceDescription createNamedResourceDescription(final String aName,
          Class<? extends Resource> aInterface, Object... aParams); static ExternalResourceDescription createSharedResourceDescription(
          String aUrl, Class<? extends SharedResourceObject> aInterface, Object... aParams); static ExternalResourceDescription createSharedResourceDescription(
          URL aUrl, Class<? extends SharedResourceObject> aInterface, Object... aParams); static ExternalResourceDescription createSharedResourceDescription(
          File aFile, Class<? extends SharedResourceObject> aInterface, Object... aParams); static ExternalResourceDescription createNamedResourceDescriptionUsingUrl(final String aName,
          Class<? extends SharedResourceObject> aInterface, String aUrl, Object... aParams); static ExternalResourceDescription createNamedFileResourceDescription(
          final String aName, String aUrl); static ExternalResourceBinding createResourceBinding(final String aKey,
          final ExternalResourceDescription aResource); static ExternalResourceBinding createResourceBinding(final String aKey,
          final String aResourceKey); @SuppressWarnings({ "unchecked", "rawtypes" }) static ExternalResourceDependency createResourceDependency(Field field); static ExternalResourceDependency createResourceDependency(final String aKey,
          final Class<?> aInterface, final boolean aOptional, String aDescription); static ExternalResourceDependency[] createResourceDependencies(
          Class<?> cls); static void bindResource(ResourceSpecifier aDesc, String aKey, URL aUrl); static void bindResource(ResourceSpecifier aDesc, String aKey, File aFile); @Deprecated static void bindResource(ResourceSpecifier aDesc, String aKey, String aUrl); static void bindResourceUsingUrl(ResourceSpecifier aDesc, String aKey, String aUrl); static void bindResource(ResourceSpecifier aDesc, Class<? extends Resource> aRes,
          String... aParams); static void bindResource(ResourceSpecifier aDesc, Class<?> aApi,
          Class<? extends Resource> aRes, String... aParams); static void bindResourceUsingUrl(ResourceSpecifier aDesc,
          Class<? extends SharedResourceObject> aRes, String aUrl, Object... aParams); static void bindResourceUsingUrl(ResourceSpecifier aDesc, Class<?> aApi,
          Class<? extends SharedResourceObject> aRes, String aUrl, Object... aParams); static void bindResourceUsingUrl(ResourceSpecifier aDesc, String aKey,
          Class<? extends SharedResourceObject> aRes, String aUrl, Object... aParams); static void bindResource(ResourceSpecifier aDesc, String aKey,
          Class<? extends Resource> aRes, String... aParams); static void bindResource(ResourceSpecifier aDesc, ExternalResourceDescription aResDesc); static void bindResource(ResourceSpecifier aDesc, String aKey,
          ExternalResourceDescription aResDesc); static void createDependencyAndBind(ResourceSpecifier aDesc, String aKey,
          Class<? extends Resource> aImpl, String... aParams); static void createDependencyAndBind(ResourceSpecifier aDesc, String aKey,
          Class<? extends Resource> aImpl, Class<?> aApi, String... aParams); static void createDependency(ResourceSpecifier aDesc, String aKey, Class<?> aApi); static void createDependencyAndBindUsingUrl(AnalysisEngineDescription aDesc, String aKey,
          Class<? extends SharedResourceObject> aImpl, String aUrl, Object... aParams); @Deprecated static void bindResource(ResourceManagerConfiguration aResMgrCfg, String aBindTo,
          ExternalResourceDescription aRes); static void bindResourceOnce(ResourceManagerConfiguration aResMgrCfg, String aBindTo,
          ExternalResourceDescription aRes); @Deprecated static void bindResource(ExternalResourceDescription aRes, String aBindTo,
          ExternalResourceDescription aNestedRes); static void bindResourceOnce(ExternalResourceDescription aRes, String aBindTo,
          ExternalResourceDescription aNestedRes); static void bindResourceOnce(ResourceCreationSpecifier aDesc, String aBindTo,
          ExternalResourceDescription aRes); @Deprecated static void bindResource(ResourceManagerConfiguration aResMgrCfg, String aBindTo,
          String aRes); static void bindResourceOnceWithoutNested(ResourceManagerConfiguration aResMgrCfg,
          String aBindTo, String aRes); static void bindResourceOnceWithoutNested(ResourceCreationSpecifier aDesc, String aBindTo, String aRes); static R createResource(Class<R> resourceClass,
          Object... params); @SuppressWarnings("unchecked") static R createResource(Class<R> resourceClass,
          ResourceManager resMgr, Object... params); }
ExternalResourceFactory { public static ExternalResourceDescription createNamedResourceDescription(final String aName, Class<? extends Resource> aInterface, Object... aParams) { ConfigurationParameterFactory.ensureParametersComeInPairs(aParams); List<ExternalResourceBinding> bindings = new ArrayList<ExternalResourceBinding>(); List<ExternalResourceDescription> descs = new ArrayList<ExternalResourceDescription>(); for (Entry<String, ExternalResourceDescription> res : extractResourceParameters(aParams) .entrySet()) { bindings.add(createResourceBinding(res.getKey(), res.getValue())); descs.add(res.getValue()); } ResourceSpecifier spec; if (ConfigurableDataResource_impl.class.isAssignableFrom(aInterface)) { ConfigurationData cfg = ConfigurationParameterFactory.createConfigurationData(aParams); ResourceMetaData_impl meta = new ResourceMetaData_impl(); ConfigurationData reflectedConfigurationData = createConfigurationData(aInterface); ResourceCreationSpecifierFactory.setConfigurationParameters(meta, reflectedConfigurationData.configurationParameters, reflectedConfigurationData.configurationValues); ResourceCreationSpecifierFactory.setConfigurationParameters(meta, cfg.configurationParameters, cfg.configurationValues); ConfigurableDataResourceSpecifier_impl spec1 = new ConfigurableDataResourceSpecifier_impl(); spec1.setUrl(""); spec1.setMetaData(meta); spec = spec1; } else { List<Parameter> params = new ArrayList<Parameter>(); if (aParams != null) { for (int i = 0; i < aParams.length / 2; i++) { if (ExternalResourceFactory.getResourceParameterType(aParams[i * 2 + 1]) != ResourceValueType.NO_RESOURCE) { continue; } Parameter param = new Parameter_impl(); param.setName((String) aParams[i * 2]); param.setValue((String) aParams[i * 2 + 1]); params.add(param); } } CustomResourceSpecifier spec1 = UIMAFramework.getResourceSpecifierFactory() .createCustomResourceSpecifier(); spec1.setResourceClassName(aInterface.getName()); spec1.setParameters(params.toArray(new Parameter[params.size()])); spec = spec1; } ExtendedExternalResourceDescription_impl extRes = new ExtendedExternalResourceDescription_impl(); extRes.setName(aName); extRes.setResourceSpecifier(spec); extRes.setExternalResourceBindings(bindings); extRes.setExternalResources(descs); return extRes; } private  ExternalResourceFactory(); static boolean isExternalResourceField(Field field); static ExternalResourceDescription createResourceDescription(
          Class<? extends Resource> aInterface, Object... aParams); static ExternalResourceDescription createNamedResourceDescription(final String aName,
          Class<? extends Resource> aInterface, Object... aParams); static ExternalResourceDescription createSharedResourceDescription(
          String aUrl, Class<? extends SharedResourceObject> aInterface, Object... aParams); static ExternalResourceDescription createSharedResourceDescription(
          URL aUrl, Class<? extends SharedResourceObject> aInterface, Object... aParams); static ExternalResourceDescription createSharedResourceDescription(
          File aFile, Class<? extends SharedResourceObject> aInterface, Object... aParams); static ExternalResourceDescription createNamedResourceDescriptionUsingUrl(final String aName,
          Class<? extends SharedResourceObject> aInterface, String aUrl, Object... aParams); static ExternalResourceDescription createNamedFileResourceDescription(
          final String aName, String aUrl); static ExternalResourceBinding createResourceBinding(final String aKey,
          final ExternalResourceDescription aResource); static ExternalResourceBinding createResourceBinding(final String aKey,
          final String aResourceKey); @SuppressWarnings({ "unchecked", "rawtypes" }) static ExternalResourceDependency createResourceDependency(Field field); static ExternalResourceDependency createResourceDependency(final String aKey,
          final Class<?> aInterface, final boolean aOptional, String aDescription); static ExternalResourceDependency[] createResourceDependencies(
          Class<?> cls); static void bindResource(ResourceSpecifier aDesc, String aKey, URL aUrl); static void bindResource(ResourceSpecifier aDesc, String aKey, File aFile); @Deprecated static void bindResource(ResourceSpecifier aDesc, String aKey, String aUrl); static void bindResourceUsingUrl(ResourceSpecifier aDesc, String aKey, String aUrl); static void bindResource(ResourceSpecifier aDesc, Class<? extends Resource> aRes,
          String... aParams); static void bindResource(ResourceSpecifier aDesc, Class<?> aApi,
          Class<? extends Resource> aRes, String... aParams); static void bindResourceUsingUrl(ResourceSpecifier aDesc,
          Class<? extends SharedResourceObject> aRes, String aUrl, Object... aParams); static void bindResourceUsingUrl(ResourceSpecifier aDesc, Class<?> aApi,
          Class<? extends SharedResourceObject> aRes, String aUrl, Object... aParams); static void bindResourceUsingUrl(ResourceSpecifier aDesc, String aKey,
          Class<? extends SharedResourceObject> aRes, String aUrl, Object... aParams); static void bindResource(ResourceSpecifier aDesc, String aKey,
          Class<? extends Resource> aRes, String... aParams); static void bindResource(ResourceSpecifier aDesc, ExternalResourceDescription aResDesc); static void bindResource(ResourceSpecifier aDesc, String aKey,
          ExternalResourceDescription aResDesc); static void createDependencyAndBind(ResourceSpecifier aDesc, String aKey,
          Class<? extends Resource> aImpl, String... aParams); static void createDependencyAndBind(ResourceSpecifier aDesc, String aKey,
          Class<? extends Resource> aImpl, Class<?> aApi, String... aParams); static void createDependency(ResourceSpecifier aDesc, String aKey, Class<?> aApi); static void createDependencyAndBindUsingUrl(AnalysisEngineDescription aDesc, String aKey,
          Class<? extends SharedResourceObject> aImpl, String aUrl, Object... aParams); @Deprecated static void bindResource(ResourceManagerConfiguration aResMgrCfg, String aBindTo,
          ExternalResourceDescription aRes); static void bindResourceOnce(ResourceManagerConfiguration aResMgrCfg, String aBindTo,
          ExternalResourceDescription aRes); @Deprecated static void bindResource(ExternalResourceDescription aRes, String aBindTo,
          ExternalResourceDescription aNestedRes); static void bindResourceOnce(ExternalResourceDescription aRes, String aBindTo,
          ExternalResourceDescription aNestedRes); static void bindResourceOnce(ResourceCreationSpecifier aDesc, String aBindTo,
          ExternalResourceDescription aRes); @Deprecated static void bindResource(ResourceManagerConfiguration aResMgrCfg, String aBindTo,
          String aRes); static void bindResourceOnceWithoutNested(ResourceManagerConfiguration aResMgrCfg,
          String aBindTo, String aRes); static void bindResourceOnceWithoutNested(ResourceCreationSpecifier aDesc, String aBindTo, String aRes); static R createResource(Class<R> resourceClass,
          Object... params); @SuppressWarnings("unchecked") static R createResource(Class<R> resourceClass,
          ResourceManager resMgr, Object... params); static final String PARAM_RESOURCE_NAME; static final String PREFIX_SEPARATOR; }