KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > soap > xfire > MuleObjectServiceFactory


1 /*
2  * $Id: MuleObjectServiceFactory.java 3937 2006-11-20 16:04:25Z lajos $
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 MuleSource MPL
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 java.lang.reflect.Method JavaDoc;
14 import java.lang.reflect.Modifier JavaDoc;
15 import java.util.HashSet JavaDoc;
16 import java.util.Set JavaDoc;
17
18 import org.codehaus.xfire.service.binding.ObjectServiceFactory;
19 import org.codehaus.xfire.transport.TransportManager;
20 import org.mule.umo.lifecycle.Callable;
21 import org.mule.umo.lifecycle.Disposable;
22 import org.mule.umo.lifecycle.Initialisable;
23 import org.mule.util.ClassUtils;
24
25 /**
26  * TODO document
27  */

28 public class MuleObjectServiceFactory extends ObjectServiceFactory
29 {
30
31     protected final Set JavaDoc excludedMethods = new HashSet JavaDoc();
32
33     /**
34      * Initializes a new instance of the <code>ObjectServiceFactory</code>.
35      */

36     public MuleObjectServiceFactory(TransportManager transportManager)
37     {
38         super(transportManager);
39         initExcludedMethods();
40     }
41
42     protected void initExcludedMethods()
43     {
44         // JDK methods to be ignored
45
addIgnoredMethods("java.lang.Object");
46         addIgnoredMethods("java.lang.Throwable");
47         addIgnoredMethods("org.omg.CORBA_2_3.portable.ObjectImpl");
48         addIgnoredMethods("org.omg.CORBA.portable.ObjectImpl");
49         addIgnoredMethods("javax.ejb.EJBObject");
50         addIgnoredMethods("javax.rmi.CORBA.Stub");
51
52         // Mule methods to be ignored
53
addIgnoredMethods(Callable.class.getName());
54         addIgnoredMethods(Initialisable.class.getName());
55         addIgnoredMethods(Disposable.class.getName());
56     }
57
58     /**
59      * Ignore the specified class' declared methods. This can be used to not expose
60      * certain interfaces as a service. By default, the methods specified by the
61      * following interfaces/classes are ignored:
62      * <li><code>java.lang.Object</code>
63      * <li><code>org.omg.CORBA_2_3.portable.ObjectImpl</code>
64      * <li><code>org.omg.CORBA.portable.ObjectImpl</code>
65      * <li><code>javax.ejb.EJBObject</code>
66      * <li><code>javax.ejb.EJBLocalObject</code>
67      * <li><code>javax.rmi.CORBA.Stub</code>
68      * <li><code>org.mule.umo.lifecycle.Callable</code>
69      * <li><code>org.mule.umo.lifecycle.Initialisable</code>
70      * <li><code>org.mule.umo.lifecycle.Disposable</code>
71      *
72      * @param className the fully qualified class name
73      */

74     public void addIgnoredMethods(String JavaDoc className)
75     {
76         try
77         {
78             Class JavaDoc c = ClassUtils.loadClass(className, getClass());
79             for (int i = 0; i < c.getMethods().length; i++)
80             {
81                 excludedMethods.add(getMethodName(c.getMethods()[i]));
82             }
83         }
84         catch (ClassNotFoundException JavaDoc e)
85         {
86             // can be ignored.
87
}
88     }
89
90     protected boolean isValidMethod(final Method JavaDoc method)
91     {
92         if (excludedMethods.contains(getMethodName(method))) return false;
93
94         final int modifiers = method.getModifiers();
95
96         return Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers);
97     }
98
99     protected String JavaDoc getMethodName(Method JavaDoc method)
100     {
101         return method.getName();
102     }
103
104 }
105
Popular Tags