Skip to content

Commit

Permalink
Lots of changes, mainly VMSee related.
Browse files Browse the repository at this point in the history
  • Loading branch information
brett-smith committed Jun 3, 2024
1 parent c45f84b commit 89095a8
Show file tree
Hide file tree
Showing 27 changed files with 506 additions and 78 deletions.
10 changes: 8 additions & 2 deletions config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<artifactId>jenny-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jenny-product</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sshtools</groupId>
Expand All @@ -45,8 +51,8 @@
<!-- Required -->
<dependency>
<groupId>com.sshtools</groupId>
<artifactId>jini</artifactId>
<version>0.2.2</version>
<artifactId>jini-config</artifactId>
<version>0.3.3-SNAPSHOT</version>
</dependency>

</dependencies>
Expand Down
27 changes: 26 additions & 1 deletion config/src/main/java/com/sshtools/jenny/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package com.sshtools.jenny.config;

import static com.sshtools.bootlace.api.PluginContext.$;

import java.io.Closeable;
import java.io.IOException;
import java.io.StringReader;
import java.io.UncheckedIOException;
Expand All @@ -38,26 +41,34 @@
import com.sshtools.bootlace.api.Plugin;
import com.sshtools.bootlace.api.PluginContext;
import com.sshtools.jenny.api.ApiLog;
import com.sshtools.jenny.product.Product;
import com.sshtools.jini.INI;
import com.sshtools.jini.INIReader;
import com.sshtools.jini.INIWriter;
import com.sshtools.jini.config.INISet;

public class Config implements Plugin {

private static final String CONFIG_APP_ID = "jenny";

private final static Log LOG = Logs.of(ApiLog.CONFIG);

public interface Handle {
public interface Handle extends Closeable {

INI ini();

void store();

@Override
void close();
}

private record Key(Plugin plugin, Scope scope) {
}

private final Product product = $().plugin(Product.class);

@Deprecated
private final Map<Key, Handle> config = new ConcurrentHashMap<>();
private URLClassLoader bundleLoader;
private final ResourceBundle emptyBundle;
Expand Down Expand Up @@ -88,7 +99,16 @@ public ResourceBundle bundle(Plugin plugin, Locale locale) {
return emptyBundle;
}
}

public INISet.Builder defaultConfig() {
return new INISet.Builder(product.info().app());
}

public INISet.Builder configBuilder(String name) {
return new INISet.Builder(name).withApp(product.info().app());
}

@Deprecated
public Handle config(Plugin plugin, Scope scope) {

synchronized (config) {
Expand Down Expand Up @@ -122,6 +142,11 @@ public INI ini() {
public String toString() {
return iniFile.toString();
}

@Override
public void close() {
config.remove(key);
}
};
config.put(key, cfg);
}
Expand Down
3 changes: 3 additions & 0 deletions config/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
opens com.sshtools.jenny.config;

requires transitive com.sshtools.jenny.api;
requires transitive com.sshtools.jenny.product;
requires transitive com.sshtools.jini;
requires transitive com.sshtools.jini.schema;
requires transitive com.sshtools.jini.config;

provides Plugin with Config;
}
4 changes: 3 additions & 1 deletion config/src/main/resources/layers.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
description = Configuration framework, providing each plugin their own INI configuration file(s).

[artifacts]
;com.sshtools:jini:0.2.2
;com.sshtools:jini-lib:0.3.2
;com.sshtools:jini-schema:0.3.2
;com.sshtools:jini-config:0.3.2
1 change: 1 addition & 0 deletions frameworks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<module>tty</module>
<module>vfs</module>
<module>tunnels</module>
<module>product</module>
</modules>
</project>
1 change: 1 addition & 0 deletions frameworks/product/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
46 changes: 46 additions & 0 deletions frameworks/product/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--
Copyright © 2023 JAdaptive Limited (support@jadaptive.com)
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.sshtools</groupId>
<artifactId>jenny</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<name>Jenny - Product</name>
<artifactId>jenny-product</artifactId>
<dependencies>

<!-- Framework Provided -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jenny-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sshtools</groupId>
<artifactId>bootlace-api</artifactId>
<scope>provided</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* Copyright © 2023 JAdaptive Limited (support@jadaptive.com)
*
* 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.
*/
package com.sshtools.jenny.product;

import java.util.Optional;

import com.sshtools.bootlace.api.Plugin;
import com.sshtools.bootlace.api.PluginContext;

public final class Product implements Plugin {

private Info info;

public record Info(String app, String vendor) {
}

public final static class Builder {

private Optional<String> app = Optional.empty();
private Optional<Class<?>> appClass = Optional.empty();
private Optional<String> vendor = Optional.empty();

public Builder withApp(Class<?> appClass) {
this.appClass = Optional.of(appClass);
return this;
}

public Builder withApp(String app) {
this.app = Optional.of(app);
return this;
}

public Builder withVendor(String vendor) {
this.vendor = Optional.of(vendor);
return this;
}

public Info build() {
return new Info(
app.or(() -> appClass.map(Class::getName)).orElseThrow(() -> new IllegalStateException("'App' must be set, either a class or short ID.")),
vendor.orElse("Unknown")
);
}
}

public Product() {
}

public Product(Info info) {
info(info);
}

@Override
public void afterOpen(PluginContext context) throws Exception {
}

public void info(Info info) {
if(this.info != null)
throw new IllegalStateException("Product already registered.");
this.info = info;
}

public Info info() {
return info;
}

}
23 changes: 23 additions & 0 deletions frameworks/product/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Copyright © 2023 JAdaptive Limited (support@jadaptive.com)
*
* 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.
*/

module com.sshtools.jenny.product {
exports com.sshtools.jenny.product;
opens com.sshtools.jenny.product;

requires transitive com.sshtools.jenny.api;

}
9 changes: 9 additions & 0 deletions frameworks/product/src/main/resources/layers.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[component]
id = com.sshtools:jenny-product
name = Product

[meta]
icon = plugin
description = Framework for providing details about the concrete product running on the Jenny framework.

[artifacts]
6 changes: 4 additions & 2 deletions frameworks/tty/src/main/java/com/sshtools/jenny/tty/Tty.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.sshtools.jenny.tty;

import java.text.MessageFormat;

import com.sshtools.bootlace.api.Logs;
import com.sshtools.bootlace.api.Logs.Log;
import com.sshtools.bootlace.api.Plugin;
Expand All @@ -38,8 +40,8 @@ public void provider(TtyProvider provider) {
this.provider = provider;
} else if (this.provider != null && provider == null) {
this.provider = null;
} else {
throw new IllegalStateException();
} else if(this.provider != null) {
throw new IllegalStateException(MessageFormat.format("Cannot be more than one Tty provider. {0} and {1}", this.provider.getClass().getName(), provider.getClass().getName()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.sshtools.bootlace.api.Plugin;
import com.sshtools.jenny.web.NpmWebModule;
import com.sshtools.jenny.web.WebModule;
import com.sshtools.jenny.web.WebModule.Type;
import com.sshtools.tinytemplate.bootstrap.forms.Form;

public class Bootstrap5 implements Plugin {

Expand All @@ -33,6 +35,7 @@ public class Bootstrap5 implements Plugin {
public final static WebModule MODULE_BOOTSTRAP5 = new NpmWebModule.Builder().
withGAV(ofSpec("npm:bootstrap")).
withClass(Bootstrap5.class).
withType(Type.JS).
withMain("dist/js/bootstrap.bundle.min.js").
withRequires(MODULE_JQUERY).
build();
Expand All @@ -46,7 +49,7 @@ public class Bootstrap5 implements Plugin {

public final static WebModule MODULE_BOOTSTRAP_TABLE = new NpmWebModule.Builder().
withMain("dist/bootstrap-table.min.js").
withType("").
withType(Type.JS).
withGAV(ofSpec("npm:bootstrap-table")).
withClass(Bootstrap5.class).
withRequires(MODULE_BOOTSTRAP5).
Expand All @@ -66,5 +69,10 @@ public class Bootstrap5 implements Plugin {
MODULE_BOOTSTRAP5
);


public final static WebModule MODULE_TTBS = WebModule.of(
"/ttbs.js",
Form.class,
"ttbs.js",
Bootstrap5.MODULE_BOOTSTRAP5
);
}
Loading

0 comments on commit 89095a8

Please sign in to comment.