1 28 29 package org.objectweb.util.explorer.core.common.lib; 30 31 import org.objectweb.fractal.api.NoSuchInterfaceException; 32 import org.objectweb.util.explorer.core.common.api.BadParamException; 33 import org.objectweb.util.explorer.core.common.api.KeyProvider; 34 import org.objectweb.util.explorer.core.role.api.Role; 35 import org.objectweb.util.explorer.core.role.api.RoleProvider; 36 37 45 public class DefaultKeyProvider 46 extends BindingFeature 47 implements KeyProvider 48 { 49 50 56 62 68 protected DefaultKey getKey(String [] values){ 69 Role role = null; 70 try { 71 role = ((RoleProvider)lookupFc(RoleProvider.ROLE_PROVIDER)).getRole(values[2]); 72 } catch (NoSuchInterfaceException e) { 73 e.printStackTrace(); 74 } 75 return new DefaultKey(values[0],values[1],role); 76 } 77 78 84 87 public String [] clientFc() { 88 return new String []{RoleProvider.ROLE_PROVIDER}; 89 } 90 91 97 100 public Object computeKey(Object key) 101 throws BadParamException { 102 try{ 103 String [] value = (String [])key; 104 return getKey(value); 105 } catch (ClassCastException e){ 106 throw new BadParamException("Array of String expected!"); 107 } 108 } 109 110 } 111 | Popular Tags |