Search in sources :

Example 1 with MyContext

use of com.gpcoder.context.MyContext in project Java-Tutorial by gpcodervn.

the class ChainStart1 method main.

public static void main(String[] args) throws Exception {
    // Create context
    MyContext context = new MyContext();
    context.setProperty("property-value");
    context.put("custom-key", "custom-value");
    // Get the command
    Command command = new MyChain();
    command.execute(context);
}
Also used : MyContext(com.gpcoder.context.MyContext) Command(org.apache.commons.chain.Command)

Example 2 with MyContext

use of com.gpcoder.context.MyContext in project Java-Tutorial by gpcodervn.

the class ChainStart2 method main.

public static void main(String[] args) throws Exception {
    // Create context
    MyContext ctx = new MyContext();
    ctx.setProperty("property-value");
    ctx.put("custom-key", "custom-value");
    // Get the catalog
    Catalog catalog = new MyCatalog();
    // Get the command
    System.out.println("Execute the specific command: CMD_1");
    Command command1 = catalog.getCommand(MyCommandNamed.CMD_1.name());
    command1.execute(ctx);
    System.out.println("\nExecute the specific chain: CHAIN_1");
    Command chain1 = catalog.getCommand(MyCommandNamed.CHAIN_1.name());
    chain1.execute(ctx);
}
Also used : MyContext(com.gpcoder.context.MyContext) Command(org.apache.commons.chain.Command) Catalog(org.apache.commons.chain.Catalog)

Example 3 with MyContext

use of com.gpcoder.context.MyContext in project Java-Tutorial by gpcodervn.

the class ChainStart3 method main.

public static void main(String[] args) throws Exception {
    Command chain = new MyChain3();
    chain.execute(new MyContext());
}
Also used : MyContext(com.gpcoder.context.MyContext) Command(org.apache.commons.chain.Command)

Example 4 with MyContext

use of com.gpcoder.context.MyContext in project Java-Tutorial by gpcodervn.

the class ChainStart4 method main.

public static void main(String[] args) throws Exception {
    // Create context
    MyContext ctx = new MyContext();
    ctx.setProperty("property-value");
    ctx.put("custom-key", "custom-value");
    // Get the catalog
    Catalog catalog = new MyXMLCatalog().getCatalog();
    // Get the command
    System.out.println("Execute the specific command: CMD_1");
    Command command1 = catalog.getCommand(MyCommandNamed.CMD_1.name());
    command1.execute(ctx);
    System.out.println("\nExecute the specific chain: CHAIN_1");
    Command chain1 = catalog.getCommand(MyCommandNamed.CHAIN_1.name());
    chain1.execute(ctx);
}
Also used : MyContext(com.gpcoder.context.MyContext) Command(org.apache.commons.chain.Command) Catalog(org.apache.commons.chain.Catalog)

Aggregations

MyContext (com.gpcoder.context.MyContext)4 Command (org.apache.commons.chain.Command)4 Catalog (org.apache.commons.chain.Catalog)2