Kaynağa Gözat

HPCC-14246 Update based on review

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Anthony Fishbeck 9 yıl önce
ebeveyn
işleme
871483924e

+ 2 - 2
esp/esdllib/esdl_def.cpp

@@ -2095,7 +2095,7 @@ static bool type_list_inited = false;
 typedef MapStringTo<EsdlBasicElementType> EsdlTypeList;
 static EsdlTypeList esdlTypeList;
 
-void init_type_list_v2(EsdlTypeList &list)
+void init_type_list(EsdlTypeList &list)
 {
     static CriticalSection crit;
     CriticalBlock block(crit);
@@ -2177,7 +2177,7 @@ void init_type_list_v2(EsdlTypeList &list)
 esdl_decl void initEsdlTypeList()
 {
     if (!type_list_inited)
-        init_type_list_v2(esdlTypeList);
+        init_type_list(esdlTypeList);
 }
 
 esdl_decl EsdlBasicElementType esdlSimpleType(const char *type)

+ 0 - 4
esp/esdllib/esdl_def.hpp

@@ -19,9 +19,6 @@
 #define ESDLDEF_HPP
 
 #include "jliball.hpp"
-//#include "esp.hpp"
-//#include "soapesp.hpp"
-//#include "ws_ecl_client.hpp"
 #include "jqueue.tpp"
 
 #ifdef _WIN32
@@ -223,5 +220,4 @@ esdl_decl void releaseEsdlDefinition(const char *esdl_ns=NULL);
 esdl_decl void initEsdlTypeList();
 esdl_decl EsdlBasicElementType esdlSimpleType(const char *type);
 
-
 #endif //ESDLDEF_HPP

+ 1 - 0
esp/services/esdl_svc_engine/CMakeLists.txt

@@ -56,6 +56,7 @@ include_directories (
          ${HPCC_SOURCE_DIR}/rtl/include
          ${HPCC_SOURCE_DIR}/esp/esdllib
          ${HPCC_SOURCE_DIR}/esp/logging
+         ${CMAKE_BINARY_DIR}
     )
 
 ADD_DEFINITIONS( -D_USRDLL )

+ 14 - 10
esp/services/esdl_svc_engine/esdl_binding.cpp

@@ -33,6 +33,7 @@
 #include "thorxmlwrite.hpp" //JSON WRITER
 #include "workunit.hpp"
 #include "wuwebview.hpp"
+#include "build-config.h"
 
 /*
  * trim xpath at first instance of element
@@ -197,7 +198,6 @@ bool EsdlServiceImpl::loadLogggingManager()
     return true;
 }
 
-
 void EsdlServiceImpl::init(const IPropertyTree *cfg,
                            const char *process,
                            const char *service)
@@ -232,7 +232,7 @@ void EsdlServiceImpl::init(const IPropertyTree *cfg,
         throw MakeStringException(-1, "Could not access ESDL service configuration: esp process '%s' service name '%s'", process, service);
 }
 
-void EsdlServiceImpl::configureJavaMethod(const char *method, IPropertyTree &entry)
+void EsdlServiceImpl::configureJavaMethod(const char *method, IPropertyTree &entry, const char *classPath)
 {
     const char *javaScopedMethod = entry.queryProp("@javamethod");
     if (!javaScopedMethod || !*javaScopedMethod)
@@ -258,7 +258,8 @@ void EsdlServiceImpl::configureJavaMethod(const char *method, IPropertyTree &ent
 
     if (!javaServiceMap.getValue(javaScopedClass))
     {
-        Owned<IEmbedServiceContext> srvctx = ensureJavaEmbeded().createServiceContext(javaScopedClass, EFimport, "classpath=/opt/HPCCSystems/classes");
+        VStringBuffer classPathOption("classpath=%s", classPath);
+        Owned<IEmbedServiceContext> srvctx = ensureJavaEmbeded().createServiceContext(javaScopedClass, EFimport, classPathOption);
         javaServiceMap.setValue(javaScopedClass, srvctx.getClear());
     }
 }
@@ -306,6 +307,13 @@ void EsdlServiceImpl::configureTargets(IPropertyTree *cfg, const char *service)
         ForEach(*itns)
             m_pServiceMethodTargets->addPropTree("Target", createPTreeFromIPT(&itns->query()));
 
+        StringBuffer classPath;
+        Owned<IProperties> envConf = createProperties(CONFIG_DIR PATHSEPSTR "environment.conf", true);
+        if (envConf && envConf->hasProp("classpath"))
+            envConf->getProp("classpath", classPath);
+        else
+            classPath.append(INSTALL_DIR).append(PATHSEPCHAR).append("classes");
+
         Owned<IPropertyTreeIterator> iter = m_pServiceMethodTargets->getElements("Target");
         ForEach(*iter)
         {
@@ -314,7 +322,7 @@ void EsdlServiceImpl::configureTargets(IPropertyTree *cfg, const char *service)
                 throw MakeStringException(-1, "ESDL binding - found target method entry without name!");
             const char *type = iter->query().queryProp("@querytype");
             if (type && strieq(type, "java"))
-                configureJavaMethod(method, iter->query());
+                configureJavaMethod(method, iter->query(), classPath);
             else
                 configureUrlMethod(method, iter->query());
         }
@@ -1036,10 +1044,6 @@ void EsdlBindingImpl::initEsdlServiceInfo(IEsdlDefService &srvdef)
     xsltpath.append("xslt/esxdl2xsd.xslt");
     m_xsdgen->loadTransform(xsltpath, xsdparams, EsdlXslToXsd );
     m_xsdgen->loadTransform(xsltpath, wsdlparams, EsdlXslToWsdl );
-
-
-//   xsltpath.set(getCFD()).append("xslt/esdl2java_srvbase.xslt");
-//   m_xsdgen->loadTransform(xsltpath, NULL, EsdlXslToJavaPlugin );
 }
 
 void EsdlBindingImpl::getSoapMessage(StringBuffer& soapmsg,
@@ -1490,11 +1494,11 @@ int EsdlBindingImpl::onJavaPlugin(IEspContext &context,
         }
         catch (IException *E)
         {
-            throw makeWsException(*E, WSERR_CLIENT , "ESP");
+            throw makeWsException(*E, WSERR_CLIENT , "ESDL");
         }
         catch (...)
         {
-            throw makeWsException(ERR_ESDL_BINDING_INTERNERR, WSERR_CLIENT , "ESP", "Could not generate JavaPlugin for this service." );
+            throw makeWsException(ERR_ESDL_BINDING_INTERNERR, WSERR_CLIENT , "ESDL", "Could not generate JavaPlugin for this service." );
         }
         response->setStatus(HTTP_STATUS_OK);
     }

+ 1 - 1
esp/services/esdl_svc_engine/esdl_binding.hpp

@@ -127,7 +127,7 @@ public:
     virtual bool loadLogggingManager();
     virtual void init(const IPropertyTree *cfg, const char *process, const char *service);
     virtual void configureTargets(IPropertyTree *cfg, const char *service);
-    void configureJavaMethod(const char *method, IPropertyTree &entry);
+    void configureJavaMethod(const char *method, IPropertyTree &entry, const char *classPath);
     void configureUrlMethod(const char *method, IPropertyTree &entry);
 
     virtual void handleServiceRequest(IEspContext &context, IEsdlDefService &srvdef, IEsdlDefMethod &mthdef, Owned<IPropertyTree> &tgtcfg, Owned<IPropertyTree> &tgtctx, const char *ns, const char *schema_location, IPropertyTree *req, StringBuffer &out, StringBuffer &logdata, unsigned int flags);

+ 1 - 1
esp/xslt/esdl2java_srvbase.xslt

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
 ##############################################################################
-#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
+#    HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems.
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
 #    you may not use this file except in compliance with the License.

+ 0 - 170
esp/xslt/esdl2javaplugin.xslt

@@ -1,170 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-##############################################################################
-#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License");
-#    you may not use this file except in compliance with the License.
-#    You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#    See the License for the specific language governing permissions and
-#    limitations under the License.
-##############################################################################
--->
-
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
-    <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
-
-    <xsl:template match="esxdl">
-import java.util.*;
-        <!--xsl:apply-templates select="EsdlEnumType" /-->
-        <xsl:apply-templates select="EsdlStruct"/>
-        <xsl:apply-templates select="EsdlRequest"/>
-        <xsl:apply-templates select="EsdlResponse"/>
-        <xsl:apply-templates select="EsdlService"/>
-
-    </xsl:template>
-
-    <xsl:template match="EsdlStruct|EsdlRequest|EsdlResponse">
-public class <xsl:value-of select="@name"/><xsl:if test="@base_type"> extends <xsl:value-of select="@base_type"/></xsl:if>
-{
-<xsl:apply-templates select="EsdlElement|EsdlArray|EsdlEnum"/>
-}
-    </xsl:template>
-
-    <xsl:template name="ouputJavaPrimitive">
-        <xsl:param name="typename"/>
-        <xsl:choose>
-            <xsl:when test="$typename='bool'"><xsl:value-of select="'Boolean'"/></xsl:when>
-            <xsl:when test="$typename='boolean'"><xsl:value-of select="'Boolean'"/></xsl:when>
-            <xsl:when test="$typename='decimal'"><xsl:value-of select="'BigDecimal'"/></xsl:when>
-            <xsl:when test="$typename='float'"><xsl:value-of select="'Float'"/></xsl:when>
-            <xsl:when test="$typename='double'"><xsl:value-of select="'Double'"/></xsl:when>
-            <xsl:when test="$typename='integer'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='int64'"><xsl:value-of select="'BigInteger'"/></xsl:when>
-            <xsl:when test="$typename='long'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='int'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='short'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='nonPositiveInteger'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='negativeInteger'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='nonNegativeInteger'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='unsigned'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='unsignedLong'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='unsignedInt'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='unsignedShort'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='unsignedByte'"><xsl:value-of select="'Byte'"/></xsl:when>
-            <xsl:when test="$typename='positiveInteger'"><xsl:value-of select="'Integer'"/></xsl:when>
-            <xsl:when test="$typename='base64Binary'"><xsl:value-of select="'String'"/></xsl:when>
-            <xsl:when test="$typename='string'"><xsl:value-of select="'String'"/></xsl:when>
-            <xsl:when test="$typename='xsdString'"><xsl:value-of select="'String'"/></xsl:when>
-            <xsl:when test="$typename='normalizedString'"><xsl:value-of select="'String'"/></xsl:when>
-            <xsl:when test="$typename='binary'"><xsl:value-of select="'Byte'"/></xsl:when>
-            <xsl:otherwise><xsl:value-of select="$typename"/></xsl:otherwise>
-        </xsl:choose>
-    </xsl:template>
-
-    <xsl:template match="EsdlElement|EsdlArray|EsdlEnum">
-        <xsl:variable name="enum_type" select="@enum_type"/>
-        <xsl:text>    public </xsl:text>
-
-        <xsl:variable name="primitive">
-	        <xsl:call-template name="ouputJavaPrimitive">
-	           <xsl:with-param name="typename">
-			<xsl:choose>
-			    <xsl:when test="@enum_type"><xsl:value-of select="esxdl/EsdlEnumType[@name=$enum_type]/@base_type"/></xsl:when>
-			    <xsl:when test="@type"><xsl:value-of select="@type"/></xsl:when>
-			    <xsl:when test="@complex_type"><xsl:value-of select="@complex_type"/></xsl:when>
-			</xsl:choose>
-	           </xsl:with-param>
-	        </xsl:call-template>
-        </xsl:variable>
-	<xsl:value-of select="$primitive"/>
-        <xsl:text> </xsl:text>
-        <xsl:value-of select="@name"/>
-        <xsl:choose>
-            <xsl:when test="@type='binary'"><xsl:value-of select="'[]'"/></xsl:when>
-            <xsl:when test="local-name()='EsdlArray'"><xsl:value-of select="'[]'"/></xsl:when>
-            <xsl:when test="@default">
-		<xsl:text> = new </xsl:text><xsl:value-of select="$primitive"/><xsl:text>(</xsl:text>
-		<xsl:choose>
-	            <xsl:when test="$primitive='String'">"<xsl:value-of select="@default"/>"</xsl:when>
-	            <xsl:when test="$primitive='Boolean'">
-			<xsl:choose>
-			    <xsl:when test="@default='true'"><xsl:value-of select="'true'"/></xsl:when>
-			    <xsl:when test="@default='1'"><xsl:value-of select="'true'"/></xsl:when>
-			    <xsl:otherwise><xsl:value-of select="'false'"/></xsl:otherwise>
-	                </xsl:choose>
-                    </xsl:when>
-	            <xsl:otherwise><xsl:value-of select="@default"/></xsl:otherwise>
-                </xsl:choose>
-		<xsl:text>)</xsl:text>
-            </xsl:when>
-        </xsl:choose>
-        <xsl:text>;
-</xsl:text>
-    </xsl:template>
-
-    <xsl:template match="EsdlService">
-public class <xsl:value-of select="@name"/>
-{
-        <xsl:for-each select="EsdlMethod">
-    public void <xsl:value-of select="@name"/>(<xsl:value-of select="@request_type"/> request, <xsl:value-of select="@response_type"/> response);
-        </xsl:for-each>
-}
-    </xsl:template>
-    <!--xsl:template match="EsdlEnumItem">
-        <xsd:enumeration>
-            <xsl:attribute name="value"><xsl:value-of select="@enum"/></xsl:attribute>
-        </xsd:enumeration>
-    </xsl:template>
-
-    <xsl:template match="EsdlEnumType">
-        <xsd:simpleType>
-            <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
-            <xsl:if test="(EsdlEnumItem[@desc]) and EsdlEnumItem/@desc!=''">
-                <xsl:if test="not($no_annot_Param) or boolean($all_annot_Param)">
-                    <xsd:annotation>
-                        <xsd:appinfo>
-                            <xsl:apply-templates select="EsdlEnumItem" mode="annotation" />
-                        </xsd:appinfo>
-                    </xsd:annotation>
-                </xsl:if>
-            </xsl:if>
-            <xsd:restriction>
-                <xsl:attribute name="base">xsd:<xsl:value-of select="@base_type"/></xsl:attribute>
-                <xsl:apply-templates select="EsdlEnumItem"/>
-            </xsd:restriction>
-        </xsd:simpleType>
-    </xsl:template>
-
-    <xsl:template match="EsdlEnum">
-        <xsd:element>
-            <xsl:choose>
-                <xsl:when test="@required"></xsl:when>
-                <xsl:otherwise>
-                    <xsl:attribute name="minOccurs">0</xsl:attribute>
-                </xsl:otherwise>
-            </xsl:choose>
-            <xsl:attribute name="name">
-                <xsl:choose>
-                    <xsl:when test="@xml_tag"><xsl:value-of select="@xml_tag" /></xsl:when>
-                    <xsl:otherwise><xsl:value-of select="@name" /></xsl:otherwise>
-                </xsl:choose>
-            </xsl:attribute>
-            <xsl:attribute name="type">
-                <xsl:choose>
-                    <xsl:when test="@xsd_type"><xsl:value-of select="@xsd_type" /></xsl:when>
-                    <xsl:when test="@enum_type">tns:<xsl:value-of select="@enum_type" /></xsl:when>
-                </xsl:choose>
-            </xsl:attribute>
-            <xsl:if test="@default or (@default='')">
-                <xsl:attribute name="default"><xsl:value-of select="@default"/></xsl:attribute>
-            </xsl:if>
-        </xsd:element>
-    </xsl:template-->
-</xsl:stylesheet>

+ 17 - 0
initfiles/examples/EsdlExample/ReadMeFirst.txt

@@ -1,3 +1,20 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
 You must have configured an instance of dynamicEsdl in this environment.  Either through configmgr or by editing environment.xml.  This document assumes dynamicESDL is running on "myesp" port 8088.
 
 Run the following from the node running the eclwatch server:

+ 4 - 6
plugins/javaembed/javaembed.cpp

@@ -1304,10 +1304,6 @@ public:
         writeChildren(JNIenv->GetObjectClass(fieldObj), fieldObj, defStruct);
         writer.outputEndNested(fieldname);
     }
-    void writeSimpleArray(jclass parentClass, jobject parentObject, IEsdlDefObject &defObject)
-    {
-        //tbd
-    }
     void writeComplexArray(jclass parentClass, jobject parentObject, IEsdlDefObject &defObject)
     {
         IEsdlDefStruct *defStruct = esdl.queryStruct(defObject.queryProp("type"));
@@ -2025,7 +2021,7 @@ public:
     }
     IXmlWriterExt & clear()
     {
-        UNIMPLEMENTED;
+        throwUnexpected();
     }
     virtual size32_t length() const
     {
@@ -2033,10 +2029,12 @@ public:
     }
     virtual const char *str() const
     {
-        UNIMPLEMENTED;
+        throwUnexpected();
     }
     virtual void rewindTo(unsigned int prevlen)
     {
+        //needs to be a no-op because it is used, but the way its used to trim empty xml sections I think we're fairly safe.
+        //revisit cleaning up any empty objects later.
     }
     inline IEsdlDefStruct *queryCurrentEsdlStruct()
     {

+ 0 - 2
tools/esdlcmd/esdlcmd_core.cpp

@@ -824,7 +824,6 @@ public:
     void setFlag( unsigned f ) { optFlags |= f; }
     void unsetFlag( unsigned f ) { optFlags &= ~f; }
 
-
 public:
     StringAttr optService;
     StringAttr optXsltPath;
@@ -872,6 +871,5 @@ IEsdlCommand *createCoreEsdlCommand(const char *cmdname)
     if (strieq(cmdname, "LIST-BINDINGS"))
         return new EsdlListESDLBindingsCmd();
 
-
     return NULL;
 }