1 28 29 package org.objectweb.util.explorer.parser.lib; 30 31 import java.util.Iterator ; 32 import java.util.List ; 33 34 import org.objectweb.fractal.api.NoSuchInterfaceException; 35 import org.objectweb.util.explorer.core.common.api.BadParamException; 36 import org.objectweb.util.explorer.core.common.api.KeyProvider; 37 import org.objectweb.util.explorer.core.common.lib.BindingFeature; 38 import org.objectweb.util.explorer.core.role.api.RoleProvider; 39 import org.objectweb.util.explorer.explorerConfig.Node; 40 import org.objectweb.util.explorer.explorerConfig.Role; 41 import org.objectweb.util.explorer.explorerConfig.beans.ExplorerBean; 42 import org.objectweb.util.explorer.parser.api.ExplorerParser; 43 import org.objectweb.util.explorer.parser.api.NodeParser; 44 import org.objectweb.util.explorer.parser.api.RoleParser; 45 46 54 public class NodeDispatcher 55 extends BindingFeature 56 implements ExplorerParser, RoleParser 57 { 58 59 65 71 77 protected void dispatchNode(String roleId, Node theNode){ 78 try { 79 String [] keyElements = new String []{theNode.getTypeSystem(),theNode.getTypeName(),roleId}; 80 Object key = ((KeyProvider)lookupFc(KeyProvider.KEY_PROVIDER)).computeKey(keyElements); 81 82 String [] clientIftNames = listFc(); 83 for (int i = 0; i < clientIftNames.length; i++) { 84 if(clientIftNames[i].startsWith(NodeParser.NODE_PARSER)){ 85 ((NodeParser)lookupFc(clientIftNames[i])).parseNode(key,theNode); 86 } 87 } 88 } catch (BadParamException e) { 89 e.printStackTrace(); 90 } catch (NoSuchInterfaceException e) { 91 e.printStackTrace(); 92 } 93 } 94 95 protected void parseNodeList(String roleId, List nodeList){ 96 Iterator it = nodeList.iterator(); 97 while (it.hasNext()) { 98 Node node = (Node)it.next(); 99 if(node!=null) { 100 dispatchNode(roleId, node); 101 } 102 } 103 } 104 105 111 114 public String [] clientFc() { 115 return new String []{NodeParser.NODE_PARSER, 116 KeyProvider.KEY_PROVIDER}; 117 } 118 119 125 128 public void parseExplorer(ExplorerBean explorer) { 129 parseNodeList(RoleProvider.DEFAULT_ROLE,explorer.getNodeList()); 130 } 131 132 138 141 public void parseRole(Role role) { 142 parseNodeList(role.getId(),role.getNodeList()); 143 } 144 } 145 | Popular Tags |