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.Map;
36  
37  /**
38   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
39   * @version $Id: PropertiesHandlerMapping.java 1372260 2012-08-13 04:29:09Z brett $
40   * @plexus.component role="org.apache.xmlrpc.server.PropertyHandlerMapping"
41   */
42  public class PropertiesHandlerMapping
43      extends PropertyHandlerMapping
44      implements Contextualizable
45  {
46      private static final Logger log = LoggerFactory.getLogger( PropertiesHandlerMapping.class );
47  
48      /**
49       * @plexus.requirement role="org.apache.maven.continuum.xmlrpc.server.ContinuumXmlRpcComponent"
50       */
51      private Map<String, Object> xmlrpcComponents;
52  
53      private PlexusContainer container;
54  
55      public void load()
56          throws XmlRpcException
57      {
58          for ( String key : xmlrpcComponents.keySet() )
59          {
60              Class cl = xmlrpcComponents.get( key ).getClass();
61              if ( log.isDebugEnabled() )
62              {
63                  log.debug( key + " => " + cl.getName() );
64              }
65  
66              registerPublicMethods( key, cl );
67          }
68  
69          if ( log.isDebugEnabled() )
70          {
71              String[] methods = getListMethods();
72              for ( String method : methods )
73              {
74                  log.debug( method );
75              }
76          }
77      }
78  
79      protected XmlRpcHandler newXmlRpcHandler( final Class pClass, final Method[] pMethods )
80          throws XmlRpcException
81      {
82          String[][] sig = getSignature( pMethods );
83          String help = getMethodHelp( pClass, pMethods );
84          RequestProcessorFactoryFactory.RequestProcessorFactory factory =
85              getRequestProcessorFactoryFactory().getRequestProcessorFactory( pClass );
86          return new ContinuumXmlRpcMetaDataHandler( this, getTypeConverterFactory(), pClass, factory, pMethods, sig,
87                                                     help, container );
88      }
89  
90      public void contextualize( Context context )
91          throws ContextException
92      {
93          container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
94      }
95  }