View Javadoc

1   package org.apache.maven.continuum.xmlrpc.server;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.xmlrpc.XmlRpcException;
23  import org.apache.xmlrpc.XmlRpcHandler;
24  import org.apache.xmlrpc.server.PropertyHandlerMapping;
25  import org.apache.xmlrpc.server.RequestProcessorFactoryFactory;
26  import org.codehaus.plexus.PlexusConstants;
27  import org.codehaus.plexus.PlexusContainer;
28  import org.codehaus.plexus.context.Context;
29  import org.codehaus.plexus.context.ContextException;
30  import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
31  import org.slf4j.Logger;
32  import org.slf4j.LoggerFactory;
33  
34  import java.lang.reflect.Method;
35  import java.util.Iterator;
36  import java.util.Map;
37  
38  /**
39   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
40   * @version $Id: PropertiesHandlerMapping.java 765340 2009-04-15 20:22:00Z evenisse $
41   * @plexus.component role="org.apache.xmlrpc.server.PropertyHandlerMapping"
42   */
43  public class PropertiesHandlerMapping
44      extends PropertyHandlerMapping
45      implements Contextualizable
46  {
47      private static final Logger log = LoggerFactory.getLogger( PropertiesHandlerMapping.class );
48  
49      /**
50       * @plexus.requirement role="org.apache.maven.continuum.xmlrpc.server.ContinuumXmlRpcComponent"
51       */
52      private Map<String, Object> xmlrpcComponents;
53  
54      private PlexusContainer container;
55  
56      public void load()
57          throws XmlRpcException
58      {
59          for ( String key : xmlrpcComponents.keySet() )
60          {
61              Class cl = xmlrpcComponents.get( key ).getClass();
62              if ( log.isDebugEnabled() )
63              {
64                  log.debug( key + " => " + cl.getName() );
65              }
66  
67              registerPublicMethods( key, cl );
68          }
69  
70          if ( log.isDebugEnabled() )
71          {
72              String[] methods = getListMethods();
73              for ( String method : methods )
74              {
75                  log.debug( method );
76              }
77          }
78      }
79  
80      protected XmlRpcHandler newXmlRpcHandler( final Class pClass, final Method[] pMethods )
81          throws XmlRpcException
82      {
83          String[][] sig = getSignature( pMethods );
84          String help = getMethodHelp( pClass, pMethods );
85          RequestProcessorFactoryFactory.RequestProcessorFactory factory =
86              getRequestProcessorFactoryFactory().getRequestProcessorFactory( pClass );
87          return new ContinuumXmlRpcMetaDataHandler( this, getTypeConverterFactory(), pClass, factory, pMethods, sig,
88                                                     help, container );
89      }
90  
91      public void contextualize( Context context )
92          throws ContextException
93      {
94          container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
95      }
96  }