1 10 11 package org.mule.impl.container; 12 13 import org.mule.umo.lifecycle.InitialisationException; 14 import org.mule.umo.manager.ObjectNotFoundException; 15 import org.mule.util.ClassUtils; 16 17 import javax.naming.NamingException ; 18 19 26 public class RmiContainerContext extends JndiContainerContext 27 { 28 protected String securityPolicy = null; 29 protected String securityManager = null; 30 31 protected RmiContainerContext(String name) 32 { 33 super(name); 34 } 35 36 public RmiContainerContext() 37 { 38 super("rmi"); 39 } 40 41 public void initialise() throws InitialisationException 42 { 43 super.initialise(); 44 if (securityPolicy != null) 45 { 46 if (ClassUtils.getResource(securityPolicy, getClass()) != null) 47 { 48 System.setProperty("java.security.policy", securityPolicy); 49 } 50 } 51 52 if (System.getSecurityManager() == null) 54 { 55 try 56 { 57 if (securityManager != null) 58 { 59 Class clazz = ClassUtils.loadClass(securityManager, getClass()); 60 System.setSecurityManager((SecurityManager )clazz.newInstance()); 61 } 62 } 63 catch (Exception e) 64 { 65 throw new InitialisationException(e, this); 66 } 67 } 68 } 69 70 public Object getComponent(Object key) throws ObjectNotFoundException 71 { 72 Object object = null; 73 if (key == null) 74 { 75 throw new ObjectNotFoundException("null"); 76 } 77 try 78 { 79 object = context.lookup(key.toString()); 80 } 81 catch (NamingException e) 82 { 83 throw new ObjectNotFoundException(key.toString(), e); 84 } 85 86 if (object == null) 87 { 88 throw new ObjectNotFoundException(key.toString()); 89 } 90 else 91 { 92 return object; 93 } 94 } 95 96 public String getSecurityPolicy() 97 { 98 return securityPolicy; 99 } 100 101 public void setSecurityPolicy(String securityPolicy) 102 { 103 this.securityPolicy = securityPolicy; 104 } 105 106 public String getSecurityManager() 107 { 108 return securityManager; 109 } 110 111 public void setSecurityManager(String securityManager) 112 { 113 this.securityManager = securityManager; 114 } 115 } 116 | Popular Tags |