-
Notifications
You must be signed in to change notification settings - Fork 3
1. Semantika Configuration
Every application must have a configuration file in its classpath. It allows you to specify configuration properties such as the JDBC connection settings and resource files location. The configuration describes the essential information for the system to assemble itself. Among other things, the configuration does the following:
- It names the application factory. The factory name serves as a unique identifier for the application.
- It describes the system settings -- the source data, domain model and mapping assertions. These declarations are required by Semantika to help processing the query and getting the result.
- It declares the JDBC connection parameters for the target database.
- It declares the connection pool parameters.
- It declares the JDBC transaction options for query execution.
- It declares the ontology resource that models the application domain as a set of classes and properties and other axioms.
- It declares the mapping resource that associates the domain model with the actual data stored in database.
The snippet below shows the general structure of the configuration file and every element that it can contain.
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE semantika-configuration PUBLIC
"-//Semantika/Semantika Configuration DTD//EN"
"http://www.obidea.com/semantika/dtd/semantika-configuration-1.0.dtd">
<semantika-configuration>
<application-factory name="...">
<data-source>
<property name="connection.url">...</property>
<property name="connection.driver_class">...</property>
<property name="connection.username">...</property>
<property name="connection.password">...</property>
<!-- Parameters for connection pool (since Semantika 1.3) -->
<property name="connection.pool.initial_size">...</property>
<property name="connection.pool.min_size">...</property>
<property name="connection.pool.max_size">...</property>
<property name="connection.pool.timeout">...</property>
<!-- Parameters for JDBC transaction (since Semantika 1.3) -->
<property name="transaction.timeout">...</property>
<property name="transaction.fetch_size">...</property>
<property name="transaction.max_rows">...</property>
</data-source>
<ontology-source resource="..."/>
<mapping-source resource="..."/>
<!-- Input multiple mapping files (since Semantika 1.3) -->
<mapping-source resource="..."/>
<mapping-source resource="..."/>
</application-factory>
</semantika-configuration>
With the XML application.cfg.xml
placed in the application's CLASSPATH, creating Semantika application manager is then as simple as:
ApplicationManager manager =
new ApplicationFactory().configure().createApplicationManager();
Or alternatively you can select a different XML configuration file using:
ApplicationManager manager =
new ApplicationFactory().configure("other/path/location.xml").createApplicationManager();
-
<application-factory>
Describes the setting for the Semantika application factory to prepare and create the application manager. Name the factory using the
name
attribute. -
<data-source>
Specifies the JDBC connection parameters with the following meanings:
-
connection.url
: The URL that identifies the database. In general the URL contains the host name of the server, the port number and the database name. -
connection.driver_class
: The JDBC driver class. -
connection.username
: Database user name. -
connection.password
: Database user password. -
connection.pool.intial_size
: The number of connections when the pool try to acquire upon startup. The value should be betweenmin_size
andmax_size
. -
connection.pool.min_size
: Minimum number of connections in the pool. -
connection.pool.max_size
: Maximum number of connections in the pool. -
connection.pool.timeout
: The time limit for a connection to be removed from the pool due to idle activity (in seconds). Zero means idle connections will never expire. -
transaction.timeout
: The time limit for the JDBC driver will wait for a running statement to complete (in seconds). Zero means there is no limit. -
transaction.fetch_size
: A hint value for JDBC driver should fetch rows per network call. -
transaction.max_rows
: Maximum number of rows that JDBC can obtain. Zero means there is no limit.
-
-
<ontology-source>
Specifies the ontology document at
resource="path/to/file"
. The system only accepts OWL ontology in OWL/XML or OWLFunctional syntax. This parameter is optional thus you can build a system without domain reasoning. -
<mapping-source>
Specifies the mapping document at
resource="path/to/file"
. Set the attributestrict-parsing="false"
to skip the class/property name checking. Note that you MUST set strict-parsing to false when omitting the ontology source. You can specify multiple mapping sources by listing them repeatedly using this element tag.
Starting from Semantika 1.6+, you can create an instance of Semantika application manager by specifying directly the properties and resources to the ApplicationFactory. For example:
ApplicationManager manager = new ApplicationFactory()
.setName("simple-app")
.addProperty(Environment.CONNECTION_URL, "jdbc:mysql://localhost:3306/db")
.addProperty(Environment.CONNECTION_DRIVER, "com.mysql.jdbc.Driver")
.addProperty(Environment.CONNECTION_USERNAME, "user")
.addProperty(Environment.CONNECTION_PASSWORD, "secret")
.setOntologySource("path/to/ontology")
.addMappingSource("path/to/mapping", false)
.createApplicationManager();
The output will be the same as using the XML configuration file.
Join the user community or follow the development on Twitter @obda_semantika