= HSQLDB Manager

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.


The `HsqlDbManagerMenu` provides a single menu item to open up the HSQLDB manager.
This is only enabled for prototyping, and if HSQLDB is detected in the underlying JDBC URL.

The menu appears under the "Prototyping" menu.

NOTE: the HSQLDB Manager is a Swing application, so this can only be used in a local setting.


== Maven Configuration

include::docs:mavendeps:partial$setup-and-configure-dependencyManagement.adoc[leveloffset=+2]

In addition, add a section for the BOM of all the testing support libraries:

[source,xml,subs="attributes+"]
.pom.xml
----
<dependencyManagement>
    <dependencies>
        <dependency>
        	<groupId>org.apache.isis.testing</groupId>
	        <artifactId>isis-testing</artifactId>
            <scope>import</scope>
            <type>pom</type>
            <version>{page-isisrel}</version>
        </dependency>
    </dependencies>
</dependencyManagement>
----

[#dependencies]
=== Dependencies

In the domain module(s) of your application, add the following dependency:

[source,xml]
.pom.xml
----
<dependencies>
    <dependency>
        <groupId>org.apache.isis.testing</groupId>
        <artifactId>isis-testing-h2console-ui</artifactId>
    </dependency>
</dependencies>
----

=== Update AppManifest

In your application's `AppManifest` (top-level Spring `@Configuration` used to bootstrap the app), import the `HsqlDbManagerMenu` module:

[source,java]
.AppManifest.java
----
@Configuration
@Import({
        ...
        HsqlDbManagerMenu.class,
        ...
})
public class AppManifest {
}
----


== API & Implementation

The API of the service is:

[source,java]
----
public class HsqlDbManagerMenu {
    public void hsqlDbManager() { /* ... */ }
}
----

Note that this launches the manager on the same host that the webapp runs, and so is only appropriate to use when running on `localhost`.


== Disabling/hiding the menu

The menu can be hidden or disabled by subscribing to its domain event, eg:

[source,java]
----
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;

@Service
public class HideHsqlDbManagerMenu {

    @EventListener(HsqlDbManagerMenu.ActionDomainEvent.class)
    public void on(HsqlDbManagerMenu.ActionDomainEvent ev) {
        ev.hide();
    }
}
----
