Skip to content

Commit

Permalink
[BLZT-70] whole markdown documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
romanovosad87 committed Dec 2, 2023
1 parent 2ed2697 commit e4dd773
Show file tree
Hide file tree
Showing 64 changed files with 532 additions and 229 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Annotation used to mark extensions for custom scanners, resolvers, or processors in the client's application.
* These extensions can be used to perform specific tasks related to bean scanning, resolving, or processing.
* In addition, we have some limitation on constructor some of the classes should have only default or one field.
* In addition, we have some limitation on constructor some classes should have only default or one field.
* for instance RestControllerBeanPostProcessor.
* This limitation only for customization scanners, resolvers, or processors
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ public class BeanAnnotationMissingException extends RuntimeException {
public BeanAnnotationMissingException(String message, Object... args) {
super(String.format(message, args));
}

}
72 changes: 35 additions & 37 deletions features/Core.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Bring Core

## General DI flow diagram
## General DI Flow Diagram

![Bring DI diagram](https://github.com/YevgenDemoTestOrganization/bring/assets/73576438/0e8d074a-3d49-4099-bf8e-68b029056cce)

1. The BringApplication provides a simple entry point to initialize and run a BringApplicationContext.
It allows the user to create and configure a BringApplicationContext either by specifying a base package for component scanning or by providing a class that contains configuration information.
2. The ClassPathScannerFactory is responsible for creating a set of class path scanners, each designed to scan the classpath for specific types of annotated classes relevant to the Bring application. It initializes scanners for components, services, and configuration classes etc.
3. The BeanPostProcessorDefinitionFactory is responsible for creating and managing a list of BeanFactoryPostProcessor instances. It initializes the list with default post-processors, such as the ConfigurationClassPostProcessor etc. In this step we create Bean definitions for classes annotated with annotations from ClassPathScanner
4. The next step will be go throw all bean definitions and register/create beans with dependencies
5. The last one BeanPostProcessorFactory is responsible for creating and managing a list BeanPostProcessor instances.
It initializes the list with default post-processors such as the ScheduleBeanPostProcessor and add addition logic to them.
1. The **BringApplication** provides a simple entry point to initialize and run a **BringApplicationContext**.
It allows the user to create and configure a **BringApplicationContext** either by specifying a base package for component scanning or by providing a class that contains configuration information.
2. The **ClassPathScannerFactory** is responsible for creating a set of class path scanners, each designed to scan the classpath for specific types of annotated classes relevant to the Bring application. It initializes scanners for components, services, and configuration classes etc.
3. The **BeanPostProcessorDefinitionFactory** is responsible for creating and managing a list of **BeanFactoryPostProcessor** instances. It initializes the list with default post-processors, such as the **ConfigurationClassPostProcessor** etc. In this step we create Bean definitions for classes annotated with annotations from **ClassPathScanner**.
4. The next step will be to go through all bean definitions and register/create beans with dependencies.
5. The last one **BeanPostProcessorFactory** is responsible for creating and managing a list **BeanPostProcessor** instances.
It initializes the list with default post-processors such as the **ScheduleBeanPostProcessor** and add addition logic to them.

## Documentations

Expand All @@ -29,45 +29,43 @@ It initializes the list with default post-processors such as the ScheduleBeanPos


- Configuration support
- [Annotation configuration](core/Component.md) `@Component`, `@Service`.
- [Annotation](core/Autowired.md) `@Autowired`
- [Java Configuration](core/Configuration.md) `@Bean`, `@Configuration`.
- [Annotation configuration](core/annotation/Component.md) `@Component`, `@Service`.
- [Annotation](core/annotation/Autowired.md) `@Autowired`
- [Java Configuration](core/annotation/Configuration.md) `@Bean`, `@Configuration`.


- Annotations
- [@Autowired](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/Autowired.html)
- [@Bean](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/Bean.html)
- [@BeanProcessor](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/BeanProcessor.html)
- [@Component](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/Component.html)
- [@Configuration](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/Configuration.html)
- [@Order](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/Order.html)
- [@PostConstruct](core/PostConstruct.md)
- [@PreDestroy](core/PreDestroy.md)
- [@Primary](core/Primary.md)
- [@Qualifier](core/Qualifier.md)
- [@ScheduledTask](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/ScheduledTask.html)
- [@Scope](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/package-summary.html#:~:text=a%20scheduled%20task.-,Scope,-Annotation%20indicating%20the)
- [@Service](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/Service.html)
- [@Value](core/Value.md)
- [@Autowired](core/annotation/Autowired.md)
- [@Bean](core/annotation/Bean.md)
- [@BeanProcessor](core/annotation/BeanProcessor.md)
- [@Component](core/annotation/Component.md)
- [@Configuration](core/annotation/Configuration.md)
- [@Order](core/annotation/Order.md)
- [@PostConstruct](core/annotation/PostConstruct.md)
- [@Primary](core/annotation/Primary.md)
- [@Qualifier](core/annotation/Qualifier.md)
- [@ScheduledTask](core/annotation/ScheduledTask.md)
- [@Scope](core/annotation/Scope.md)
- [@Service](core/annotation/Service.md)
- [@Value](core/annotation/Value.md)


- Exceptions
- [Circular Dependencies](core/CircularDependencies.md)
- [BeanAnnotationMissingException](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/exception/BeanAnnotationMissingException.html)
- [BeanPostProcessorConstructionLimitationException](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/exception/BeanPostProcessorConstructionLimitationException.html)
- [BringGeneralException](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/exception/BringGeneralException.html)
- [CyclicBeanException](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/exception/CyclicBeanException.html)
- [NoConstructorWithAutowiredAnnotationBeanException](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/exception/NoConstructorWithAutowiredAnnotationBeanException.html)
- [NoSuchBeanException](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/exception/NoSuchBeanException.html)
- [NoUniqueBeanException](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/exception/NoUniqueBeanException.html)
- [PostConstructException](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/exception/PostConstructException.html)
- [PropertyValueNotFoundException](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/exception/PropertyValueNotFoundException.html)
- [BeanAnnotationMissingException](core/exception/BeanAnnotationMissingException.md)
- [BeanPostProcessorConstructionLimitationException](core/exception/BringGeneralException.md)
- [BringGeneralException](core/exception/BringGeneralException.md)
- [CyclicBeanException](core/exception/CircularDependencies.md)
- [NoConstructorWithAutowiredAnnotationBeanException](core/exception/NoConstructorWithAutowiredAnnotationBeanException.md)
- [NoSuchBeanException](core/exception/NoSuchBeanException.md)
- [NoUniqueBeanException](core/exception/NoUniqueBeanException.md)
- [PostConstructException](core/exception/PostConstructException.md)
- [PreDestroyException](core/exception/PreDestroyException.md)
- [PropertyValueNotFoundException](core/exception/PropertyValueNotFoundException.md)



- addition items:
- additional items:
- [Scheduling](core/Scheduling.md)
- [Properties File Support](core/PropertiesFileSupport.md)
- [Logging](core/Logging.md)
- PreDestroy
- [Banner](core/Banner.md)
4 changes: 3 additions & 1 deletion features/Web.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Bring Web

## General Web flow diagram
## General Web Flow Diagram

![Bring DI diagram](https://github.com/YevgenDemoTestOrganization/bring/assets/114337016/06604708-d660-4e2c-ba08-ef8b215bbcb3)

Expand Down Expand Up @@ -44,6 +44,7 @@
- [Exception handler](web/servlet/JsonExceptionHandler.md): This component specializes in managing exceptions by intercepting and customizing error responses in JSON format. It extends ErrorReportValve to provide tailored error handling within a Servlet container.
- [Actuator](web/servlet/Actuator.md): Provides endpoints for checking application health, retrieving environment properties, Git information, and dynamically changing log levels.

[**Web Configuration Guide**](web/server/ConfigGuide.md)

- addition items:
- The code supports the generation of a random port based on the key ${random.port}. When this key is encountered as the value for a property, it is replaced with a randomly generated port number within the specified range. The range for the random port generation is defined by the constants START_PORT_RANGE and END_PORT_RANGE, which are set to 8000 and 9000, respectively. This feature allows dynamic allocation of ports, which can be useful in scenarios where a unique port is needed, and the actual port number is not predetermined but instead generated at runtime.
Expand Down Expand Up @@ -77,3 +78,4 @@ Exception scenarios:
- [RequestBodyTypeUnsupportedException](web/servlet/exception/RequestBodyTypeUnsupportedException.md)
- [RequestPathDuplicateException](web/servlet/exception/RequestPathDuplicateException.md)
- [TypeArgumentUnsupportedException](web/servlet/exception/TypeArgumentUnsupportedException.md)

56 changes: 0 additions & 56 deletions features/core/Autowired.md

This file was deleted.

2 changes: 2 additions & 0 deletions features/core/Banner.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

The `Banner` class provides functionality for printing a banner to the console, either from a predefined string or custom banner by reading from a file.

![DEFAULT_BANNER](https://github.com/YevgenDemoTestOrganization/bring/assets/114337016/9444e18e-e574-41a4-a41c-af72a4b0ef65)

The `Banner` class supports dynamic profile configuration using VM parameters.
The default `Mode` value is `ON`, meaning the banner will be printed to the console. To configure the `Mode` to `OFF`, use the `-Dbring.main.banner=off` parameter during application launch.
To print a custom banner, create a file named `banner.txt` in the `resources` folder and set `-Dbring.main.banner.file=resources/banner.txt` as a VM parameter.
Expand Down
61 changes: 0 additions & 61 deletions features/core/Value.md

This file was deleted.

27 changes: 27 additions & 0 deletions features/core/annotation/Autowired.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Autowired Annotation

**Annotation indicating that a field, constructor, or method should be autowired by the *Bring IoC* container.**

This annotation can be applied to fields, constructors, and methods in a *Bring* bean class to let Bring automatically inject the dependencies at runtime.

When applied to a field, the *Bring IoC* container will automatically inject a compatible bean, resolved by type, into the annotated field. When applied to a constructor, the container will use constructor injection to provide the required dependencies. If applied to a method, the container will invoke the method after initializing the bean, injecting the necessary dependencies into the method parameters.

This annotation is part of the *Bring Framework's* dependency injection mechanism, enabling the creation of loosely coupled and easily testable components.

**Usage Example:**
```java
@Component
public class MyComponent {

@Autowired
private MyDependency myDependency;

// Constructors and methods can also be annotated
@Autowired
public MyComponent(MyDependency myDependency) {
this.myDependency = myDependency;
}
}
```

- [Java Doc](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/Autowired.html)
32 changes: 32 additions & 0 deletions features/core/annotation/Bean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Bean Annotation

**Annotation indicating that a method will be used to create `Singleton` or `Prototype` Beans.**

The result of the method invocation is an object that represents a `Bean` that can be injected into other Beans
via constructor, field injection, or setter using the `Autowired` annotation.

This annotation should be used only for methods under a configuration class
(a class annotated with `@Configuration`). When applied to a method,
it becomes eligible for `Bean` definition registration and later used for `Bean` creation.

The name of the `Bean` will be the name of the method. Injection of another `Bean` via a parameter is possible by
adding a method parameter of the type and name of a bean already defined in the `Configuration` class.

**Usage Example:**
```java
@Configuration
public class MyConfiguration {

@Bean
public String stringBean1() {
return "Hello, 1";
}

@Bean
public String stringBean2(String stringBean1) {
return stringBean1 + "!";
}
}
```

- [Java Doc](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/Bean.html)
16 changes: 16 additions & 0 deletions features/core/annotation/BeanProcessor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# BeanProcessor Annotation

**Annotation used to mark extensions for custom scanners, resolvers, or processors in the client's application.**

These extensions can be used to perform specific tasks related to bean scanning, resolving, or processing.
In addition, there are some limitations on constructors. Some classes should have only the default constructor or one field,
for instance, `RestControllerBeanPostProcessor`.

**Usage Example:**
```java
@BeanProcessor
public class MyCustomProcessor {
// Your custom processing logic here
}
```
- [Java Doc](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/BeanProcessor.html)
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Component and Service Annotations

## Component Annotation

The `@Component` annotation in Bring indicates that an annotated class is a Bring component. This annotation serves as a marker for Bring to automatically detect and register the annotated class as a bean during component scanning.
Expand All @@ -25,28 +23,6 @@ public class AnotherComponent {
In the above example, `MyComponent` and `AnotherComponent` are annotated with `@Component`.
This allows Bring to automatically detect and register these classes as beans during component scanning.

## Service Annotation

The `@Service` annotation in Bring is also used to indicate that an annotated class is a Bring component.
It serves the same purpose as the `@Component` annotation, providing a marker for Bring to automatically
detect and register the annotated class as a bean during component scanning.

Similarly, you can customize the bean name using the value attribute.

### Usage Example:
[Java Doc](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/Component.html)

```java
@Service
public class MyComponent {
// Class definition
}

// Custom bean name
@Service("customBeanName")
public class AnotherComponent {
// Class definition
}
```

In this example, `MyComponent` and `AnotherComponent` are annotated with `@Service`.
This annotation is often used for classes that define business services or service components.
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public class MyConfiguration {
```
In this example, `MyConfiguration` is a configuration class annotated with `@Configuration`.
It declares two beans (myBean and anotherBean) using methods annotated with `@Bean`.
These beans will be registered with the Bring context during the application context initialization.
These beans will be registered with the Bring context during the application context initialization.

- [Java Doc](https://yevgendemotestorganization.github.io/bring-core-javadoc/com/bobocode/bring/core/annotation/Configuration.html)
Loading

0 comments on commit e4dd773

Please sign in to comment.