Skip to content

Commit

Permalink
feat: Migration to Java 8
Browse files Browse the repository at this point in the history
- Update dependencies
  • Loading branch information
yyvess committed Nov 28, 2020
1 parent 4189ed9 commit d4c1bd5
Show file tree
Hide file tree
Showing 36 changed files with 341 additions and 326 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: 'Java Build'
name: 'Maven Build'

on:
push:
Expand All @@ -12,7 +12,7 @@ on:
jobs:
build:
env:
MAVEN_ARGS: -B -ntp -Prelease -Pcoverage
MAVEN_ARGS: -B -ntp -Prelease -Pcoverage -Dmaven.javadoc.skip=true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -23,7 +23,7 @@ jobs:
with:
java-version: 1.8
- name: Build Maven
run: mvn ${MAVEN_ARGS} compile
run: mvn ${MAVEN_ARGS} -Drevision=${{ steps.bump_version.outputs.new_tag }} compile
- name: Maven Test
run: mvn ${MAVEN_ARGS} test
- name: Set up JDK 11
Expand All @@ -34,4 +34,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn ${MAVEN_ARGS} -Dsonar.branch.name=${CIRCLE_BRANCH} -Dsonar.java.binaries=target/classes -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=yyvess-github -Dmaven.javadoc.skip=true jacoco:report sonar:sonar
run: mvn ${MAVEN_ARGS} -Dsonar.java.binaries=target/classes -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=yyvess-github jacoco:report sonar:sonar
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ name: Release

on:
workflow_run:
workflows: ["Java Build"]
workflows: ["Maven Build"]
branches: ["master"]
types:
- completed


jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
MAVEN_ARGS: -B -ntp -Prelease -Dmaven.test.skip=true
runs-on: ubuntu-latest
Expand All @@ -35,7 +37,6 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
dry_run: true
custom_release_rules: patch:patch,minor:minor,major:major
release_branches: release.*,hotfix.*,master
- name: Build the release
env:
Expand All @@ -47,7 +48,6 @@ jobs:
uses: mathieudutour/github-tag-action@v5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_release_rules: patch:patch,minor:minor,major:major
release_branches: release.*,hotfix.*,master
- name: Deploy the release to maven central
env:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Spring configuration module provides JSON & HOCON support, build on the top of Typesafe config

![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.jmob/jsconf/badge.svg)
[![Build Status](https://travis-ci.org/yyvess/jsconf.svg?branch=master)](https://travis-ci.org/yyvess/jsconf)
[![Sonar Status](https://sonarcloud.io/api/project_badges/measure?project=net.jmob%3Ajsconf&metric=alert_status)](https://sonarcloud.io/dashboard?id=net.jmob%3Ajsconf) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=net.jmob%3Ajsconf&metric=coverage)](https://sonarcloud.io/dashboard?id=net.jmob%3Ajsconf)

[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

JSConf
======
Expand All @@ -22,7 +24,7 @@ You can find published releases (compiled for Java 7 and above) on Maven Central
<dependency>
<groupId>net.jmob</groupId>
<artifactId>jsconf</artifactId>
<version>1.3.1</version>
<version>1.4.0</version>
</dependency>

Spring context is required, it's not provided by this library
Expand Down
30 changes: 17 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<version>${revision}${changelist}</version>
<packaging>jar</packaging>

<prerequisites>
<maven>3.6.0</maven>
</prerequisites>

<name>JSON Spring Configuration</name>
<description>
Spring configuration module provides JSON and HOCON support
Expand All @@ -32,9 +36,9 @@
<revision>0.0.0</revision>
<changelist>-SNAPSHOT</changelist>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-version>3.2.4.RELEASE</spring-version>
<junit-version>4.11</junit-version>
<typesafe-version>1.2.1</typesafe-version>
<spring-version>5.3.1</spring-version>
<junit-version>5.7.0</junit-version>
<typesafe-version>1.4.1</typesafe-version>
<logback-version>1.1.2</logback-version>
<dhcp.version>1.4</dhcp.version>
</properties>
Expand Down Expand Up @@ -74,8 +78,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -106,7 +110,7 @@
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.4</version>
<version>2.2.6</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -168,7 +172,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.1.0</version>
<version>1.2.5</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
Expand Down Expand Up @@ -199,16 +203,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<version>3.7.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -221,7 +225,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<version>3.0.0-M5</version>
<configuration>
<parallel>classes</parallel>
<includes>
Expand All @@ -236,7 +240,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<version>3.0.0-M1</version>
<configuration>
<quiet>true</quiet>
<nonavbar>true</nonavbar>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/jmob/jsconf/core/ConfigurationFactory.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
*
* <p>
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* 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.
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/net/jmob/jsconf/core/impl/BeanDefinition.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package net.jmob.jsconf.core.impl;

import static org.springframework.util.StringUtils.isEmpty;
import static org.springframework.util.StringUtils.hasText;

/**
* Copyright 2015 Yves Galante
*
* <p>
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* 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.
Expand All @@ -26,10 +26,10 @@ public class BeanDefinition {
private boolean reloading;

public String getId() {
if (isEmpty(id)) {
return this.key;
if (hasText(id)) {
return id;
}
return id;
return this.key;
}

public BeanDefinition withId(String id) {
Expand Down
40 changes: 19 additions & 21 deletions src/main/java/net/jmob/jsconf/core/impl/BeanFactory.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
*
* <p>
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* 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.
Expand All @@ -16,15 +16,9 @@

package net.jmob.jsconf.core.impl;

import static java.lang.String.format;
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanCreationException;
Expand All @@ -33,10 +27,14 @@
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.ApplicationContext;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigValue;
import static java.lang.String.format;
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition;

public class BeanFactory {

Expand Down Expand Up @@ -77,25 +75,25 @@ public boolean isReloading() {
}

public String registerBean() {
final BeanDefinitionBuilder beanDefinition;
final BeanDefinitionBuilder bd;
final String beanId = this.beanDefinition.getId();
this.log.debug("Initialize bean id : {}", beanId);
if (this.beanDefinition.isAInterface()) {
beanDefinition = buildBeanFromInterface();
bd = buildBeanFromInterface();
} else {
beanDefinition = buildBeanFromClass();
bd = buildBeanFromClass();
}
this.log.debug("Register bean id : {}", beanId);
AutowireCapableBeanFactory factory = context.getAutowireCapableBeanFactory();
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
registry.registerBeanDefinition(beanId, beanDefinition.getBeanDefinition());
registry.registerBeanDefinition(beanId, bd.getBeanDefinition());
return beanId;
}

private BeanDefinitionBuilder buildBeanFromClass() {
try {
BeanDefinitionBuilder beanDefinition = genericBeanDefinition(Class.forName(this.beanDefinition.getClassName()));
return addPropertiesValue(beanDefinition, buildProperties(beanDefinition));
BeanDefinitionBuilder bd = genericBeanDefinition(Class.forName(this.beanDefinition.getClassName()));
return addPropertiesValue(bd, buildProperties(bd));
} catch (ClassNotFoundException e) {
throw new BeanCreationException(format("Class not found : %s", this.beanDefinition.getClassName()), e);
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/net/jmob/jsconf/core/impl/BeanValidator.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2015 Yves Galante
*
* <p>
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* 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.
Expand All @@ -33,6 +33,8 @@ class BeanValidator {
private static final Logger log = LoggerFactory.getLogger(BeanValidator.class);
private static final ValidatorFactory factory;

private BeanValidator() {
}

static {
ValidatorFactory f = null;
Expand Down
26 changes: 8 additions & 18 deletions src/main/java/net/jmob/jsconf/core/impl/ProxyPostProcessor.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* Copyright 2013 Yves Galante
*
* <p>
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
*
* <p>
* 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.
Expand All @@ -23,11 +23,7 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

import static java.lang.String.format;

Expand All @@ -43,16 +39,13 @@ public ProxyPostProcessor(ApplicationContext context) {

public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean.getClass().getInterfaces().length > 0) {
BeanProxy proxy = this.proxyRef.get(beanName);
if (proxy == null) {
BeanProxy proxy = this.proxyRef.computeIfAbsent(beanName, key -> {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
List<Class<?>> asList = new ArrayList<>();
asList.addAll(Arrays.asList(bean.getClass().getInterfaces()));
List<Class<?>> asList = new ArrayList<>(Arrays.asList(bean.getClass().getInterfaces()));
asList.add(BeanProxy.class);
Class<?>[] interfaces = asList.toArray(new Class<?>[asList.size()]);
proxy = (BeanProxy) Proxy.newProxyInstance(cl, interfaces, new ProxyHandler());
this.proxyRef.put(beanName, proxy);
}
return (BeanProxy) Proxy.newProxyInstance(cl, interfaces, new ProxyHandler());
});
proxy.setBean(bean);
return proxy;
} else {
Expand Down Expand Up @@ -80,9 +73,6 @@ private static class ProxyHandler implements InvocationHandler {

private Object bean;

public ProxyHandler() {
}

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.isAnnotationPresent(SetBeanMethod.class)) {
Expand Down
Loading

0 comments on commit d4c1bd5

Please sign in to comment.