├── decorator-pattern
├── Shape.java
├── Circle.java
├── Rectangle.java
├── ShapeDecorator.java
├── RedShapeDecorator.java
└── DecoratorPatternDemo.java
├── factory-pattern
├── Shape.java
├── Square.java
├── Circle.java
├── Rectangle.java
├── ShapeFactory.java
└── FactoryPatternDemo.java
├── abstract-factory-pattern
├── Color.java
├── Shape.java
├── AbstractFactory.java
├── Red.java
├── Square.java
├── Circle.java
├── Rectangle.java
├── Blue.java
├── Green.java
├── FactoryProducer.java
├── ColorFactory.java
├── ShapeFactory.java
└── AbstractFactoryPatternDemo.java
├── command
├── manifest.mf
├── src
│ └── command
│ │ ├── Order.java
│ │ ├── BuyStock.java
│ │ ├── SellStock.java
│ │ ├── Stock.java
│ │ ├── Broker.java
│ │ └── CommandDemo.java
├── nbproject
│ ├── genfiles.properties
│ ├── project.xml
│ ├── project.properties
│ └── build-impl.xml
└── build.xml
├── bridge-pattern
├── DrawAPI.java
├── Shape.java
├── RedCircle.java
├── GreenCircle.java
├── BridgePatternDemo.java
└── Circle.java
├── singleton
├── manifest.mf
├── src
│ └── singleton
│ │ ├── SingletonDemo.java
│ │ └── SingleObject.java
├── nbproject
│ ├── genfiles.properties
│ ├── project.xml
│ ├── project.properties
│ └── build-impl.xml
└── build.xml
├── Adapter-pattern
├── Client.java
└── Adapter.java
├── observer-pattern
├── Observer.java
├── OctalObserver.java
├── BinaryObserver.java
├── ObserverPatternDemo.java
└── Subject.java
├── .gitignore
├── facade-pattern
├── TestFacade.java
├── RunServer.java
├── ScheduleServerFacade.java
└── ScheduleServer.java
├── LICENSE
├── proxy-pattern
└── proxy.java
├── strategy-pattern
└── strategy.java
└── README.md
/decorator-pattern/Shape.java:
--------------------------------------------------------------------------------
1 | public interface Shape {
2 | void draw();
3 | }
4 |
--------------------------------------------------------------------------------
/factory-pattern/Shape.java:
--------------------------------------------------------------------------------
1 |
2 | public interface Shape {
3 | void draw();
4 | }
5 |
--------------------------------------------------------------------------------
/abstract-factory-pattern/Color.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public interface Color {
4 | void fill();
5 | }
6 |
--------------------------------------------------------------------------------
/abstract-factory-pattern/Shape.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public interface Shape {
4 | void draw();
5 | }
6 |
--------------------------------------------------------------------------------
/command/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/bridge-pattern/DrawAPI.java:
--------------------------------------------------------------------------------
1 | public interface DrawAPI {
2 | public void drawCircle(int radius, int x, int y);
3 | }
--------------------------------------------------------------------------------
/singleton/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/Adapter-pattern/Client.java:
--------------------------------------------------------------------------------
1 | Itarget target =
2 | new Adapter(
3 | new Adaptee();
4 | );
5 | target.request();
--------------------------------------------------------------------------------
/observer-pattern/Observer.java:
--------------------------------------------------------------------------------
1 | public abstract class Observer {
2 | protected Subject subject;
3 | public abstract void update();
4 | }
5 |
--------------------------------------------------------------------------------
/decorator-pattern/Circle.java:
--------------------------------------------------------------------------------
1 | public class Circle implements Shape {
2 |
3 | @Override
4 | public void draw() {
5 | System.out.println("Shape: Circle");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/decorator-pattern/Rectangle.java:
--------------------------------------------------------------------------------
1 | public class Rectangle implements Shape {
2 |
3 | @Override
4 | public void draw() {
5 | System.out.println("Shape: Rectangle");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/abstract-factory-pattern/AbstractFactory.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public abstract class AbstractFactory {
4 | abstract Color getColor(String color);
5 | abstract Shape getShape(String shape) ;
6 | }
--------------------------------------------------------------------------------
/abstract-factory-pattern/Red.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class Red implements Color {
4 |
5 | @Override
6 | public void fill() {
7 | System.out.println("Inside Red::fill() method.");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/factory-pattern/Square.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class Square implements Shape {
4 |
5 | @Override
6 | public void draw() {
7 | System.out.println("Inside Square::draw() method.");
8 | }
9 |
10 | }
--------------------------------------------------------------------------------
/abstract-factory-pattern/Square.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class Square implements Shape {
4 |
5 | @Override
6 | public void draw() {
7 | System.out.println("Inside Square::draw() method.");
8 | }
9 |
10 | }
--------------------------------------------------------------------------------
/bridge-pattern/Shape.java:
--------------------------------------------------------------------------------
1 | public abstract class Shape {
2 | protected DrawAPI drawAPI;
3 |
4 | protected Shape(DrawAPI drawAPI){
5 | this.drawAPI = drawAPI;
6 | }
7 | public abstract void draw();
8 | }
--------------------------------------------------------------------------------
/factory-pattern/Circle.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class Circle implements Shape {
4 |
5 | @Override
6 | public void draw() {
7 | System.out.println("Inside Circle::draw() method.");
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/factory-pattern/Rectangle.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class Rectangle implements Shape {
4 |
5 | @Override
6 | public void draw() {
7 | System.out.println("Inside Rectangle::draw() method.");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/abstract-factory-pattern/Circle.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class Circle implements Shape {
4 |
5 | @Override
6 | public void draw() {
7 | System.out.println("Inside Circle::draw() method.");
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/abstract-factory-pattern/Rectangle.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class Rectangle implements Shape {
4 |
5 | @Override
6 | public void draw() {
7 | System.out.println("Inside Rectangle::draw() method.");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/abstract-factory-pattern/Blue.java:
--------------------------------------------------------------------------------
1 | package com.company;
2 |
3 | public class Blue implements Color {
4 |
5 | @Override
6 | public void fill() {
7 | System.out.println("Inside Blue::fill() method.");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/abstract-factory-pattern/Green.java:
--------------------------------------------------------------------------------
1 | package com.company;
2 |
3 | public class Green implements Color {
4 |
5 | @Override
6 | public void fill() {
7 | System.out.println("Inside Green::fill() method.");
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/bridge-pattern/RedCircle.java:
--------------------------------------------------------------------------------
1 | public class RedCircle implements DrawAPI {
2 | @Override
3 | public void drawCircle(int radius, int x, int y) {
4 | System.out.println("Drawing Circle[ color: red, radius: " + radius + ", x: " + x + ", " + y + "]");
5 | }
6 | }
--------------------------------------------------------------------------------
/bridge-pattern/GreenCircle.java:
--------------------------------------------------------------------------------
1 | public class GreenCircle implements DrawAPI {
2 | @Override
3 | public void drawCircle(int radius, int x, int y) {
4 | System.out.println("Drawing Circle[ color: green, radius: " + radius + ", x: " + x + ", " + y + "]");
5 | }
6 | }
--------------------------------------------------------------------------------
/singleton/src/singleton/SingletonDemo.java:
--------------------------------------------------------------------------------
1 | package singleton;
2 |
3 | public class SingletonDemo {
4 |
5 | public static void main(String[] args) {
6 | SingleObject object = SingleObject.getInstance();
7 | object.showMessage();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/decorator-pattern/ShapeDecorator.java:
--------------------------------------------------------------------------------
1 | public abstract class ShapeDecorator implements Shape {
2 | protected Shape decoratedShape;
3 |
4 | public ShapeDecorator(Shape decoratedShape){
5 | this.decoratedShape = decoratedShape;
6 | }
7 |
8 | public void draw(){
9 | decoratedShape.draw();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/bridge-pattern/BridgePatternDemo.java:
--------------------------------------------------------------------------------
1 | public class BridgePatternDemo {
2 | public static void main(String[] args) {
3 | Shape redCircle = new Circle(100,100, 10, new RedCircle());
4 | Shape greenCircle = new Circle(100,100, 10, new GreenCircle());
5 |
6 | redCircle.draw();
7 | greenCircle.draw();
8 | }
9 | }
--------------------------------------------------------------------------------
/command/src/command/Order.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package command;
7 |
8 | /**
9 | *
10 | * @author inman
11 | */
12 | public interface Order {
13 | void execute();
14 | }
15 |
--------------------------------------------------------------------------------
/observer-pattern/OctalObserver.java:
--------------------------------------------------------------------------------
1 | public class OctalObserver extends Observer{
2 |
3 | public OctalObserver(Subject subject){
4 | this.subject = subject;
5 | this.subject.attach(this);
6 | }
7 |
8 | @Override
9 | public void update() {
10 | System.out.println( "Octal String: " + Integer.toOctalString( subject.getState() ) );
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/bridge-pattern/Circle.java:
--------------------------------------------------------------------------------
1 | public class Circle extends Shape {
2 | private int x, y, radius;
3 |
4 | public Circle(int x, int y, int radius, DrawAPI drawAPI) {
5 | super(drawAPI);
6 | this.x = x;
7 | this.y = y;
8 | this.radius = radius;
9 | }
10 |
11 | public void draw() {
12 | drawAPI.drawCircle(radius,x,y);
13 | }
14 | }
--------------------------------------------------------------------------------
/observer-pattern/BinaryObserver.java:
--------------------------------------------------------------------------------
1 | public class BinaryObserver extends Observer{
2 |
3 | public BinaryObserver(Subject subject){
4 | this.subject = subject;
5 | this.subject.attach(this);
6 | }
7 |
8 | @Override
9 | public void update() {
10 | System.out.println( "Binary String: " + Integer.toBinaryString( subject.getState() ) );
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Adapter-pattern/Adapter.java:
--------------------------------------------------------------------------------
1 | public class Adapter ITarget {
2 | Adaptee adaptee;
3 | public Adapter(Adaptee a) {
4 | this.adaptee = a;
5 | }
6 |
7 | public void request() {
8 | this.adaptee.specificRequest();
9 | }
10 | }
11 |
12 | public class Adaptee {
13 | public void specificRequest(){
14 | // Code for some specific request.
15 | }
16 | }
--------------------------------------------------------------------------------
/abstract-factory-pattern/FactoryProducer.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class FactoryProducer {
4 | public static AbstractFactory getFactory(String choice){
5 |
6 | if(choice.equalsIgnoreCase("SHAPE")){
7 | return new ShapeFactory();
8 |
9 | }else if(choice.equalsIgnoreCase("COLOR")){
10 | return new ColorFactory();
11 | }
12 |
13 | return null;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/observer-pattern/ObserverPatternDemo.java:
--------------------------------------------------------------------------------
1 | public class ObserverPatternDemo {
2 | public static void main(String[] args) {
3 | Subject subject = new Subject();
4 |
5 | new OctalObserver(subject);
6 | new BinaryObserver(subject);
7 |
8 | System.out.println("First state change: 15");
9 | subject.setState(15);
10 | System.out.println("Second state change: 10");
11 | subject.setState(10);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/decorator-pattern/RedShapeDecorator.java:
--------------------------------------------------------------------------------
1 | public class RedShapeDecorator extends ShapeDecorator {
2 |
3 | public RedShapeDecorator(Shape decoratedShape) {
4 | super(decoratedShape);
5 | }
6 |
7 | @Override
8 | public void draw() {
9 | decoratedShape.draw();
10 | setRedBorder(decoratedShape);
11 | }
12 |
13 | private void setRedBorder(Shape decoratedShape){
14 | System.out.println("Border Color: Red");
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.ear
17 | *.zip
18 | *.tar.gz
19 | *.rar
20 |
21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22 | hs_err_pid*
23 | /singleton/nbproject/private/
24 | /singleton/build/
25 | /command/nbproject/private/
26 | /command/build/
--------------------------------------------------------------------------------
/command/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=5341e12c
2 | build.xml.script.CRC32=a8cd507b
3 | build.xml.stylesheet.CRC32=8064a381@1.79.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=5341e12c
7 | nbproject/build-impl.xml.script.CRC32=a2377955
8 | nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48
9 |
--------------------------------------------------------------------------------
/singleton/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=91fe1efb
2 | build.xml.script.CRC32=845f39e7
3 | build.xml.stylesheet.CRC32=8064a381@1.79.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=91fe1efb
7 | nbproject/build-impl.xml.script.CRC32=95060f52
8 | nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48
9 |
--------------------------------------------------------------------------------
/facade-pattern/TestFacade.java:
--------------------------------------------------------------------------------
1 | package com.javacodegeeks.patterns.facadepattern;
2 |
3 | public class TestFacade {
4 |
5 | public static void main(String[] args) {
6 |
7 | ScheduleServer scheduleServer = new ScheduleServer();
8 | ScheduleServerFacade facadeServer = new ScheduleServerFacade(scheduleServer);
9 | facadeServer.startServer();
10 |
11 | System.out.println("Start working......");
12 | System.out.println("After work done.........");
13 |
14 | facadeServer.stopServer();
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/command/src/command/BuyStock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package command;
7 |
8 | /**
9 | *
10 | * @author inman
11 | */
12 | public class BuyStock implements Order {
13 | private Stock abcStock;
14 |
15 | public BuyStock(Stock abcStock){
16 | this.abcStock = abcStock;
17 | }
18 |
19 | public void execute() {
20 | abcStock.buy();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/command/src/command/SellStock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package command;
7 |
8 | /**
9 | *
10 | * @author inman
11 | */
12 | public class SellStock implements Order {
13 | private Stock abcStock;
14 |
15 | public SellStock(Stock abcStock){
16 | this.abcStock = abcStock;
17 | }
18 |
19 | public void execute() {
20 | abcStock.sell();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/command/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | command
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/singleton/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | singleton
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/decorator-pattern/DecoratorPatternDemo.java:
--------------------------------------------------------------------------------
1 | public class DecoratorPatternDemo {
2 | public static void main(String[] args) {
3 |
4 | Shape circle = new Circle();
5 |
6 | Shape redCircle = new RedShapeDecorator(new Circle());
7 |
8 | Shape redRectangle = new RedShapeDecorator(new Rectangle());
9 | System.out.println("Circle with normal border");
10 | circle.draw();
11 |
12 | System.out.println("\nCircle of red border");
13 | redCircle.draw();
14 |
15 | System.out.println("\nRectangle of red border");
16 | redRectangle.draw();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/factory-pattern/ShapeFactory.java:
--------------------------------------------------------------------------------
1 |
2 | public class ShapeFactory {
3 | //use getShape method to get object of type shape
4 | public Shape getShape(String shapeType){
5 | if(shapeType == null){
6 | return null;
7 | }
8 | if(shapeType.equalsIgnoreCase("CIRCLE")){
9 | return new Circle();
10 |
11 | } else if(shapeType.equalsIgnoreCase("RECTANGLE")){
12 | return new Rectangle();
13 |
14 | } else if(shapeType.equalsIgnoreCase("SQUARE")){
15 | return new Square();
16 | }
17 |
18 | return null;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/observer-pattern/Subject.java:
--------------------------------------------------------------------------------
1 | import java.util.ArrayList;
2 | import java.util.List;
3 |
4 | public class Subject {
5 |
6 | private List observers = new ArrayList();
7 | private int state;
8 |
9 | public int getState() {
10 | return state;
11 | }
12 |
13 | public void setState(int state) {
14 | this.state = state;
15 | notifyAllObservers();
16 | }
17 |
18 | public void attach(Observer observer){
19 | observers.add(observer);
20 | }
21 |
22 | public void notifyAllObservers(){
23 | for (Observer observer : observers) {
24 | observer.update();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/command/src/command/Stock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package command;
7 |
8 | /**
9 | *
10 | * @author inman
11 | */
12 | public class Stock {
13 | private String name = "ABC";
14 | private int quantity = 10;
15 |
16 | public void buy(){
17 | System.out.println("Stock [ Name: "+name+", Quantity: " + quantity +" ] bought");
18 | }
19 | public void sell(){
20 | System.out.println("Stock [ Name: "+name+", Quantity: " + quantity +" ] sold");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/abstract-factory-pattern/ColorFactory.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class ColorFactory extends AbstractFactory {
4 |
5 | @Override
6 | public Shape getShape(String shapeType){
7 | return null;
8 | }
9 |
10 | @Override
11 | Color getColor(String color) {
12 |
13 | if(color == null){
14 | return null;
15 | }
16 |
17 | if(color.equalsIgnoreCase("RED")){
18 | return new Red();
19 |
20 | }else if(color.equalsIgnoreCase("GREEN")){
21 | return new Green();
22 |
23 | }else if(color.equalsIgnoreCase("BLUE")){
24 | return new Blue();
25 | }
26 |
27 | return null;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/abstract-factory-pattern/ShapeFactory.java:
--------------------------------------------------------------------------------
1 |
2 | public class ShapeFactory extends AbstractFactory {
3 |
4 | @Override
5 | public Shape getShape(String shapeType){
6 |
7 | if(shapeType == null){
8 | return null;
9 | }
10 |
11 | if(shapeType.equalsIgnoreCase("CIRCLE")){
12 | return new Circle();
13 |
14 | }else if(shapeType.equalsIgnoreCase("RECTANGLE")){
15 | return new Rectangle();
16 |
17 | }else if(shapeType.equalsIgnoreCase("SQUARE")){
18 | return new Square();
19 | }
20 |
21 | return null;
22 | }
23 |
24 | @Override
25 | Color getColor(String color) {
26 | return null;
27 | }
28 | }
--------------------------------------------------------------------------------
/command/src/command/Broker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package command;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | /**
11 | *
12 | * @author inman
13 | */
14 | public class Broker {
15 | private List orderList = new ArrayList();
16 |
17 | public void takeOrder(Order order){
18 | orderList.add(order);
19 | }
20 |
21 | public void placeOrders(){
22 |
23 | for (Order order : orderList) {
24 | order.execute();
25 | }
26 | orderList.clear();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/singleton/src/singleton/SingleObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package singleton;
7 |
8 | /**
9 | *
10 | * @author inman
11 | */
12 | public class SingleObject {
13 | private static SingleObject instance;
14 |
15 | private SingleObject () {
16 | }
17 |
18 | public static SingleObject getInstance () {
19 | if (instance == null) {
20 | instance = new SingleObject();
21 | }
22 |
23 | return instance;
24 | }
25 |
26 | public void showMessage () {
27 | System.out.println("Hello World, This is singleton pattern.");
28 | }
29 | }
--------------------------------------------------------------------------------
/factory-pattern/FactoryPatternDemo.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class FactoryPatternDemo {
4 | public static void main(String[] args) {
5 |
6 | ShapeFactory shapeFactory = new ShapeFactory();
7 |
8 | //get an object of Circle and call its draw method.
9 | Shape shape1 = shapeFactory.getShape("CIRCLE");
10 |
11 | //call draw method of Circle
12 | shape1.draw();
13 |
14 | //get an object of Rectangle and call its draw method.
15 | Shape shape2 = shapeFactory.getShape("RECTANGLE");
16 |
17 | //call draw method of Rectangle
18 | shape2.draw();
19 |
20 | //get an object of Square and call its draw method.
21 | Shape shape3 = shapeFactory.getShape("SQUARE");
22 |
23 | //call draw method of circle
24 | shape3.draw();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/command/src/command/CommandDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package command;
7 |
8 | /**
9 | *
10 | * @author inman
11 | */
12 | public class CommandDemo {
13 |
14 | /**
15 | * @param args the command line arguments
16 | */
17 | public static void main(String[] args) {
18 | Stock abcStock = new Stock();
19 |
20 | BuyStock buyStockOrder = new BuyStock(abcStock);
21 | SellStock sellStockOrder = new SellStock(abcStock);
22 |
23 | Broker broker = new Broker();
24 | broker.takeOrder(buyStockOrder);
25 | broker.takeOrder(sellStockOrder);
26 |
27 | broker.placeOrders();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/facade-pattern/RunServer.java:
--------------------------------------------------------------------------------
1 | package com.javacodegeeks.patterns.facadepattern;
2 |
3 | public class RunServer {
4 |
5 | public static void main(String[] args) {
6 | ScheduleServer scheduleServer = new ScheduleServer();
7 |
8 | scheduleServer.startBooting();
9 | scheduleServer.readSystemConfigFile();
10 | scheduleServer.init();
11 | scheduleServer.initializeContext();
12 | scheduleServer.initializeListeners();
13 | scheduleServer.createSystemObjects();
14 |
15 | System.out.println("Start working......");
16 | System.out.println("After work done.........");
17 |
18 | scheduleServer.releaseProcesses();
19 | scheduleServer.destory();
20 | scheduleServer.destroySystemObjects();
21 | scheduleServer.destoryListeners();
22 | scheduleServer.destoryContext();
23 | scheduleServer.shutdown();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/facade-pattern/ScheduleServerFacade.java:
--------------------------------------------------------------------------------
1 | package com.javacodegeeks.patterns.facadepattern;
2 |
3 | public class ScheduleServerFacade {
4 |
5 | private final ScheduleServer scheduleServer;
6 |
7 | public ScheduleServerFacade(ScheduleServer scheduleServer){
8 | this.scheduleServer = scheduleServer;
9 | }
10 |
11 | public void startServer(){
12 |
13 | scheduleServer.startBooting();
14 | scheduleServer.readSystemConfigFile();
15 | scheduleServer.init();
16 | scheduleServer.initializeContext();
17 | scheduleServer.initializeListeners();
18 | scheduleServer.createSystemObjects();
19 | }
20 |
21 | public void stopServer(){
22 |
23 | scheduleServer.releaseProcesses();
24 | scheduleServer.destory();
25 | scheduleServer.destroySystemObjects();
26 | scheduleServer.destoryListeners();
27 | scheduleServer.destoryContext();
28 | scheduleServer.shutdown();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 komkanit
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/proxy-pattern/proxy.java:
--------------------------------------------------------------------------------
1 | public class RealImage implements Image {
2 |
3 | private String fileName;
4 |
5 | public RealImage(String fileName){
6 | this.fileName = fileName;
7 | loadFromDisk(fileName);
8 | }
9 |
10 | @Override
11 | public void display() {
12 | System.out.println("Displaying " + fileName);
13 | }
14 |
15 | private void loadFromDisk(String fileName){
16 | System.out.println("Loading " + fileName);
17 | }
18 | }
19 |
20 | public class ProxyImage implements Image{
21 |
22 | private RealImage realImage;
23 | private String fileName;
24 |
25 | public ProxyImage(String fileName){
26 | this.fileName = fileName;
27 | }
28 |
29 | @Override
30 | public void display() {
31 | if(realImage == null){
32 | realImage = new RealImage(fileName);
33 | }
34 | realImage.display();
35 | }
36 | }
37 |
38 | public class ProxyPatternDemo {
39 |
40 | public static void main(String[] args) {
41 | Image image = new ProxyImage("test_10mb.jpg");
42 |
43 | //image will be loaded from disk
44 | image.display();
45 | System.out.println("");
46 |
47 | //image will not be loaded from disk
48 | image.display();
49 | }
50 | }
--------------------------------------------------------------------------------
/facade-pattern/ScheduleServer.java:
--------------------------------------------------------------------------------
1 | package com.javacodegeeks.patterns.facadepattern;
2 |
3 | public class ScheduleServer {
4 |
5 | public void startBooting(){
6 | System.out.println("Starts booting...");
7 | }
8 |
9 | public void readSystemConfigFile(){
10 | System.out.println("Reading system config files...");
11 | }
12 |
13 | public void init(){
14 | System.out.println("Initializing...");
15 | }
16 |
17 | public void initializeContext(){
18 | System.out.println("Initializing context...");
19 | }
20 |
21 | public void initializeListeners(){
22 | System.out.println("Initializing listeners...");
23 | }
24 |
25 | public void createSystemObjects(){
26 | System.out.println("Creating system objects...");
27 | }
28 |
29 | public void releaseProcesses(){
30 | System.out.println("Releasing processes...");
31 | }
32 |
33 | public void destory(){
34 | System.out.println("Destorying...");
35 | }
36 |
37 | public void destroySystemObjects(){
38 | System.out.println("Destroying system objects...");
39 | }
40 |
41 | public void destoryListeners(){
42 | System.out.println("Destroying listeners...");
43 | }
44 |
45 | public void destoryContext(){
46 | System.out.println("Destroying context...");
47 | }
48 |
49 | public void shutdown(){
50 | System.out.println("Shutting down...");
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/abstract-factory-pattern/AbstractFactoryPatternDemo.java:
--------------------------------------------------------------------------------
1 |
2 |
3 | public class AbstractFactoryPatternDemo {
4 | public static void main(String[] args) {
5 |
6 | //get shape factory
7 | AbstractFactory shapeFactory = FactoryProducer.getFactory("SHAPE");
8 |
9 | //get an object of Shape Circle
10 | Shape shape1 = shapeFactory.getShape("CIRCLE");
11 |
12 | //call draw method of Shape Circle
13 | shape1.draw();
14 |
15 | //get an object of Shape Rectangle
16 | Shape shape2 = shapeFactory.getShape("RECTANGLE");
17 |
18 | //call draw method of Shape Rectangle
19 | shape2.draw();
20 |
21 | //get an object of Shape Square
22 | Shape shape3 = shapeFactory.getShape("SQUARE");
23 |
24 | //call draw method of Shape Square
25 | shape3.draw();
26 |
27 | //get color factory
28 | AbstractFactory colorFactory = FactoryProducer.getFactory("COLOR");
29 |
30 | //get an object of Color Red
31 | Color color1 = colorFactory.getColor("RED");
32 |
33 | //call fill method of Red
34 | color1.fill();
35 |
36 | //get an object of Color Green
37 | Color color2 = colorFactory.getColor("Green");
38 |
39 | //call fill method of Green
40 | color2.fill();
41 |
42 | //get an object of Color Blue
43 | Color color3 = colorFactory.getColor("BLUE");
44 |
45 | //call fill method of Color Blue
46 | color3.fill();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/strategy-pattern/strategy.java:
--------------------------------------------------------------------------------
1 | public interface Strategy {
2 | public int doOperation(int num1, int num2);
3 | }
4 |
5 | // สร้าง Stratergy 3แบบ เป็น behavior แยกจาก class
6 | public class OperationAdd implements Strategy {
7 | @Override
8 | public int doOperation(int num1, int num2) {
9 | return num1 + num2;
10 | }
11 | }
12 |
13 | public class OperationSubstract implements Strategy {
14 | @Override
15 | public int doOperation(int num1, int num2) {
16 | return num1 - num2;
17 | }
18 | }
19 |
20 | public class OperationMultiply implements Strategy{
21 | @Override
22 | public int doOperation(int num1, int num2) {
23 | return num1 * num2;
24 | }
25 | }
26 |
27 | // class ที่จะใส่พฤติกรรมเข้าไป
28 | public class Context {
29 | private Strategy strategy;
30 |
31 | public Context(Strategy strategy){
32 | this.strategy = strategy;
33 | }
34 |
35 | public int executeStrategy(int num1, int num2){
36 | return strategy.doOperation(num1, num2);
37 | }
38 | }
39 |
40 | public class StrategyPatternDemo {
41 | public static void main(String[] args) {
42 | Context context = new Context(new OperationAdd());
43 | System.out.println("10 + 5 = " + context.executeStrategy(10, 5));
44 |
45 | context = new Context(new OperationSubstract());
46 | System.out.println("10 - 5 = " + context.executeStrategy(10, 5));
47 |
48 | context = new Context(new OperationMultiply());
49 | System.out.println("10 * 5 = " + context.executeStrategy(10, 5));
50 | }
51 | }
--------------------------------------------------------------------------------
/command/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/command.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.7
40 | javac.target=1.7
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=command.CommandDemo
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/singleton/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/singleton.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.7
40 | javac.target=1.7
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=singleton.SingletonDemo
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/command/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project command.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/singleton/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project singleton.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # design-pattern
2 | Used of Software engineer final test.
3 |
4 | ## Note
5 |
6 | ### adapter pattern
7 | ตามหลักแล้วถ้าเราจะใช้ปลั๊กไฟแบบบ้านเราไปต่อต่างประเทศนั้น เราก็ต้องผ่าน
8 | Adapter ตัวนึงก่อนที่เข้ากับของเราได้ เพื่อไปใช้กับปลั๊กประเทศนั้นๆ
9 | เป็นการเปรียบเทียบกับ interface ของฝั่ง client request ไปที่ ITarget
10 | และต้องมี Adapter มาอีกต่อนึง โดย Adapter จะเรียกใช้ Adaptee เพื่อร้องขอ
11 | SpecificationRequest อีกทีหนึ่ง
12 | ### Strategy Pattern
13 |
14 | แยก behaviour ออกจาก class แม่
15 | เพื่อไม่ให้มีผลกระทบกับ class ลูกเสมอไป
16 | behaviour ที่แยกออกมาเรียกว่า strategy
17 |
18 | composition vs inheritance
19 |
20 | inheritance สิ่งหนึ่งเป็นอีกสิ่งหนึ่ง คือการสืบทอดพฤติกรรมต่อจากแม่ให้ลูก
21 |
22 | composition สิ่งหนึ่งมีอีกสิ่งหนึ่ง คือการใส่พฤติกรรมให้ class
23 |
24 | *** ทั้งสองสิ่งไม่ได้แยกจากกันโดยสมบูรณ์ สามารถใช้เสริมกันได้
25 |
26 | ตัวอย่างในไฟล์ strategy.java คือเราสร้าง class ชื่อ context เป็นตัวรับ behavior
27 | โดยที่มี strategy 3 อย่างคือ +, -, *
28 | แล้วเลือกว่าตอนเรียกใช้ context จะใส่ behaivior ไหนเข้าไป คือเราสามารถเปลี่ยนความสามารถของ class ในตอนที่ run time ได้
29 |
30 | ### Observer Pattern
31 | เป็น Pattern ที่เชื่อมโยง Object กันแบบ One-to-Many เมื่อ Subject มีการเปลี่ยนแปลง เหล่า Observer ทั้งหลายที่ Subscribe ก็จะรับรู้การเปลี่ยนแปลงนั้น เหมือนเป็น เหมือนเป็น Hub ข้อมูลกลาง และส่งข้อมูลใหเ Object อื่นๆใช้
32 | https://www.algorithmtut.com/algorithm-observer-design-pattern/
33 | https://www.tutorialspoint.com/design_pattern/observer_pattern.htm
34 | เนื้อหาในโค๊ดคร่าวๆ
35 | 1. ไฟล์ `Subject.java` method `attach` จะทำหน้าที่สร้าง Subscribe พอ `setState` จะสั่งให้ Subscribe ทั้งหมด `update`
36 | 2. ไฟล์ `BinaryObserver.java` มี method `update` ที่เอาทำจากข้อ 1
37 | 3. ไฟล์ `ObserverPatternDemo.java` เป็น main หลัก พอสั่ง `setState` method ทั้งหมดจะ `update`
38 | ```
39 | output
40 | First state change: 15
41 | Octal String: 17
42 | Binary String: 1111
43 | Second state change: 10
44 | Octal String: 12
45 | Binary String: 1010
46 | ```
47 |
48 |
49 | ### Decorator Pattern
50 | Decorator Pattern คือรูปแบบที่ช่วยให้เราสามารถเพิ่มเติม state และ พฤติกรรมใหม่ เข้าไปใน object แบบ dynamic ได้ นั่นคือการที่เราสามารถเพิ่ม state และ พฤติกรรมใหม่ เช่นนี้เข้าไปได้ เราจึงไม่จำเป็นต้องกลับไปแก้ไข code method หรือ state ของ object เดิมเลย
51 | https://www.tutorialspoint.com/design_pattern/decorator_pattern.htm
52 | 1. create `Shape.java`
53 | 2. create `Rectangle.java` and `Circle.java` and override method `draw`
54 | 3. create `ShapeDecorator.java` คือ Class ที่จะเอามาคลุม `Shape` ทำให้เราสามารถ custom ได้
55 | 4. create `RedShapeDecorator.java` extend `ShapeDecorator` เพื่อสร้าง Shape สีแดง
56 | 5. `DecoratorPatternDemo.java` เป็น main หลัก `Shape redCircle = new RedShapeDecorator(new Circle());` จะเป็นการสร้างวงกรมสีแดงขึ้นมา
57 |
58 | ```
59 | output
60 | Circle with normal border
61 | Shape: Circle
62 |
63 | Circle of red border
64 | Shape: Circle
65 | Border Color: Red
66 |
67 | Rectangle of red border
68 | Shape: Rectangle
69 | Border Color: Red
70 | ```
71 |
72 |
73 | ### Bridge Pattern
74 | คือ แนวคิดในการยืมความสามารถจาก Class ภายนอกมาใช้งาน ใช้สำหรับแก้ปัญหาการ couple ระหว่าง abstraction กับ implementation โดย class หลักที่เราจะใช้งานจะถูกเรียกว่า Abstraction และ class ที่เราจะยืมความสามารถมาจะเรียกว่า Implementor วิธีนี้แก้คือเราสร้าง abstraction ขึ้นมาคั่น ระหว่าง target กับ client เพื่อให้ client เห็นแค่ abstraction อันใหม่ จากนั้นเราจะแก้ abstraction นี้ยังไงก็ได้ โดยการแก้นั้นจะไม่ส่งผลกระทบอะไรกับ target (ดูความสัมพันธ์ในลิ้งด้านล่างแบบเห็นละรู้เลย)
75 | เนื้อหาในโค้ดคร่าวๆ
76 | 1. create 'DrawAPI.java' เป็นคำสั่งให้วาดวงกลม
77 | 2. create 'RedCircle.java' กับ 'GreenCircle.java' ไว้ implement DrawAPI มาใช้
78 | 3. create 'Shape.java' สร้างมารับค่าจะ user แล้วค่อยเรียกใช้คำสั่งจาก 'Circle.java'
79 | 4. create 'Circle.java' จะส่งคำสั่งกำหนดค่าและวาดรูปไปให้ Shape
80 | 5. create 'BridgePatternDemo.java' เรียกใช้ class Shape กับ DrawAPI เพื่อวาดวงกลมต่างสีกัน
81 |
82 | ```
83 | output
84 | Drawing Circle[ color: red, radius: 10, x: 100, 100]
85 | Drawing Circle[ color: green, radius: 10, x: 100, 100]
86 | ```
87 |
88 | อ้างอิงจาก http://manit-tree.blogspot.com/2012/07/design-pattern-bridge-pattern.html มีสรุปอยู่ด้านล่างเผื่ออ่านละยังงงอีก
89 | อ้างอิงจาก https://2bedev.com/365days-of-program-day-53/ มีตัวอย่างที่คิดว่าสรุปแล้วเห็นภาพเลยอยู่ด้านล่างเว็บนี้ด้วย
90 | https://www.tutorialspoint.com/design_pattern/bridge_pattern.htm คำอธิบายโค้ดอยู่ในนี้
91 |
92 |
93 | ### Singleton Pattern
94 | เป็น Pattern ที่จำกัดจำนวนของ Object ที่ถูกสร้างขึ้นในระบบ ซึ่งจะเป็นประโยชน์เมื่อระบบต้องการจะมี Object นั้นเพียงตัวเดียวเพื่อป้องกันไม่ให้เกิดการทำงานซ้ำซ้อนกันเช่น class สำหรับการเก็บข้อมูล หรือเป็น Model ที่มีการเรียกใช้งานทั้งระบบ
95 |
96 | อ้างอิงจาก https://medium.com/20scoops-cnx/singleton-pattern-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3-b7b28182654f
97 | อ่านเพิ่ม https://www.tutorialspoint.com/design_pattern/singleton_pattern.htm
98 |
99 | เนื้อหาจากไฟล์
100 | 1. ไฟล์ `SingleObject` ในไฟล์จะมีตัวแปร `instance` เป็นตัวแปรแบบ static และจะอนุญาติให้สร้าง object ได้จากการ `getInstance()` เท่านั้น และ object นี้สามารถถูกสร้างได้แค่ครั้งเดียวจากการเช็คใน `getInstance` ว่าเคยถูกสร้างหรือยัง
101 | 2. ไฟล์ `SingletonDemo` เป็นไฟล์ main ของโปรแกรม จะแสดงข้อความ
102 | ```
103 | Hello World, This is singleton pattern.
104 | ```
105 |
106 | ### Factory Pattern
107 | Factory Pattern คือรูปแบบที่จำลองโรงงานสร้างของขึ้นมา โดยที่เราสามารถสั่งสร้างของได้โดยไม่ต้องสนใจโลจิกการสร้างของในfactory ทำให้ง่ายต่อการสร้างobject
108 | เนื้อหาจากไฟล์
109 | 1. สร้าง interface `Shape.java` และสร้างคลาสobjectที่จะสร้างขึ้นมา `Circle.java ,Rectangle.java ,Square.java` ให้object ทุกตัว implements Shape
110 | 2. สร้าง factory `ShapeFactory.java` factoryจะเป็นตัวสร้างobjectทั้ง3ตัวโดยจะรับargumentเป็นเงื่อนไขการสร้าง
111 | 3. สร้าง FactoryPatternDemo `FactoryPatternDemo.java` เมื่อต้องการจะใช้objectไหนก็สั่งสร้างผ่าน ShapeFactory และนำไปใช้ได้เลย
112 | https://www.tutorialspoint.com/design_pattern/abstract_factory_pattern.htm
113 | ```
114 | output
115 | Inside Circle::draw() method.
116 | Inside Rectangle::draw() method.
117 | Inside Square::draw() method.
118 | ```
119 |
120 | ### Abstract Factory Pattern
121 | คล้ายกับ Factory Pattern แต่จะมีตัวที่สร้างโรงงานขึ้นมาอีกทีนั่นคือ `FactoryProducer` และแต่ละโรงงานก็จะมีโครงสร้างเหมือนกับ Factory Pattern การสร้างobjectนั่นเปลี่ยนจากการสร้างผ่าน factory เป็นติดต่อผ่าน `AbstractFactory`แทน ทำให้สามารถเพิ่มเติมหรือแก้ไขfactoryในภายหลังได้
122 | https://www.tutorialspoint.com/design_pattern/abstract_factory_pattern.htm
123 | ```
124 | output
125 | Inside Circle::draw() method.
126 | Inside Rectangle::draw() method.
127 | Inside Square::draw() method.
128 | Inside Red::fill() method.
129 | Inside Green::fill() method.
130 | Inside Blue::fill() method.
131 | ```
132 |
133 |
134 | ### Facade Pattern
135 | Facade Pattern คือ pattern ที่ช่วยลดความซับซ้อนของระบบ และหน้า interface ของ client โดยนำระบบย่อยมารวมใน class เดียว แล้วให้ client เรียกใช้ class นั้นเพียง class เดียว (source: http://enos.itcollege.ee/~jpoial/java/naited/Java-Design-Patterns.pdf)
136 |
137 | 1. ไฟล์ `Runserver.java` แสดงให้เห็นว่่าหากไม่นำ Facade Pattern มาใช้ client ต้องรันคำสั่งมากมายเพื่อ start/stop server
138 | 2. ไฟล์ `ScheduleServerFacade.java` รวมคำสั่งที่ต้องรันเพื่อ start/stop server ไว้ในคำสั่งเดียว
139 | 3. ไฟล์ `TestFacade.java` หน้า interface ของ user เหลือเพียงแค่คำสั่ง start/stop server
140 |
141 |
142 | ### Command Pattern
143 | Command pattern คือ pattern ที่มีการสร้างตัว request (object ตัวนึงขึ้นมาเพื่อห่อหุ้มข้อมูลและ command ต่างๆ) และส่งผ่านให้ invoker มาจัดการกับ request ที่รับไปยัง object ที่สอดคล้องกับ command ใน request นั้นๆ
144 |
145 | อ้างอิงจาก https://www.tutorialspoint.com/design_pattern/command_pattern.htm
146 | อ่านเพิ่ม https://2bedev.com/365days-of-program-day-61/
147 |
148 | เนื้อหาจากไฟล์
149 | 1. ไฟล์ `Order.java` เป็น interface ของ command
150 | 2. ไฟล์ `Stock.java` เป็น request class
151 | 3. ไฟล์ `BuyStock.java` และ `SellStock.java` เป็น class ที่ implement มาจาก `Order` เพื่อ execute ตัว request ที่รับมาจาก `Broker`
152 | 4. ไฟล์ `Broker.java` เป็น invoker class มารับ request แล้วส่งไปเรียกใช้งานคำสั่งตามที่เหมาะสม
153 | 5. ไฟล์ `CommandDemo.java` เป็น Main ของโปรแกรม เรียกใช้ Broker มารับ request แล้วรัน command
154 |
155 | ```
156 | Stock [ Name: ABC, Quantity: 10 ] bought
157 | Stock [ Name: ABC, Quantity: 10 ] sold
158 | ```
159 |
160 |
161 | ### Proxy Pattern
162 | proxy หมายความว่า ผู้แทน ดังนั้น pattern นี่คือการมอบหมายให้ class หนึ่งเป็นตัวแทนของอีก class หนึ่ง
163 | ยกตัวอย่างเช่นการ Reverse proxy ที่ให้ server หนึ่งรับ request มาก่อนส่งให้ server หลัก
164 | เพื่อช่วยลดภาระการทำงานของ server หลัก
165 |
166 | ประโยชน์จากการใช้
167 | 1. Lazy-instantiate an object: ข้อมูลจะไม่ถูกโหลดจนกว่าเราจะเรียกใช้
168 | 2. Control access to the object: เช็คสิทธิการเข้าถึงก่อนเข้า real service ได้
169 | 3. Hide the fact object: สามารคืนค่าให้ client ก่อนโดยไม่ต้องผ่าน real service
170 |
171 | อ่านเพิ่ม http://manit-tree.blogspot.com/2012/07/design-pattern-proxy-pattern.html
172 |
173 | ในตัวอย่าง proxy.java จะเป็นการสร้าง RealImage กับ ProxyImage ที่ inherit มาจาก RealImage
174 | ใน main เราประกาศ class ProxyImage ซึ่งจะมีการ load ข้อมูลจาก disk แค่ครั้งแรกที่ display
175 | รอบถัดไปจะไม่ต้องโหลดมาใหม่อีก
176 |
177 |
178 | ### Structural Patterns
179 | path นี้จะเป็นการเปรียบเทียบระหว่าง
180 | ##### 1.Decorator Pattern
181 | เปลี่ยน behavior คือไม่ได้เปลี่ยน interface แต่เปลี่ยน implementation พยายามจะ solve ปัญหาโดยการที่พยายามจะ compose ยังไงก็ได้แล้วแต่เรา ทำการ decorating ทุก component
182 | ##### 2.Adapter Pattern
183 | เราเปลี่ยนแปลงไปโดยที่ไม่สน behavior คือเปลี่ยน interface ที่เราอยากใช้ ให้เข้ากับ interface ของเรา
184 | ##### 3.Facade Pattern
185 | ตัว facal จะเป็นตัว higher level interface ที่เอาไว้ให้เราใช้พวกที่ต่ำกว่านี้ ที่ซับซ้อนมากๆ ได้ง่ายขึ้น
186 | ##### 4.Proxy Pattern
187 | ตัว proxy จะเป็นตัวติดต่อกับ client แล้วค่อยส่งไปให้ real คือทำอะไรต้องผ่าน proxy ก่อน แต่ว่าทั้ง 2 อย่่างจะใช้ subject ร่วมกัน คือบาง common answer ทาง real ก็จะสามารถใช้ได้โดยตรง proxy เหมือนเป็น control access เปลี่ยน implementation แต่ interface ของ real กับ proxy เหมือนกัน
188 | ##### 5.Bridge Pattern
189 | ตัวอย่างเช่นการที่เรามี 2 hierarchy ที่เหมือนๆกัน คนละ interface กัน เรียกว่า bridge เพราะมันคือการ bridge ข้ามไปอีก interface นึง ค่อนข้างจะ flexible
190 |
--------------------------------------------------------------------------------
/command/nbproject/build-impl.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 | Must set src.dir
233 | Must set test.src.dir
234 | Must set build.dir
235 | Must set dist.dir
236 | Must set build.classes.dir
237 | Must set dist.javadoc.dir
238 | Must set build.test.classes.dir
239 | Must set build.test.results.dir
240 | Must set build.classes.excludes
241 | Must set dist.jar
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 | Must set javac.includes
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 | No tests executed.
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 | Must set JVM to use for profiling in profiler.info.jvm
722 | Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
723 |
724 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 | Must select some files in the IDE or set javac.includes
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 | To run this application from the command line without Ant, try:
1001 |
1002 | java -jar "${dist.jar.resolved}"
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1038 |
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 | Must select one file in the IDE or set run.class
1050 |
1051 |
1052 |
1053 | Must select one file in the IDE or set run.class
1054 |
1055 |
1056 |
1061 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 |
1068 |
1069 |
1070 |
1071 |
1072 |
1073 |
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 | Must select one file in the IDE or set debug.class
1081 |
1082 |
1083 |
1084 |
1085 | Must select one file in the IDE or set debug.class
1086 |
1087 |
1088 |
1089 |
1090 | Must set fix.includes
1091 |
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1102 |
1105 |
1106 | This target only works when run from inside the NetBeans IDE.
1107 |
1108 |
1109 |
1110 |
1111 |
1112 |
1113 |
1114 |
1115 | Must select one file in the IDE or set profile.class
1116 | This target only works when run from inside the NetBeans IDE.
1117 |
1118 |
1119 |
1120 |
1121 |
1122 |
1123 |
1124 |
1125 | This target only works when run from inside the NetBeans IDE.
1126 |
1127 |
1128 |
1129 |
1130 |
1131 |
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 | This target only works when run from inside the NetBeans IDE.
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 |
1163 |
1164 |
1165 |
1166 |
1167 |
1168 |
1169 |
1170 |
1171 |
1172 |
1173 |
1174 |
1175 |
1176 | Must select one file in the IDE or set run.class
1177 |
1178 |
1179 |
1180 |
1181 |
1182 | Must select some files in the IDE or set test.includes
1183 |
1184 |
1185 |
1186 |
1187 | Must select one file in the IDE or set run.class
1188 |
1189 |
1190 |
1191 |
1192 | Must select one file in the IDE or set applet.url
1193 |
1194 |
1195 |
1196 |
1201 |
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1208 |
1209 |
1210 |
1211 |
1212 |
1213 |
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
1220 |
1221 |
1222 |
1223 |
1224 |
1225 |
1226 |
1227 |
1228 |
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1245 |
1246 |
1247 |
1248 |
1249 |
1250 |
1251 |
1252 |
1253 |
1254 |
1255 |
1256 |
1257 |
1258 |
1259 |
1260 |
1261 |
1262 |
1263 |
1264 |
1265 |
1266 |
1267 |
1268 |
1269 |
1270 |
1271 | Must select some files in the IDE or set javac.includes
1272 |
1273 |
1274 |
1275 |
1276 |
1277 |
1278 |
1279 |
1280 |
1281 |
1282 |
1283 |
1288 |
1289 |
1290 |
1291 |
1292 |
1293 |
1294 |
1295 | Some tests failed; see details above.
1296 |
1297 |
1298 |
1299 |
1300 |
1301 |
1302 |
1303 |
1304 | Must select some files in the IDE or set test.includes
1305 |
1306 |
1307 |
1308 | Some tests failed; see details above.
1309 |
1310 |
1311 |
1312 | Must select some files in the IDE or set test.class
1313 | Must select some method in the IDE or set test.method
1314 |
1315 |
1316 |
1317 | Some tests failed; see details above.
1318 |
1319 |
1320 |
1325 |
1326 | Must select one file in the IDE or set test.class
1327 |
1328 |
1329 |
1330 | Must select one file in the IDE or set test.class
1331 | Must select some method in the IDE or set test.method
1332 |
1333 |
1334 |
1335 |
1336 |
1337 |
1338 |
1339 |
1340 |
1341 |
1342 |
1343 |
1348 |
1349 | Must select one file in the IDE or set applet.url
1350 |
1351 |
1352 |
1353 |
1354 |
1355 |
1356 |
1361 |
1362 | Must select one file in the IDE or set applet.url
1363 |
1364 |
1365 |
1366 |
1367 |
1368 |
1369 |
1370 |
1375 |
1376 |
1377 |
1378 |
1379 |
1380 |
1381 |
1382 |
1383 |
1384 |
1385 |
1386 |
1387 |
1388 |
1389 |
1390 |
1391 |
1392 |
1393 |
1394 |
1395 |
1396 |
1397 |
1398 |
1399 |
1400 |
1401 |
1402 |
1403 |
1404 |
1405 |
1406 |
1407 |
1408 |
1409 |
1410 |
1411 |
1412 |
1413 |
1414 |
1415 |
1416 |
1417 |
1418 |
1419 |
1420 |
--------------------------------------------------------------------------------
/singleton/nbproject/build-impl.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 | Must set src.dir
233 | Must set test.src.dir
234 | Must set build.dir
235 | Must set dist.dir
236 | Must set build.classes.dir
237 | Must set dist.javadoc.dir
238 | Must set build.test.classes.dir
239 | Must set build.test.results.dir
240 | Must set build.classes.excludes
241 | Must set dist.jar
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 | Must set javac.includes
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 | No tests executed.
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 | Must set JVM to use for profiling in profiler.info.jvm
722 | Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
723 |
724 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 | Must select some files in the IDE or set javac.includes
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 | To run this application from the command line without Ant, try:
1001 |
1002 | java -jar "${dist.jar.resolved}"
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1038 |
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 | Must select one file in the IDE or set run.class
1050 |
1051 |
1052 |
1053 | Must select one file in the IDE or set run.class
1054 |
1055 |
1056 |
1061 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 |
1068 |
1069 |
1070 |
1071 |
1072 |
1073 |
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 | Must select one file in the IDE or set debug.class
1081 |
1082 |
1083 |
1084 |
1085 | Must select one file in the IDE or set debug.class
1086 |
1087 |
1088 |
1089 |
1090 | Must set fix.includes
1091 |
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1102 |
1105 |
1106 | This target only works when run from inside the NetBeans IDE.
1107 |
1108 |
1109 |
1110 |
1111 |
1112 |
1113 |
1114 |
1115 | Must select one file in the IDE or set profile.class
1116 | This target only works when run from inside the NetBeans IDE.
1117 |
1118 |
1119 |
1120 |
1121 |
1122 |
1123 |
1124 |
1125 | This target only works when run from inside the NetBeans IDE.
1126 |
1127 |
1128 |
1129 |
1130 |
1131 |
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 | This target only works when run from inside the NetBeans IDE.
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 |
1163 |
1164 |
1165 |
1166 |
1167 |
1168 |
1169 |
1170 |
1171 |
1172 |
1173 |
1174 |
1175 |
1176 | Must select one file in the IDE or set run.class
1177 |
1178 |
1179 |
1180 |
1181 |
1182 | Must select some files in the IDE or set test.includes
1183 |
1184 |
1185 |
1186 |
1187 | Must select one file in the IDE or set run.class
1188 |
1189 |
1190 |
1191 |
1192 | Must select one file in the IDE or set applet.url
1193 |
1194 |
1195 |
1196 |
1201 |
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1208 |
1209 |
1210 |
1211 |
1212 |
1213 |
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
1220 |
1221 |
1222 |
1223 |
1224 |
1225 |
1226 |
1227 |
1228 |
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1245 |
1246 |
1247 |
1248 |
1249 |
1250 |
1251 |
1252 |
1253 |
1254 |
1255 |
1256 |
1257 |
1258 |
1259 |
1260 |
1261 |
1262 |
1263 |
1264 |
1265 |
1266 |
1267 |
1268 |
1269 |
1270 |
1271 | Must select some files in the IDE or set javac.includes
1272 |
1273 |
1274 |
1275 |
1276 |
1277 |
1278 |
1279 |
1280 |
1281 |
1282 |
1283 |
1288 |
1289 |
1290 |
1291 |
1292 |
1293 |
1294 |
1295 | Some tests failed; see details above.
1296 |
1297 |
1298 |
1299 |
1300 |
1301 |
1302 |
1303 |
1304 | Must select some files in the IDE or set test.includes
1305 |
1306 |
1307 |
1308 | Some tests failed; see details above.
1309 |
1310 |
1311 |
1312 | Must select some files in the IDE or set test.class
1313 | Must select some method in the IDE or set test.method
1314 |
1315 |
1316 |
1317 | Some tests failed; see details above.
1318 |
1319 |
1320 |
1325 |
1326 | Must select one file in the IDE or set test.class
1327 |
1328 |
1329 |
1330 | Must select one file in the IDE or set test.class
1331 | Must select some method in the IDE or set test.method
1332 |
1333 |
1334 |
1335 |
1336 |
1337 |
1338 |
1339 |
1340 |
1341 |
1342 |
1343 |
1348 |
1349 | Must select one file in the IDE or set applet.url
1350 |
1351 |
1352 |
1353 |
1354 |
1355 |
1356 |
1361 |
1362 | Must select one file in the IDE or set applet.url
1363 |
1364 |
1365 |
1366 |
1367 |
1368 |
1369 |
1370 |
1375 |
1376 |
1377 |
1378 |
1379 |
1380 |
1381 |
1382 |
1383 |
1384 |
1385 |
1386 |
1387 |
1388 |
1389 |
1390 |
1391 |
1392 |
1393 |
1394 |
1395 |
1396 |
1397 |
1398 |
1399 |
1400 |
1401 |
1402 |
1403 |
1404 |
1405 |
1406 |
1407 |
1408 |
1409 |
1410 |
1411 |
1412 |
1413 |
1414 |
1415 |
1416 |
1417 |
1418 |
1419 |
1420 |
--------------------------------------------------------------------------------