There are a lot of reactive frameworks in the field, some with functional languages for the JVM. But Java9 give you both. But how you could combine this and use this without adding the next big framework to your project? We will have a Core Java journey to explore a lot of nice possibilities based on the the JDK.
3. @SvenRuppert
has been coding java since 1996
Projects in the field of:
•Automobile-industry
•Energy
•Finance / Leasing
•Space- Satellit-
•Government / UN / World-bank
Where?
•Europe
•Asia - from India up to Malaysia
2
83. Virtual Proxy
28
@SvenRuppert
public class ServiceProxy implements Service {
private Service service = new ServiceImpl();
public String work(String txt) { return service.work(txt); }
}
84. Virtual Proxy
28
@SvenRuppert
public class ServiceProxy implements Service {
private Service service = new ServiceImpl();
public String work(String txt) { return service.work(txt); }
}
What could we
change now ?
85. Virtual Proxy
28
@SvenRuppert
public class ServiceProxy implements Service {
private Service service = new ServiceImpl();
public String work(String txt) { return service.work(txt); }
}
What could we
change now ? Virtual Proxy:
create the Delegator later
86. Virtual Proxy
28
@SvenRuppert
public class ServiceProxy implements Service {
private Service service = new ServiceImpl();
public String work(String txt) { return service.work(txt); }
}
What could we
change now ? Virtual Proxy:
create the Delegator later
public class VirtualService implements Service {
private Service service = null;
public String work(String txt) {
if(service == null) { service = new ServiceImpl(); }
return service.work(txt);
}
}
87. Virtual Proxy
28
@SvenRuppert
public class ServiceProxy implements Service {
private Service service = new ServiceImpl();
public String work(String txt) { return service.work(txt); }
}
What could we
change now ? Virtual Proxy:
create the Delegator later
public class VirtualService implements Service {
private Service service = null;
public String work(String txt) {
if(service == null) { service = new ServiceImpl(); }
return service.work(txt);
}
}
88. Virtual Proxy
28
@SvenRuppert
public class ServiceProxy implements Service {
private Service service = new ServiceImpl();
public String work(String txt) { return service.work(txt); }
}
What could we
change now ? Virtual Proxy:
create the Delegator later
public class VirtualService implements Service {
private Service service = null;
public String work(String txt) {
if(service == null) { service = new ServiceImpl(); }
return service.work(txt);
}
}
89. Virtual Proxy
29
@SvenRuppert
public class VirtualService implements Service {
private Service service = null;
public String work(String txt) {
if(service == null) { service = new ServiceImpl(); }
return service.work(txt);
}
}
90. Virtual Proxy
29
@SvenRuppert
public class VirtualService implements Service {
private Service service = null;
public String work(String txt) {
if(service == null) { service = new ServiceImpl(); }
return service.work(txt);
}
}
91. Virtual Proxy
29
@SvenRuppert
public class VirtualService implements Service {
private Service service = null;
public String work(String txt) {
if(service == null) { service = new ServiceImpl(); }
return service.work(txt);
}
}
This is NOT ThreadSafe
92. Virtual Proxy
29
@SvenRuppert
public class VirtualService implements Service {
private Service service = null;
public String work(String txt) {
if(service == null) { service = new ServiceImpl(); }
return service.work(txt);
}
}
This is NOT ThreadSafe
93. Virtual Proxy
29
@SvenRuppert
public class VirtualService implements Service {
private Service service = null;
public String work(String txt) {
if(service == null) { service = new ServiceImpl(); }
return service.work(txt);
}
}
This is NOT ThreadSafe
fixed decision for
an implementation
94. Virtual Proxy
29
@SvenRuppert
public class VirtualService implements Service {
private Service service = null;
public String work(String txt) {
if(service == null) { service = new ServiceImpl(); }
return service.work(txt);
}
}
This is NOT ThreadSafe
fixed decision for
an implementation
95. Virtual Proxy
29
@SvenRuppert
public class VirtualService implements Service {
private Service service = null;
public String work(String txt) {
if(service == null) { service = new ServiceImpl(); }
return service.work(txt);
}
}
This is NOT ThreadSafe
fixed decision for
an implementation
how to combine it with
a FactoryPattern ?
100. Virtual Proxy
30
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public interface ServiceFactory {
Service createInstance();
}
public interface ServiceStrategyFactory {
Service realSubject(ServiceFactory factory);
}
101. Virtual Proxy - Not - ThreadSafe
31
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
102. Virtual Proxy - Not - ThreadSafe
31
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
103. Virtual Proxy - Not - ThreadSafe
31
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
private ServiceFactory serviceFactory = ServiceImpl::new;
104. Virtual Proxy - Not - ThreadSafe
31
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
private ServiceFactory serviceFactory = ServiceImpl::new;
105. Virtual Proxy - Not - ThreadSafe
31
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceStrategyFactoryImpl implements ServiceStrategyFactory {
Service realSubject;
public Service realSubject(final ServiceFactory factory) {
if (realSubject == null) {
realSubject = factory.createInstance();
}
return realSubject;
}
}
private ServiceFactory serviceFactory = ServiceImpl::new;
106. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
107. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceProxy implements Service {
108. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceProxy implements Service {
private ServiceFactory serviceFactory = ServiceImpl::new;
109. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceProxy implements Service {
private ServiceFactory serviceFactory = ServiceImpl::new;
private ServiceStrategyFactory strategyFactory = new ServiceStrategyFactoryImpl();
110. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceProxy implements Service {
private ServiceFactory serviceFactory = ServiceImpl::new;
private ServiceStrategyFactory strategyFactory = new ServiceStrategyFactoryImpl();
public String work(String txt) {
111. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceProxy implements Service {
private ServiceFactory serviceFactory = ServiceImpl::new;
private ServiceStrategyFactory strategyFactory = new ServiceStrategyFactoryImpl();
public String work(String txt) {
}
}
112. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceProxy implements Service {
private ServiceFactory serviceFactory = ServiceImpl::new;
private ServiceStrategyFactory strategyFactory = new ServiceStrategyFactoryImpl();
public String work(String txt) {
return
}
}
113. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceProxy implements Service {
private ServiceFactory serviceFactory = ServiceImpl::new;
private ServiceStrategyFactory strategyFactory = new ServiceStrategyFactoryImpl();
public String work(String txt) {
return strategyFactory
}
}
114. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceProxy implements Service {
private ServiceFactory serviceFactory = ServiceImpl::new;
private ServiceStrategyFactory strategyFactory = new ServiceStrategyFactoryImpl();
public String work(String txt) {
return strategyFactory .realSubject(
}
}
115. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceProxy implements Service {
private ServiceFactory serviceFactory = ServiceImpl::new;
private ServiceStrategyFactory strategyFactory = new ServiceStrategyFactoryImpl();
public String work(String txt) {
return strategyFactory .realSubject(serviceFactory
}
}
116. Virtual Proxy - Not - ThreadSafe
32
@SvenRuppert
if(service == null) { service = new ServiceImpl(); }
public class ServiceProxy implements Service {
private ServiceFactory serviceFactory = ServiceImpl::new;
private ServiceStrategyFactory strategyFactory = new ServiceStrategyFactoryImpl();
public String work(String txt) {
return strategyFactory .realSubject(serviceFactory).work(txt);
}
}