If-Then-Else construction In Angular

In Angular, using ngIf structural directive, we can achieve if-then-else functionality like below: myComponent.html: <p *ngIf=“myProperty ; else elseTemplate”> This element is rendered if myProperty is true </p> <ng-template #elseTemplate> <p> This element is only rendered if myProperty is false </p> </ngTemplate> myComponent.ts … … export myComponent {  myProperty: boolean = false; } ==============================   … More If-Then-Else construction In Angular

Domain Driven Design Context Map Integration Patterns

Shared Kernel Two or more teams shares some context. They are both and equally responsible from the shared context. Consumer/Supplier Consumer and the supplier has to work together. The consumer may veto the changes or may demand changes from the producer. Conformist The consumer and the producer are independent of each other and the producer … More Domain Driven Design Context Map Integration Patterns

Configuring Docker insecure repository ( server gave HTTP response to HTTPS client)

If docker gives the error “server gave HTTP response to HTTPS client” when starting a container, you can fix it by adding the following configuration: for never Docker releases, create or update the file /etc/docker/daemon.json as: { “insecure-registries”:[“MY_INSECURE_ADDRESS:5000”] } Replace MY_INSECURE_ADDRESS with your own address. for older Docker releases, create or update the file  /etc/init.d/docker as: DOCKER_OPTS=–insecure-registry MY_INSECURE_ADDRESS:5000 … More Configuring Docker insecure repository ( server gave HTTP response to HTTPS client)

CompletableFuture with timeout

Two CompletableFutures  can be combined to timeout the CompletableFuture with the business logic like below:  package competablefuture; import java.time.Duration; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; public class CompletableFutureSample { static ScheduledExecutorService pool = Executors.newScheduledThreadPool(4); public static CompletableFuture executeAsyncTimed(Duration duration) { final CompletableFuture asyncTimedFuture = new CompletableFuture<>(); pool.schedule(() -> asyncTimedFuture.completeExceptionally(new TimeoutException()), duration.toMillis(), … More CompletableFuture with timeout

JBOSS Wildfly XADataSourceClass is undefined

Sometimes, the server gives the following error after configuring the driver for the database: ERROR [org.jboss.jca.core.tx.jbossts.XAResourceRecoveryImpl] (Periodic Recovery) IJ000906: Error during crash recovery: java:/PostgresXADS (IJ031084: Unable to create connection): javax.resource.ResourceException: IJ031084: Unable to create connection at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:509) at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory$1$1.run(XAManagedConnectionFactory.java:395) at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory$1$1.run(XAManagedConnectionFactory.java:392) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory$1.run(XAManagedConnectionFactory.java:391) at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory$1.run(XAManagedConnectionFactory.java:388) at java.security.AccessController.doPrivileged(Native Method) at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:387) … More JBOSS Wildfly XADataSourceClass is undefined

RxJava Mapping functions

RxJava has several mapping functions. These functions transforms the emitted items to another form or value. The mapping functions are: map flatMap concatMap flatMapIterable switchMap   map function maps the items to another value of the same or different type @Test public void testobservableMap() { List<Integer> list = new ArrayList<>(); IntStream.range(0, 1000).forEach(list::add); Observable<Integer> observableFromCollection = … More RxJava Mapping functions

RxJava Operations on Observables

Filtering and other operations on Observables If only a subset of elements in a stream is needed, a filter can be used to eliminate the items not needed and let the observable emit only desired elements. @Test public void testCreateObservableFromCollectionWithFilter() { List<Integer> list = new ArrayList<>(); IntStream.range(0, 1000).forEach(list::add); Observable<Integer> observableFromCollection = Observable.from(list).filter(e -> e%2==0); observableFromCollection.subscribe(new … More RxJava Operations on Observables