Skip to content

Commit

Permalink
fix error alert
Browse files Browse the repository at this point in the history
  • Loading branch information
dinstone committed Jan 6, 2024
1 parent 1ef6db1 commit bf35275
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 31 deletions.
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,25 @@ The quick start gives a basic example of running client and server on the same m
1. create maven project focus-quickstart and add dependencies to pom.

```xml
<dependency>
<groupId>com.dinstone.focus</groupId>
<artifactId>focus-server-photon</artifactId>
<version>1.1.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.dinstone.focus</groupId>
<artifactId>focus-client-photon</artifactId>
<version>1.1.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.dinstone.focus</groupId>
<artifactId>focus-serialize-json</artifactId>
<version>1.1.0</version>
</dependency>
<dependencies>
<dependency>
<groupId>com.dinstone.focus</groupId>
<artifactId>focus-server-photon</artifactId>
<version>1.1.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.dinstone.focus</groupId>
<artifactId>focus-client-photon</artifactId>
<version>1.1.0</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.dinstone.focus</groupId>
<artifactId>focus-serialize-json</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
```

2. create FooService interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class NacosServiceResolver extends DefaultServiceResolver {

private NamingService namingService;
private final NamingService namingService;

public NacosServiceResolver(NacosResolverOptions options) {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
com.dinstone.focus.server.nacos.NacosServiceResolver
com.dinstone.focus.server.nacos.NacosResolverFactory
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionR
AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent;
AnnotationMetadata annotationMetadata = beanDefinition.getMetadata();
Assert.isTrue(annotationMetadata.isInterface(),
"@FocusReference can only be specified on an interface");
"@ServiceReference can only be specified on an interface");

Map<String, Object> attributes = annotationMetadata
.getAnnotationAttributes(ServiceReference.class.getCanonicalName());

registerServiceReference(registry, annotationMetadata, attributes);
if (attributes != null) {
registerServiceReference(registry, annotationMetadata, attributes);
}
}
}

Expand Down Expand Up @@ -100,23 +101,25 @@ private void registerServiceReference(BeanDefinitionRegistry registry, Annotatio

BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(clazz);
GenericBeanDefinition beanDefinition = (GenericBeanDefinition) builder.getBeanDefinition();
beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(beanDefinition.getBeanClassName());
beanDefinition.setInstanceSupplier(() -> {
return factoryBean.getObject();
});
String beanClassName = beanDefinition.getBeanClassName();
if (beanClassName != null) {
beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(beanClassName);
}
beanDefinition.setInstanceSupplier(factoryBean::getObject);
beanDefinition.setFactoryBeanName(factoryBean.getClass().getSimpleName());
beanDefinition.setLazyInit(true);
beanDefinition.setPrimary(true);
registry.registerBeanDefinition(className, beanDefinition);
}

protected Set<String> getBasePackages(AnnotationMetadata metadata) {
Map<String, Object> attributes = metadata.getAnnotationAttributes(EnableFocusClient.class.getCanonicalName());

Set<String> basePackages = new HashSet<>();
for (String pkg : (String[]) attributes.get("value")) {
if (StringUtils.hasText(pkg)) {
basePackages.add(pkg);
Map<String, Object> attributes = metadata.getAnnotationAttributes(EnableFocusClient.class.getCanonicalName());
if (attributes != null) {
for (String pkg : (String[]) attributes.get("value")) {
if (StringUtils.hasText(pkg)) {
basePackages.add(pkg);
}
}
}
if (basePackages.isEmpty()) {
Expand Down

0 comments on commit bf35275

Please sign in to comment.