You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2011/12/22 11:36:02 UTC

svn commit: r1222165 - in /axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/axis2/ src/main/java/org/apache/axis2/maven2/ src/main...

Author: sagara
Date: Thu Dec 22 10:36:02 2011
New Revision: 1222165

URL: http://svn.apache.org/viewvc?rev=1222165&view=rev
Log:
Added initial codes for AXIS2-5217. 

Added:
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/pom.xml   (with props)
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/SimpleHttpServerMojo.java   (with props)
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Axis2Server.java   (with props)
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Constants.java   (with props)
    axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/RepoHelper.java   (with props)

Added: axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/pom.xml?rev=1222165&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/pom.xml (added)
+++ axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/pom.xml Thu Dec 22 10:36:02 2011
@@ -0,0 +1,78 @@
+<?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 ~ 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. -->
+
+<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.axis2</groupId>
+		<artifactId>axis2-parent</artifactId>
+		<version>1.7.0-SNAPSHOT</version>
+		<relativePath>../../parent/pom.xml</relativePath>
+	</parent>
+	<artifactId>simple-server-maven-plugin</artifactId>
+	<name>Apache Axis2 Simple HTTP server Maven Plugin</name>
+	<packaging>maven-plugin</packaging>
+	<description>The Axis2 Plugin for Maven that allows to run simple HTTP server.</description>
+	<url>http://axis.apache.org/axis2/java/core/</url>
+	<scm>
+		<connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin</connection>
+		<developerConnection>scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin</developerConnection>
+		<url>http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin</url>
+	</scm>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-plugin-plugin</artifactId>
+				<configuration>
+					<goalPrefix>axis2</goalPrefix>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.maven</groupId>
+			<artifactId>maven-plugin-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.maven</groupId>
+			<artifactId>maven-plugin-descriptor</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.codehaus.plexus</groupId>
+			<artifactId>plexus-classworlds</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.axis2</groupId>
+			<artifactId>axis2-kernel</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.axis2</groupId>
+			<artifactId>axis2-adb</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.axis2</groupId>
+			<artifactId>axis2-transport-http</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.axis2</groupId>
+			<artifactId>axis2-transport-local</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+	</dependencies>
+</project>

Propchange: axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/SimpleHttpServerMojo.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/SimpleHttpServerMojo.java?rev=1222165&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/SimpleHttpServerMojo.java (added)
+++ axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/SimpleHttpServerMojo.java Thu Dec 22 10:36:02 2011
@@ -0,0 +1,210 @@
+/*
+ * Copyright 2004, 2009 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.axis2.maven2.server;
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+import org.apache.axis2.maven2.server.util.Axis2Server;
+import org.apache.axis2.maven2.server.util.Constants;
+import org.apache.axis2.maven2.server.util.RepoHelper;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.codehaus.classworlds.ClassRealm;
+import org.codehaus.classworlds.ClassWorld;
+import org.codehaus.classworlds.DuplicateRealmException;
+
+/**
+ * Run simple Axis 2Server.
+ * 
+ * @since 1.7.0
+ * @goal run 
+ * @execute phase="compile"  // TODO - check this again.
+ * @requiresDependencyResolution runtime 
+ */
+public class SimpleHttpServerMojo extends AbstractMojo {
+
+    // configuration parameters.
+    /**
+     * The repository path.
+     * 
+     * @parameter
+     */
+    private String repoPath;
+
+    /**
+     * Path to axis2.xml configuration file.
+     * 
+     * @parameter
+     */
+    private String confPath;
+
+    /**
+     * This parameter indicate service type whether it's JAX-WS or not.
+     * 
+     * @parameter default-value="false"
+     */
+    private boolean jaxwsService;
+
+    /**
+     * @parameter
+     */
+    private String stdServiceSrcDir;
+
+    /**
+     * @parameter
+     */
+    private String jaxwsServiceSrcDir;
+
+    /**
+     * @parameter
+     */
+    private String moduleSrcDir;
+
+    /**
+     * @parameter 
+     */
+    private String port;
+
+    /*
+     * Maven project parameters
+     */
+
+    /**
+     * The plugin descriptor
+     * 
+     * @parameter default-value="${descriptor}"
+     * @required
+     */
+    private PluginDescriptor descriptor;
+
+    /**
+     * Build directory of current project.
+     * 
+     * @parameter default-value="${project.build.directory}"
+     * @required
+     * @readonly
+     */
+    private String buildDir;
+
+    /**
+     * Project version
+     * 
+     * @parameter default-value="${project.version}"
+     * @required
+     * @readonly
+     */
+    private String projectVersion;
+
+    /**
+     * Project Id
+     * 
+     * @parameter default-value="${project.artifactId}"
+     * @required
+     * @readonly
+     */
+    private String projectId;
+
+    private Axis2Server server;
+    private boolean fork;
+
+    public RepoHelper getRepoHelper() {
+        RepoHelper repoHelper = new RepoHelper(repoPath);
+        if (stdServiceSrcDir != null) {
+            repoHelper.setStdServiceSrcDir(stdServiceSrcDir);
+        }
+        if (jaxwsServiceSrcDir != null) {
+            repoHelper.setJaxwsServiceSrcDir(jaxwsServiceSrcDir);
+        }
+        if (moduleSrcDir != null) {
+            repoHelper.setModuleSrcDir(moduleSrcDir);
+        }
+        if (jaxwsService) {
+            repoHelper.setJaxwsService(jaxwsService);
+            String serviceJarFile = buildDir + File.separator + projectId + "-" + projectVersion
+                    + ".jar";
+            repoHelper.setServiceJarLocation(serviceJarFile);
+        }
+        return repoHelper;
+    }
+
+    public void execute() throws MojoExecutionException {
+        try {
+            getLog().info("repo path : " + repoPath);
+            getLog().info("conf path : " + confPath);
+            getRepoHelper().prepareRepostory();
+            extendClassLoader();
+            String serverPort = port == null ? Constants.DEFAULT_PORT : port;
+            server = Axis2Server.newInstance(repoPath, confPath, serverPort );
+            if (fork) {
+                new Thread(new Runnable() {
+                    public void run() {
+                        getLog().info(" Starting Axis2 Simple HTTP Server..................... ");
+                        server.startServer();
+                        getLog().info(" Axis2 Simple HTTP server satreted");
+                        waitForShutdown();
+                    }
+                }).start();
+            } else {
+                server.startServer();
+                waitForShutdown();
+            }
+        } catch (Exception e) {
+            throw new MojoExecutionException("Failed to start AXIS2 HTTP server", e);
+        }
+
+    }
+
+    private void extendClassLoader() throws DuplicateRealmException, MalformedURLException {
+        ClassRealm realm = descriptor.getClassRealm();
+        if (realm == null) {
+            ClassWorld world = new ClassWorld();
+            realm = world.newRealm("maven.plugin." + getClass().getSimpleName(), Thread
+                    .currentThread().getContextClassLoader());
+        }
+        File cls = new File(buildDir + File.separator + Constants.DEFAULT_CLASSES_DIRECTORY);
+        realm.addConstituent(cls.toURL());
+        Thread.currentThread().setContextClassLoader(realm.getClassLoader());
+    }
+
+    protected void waitForShutdown() {
+        final boolean[] shutdown = new boolean[] { false };
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            public void run() {
+                synchronized (shutdown) {
+                    shutdown[0] = true;
+                    shutdown.notify();
+                }
+            }
+        });
+
+        // Wait for any shutdown event
+        synchronized (shutdown) {
+            while (!shutdown[0]) {
+                try {
+                    shutdown.wait();
+                } catch (InterruptedException e) {
+                }
+            }
+        }
+        server.stopServer();
+        getLog().info("Axis2 Simple HTTP server stoped ");
+
+    }
+
+}

Propchange: axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/SimpleHttpServerMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Axis2Server.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Axis2Server.java?rev=1222165&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Axis2Server.java (added)
+++ axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Axis2Server.java Thu Dec 22 10:36:02 2011
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2004, 2009 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.axis2.maven2.server.util;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.transport.SimpleAxis2Server;
+
+/**
+ * The Class Axis2Server.
+ * 
+ * @since 1.7.0
+ */
+public class Axis2Server extends SimpleAxis2Server {
+
+    private static Axis2Server server;
+
+    /**
+     * Create new instance of Axis2Server.
+     *
+     * @param repoPath the repo path
+     * @param confPath the conf path
+     * @param port the port
+     * @return the axis2 server
+     */
+    public static Axis2Server newInstance(String repoPath, String confPath, String port) {
+        try {
+            if (repoPath == null) {
+                repoPath = Constants.DEFAULT_REPO_LOCATION;
+            }
+            server = new Axis2Server(repoPath, confPath);
+            if (confPath == null) {
+                /**
+                 * By default Axis2 HTTP transport listen on 6060 ,if user does
+                 * not specify any port use 8080 as HTTP port.
+                 */
+                Parameter parameter = new Parameter();
+                parameter.setName(Constants.DEFAULT_PORT_PARAM);
+                parameter.setValue(port);
+                ((TransportInDescription) server.getConfigurationContext().getAxisConfiguration()
+                        .getTransportIn("http")).addParameter(parameter);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return server;
+    }
+
+    /**
+     * Instantiates a new axis2 server.
+     *
+     * @param repoPath the repo path
+     * @param confPath the conf path
+     * @throws Exception the exception
+     */
+    private Axis2Server(String repoPath, String confPath) throws Exception {
+        super(repoPath, confPath);
+        server = null;
+    }
+
+    /**
+     * Start server.
+     */
+    public void startServer() {
+        try {
+            server.start();
+        } catch (AxisFault e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Stop server.
+     */
+    public void stopServer() {
+        try {
+            server.stop();
+        } catch (AxisFault e) {
+            e.printStackTrace();
+        }
+    }
+
+}

Propchange: axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Axis2Server.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Constants.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Constants.java?rev=1222165&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Constants.java (added)
+++ axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Constants.java Thu Dec 22 10:36:02 2011
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004, 2009 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.axis2.maven2.server.util;
+
+/**
+ * The Class Constants.
+ * 
+ * @since 1.7.0 
+ */
+public class Constants {
+    
+    /** The Constant DEFAULT_REPO_LOCATION. */
+    public static final String DEFAULT_REPO_LOCATION = "target/work/repository";
+    
+    /** The Constant DEFAULT_STD_SERVICE_DIRECTOY. */
+    public static final String DEFAULT_STD_SERVICE_DIRECTORY = "services";
+    
+    /** The Constant DEFAULT_JAX_WS_SERVICE_DIRECTOY. */
+    public static final String DEFAULT_JAX_WS_SERVICE_DIRECTORY = "servicejars";    
+    
+    /** The Constant DEFAULT_MODULE_REPO_DIRECTOY. */
+    public static final String DEFAULT_MODULE_REPO_DIRECTORY = "modules";
+    
+    /** The Constant DEFAULT_STD_SERVICE_SRC_DIRECTOY. */
+    public static final String DEFAULT_STD_SERVICE_SRC_DIRECTORY = "src/main/resources/services";
+    
+    /** The Constant DEFAULT_JAX_WS_SERVICE_SRC_DIRECTOY. */
+    public static final String DEFAULT_JAX_WS_SERVICE_SRC_DIRECTORY = "src/main/resources/serviceJars"; 
+    
+    /** The Constant DEFAULT_MODULE_SRC_DIRECTOY. */
+    public static final String DEFAULT_MODULE_SRC_DIRECTORY = "src/main/resources/modules"; 
+    
+    /** The Constant DEFAULT_WEB_APP_DIRECTOY. */
+    public static final String DEFAULT_WEB_APP_DIRECTORY = "src/main/webapp/WEB-INF";
+    
+    /** The Constant DEFAULT_CLASSES_DIRECTOY. */
+    public static final String DEFAULT_CLASSES_DIRECTORY = "classes";
+    
+    /** The Constant DEFAULT_PORT_PARAM. */
+    public static final String DEFAULT_PORT_PARAM = "port";
+    
+    /** The Constant DEFAULT_PORT. */
+    public static final String DEFAULT_PORT = "8080";
+
+}

Propchange: axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/Constants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/RepoHelper.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/RepoHelper.java?rev=1222165&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/RepoHelper.java (added)
+++ axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/RepoHelper.java Thu Dec 22 10:36:02 2011
@@ -0,0 +1,346 @@
+/*
+ * Copyright 2004, 2009 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.axis2.maven2.server.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * The Class RepoHelper is utility that deal with repo creation.
+ * 
+ * @since 1.7.0
+ */
+public class RepoHelper {
+
+    /** The repo location. */
+    private String repoLocation;
+
+    /** The service jar location. */
+    private String serviceJarLocation;
+
+    /** The std service dir. */
+    private String stdServiceDir;
+
+    /** The jaxws service dir. */
+    private String jaxwsServiceDir;
+
+    /** The module dir. */
+    private String moduleDir;
+
+    /** The std service src dir. */
+    private String stdServiceSrcDir;
+
+    /** The jaxws service src dir. */
+    private String jaxwsServiceSrcDir;
+
+    /** The module src dir. */
+    private String moduleSrcDir;
+
+    /** The jaxws service. */
+    private boolean jaxwsService = false;
+
+    /**
+     * Gets the module src dir.
+     * 
+     * @return the module src dir
+     */
+    public String getModuleSrcDir() {
+        return moduleSrcDir;
+    }
+
+    /**
+     * Sets the module src dir.
+     * 
+     * @param moduleSrcDir
+     *            the new module src dir
+     */
+    public void setModuleSrcDir(String moduleSrcDir) {
+        this.moduleSrcDir = moduleSrcDir;
+    }
+
+    /**
+     * Gets the repo location.
+     * 
+     * @return the repo location
+     */
+    public String getRepoLocation() {
+        return repoLocation;
+    }
+
+    /**
+     * Sets the repo location.
+     * 
+     * @param repoLocation
+     *            the new repo location
+     */
+    public void setRepoLocation(String repoLocation) {
+        this.repoLocation = repoLocation;
+    }
+
+    /**
+     * Gets the std service src dir.
+     * 
+     * @return the std service src dir
+     */
+    public String getStdServiceSrcDir() {
+        return stdServiceSrcDir;
+    }
+
+    /**
+     * Sets the std service src dir.
+     * 
+     * @param stdServiceSrcDir
+     *            the new std service src dir
+     */
+    public void setStdServiceSrcDir(String stdServiceSrcDir) {
+        this.stdServiceSrcDir = stdServiceSrcDir;
+    }
+
+    /**
+     * Gets the jaxws service src dir.
+     * 
+     * @return the jaxws service src dir
+     */
+    public String getJaxwsServiceSrcDir() {
+        return jaxwsServiceSrcDir;
+    }
+
+    /**
+     * Sets the jaxws service src dir.
+     * 
+     * @param jaxwsServiceSrcDir
+     *            the new jaxws service src dir
+     */
+    public void setJaxwsServiceSrcDir(String jaxwsServiceSrcDir) {
+        this.jaxwsServiceSrcDir = jaxwsServiceSrcDir;
+    }
+
+    /**
+     * Checks if is jaxws service.
+     * 
+     * @return true, if is jaxws service
+     */
+    public boolean isJaxwsService() {
+        return jaxwsService;
+    }
+
+    /**
+     * Sets the jaxws service.
+     * 
+     * @param jaxwsService
+     *            the new jaxws service
+     */
+    public void setJaxwsService(boolean jaxwsService) {
+        this.jaxwsService = jaxwsService;
+    }
+
+    /**
+     * Gets the service jar location.
+     * 
+     * @return the service jar location
+     */
+    public String getServiceJarLocation() {
+        return serviceJarLocation;
+    }
+
+    /**
+     * Sets the service jar location.
+     * 
+     * @param serviceJarLocation
+     *            the new service jar location
+     */
+    public void setServiceJarLocation(String serviceJarLocation) {
+        this.serviceJarLocation = serviceJarLocation;
+    }
+
+    /**
+     * Instantiates a new repo helper.
+     * 
+     * @param repoLocation
+     *            the repo location
+     */
+    public RepoHelper(String repoLocation) {
+        this.repoLocation = repoLocation == null ? Constants.DEFAULT_REPO_LOCATION : repoLocation;
+        initialize();
+
+    }
+
+    /**
+     * Prepare repostory.
+     * 
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
+     */
+    public void prepareRepostory() throws IOException {
+        createDirectoryStructure();
+        copyResourcesForService();
+
+    }
+
+    /**
+     * Initialize.
+     */
+    private void initialize() {
+        this.stdServiceDir = repoLocation + File.separator
+                + Constants.DEFAULT_STD_SERVICE_DIRECTORY;
+        this.jaxwsServiceDir = repoLocation + File.separator
+                + Constants.DEFAULT_JAX_WS_SERVICE_DIRECTORY;
+        this.moduleDir = repoLocation + File.separator + Constants.DEFAULT_MODULE_REPO_DIRECTORY;
+        this.stdServiceSrcDir = Constants.DEFAULT_STD_SERVICE_SRC_DIRECTORY;
+        this.jaxwsServiceSrcDir = Constants.DEFAULT_JAX_WS_SERVICE_SRC_DIRECTORY;
+    }
+
+    /**
+     * Copy resources for service.
+     * 
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
+     */
+    private void copyResourcesForService() throws IOException {
+        if (isJaxwsService()) {
+            copyJaxwsServices();
+        } else {
+            copyStdServices();
+        }
+        copyModules();
+    }
+
+    /**
+     * Copy modules.
+     * 
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
+     */
+    private void copyModules() throws IOException {
+        if (moduleSrcDir == null) {
+            return;
+        }
+        File modsrcFile = new File(moduleSrcDir);
+        File moddisFile = new File(moduleDir);
+        if (modsrcFile.exists()) {
+            copyDirectory(modsrcFile, moddisFile);
+        }
+    }
+
+    /**
+     * Copy jaxws services.
+     * 
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
+     */
+    private void copyJaxwsServices() throws IOException {
+        /*
+         * copy content of JAX-WS service directory If the JAX-WS service
+         * directory mentioned copy content else copy
+         * target/articaft-version.jar file to the repo.
+         */
+        System.out.println("ZZZZZZZZZZZZZZZZZZZZ = " + serviceJarLocation + ":"
+                + jaxwsServiceSrcDir);
+        File srcFile;
+        File disFile = new File(jaxwsServiceDir
+                + serviceJarLocation.substring(serviceJarLocation.lastIndexOf(File.separator)));
+        if (jaxwsServiceSrcDir != null) {
+            /*
+             * TODO - change this
+             */
+            srcFile = new File(serviceJarLocation);
+        } else {
+            srcFile = new File(jaxwsServiceSrcDir);
+        }
+
+        if (srcFile.exists()) {
+            copyDirectory(srcFile, disFile);
+        }
+    }
+
+    /**
+     * Copy std services.
+     * 
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
+     */
+    private void copyStdServices() throws IOException {
+        // copy content of std service directory
+        if (stdServiceSrcDir == null) {
+            return;
+        }
+        File srcFile = new File(stdServiceSrcDir);
+        File disFile = new File(stdServiceDir);
+        if (srcFile.exists()) {
+            copyDirectory(srcFile, disFile);
+        }
+    }
+
+    /**
+     * Creates the directory structure.
+     */
+    private void createDirectoryStructure() {
+        // Create one directory
+        File stdServiceFile = new File(stdServiceDir);
+        File jaxwsServiceFile = new File(jaxwsServiceDir);
+        File moduleFile = new File(moduleDir);
+        boolean success = stdServiceFile.mkdirs();
+        success = jaxwsServiceFile.mkdirs();
+        success = moduleFile.mkdirs();
+        if (success) {
+            System.out.println("Service directories created");
+        }
+    }
+
+    /**
+     * Copy directory.
+     * 
+     * @param sourceLocation
+     *            the source location
+     * @param targetLocation
+     *            the target location
+     * @throws IOException
+     *             Signals that an I/O exception has occurred.
+     */
+    public static void copyDirectory(File sourceLocation, File targetLocation) throws IOException {
+
+        if (sourceLocation.isDirectory()) {
+            if (!targetLocation.exists()) {
+                targetLocation.mkdir();
+            }
+
+            String[] children = sourceLocation.list();
+            for (int i = 0; i < children.length; i++) {
+                copyDirectory(new File(sourceLocation, children[i]), new File(targetLocation,
+                        children[i]));
+            }
+        } else {
+
+            InputStream in = new FileInputStream(sourceLocation);
+            OutputStream out = new FileOutputStream(targetLocation);
+
+            // Copy the bits from instream to outstream
+            byte[] buf = new byte[1024];
+            int len;
+            while ((len = in.read(buf)) > 0) {
+                out.write(buf, 0, len);
+            }
+            in.close();
+            out.close();
+        }
+    }
+
+}

Propchange: axis/axis2/java/core/trunk/modules/tool/simple-server-maven-plugin/src/main/java/org/apache/axis2/maven2/server/util/RepoHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native