-
Notifications
You must be signed in to change notification settings - Fork 2
SolarNet Development Guide
This guide explains how to setup a development environment for contributing or modifying the SolarNet application code.
The SolarNet project consists of a set of OSGi bundle projects that, when combined and run in an OSGi container, form a complete SolarNet application. Each OSGi bundle comes configured as an Eclipse IDE plug-in project (Eclipse refers to OSGi bundles as "plug-ins" and its OSGi development tools are collectively known as PDE). Although Eclipse is not actually required, the remainder of this guide will describe setting up Eclipse for viewing and running the code for development purposes.
If you haven't already set up your SolarNetwork development environment, go through the Eclipse Setup Guide first, and then return here.
The SolarNet project is contained in the solarnetwork-central repository. You can clone a Git repository by going to Window > Open Perspective > Git Repository Exploring (you may need to choose "Other..." under Open Perspective if Git does not appear there).
- git@github.com:SolarNetwork/solarnetwork-central.git
Note this is in addition to the common repositories mentioned in the Eclipse Setup Guide, which also describes in more detail how to clone repositories in Eclipse.
The SolarNet code is divided into many small projects which follow a Java package-like naming convention using periods between domain names, like net.solarnetwork.central.datum. All SolarNet-specific projects start with new.solarnetwork.central followed by a feature name and then optionally followed by other implementation specific names. Examples of features are:
-
in -
net.solarnetwork.central.in.*- the SolarIn app -
query -
net.solarnetwork.central.query.*- the SolarQuery app -
user -
net.solarnetwork.central.user.*- the SolarUser app
If you are not interested in a particular feature, you can disable all projects whose name starts with that feature by closing them in Eclipse (right-click and choose Close Project.
Some bundles expose properties that can be configured to suit different operating environments. These bundles will always provide default values for the configurable properties, so you only need to create custom properties files if the default values do not match your local environment.
The bundle properties are configured via Java Properties files located in the /solarnetwork-osgi-target/configurations/services directory. If a bundle project exposes configurable properties, it will have an example properties file in the example/configuration directory within that project. These files will have particular names which must not be changed because the bundle will look for its properties file based on the pre-defined name. To customize the properties for a bundle, copy the desired example/configuration/*.properties file into /solarnetwork-osgi-target/configurations/services, rename it to have a .cfg extensions, and then modify the copied file as necessary. The example files will contain all available configurable properties, along with documentation on each property.
For example, the net.solarnetwork.central.in.biz project exposes some configurable properties as detailed in /net.solarnetwork.central.in.biz/example/configuration/net.solarnetwork.central.in.properties. This bundle configures the SolarIn identify information used by the SolarNet for accepting data from SolarNodes. If you want to customize these details in any way, copy this file to /solarnetwork-osgi-target/configurations/services/net.solarnetwork.central.in.cfg and modify it as desired.
SolarNet requires a PostgreSQL database, version 9.1 or higher, to operate. Please note that only version 9.1 has been extensively tested. There are SQL setup scripts to create the initial database tables located in the net.solarnetwork.central.datum project, in the defs/sql/postgres directory. The postgres-init.sql script is designed to be run by the psql utility and create all the necessary database structures used by SolarNet, once a database has been created. For example, to create a new solarnetwork user, new solarnetwork database, and initialize all the necessary structures, you could do the following steps:
createuser -ADEP solarnetwork
createdb -E UNICODE -O solarnetwork solarnetwork
psql -U solarnetwork -d solarnetwork -f postgres-init.sql
PostgreSQL administration is beyond the scope of this article. Please see the PostgreSQL documentation available online for more information.
See the Debugging SolarNetwork with Eclipse page for information on running SolarNetwork applications within Eclipse.