source:
fedd/abac-src/ttg/process/StrategyFactory.java
@
8780cbec
Last change on this file since 8780cbec was 8780cbec, checked in by , 15 years ago | |
---|---|
|
|
File size: 1.2 KB |
Rev | Line | |
---|---|---|
[8780cbec] | 1 | package com.nailabs.abac.process; |
2 | ||
3 | import java.util.*; | |
4 | ||
5 | /** | |
6 | * Factory for creating a specific strategy. | |
7 | */ | |
8 | public class StrategyFactory { | |
9 | ||
10 | public static Strategy getStrategy(HashMap config) { | |
11 | Strategy strat = null; | |
12 | System.out.println("config = " + config); | |
13 | Properties props = (Properties)config.get("Strategy"); | |
14 | String type = props.getProperty("type"); | |
15 | NegotiationContext context = (NegotiationContext)config.get("context"); | |
16 | if(type == null) { // if no config then use default | |
17 | strat = new Strategy(context); | |
18 | System.out.print("Creating default strategy for "); | |
19 | } else if(type.equalsIgnoreCase("Stingy")) { | |
20 | // stingy strategy construction | |
21 | StingyStrategy stingy = new StingyStrategy(context, props); | |
22 | System.out.print("Creating stingy strategy for "); | |
23 | strat = stingy; | |
24 | } else { // default strategy construction | |
25 | strat = new Strategy(context); | |
26 | System.out.print("Creating default strategy for "); | |
27 | } | |
28 | System.out.println(context.getSelf()); | |
29 | return strat; | |
30 | } | |
31 | ||
32 | } |
Note: See TracBrowser
for help on using the repository browser.