[Minor] code formatting
This commit is contained in:
parent
c3a6f7c25f
commit
a59272cfd2
|
@ -131,7 +131,6 @@ You change into the directory of the new project and then build the project by c
|
||||||
```shell
|
```shell
|
||||||
cd <my-artifactId>
|
cd <my-artifactId>
|
||||||
mvn clean package
|
mvn clean package
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Start the program using:
|
Start the program using:
|
||||||
|
|
|
@ -44,6 +44,8 @@ registered in the `StrolchConfiguration.xml` file with a
|
||||||
The dependencies is an important feature as the dependencies of a component
|
The dependencies is an important feature as the dependencies of a component
|
||||||
are always started before the actual component.
|
are always started before the actual component.
|
||||||
|
|
||||||
|
## Example Component implementation and configuration
|
||||||
|
|
||||||
By example of the `MailHandler` we shall show how a strolch component would
|
By example of the `MailHandler` we shall show how a strolch component would
|
||||||
be implemented.
|
be implemented.
|
||||||
|
|
||||||
|
@ -58,7 +60,7 @@ Then implement a concrete `MailHandler`:
|
||||||
```java
|
```java
|
||||||
public class SmtpMailHandler extends StrolchComponent implements MailHandler {
|
public class SmtpMailHandler extends StrolchComponent implements MailHandler {
|
||||||
|
|
||||||
// instance fields with configuration properties to send the mail
|
// TODO instance fields with configuration properties to send the mail
|
||||||
|
|
||||||
public SmtpMailHandler(ComponentContainer container, String componentName) {
|
public SmtpMailHandler(ComponentContainer container, String componentName) {
|
||||||
super(container, componentName);
|
super(container, componentName);
|
||||||
|
@ -67,7 +69,7 @@ public class SmtpMailHandler extends StrolchComponent implements MailHandler {
|
||||||
@Override
|
@Override
|
||||||
public void initialize(ComponentConfiguration configuration) throws Exception {
|
public void initialize(ComponentConfiguration configuration) throws Exception {
|
||||||
|
|
||||||
// store any properties needed from the configuration
|
// TODO store any properties needed from the configuration
|
||||||
|
|
||||||
super.initialize(configuration);
|
super.initialize(configuration);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +77,7 @@ public class SmtpMailHandler extends StrolchComponent implements MailHandler {
|
||||||
@Override
|
@Override
|
||||||
public void sendMail(String subject, String text, String recipient) {
|
public void sendMail(String subject, String text, String recipient) {
|
||||||
|
|
||||||
// send the e-mail using SMTP, or store in stack to send by thread
|
// TODO send the e-mail using SMTP, or send asynchronously
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -107,7 +109,12 @@ element:
|
||||||
Now when the agent is started, the component can be retrieved and used.
|
Now when the agent is started, the component can be retrieved and used.
|
||||||
E.g from inside a Service:
|
E.g from inside a Service:
|
||||||
```java
|
```java
|
||||||
MailHandler mailHandler = getComponent(MailHandler.class);
|
public class MyService extends AbstractService<ServiceArgument, ServiceResult> {
|
||||||
mailHandler.sendMail("My Subject", "Hello World", "test@test.ch");
|
@Override
|
||||||
|
protected ServiceResult internalDoService(ServiceArgument arg) throws Exception {
|
||||||
|
MailHandler mailHandler = getComponent(MailHandler.class);
|
||||||
|
mailHandler.sendMail("My Subject", "Hello World", "test@test.ch");
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,12 @@ The following is a simple list of do's and don'ts:
|
||||||
* Subclass `ResourceSearch`, `OrderSearch` and `ActivitySearch` when implementing use-case specific search - this allows privilege checking.
|
* Subclass `ResourceSearch`, `OrderSearch` and `ActivitySearch` when implementing use-case specific search - this allows privilege checking.
|
||||||
* One Transaction at a time - no TX inside of another TX.
|
* One Transaction at a time - no TX inside of another TX.
|
||||||
* Commands are added to TXs and performed on close: `tx.addCommand(Command)` and then `tx.commitOnClose()`
|
* Commands are added to TXs and performed on close: `tx.addCommand(Command)` and then `tx.commitOnClose()`
|
||||||
* Use `tx.flush()` if you need to perform first some work and then as late as possible call `tx.commitOnClose()`
|
|
||||||
* Only access `ElementMaps` if really no other way, mostly use `tx.get*By()`, `tx.findBy()` and searches - if a specific get is missing, then add the method to `StrolchTransaction` and send a pull request!
|
* Only access `ElementMaps` if really no other way, mostly use `tx.get*By()`, `tx.findBy()` and searches - if a specific get is missing, then add the method to `StrolchTransaction` and send a pull request!
|
||||||
* Use `tx.stream*()` methods to iterate over all elements, if you don't want to use a search.
|
* Use `tx.stream*()` methods to iterate over all elements, if you don't want to use a search.
|
||||||
* Don't write logic in REST API beans. Delegate to other services, making your code reusable!
|
* Don't write logic in REST API beans. Delegate to other services, making your code reusable!
|
||||||
* Transform to JSON using the `StrolchElementToJsonVisitor`.
|
* Marshall to JSON using the `StrolchElementToJsonVisitor`.
|
||||||
|
* Unmarshall JSON using `FromFlatJsonVisitor` or if needed `StrolchElementFromJsonVisitor`
|
||||||
* References between objects is done by adding a `ParameterBag` with the id `relations` to the object and then `StringParameters` with the value being the ID, the UOM set to the type of element being referenced and the Interpretation set to the class type being referenced.
|
* References between objects is done by adding a `ParameterBag` with the id `relations` to the object and then `StringParameters` with the value being the ID, the UOM set to the type of element being referenced and the Interpretation set to the class type being referenced.
|
||||||
|
* Very seldom and sparingly use `tx.flush()` if you need to perform first some work and then as late as possible call `tx.commitOnClose()`
|
||||||
|
|
||||||
|
The `flush()`-method flushes everything, i.e. rollback isn't possible anymore.
|
||||||
|
|
Loading…
Reference in New Issue