Coverage Report - org.mule.providers.soap.xfire.MuleObjectServiceFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
MuleObjectServiceFactory
0%
0/25
0%
0/6
1.8
 
 1  
 /*
 2  
  * $Id: MuleObjectServiceFactory.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.providers.soap.xfire;
 12  
 
 13  
 import org.mule.umo.lifecycle.Callable;
 14  
 import org.mule.umo.lifecycle.Disposable;
 15  
 import org.mule.umo.lifecycle.Initialisable;
 16  
 import org.mule.util.ClassUtils;
 17  
 
 18  
 import java.lang.reflect.Method;
 19  
 import java.lang.reflect.Modifier;
 20  
 import java.util.HashSet;
 21  
 import java.util.Set;
 22  
 
 23  
 import org.codehaus.xfire.service.binding.ObjectServiceFactory;
 24  
 import org.codehaus.xfire.transport.TransportManager;
 25  
 
 26  
 /**
 27  
  * TODO document
 28  
  */
 29  
 public class MuleObjectServiceFactory extends ObjectServiceFactory
 30  
 {
 31  
 
 32  0
     protected final Set excludedMethods = new HashSet();
 33  
 
 34  
     /**
 35  
      * Initializes a new instance of the <code>ObjectServiceFactory</code>.
 36  
      */
 37  
     public MuleObjectServiceFactory(TransportManager transportManager)
 38  
     {
 39  0
         super(transportManager);
 40  0
         initExcludedMethods();
 41  0
     }
 42  
 
 43  
     protected void initExcludedMethods()
 44  
     {
 45  
         // JDK methods to be ignored
 46  0
         addIgnoredMethods("java.lang.Object");
 47  0
         addIgnoredMethods("java.lang.Throwable");
 48  0
         addIgnoredMethods("org.omg.CORBA_2_3.portable.ObjectImpl");
 49  0
         addIgnoredMethods("org.omg.CORBA.portable.ObjectImpl");
 50  0
         addIgnoredMethods("javax.ejb.EJBObject");
 51  0
         addIgnoredMethods("javax.rmi.CORBA.Stub");
 52  
 
 53  
         // Mule methods to be ignored
 54  0
         addIgnoredMethods(Callable.class.getName());
 55  0
         addIgnoredMethods(Initialisable.class.getName());
 56  0
         addIgnoredMethods(Disposable.class.getName());
 57  0
     }
 58  
 
 59  
     /**
 60  
      * Ignore the specified class' declared methods. This can be used to not expose
 61  
      * certain interfaces as a service. By default, the methods specified by the
 62  
      * following interfaces/classes are ignored:
 63  
      * <li><code>java.lang.Object</code>
 64  
      * <li><code>org.omg.CORBA_2_3.portable.ObjectImpl</code>
 65  
      * <li><code>org.omg.CORBA.portable.ObjectImpl</code>
 66  
      * <li><code>javax.ejb.EJBObject</code>
 67  
      * <li><code>javax.ejb.EJBLocalObject</code>
 68  
      * <li><code>javax.rmi.CORBA.Stub</code>
 69  
      * <li><code>org.mule.umo.lifecycle.Callable</code>
 70  
      * <li><code>org.mule.umo.lifecycle.Initialisable</code>
 71  
      * <li><code>org.mule.umo.lifecycle.Disposable</code>
 72  
      * 
 73  
      * @param className the fully qualified class name
 74  
      */
 75  
     public void addIgnoredMethods(String className)
 76  
     {
 77  
         try
 78  
         {
 79  0
             Class c = ClassUtils.loadClass(className, getClass());
 80  0
             for (int i = 0; i < c.getMethods().length; i++)
 81  
             {
 82  0
                 excludedMethods.add(getMethodName(c.getMethods()[i]));
 83  
             }
 84  
         }
 85  0
         catch (ClassNotFoundException e)
 86  
         {
 87  
             // can be ignored.
 88  0
         }
 89  0
     }
 90  
 
 91  
     protected boolean isValidMethod(final Method method)
 92  
     {
 93  0
         if (excludedMethods.contains(getMethodName(method)))
 94  
         {
 95  0
             return false;
 96  
         }
 97  
 
 98  0
         final int modifiers = method.getModifiers();
 99  
 
 100  0
         return Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers);
 101  
     }
 102  
 
 103  
     protected String getMethodName(Method method)
 104  
     {
 105  0
         return method.getName();
 106  
     }
 107  
 
 108  
 }