<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Towards a Knowledge Interface for Java Applications</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Mario Scrocca</string-name>
          <email>mario.scrocca@cefriel.com</email>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Politecnico di Milano</institution>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Tartu, Data System Group</institution>
          ,
          <country country="EE">Estonia</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>and Riccardo Tommasini</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>We are witnessing the spread of data-driven organizations. In particular, enterprise software is migrating from legacy monolithic data systems to microservices, which embrace the distributed nature of data. Despite o ering many bene ts, microservices pose several challenges in the development and maintenance of information systems. Techniques like Domain-Driven Design and Data Mesh emerged to ease data and system integration by infusing domain knowledge within the developing process. In this scenario, knowledge representation and reasoning (KRR) can come to the rescue. Thus, in this paper, we present the Java Knowledge Interface (JKI), whose goal is allowing Java programmers to semantically lift the applications' data model (compile time) and state (runtime) with respect to an OWL2 ontology.</p>
      </abstract>
      <kwd-group>
        <kwd>Poster</kwd>
        <kwd>Knowledge Representation</kwd>
        <kwd>Semantic Debugging</kwd>
        <kwd>Semantic Programming</kwd>
        <kwd>Semantic Microservices</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        We are witnessing the spread of data-driven organizations. In particular,
enterprise software is migrating from legacy monolithic data systems to
microservices, which embrace the distributed nature of data. Despite o ering many
bene ts, microservices pose several challenges in the development and
maintenance of information systems. Microservices have to speed up the velocity of the
software lifecycle, supported by the adoption of novel techniques for continuous
delivery and integration. Moreover, di erent independent teams often develop
microservices, which do not necessarily share the exact requirements. In
practice, the adoption of microservices may lead to small incremental changes that
can integrate di erent data products [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. Thus, techniques like Domain-Driven
Design [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], Event Sourcing, and Data Mesh3 evolved to ease data and system
integration by infusing domain knowledge within the developing process.
      </p>
      <p>Copyright © 2021 for this paper by its authors. Use permitted under Creative
Commons License Attribution 4.0 International (CC BY 4.0).
3 https://martinfowler.com/articles/data-mesh-principles.html</p>
      <p>
        In this scenario, knowledge representation and reasoning (KRR) can come
to the rescue. Indeed, ontologies can model the application domains to ensure
semantic interoperability among di erent data systems. Intuitively, the
combination of KRR and software engineering (SE) have been studied already [
        <xref ref-type="bibr" rid="ref4 ref5 ref7">4,5,7</xref>
        ]4.
Leinberger et al. [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] studied the usage of SHACL for type checking code that
queries RDF graphs. More recently, Kamburjan et al. [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] discussed the
advantages of semantically lifting the state of a software program through ontologies.
      </p>
      <p>
        In this paper, we present the Java Knowledge Interface (JKI), which falls
into Ontology-driven development [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. The goal of JKI is to allow Java
programmers to semantically lift the applications' data model and state (runtime) with
respect to an OWL2 ontology. Moreover, JKI allows querying and reasoning
for the current application state as a knowledge graph (KG). We demonstrated
the feasibility and relevance of JKI developing an initial proof-of-concept that
exploits a Java Debug Interface (JDI) and OWL API.
      </p>
      <p>Outline. Section 2 de nes the proposed JKI. Section 3 describes the
implemented proof of concept. Section 4 draws the conclusions.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Java Knowledge Interface</title>
      <p>
        In this section, we present the Java Knowledge Interface (JKI). Figure 1 shows
an overview of JKI. As mentioned before, JKI aims at running a multitude of
reasoning tasks over Java applications. In particular, JKI must enable two
inference scenarios: (1) Static, i.e., applying a given reasoning task to the application
data model at compile time. Java applications rely on a speci c data model
describing the domain addressed by the software program. JKI requires to map
relevant Java classes (i.e., the application data model) to corresponding OWL
classes in the given TBox. Notably, not all classes of the application model need
to be mapped to the ontology. (2) Dynamic, i.e., executing a given reasoning
task over the application state at runtime. Given a generic running Java
application, its runtime state is represented by instances of classes of the model
that are handled and interconnected in-memory (heap and stack ). JKI should be
4 we invite the reader to consult [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] for a survey of di erent approaches
responsible for connecting to the running Java application, lifting the state
integrating it in a KG and execute di erent reasoning tasks on it. The JKI should
implement Semantic State Lifting by mapping the active class instances to the
corresponding OWL individuals. In practice, JKI should allow checking that no
inconsistencies are generated at runtime considering one or more snapshots of
the application state, potentially enriched with external domain knowledge.
      </p>
      <p>The obtained KG o ers an abstraction to reason on the domain logic
coherence over the implementation details of one or more applications. In particular,
we distinguish two scenarios (A) Intra-Application Inference, where JKI is
executing a given reasoning task over a KG resulting from the state lifting of an
application. (B) Inter-Application Inference, where JKI is executing a given
reasoning task over a KG resulting from the integration of the lifted state of n
di erent applications. Intuitively, all four combinations are possible. Indeed, the
JKI users might be interested to verify the compliance of a single application
data model to the ontological speci cation (1A) or check if a static alignment
exists across applications (e.g., di erent microservices in a distributed
architecture) (1B). On the other hand, the JKI users might want to reason about a
single application state (2A) or the integration of many (2B).
3</p>
    </sec>
    <sec id="sec-3">
      <title>Proof of Concepts</title>
      <p>
        To validate JKI we developed a proof-of-concept (POC)5 that exploits the Java
Debug Interface (JDI)6, and OWL API [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].
      </p>
      <p>The POC consists of two examples, i.e., app.artmarket and app.eshop,
which respectively represents a paint shop and e-commerce. These examples are
designed to show the bene ts of the lifted states for debugging the application
state. The E-Shop demo shows how the integration between the application
state and external data allows validating (consistency checking) the discounts.
For example, including in the ontology, an axiom about discounts available only
to particular customers allows evaluating, at runtime, the validity (consistency)
of the application state. The Art Market demo shows how an ontology allows
reasoning over the knowledge that is not explicitly represented in the classes.
For example, each individual of the class Artist associated to a Paint can be
axiomatically inferenced as an instance of the Painter subclass, thus enabling
querying considering external knowledge about Painters.</p>
      <p>The applications data models are made available to JKI using a set of maps
that are con gured to bind IRIs of the ontology to Java classes (to generate
individuals) and their elds (to generate data and object properties). Multiple
property relations from the same instance are stored in named lists.</p>
      <p>The JKI is implemented using the JDI API to connect to the Java
application and place breakpoints to collect state snapshots. Indeed, using JDI we
do not need to modify the monitored Java application. The only requirement
is to run the application in debug mode, where it is possible to receive updates
5 https://github.com/marioscrock/java-reasoning
6 https://docs.oracle.com/javase/8/docs/jdk/api/jpda/jdi/
from the JVM via socket. Once reached a breakpoint event, the JVM execution
is suspended and a JKI component (implementing the InspectToAxiom
interface) incrementally inspects the application state and generates ABox axioms
considering a given con guration.</p>
      <p>Using OWL API, the POC allows its user to programmatically: (i) add other
axioms to the generated KG, and (ii) answer Description Logic queries on the
KG. The POC periodically runs a reasoning routine every time the JVM is
suspended for a breakpoint. A bu er is kept to ensure that previously added
ABox axioms (generated by the last inspection of application instances) are
deleted and only the active instances are left in the KG.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Conclusion and Future Works</title>
      <p>
        In this paper, we presented a proof-of-concept implementation of a Knowledge
Interface for Java programs. JKI supports two kinds of reasoning, i.e., static
reasoning about the application data model at compile-time, and dynamic reasoning
on the application state at runtime. We showcased the feasibility of JKI with
two examples, i.e., an Art Market and an E-Shop. As future work, we plan to
(i) design an annotation-based mechanism to map the application data model to
the OWL classes, (ii) enable the usage of SHACL shapes to validate the
semantically lifted state of the application, (iii) integrate other forms of application
data within the KG, i.e., traces, logs, and metrics [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], (iv) integrate RSP4J [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]
within JKI for stream reasoning about application state changes. Finally, we will
investigate the factors impacting the performances of the JKI.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Evans</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Evans</surname>
            ,
            <given-names>E.J.</given-names>
          </string-name>
          :
          <article-title>Domain-driven design: tackling complexity in the heart of software</article-title>
          . Addison-Wesley
          <string-name>
            <surname>Professional</surname>
          </string-name>
          (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Happel</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Maalej</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Seedorf</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Applications of ontologies in collaborative software development</article-title>
          . In:
          <article-title>Mistr k, I</article-title>
          ., van der Hoek,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Grundy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            ,
            <surname>Whitehead</surname>
          </string-name>
          ,
          <string-name>
            <surname>J</surname>
          </string-name>
          . (eds.) Collaborative Software Engineering. Springer (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Horridge</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bechhofer</surname>
            ,
            <given-names>S.:</given-names>
          </string-name>
          <article-title>The OWL API: A java API for OWL ontologies</article-title>
          .
          <source>Semantic Web</source>
          <volume>2</volume>
          (
          <issue>1</issue>
          ),
          <volume>11</volume>
          {
          <fpage>21</fpage>
          (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Kamburjan</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Klungre</surname>
            ,
            <given-names>V.N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schlatte</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Johnsen</surname>
            ,
            <given-names>E.B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Giese</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Programming and debugging with semantically lifted states</article-title>
          .
          <source>In: European Semantic Web Conference</source>
          . pp.
          <volume>126</volume>
          {
          <fpage>142</fpage>
          . Springer (
          <year>2021</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Leinberger</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Seifer</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Schon</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          , Lammel, R.,
          <string-name>
            <surname>Staab</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Type checking program code using SHACL</article-title>
          . In: ISWC - New Zealand,
          <source>Proceedings. LNCS</source>
          , Springer (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Overeem</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Spoor</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Jansen</surname>
            ,
            <given-names>S.:</given-names>
          </string-name>
          <article-title>The dark side of event sourcing: Managing data conversion</article-title>
          . In: SANER, Klagenfurt, Austria. IEEE Computer Society (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Puleston</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Parsia</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cunningham</surname>
            ,
            <given-names>J.A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rector</surname>
            ,
            <given-names>A.L.</given-names>
          </string-name>
          :
          <article-title>Integrating objectoriented and ontological representations: A case study in java and OWL</article-title>
          . In: ISWC, Germany,
          <source>October 26-30</source>
          ,
          <year>2008</year>
          . Proceedings. LNCS, Springer (
          <year>2008</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Scrocca</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tommasini</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Margara</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Valle</surname>
            ,
            <given-names>E.D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sakr</surname>
            ,
            <given-names>S.:</given-names>
          </string-name>
          <article-title>The Kaiju project: enabling event-driven observability</article-title>
          . In: DEBS: Montreal, Canada. ACM (
          <year>2020</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Tommasini</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bonte</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ongenae</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Valle</surname>
            ,
            <given-names>E.D.:</given-names>
          </string-name>
          <article-title>RSP4J: an API for RDF stream processing</article-title>
          . In: ESWC,
          <string-name>
            <surname>Virtual</surname>
            <given-names>Event</given-names>
          </string-name>
          ,
          <source>Proceedings. LNCS</source>
          , Springer (
          <year>2021</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>