mirror of
https://github.com/apache/archiva.git
synced 2025-02-07 02:29:23 +00:00
XmlRpc servlet works :)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@691863 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0289eb1446
commit
79c634f2df
@ -84,6 +84,10 @@
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-rss</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-xmlrpc-services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
@ -221,6 +225,11 @@
|
||||
<artifactId>commons-logging-api</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atlassian.xmlrpc</groupId>
|
||||
<artifactId>atlassian-xmlrpc-binder-server-spring</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
|
@ -30,4 +30,14 @@
|
||||
<bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="location" value="classpath:application.properties" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean name="testXmlRpcService" lazy-init="true" scope="singleton" class="org.apache.maven.archiva.web.xmlrpc.services.PingServiceImpl"/>
|
||||
|
||||
<bean name="xmlrpcServicesList" class="java.util.ArrayList">
|
||||
<constructor-arg>
|
||||
<ref bean="testXmlRpcService"/>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one
|
||||
~ or more contributor license agreements. See the NOTICE file
|
||||
@ -17,10 +17,7 @@
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
||||
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
|
||||
|
||||
<display-name>Apache Archiva</display-name>
|
||||
|
||||
@ -85,6 +82,16 @@
|
||||
<!-- Loading this on startup so as to take advantage of configuration listeners -->
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>XmlRpcServlet</servlet-name>
|
||||
<servlet-class>com.atlassian.xmlrpc.spring.BinderSpringXmlRpcServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>serviceListBeanName</param-name>
|
||||
<param-value>xmlrpcServicesList</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>RssFeedServlet</servlet-name>
|
||||
@ -101,6 +108,11 @@
|
||||
<url-pattern>/repository/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>XmlRpcServlet</servlet-name>
|
||||
<url-pattern>/xmlrpc</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<resource-ref>
|
||||
<res-ref-name>jdbc/users</res-ref-name>
|
||||
<res-type>javax.sql.DataSource</res-type>
|
||||
@ -119,5 +131,4 @@
|
||||
<res-auth>Container</res-auth>
|
||||
<res-sharing-scope>Shareable</res-sharing-scope>
|
||||
</resource-ref>
|
||||
|
||||
</web-app>
|
||||
|
@ -26,8 +26,8 @@
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>archiva-xmlrpc-server</artifactId>
|
||||
<name>Archiva Web :: XML-RPC Server</name>
|
||||
<artifactId>archiva-xmlrpc-services</artifactId>
|
||||
<name>Archiva Web :: XML-RPC Services</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
@ -41,9 +41,5 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atlassian.xmlrpc</groupId>
|
||||
<artifactId>atlassian-xmlrpc-binder-server</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -1,71 +0,0 @@
|
||||
package org.apache.maven.archiva.web.xmlrpc.server;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
import org.apache.xmlrpc.XmlRpcRequest;
|
||||
import org.apache.xmlrpc.server.RequestProcessorFactoryFactory;
|
||||
|
||||
public class ArchivaRequestProcessorFactoryFactory implements RequestProcessorFactoryFactory
|
||||
{
|
||||
private final Map<Class, ArchivaRequestProcessorFactory> services;
|
||||
|
||||
public ArchivaRequestProcessorFactoryFactory(List serviceList)
|
||||
{
|
||||
services = new HashMap<Class, ArchivaRequestProcessorFactory>();
|
||||
for (Object service : serviceList)
|
||||
{
|
||||
services.put(service.getClass(), new ArchivaRequestProcessorFactory(service.getClass(), service));
|
||||
}
|
||||
}
|
||||
|
||||
public RequestProcessorFactory getRequestProcessorFactory(Class pClass)
|
||||
throws XmlRpcException
|
||||
{
|
||||
ArchivaRequestProcessorFactory processorFactory = services.get(pClass);
|
||||
if (processorFactory == null)
|
||||
{
|
||||
throw new XmlRpcException("Could not find service object instance for type " + pClass.getName());
|
||||
}
|
||||
return processorFactory;
|
||||
}
|
||||
|
||||
private class ArchivaRequestProcessorFactory implements RequestProcessorFactory
|
||||
{
|
||||
private final Class pType;
|
||||
|
||||
private final Object serviceObject;
|
||||
|
||||
public ArchivaRequestProcessorFactory(Class pType, Object serviceObject)
|
||||
{
|
||||
this.pType = pType;
|
||||
this.serviceObject = serviceObject;
|
||||
}
|
||||
|
||||
public Object getRequestProcessor(XmlRpcRequest request)
|
||||
throws XmlRpcException
|
||||
{
|
||||
return serviceObject;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package org.apache.maven.archiva.web.xmlrpc.server;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import com.atlassian.xmlrpc.BinderXmlRpcServlet;
|
||||
import java.util.List;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
import org.apache.xmlrpc.XmlRpcRequest;
|
||||
import org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping.AuthenticationHandler;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
public class ArchivaXmlRpcServlet extends BinderXmlRpcServlet
|
||||
{
|
||||
private final String XMLRPC_SERVICES_BEAN_NAME = "xmlrpcServices";
|
||||
|
||||
private ApplicationContext context;
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig pConfig)
|
||||
throws ServletException
|
||||
{
|
||||
super.init(pConfig);
|
||||
|
||||
context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
|
||||
setAuthenticationHandler(new ArchivaAuthenticationHandler());
|
||||
initRequestProcessorFactoryFactory();
|
||||
}
|
||||
|
||||
private void initRequestProcessorFactoryFactory() throws ServletException
|
||||
{
|
||||
List serviceList = (List)context.getBean(XMLRPC_SERVICES_BEAN_NAME);
|
||||
if (serviceList == null)
|
||||
{
|
||||
throw new ServletException("Could not find bean " + XMLRPC_SERVICES_BEAN_NAME);
|
||||
}
|
||||
|
||||
setRequestProcessorFactoryFactory(new ArchivaRequestProcessorFactoryFactory(serviceList));
|
||||
}
|
||||
|
||||
/**
|
||||
* Servlet Security
|
||||
*/
|
||||
private class ArchivaAuthenticationHandler implements AuthenticationHandler
|
||||
{
|
||||
public boolean isAuthorized(XmlRpcRequest request) throws XmlRpcException {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.apache.maven.archiva.web.xmlrpc.server.services;
|
||||
package org.apache.maven.archiva.web.xmlrpc.services;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
@ -388,7 +388,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-xmlrpc-server</artifactId>
|
||||
<artifactId>archiva-xmlrpc-services</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -882,12 +882,12 @@
|
||||
<dependency>
|
||||
<groupId>com.atlassian.xmlrpc</groupId>
|
||||
<artifactId>atlassian-xmlrpc-binder-annotations</artifactId>
|
||||
<version>0.5</version>
|
||||
<version>0.6-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atlassian.xmlrpc</groupId>
|
||||
<artifactId>atlassian-xmlrpc-binder-server</artifactId>
|
||||
<version>0.5</version>
|
||||
<artifactId>atlassian-xmlrpc-binder-server-spring</artifactId>
|
||||
<version>0.6-SNAPSHOT</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
@ -898,13 +898,13 @@
|
||||
<dependency>
|
||||
<groupId>com.atlassian.xmlrpc</groupId>
|
||||
<artifactId>atlassian-xmlrpc-binder</artifactId>
|
||||
<version>0.5</version>
|
||||
<version>0.6-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atlassian.xmlrpc</groupId>
|
||||
<artifactId>atlassian-xmlrpc-binder-testing</artifactId>
|
||||
<version>0.5</version>
|
||||
<version>0.6-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user