proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/parser/AsyncInitBeanDefinitionDecorator.java | AsyncInitBeanDefinitionDecorator | decorate | class AsyncInitBeanDefinitionDecorator implements BeanDefinitionDecorator,
SofaBootTagNameSupport {
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition,
ParserContext parserContext) {<FILL... |
if (!Boolean.TRUE.toString().equalsIgnoreCase(((Attr) node).getValue())) {
return definition;
}
String initMethodName = definition.getBeanDefinition().getInitMethodName();
if (StringUtils.hasText(initMethodName)) {
definition.getBeanDefinition().setAttribute(ASY... | 99 | 101 | 200 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/parser/ReferenceDefinitionParser.java | ReferenceDefinitionParser | doParseInternal | class ReferenceDefinitionParser extends AbstractContractDefinitionParser {
public static final String JVM_FIRST = "jvm-first";
public static final String PROPERTY_JVM_FIRST = "jvmFirst";
public static final String PROPERTY_LOAD_BALANCE = "loadBalance";
public static final String REQUIRED ... |
String jvmFirstString = element.getAttribute(JVM_FIRST);
if (StringUtils.hasText(jvmFirstString)) {
if ("true".equalsIgnoreCase(jvmFirstString)) {
builder.addPropertyValue(PROPERTY_JVM_FIRST, true);
} else if ("false".equalsIgnoreCase(jvmFirstString)) {
... | 261 | 382 | 643 | <methods>public non-sealed void <init>() <variables>public static final java.lang.String BEAN_ID_ELEMENT,public static final java.lang.String BEAN_ID_PROPERTY,public static final java.lang.String BINDINGS,public static final java.lang.String BINDING_ADAPTER_FACTORY,public static final java.lang.String BINDING_CONVERTER... |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/spring/parser/ServiceDefinitionParser.java | ServiceDefinitionParser | doParseInternal | class ServiceDefinitionParser extends AbstractContractDefinitionParser {
public static final String REF = "ref";
public static final String BEAN_ID = "beanId";
@Override
protected void doParseInternal(Element element, ParserContext parserContext,
BeanDefinitionBui... |
String ref = element.getAttribute(REF);
builder.addPropertyReference(REF, ref);
if (element.hasAttribute("id")) {
String id = element.getAttribute("id");
builder.addPropertyValue(BEAN_ID, id);
} else {
builder.addPropertyValue(BEAN_ID, ref);
}... | 194 | 89 | 283 | <methods>public non-sealed void <init>() <variables>public static final java.lang.String BEAN_ID_ELEMENT,public static final java.lang.String BEAN_ID_PROPERTY,public static final java.lang.String BINDINGS,public static final java.lang.String BINDING_ADAPTER_FACTORY,public static final java.lang.String BINDING_CONVERTER... |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/startup/ComponentBeanStatCustomizer.java | ComponentBeanStatCustomizer | customize | class ComponentBeanStatCustomizer implements BeanStatCustomizer {
@Override
public BeanStat customize(String beanName, Object bean, BeanStat bs) {<FILL_FUNCTION_BODY>}
} |
if (bean instanceof ServiceFactoryBean) {
bs.putAttribute("interface", ((ServiceFactoryBean) bean).getInterfaceType());
bs.putAttribute("uniqueId", ((ServiceFactoryBean) bean).getUniqueId());
return null;
} else if (bean instanceof ReferenceFactoryBean) {
... | 55 | 201 | 256 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/datasource/DataSourceBeanPostProcessor.java | DataSourceBeanPostProcessor | postProcessAfterInitialization | class DataSourceBeanPostProcessor implements BeanPostProcessor, PriorityOrdered {
private String appName;
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {<FILL_FUNCTION... |
/*
* filter bean which is type of {@link SmartDataSource}
* filter bean which is not type of {@link DataSource}
*/
if (!(bean instanceof DataSource) || bean instanceof SmartDataSource) {
return bean;
}
String getUrlMethodName;
String url;... | 125 | 529 | 654 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/feign/FeignContextBeanPostProcessor.java | FeignContextBeanPostProcessor | postProcessBeforeInitialization | class FeignContextBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {<FILL_FUNCTION_BODY>}
} |
if (bean instanceof FeignClientFactory && !(bean instanceof SofaTracerFeignClientFactory)) {
return new SofaTracerFeignClientFactory((FeignClientFactory) bean);
}
return bean;
| 58 | 58 | 116 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/flexible/SofaTracerIntroductionInterceptor.java | SofaTracerIntroductionInterceptor | findAnnotation | class SofaTracerIntroductionInterceptor implements IntroductionInterceptor {
private final MethodInvocationProcessor sofaMethodInvocationProcessor;
public SofaTracerIntroductionInterceptor(MethodInvocationProcessor sofaMethodInvocationProcessor) {
this.sofaMethodInvocationProcessor = sofaMethodInvocat... |
T annotation = AnnotationUtils.findAnnotation(method, clazz);
if (annotation == null) {
try {
annotation = AnnotationUtils.findAnnotation(
method.getDeclaringClass().getMethod(method.getName(),
method.getParameterTypes()), clazz);
... | 275 | 114 | 389 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/flexible/SofaTracerMethodInvocationProcessor.java | SofaTracerMethodInvocationProcessor | proceedProxyMethodWithTracerAnnotation | class SofaTracerMethodInvocationProcessor implements MethodInvocationProcessor {
private final io.opentracing.Tracer tracer;
public SofaTracerMethodInvocationProcessor(io.opentracing.Tracer tracer) {
this.tracer = tracer;
}
@Override
public Object process(MethodInvocation invocation, Trac... |
if (tracer instanceof FlexibleTracer) {
try {
String operationName = tracerSpan.operateName();
if (StringUtils.isBlank(operationName)) {
operationName = invocation.getMethod().getName();
}
SofaTracerSpan sofaTracerS... | 171 | 308 | 479 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/flexible/TracerAnnotationClassPointcut.java | AnnotationMethodsResolver | hasAnnotatedMethods | class AnnotationMethodsResolver {
private final Class<? extends Annotation> annotationType;
AnnotationMethodsResolver(Class<? extends Annotation> annotationType) {
this.annotationType = annotationType;
}
boolean hasAnnotatedMethods(Class<?> clazz) {<FILL_FUNCTION_BODY>}
... |
final AtomicBoolean found = new AtomicBoolean(false);
ReflectionUtils.doWithMethods(clazz, (method) ->{
if (found.get()) {
return;
}
Annotation annotation = AnnotationUtils.findAnnotation(method,
Annotat... | 87 | 111 | 198 | <methods>public void <init>() ,public org.springframework.aop.ClassFilter getClassFilter() ,public final org.springframework.aop.MethodMatcher getMethodMatcher() <variables> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/kafka/KafkaConsumerFactoryBeanPostProcessor.java | KafkaConsumerFactoryBeanPostProcessor | postProcessAfterInitialization | class KafkaConsumerFactoryBeanPostProcessor implements BeanPostProcessor {
@SuppressWarnings("rawtypes")
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {<FILL_FUNCTION_B... |
if (bean instanceof ConsumerFactory && !(bean instanceof SofaTracerKafkaConsumerFactory)) {
return new SofaTracerKafkaConsumerFactory((ConsumerFactory) bean);
}
return bean;
| 72 | 57 | 129 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/kafka/KafkaProducerBeanFactoryPostProcessor.java | KafkaProducerBeanFactoryPostProcessor | postProcessAfterInitialization | class KafkaProducerBeanFactoryPostProcessor implements BeanPostProcessor {
@SuppressWarnings("rawtypes")
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {<FILL_FUNCTION_B... |
if (bean instanceof ProducerFactory && !(bean instanceof SofaTracerKafkaProducerFactory)) {
return new SofaTracerKafkaProducerFactory((ProducerFactory) bean);
}
return bean;
| 73 | 60 | 133 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/mongodb/SofaTracerCommandListenerCustomizer.java | SofaTracerCommandListenerCustomizer | customize | class SofaTracerCommandListenerCustomizer implements MongoClientSettingsBuilderCustomizer {
private String appName;
@Override
public void customize(Builder clientSettingsBuilder) {<FILL_FUNCTION_BODY>}
public void setAppName(String appName) {
this.appName = appName;
}
} |
Assert.isTrue(StringUtils.hasText(appName), TRACER_APPNAME_KEY + " must be configured!");
SofaTracerCommandListener commandListener = new SofaTracerCommandListener(appName);
clientSettingsBuilder.addCommandListener(commandListener);
| 86 | 71 | 157 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/rabbitmq/RabbitMqBeanPostProcessor.java | RabbitMqBeanPostProcessor | getAdviceChainOrAddInterceptorToChain | class RabbitMqBeanPostProcessor implements BeanPostProcessor, PriorityOrdered {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
if (bean instanceof AbstractRabbit... |
if (existingAdviceChain == null) {
return new Advice[] { new SofaTracerConsumeInterceptor() };
}
for (Advice advice : existingAdviceChain) {
if (advice instanceof SofaTracerConsumeInterceptor) {
return existingAdviceChain;
}
}
... | 408 | 173 | 581 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/resttemplate/RestTemplateBeanPostProcessor.java | RestTemplateBeanPostProcessor | postProcessAfterInitialization | class RestTemplateBeanPostProcessor implements BeanPostProcessor {
private final RestTemplateEnhance sofaTracerRestTemplateEnhance;
public RestTemplateBeanPostProcessor(RestTemplateEnhance sofaTracerRestTemplateEnhance) {
this.sofaTracerRestTemplateEnhance = sofaTracerRestTemplateEnhance;
}
@... |
if (bean instanceof RestTemplate restTemplate) {
sofaTracerRestTemplateEnhance.enhanceRestTemplateWithSofaTracer(restTemplate);
}
return bean;
| 127 | 49 | 176 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/resttemplate/RestTemplateEnhance.java | RestTemplateEnhance | enhanceRestTemplateWithSofaTracer | class RestTemplateEnhance {
private final RestTemplateInterceptor restTemplateInterceptor;
public RestTemplateEnhance() {
AbstractTracer restTemplateTracer = SofaTracerRestTemplateBuilder.getRestTemplateTracer();
this.restTemplateInterceptor = new RestTemplateInterceptor(restTemplateTracer);
... |
// check interceptor
if (checkRestTemplateInterceptor(restTemplate)) {
return;
}
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(
restTemplate.getInterceptors());
interceptors.add(0, this.restTemplateInterceptor);
restTemplate.se... | 195 | 93 | 288 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/rocketmq/RocketMqConsumerPostProcessor.java | RocketMqConsumerPostProcessor | postProcessAfterInitialization | class RocketMqConsumerPostProcessor implements BeanPostProcessor, PriorityOrdered {
private String appName;
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {<FILL_FUNCTI... |
if (bean instanceof DefaultRocketMQListenerContainer container) {
Assert.isTrue(StringUtils.hasText(appName), TRACER_APPNAME_KEY + " must be configured!");
SofaTracerConsumeMessageHook hook = new SofaTracerConsumeMessageHook(appName);
container.getConsumer().getDefaultMQPush... | 127 | 114 | 241 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/rocketmq/RocketMqProducerPostProcessor.java | RocketMqProducerPostProcessor | postProcessAfterInitialization | class RocketMqProducerPostProcessor implements BeanPostProcessor, PriorityOrdered {
private String appName;
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {<FILL_FUNCTI... |
if (bean instanceof DefaultMQProducer producer) {
Assert.isTrue(StringUtils.hasText(appName), TRACER_APPNAME_KEY + " must be configured!");
SofaTracerSendMessageHook hook = new SofaTracerSendMessageHook(appName);
producer.getDefaultMQProducerImpl().registerSendMessageHook(ho... | 128 | 105 | 233 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot-core/tracer-sofa-boot/src/main/java/com/alipay/sofa/boot/tracer/springmessage/SpringMessageTracerBeanPostProcessor.java | SpringMessageTracerBeanPostProcessor | postProcessBeforeInitialization | class SpringMessageTracerBeanPostProcessor implements BeanPostProcessor, PriorityOrdered {
private String appName;
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {<FI... |
if (bean instanceof AbstractMessageChannel) {
Assert
.isTrue(StringUtils.hasText(appName), TRACER_APPNAME_KEY + " must be configured!");
((AbstractMessageChannel) bean).addInterceptor(SofaTracerChannelInterceptor
.create(appName));
}
retur... | 127 | 86 | 213 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/Initializer/SwitchableApplicationContextInitializer.java | SwitchableApplicationContextInitializer | isEnable | class SwitchableApplicationContextInitializer
implements
ApplicationContextInitializer<ConfigurableApplicationContext> {
protected static final String CONFIG_KEY_PREFIX = "sofa.boot.switch.init... |
String switchKey = switchKey();
Assert.hasText(switchKey, "switch key must has text.");
String realKey = CONFIG_KEY_PREFIX + switchKey + ".enabled";
String switchStr = applicationContext.getEnvironment().getProperty(realKey);
if (StringUtils.hasText(switchStr)) {
ret... | 273 | 107 | 380 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/annotation/AnnotationWrapper.java | AnnotationWrapper | build | class AnnotationWrapper<A extends Annotation> {
private final Class<A> clazz;
private Annotation delegate;
private PlaceHolderBinder binder;
private Environment environment;
private AnnotationWrapper(Class<A> clazz) {
this.clazz = clazz;
}
public static <A exten... |
ClassLoader cl = this.getClass().getClassLoader();
Class<?>[] exposedInterface = { delegate.annotationType(), WrapperAnnotation.class };
return (A) Proxy.newProxyInstance(cl, exposedInterface,
new PlaceHolderAnnotationInvocationHandler(delegate, binder, environment));
| 335 | 78 | 413 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/annotation/PlaceHolderAnnotationInvocationHandler.java | PlaceHolderAnnotationInvocationHandler | invoke | class PlaceHolderAnnotationInvocationHandler implements InvocationHandler {
private final Annotation delegate;
private final PlaceHolderBinder binder;
private final Environment environment;
public PlaceHolderAnnotationInvocationHandler(Annotation delegate, PlaceHolderBinder binder,
... |
Object ret = method.invoke(delegate, args);
if (ret != null && !ReflectionUtils.isObjectMethod(method) && isAttributeMethod(method)) {
return resolvePlaceHolder(ret);
}
return ret;
| 430 | 63 | 493 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/aop/framework/autoproxy/ExcludeBeanNameAutoProxyCreator.java | ExcludeBeanNameAutoProxyCreator | setExcludeBeanNames | class ExcludeBeanNameAutoProxyCreator extends BeanNameAutoProxyCreator {
@Nullable
private List<String> excludeBeanNames;
/**
* Set the names of the beans that should not automatically get wrapped with proxies.
* A name can specify a prefix to match by ending with "*", e.g. "myBean,tx*"
* w... |
Assert.notEmpty(beanNames, "'excludeBeanNames' must not be empty");
this.excludeBeanNames = new ArrayList<>(beanNames.length);
for (String mappedName : beanNames) {
this.excludeBeanNames.add(mappedName.strip());
}
| 429 | 74 | 503 | <methods>public void <init>() ,public transient void setBeanNames(java.lang.String[]) <variables>private static final java.lang.String[] NO_ALIASES,private List<java.lang.String> beanNames |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/compatibility/AbstractJarVersionVerifier.java | AbstractJarVersionVerifier | compatibilityPredicate | class AbstractJarVersionVerifier extends AbstractSwitchableCompatibilityVerifier {
public AbstractJarVersionVerifier(Environment environment) {
super(environment);
}
@Override
public CompatibilityPredicate compatibilityPredicate() {<FILL_FUNCTION_BODY>}
@Override
public String errorDe... |
return () -> {
Collection<CompatibilityPredicate> compatibilityPredicates = getJarCompatibilityPredicates();
if (compatibilityPredicates == null) {
return true;
}
return compatibilityPredicates.stream().allMatch(CompatibilityPredicate::isCompatibl... | 241 | 79 | 320 | <methods>public void <init>(org.springframework.core.env.Environment) ,public abstract java.lang.String action() ,public abstract com.alipay.sofa.boot.compatibility.CompatibilityPredicate compatibilityPredicate() ,public abstract java.lang.String enableKey() ,public abstract java.lang.String errorDescription() ,public ... |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/compatibility/AbstractSwitchableCompatibilityVerifier.java | AbstractSwitchableCompatibilityVerifier | verify | class AbstractSwitchableCompatibilityVerifier implements CompatibilityVerifier {
private static final String ENABLE_KEY_FORMAT = "sofa.boot.compatibility-verifier.%s.enabled";
protected final Environment environment;
protected String enableKey;
public AbstractSwitchableCompatibilityVerifi... |
this.enableKey = String.format(ENABLE_KEY_FORMAT, enableKey());
if (!Boolean.parseBoolean(environment.getProperty(enableKey, "true"))) {
return VerificationResult.compatible();
}
CompatibilityPredicate compatibilityPredicate = compatibilityPredicate();
boolean match... | 159 | 122 | 281 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/compatibility/CompatibilityVerifierApplicationContextInitializer.java | CompatibilityVerifierApplicationContextInitializer | initialize | class CompatibilityVerifierApplicationContextInitializer
implements
ApplicationContextInitializer<ConfigurableApplicationContext> {
public static final String COMPATIBILITY_VERIFIER_ENABLED... |
Environment environment = applicationContext.getEnvironment();
if (!Boolean.parseBoolean(environment.getProperty(COMPATIBILITY_VERIFIER_ENABLED, "true"))) {
Logger logger = LoggerFactory
.getLogger(CompatibilityVerifierApplicationContextInitializer.class);
logger... | 241 | 154 | 395 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/compatibility/CompositeCompatibilityVerifier.java | CompositeCompatibilityVerifier | verifierErrors | class CompositeCompatibilityVerifier {
private final List<CompatibilityVerifier> verifiers;
public CompositeCompatibilityVerifier(List<CompatibilityVerifier> verifiers) {
this.verifiers = verifiers;
}
public void verifyCompatibilities() {
List<VerificationResult> errors = verifierErro... |
List<VerificationResult> errors = new ArrayList<>();
for (CompatibilityVerifier verifier : this.verifiers) {
VerificationResult result = verifier.verify();
if (result.isNotCompatible()) {
errors.add(result);
}
}
return errors;
| 172 | 78 | 250 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/compatibility/VerificationResult.java | VerificationResult | toErrorMessage | class VerificationResult {
private final String description;
private final String action;
// if OK
private VerificationResult() {
this.description = "";
this.action = "";
}
// if not OK
private VerificationResult(String errorDescription, String action) {
this.desc... |
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("\n");
stringBuilder.append("VerificationResult:");
stringBuilder.append("\n");
stringBuilder.append("—— description: ");
stringBuilder.append(description);
stringBuilder.append("\n");
... | 319 | 101 | 420 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/context/SofaGenericApplicationContext.java | SofaGenericApplicationContext | publishEvent | class SofaGenericApplicationContext extends GenericApplicationContext {
private static final Method GET_APPLICATION_EVENT_MULTICASTER_METHOD;
private static final Field EARLY_APPLICATION_EVENTS_FIELD;
private List<ContextRefreshInterceptor> interceptors = new ArrayList<>();
... |
if (publishEventToParent) {
super.publishEvent(event, eventType);
return;
}
Assert.notNull(event, "Event must not be null");
// Decorate event as an ApplicationEvent if necessary
ApplicationEvent applicationEvent;
if (event instanceof Application... | 891 | 276 | 1,167 | <methods>public void <init>() ,public void <init>(org.springframework.beans.factory.support.DefaultListableBeanFactory) ,public void <init>(org.springframework.context.ApplicationContext) ,public void <init>(org.springframework.beans.factory.support.DefaultListableBeanFactory, org.springframework.context.ApplicationCon... |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/context/SofaSpringContextSupport.java | SofaSpringContextSupport | createBeanFactory | class SofaSpringContextSupport {
public static SofaDefaultListableBeanFactory createBeanFactory(ClassLoader beanClassLoader,
Supplier<SofaDefaultListableBeanFactory> supplier) {<FILL_FUNCTION_BODY>}
public static SofaGenericApplicationContext ... |
SofaDefaultListableBeanFactory beanFactory = supplier.get();
if (!(beanFactory.getAutowireCandidateResolver() instanceof QualifierAnnotationAutowireCandidateResolver)) {
beanFactory.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
}
beanFacto... | 156 | 194 | 350 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/context/processor/SofaPostProcessorShareManager.java | SofaPostProcessorShareManager | afterPropertiesSet | class SofaPostProcessorShareManager implements BeanFactoryAware, InitializingBean {
private static final String[] WHITE_NAME_LIST = new String[] {
ConfigurationClassPostProcessor.class.getName() + ".importAwareProcessor",
ConfigurationClassPostProcessor.class... |
if (!isShareParentContextPostProcessors) {
return;
}
Assert.notNull(beanFactory, "beanFactory must not be null");
Assert.notNull(registerSingletonMap, "registerSingletonMap must not be null");
Assert.notNull(registerBeanDefinitionMap, "registerBeanDefinitionMap must ... | 1,189 | 126 | 1,315 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/env/ScenesEnvironmentPostProcessor.java | ScenesEnvironmentPostProcessor | scenesResources | class ScenesEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
public static final String SCENES_KEY = "sofa.boot.scenes";
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
... |
List<SceneConfigDataReference> resources = new ArrayList<>();
if (scenes != null && !scenes.isEmpty()) {
scenes.forEach(scene -> propertySourceLoaders.forEach(psl -> {
for (String extension : psl.getFileExtensions()) {
String location =
... | 1,048 | 179 | 1,227 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/env/SofaBootEnvironmentPostProcessor.java | SofaBootEnvironmentPostProcessor | getSofaBootVersionProperties | class SofaBootEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
private static final String PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE = "spring.autoconfigure.exclude";
private static final List<String> SOFABOOT_EXCLUDE_AUTOCONFIGURATION_CLASSES = List
... |
Properties properties = new Properties();
String sofaBootVersion = getSofaBootVersion();
// generally, it would not be null and just for test.
sofaBootVersion = !StringUtils.hasText(sofaBootVersion) ? "" : sofaBootVersion;
String sofaBootFormattedVersion = sofaBootVersion.isEmpt... | 850 | 161 | 1,011 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/listener/SofaConfigSourceSupportListener.java | SofaConfigSourceSupportListener | registerSofaConfigs | class SofaConfigSourceSupportListener
implements
ApplicationListener<ApplicationEnvironmentPreparedEvent>,
Ordered {
private final AtomicBoolean registered = new AtomicBoolean();
... |
SofaConfigs.addConfigSource(new AbstractConfigSource() {
@Override
public int getOrder() {
return LOWEST_PRECEDENCE;
}
@Override
public String getName() {
return SofaBootConstants.SOFA_BOOT_SPACE_NAME;
}
... | 177 | 153 | 330 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/listener/SpringCloudConfigListener.java | SpringCloudConfigListener | onApplicationEvent | class SpringCloudConfigListener implements
ApplicationListener<ApplicationEnvironmentPreparedEvent>,
Ordered {
private final static MapPropertySource HIGH_PRIORITY_CONFIG = new MapPropertySource(
... |
ConfigurableEnvironment environment = event.getEnvironment();
// only work in spring cloud application
if (SofaBootEnvUtils.isSpringCloudEnvironmentEnabled(environment)) {
if (environment.getPropertySources().contains(SofaBootConstants.SPRING_CLOUD_BOOTSTRAP)) {
// i... | 421 | 542 | 963 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/listener/SwitchableApplicationListener.java | SwitchableApplicationListener | onApplicationEvent | class SwitchableApplicationListener<E extends ApplicationEvent>
implements
ApplicationListener<E> {
protected static final String CONFIG_KEY_PREFIX = "sofa... |
ApplicationContext applicationContext = null;
Environment environment = null;
if (event instanceof ApplicationContextEvent applicationContextEvent) {
applicationContext = applicationContextEvent.getApplicationContext();
} else if (event instanceof ApplicationContextInitializ... | 323 | 320 | 643 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/log/SofaBootLoggerFactory.java | SofaBootLoggerFactory | getLogger | class SofaBootLoggerFactory {
/**
* get Logger Object
*
* @param name name of the logger
* @return Logger Object
*/
public static Logger getLogger(String name) {
if (name == null || name.isEmpty()) {
return null;
}
return LoggerSpaceManager.getLogger... |
if (clazz == null) {
return null;
}
return getLogger(clazz.getCanonicalName());
| 182 | 35 | 217 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/logging/LogEnvironmentPostProcessor.java | LogEnvironmentPostProcessor | initLoggingConfig | class LogEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
public static final int ORDER = ConfigDataEnvironmentPostProcessor.ORDER + 1;
/**
* support use config to disable sofa common thread pool monitor.
*/
public static final String SOFA_THR... |
Map<String, String> context = new HashMap<>();
loadLogConfiguration(Constants.LOG_PATH, environment.getProperty(Constants.LOG_PATH),
Constants.LOGGING_PATH_DEFAULT, context);
loadLogConfiguration(Constants.OLD_LOG_PATH,
environment.getProperty(Constants.OLD_LOG_PATH), co... | 508 | 341 | 849 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/spring/namespace/handler/SofaBootNamespaceHandler.java | SofaBootNamespaceHandler | registerTagParser | class SofaBootNamespaceHandler extends NamespaceHandlerSupport {
private static final Logger logger = SofaBootLoggerFactory
.getLogger(SofaBootNamespaceHandler.class);
@Override
public void init() {
List<SofaBootTagNameSupport> sofaBootTagNameSupports = S... |
if (tagNameSupport instanceof BeanDefinitionParser) {
registerBeanDefinitionParser(tagNameSupport.supportTagName(),
(BeanDefinitionParser) tagNameSupport);
} else if (tagNameSupport instanceof BeanDefinitionDecorator) {
registerBeanDefinitionDecoratorForAttribute... | 153 | 154 | 307 | <methods>public void <init>() ,public org.springframework.beans.factory.config.BeanDefinitionHolder decorate(org.w3c.dom.Node, org.springframework.beans.factory.config.BeanDefinitionHolder, org.springframework.beans.factory.xml.ParserContext) ,public org.springframework.beans.factory.config.BeanDefinition parse(org.w3c... |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/spring/parameter/LocalVariableTableParameterNameDiscoverer.java | LocalVariableTableVisitor | resolveExecutable | class LocalVariableTableVisitor extends MethodVisitor {
private static final String CONSTRUCTOR = "<init>";
private final Class<?> clazz;
private final Map<Executable, String[]> executableMap;
private final String name;
private... |
ClassLoader loader = this.clazz.getClassLoader();
Class<?>[] argTypes = new Class<?>[this.args.length];
for (int i = 0; i < this.args.length; i++) {
argTypes[i] = ClassUtils.resolveClassName(this.args[i].getClassName(), loader);
}
try {
... | 762 | 210 | 972 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/startup/StartupReporterBeanPostProcessor.java | StartupReporterBeanPostProcessor | postProcessBeforeInitialization | class StartupReporterBeanPostProcessor implements BeanPostProcessor {
private final StartupReporter startupReporter;
public StartupReporterBeanPostProcessor(StartupReporter startupReporter) {
this.startupReporter = startupReporter;
}
@Override
@Nullable
public Object postProcessBefore... |
if (bean instanceof StartupReporterAware) {
((StartupReporterAware) bean).setStartupReporter(startupReporter);
}
return bean;
| 113 | 48 | 161 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/startup/StartupSmartLifecycle.java | StartupSmartLifecycle | start | class StartupSmartLifecycle implements SmartLifecycle, ApplicationContextAware {
public static final String ROOT_MODULE_NAME = "ROOT_APPLICATION_CONTEXT";
private final StartupReporter startupReporter;
private ConfigurableApplicationContext applicationContext;
public StartupSmar... |
// init ContextRefreshStageStat
ChildrenStat<ModuleStat> stat = new ChildrenStat<>();
stat.setName(APPLICATION_CONTEXT_REFRESH_STAGE);
stat.setEndTime(System.currentTimeMillis());
// build root ModuleStat
ModuleStat rootModuleStat = new ModuleStat();
rootModuleS... | 242 | 202 | 444 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/startup/StartupSpringApplication.java | StartupSpringApplication | applyInitializers | class StartupSpringApplication extends SpringApplication {
private final List<BaseStat> initializerStartupStatList = new ArrayList<>();
public StartupSpringApplication(Class<?>... primarySources) {
super(primarySources);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
prote... |
for (ApplicationContextInitializer initializer : getInitializers()) {
Class<?> requiredType = GenericTypeResolver.resolveTypeArgument(initializer.getClass(),
ApplicationContextInitializer.class);
if (requiredType != null) {
Assert.isInstanceOf(requiredTyp... | 146 | 168 | 314 | <methods>public transient void <init>(Class<?>[]) ,public transient void <init>(org.springframework.core.io.ResourceLoader, Class<?>[]) ,public void addBootstrapRegistryInitializer(org.springframework.boot.BootstrapRegistryInitializer) ,public transient void addInitializers(ApplicationContextInitializer<?>[]) ,public t... |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/startup/StartupSpringApplicationRunListener.java | StartupSpringApplicationRunListener | environmentPrepared | class StartupSpringApplicationRunListener implements SpringApplicationRunListener, Ordered {
private final SpringApplication application;
private final String[] args;
private final StartupReporter startupReporter;
private final ApplicationStartup userApplicationStartup;
... |
environmentPrepareStage = new BaseStat();
environmentPrepareStage.setName(BootStageConstants.ENVIRONMENT_PREPARE_STAGE);
environmentPrepareStage.setStartTime(jvmStartingStage.getEndTime());
environmentPrepareStage.setEndTime(System.currentTimeMillis());
startupReporter.setAppNam... | 1,418 | 272 | 1,690 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/util/BeanDefinitionUtil.java | BeanDefinitionUtil | resolveBeanClassType | class BeanDefinitionUtil {
/**
* {@link AnnotatedGenericBeanDefinition}
* {@link ScannedGenericBeanDefinition}
* {@link GenericBeanDefinition}
* {@link org.springframework.beans.factory.support.ChildBeanDefinition}
* {@link org.springframework.beans.factory.support.RootBeanDefinition}
... |
Class<?> clazz = null;
if (beanDefinition instanceof AnnotatedBeanDefinition) {
String className;
if (isFromConfigurationSource(beanDefinition)) {
MethodMetadata methodMetadata = ((AnnotatedBeanDefinition) beanDefinition)
.getFactoryMethodMet... | 254 | 389 | 643 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/util/ClassLoaderContextUtils.java | ClassLoaderContextUtils | callWithTemporaryContextClassloader | class ClassLoaderContextUtils {
/**
* Store thread context classloader then use new classloader to invoke runnable,
* finally reset thread context classloader.
* @param runnable runnable to invoke
* @param newClassloader classloader used to invoke runnable
*/
public static void runWith... |
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(newClassloader);
try {
return callable.call();
} catch (Exception e) {
throw new RuntimeException("Failed to invoke callable", e);
} ... | 284 | 97 | 381 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/util/SmartAnnotationUtils.java | SmartAnnotationUtils | getAnnotations | class SmartAnnotationUtils {
/**
* 使用 {@link MergedAnnotations.SearchStrategy#TYPE_HIERARCHY} 搜索策略获取最近的注解集合
* <p> 如果元素上无注解,返回空的集合
* <p> 如果元素上仅有一个注解,返回包含该注解的集合
* <p> 如果元素上有多个注解,通过 {@link MergedAnnotations#get(Class)} 方法拿到最近的注解,返回的集合仅包含最近的注解所在元素上的注解
*
* @param element 注解所在元素
* @par... |
MergedAnnotations annotations = MergedAnnotations.from(element, searchStrategy);
List<T> sofaServiceList = annotations.stream(annotationType).map(MergedAnnotation::synthesize).collect(Collectors.toList());
if (sofaServiceList.size() > 1) {
// 如果存在多个注解,先通过 get 方法拿到最高优先级的注解所在的 element... | 537 | 222 | 759 | <no_super_class> |
sofastack_sofa-boot | sofa-boot/sofa-boot-project/sofa-boot/src/main/java/com/alipay/sofa/boot/util/SofaBootEnvUtils.java | SofaBootEnvUtils | initLocalEnv | class SofaBootEnvUtils {
/**
* Property name for bootstrap configuration class name.
*/
public static final String CLOUD_BOOTSTRAP_CONFIGURATION_CLASS = "org.springframework.cloud.bootstrap.BootstrapConfiguration";
/**
* Boolean if bootstrap configuration class exists.
*/
p... |
if (Boolean.getBoolean(LOCAL_ENV_KEY)) {
LOCAL_ENV = true;
return;
}
try {
Class.forName(INTELLIJ_IDE_MAIN_CLASS);
LOCAL_ENV = true;
} catch (ClassNotFoundException e) {
LOCAL_ENV = false;
}
| 1,084 | 92 | 1,176 | <no_super_class> |
noear_solon | solon/__hatch/solon.boot.reactor-netty/src/main/java/org/noear/solon/boot/reactornetty/HttpRequestParser.java | HttpRequestParser | parse | class HttpRequestParser {
private final DefaultFullHttpRequest _request;
protected final Map<String, List<String>> parmMap = new HashMap<>();
protected final Map<String, List<UploadedFile>> fileMap = new HashMap<>();
public HttpRequestParser(DefaultFullHttpRequest req) {
_request = req;
}
... |
HttpMethod method = _request.method();
// url 参数
if (_request.uri().indexOf("?") > 0) {
QueryStringDecoder decoder = new QueryStringDecoder(_request.uri());
decoder.parameters().entrySet().forEach(entry -> {
parmMap.put(entry.getKey(), entry.getValue())... | 112 | 586 | 698 | <no_super_class> |
noear_solon | solon/__hatch/solon.boot.reactor-netty/src/main/java/org/noear/solon/boot/reactornetty/RnHttpContext.java | RnHttpContext | cookieSet | class RnHttpContext extends WebContextBase {
private final HttpServerRequest _request;
private final HttpServerResponse _response;
private final HttpRequestParser _request_parse;
public RnHttpContext(HttpServerRequest request, HttpServerResponse response, HttpRequestParser request_parse) {
_requ... |
StringBuilder sb = new StringBuilder();
sb.append(key).append("=").append(val).append(";");
if (Utils.isNotEmpty(path)) {
sb.append("path=").append(path).append(";");
}
if (maxAge >= 0) {
sb.append("max-age=").append(maxAge).append(";");
}
... | 1,851 | 160 | 2,011 | <methods>public non-sealed void <init>() ,public java.lang.String contentCharset() ,public java.lang.String contentType() ,public void filesDelete() throws java.io.IOException,public void outputAsFile(org.noear.solon.core.handle.DownloadedFile) throws java.io.IOException,public void outputAsFile(java.io.File) throws ja... |
noear_solon | solon/__hatch/solon.boot.reactor-netty/src/main/java/org/noear/solon/boot/reactornetty/RnHttpHandler.java | RnHttpHandler | apply | class RnHttpHandler implements BiFunction<HttpServerRequest, HttpServerResponse, Publisher<Void>> {
@Override
public Publisher<Void> apply(HttpServerRequest request, HttpServerResponse response) {<FILL_FUNCTION_BODY>}
protected ByteBuf applyDo(HttpServerRequest request, HttpServerResponse response, ByteB... |
List<ByteBuf> ary = new ArrayList<>();
request.receive().aggregate().map(m->{
ary.add(m);
return m;
}).subscribe().dispose();
// Mono<ByteBuf> mono = request.receive()
// .aggregate()
// .map(byteBuf -> applyDo(request, response... | 354 | 178 | 532 | <no_super_class> |
noear_solon | solon/__hatch/solon.boot.reactor-netty/src/main/java/org/noear/solon/boot/reactornetty/XPluginImp.java | XPluginImp | start0 | class XPluginImp implements Plugin {
DisposableServer _server = null;
public static String solon_boot_ver() {
return "reactor-netty-http 1.0.20/" + Solon.version();
}
@Override
public void start(AppContext context) {
if (Solon.app().enableHttp() == false) {
return;
... |
long time_start = System.currentTimeMillis();
try {
RnHttpHandler handler = new RnHttpHandler();
//
// https://projectreactor.io/docs/netty/release/reference/index.html#_starting_and_stopping_2
//
_server = HttpServer.create()
... | 239 | 292 | 531 | <no_super_class> |
noear_solon | solon/__hatch/solon.serialization.avro/src/main/java/org/noear/solon/serialization/avro/AvroSerializer.java | AvroSerializer | serialize | class AvroSerializer implements StringSerializer {
@Override
public String serialize(Object obj) throws IOException {<FILL_FUNCTION_BODY>}
} |
DatumWriter datumWriter = new SpecificDatumWriter(obj.getClass());
ByteArrayOutputStream out = new ByteArrayOutputStream();
BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(out, null);
datumWriter.write(obj, encoder);
return out.toString();
| 40 | 79 | 119 | <no_super_class> |
noear_solon | solon/__hatch/solon.serialization.avro/src/main/java/org/noear/solon/serialization/avro/XPluginImp.java | XPluginImp | start | class XPluginImp implements Plugin {
public static boolean output_meta = false;
@Override
public void start(AppContext context) {<FILL_FUNCTION_BODY>}
} |
output_meta = Solon.cfg().getInt("solon.output.meta", 0) > 0;
//RenderManager.register(render);
RenderManager.mapping("@avro", new AvroStringRender());
| 51 | 59 | 110 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-breaker/guava-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/guava/impl/CloudBreakerEntryImpl.java | CloudBreakerEntryImpl | enter | class CloudBreakerEntryImpl extends BreakerEntrySim {
RateLimiter limiter;
int thresholdValue;
public CloudBreakerEntryImpl(int permitsPerSecond) {
this.thresholdValue = permitsPerSecond;
loadRules();
}
private void loadRules(){
limiter = RateLimiter.create(thresholdValue)... |
if (limiter.tryAcquire()) {
return this;
} else {
throw new BreakerException();
}
| 172 | 36 | 208 | <methods>public non-sealed void <init>() ,public abstract void reset(int) <variables> |
noear_solon | solon/solon-projects-cloud/solon-cloud-breaker/semaphore-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/semaphore/impl/CloudBreakerEntryImpl.java | CloudBreakerEntryImpl | enter | class CloudBreakerEntryImpl extends BreakerEntrySim {
String breakerName;
int thresholdValue;
Semaphore limiter;
public CloudBreakerEntryImpl(String breakerName, int permits) {
this.breakerName = breakerName;
this.thresholdValue = permits;
this.limiter = new Semaphore(permits);
... |
if (limiter.tryAcquire()) {
return this;
} else {
throw new BreakerException();
}
| 202 | 36 | 238 | <methods>public non-sealed void <init>() ,public abstract void reset(int) <variables> |
noear_solon | solon/solon-projects-cloud/solon-cloud-breaker/sentinel-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/sentinel/impl/CloudBreakerEntryImpl.java | CloudBreakerEntryImpl | loadRules | class CloudBreakerEntryImpl extends BreakerEntrySim {
String breakerName;
int thresholdValue;
public CloudBreakerEntryImpl(String breakerName, int permits) {
this.breakerName = breakerName;
this.thresholdValue = permits;
loadRules();
}
private void loadRules(){<FILL_FUNCTI... |
List<FlowRule> ruleList = new ArrayList<>();
FlowRule rule = null;
rule = new FlowRule();
rule.setResource(breakerName);
rule.setGrade(RuleConstant.FLOW_GRADE_QPS); //qps
rule.setCount(thresholdValue);
ruleList.add(rule);
rule = new FlowRule();
... | 207 | 168 | 375 | <methods>public non-sealed void <init>() ,public abstract void reset(int) <variables> |
noear_solon | solon/solon-projects-cloud/solon-cloud-config/kubernetes-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/kubernetes/XPluginImp.java | XPluginImp | start | class XPluginImp implements Plugin {
private Timer clientTimer = new Timer();
/*
https://support.huaweicloud.com/sdkreference-cci/cci_09_0004.html
https://github.com/kubernetes-client/java/wiki/3.-Code-Examples
*/
@Override
public void start(AppContext context) {<FILL_FUNCTION_BODY>}
} |
CloudProps cloudProps = new CloudProps(context, "kubernetes");
if (Utils.isEmpty(cloudProps.getServer())) {
return;
}
//1.登记配置服务
if (cloudProps.getConfigEnable()) {
CloudConfigServiceK8sImpl serviceImp = new CloudConfigServiceK8sImpl(cloudProps);
... | 115 | 181 | 296 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-config/kubernetes-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/kubernetes/service/CloudConfigServiceK8sImpl.java | CloudConfigServiceK8sImpl | pull | class CloudConfigServiceK8sImpl extends TimerTask implements CloudConfigService {
final ApiClient client;
final CoreV1Api configApi;
private long refreshInterval;
public CloudConfigServiceK8sImpl(CloudProps cloudProps) {
try {
client = ClientBuilder.defaultClient();
con... |
try {
V1ConfigMap v1ConfigMap = configApi.readNamespacedConfigMap(name, group, null);
if(v1ConfigMap == null){
return null;
}
StringBuilder kvs = new StringBuilder();
v1ConfigMap.getData().forEach((k, v) -> {
kvs.appe... | 290 | 150 | 440 | <methods>public boolean cancel() ,public abstract void run() ,public long scheduledExecutionTime() <variables>static final int CANCELLED,static final int EXECUTED,static final int SCHEDULED,static final int VIRGIN,final java.lang.Object lock,long nextExecutionTime,long period,int state |
noear_solon | solon/solon-projects-cloud/solon-cloud-discovery/jmdns-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/jmdns/XPluginImp.java | XPluginImp | start | class XPluginImp implements Plugin {
CloudDiscoveryServiceJmdnsImpl discoveryServiceJmdnsImpl;
@Override
public void start(AppContext context) {<FILL_FUNCTION_BODY>}
@Override
public void stop() throws IOException {
if (discoveryServiceJmdnsImpl != null) {
discoveryServiceJmdns... |
CloudProps cloudProps = new CloudProps(context, "jmdns");
if (Utils.isEmpty(cloudProps.getServer())) {
return;
}
if (cloudProps.getDiscoveryEnable()) {
discoveryServiceJmdnsImpl = new CloudDiscoveryServiceJmdnsImpl(cloudProps);
CloudManager.register... | 104 | 98 | 202 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-discovery/jmdns-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/jmdns/service/CloudDiscoveryServiceJmdnsImpl.java | CloudDiscoveryServiceJmdnsImpl | attention | class CloudDiscoveryServiceJmdnsImpl implements CloudDiscoveryService {
/**
* solon 作为固定前缀,区分其他使用 JmDNS 应用
*/
public static final String PREFIX = "solon";
/**
* 服务所属域,使用 local 表示通过 mDNS 在局域网广播从而实现服务发现,其他值则涉及全局DNS服务器
*/
public static final String DOMAIN = "local";
/**
* JmD... |
if (Utils.isEmpty(group)) {
group = Solon.cfg().appGroup();
}
CloudDiscoveryObserverEntity entity = new CloudDiscoveryObserverEntity(group, service, observer);
Consumer<ServiceEvent> handle = event -> {
Discovery discovery = find(entity.group, service);
... | 1,216 | 202 | 1,418 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/activemq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/activemq/ActivemqProps.java | ActivemqProps | getTopicNew | class ActivemqProps {
public static final String GROUP_SPLIT_MARK = ":";
public static String getTopicNew(Event event){<FILL_FUNCTION_BODY>}
} |
//new topic
String topicNew;
if (Utils.isEmpty(event.group())) {
topicNew = event.topic();
} else {
topicNew = event.group() + ActivemqProps.GROUP_SPLIT_MARK + event.topic();
}
return topicNew;
| 54 | 79 | 133 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/activemq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/activemq/XPluginImp.java | XPluginImp | start | class XPluginImp implements Plugin {
@Override
public void start(AppContext context) throws Throwable {<FILL_FUNCTION_BODY>}
} |
CloudProps cloudProps = new CloudProps(context,"activemq");
if (Utils.isEmpty(cloudProps.getEventServer())) {
return;
}
if (cloudProps.getEventEnable()) {
CloudEventServiceActivemqImp eventServiceImp = new CloudEventServiceActivemqImp(cloudProps);
Clou... | 43 | 124 | 167 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/activemq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/activemq/impl/ActivemqConsumeHandler.java | ActivemqConsumeHandler | onReceiveDo | class ActivemqConsumeHandler implements MessageListener {
static final Logger log = LoggerFactory.getLogger(ActivemqConsumeHandler.class);
private CloudEventObserverManger observerManger;
private Session session;
public ActivemqConsumeHandler(CloudEventObserverManger observerManger, Session session) {... |
boolean isOk = true;
CloudEventHandler handler = null;
//new topic
String topicNew = getTopicNew(event);
handler = observerManger.getByTopic(topicNew);
if (handler != null) {
isOk = handler.handle(event);
} else {
//只需要记录一下
l... | 484 | 120 | 604 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/activemq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/activemq/impl/ActivemqConsumer.java | ActivemqConsumer | init | class ActivemqConsumer {
static Logger log = LoggerFactory.getLogger(ActivemqConsumer.class);
private ActiveMQConnectionFactory factory;
private ActivemqProducer producer;
private Connection connection;
private ActivemqConsumeHandler handler;
public ActivemqConsumer(ActiveMQConnectionFactory factory, ActivemqPro... |
if (connection != null) {
return;
}
connection = factory.createConnection();
connection.start();
//创建会话
Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
handler = new ActivemqConsumeHandler(observerManger, session);
//订阅所有主题
for (String topic : observerManger.topicA... | 170 | 169 | 339 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/activemq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/activemq/impl/ActivemqProducer.java | ActivemqProducer | init | class ActivemqProducer {
static Logger log = LoggerFactory.getLogger(ActivemqProducer.class);
private ActiveMQConnectionFactory factory;
private Connection connection;
public ActivemqProducer(ActiveMQConnectionFactory factory) {
this.factory = factory;
}
private void init() throws JMSException {<FILL_FUNCTION... |
if (connection == null) {
synchronized (factory) {
if (connection == null) {
connection = factory.createConnection();
connection.start();
}
}
}
| 482 | 56 | 538 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/activemq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/activemq/service/CloudEventServiceActivemqImp.java | CloudEventServiceActivemqImp | publish | class CloudEventServiceActivemqImp implements CloudEventServicePlus {
static Logger log = LoggerFactory.getLogger(CloudEventServiceActivemqImp.class);
private CloudProps cloudProps;
private ActivemqProducer producer;
private ActivemqConsumer consumer;
public CloudEventServiceActivemqImp(CloudProps ... |
if (Utils.isEmpty(event.topic())) {
throw new IllegalArgumentException("Event missing topic");
}
if (Utils.isEmpty(event.content())) {
throw new IllegalArgumentException("Event missing content");
}
if (Utils.isEmpty(event.key())) {
event.key... | 767 | 157 | 924 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/aliyun-ons-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/aliyun/ons/XPluginImp.java | XPluginImp | start | class XPluginImp implements Plugin {
@Override
public void start(AppContext context) {<FILL_FUNCTION_BODY>}
} |
CloudProps cloudProps = new CloudProps(context,"aliyun.ons");
if (Utils.isEmpty(cloudProps.getEventServer())) {
return;
}
if (cloudProps.getEventEnable()) {
CloudEventServiceOnsImp eventServiceImp = new CloudEventServiceOnsImp(cloudProps);
CloudMana... | 39 | 123 | 162 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/aliyun-ons-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/aliyun/ons/impl/OnsConfig.java | OnsConfig | getConsumerProperties | class OnsConfig {
static final Logger log = LoggerFactory.getLogger(OnsConfig.class);
private static final String PROP_EVENT_consumerGroup = "event.consumerGroup";
private static final String PROP_EVENT_producerGroup = "event.producerGroup";
private static final String PROP_EVENT_consumeThreadNums = "... |
Properties consumer = getBaseProperties();
consumer.put(PropertyKeyConst.GROUP_ID, consumerGroup);
//只能是集群模式
consumer.put(PropertyKeyConst.MessageModel, PropertyValueConst.CLUSTERING);
//实例的消费线程数
if (consumeThreadNums > 0) {
consumer.put(PropertyKeyConst.Cons... | 737 | 162 | 899 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/aliyun-ons-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/aliyun/ons/impl/OnsConsumer.java | OnsConsumer | init | class OnsConsumer {
static Logger log = LoggerFactory.getLogger(OnsConsumer.class);
private OnsConfig config;
private ConsumerBean consumer;
public OnsConsumer(OnsConfig config) {
this.config = config;
}
public void init(CloudProps cloudProps, CloudEventObserverManger observerManger) ... |
if (consumer != null) {
return;
}
Utils.locker().lock();
try {
if (consumer != null) {
return;
}
consumer = new ConsumerBean();
consumer.setProperties(config.getConsumerProperties());
OnsConsumer... | 104 | 369 | 473 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/aliyun-ons-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/aliyun/ons/impl/OnsConsumerHandler.java | OnsConsumerHandler | consume | class OnsConsumerHandler implements MessageListener {
static final Logger log = LoggerFactory.getLogger(OnsConsumerHandler.class);
private CloudEventObserverManger observerManger;
private OnsConfig config;
public OnsConsumerHandler(OnsConfig config, CloudEventObserverManger observerManger) {
... |
boolean isOk = true;
try {
String topicNew = message.getTopic();
String group = null;
String topic = null;
if (topicNew.contains(OnsProps.GROUP_SPLIT_MARK)) {
group = topicNew.split(OnsProps.GROUP_SPLIT_MARK)[0];
topic = t... | 357 | 306 | 663 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/aliyun-ons-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/aliyun/ons/impl/OnsProducer.java | OnsProducer | init | class OnsProducer {
static Logger log = LoggerFactory.getLogger(OnsProducer.class);
OnsConfig config;
Producer producer;
public OnsProducer(OnsConfig config) {
this.config = config;
}
private void init() {<FILL_FUNCTION_BODY>}
public boolean publish(Event event, String topic) {
... |
if (producer != null) {
return;
}
Utils.locker().lock();
try {
if (producer != null) {
return;
}
producer = ONSFactory.createProducer(config.getProducerProperties());
producer.start();
log.debug("... | 201 | 119 | 320 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/aliyun-ons-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/aliyun/ons/service/CloudEventServiceOnsImp.java | CloudEventServiceOnsImp | publish | class CloudEventServiceOnsImp implements CloudEventServicePlus {
private CloudProps cloudProps;
private OnsProducer producer;
private OnsConsumer consumer;
public CloudEventServiceOnsImp(CloudProps cloudProps) {
this.cloudProps = cloudProps;
OnsConfig config = new OnsConfig(cloudProps)... |
if (Utils.isEmpty(event.topic())) {
throw new IllegalArgumentException("Event missing topic");
}
if (Utils.isEmpty(event.content())) {
throw new IllegalArgumentException("Event missing content");
}
if (Utils.isEmpty(event.key())) {
event.key... | 467 | 210 | 677 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/folkmq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/folkmq/FolkmqProps.java | FolkmqProps | getTopicNew | class FolkmqProps {
public static final String GROUP_SPLIT_MARK = ":";
public static String getTopicNew(Event event){<FILL_FUNCTION_BODY>}
} |
//new topic
String topicNew;
if (Utils.isEmpty(event.group())) {
topicNew = event.topic();
} else {
topicNew = event.group() + FolkmqProps.GROUP_SPLIT_MARK + event.topic();
}
return topicNew;
| 54 | 79 | 133 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/folkmq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/folkmq/XPluginImpl.java | XPluginImpl | start | class XPluginImpl implements Plugin {
@Override
public void start(AppContext context) throws Throwable {<FILL_FUNCTION_BODY>}
} |
CloudProps cloudProps = new CloudProps(context,"folkmq");
if (Utils.isEmpty(cloudProps.getEventServer())) {
return;
}
if (cloudProps.getEventEnable()) {
CloudEventServiceFolkMqImpl eventServiceImp = new CloudEventServiceFolkMqImpl(cloudProps);
Cloud... | 42 | 123 | 165 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/folkmq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/folkmq/impl/FolkmqConsumeHandler.java | FolkmqConsumeHandler | onReceiveDo | class FolkmqConsumeHandler implements MqConsumeHandler {
static final Logger log = LoggerFactory.getLogger(FolkmqConsumeHandler.class);
private CloudEventObserverManger observerManger;
public FolkmqConsumeHandler(CloudEventObserverManger observerManger) {
this.observerManger = observerManger;
... |
boolean isOk = true;
CloudEventHandler handler = null;
//new topic
String topicNew = getTopicNew(event);
handler = observerManger.getByTopic(topicNew);
if (handler != null) {
isOk = handler.handle(event);
} else {
//只需要记录一下
l... | 460 | 120 | 580 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/folkmq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/folkmq/service/CloudEventServiceFolkMqImpl.java | CloudEventServiceFolkMqImpl | subscribe | class CloudEventServiceFolkMqImpl implements CloudEventServicePlus {
protected final MqClient client;
private final CloudProps cloudProps;
private final FolkmqConsumeHandler folkmqConsumeHandler;
private final CloudEventObserverManger observerManger;
private final long publishTimeout;
public C... |
if (observerManger.topicSize() > 0) {
Instance instance = Instance.local();
for (String topicNew : observerManger.topicAll()) {
client.subscribe(topicNew, instance.service(), folkmqConsumeHandler);
}
}
| 895 | 73 | 968 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/jedis-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/jedis/XPluginImp.java | XPluginImp | start | class XPluginImp implements Plugin {
@Override
public void start(AppContext context) {<FILL_FUNCTION_BODY>}
} |
CloudProps cloudProps = new CloudProps(context,"jedis");
if (cloudProps.getLockEnable() && Utils.isNotEmpty(cloudProps.getLockServer())) {
CloudLockServiceJedisImpl lockServiceImp = new CloudLockServiceJedisImpl(cloudProps);
CloudManager.register(lockServiceImp);
}
... | 40 | 181 | 221 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/jedis-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/jedis/impl/JedisEventConsumer.java | JedisEventConsumer | onReceiveDo | class JedisEventConsumer extends JedisPubSub {
static final Logger log = LoggerFactory.getLogger(JedisEventConsumer.class);
CloudEventObserverManger observerManger;
String eventChannelName;
public JedisEventConsumer(CloudProps cloudProps, CloudEventObserverManger observerManger) {
this.observe... |
boolean isOk = true;
CloudEventHandler handler = null;
//new topic
String topicNew;
if (Utils.isEmpty(event.group())) {
topicNew = event.topic();
} else {
topicNew = event.group() + JedisProps.GROUP_SPLIT_MARK + event.topic();
}
... | 363 | 171 | 534 | <methods>public void <init>() <variables> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/jedis-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/jedis/service/CloudEventServiceJedisImpl.java | CloudEventServiceJedisImpl | publish | class CloudEventServiceJedisImpl implements CloudEventServicePlus {
private final RedisClient client;
private final CloudProps cloudProps;
public CloudEventServiceJedisImpl(CloudProps cloudProps) {
Props props = cloudProps.getProp("event");
if (props.get("server") == null) {
p... |
if (Utils.isEmpty(event.topic())) {
throw new IllegalArgumentException("Event missing topic");
}
if (Utils.isEmpty(event.content())) {
throw new IllegalArgumentException("Event missing content");
}
if (Utils.isEmpty(event.key())) {
event.key... | 615 | 187 | 802 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/kafka-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/kafka/XPluginImpl.java | XPluginImpl | start | class XPluginImpl implements Plugin {
CloudEventServiceKafkaImpl eventServiceImpl;
@Override
public void start(AppContext context) {<FILL_FUNCTION_BODY>}
@Override
public void stop() throws Throwable {
if (eventServiceImpl != null) {
eventServiceImpl.close();
}
}
} |
CloudProps cloudProps = new CloudProps(context, "kafka");
if (Utils.isEmpty(cloudProps.getEventServer())) {
return;
}
if (cloudProps.getEventEnable()) {
eventServiceImpl = new CloudEventServiceKafkaImpl(cloudProps);
CloudManager.register(eventServic... | 94 | 112 | 206 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/kafka-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/kafka/impl/KafkaConfig.java | KafkaConfig | getProducerProperties | class KafkaConfig {
private final CloudProps cloudProps;
private final String server;
private final long publishTimeout;
private final String eventChannel;
private final String eventGroup;
public long getPublishTimeout() {
return publishTimeout;
}
public String getEventChanne... |
Properties properties = new Properties();
properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, server);
properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.g... | 515 | 258 | 773 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/kafka-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/kafka/service/CloudEventServiceKafkaImpl.java | CloudEventServiceKafkaImpl | publish | class CloudEventServiceKafkaImpl implements CloudEventServicePlus, Closeable {
static final Logger log = LoggerFactory.getLogger(CloudEventServiceKafkaImpl.class);
private final KafkaConfig config;
private KafkaProducer<String, String> producer;
private KafkaConsumer<String, String> consumer;
publ... |
initProducer();
if (Utils.isEmpty(event.key())) {
event.key(Utils.guid());
}
Future<RecordMetadata> future = producer.send(new ProducerRecord<>(event.topic(), event.key(), event.content()));
if (config.getPublishTimeout() > 0 && event.qos() > 0) {
try {... | 1,165 | 149 | 1,314 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt/XPluginImpl.java | XPluginImpl | start | class XPluginImpl implements Plugin {
@Override
public void start(AppContext context) {<FILL_FUNCTION_BODY>}
} |
CloudProps cloudProps = new CloudProps(context,"mqtt");
if (Utils.isEmpty(cloudProps.getEventServer())) {
return;
}
if (cloudProps.getEventEnable()) {
CloudEventServiceMqtt3 eventServiceImp = new CloudEventServiceMqtt3(cloudProps);
CloudManager.regi... | 38 | 146 | 184 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt/event/MqttDeliveryCompleteEvent.java | MqttDeliveryCompleteEvent | toString | class MqttDeliveryCompleteEvent implements Serializable {
private String clientId;
private int messageId;
private transient IMqttToken token;
public MqttDeliveryCompleteEvent(String clientId, int messageId, IMqttToken token){
this.clientId = clientId;
this.messageId = messageId;
... |
return "MqttDeliveryCompleteEvent{" +
"clientId='" + clientId + '\'' +
", messageId=" + messageId +
'}';
| 178 | 46 | 224 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt/service/CloudEventServiceMqtt3.java | CloudEventServiceMqtt3 | publish | class CloudEventServiceMqtt3 implements CloudEventServicePlus {
private final CloudProps cloudProps;
private final long publishTimeout;
private MqttClientManagerImpl clientManager;
private CloudEventObserverManger observerMap = new CloudEventObserverManger();
/**
* 获取客户端
*/
public... |
MqttMessage message = new MqttMessage();
message.setQos(event.qos());
message.setRetained(event.retained());
message.setPayload(event.content().getBytes());
try {
IMqttToken token = clientManager.getClient().publish(event.topic(), message);
if (!clientM... | 457 | 164 | 621 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt/service/MqttClientManagerImpl.java | MqttClientManagerImpl | messageArrived | class MqttClientManagerImpl implements MqttClientManager, MqttCallbackExtended {
private static final Logger log = LoggerFactory.getLogger(MqttClientManagerImpl.class);
private static final String PROP_EVENT_clientId = "event.clientId";
private final String server;
private final String username;
pr... |
if (log.isTraceEnabled()) {
log.trace("MQTT message arrived, clientId={}, messageId={}", clientId, message.getId());
}
CloudEventHandler eventHandler = observerManger.getByTopic(topic);
if (eventHandler != null) {
MqttMessageHandler handler = new MqttMessageHan... | 1,681 | 141 | 1,822 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt/service/MqttMessageHandler.java | MqttMessageHandler | run | class MqttMessageHandler implements Runnable {
private static Logger log = LoggerFactory.getLogger(MqttMessageListenerImpl.class);
private MqttClientManager clientManager;
private String eventChannelName;
private CloudEventHandler eventHandler;
private String topic;
private MqttMessage message;
... |
try {
Event event = new Event(topic, new String(message.getPayload()))
.qos(message.getQos())
.retained(message.isRetained())
.channel(eventChannelName);
if (eventHandler != null) {
if (eventHandler.handle(even... | 195 | 249 | 444 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt/service/MqttMessageListenerImpl.java | MqttMessageListenerImpl | messageArrived | class MqttMessageListenerImpl implements IMqttMessageListener {
private CloudEventHandler eventHandler;
private String eventChannelName;
private MqttClientManager clientManager;
public MqttMessageListenerImpl(MqttClientManager clientManager, String eventChannelName, CloudEventHandler eventHandler) {
... |
MqttMessageHandler handler = new MqttMessageHandler(clientManager, eventChannelName, eventHandler, topic, message);
if (clientManager.getAsync()) {
RunUtil.parallel(handler);
} else {
handler.run();
}
| 148 | 68 | 216 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt5-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt5/XPluginImpl.java | XPluginImpl | start | class XPluginImpl implements Plugin {
@Override
public void start(AppContext context) {<FILL_FUNCTION_BODY>}
} |
CloudProps cloudProps = new CloudProps(context, "mqtt");
if (Utils.isEmpty(cloudProps.getEventServer())) {
return;
}
if (cloudProps.getEventEnable()) {
CloudEventServiceMqtt5 eventServiceImp = new CloudEventServiceMqtt5(cloudProps);
CloudManager.reg... | 38 | 147 | 185 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt5-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt5/event/MqttDeliveryCompleteEvent.java | MqttDeliveryCompleteEvent | toString | class MqttDeliveryCompleteEvent implements Serializable {
private String clientId;
private int messageId;
private transient IMqttToken token;
public MqttDeliveryCompleteEvent(String clientId, int messageId, IMqttToken token){
this.clientId = clientId;
this.messageId = messageId;
... |
return "MqttDeliveryCompleteEvent{" +
"clientId='" + clientId + '\'' +
", messageId=" + messageId +
'}';
| 178 | 46 | 224 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt5-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt5/service/CloudEventServiceMqtt5.java | CloudEventServiceMqtt5 | publish | class CloudEventServiceMqtt5 implements CloudEventServicePlus {
private final CloudProps cloudProps;
private final long publishTimeout;
private MqttClientManagerImpl clientManager;
private CloudEventObserverManger observerMap = new CloudEventObserverManger();
/**
* 获取客户端
*/
public... |
MqttMessage message = new MqttMessage();
message.setQos(event.qos());
message.setRetained(event.retained());
message.setPayload(event.content().getBytes());
try {
IMqttToken token = clientManager.getClient().publish(event.topic(), message);
if (event.qo... | 457 | 157 | 614 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt5-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt5/service/MqttMessageHandler.java | MqttMessageHandler | run | class MqttMessageHandler implements Runnable{
private static Logger log = LoggerFactory.getLogger(MqttMessageListenerImpl.class);
private MqttClientManager clientManager;
private String eventChannelName;
private CloudEventHandler eventHandler;
private String topic;
private MqttMessage message;
... |
try {
Event event = new Event(topic, new String(message.getPayload()))
.qos(message.getQos())
.retained(message.isRetained())
.channel(eventChannelName);
if (eventHandler != null) {
if (eventHandler.handle(even... | 195 | 249 | 444 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/mqtt5-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/mqtt5/service/MqttMessageListenerImpl.java | MqttMessageListenerImpl | messageArrived | class MqttMessageListenerImpl implements IMqttMessageListener {
private CloudEventHandler eventHandler;
private String eventChannelName;
private MqttClientManager clientManager;
public MqttMessageListenerImpl(MqttClientManager clientManager, String eventChannelName, CloudEventHandler eventHandler) {
... |
MqttMessageHandler handler = new MqttMessageHandler(clientManager, eventChannelName, eventHandler, topic, message);
if (clientManager.getAsync()) {
RunUtil.parallel(handler);
} else {
handler.run();
}
| 148 | 68 | 216 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/pulsar-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/pulsar/XPluginImp.java | XPluginImp | start | class XPluginImp implements Plugin {
@Override
public void start(AppContext context) {<FILL_FUNCTION_BODY>}
} |
CloudProps cloudProps = new CloudProps(context,"pulsar");
if (Utils.isEmpty(cloudProps.getEventServer())) {
return;
}
if (cloudProps.getEventEnable()) {
CloudEventServicePulsarImp eventServiceImp = new CloudEventServicePulsarImp(cloudProps);
CloudMa... | 39 | 123 | 162 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/pulsar-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/pulsar/impl/PulsarMessageListenerImpl.java | PulsarMessageListenerImpl | onReceiveDo | class PulsarMessageListenerImpl implements MessageListener<byte[]> {
static final Logger log = LoggerFactory.getLogger(PulsarMessageListenerImpl.class);
private CloudEventObserverManger observerManger;
private String eventChannelName;
public PulsarMessageListenerImpl(CloudProps cloudProps, CloudEventO... |
boolean isOk = true;
CloudEventHandler handler = null;
//new topic
String topicNew;
if (Utils.isEmpty(event.group())) {
topicNew = event.topic();
} else {
topicNew = event.group() + PulsarProps.GROUP_SPLIT_MARK + event.topic();
}
... | 522 | 171 | 693 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/pulsar-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/pulsar/service/CloudEventServicePulsarImp.java | CloudEventServicePulsarImp | publish | class CloudEventServicePulsarImp implements CloudEventServicePlus {
private static final String PROP_EVENT_consumerGroup = "event.consumerGroup";
private static final String PROP_EVENT_producerGroup = "event.producerGroup";
private final CloudProps cloudProps;
private PulsarClient client;
public... |
if (Utils.isEmpty(event.topic())) {
throw new IllegalArgumentException("Event missing topic");
}
if (Utils.isEmpty(event.content())) {
throw new IllegalArgumentException("Event missing content");
}
if (Utils.isEmpty(event.key())) {
event.key... | 722 | 338 | 1,060 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/rabbitmq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/rabbitmq/XPluginImp.java | XPluginImp | start | class XPluginImp implements Plugin {
@Override
public void start(AppContext context) {<FILL_FUNCTION_BODY>}
} |
CloudProps cloudProps = new CloudProps(context,"rabbitmq");
if (Utils.isEmpty(cloudProps.getEventServer())) {
return;
}
if (cloudProps.getEventEnable()) {
CloudEventServiceRabbitmqImp eventServiceImp = new CloudEventServiceRabbitmqImp(cloudProps);
C... | 39 | 128 | 167 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/rabbitmq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/rabbitmq/impl/RabbitChannelFactory.java | RabbitChannelFactory | initChannel | class RabbitChannelFactory {
private ConnectionFactory connectionFactory;
private RabbitConfig config;
public RabbitChannelFactory(RabbitConfig config) {
this.config = config;
String host = config.server.split(":")[0];
int port = Integer.parseInt(config.server.split(":")[1]);
... |
//for exchange
channel.exchangeDeclare(config.exchangeName,
config.exchangeType,
config.durable,
config.autoDelete,
config.internal, new HashMap<>());
//for producer
if (config.publishTimeout > 0) {
channel.con... | 371 | 134 | 505 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/rabbitmq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/rabbitmq/impl/RabbitConfig.java | RabbitConfig | getVirtualHostInternal | class RabbitConfig {
static final Logger log = LoggerFactory.getLogger(RabbitConfig.class);
/**
* 虚拟主机
*/
public final String virtualHost;
/**
* 交换器名称
*/
public final String exchangeName;
/**
* 交换器类型
*/
public final BuiltinExchangeType exchangeType = BuiltinExch... |
String tmp = cloudProps.getValue(RabbitmqProps.PROP_EVENT_virtualHost);
if (Utils.isEmpty(tmp)) {
return Solon.cfg().appNamespace();
} else {
return tmp;
}
| 945 | 63 | 1,008 | <no_super_class> |
noear_solon | solon/solon-projects-cloud/solon-cloud-event/rabbitmq-solon-cloud-plugin/src/main/java/org/noear/solon/cloud/extend/rabbitmq/impl/RabbitConsumeTask.java | RabbitConsumeTask | onReceiveDo | class RabbitConsumeTask implements Runnable{
static final Logger log = LoggerFactory.getLogger(RabbitConsumeTask.class);
private String consumerTag;
private Envelope envelope;
private AMQP.BasicProperties properties;
private byte[] body;
private RabbitConsumeHandler master;
public RabbitC... |
boolean isOk = true;
CloudEventHandler handler = null;
//new topic
String topicNew;
if (Utils.isEmpty(event.group())) {
topicNew = event.topic();
} else {
topicNew = event.group() + RabbitmqProps.GROUP_SPLIT_MARK + event.topic();
}
... | 569 | 175 | 744 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.