Package org.apache.uima.resource.metadata

Examples of org.apache.uima.resource.metadata.ResourceMetaData


  public ResourceMetaData callGetMetaData() throws ResourceServiceException {
    // metadata already retrieved during initialization
    try {
      //return uimaEEEngine.getMetaData();
     
      ResourceMetaData  rmd = uimaEEEngine.getMetaData();
      if ( rmd != null ) {
        ((ProcessingResourceMetaData)rmd).getOperationalProperties().setMultipleDeploymentAllowed(true);
        return rmd;
      }
     
View Full Code Here


        endpoint.cancelTimer();
        boolean collocatedAggregate = false;
        if ( endpoint.getServiceInfo() != null ) {
          endpoint.getServiceInfo().setState(ServiceState.RUNNING.name());
        }
        ResourceMetaData resource = null;
        ServiceInfo remoteDelegateServiceInfo = null;
        if (aTypeSystem.trim().length() > 0) {
          if (endpoint.isRemote()) {
            if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.CONFIG)) {
              UIMAFramework.getLogger(CLASS_NAME).logrb(Level.CONFIG, CLASS_NAME.getName(),
View Full Code Here

  public void testInitialize() throws Exception {
    try {
      // create a ConfigurableDataResourceSpecifier
      ConfigurableDataResourceSpecifier_impl cspec = new ConfigurableDataResourceSpecifier_impl();
      cspec.setUrl("jdbc:db2:MyDatabase");
      ResourceMetaData md = new ResourceMetaData_impl();
      cspec.setMetaData(md);
      md.setName("foo");
      ConfigurationParameterDeclarations decls = new ConfigurationParameterDeclarations_impl();
      ConfigurationParameter param = new ConfigurationParameter_impl();
      param.setName("param");
      param.setType("String");
      decls.addConfigurationParameter(param);
      md.setConfigurationParameterDeclarations(decls);

      // initialize a DataResource
      ConfigurableDataResource_impl cdr = new ConfigurableDataResource_impl();
      cdr.initialize(cspec, Collections.EMPTY_MAP);
      assertEquals(new URI("jdbc:db2:MyDatabase"), cdr.getUri());
View Full Code Here

      // Normalize language codes. Need to do this since a wide variety of
      // spellings are acceptable according to ISO.
      normalizeIsoLangCodes(md);

      // clone this metadata and assign a UUID if not already present
      ResourceMetaData mdCopy = (ResourceMetaData) md.clone();

      if (mdCopy.getUUID() == null) {
        mdCopy.setUUID(UUIDGenerator.generate());
      }
      setMetaData(mdCopy);

      // validate the AnalysisEngineDescription and throw a
      // ResourceInitializationException if there is a problem
View Full Code Here

              throw (RuntimeException) e;
            else
              throw new RuntimeException(e);
          }
        }
        ResourceMetaData metadata = (resource == null) ? null : resource.getMetaData();

        synchronized (metaDataCache) {
          if (cacheDebug) {
            System.err.format("GetMetaDataCache: saving entry in cache%n");
          }
View Full Code Here

  public void testReconfigure() throws Exception {
    try {
      // set up some resource metadata and create a resource
      ResourceCreationSpecifier specifier = new MyTestSpecifier();
      ResourceMetaData md = specifier.getMetaData();
      md.setName("TestResource");
      md.setDescription("Resource used for Testing the Resource_impl base class");
      ConfigurationParameter p1 = new ConfigurationParameter_impl();
      p1.setName("StringParam");
      p1.setDescription("parameter with String data type");
      p1.setType(ConfigurationParameter.TYPE_STRING);
      ConfigurationParameter p2 = new ConfigurationParameter_impl();
      p2.setName("IntegerParam");
      p2.setDescription("parameter with Integer data type");
      p2.setType(ConfigurationParameter.TYPE_INTEGER);
      ConfigurationParameter p3 = new ConfigurationParameter_impl();
      p3.setName("BooleanParam");
      p3.setDescription("parameter with Boolean data type");
      p3.setType(ConfigurationParameter.TYPE_BOOLEAN);
      ConfigurationParameter p4 = new ConfigurationParameter_impl();
      p4.setName("FloatParam");
      p4.setDescription("parameter with Float data type");
      p4.setType(ConfigurationParameter.TYPE_FLOAT);
      ConfigurationParameter p5 = new ConfigurationParameter_impl();
      p5.setName("StringArrayParam");
      p5.setDescription("mutli-valued parameter with String data type");
      p5.setType(ConfigurationParameter.TYPE_STRING);
      p5.setMultiValued(true);
      ConfigurationParameter p6 = new ConfigurationParameter_impl();
      p6.setName("IntegerArrayParam");
      p6.setDescription("multi-valued parameter with Integer data type");
      p6.setType(ConfigurationParameter.TYPE_INTEGER);
      p6.setMultiValued(true);
      ConfigurationParameter p7 = new ConfigurationParameter_impl();
      p7.setName("BooleanArrayParam");
      p7.setDescription("multi-valued parameter with Boolean data type");
      p7.setType(ConfigurationParameter.TYPE_BOOLEAN);
      p7.setMultiValued(true);
      ConfigurationParameter p8 = new ConfigurationParameter_impl();
      p8.setName("FloatArrayParam");
      p8.setDescription("multi-valued parameter with Float data type");
      p8.setType(ConfigurationParameter.TYPE_FLOAT);
      p8.setMultiValued(true);
      md.getConfigurationParameterDeclarations().setConfigurationParameters(
              new ConfigurationParameter[] { p1, p2, p3, p4, p5, p6, p7, p8 });
      ConfigurableResource testResource1 = new MyTestResource();
      testResource1.initialize(specifier, null);

      // valid settings
      String[] paramNames = { "StringParam", "BooleanParam", "IntegerParam", "FloatParam",
          "StringArrayParam", "BooleanArrayParam", "IntegerArrayParam", "FloatArrayParam" };

      String theStr = "hello world";
      Boolean theBool = new Boolean(false);
      Integer theInt = new Integer(42);
      Float theFloat = new Float(2.718281828459045);
      String[] theStrArr = { "the", "quick", "brown", "fox" };
      Boolean[] theBoolArr = { new Boolean(false), new Boolean(true) };
      Integer[] theIntArr = { new Integer(1), new Integer(2), new Integer(3) };
      Float[] theFloatArr = { new Float(3.0), new Float(3.1), new Float(3.14) };

      Object[] values = new Object[] { theStr, theBool, theInt, theFloat, theStrArr, theBoolArr,
          theIntArr, theFloatArr };

      for (int i = 0; i < paramNames.length; i++) {
        testResource1.setConfigParameterValue(paramNames[i], values[i]);
      }
      testResource1.reconfigure();

      // check
      for (int i = 0; i < paramNames.length; i++) {
        Object val = testResource1.getConfigParameterValue(paramNames[i]);
        Assert.assertEquals(val, values[i]);
      }

      // invalid settings
      // wrong type
      Exception ex = null;
      testResource1.setConfigParameterValue("StringParam", new Integer(13));
      try {
        testResource1.reconfigure();
      } catch (ResourceConfigurationException e) {
        ex = e;
      }
      Assert.assertNotNull(ex);

      ex = null;
      testResource1.setConfigParameterValue("IntegerArrayParam", new Object[] { "A", "B", "C" });
      try {
        testResource1.reconfigure();
      } catch (ResourceConfigurationException e) {
        ex = e;
      }
      Assert.assertNotNull(ex);

      // inappropriate array
      ex = null;
      testResource1.setConfigParameterValue("FloatParam", new Float[] { new Float(0.1),
          new Float(0.2), new Float(0.3) });
      try {
        testResource1.reconfigure();
      } catch (ResourceConfigurationException e) {
        ex = e;
      }
      Assert.assertNotNull(ex);

      // array required
      ex = null;
      testResource1.setConfigParameterValue("BooleanArrayParam", new Boolean(true));
      try {
        testResource1.reconfigure();
      } catch (ResourceConfigurationException e) {
        ex = e;
      }
      Assert.assertNotNull(ex);

      // required parameter set to null
      ex = null;
      testResource1.setConfigParameterValue("StringParam", null);
      try {
        testResource1.reconfigure();
      } catch (ResourceConfigurationException e) {
        ex = e;
      }
      Assert.assertNotNull(ex);

      // Now try a resource that defines configuration groups
      // (instantiate metadata from XML TAE descriptor because it's convenient)
      XMLInputSource in = new XMLInputSource(JUnitExtension
              .getFile("ConfigurableResourceImplTest/AnnotatorWithConfigurationGroups.xml"));
      AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
      ResourceMetaData metadata = desc.getMetaData();
      MyTestSpecifier spec = new MyTestSpecifier();
      spec.setMetaData(metadata);
      ConfigurableResource testResource2 = new MyTestResource();
      testResource2.initialize(spec, null);
View Full Code Here

    // if this is a local resource (instantaited from a ResourceCreationSpedcifier),
    // initialize the ResourceManager and UIMA Context.
    if (aSpecifier instanceof ResourceCreationSpecifier) {
      // resolve imports in the metadata
      ResourceMetaData metadata = ((ResourceCreationSpecifier) aSpecifier).getMetaData();
      name = metadata.getName();
      try {
        metadata.resolveImports(getResourceManager());
      } catch (InvalidXMLException e) {
        throw new ResourceInitializationException(e);
      }
      // store Resoure metadata so it can be retrieved via getMetaData() method
      setMetaData(metadata);

      // initialize configuration
      try {
        mUimaContextAdmin.getConfigurationManager().createContext(
                mUimaContextAdmin.getQualifiedContextName(), getMetaData());
        mUimaContextAdmin.getConfigurationManager().setSession(mUimaContextAdmin.getSession());
      } catch (ResourceConfigurationException e) {
        throw new ResourceInitializationException(
                ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] {
                    name, metadata.getSourceUrlString() }, e);
      }

      // initialize any external resource declared in this descriptor
      ResourceManagerConfiguration resMgrCfg = ((ResourceCreationSpecifier) aSpecifier)
              .getResourceManagerConfiguration();
View Full Code Here

            else
              throw new RuntimeException(e);
          }
        }
        if (resource != null) {
          ResourceMetaData metadata = resource.getMetaData();
          if (metadata instanceof ProcessingResourceMetaData) {
            mdList.add(metadata);
          }
          resource.destroy();
        }
View Full Code Here

          throws Exception {
    OperationalProperties op = null;
    // Parse the descriptor to access Operational Properties
    ResourceSpecifier resourceSpecifier = cpeFactory.getSpecifier(new File(aDescPath).toURL());
    if (resourceSpecifier != null && resourceSpecifier instanceof ResourceCreationSpecifier) {
      ResourceMetaData md = ((ResourceCreationSpecifier) resourceSpecifier).getMetaData();
      if (md instanceof ProcessingResourceMetaData) {
        op = ((ProcessingResourceMetaData) md).getOperationalProperties();
        if (op == null) {
          // Operational Properties not defined, so use defaults
          if (isConsumer) {
View Full Code Here

      // Normalize language codes. Need to do this since a wide variety of
      // spellings are acceptable according to ISO.
      normalizeIsoLangCodes(md);

      // clone this metadata and assign a UUID if not already present
      ResourceMetaData mdCopy = (ResourceMetaData) md.clone();

      if (mdCopy.getUUID() == null) {
        mdCopy.setUUID(UUIDGenerator.generate());
      }
      setMetaData(mdCopy);

      // validate the AnalysisEngineDescription and throw a
      // ResourceInitializationException if there is a problem
View Full Code Here

TOP

Related Classes of org.apache.uima.resource.metadata.ResourceMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.