archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdu...@apache.org
Subject svn commit: r689708 - in /archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc: ./ archiva-xmlrpc-api/ archiva-xmlrpc-server/ archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ archiva-xmlrpc-server/src/main/...
Date Thu, 28 Aug 2008 04:02:44 GMT
Author: jdumay
Date: Wed Aug 27 21:02:43 2008
New Revision: 689708

URL: http://svn.apache.org/viewvc?rev=689708&view=rev
Log:
Can now define XmlRpc Services as spring beans :)


Added:
    archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaRequestProcessorFactory.java
    archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaRequestProcessorFactoryFactory.java
    archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaXmlRpcServlet.java
    archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/services/
    archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/services/PingServiceImpl.java
Modified:
    archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/   (props changed)
    archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/
  (props changed)
    archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/
  (props changed)
    archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/pom.xml

Propchange: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Aug 27 21:02:43 2008
@@ -0,0 +1 @@
+target

Propchange: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Aug 27 21:02:43 2008
@@ -0,0 +1 @@
+target

Propchange: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Aug 27 21:02:43 2008
@@ -0,0 +1 @@
+target

Modified: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/pom.xml
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/pom.xml?rev=689708&r1=689707&r2=689708&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/pom.xml
(original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/pom.xml
Wed Aug 27 21:02:43 2008
@@ -19,19 +19,31 @@
   -->
 
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.apache.archiva</groupId>
-    <artifactId>archiva-xmlrpc</artifactId>
-    <version>1.2-SNAPSHOT</version>
-  </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.archiva</groupId>
+        <artifactId>archiva-xmlrpc</artifactId>
+        <version>1.2-SNAPSHOT</version>
+    </parent>
 
-  <artifactId>archiva-xmlrpc-server</artifactId>
-  <name>Archiva Web :: XML-RPC Server</name>
-  <dependencies>
-      <dependency>
-        <groupId>com.atlassian.xmlrpc</groupId>
-        <artifactId>atlassian-xmlrpc-binder-server</artifactId>
-      </dependency>
-  </dependencies>
+    <artifactId>archiva-xmlrpc-server</artifactId>
+    <name>Archiva Web :: XML-RPC Server</name>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.archiva</groupId>
+            <artifactId>archiva-xmlrpc-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.atlassian.xmlrpc</groupId>
+            <artifactId>atlassian-xmlrpc-binder-server</artifactId>
+        </dependency>
+    </dependencies>
 </project>

Added: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaRequestProcessorFactory.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaRequestProcessorFactory.java?rev=689708&view=auto
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaRequestProcessorFactory.java
(added)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaRequestProcessorFactory.java
Wed Aug 27 21:02:43 2008
@@ -0,0 +1,46 @@
+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 org.apache.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.XmlRpcRequest;
+import org.apache.xmlrpc.server.RequestProcessorFactoryFactory;
+
+/**
+ * Service an instance of the service object
+ */
+public class ArchivaRequestProcessorFactory implements RequestProcessorFactoryFactory.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;
+    }
+}

Added: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaRequestProcessorFactoryFactory.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaRequestProcessorFactoryFactory.java?rev=689708&view=auto
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaRequestProcessorFactoryFactory.java
(added)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaRequestProcessorFactoryFactory.java
Wed Aug 27 21:02:43 2008
@@ -0,0 +1,52 @@
+package org.apache.maven.archiva.web.xmlrpc.server;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/*
+ * 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.List;
+import org.apache.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.server.RequestProcessorFactoryFactory;
+import org.apache.xmlrpc.server.RequestProcessorFactoryFactory.RequestProcessorFactory;
+
+public class ArchivaRequestProcessorFactoryFactory implements RequestProcessorFactoryFactory
+{
+    private final Map<Class, Object> services;
+
+    public ArchivaRequestProcessorFactoryFactory(List serviceList)
+    {
+        services = new HashMap<Class, Object>();
+        for (Object service : serviceList)
+        {
+            services.put(service.getClass(), service);
+        }
+    }
+
+    public RequestProcessorFactory getRequestProcessorFactory(Class pClass)
+        throws XmlRpcException
+    {
+        Object object = services.get(pClass);
+        if (object == null)
+        {
+            throw new XmlRpcException("Could not find service object instance for type "
+ pClass.getName());
+        }
+        return new ArchivaRequestProcessorFactory(pClass, object);
+    }
+}

Added: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaXmlRpcServlet.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaXmlRpcServlet.java?rev=689708&view=auto
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaXmlRpcServlet.java
(added)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/ArchivaXmlRpcServlet.java
Wed Aug 27 21:02:43 2008
@@ -0,0 +1,69 @@
+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;
+        }
+    }
+}

Added: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/services/PingServiceImpl.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/services/PingServiceImpl.java?rev=689708&view=auto
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/services/PingServiceImpl.java
(added)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-server/src/main/java/org/apache/maven/archiva/web/xmlrpc/server/services/PingServiceImpl.java
Wed Aug 27 21:02:43 2008
@@ -0,0 +1,30 @@
+package org.apache.maven.archiva.web.xmlrpc.server.services;
+
+/*
+ * 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 org.apache.maven.archiva.web.xmlrpc.api.TestService;
+
+public class PingServiceImpl implements TestService
+{
+    public String ping()
+    {
+        return "pong";
+    }
+}



Mime
View raw message