This is an automated email from the ASF dual-hosted git repository. rec pushed a commit to branch refactoring/UIMA-6373-Format-UIMA-Core-Java-SDK-codebase in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git
commit 4ea1cae4f9b78068bacd848df0ff2ff95ae39809 Author: Richard Eckart de Castilho <[email protected]> AuthorDate: Thu Feb 10 14:57:55 2022 +0100 [UIMA-6373] Format UIMA Core Java SDK codebase - Auto-format --- .../uima/adapter/vinci/CASTransportable.java | 188 +++++++++++++-------- .../vinci/VinciAnalysisEngineServiceAdapter.java | 22 ++- .../vinci/VinciAnalysisEngineServiceStub.java | 126 ++++++++------ .../vinci/VinciAnalysisEngineService_impl.java | 80 +++++---- .../VinciBinaryAnalysisEngineServiceStub.java | 93 +++++----- .../VinciBinaryAnalysisEngineService_impl.java | 75 +++++--- .../apache/uima/adapter/vinci/util/Constants.java | 2 +- .../apache/uima/adapter/vinci/util/Descriptor.java | 42 +++-- .../adapter/vinci/util/SaxVinciFrameBuilder.java | 51 +++--- .../apache/uima/adapter/vinci/util/Shutdown.java | 3 +- .../vinci/util/UimaSaxVinciFrameBuilder.java | 20 ++- .../uima/adapter/vinci/util/VinciSaxParser.java | 24 ++- .../uima/adapter/vinci/util/VinciTAEClient.java | 3 +- .../VinciAnalysisEngineServiceAdapterTest.java | 56 +++--- 14 files changed, 469 insertions(+), 316 deletions(-) diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/CASTransportable.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/CASTransportable.java index 4f220e5..d965c47 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/CASTransportable.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/CASTransportable.java @@ -77,10 +77,14 @@ public class CASTransportable extends DefaultHandler implements Transportable { * This constructor is used on the service side - a CAS Pool reference is provided. We don't check * a CAS out of the pool until we get a request. * - * @param casPool the cas pool - * @param outOfTypeSystemData the out of type system data - * @param uimaContext the uima context - * @param includeDocText the include doc text + * @param casPool + * the cas pool + * @param outOfTypeSystemData + * the out of type system data + * @param uimaContext + * the uima context + * @param includeDocText + * the include doc text */ public CASTransportable(CasPool casPool, OutOfTypeSystemData outOfTypeSystemData, UimaContext uimaContext, boolean includeDocText) { @@ -97,13 +101,17 @@ public class CASTransportable extends DefaultHandler implements Transportable { * This constructor is used on the client side, where we have a dedicated CAS instance for the * request. * - * @param cas the cas - * @param outOfTypeSystemData the out of type system data - * @param uimaContext the uima context - * @param includeDocText the include doc text + * @param cas + * the cas + * @param outOfTypeSystemData + * the out of type system data + * @param uimaContext + * the uima context + * @param includeDocText + * the include doc text */ - public CASTransportable(CAS cas, OutOfTypeSystemData outOfTypeSystemData, - UimaContext uimaContext, boolean includeDocText) { + public CASTransportable(CAS cas, OutOfTypeSystemData outOfTypeSystemData, UimaContext uimaContext, + boolean includeDocText) { // Debug.p("Creating new CASTransportable."); this.myCas = cas; this.myCasPool = null; @@ -143,7 +151,8 @@ public class CASTransportable extends DefaultHandler implements Transportable { /** * Sets the command. * - * @param command the new command + * @param command + * the new command */ public void setCommand(String command) { this.command = command; @@ -163,7 +172,7 @@ public class CASTransportable extends DefaultHandler implements Transportable { * XCASSerializer. */ class XTalkSerializer extends DefaultHandler { - + /** The os. */ OutputStream os; @@ -174,15 +183,19 @@ public class CASTransportable extends DefaultHandler implements Transportable { /** * Instantiates a new x talk serializer. * - * @param os the os - * @param s the s + * @param os + * the os + * @param s + * the s */ XTalkSerializer(OutputStream os, XCASSerializer s) { this.os = os; this.serializer = s; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.xml.sax.helpers.DefaultHandler#startDocument() */ @Override @@ -228,8 +241,10 @@ public class CASTransportable extends DefaultHandler implements Transportable { /** * Attributes to X talk. * - * @param attributes the attributes - * @throws IOException Signals that an I/O exception has occurred. + * @param attributes + * the attributes + * @throws IOException + * Signals that an I/O exception has occurred. */ void attributesToXTalk(org.xml.sax.Attributes attributes) throws IOException { int size = attributes.getLength(); @@ -241,8 +256,11 @@ public class CASTransportable extends DefaultHandler implements Transportable { } } - /* (non-Javadoc) - * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, + * java.lang.String) */ @Override public void endElement(String uri, String name, String qName) throws SAXException { @@ -250,8 +268,11 @@ public class CASTransportable extends DefaultHandler implements Transportable { // Debug.p("Ending element: " + qName); } - /* (non-Javadoc) - * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) + /* + * (non-Javadoc) + * + * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, + * java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String name, String qName, org.xml.sax.Attributes atts) @@ -276,7 +297,9 @@ public class CASTransportable extends DefaultHandler implements Transportable { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) */ @Override @@ -291,7 +314,9 @@ public class CASTransportable extends DefaultHandler implements Transportable { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.vinci.transport.Transportable#fromStream(java.io.InputStream) */ @Override @@ -305,9 +330,9 @@ public class CASTransportable extends DefaultHandler implements Transportable { // Debug.p("...done parsing."); done = true; } catch (SAXException e) { - //if SAXException wraps an IOException, throw the IOException. This is - //important since different types of IOExceptions (e.g. SocketTimeoutExceptions) - //are treated differently by Vinci + // if SAXException wraps an IOException, throw the IOException. This is + // important since different types of IOExceptions (e.g. SocketTimeoutExceptions) + // are treated differently by Vinci throw convertToIOException(e); } finally { if (!done) { @@ -325,8 +350,10 @@ public class CASTransportable extends DefaultHandler implements Transportable { * Serialize the CAS to the stream in XTalk format. After serialization is complete the cas is * returned to the pool (if it was allocated from a pool.) * - * @param os the os - * @throws IOException Signals that an I/O exception has occurred. + * @param os + * the os + * @throws IOException + * Signals that an I/O exception has occurred. */ @Override public void toStream(OutputStream os) throws IOException { @@ -340,9 +367,9 @@ public class CASTransportable extends DefaultHandler implements Transportable { try { xcasSerializer.serialize(myCas, s, includeDocText, outOfTypeSystemData); } catch (org.xml.sax.SAXException e) { - //if SAXException wraps an IOException, throw the IOException. This is - //important since different types of IOExceptions (e.g. SocketTimeoutExceptions) - //are treated differently by Vinci + // if SAXException wraps an IOException, throw the IOException. This is + // important since different types of IOExceptions (e.g. SocketTimeoutExceptions) + // are treated differently by Vinci throw convertToIOException(e); } UIMAFramework.getLogger().log(Level.FINEST, "CAS Serialization Complete."); @@ -368,7 +395,9 @@ public class CASTransportable extends DefaultHandler implements Transportable { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#finalize() */ @Override @@ -383,8 +412,11 @@ public class CASTransportable extends DefaultHandler implements Transportable { } } - /* (non-Javadoc) - * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) + /* + * (non-Javadoc) + * + * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, + * java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String name, String qName, org.xml.sax.Attributes atts) @@ -404,8 +436,8 @@ public class CASTransportable extends DefaultHandler implements Transportable { } if (Constants.KEYS.equals(qName)) { // the data inside the KEYS element is the contents of an incoming CAS. - // So this is where we need to grab a CAS from the CasPool and initialize - //the XCASDeserializer. + // So this is where we need to grab a CAS from the CasPool and initialize + // the XCASDeserializer. if (myCas == null) { myCas = myCasPool.getCas(0); } @@ -419,13 +451,16 @@ public class CASTransportable extends DefaultHandler implements Transportable { } handler.startDocument(); handler.startElement("", "CAS", "CAS", null); - //set the ready flag to indicate that following elements are CAS data + // set the ready flag to indicate that following elements are CAS data ready++; } } - /* (non-Javadoc) - * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String) + /* + * (non-Javadoc) + * + * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, + * java.lang.String) */ @Override public void endElement(String uri, String name, String qName) throws SAXException { @@ -442,7 +477,9 @@ public class CASTransportable extends DefaultHandler implements Transportable { } } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) */ @Override @@ -480,48 +517,51 @@ public class CASTransportable extends DefaultHandler implements Transportable { @Override public void endDocument() throws SAXException { } - + /** - * Create a SAXException that wraps the given IOException. - * The wrapping is done using the standard Java 1.4 mechanism, - * so that getCause() will work. Note that new SAXException(Exception) - * does NOT work. - * @param e an IOException to wrap + * Create a SAXException that wraps the given IOException. The wrapping is done using the standard + * Java 1.4 mechanism, so that getCause() will work. Note that new SAXException(Exception) does + * NOT work. + * + * @param e + * an IOException to wrap * @return a SAX exception for which <code>getCause()</code> will return <code>e</code>. */ public SAXException wrapAsSAXException(IOException e) { - SAXException saxEx =new SAXException(e.getMessage()); + SAXException saxEx = new SAXException(e.getMessage()); saxEx.initCause(e); return saxEx; } - + /** - * Converts a Throwable to an IOException. If <code>t</code> is an IOException, - * then <code>t</code> is returned. If not, then if <code>t</code> was caused - * by an IOException (directly or indirectly), then that IOException is returned. - * Otherwise, a new IOException is created which wraps (is caused by) <code>t</code>. - * @param t the throwable to convert - * @return an IOException which is either t, one of the causes of t, or a new IOException - * that wraps t. + * Converts a Throwable to an IOException. If <code>t</code> is an IOException, then + * <code>t</code> is returned. If not, then if <code>t</code> was caused by an IOException + * (directly or indirectly), then that IOException is returned. Otherwise, a new IOException is + * created which wraps (is caused by) <code>t</code>. + * + * @param t + * the throwable to convert + * @return an IOException which is either t, one of the causes of t, or a new IOException that + * wraps t. */ private IOException convertToIOException(Throwable t) { - //if t is itself an IOException, just return it - if (t instanceof IOException) { - return (IOException)t; - } - - //search for a cause that is an IOException. If one is found, return that. - Throwable cause = t.getCause(); - while (cause != null) { - if (cause instanceof IOException) { - return (IOException)cause; - } - cause = cause.getCause(); - } - - //otherwise, wrap t in a new IOException - IOException ioex = new IOException(); - ioex.initCause(t); - return ioex; - } + // if t is itself an IOException, just return it + if (t instanceof IOException) { + return (IOException) t; + } + + // search for a cause that is an IOException. If one is found, return that. + Throwable cause = t.getCause(); + while (cause != null) { + if (cause instanceof IOException) { + return (IOException) cause; + } + cause = cause.getCause(); + } + + // otherwise, wrap t in a new IOException + IOException ioex = new IOException(); + ioex.initCause(t); + return ioex; + } } diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceAdapter.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceAdapter.java index d0cbb36..39bb6c9 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceAdapter.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceAdapter.java @@ -38,10 +38,13 @@ public class VinciAnalysisEngineServiceAdapter extends AnalysisEngineServiceAdap /** * Initialize. * - * @param aSpecifier the a specifier - * @param aAdditionalParams the a additional params + * @param aSpecifier + * the a specifier + * @param aAdditionalParams + * the a additional params * @return true, if successful - * @throws ResourceInitializationException the resource initialization exception + * @throws ResourceInitializationException + * the resource initialization exception * @see org.apache.uima.resource.Resource#initialize(ResourceSpecifier, Map) */ @Override @@ -67,8 +70,8 @@ public class VinciAnalysisEngineServiceAdapter extends AnalysisEngineServiceAdap setStub(new VinciAnalysisEngineServiceStub(uriSpec.getUri(), uriSpec.getTimeout(), this, uriSpec.getParameters())); } else { - setStub(new VinciBinaryAnalysisEngineServiceStub(uriSpec.getUri(), uriSpec.getTimeout(), - this, uriSpec.getParameters())); + setStub(new VinciBinaryAnalysisEngineServiceStub(uriSpec.getUri(), uriSpec.getTimeout(), this, + uriSpec.getParameters())); } // do superclass initialization, which among other things initializes UimaContext. @@ -76,13 +79,14 @@ public class VinciAnalysisEngineServiceAdapter extends AnalysisEngineServiceAdap // superclass initialization depends on having access to the component metadata. super.initialize(aSpecifier, aAdditionalParams); - // Sofa mappings are currently not implemented for remote AEs. Catch this + // Sofa mappings are currently not implemented for remote AEs. Catch this // and report an error. if (getUimaContextAdmin().getSofaMap().size() > 0) { - throw new ResourceInitializationException(ResourceInitializationException.SOFA_MAPPING_NOT_SUPPORTED_FOR_REMOTE, - new Object[]{getMetaData().getName()}); + throw new ResourceInitializationException( + ResourceInitializationException.SOFA_MAPPING_NOT_SUPPORTED_FOR_REMOTE, + new Object[] { getMetaData().getName() }); } - + return true; } diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceStub.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceStub.java index 2580ceb..387a704 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceStub.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceStub.java @@ -53,18 +53,18 @@ import org.apache.vinci.transport.document.AFrame; * The Class VinciAnalysisEngineServiceStub. */ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub { - + /** The m vinci client. */ private VinciClient mVinciClient; /** The m owner. */ private Resource mOwner; - + /** * Timeout to use for process and collectionProcessComplete calls. */ private int mTimeout; - + /** * Timeout to use for getMetaData calls. */ @@ -72,20 +72,23 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub /** The Constant debug. */ private static final boolean debug = System.getProperty("DEBUG") != null; - + /** - * Value to return from callGetSupportedXCasVersions method for older services - * that don't actually implement this method. + * Value to return from callGetSupportedXCasVersions method for older services that don't actually + * implement this method. */ - private static final List SUPPORT_XCAS_V1 = Collections.unmodifiableList( - Arrays.asList(new String[]{"1"})); - + private static final List SUPPORT_XCAS_V1 = Collections + .unmodifiableList(Arrays.asList(new String[] { "1" })); + /** * Instantiates a new vinci analysis engine service stub. * - * @param endpointURI the endpoint URI - * @param owner the owner - * @throws ResourceInitializationException the resource initialization exception + * @param endpointURI + * the endpoint URI + * @param owner + * the owner + * @throws ResourceInitializationException + * the resource initialization exception */ public VinciAnalysisEngineServiceStub(String endpointURI, Resource owner) throws ResourceInitializationException { @@ -95,11 +98,16 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub /** * Instantiates a new vinci analysis engine service stub. * - * @param endpointURI the endpoint URI - * @param timeout the timeout - * @param owner the owner - * @param parameters the parameters - * @throws ResourceInitializationException the resource initialization exception + * @param endpointURI + * the endpoint URI + * @param timeout + * the timeout + * @param owner + * the owner + * @param parameters + * the parameters + * @throws ResourceInitializationException + * the resource initialization exception */ public VinciAnalysisEngineServiceStub(String endpointURI, Integer timeout, Resource owner, Parameter[] parameters) throws ResourceInitializationException { @@ -110,30 +118,29 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub VinciContext vctx = new VinciContext(InetAddress.getLocalHost().getCanonicalHostName(), 0); // Override vinci default VNS settings String vnsHost = null; - String vnsPort = null; - String getMetaDataTimeout = null; + String vnsPort = null; + String getMetaDataTimeout = null; if (parameters != null) { - vnsHost = - VinciBinaryAnalysisEngineServiceStub.getParameterValueFor("VNS_HOST", parameters); - vnsPort = VinciBinaryAnalysisEngineServiceStub.getParameterValueFor("VNS_PORT", - parameters); - getMetaDataTimeout = VinciBinaryAnalysisEngineServiceStub.getParameterValueFor("GetMetaDataTimeout", parameters); + vnsHost = VinciBinaryAnalysisEngineServiceStub.getParameterValueFor("VNS_HOST", parameters); + vnsPort = VinciBinaryAnalysisEngineServiceStub.getParameterValueFor("VNS_PORT", parameters); + getMetaDataTimeout = VinciBinaryAnalysisEngineServiceStub + .getParameterValueFor("GetMetaDataTimeout", parameters); } if (vnsHost == null) { vnsHost = System.getProperty("VNS_HOST"); if (vnsHost == null) { - vnsHost = Constants.DEFAULT_VNS_HOST; + vnsHost = Constants.DEFAULT_VNS_HOST; } } if (vnsPort == null) { vnsPort = System.getProperty("VNS_PORT"); if (vnsPort == null) { - vnsPort = "9000"; + vnsPort = "9000"; } } vctx.setVNSHost(vnsHost); vctx.setVNSPort(Integer.parseInt(vnsPort)); - + // Override socket keepAlive setting vctx.setSocketKeepAliveEnabled(isSocketKeepAliveEnabled()); @@ -141,22 +148,22 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub System.out.println("Establishing connnection to " + endpointURI + " using VNS_HOST:" + vctx.getVNSHost() + " and VNS_PORT=" + vctx.getVNSPort()); } - + // establish connection to service mVinciClient = new VinciClient(endpointURI, AFrame.getAFrameFactory(), vctx); - - //store timeout for use in later RPC calls + + // store timeout for use in later RPC calls if (timeout != null) { mTimeout = timeout; } else { - mTimeout = mVinciClient.getSocketTimeout(); //default + mTimeout = mVinciClient.getSocketTimeout(); // default } if (getMetaDataTimeout != null) { mGetMetaDataTimeout = Integer.parseInt(getMetaDataTimeout); } else { - mGetMetaDataTimeout = mVinciClient.getSocketTimeout(); //default + mGetMetaDataTimeout = mVinciClient.getSocketTimeout(); // default } - + if (debug) { System.out.println("Success"); } @@ -165,12 +172,12 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub } } - /** * Call get meta data. * * @return the resource meta data - * @throws ResourceServiceException the resource service exception + * @throws ResourceServiceException + * the resource service exception * @see ResourceServiceStub#callGetMetaData() */ @Override @@ -224,8 +231,10 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub /** * Call process. * - * @param aCAS the a CAS - * @throws ResourceServiceException the resource service exception + * @param aCAS + * the a CAS + * @throws ResourceServiceException + * the resource service exception * @see AnalysisEngineServiceStub#callProcess(CAS) */ @Override @@ -236,8 +245,10 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub /** * Call process cas. * - * @param aCAS the a CAS - * @throws ResourceServiceException the resource service exception + * @param aCAS + * the a CAS + * @throws ResourceServiceException + * the resource service exception * @see CasObjectProcessor#processCas(CAS) */ public void callProcessCas(CAS aCAS) throws ResourceServiceException { @@ -247,15 +258,18 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub /** * The actual process call. * - * @param aCAS the a CAS - * @throws ResourceServiceException the resource service exception + * @param aCAS + * the a CAS + * @throws ResourceServiceException + * the resource service exception */ private void doProcess(CAS aCAS) throws ResourceServiceException { try { aCAS = ((CASImpl) aCAS).getBaseCAS(); // create CASTransportable ... always send the base CAS - final CASTransportable query = new CASTransportable(aCAS, null, mOwner.getUimaContext(), true); + final CASTransportable query = new CASTransportable(aCAS, null, mOwner.getUimaContext(), + true); query.setCommand("Annotate"); mVinciClient.sendAndReceive(query, new TransportableFactory() { @@ -292,7 +306,8 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub /** * Call batch process complete. * - * @throws ResourceServiceException the resource service exception + * @throws ResourceServiceException + * the resource service exception * @see CasObjectProcessor#batchProcessComplete(org.apache.uima.util.ProcessTrace) */ @Override @@ -312,7 +327,8 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub /** * Call collection process complete. * - * @throws ResourceServiceException the resource service exception + * @throws ResourceServiceException + * the resource service exception * @see CasObjectProcessor#collectionProcessComplete(org.apache.uima.util.ProcessTrace) */ @Override @@ -334,7 +350,8 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub * Call is read only. * * @return true, if successful - * @throws ResourceServiceException the resource service exception + * @throws ResourceServiceException + * the resource service exception * @see CasObjectProcessor#isReadOnly() */ public boolean callIsReadOnly() throws ResourceServiceException { @@ -357,7 +374,8 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub * Call is stateless. * * @return true, if successful - * @throws ResourceServiceException the resource service exception + * @throws ResourceServiceException + * the resource service exception * @see CasObjectProcessor#isStateless() */ public boolean callIsStateless() throws ResourceServiceException { @@ -380,7 +398,8 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub * Call get supported X cas versions. * * @return the list - * @throws ResourceServiceException the resource service exception + * @throws ResourceServiceException + * the resource service exception */ public List callGetSupportedXCasVersions() throws ResourceServiceException { try { @@ -395,8 +414,7 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub if (result != null) { String[] versions = result.split("\\s+"); return Collections.unmodifiableList(Arrays.asList(versions)); - } - else { + } else { return SUPPORT_XCAS_V1; } } catch (Exception e) { @@ -405,16 +423,16 @@ public class VinciAnalysisEngineServiceStub implements AnalysisEngineServiceStub } /** - * Gets whether socket keepAlive is enabled, by consulting the - * PerformanceTuningSettings. (If no setting specified, defaults - * to true.) + * Gets whether socket keepAlive is enabled, by consulting the PerformanceTuningSettings. (If no + * setting specified, defaults to true.) + * * @return if socketKeepAlive is enabled */ protected boolean isSocketKeepAliveEnabled() { if (mOwner instanceof AnalysisEngine) { - Properties settings = ((AnalysisEngine)mOwner).getPerformanceTuningSettings(); + Properties settings = ((AnalysisEngine) mOwner).getPerformanceTuningSettings(); if (settings != null) { - String enabledStr = (String)settings.get(UIMAFramework.SOCKET_KEEPALIVE_ENABLED); + String enabledStr = (String) settings.get(UIMAFramework.SOCKET_KEEPALIVE_ENABLED); return !"false".equalsIgnoreCase(enabledStr); } } diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineService_impl.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineService_impl.java index 9dcd291..3e90d0c 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineService_impl.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineService_impl.java @@ -58,7 +58,7 @@ import org.apache.vinci.transport.document.AFrame; * The main method takes one argument - the path to the service deployment descriptor. */ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { - + /** The server. */ private VinciServer _server = null; @@ -81,10 +81,14 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { /** * Instantiate Analysis Engine from a given descriptor, debug mode, and instance Id. * - * @param serviceConfigPath descriptor location - * @param debug the debug - * @param instanceId the instance id - * @throws Exception passthru + * @param serviceConfigPath + * descriptor location + * @param debug + * the debug + * @param instanceId + * the instance id + * @throws Exception + * passthru */ public VinciAnalysisEngineService_impl(String serviceConfigPath, boolean debug, String instanceId) throws Exception { @@ -95,9 +99,12 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { /** * Instantiate Analysis Engine service from a given descriptor - possibly in debug mode. * - * @param serviceConfigPath descriptor location - * @param debug the debug - * @throws Exception the exception + * @param serviceConfigPath + * descriptor location + * @param debug + * the debug + * @throws Exception + * the exception */ public VinciAnalysisEngineService_impl(String serviceConfigPath, boolean debug) throws Exception { this.debug = debug; @@ -111,15 +118,15 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { UIMAFramework.getLogger().log(Level.CONFIG, "Resource Specifier Path::" + aResourceSpecifierPath); - ResourceSpecifier resourceSpecifier = UIMAFramework.getXMLParser().parseResourceSpecifier( - new XMLInputSource(aResourceSpecifierPath)); + ResourceSpecifier resourceSpecifier = UIMAFramework.getXMLParser() + .parseResourceSpecifier(new XMLInputSource(aResourceSpecifierPath)); // create CAS Object Processor if (mAE == null) { UIMAFramework.getLogger().log(Level.FINE, "VinciAnalysisEngineService_impl: creating CAS Processor"); - mAE = UIMAFramework - .produceAnalysisEngine(resourceSpecifier, descriptor.getInstanceCount(), 0); + mAE = UIMAFramework.produceAnalysisEngine(resourceSpecifier, descriptor.getInstanceCount(), + 0); } // create pool of CASes if (mCasPool == null) { @@ -138,8 +145,10 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { /** * Instantiate Analysis Engine service from a given descriptor. * - * @param serviceConfigPath descriptor location - * @throws Exception the exception + * @param serviceConfigPath + * descriptor location + * @throws Exception + * the exception */ public VinciAnalysisEngineService_impl(String serviceConfigPath) throws Exception { this(serviceConfigPath, false); @@ -149,7 +158,8 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { * Extracts AE metadata. * * @return Frame containing extracted meta data - * @throws Exception the exception + * @throws Exception + * the exception */ private Frame getMetaData() throws Exception { UIMAFramework.getLogger().log(Level.FINEST, "VinciAnalysisEngineService.getMetaData()"); @@ -179,9 +189,11 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { * containing XCAS translated into a set of Vinci subFrames. Each subframe containing one * annotation with all its attributes. * - * @param ct the ct + * @param ct + * the ct * @return VinciFrame containing XCAS translated into a set of Vinci subframes. - * @exception Exception if there is an error during processing + * @exception Exception + * if there is an error during processing */ private Transportable analyze(CASTransportable ct) throws Exception { CAS cas = ct.getCas(); @@ -219,11 +231,13 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { * VINCI:COMMAND. Currently, two such operations are supported: 1) Annotate - triggers document * analysis 2) GetData - triggers return of the AE meta data ( descriptor) * - * @param doc {@link org.apache.vinci.transport.Transportable} - - * a VinciFrame containing client request + * @param doc + * {@link org.apache.vinci.transport.Transportable} - a VinciFrame containing client + * request * @return {@link org.apache.vinci.transport.Transportable} - a VinciFrame containg result of * performing the service - * @throws ServiceException the service exception + * @throws ServiceException + * the service exception */ @Override public Transportable eval(Transportable doc) throws ServiceException { @@ -293,15 +307,14 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { _server = new VinciServer(serviceName, serviceHost, this); } - UIMAFramework.getLogger().log( - Level.FINEST, + UIMAFramework.getLogger().log(Level.FINEST, "VinciAnalysisEngineService_impl: Starting Server with Socket Timeout:" + descriptor.getServerSocketTimeout()); - System.out - .println("VinciAnalysisEngineService_impl: Starting Server with Socket Timeout:" - + descriptor.getServerSocketTimeout()); + System.out.println("VinciAnalysisEngineService_impl: Starting Server with Socket Timeout:" + + descriptor.getServerSocketTimeout()); _server.setSocketTimeout(descriptor.getServerSocketTimeout()); - _server.setThreadPoolSize(descriptor.getThreadPoolMinSize(), descriptor.getThreadPoolMaxSize()); + _server.setThreadPoolSize(descriptor.getThreadPoolMinSize(), + descriptor.getThreadPoolMaxSize()); _server.serve(); } catch (ServiceDownException e) { @@ -334,7 +347,8 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { /** * The main method. * - * @param args the arguments + * @param args + * the arguments */ public static void main(String[] args) { try { @@ -385,7 +399,8 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { /** * Redirects all logger output for this JVM to the given output stream. * - * @param out the out + * @param out + * the out */ private static void redirectLoggerOutput(OutputStream out) { // get root logger handlers - root logger is parent of all loggers @@ -406,20 +421,23 @@ public class VinciAnalysisEngineService_impl extends VinciServableAdapter { * Class that handles service shutdowns (including Ctrl-C). */ static class ShutdownHook extends Thread { - + /** The server. */ VinciAnalysisEngineService_impl server; /** * Instantiates a new shutdown hook. * - * @param instance the instance + * @param instance + * the instance */ public ShutdownHook(VinciAnalysisEngineService_impl instance) { server = instance; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Thread#run() */ @Override diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciBinaryAnalysisEngineServiceStub.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciBinaryAnalysisEngineServiceStub.java index fd14d7b..6e6e433 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciBinaryAnalysisEngineServiceStub.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciBinaryAnalysisEngineServiceStub.java @@ -66,32 +66,40 @@ public class VinciBinaryAnalysisEngineServiceStub implements AnalysisEngineServi * Timeout to use for process and collectionProcessComplete calls. */ private int mTimeout; - + /** * Timeout to use for getMetaData calls. */ - private int mGetMetaDataTimeout; - + private int mGetMetaDataTimeout; + /** * Instantiates a new vinci binary analysis engine service stub. * - * @param endpointURI the endpoint URI - * @param owner the owner - * @throws ResourceInitializationException the resource initialization exception + * @param endpointURI + * the endpoint URI + * @param owner + * the owner + * @throws ResourceInitializationException + * the resource initialization exception */ - public VinciBinaryAnalysisEngineServiceStub(String endpointURI, AnalysisEngineServiceAdapter owner) - throws ResourceInitializationException { + public VinciBinaryAnalysisEngineServiceStub(String endpointURI, + AnalysisEngineServiceAdapter owner) throws ResourceInitializationException { this(endpointURI, null, owner, null); } /** * Instantiates a new vinci binary analysis engine service stub. * - * @param endpointURI the endpoint URI - * @param timeout the timeout - * @param owner the owner - * @param parameters the parameters - * @throws ResourceInitializationException the resource initialization exception + * @param endpointURI + * the endpoint URI + * @param timeout + * the timeout + * @param owner + * the owner + * @param parameters + * the parameters + * @throws ResourceInitializationException + * the resource initialization exception */ public VinciBinaryAnalysisEngineServiceStub(String endpointURI, Integer timeout, AnalysisEngineServiceAdapter owner, Parameter[] parameters) @@ -103,14 +111,13 @@ public class VinciBinaryAnalysisEngineServiceStub implements AnalysisEngineServi VinciContext vctx = new VinciContext(InetAddress.getLocalHost().getCanonicalHostName(), 0); // Override vinci default VNS settings String vnsHost = null; - String vnsPort = null; - String getMetaDataTimeout = null; + String vnsPort = null; + String getMetaDataTimeout = null; if (parameters != null) { - vnsHost = - VinciBinaryAnalysisEngineServiceStub.getParameterValueFor("VNS_HOST", parameters); - vnsPort = VinciBinaryAnalysisEngineServiceStub.getParameterValueFor("VNS_PORT", - parameters); - getMetaDataTimeout = VinciBinaryAnalysisEngineServiceStub.getParameterValueFor("GetMetaDataTimeout", parameters); + vnsHost = VinciBinaryAnalysisEngineServiceStub.getParameterValueFor("VNS_HOST", parameters); + vnsPort = VinciBinaryAnalysisEngineServiceStub.getParameterValueFor("VNS_PORT", parameters); + getMetaDataTimeout = VinciBinaryAnalysisEngineServiceStub + .getParameterValueFor("GetMetaDataTimeout", parameters); } if (vnsHost == null) { vnsHost = System.getProperty("VNS_HOST"); @@ -124,7 +131,7 @@ public class VinciBinaryAnalysisEngineServiceStub implements AnalysisEngineServi } vctx.setVNSHost(vnsHost); vctx.setVNSPort(Integer.parseInt(vnsPort)); - + // Override socket keepAlive setting vctx.setSocketKeepAliveEnabled(isSocketKeepAliveEnabled()); @@ -132,22 +139,22 @@ public class VinciBinaryAnalysisEngineServiceStub implements AnalysisEngineServi System.out.println("Establishing connnection to " + endpointURI + " using VNS_HOST:" + vctx.getVNSHost() + " and VNS_PORT=" + vctx.getVNSPort()); } - + // establish connection to service mVinciClient = new VinciClient(endpointURI, AFrame.getAFrameFactory(), vctx); - - //store timeout for use in later RPC calls + + // store timeout for use in later RPC calls if (timeout != null) { mTimeout = timeout; } else { - mTimeout = mVinciClient.getSocketTimeout(); //default + mTimeout = mVinciClient.getSocketTimeout(); // default } if (getMetaDataTimeout != null) { mGetMetaDataTimeout = Integer.parseInt(getMetaDataTimeout); } else { - mGetMetaDataTimeout = mVinciClient.getSocketTimeout(); //default - } - + mGetMetaDataTimeout = mVinciClient.getSocketTimeout(); // default + } + if (debug) { System.out.println("Success"); } @@ -159,8 +166,10 @@ public class VinciBinaryAnalysisEngineServiceStub implements AnalysisEngineServi /** * Gets the parameter value for. * - * @param aKey the a key - * @param parameters the parameters + * @param aKey + * the a key + * @param parameters + * the parameters * @return the parameter value for */ public static String getParameterValueFor(String aKey, Parameter[] parameters) { @@ -178,7 +187,8 @@ public class VinciBinaryAnalysisEngineServiceStub implements AnalysisEngineServi * Call get meta data. * * @return the resource meta data - * @throws ResourceServiceException the resource service exception + * @throws ResourceServiceException + * the resource service exception * @see ResourceServiceStub#callGetMetaData() */ @Override @@ -233,8 +243,10 @@ public class VinciBinaryAnalysisEngineServiceStub implements AnalysisEngineServi /** * Call process. * - * @param aCAS the a CAS - * @throws ResourceServiceException the resource service exception + * @param aCAS + * the a CAS + * @throws ResourceServiceException + * the resource service exception * @see AnalysisEngineServiceStub#callProcess(CAS) */ @Override @@ -271,7 +283,8 @@ public class VinciBinaryAnalysisEngineServiceStub implements AnalysisEngineServi /** * Call batch process complete. * - * @throws ResourceServiceException the resource service exception + * @throws ResourceServiceException + * the resource service exception * @see AnalysisEngineServiceStub#callBatchProcessComplete() */ @Override @@ -291,7 +304,8 @@ public class VinciBinaryAnalysisEngineServiceStub implements AnalysisEngineServi /** * Call collection process complete. * - * @throws ResourceServiceException the resource service exception + * @throws ResourceServiceException + * the resource service exception * @see AnalysisEngineServiceStub#callCollectionProcessComplete() */ @Override @@ -319,17 +333,16 @@ public class VinciBinaryAnalysisEngineServiceStub implements AnalysisEngineServi mVinciClient.close(); } - /** - * Gets whether socket keepAlive is enabled, by consulting the - * PerformanceTuningSettings. (If no setting specified, defaults - * to true.) + * Gets whether socket keepAlive is enabled, by consulting the PerformanceTuningSettings. (If no + * setting specified, defaults to true.) + * * @return if socketKeepAlive is enabled */ private boolean isSocketKeepAliveEnabled() { Properties settings = mOwner.getPerformanceTuningSettings(); if (settings != null) { - String enabledStr = (String)settings.get(UIMAFramework.SOCKET_KEEPALIVE_ENABLED); + String enabledStr = (String) settings.get(UIMAFramework.SOCKET_KEEPALIVE_ENABLED); return !"false".equalsIgnoreCase(enabledStr); } return true; diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciBinaryAnalysisEngineService_impl.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciBinaryAnalysisEngineService_impl.java index dbd359c..4f80456 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciBinaryAnalysisEngineService_impl.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/VinciBinaryAnalysisEngineService_impl.java @@ -67,7 +67,7 @@ import org.apache.vinci.transport.document.AFrame; * */ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter { - + /** The server. */ private VinciServer _server = null; @@ -90,10 +90,14 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter /** * Instantiate Analysis Engine from a given descriptor - possibly in debug mode. * - * @param serviceConfigPath descriptor location - * @param debug the debug - * @param instanceId the instance id - * @throws Exception the exception + * @param serviceConfigPath + * descriptor location + * @param debug + * the debug + * @param instanceId + * the instance id + * @throws Exception + * the exception */ public VinciBinaryAnalysisEngineService_impl(String serviceConfigPath, boolean debug, String instanceId) throws Exception { @@ -105,9 +109,12 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter /** * Instantiate Analysis Engine from a given descriptor - possibly in debug mode. * - * @param serviceConfigPath descriptor location - * @param debug the debug - * @throws Exception the exception + * @param serviceConfigPath + * descriptor location + * @param debug + * the debug + * @throws Exception + * the exception */ public VinciBinaryAnalysisEngineService_impl(String serviceConfigPath, boolean debug) throws Exception { @@ -122,15 +129,15 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter String aResourceSpecifierPath = descriptor.getResourceSpecifierPath(); UIMAFramework.getLogger().log(Level.FINE, "Resource Specifier Path::" + aResourceSpecifierPath); - ResourceSpecifier resourceSpecifier = UIMAFramework.getXMLParser().parseResourceSpecifier( - new XMLInputSource(aResourceSpecifierPath)); + ResourceSpecifier resourceSpecifier = UIMAFramework.getXMLParser() + .parseResourceSpecifier(new XMLInputSource(aResourceSpecifierPath)); // create CAS Object Processor if (mAE == null) { UIMAFramework.getLogger().log(Level.FINEST, "VinciBinaryAnalysisEngineService_impl: creating CAS Processor"); - mAE = UIMAFramework - .produceAnalysisEngine(resourceSpecifier, descriptor.getInstanceCount(), 0); + mAE = UIMAFramework.produceAnalysisEngine(resourceSpecifier, descriptor.getInstanceCount(), + 0); } // create pool of CASes if (mCasPool == null) { @@ -141,8 +148,10 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter /** * Instantiate Analysis Engine from a given descriptor. * - * @param serviceConfigPath descriptor location - * @throws Exception the exception + * @param serviceConfigPath + * descriptor location + * @throws Exception + * the exception */ public VinciBinaryAnalysisEngineService_impl(String serviceConfigPath) throws Exception { this(serviceConfigPath, false); @@ -152,7 +161,8 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter * Extracts AE metadata. * * @return Frame containing extracted meta data - * @throws Exception the exception + * @throws Exception + * the exception */ private Frame getMetaData() throws Exception { UIMAFramework.getLogger().log(Level.FINEST, "getMetaData()"); @@ -182,9 +192,11 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter * VinciFrame containing XCAS translated into a set of Vinci subFrames. Each subframe containing * one annotation with all its attributes. * - * @param aRequestFrame request frame + * @param aRequestFrame + * request frame * @return VinciFrame containing XCAS translated into a set of Vinci subframes. - * @throws ServiceException the service exception + * @throws ServiceException + * the service exception */ private Transportable analyze(AFrame aRequestFrame) throws ServiceException { CAS cas = null; @@ -244,11 +256,13 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter * VINCI:COMMAND. Currently, two such operations are supported: 1) Annotate - triggers document * analysis 2) GetData - triggers return of the AE meta data ( descriptor) * - * @param doc {@link org.apache.vinci.transport.Transportable} - - * a VinciFrame containing client request + * @param doc + * {@link org.apache.vinci.transport.Transportable} - a VinciFrame containing client + * request * @return {@link org.apache.vinci.transport.Transportable} - a VinciFrame containg result of * performing the service - * @throws ServiceException the service exception + * @throws ServiceException + * the service exception */ @Override @@ -316,15 +330,15 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter _server = new VinciServer(serviceName, serviceHost, this); } - UIMAFramework.getLogger().log( - Level.FINEST, + UIMAFramework.getLogger().log(Level.FINEST, "VinciBinaryAnalysisEngineService_impl: Starting Server with Socket Timeout:" + descriptor.getServerSocketTimeout()); System.out .println("VinciBinaryAnalysisEngineService_impl: Starting Server with Socket Timeout:" + descriptor.getServerSocketTimeout()); _server.setSocketTimeout(descriptor.getServerSocketTimeout()); - _server.setThreadPoolSize(descriptor.getThreadPoolMinSize(), descriptor.getThreadPoolMaxSize()); + _server.setThreadPoolSize(descriptor.getThreadPoolMinSize(), + descriptor.getThreadPoolMaxSize()); _server.serve(); } catch (ServiceDownException e) { UIMAFramework.getLogger().log(Level.SEVERE, e.getMessage()); @@ -356,7 +370,8 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter /** * The main method. * - * @param args the arguments + * @param args + * the arguments */ public static void main(String[] args) { try { @@ -394,7 +409,8 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter /** * Redirects all logger output for this JVM to the given output stream. * - * @param out the out + * @param out + * the out */ private static void redirectLoggerOutput(OutputStream out) { // get root logger handlers - root logger is parent of all loggers @@ -415,20 +431,23 @@ public class VinciBinaryAnalysisEngineService_impl extends VinciServableAdapter * Class that handles service shutdowns (including Ctrl-C). */ static class ShutdownHook extends Thread { - + /** The server. */ VinciBinaryAnalysisEngineService_impl server; /** * Instantiates a new shutdown hook. * - * @param instance the instance + * @param instance + * the instance */ public ShutdownHook(VinciBinaryAnalysisEngineService_impl instance) { server = instance; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Thread#run() */ @Override diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Constants.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Constants.java index 17d7a02..bceb567 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Constants.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Constants.java @@ -79,7 +79,7 @@ public class Constants { /** The Constant GET_SUPPORTED_XCAS_VERSIONS. */ public static final String GET_SUPPORTED_XCAS_VERSIONS = "GetSupportedXCasVersions"; - + /** The Constant SUPPORTED_XCAS_VERSIONS_RESPONSE. */ public static final String SUPPORTED_XCAS_VERSIONS_RESPONSE = "2"; } diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Descriptor.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Descriptor.java index 8d73b03..dd89fd1 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Descriptor.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Descriptor.java @@ -29,7 +29,6 @@ import org.w3c.dom.Document; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; - // TODO: Auto-generated Javadoc /** * Instance of this class handles parsing of the xml descriptor files. It also retrieves values of @@ -57,17 +56,18 @@ public class Descriptor extends DefaultHandler { /** The server socket timeout. */ private int serverSocketTimeout = 300000; // 5 minute timeout on the service socket - + /** The thread pool min size. */ private int threadPoolMinSize = 1; - + /** The thread pool max size. */ private int threadPoolMaxSize = 20; /** * Constructor responsible for parsing the descriptor file named in filePath. * - * @param filePath Fully qualified path the xml descriptor. + * @param filePath + * Fully qualified path the xml descriptor. */ public Descriptor(String filePath) { try { @@ -80,7 +80,8 @@ public class Descriptor extends DefaultHandler { /** * Parses the. * - * @param configFile the config file + * @param configFile + * the config file * @return the document */ private Document parse(String configFile) { @@ -110,8 +111,10 @@ public class Descriptor extends DefaultHandler { /** * Gets the attribute. * - * @param attrName the attr name - * @param attribs the attribs + * @param attrName + * the attr name + * @param attribs + * the attribs * @return the attribute */ private String getAttribute(String attrName, Attributes attribs) { @@ -131,8 +134,10 @@ public class Descriptor extends DefaultHandler { /** * Gets the name. * - * @param s1 the s 1 - * @param s2 the s 2 + * @param s1 + * the s 1 + * @param s2 + * the s 2 * @return the name */ private String getName(String s1, String s2) { @@ -142,8 +147,11 @@ public class Descriptor extends DefaultHandler { return s1; } - /* (non-Javadoc) - * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) + /* + * (non-Javadoc) + * + * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, + * java.lang.String, org.xml.sax.Attributes) */ @Override public void startElement(String uri, String localName, String qName, Attributes attribs) { @@ -206,7 +214,8 @@ public class Descriptor extends DefaultHandler { /** * Sets the thread pool max size. * - * @param threadPoolMaxSize the new thread pool max size + * @param threadPoolMaxSize + * the new thread pool max size */ public void setThreadPoolMaxSize(int threadPoolMaxSize) { this.threadPoolMaxSize = threadPoolMaxSize; @@ -224,7 +233,8 @@ public class Descriptor extends DefaultHandler { /** * Sets the thread pool min size. * - * @param threadPoolMinSize the new thread pool min size + * @param threadPoolMinSize + * the new thread pool min size */ public void setThreadPoolMinSize(int threadPoolMinSize) { this.threadPoolMinSize = threadPoolMinSize; @@ -318,7 +328,8 @@ public class Descriptor extends DefaultHandler { /** * Sets the naming service host. * - * @param namingServiceHost the new naming service host + * @param namingServiceHost + * the new naming service host */ public void setNamingServiceHost(String namingServiceHost) { this.namingServiceHost = namingServiceHost; @@ -336,7 +347,8 @@ public class Descriptor extends DefaultHandler { /** * Sets the server socket timeout. * - * @param serverSocketTimeout the new server socket timeout + * @param serverSocketTimeout + * the new server socket timeout */ public void setServerSocketTimeout(int serverSocketTimeout) { this.serverSocketTimeout = serverSocketTimeout; diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/SaxVinciFrameBuilder.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/SaxVinciFrameBuilder.java index fe503c7..09dffab 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/SaxVinciFrameBuilder.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/SaxVinciFrameBuilder.java @@ -62,7 +62,8 @@ public class SaxVinciFrameBuilder extends DefaultHandler implements ContentHandl /** * Start document. * - * @throws SAXException the SAX exception + * @throws SAXException + * the SAX exception * @see org.xml.sax.ContentHandler#startDocument() */ @Override @@ -75,13 +76,18 @@ public class SaxVinciFrameBuilder extends DefaultHandler implements ContentHandl /** * Called for each start tag encountered. * - * @param namespaceURI Required if the namespaces property is true. - * @param localName The local name (without prefix), or the empty string if Namespace processing is not + * @param namespaceURI + * Required if the namespaces property is true. + * @param localName + * The local name (without prefix), or the empty string if Namespace processing is not * being performed. - * @param qualifiedName The qualified name (with prefix), or the empty string if qualified names are not + * @param qualifiedName + * The qualified name (with prefix), or the empty string if qualified names are not * available. - * @param attributes The specified or defaulted attributes. - * @throws SAXException the SAX exception + * @param attributes + * The specified or defaulted attributes. + * @throws SAXException + * the SAX exception */ @Override public void startElement(String namespaceURI, String localName, String qualifiedName, @@ -106,8 +112,8 @@ public class SaxVinciFrameBuilder extends DefaultHandler implements ContentHandl // set attributes if (mCurrentFrameAttrs != null) { for (int i = 0; i < mCurrentFrameAttrs.getLength(); i++) { - String attrName = getName(mCurrentFrameAttrs.getLocalName(i), mCurrentFrameAttrs - .getQName(i)); + String attrName = getName(mCurrentFrameAttrs.getLocalName(i), + mCurrentFrameAttrs.getQName(i)); vinciAttrs.fadd(attrName, mCurrentFrameAttrs.getValue(i)); } } @@ -125,9 +131,12 @@ public class SaxVinciFrameBuilder extends DefaultHandler implements ContentHandl /** * Characters. * - * @param ch the ch - * @param start the start - * @param length the length + * @param ch + * the ch + * @param start + * the start + * @param length + * the length * @see org.xml.sax.ContentHandler#characters(char[],int,int) */ @Override @@ -138,9 +147,12 @@ public class SaxVinciFrameBuilder extends DefaultHandler implements ContentHandl /** * End element. * - * @param namespaceURI the namespace URI - * @param localName the local name - * @param qualifiedName the qualified name + * @param namespaceURI + * the namespace URI + * @param localName + * the local name + * @param qualifiedName + * the qualified name * @see org.xml.sax.ContentHandler#endElement(String,String,String) */ @Override @@ -152,18 +164,19 @@ public class SaxVinciFrameBuilder extends DefaultHandler implements ContentHandl // the getLeafContent method just returns the contents of the // mCharContentBuffer, but exists so subclasses can override for // specialized behavior (such as supressing certain content). - String leafContent = getLeafContent(mCurrentFrameName, mCurrentFrameAttrs, mCharContentBuffer); + String leafContent = getLeafContent(mCurrentFrameName, mCurrentFrameAttrs, + mCharContentBuffer); // add leaf to parent frame AFrame parent = (AFrame) mOpenFrames.peek(); - org.apache.vinci.transport.Attributes vinciAttrs = parent - .aadd(mCurrentFrameName, leafContent); + org.apache.vinci.transport.Attributes vinciAttrs = parent.aadd(mCurrentFrameName, + leafContent); // set attributes if (mCurrentFrameAttrs != null) { for (int i = 0; i < mCurrentFrameAttrs.getLength(); i++) { - String attrName = getName(mCurrentFrameAttrs.getLocalName(i), mCurrentFrameAttrs - .getQName(i)); + String attrName = getName(mCurrentFrameAttrs.getLocalName(i), + mCurrentFrameAttrs.getQName(i)); vinciAttrs.fadd(attrName, mCurrentFrameAttrs.getValue(i)); } } diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Shutdown.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Shutdown.java index f9a0911..4114619 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Shutdown.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/Shutdown.java @@ -31,7 +31,8 @@ public class Shutdown { /** * The main method. * - * @param args the arguments + * @param args + * the arguments */ public static void main(String[] args) { System.out.println("Shutting down the service..."); diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/UimaSaxVinciFrameBuilder.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/UimaSaxVinciFrameBuilder.java index c84ffb2..1a99939 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/UimaSaxVinciFrameBuilder.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/UimaSaxVinciFrameBuilder.java @@ -33,13 +33,16 @@ import org.xml.sax.Attributes; * */ public class UimaSaxVinciFrameBuilder extends SaxVinciFrameBuilder { - + /** * Instantiates a new uima sax vinci frame builder. * - * @param aSupressDocumentText the a supress document text - * @param aIncludeSpannedTextInAnnotations the a include spanned text in annotations - * @param aDocText the a doc text + * @param aSupressDocumentText + * the a supress document text + * @param aIncludeSpannedTextInAnnotations + * the a include spanned text in annotations + * @param aDocText + * the a doc text */ public UimaSaxVinciFrameBuilder(boolean aSupressDocumentText, boolean aIncludeSpannedTextInAnnotations, String aDocText) { @@ -60,9 +63,12 @@ public class UimaSaxVinciFrameBuilder extends SaxVinciFrameBuilder { /** * Overridden to supress document content and include annotation spans. * - * @param aFrameName the a frame name - * @param aAttributes the a attributes - * @param aContentBuf the a content buf + * @param aFrameName + * the a frame name + * @param aAttributes + * the a attributes + * @param aContentBuf + * the a content buf * @return the leaf content * @see SaxVinciFrameBuilder#getLeafContent(String, Attributes, StringBuffer) */ diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/VinciSaxParser.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/VinciSaxParser.java index 7783cae..7ec934d 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/VinciSaxParser.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/VinciSaxParser.java @@ -44,7 +44,8 @@ public class VinciSaxParser { /** * Sets the content handler. * - * @param aHandler the new content handler + * @param aHandler + * the new content handler */ public void setContentHandler(ContentHandler aHandler) { mHandler = aHandler; @@ -53,8 +54,10 @@ public class VinciSaxParser { /** * Parses the. * - * @param aFrame the a frame - * @throws SAXException the SAX exception + * @param aFrame + * the a frame + * @throws SAXException + * the SAX exception */ public void parse(VinciFrame aFrame) throws SAXException { parse(aFrame, true); @@ -63,9 +66,12 @@ public class VinciSaxParser { /** * Parses the. * - * @param aFrame the a frame - * @param aSendStartAndEndDocEvents the a send start and end doc events - * @throws SAXException the SAX exception + * @param aFrame + * the a frame + * @param aSendStartAndEndDocEvents + * the a send start and end doc events + * @throws SAXException + * the SAX exception */ public void parse(VinciFrame aFrame, boolean aSendStartAndEndDocEvents) throws SAXException { if (aSendStartAndEndDocEvents) { @@ -82,8 +88,10 @@ public class VinciSaxParser { /** * Parses the. * - * @param aFrame the a frame - * @throws SAXException the SAX exception + * @param aFrame + * the a frame + * @throws SAXException + * the SAX exception */ protected void _parse(VinciFrame aFrame) throws SAXException { int count = aFrame.getKeyValuePairCount(); diff --git a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/VinciTAEClient.java b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/VinciTAEClient.java index f3da27c..881ae28 100644 --- a/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/VinciTAEClient.java +++ b/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/util/VinciTAEClient.java @@ -34,7 +34,8 @@ public class VinciTAEClient { /** * The main method. * - * @param args the arguments + * @param args + * the arguments */ public static void main(String[] args) { System.out.println("Invoking the service..."); diff --git a/uimaj-adapter-vinci/src/test/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceAdapterTest.java b/uimaj-adapter-vinci/src/test/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceAdapterTest.java index 054ff6e..59a7c8c 100644 --- a/uimaj-adapter-vinci/src/test/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceAdapterTest.java +++ b/uimaj-adapter-vinci/src/test/java/org/apache/uima/adapter/vinci/VinciAnalysisEngineServiceAdapterTest.java @@ -28,7 +28,6 @@ import org.apache.uima.resource.ResourceInitializationException; import org.apache.uima.resource.URISpecifier; import org.junit.jupiter.api.Test; - // TODO: Auto-generated Javadoc /** * The Class VinciAnalysisEngineServiceAdapterTest. @@ -38,37 +37,38 @@ public class VinciAnalysisEngineServiceAdapterTest { /** * Test initialize. * - * @throws ResourceInitializationException the resource initialization exception + * @throws ResourceInitializationException + * the resource initialization exception */ - @Test - public void testInitialize() throws ResourceInitializationException { - // Don't want an actual network dependency so will test only with services that - // don't exist. The tests just make sure that the AnalysisEngineServiceAdapter.initialize - // method just returns false when passed an inappropriate specifier and throws an - // exception when passed an appropriate specifier. + @Test + public void testInitialize() throws ResourceInitializationException { + // Don't want an actual network dependency so will test only with services that + // don't exist. The tests just make sure that the AnalysisEngineServiceAdapter.initialize + // method just returns false when passed an inappropriate specifier and throws an + // exception when passed an appropriate specifier. - final String NON_EXISTENT_URI = "this.service.does.not.exit.at.least.i.hope.not"; - URISpecifier uriSpec = UIMAFramework.getResourceSpecifierFactory().createURISpecifier(); - uriSpec.setUri(NON_EXISTENT_URI); + final String NON_EXISTENT_URI = "this.service.does.not.exit.at.least.i.hope.not"; + URISpecifier uriSpec = UIMAFramework.getResourceSpecifierFactory().createURISpecifier(); + uriSpec.setUri(NON_EXISTENT_URI); - // test incorrect protocol - uriSpec.setProtocol(Constants.PROTOCOL_SOAP); - VinciAnalysisEngineServiceAdapter adapter = new VinciAnalysisEngineServiceAdapter(); - boolean result = adapter.initialize(uriSpec, null); - assertThat(result).isFalse(); + // test incorrect protocol + uriSpec.setProtocol(Constants.PROTOCOL_SOAP); + VinciAnalysisEngineServiceAdapter adapter = new VinciAnalysisEngineServiceAdapter(); + boolean result = adapter.initialize(uriSpec, null); + assertThat(result).isFalse(); - // test correct protocol - VinciAnalysisEngineServiceAdapter adapter2 = new VinciAnalysisEngineServiceAdapter(); - uriSpec.setProtocol(Constants.PROTOCOL_VINCI); - uriSpec.setResourceType(URISpecifier.RESOURCE_TYPE_ANALYSIS_ENGINE); + // test correct protocol + VinciAnalysisEngineServiceAdapter adapter2 = new VinciAnalysisEngineServiceAdapter(); + uriSpec.setProtocol(Constants.PROTOCOL_VINCI); + uriSpec.setResourceType(URISpecifier.RESOURCE_TYPE_ANALYSIS_ENGINE); - assertThatExceptionOfType(ResourceInitializationException.class) - .isThrownBy(() -> adapter2.initialize(uriSpec, null)); + assertThatExceptionOfType(ResourceInitializationException.class) + .isThrownBy(() -> adapter2.initialize(uriSpec, null)); - // test correct protocol and no component type - uriSpec.setResourceType(null); - VinciAnalysisEngineServiceAdapter adapter1 = new VinciAnalysisEngineServiceAdapter(); - assertThatExceptionOfType(ResourceInitializationException.class) - .isThrownBy(() -> adapter1.initialize(uriSpec, null)); - } + // test correct protocol and no component type + uriSpec.setResourceType(null); + VinciAnalysisEngineServiceAdapter adapter1 = new VinciAnalysisEngineServiceAdapter(); + assertThatExceptionOfType(ResourceInitializationException.class) + .isThrownBy(() -> adapter1.initialize(uriSpec, null)); + } }
