Skip to content

Commit

Permalink
0.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
TruthBean committed Jan 3, 2022
1 parent f63dba7 commit 96de5e7
Show file tree
Hide file tree
Showing 102 changed files with 3,462 additions and 553 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
truthbean debbie cloud framework collections

## Note
Need java 11 or above
Need java 17 or above
6 changes: 3 additions & 3 deletions boot/cron/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<artifactId>debbie-cron</artifactId>

<properties>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
*/
package com.truthbean.debbie.cron;

import com.truthbean.debbie.bean.BeanInitialization;
import com.truthbean.debbie.bean.DebbieBeanInfo;
import com.truthbean.debbie.bean.MutableBeanInfo;
import com.truthbean.debbie.bean.BeanInfoManager;
import com.truthbean.debbie.boot.DebbieModuleStarter;
import com.truthbean.debbie.core.ApplicationContext;
import com.truthbean.debbie.properties.DebbieConfigurationCenter;
import org.quartz.Scheduler;
import org.quartz.impl.StdSchedulerFactory;

/**
Expand All @@ -35,12 +31,8 @@ public int getOrder() {
}

@Override
public void registerBean(ApplicationContext applicationContext, BeanInitialization beanInitialization) {
MutableBeanInfo<Scheduler> schedulerBeanInfo = new DebbieBeanInfo<>(Scheduler.class);
schedulerBeanInfo.addBeanName("scheduler");
SchedulerBeanFactory schedulerBeanFactory = new SchedulerBeanFactory();
schedulerBeanFactory.setEnvContent(applicationContext.getEnvContent());
schedulerBeanInfo.setBeanFactory(schedulerBeanFactory);
beanInitialization.initSingletonBean(schedulerBeanInfo);
public void registerBean(ApplicationContext applicationContext, BeanInfoManager beanInitialization) {
SchedulerBeanFactory schedulerBeanFactory = new SchedulerBeanFactory("scheduler");
beanInitialization.register(schedulerBeanFactory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package com.truthbean.debbie.cron;

import com.truthbean.debbie.task.MethodTaskInfo;
import com.truthbean.debbie.task.TaskInfo;

/**
* @author TruthBean/Rogar·Q
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,41 @@
import com.truthbean.Logger;
import com.truthbean.debbie.bean.BeanCreatedException;
import com.truthbean.debbie.bean.BeanFactory;
import com.truthbean.debbie.bean.GlobalBeanFactory;
import com.truthbean.debbie.env.EnvContentAware;
import com.truthbean.debbie.core.ApplicationContext;
import com.truthbean.debbie.env.EnvironmentContent;
import com.truthbean.LoggerFactory;
import com.truthbean.debbie.env.EnvironmentContentHolder;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
* @author TruthBean/Rogar·Q
* @since 0.1.0
* Created on 2020-08-11 09:39
*/
public class SchedulerBeanFactory implements BeanFactory<Scheduler>, EnvContentAware {
public class SchedulerBeanFactory implements BeanFactory<Scheduler> {
private volatile Scheduler scheduler;
private final Set<String> beanNames;

private EnvironmentContent envContent;

@Override
public void setEnvContent(EnvironmentContent envContent) {
this.envContent = envContent;
public SchedulerBeanFactory(String...names) {
this.beanNames = new HashSet<>();
Collections.addAll(this.beanNames, names);
}

@Override
public Scheduler getBean() {
public Scheduler factoryBean(ApplicationContext applicationContext) {
if (scheduler == null) {
synchronized (SchedulerBeanFactory.class) {
if (scheduler == null) {
EnvironmentContent envContent = applicationContext.getEnvContent();
if (envContent instanceof EnvironmentContentHolder) {
((EnvironmentContentHolder)envContent).addProperty("org.quartz.threadPool.threadCount", "10");
int i = Runtime.getRuntime().availableProcessors();
((EnvironmentContentHolder)envContent).addProperty("org.quartz.threadPool.threadCount", String.valueOf(i));
}
try {
StdSchedulerFactory factory = new StdSchedulerFactory(envContent.getProperties());
Expand All @@ -58,30 +62,51 @@ public Scheduler getBean() {
}

@Override
public Class<Scheduler> getBeanType() {
public Scheduler factoryNamedBean(String name, ApplicationContext applicationContext) {
return factoryBean(applicationContext);
}

@Override
public Set<String> getBeanNames() {
return beanNames;
}

@Override
public Scheduler getCreatedBean() {
return this.scheduler;
}

@Override
public Class<?> getBeanClass() {
return Scheduler.class;
}

@Override
public boolean isCreated() {
return this.scheduler != null;
}

@Override
public boolean isSingleton() {
return true;
}

@Override
public void destroy() {
public void destruct(ApplicationContext applicationContext) {
if (this.scheduler != null) {
try {
if (this.scheduler.isStarted() && !this.scheduler.isShutdown())
if (this.scheduler.isStarted() && !this.scheduler.isShutdown()) {
this.scheduler.shutdown(true);
}
} catch (SchedulerException e) {
LOGGER.error("", e);
}
}
}

@Override
public void setGlobalBeanFactory(GlobalBeanFactory globalBeanFactory) {

public Logger getLogger() {
return LOGGER;
}

private static final Logger LOGGER = LoggerFactory.getLogger(SchedulerBeanFactory.class);
Expand Down
6 changes: 3 additions & 3 deletions boot/freemarker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<artifactId>debbie-freemarker</artifactId>

<properties>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<dependencies>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,59 @@
package com.truthbean.debbie.freemarker;

import com.truthbean.debbie.bean.*;
import com.truthbean.debbie.core.ApplicationContext;
import freemarker.template.Configuration;

import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;

/**
* @author TruthBean
* @since 0.0.2
*/
public class DefaultConfigurationBeanFactory implements BeanFactory<Configuration>, ClassLoaderAware {
public class DefaultConfigurationBeanFactory implements BeanFactory<Configuration> {

private Configuration configuration;
private ClassLoader classLoader;

public DefaultConfigurationBeanFactory() {
private final Set<String> names = new HashSet<>();

public DefaultConfigurationBeanFactory(String...names) {
if (names != null && names.length > 0) {
Collections.addAll(this.names, names);
}
}

@Override
public void setGlobalBeanFactory(GlobalBeanFactory beanFactory) {
public Configuration factoryBean(ApplicationContext applicationContext) {
if (configuration == null) {
configuration = new Configuration(Configuration.VERSION_2_3_30);
configuration.setClassLoaderForTemplateLoading(applicationContext.getClassLoader(), "/templates");
configuration.setDefaultEncoding("UTF-8");
configuration.setLocale(Locale.CHINA);
}

return configuration;
}

@Override
public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
public Configuration factoryNamedBean(String name, ApplicationContext applicationContext) {
return factoryBean(applicationContext);
}

@Override
public Configuration getBean() {
if (configuration == null) {
configuration = new Configuration(Configuration.VERSION_2_3_30);
configuration.setClassLoaderForTemplateLoading(this.classLoader, "/templates");
configuration.setDefaultEncoding("UTF-8");
configuration.setLocale(Locale.CHINA);
}
public boolean isCreated() {
return configuration != null;
}

@Override
public Configuration getCreatedBean() {
return configuration;
}

@Override
public Class<Configuration> getBeanType() {
public Class<?> getBeanClass() {
return Configuration.class;
}

Expand All @@ -59,7 +72,12 @@ public boolean isSingleton() {
}

@Override
public void destroy() {
public Set<String> getBeanNames() {
return names;
}

@Override
public void destruct(ApplicationContext applicationContext) {
if (configuration != null) {
configuration.clearEncodingMap();
configuration.clearSharedVariables();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
*/
package com.truthbean.debbie.freemarker;

import com.truthbean.debbie.bean.BeanInitialization;
import com.truthbean.debbie.bean.BeanInfoManager;
import com.truthbean.debbie.boot.DebbieModuleStarter;
import com.truthbean.debbie.core.ApplicationContext;
import com.truthbean.debbie.env.EnvironmentContent;
import com.truthbean.debbie.properties.DebbieConfigurationCenter;

/**
* @author TruthBean
Expand All @@ -29,15 +28,13 @@ public boolean enable(EnvironmentContent envContent) {
}

@Override
public void registerBean(ApplicationContext context, BeanInitialization beanInitialization) {
var freemarkerConfiguration = new DebbieFreemarkerConfiguration();
freemarkerConfiguration.register(context);
public void registerBean(ApplicationContext context, BeanInfoManager beanInfoManager) {
DefaultConfigurationBeanFactory beanFactory = new DefaultConfigurationBeanFactory("freemarkerConfiguration");
beanInfoManager.register(beanFactory);
}

@Override
public void configure(DebbieConfigurationCenter configurationFactory, ApplicationContext context) {
var freemarkerConfiguration = new DebbieFreemarkerConfiguration();
freemarkerConfiguration.configure(context);
public void configure(ApplicationContext context) {
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions boot/hikari/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<artifactId>debbie-hikari</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<dependencies>
Expand Down
Loading

0 comments on commit 96de5e7

Please sign in to comment.