Coverage Report - org.mule.impl.container.RmiContainerContext
 
Classes in this File Line Coverage Branch Coverage Complexity
RmiContainerContext
0%
0/34
0%
0/6
2.5
 
 1  
 /*
 2  
  * $Id: RmiContainerContext.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 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  
 /**
 20  
  * <code>RmiContainerContext</code> is a container implementaiton that allows RMi
 21  
  * objects to be referenced either as components or properties on components
 22  
  */
 23  
 public class RmiContainerContext extends JndiContainerContext
 24  
 {
 25  0
     protected String securityPolicy = null;
 26  0
     protected String securityManager = null;
 27  
 
 28  
     protected RmiContainerContext(String name)
 29  
     {
 30  0
         super(name);
 31  0
     }
 32  
 
 33  
     public RmiContainerContext()
 34  
     {
 35  0
         super("rmi");
 36  0
     }
 37  
 
 38  
     public void initialise() throws InitialisationException
 39  
     {
 40  0
         super.initialise();
 41  0
         if (securityPolicy != null)
 42  
         {
 43  0
             if (ClassUtils.getResource(securityPolicy, getClass()) != null)
 44  
             {
 45  0
                 System.setProperty("java.security.policy", securityPolicy);
 46  
             }
 47  
         }
 48  
 
 49  
         // Set security manager
 50  0
         if (System.getSecurityManager() == null)
 51  
         {
 52  
             try
 53  
             {
 54  0
                 if (securityManager != null)
 55  
                 {
 56  0
                     Class clazz = ClassUtils.loadClass(securityManager, getClass());
 57  0
                     System.setSecurityManager((SecurityManager) clazz.newInstance());
 58  
                 }
 59  
             }
 60  0
             catch (Exception e)
 61  
             {
 62  0
                 throw new InitialisationException(e, this);
 63  0
             }
 64  
         }
 65  0
     }
 66  
 
 67  
     public Object getComponent(Object key) throws ObjectNotFoundException
 68  
     {
 69  0
         Object object = null;
 70  0
         if (key == null)
 71  
         {
 72  0
             throw new ObjectNotFoundException("null");
 73  
         }
 74  
         try
 75  
         {
 76  0
             object = context.lookup(key.toString());
 77  
         }
 78  0
         catch (NamingException e)
 79  
         {
 80  0
             throw new ObjectNotFoundException(key.toString(), e);
 81  0
         }
 82  
 
 83  0
         if (object == null)
 84  
         {
 85  0
             throw new ObjectNotFoundException(key.toString());
 86  
         }
 87  
         else
 88  
         {
 89  0
             return object;
 90  
         }
 91  
     }
 92  
 
 93  
     public String getSecurityPolicy()
 94  
     {
 95  0
         return securityPolicy;
 96  
     }
 97  
 
 98  
     public void setSecurityPolicy(String securityPolicy)
 99  
     {
 100  0
         this.securityPolicy = securityPolicy;
 101  0
     }
 102  
 
 103  
     public String getSecurityManager()
 104  
     {
 105  0
         return securityManager;
 106  
     }
 107  
 
 108  
     public void setSecurityManager(String securityManager)
 109  
     {
 110  0
         this.securityManager = securityManager;
 111  0
     }
 112  
 }