Skip to content

Commit

Permalink
Introduce javafx
Browse files Browse the repository at this point in the history
  • Loading branch information
finesoft committed Sep 25, 2022
1 parent 737a818 commit 4d30f55
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 6 deletions.
64 changes: 58 additions & 6 deletions corant-boms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<version.jackson>2.13.3</version.jackson>
<version.jandex>2.4.2.Final</version.jandex>
<version.jasperreports>6.10.0</version.jasperreports>
<version.javafx>11.0.2</version.javafx>
<version.javassist>3.27.0.GA</version.javassist>
<version.jakarta.activation-api>1.2.2</version.jakarta.activation-api>
<version.jakarta.annotation-api>1.3.5</version.jakarta.annotation-api>
Expand Down Expand Up @@ -207,11 +208,6 @@
</dependency>

<!-- Corant Modules -->
<dependency>
<groupId>org.corant</groupId>
<artifactId>corant-modules-arrow</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.corant</groupId>
<artifactId>corant-modules-bundle</artifactId>
Expand Down Expand Up @@ -537,8 +533,13 @@
<artifactId>corant-modules-websocket</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.corant</groupId>
<artifactId>corant-modules-javafx-cdi</artifactId>
<version>${revision}</version>
</dependency>

<!-- Java & Javax & Jakarta -->
<!-- Java & Javax & Jakarta & Javafx -->
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
Expand Down Expand Up @@ -682,6 +683,57 @@
<version>${version.jakarta.activation-api}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>${version.javafx}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>${version.javafx}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${version.javafx}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${version.javafx}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${version.javafx}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${version.javafx}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${version.javafx}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>${version.javafx}</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2013-2018, Bingo.Chen (finesoft@gmail.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 org.corant.context.qualifier;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.enterprise.util.AnnotationLiteral;
import javax.enterprise.util.Nonbinding;
import javax.inject.Qualifier;

/**
* corant-modules-bundle
*
* @author bingo 下午8:44:38
*
*/
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE})
public @interface Bundle {

/**
* The name of the bundle.
*/
@Nonbinding
String value();

class BundleLiteral extends AnnotationLiteral<Bundle> implements Bundle {

private static final long serialVersionUID = -5766940942537035511L;

final String value;

public BundleLiteral(String value) {
this.value = value;
}

public static BundleLiteral of(String value) {
return new BundleLiteral(value);
}

@Override
public String value() {
return value;
}

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2013-2021, Bingo.Chen (finesoft@gmail.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 org.corant.context.service;

import java.util.ResourceBundle;
import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import org.corant.context.qualifier.Bundle;

/**
* corant-modules-bundle
*
* @author bingo 下午10:14:42
*
*/
public class ResourceBundleProvider {

@Produces
@Dependent
@Bundle("")
ResourceBundle produce(final InjectionPoint injectionPoint) {
final String bundleName = injectionPoint.getAnnotated().getAnnotation(Bundle.class).value();
return ResourceBundle.getBundle(bundleName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<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>org.corant</groupId>
<artifactId>corant-modules-javafx</artifactId>
<version>${revision}</version>
</parent>
<artifactId>corant-modules-javafx-cdi</artifactId>
<dependencies>
<dependency>
<groupId>org.corant</groupId>
<artifactId>corant-context</artifactId>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
</dependency>
<!-- Standard JEE -->
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2013-2021, Bingo.Chen (finesoft@gmail.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 org.corant.modules.javafx.cdi;

import static org.corant.shared.util.Strings.EMPTY;
import javax.enterprise.util.Nonbinding;

/**
* corant-modules-javafx-cdi
*
* @author bingo 下午11:26:29
*
*/
public @interface FXML {

/**
* The name of the resources used to resolve resource key attribute values.
*/
@Nonbinding
String bundle();

/**
* The URL used to resolve relative path attribute values.
*/
@Nonbinding
String url() default EMPTY;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2013-2021, Bingo.Chen (finesoft@gmail.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 org.corant.modules.javafx.cdi;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.corant.shared.util.Conversions.toObject;
import static org.corant.shared.util.Strings.isBlank;
import java.net.URL;
import java.util.ResourceBundle;
import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import org.corant.context.Beans;
import javafx.fxml.FXMLLoader;
import javafx.fxml.JavaFXBuilderFactory;

/**
* corant-modules-javafx-cdi
*
* @author bingo 下午11:08:06
*
*/
public class FXMLLoaderFactory {

@Produces
@Dependent
public FXMLLoader produce(final InjectionPoint ip) {
final FXML fxml = ip.getAnnotated().getAnnotation(FXML.class);
final URL url = fxml == null || isBlank(fxml.url()) ? null : toObject(fxml.url(), URL.class);
final ResourceBundle bundle =
fxml == null || isBlank(fxml.bundle()) ? null : ResourceBundle.getBundle(fxml.bundle());
return new FXMLLoader(url, bundle, new JavaFXBuilderFactory(), Beans::resolve, UTF_8);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2013-2021, Bingo.Chen (finesoft@gmail.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.
*/
/**
* corant-modules-javafx-cdi
*
* @author bingo 下午11:06:37
*
*/
package org.corant.modules.javafx.cdi;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
bean-discovery-mode="annotated">
</beans>
13 changes: 13 additions & 0 deletions corant-modules/corant-modules-javafx/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<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>org.corant</groupId>
<artifactId>corant-modules</artifactId>
<version>${revision}</version>
</parent>
<artifactId>corant-modules-javafx</artifactId>
<packaging>pom</packaging>
<modules>
<module>corant-modules-javafx-cdi</module>
</modules>
</project>
1 change: 1 addition & 0 deletions corant-modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<module>corant-modules-websocket</module>
<module>corant-modules-aicv</module>
<module>corant-modules-jnosql</module>
<module>corant-modules-javafx</module>
</modules>
<description>The Corant integration modules, which contains various components involved in enterprise development.</description>
</project>

0 comments on commit 4d30f55

Please sign in to comment.