Package org.apache.uima.resource

Examples of org.apache.uima.resource.ResourceServiceException


      UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE, this.getClass().getName(),
              "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_service_exception__SEVERE",
              new Object[] { Thread.currentThread().getName(), e.getMessage() });

      e.printStackTrace();
      throw new ResourceServiceException(e);
    }
  }
View Full Code Here


    try {
      // get CAS instance from pool
      cas = getCasFromPool(mTimeout);

      if (cas == null) {
        throw new ResourceServiceException(ResourceServiceException.RESOURCE_UNAVAILABLE,
                new Object[0]);
      }

      // deserialize CAS data into this CAS instance
      aData.unmarshalCas(cas, true);

      // run the AnalysisEngine's process method
      getAnalysisEngine().process(cas, aResultSpec, trace);

      // return results
      return new ServiceDataCargo(cas, trace);
    } catch (Exception e) {
      resultMessage = e.getLocalizedMessage();
      if (e instanceof ResourceServiceException) {
        throw (ResourceServiceException) e;
      } else {
        throw new ResourceServiceException(e);
      }
    } finally {
      // release CAS
      if (cas != null) {
        getCasPool().releaseCas(cas);
View Full Code Here

   *           if a CAS is not available within the timeout period.
   */
  protected CAS getCasFromPool(int aTimeout) throws ResourceServiceException {
    CAS cas = getCasPool().getCas(aTimeout);
    if (cas == null) {
      throw new ResourceServiceException(ResourceServiceException.RESOURCE_UNAVAILABLE, null);
    }
    return cas;
  }
View Full Code Here

      call.registerTypeMapping(ResourceMetaData.class, resourceMetaDataTypeQName,
              new XmlSerializerFactory(), new XmlDeserializerFactory());

      return (ResourceMetaData) call.invoke(new Object[0]);
    } catch (ServiceException e) {
      throw new ResourceServiceException(e);
    } catch (java.rmi.RemoteException e) {
      throw new ResourceServiceException(e);
    }
  }
View Full Code Here

          Object content = dataHandler.getContent();
          // System.out.println(content.getClass().getName());
          objStream = new ObjectInputStream((InputStream) content);
          resultCargo = (ServiceDataCargo) objStream.readObject();
        } catch (IOException e) {
          throw new ResourceServiceException(e);
        } catch (ClassNotFoundException e) {
          throw new ResourceServiceException(e);
        } finally {
          if (objStream != null) {
            try {
              objStream.close();
            } catch (IOException e) {
              throw new ResourceServiceException(e);
            }
          }
        }
      } else if (result instanceof ServiceDataCargo) // direct return
      {
        resultCargo = (ServiceDataCargo) result;
      } else {
        throw new ResourceServiceException(
                ResourceServiceException.UNEXPECTED_SERVICE_RETURN_VALUE_TYPE, new Object[] {
                    ServiceDataCargo.class.getName(),
                    resultCargo == null ? "null" : resultCargo.getClass().getName() });
      }

      // unmarshal analysis results into the original AnalysisProcessData object
      // (do not replace CAS type system, as it should not have been changed
      // by the service)
      resultCargo.unmarshalCas(aCAS, false);
    } catch (ServiceException e) {
      throw new ResourceServiceException(e);
    } catch (java.rmi.RemoteException e) {
      throw new ResourceServiceException(e);
    } catch (CASException e) {
      throw new ResourceServiceException(e);
    }
  }
View Full Code Here

    try {
      // get CAS instance from pool
      cas = getCasFromPool(mTimeout);

      if (cas == null) {
        throw new ResourceServiceException(ResourceServiceException.RESOURCE_UNAVAILABLE,
                new Object[0]);
      }

      // deserialize CAS data into this CAS instance
      aData.unmarshalCas(cas, true);

      // run the AnalysisEngine's process method
      getAnalysisEngine().process(cas, aResultSpec, trace);

      // return results
      return new ServiceDataCargo(cas, trace);
    } catch (Exception e) {
      resultMessage = e.getLocalizedMessage();
      if (e instanceof ResourceServiceException) {
        throw (ResourceServiceException) e;
      } else {
        throw new ResourceServiceException(e);
      }
    } finally {
      // release CAS
      if (cas != null) {
        getCasPool().releaseCas(cas);
View Full Code Here

   *           if a CAS is not available within the timeout period.
   */
  protected CAS getCasFromPool(int aTimeout) throws ResourceServiceException {
    CAS cas = getCasPool().getCas(aTimeout);
    if (cas == null) {
      throw new ResourceServiceException(ResourceServiceException.RESOURCE_UNAVAILABLE, null);
    }
    return cas;
  }
View Full Code Here

      call.registerTypeMapping(ResourceMetaData.class, resourceMetaDataTypeQName,
              new XmlSerializerFactory(), new XmlDeserializerFactory());

      return (ResourceMetaData) call.invoke(new Object[0]);
    } catch (ServiceException e) {
      throw new ResourceServiceException(e);
    } catch (java.rmi.RemoteException e) {
      throw new ResourceServiceException(e);
    }
  }
View Full Code Here

          Object content = dataHandler.getContent();
          // System.out.println(content.getClass().getName());
          objStream = new ObjectInputStream((InputStream) content);
          resultCargo = (ServiceDataCargo) objStream.readObject();
        } catch (IOException e) {
          throw new ResourceServiceException(e);
        } catch (ClassNotFoundException e) {
          throw new ResourceServiceException(e);
        } finally {
          if (objStream != null) {
            try {
              objStream.close();
            } catch (IOException e) {
              throw new ResourceServiceException(e);
            }
          }
        }
      } else if (result instanceof ServiceDataCargo) // direct return
      {
        resultCargo = (ServiceDataCargo) result;
      } else {
        throw new ResourceServiceException(
                ResourceServiceException.UNEXPECTED_SERVICE_RETURN_VALUE_TYPE, new Object[] {
                    ServiceDataCargo.class.getName(),
                    resultCargo == null ? "null" : resultCargo.getClass().getName() });
      }

      // unmarshal analysis results into the original AnalysisProcessData object
      // (do not replace CAS type system, as it should not have been changed
      // by the service)
      resultCargo.unmarshalCas(aCAS, false);
    } catch (ServiceException e) {
      throw new ResourceServiceException(e);
    } catch (java.rmi.RemoteException e) {
      throw new ResourceServiceException(e);
    } catch (CASException e) {
      throw new ResourceServiceException(e);
    }
  }
View Full Code Here

    try {
      // get CAS instance from pool
      cas = getCasFromPool(mTimeout);

      if (cas == null) {
        throw new ResourceServiceException(ResourceServiceException.RESOURCE_UNAVAILABLE,
                new Object[0]);
      }

      // deserialize CAS data into this CAS instance
      aData.unmarshalCas(cas, true);

      // run the AnalysisEngine's process method
      getAnalysisEngine().process(cas, aResultSpec, trace);

      // return results
      return new ServiceDataCargo(cas, trace);
    } catch (Exception e) {
      resultMessage = e.getLocalizedMessage();
      if (e instanceof ResourceServiceException) {
        throw (ResourceServiceException) e;
      } else {
        throw new ResourceServiceException(e);
      }
    } finally {
      // release CAS
      if (cas != null) {
        getCasPool().releaseCas(cas);
View Full Code Here

TOP

Related Classes of org.apache.uima.resource.ResourceServiceException

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.