October 2017
Intermediate to advanced
396 pages
10h 2m
English
Let's look into following code to demonstrate the Proxy pattern.
Create a Subject.
Following is the Account.java file:
public interface Account {
void accountType();
}
Create a RealSubject class that implements Subject, let's see the following class as RealSubject class for the Proxy design pattern.
Following is the SavingAccount.java file:
public class SavingAccount implements Account{
public void accountType() {
System.out.println("SAVING ACCOUNT");
}
}
Create a Proxy class which implements Subject and having the Real Subject
Following is the ProxySavingAccount.java file:
package com.packt.patterninspring.chapter2.proxy.pattern; import com.packt.patterninspring.chapter2.model.Account; import com.packt.patterninspring.chapter2.model.SavingAccount; ...
Read now
Unlock full access