soi-toolkit / soi-toolkit-google-code

Automatically exported from code.google.com/p/soi-toolkit
0 stars 0 forks source link

Document how to add support for the servlet transport to an integration component if not added from the beginning #153

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Sample explanation
============

Add support for the servlet transport
-------------------------------------

1. Generate web-projects for the IC
No good support for that right now...
Has to generate a new IC with the same name and manually copy the two 
web-projects + update the main-parent-pom.xml-file

2. Add jetty (embedded servlet container used for tests) to the 
service-projects pom-xml file
Add:
    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty</artifactId>
        <scope>test</scope>
        <version>6.1.11</version>
    </dependency>

3. Add the servlet-transport in common.xml - file
Add the line:
    <servlet:connector name="servletConnector" />

4. Add a servlet-container to the MuleServer.java - file

- Change import from:
    import org.soitoolkit.commons.mule.test.StandaloneMuleServer;
  to:
  import org.soitoolkit.commons.mule.test.MuleServerWithServletContainer;

- Add the following member variables:
    public static final int    HTTP_PORT        = ${servletPort};
    public static final String CONTEXT_PATH     = "/${artifactId}";
    public static final String MULE_SERVLET_URI = "/services";

- Change how the Mule-server is started, i.e. add a servlet-container to it, 
change:
    StandaloneMuleServer muleServer = new StandaloneMuleServer(MULE_SERVER_ID, MULE_CONFIG);
  to:
    MuleServerWithServletContainer muleServer = new MuleServerWithServletContainer(MULE_SERVER_ID, MULE_CONFIG, HTTP_PORT, CONTEXT_PATH, MULE_SERVLET_URI);

- Change the implementation of the getAddress() - method, from:
    String url = rb.getString(serviceUrlPropertyName);
    logger.info("URL: {}", url);
    return url;
  to:
    String url = rb.getString(serviceUrlPropertyName);

    if (!url.startsWith("servlet://")) {
        logger.info("Non servlet URL: {}", url);
        return url;
    }

    String uri = url.substring("servlet://".length());
    url = "http://localhost:" + HTTP_PORT + CONTEXT_PATH + MULE_SERVLET_URI + "/" + uri;
    logger.info("Servlet URL: {}", url);
    return url;

5. Update all integration tests that tests the servlet-transport

- Add imports:
import static 
org.soitoolkit.commons.mule.mime.MimeUtil.sendFileAsMultipartHttpPost;
import static ${javaPackage}.${capitalizedJavaArtifactId}MuleServer.getAddress;
import static 
${javaPackage}.${capitalizedJavaArtifactId}MuleServer.MULE_SERVER_ID;
import static ${javaPackage}.${capitalizedJavaArtifactId}MuleServer.HTTP_PORT;
import static 
${javaPackage}.${capitalizedJavaArtifactId}MuleServer.CONTEXT_PATH;
import static 
${javaPackage}.${capitalizedJavaArtifactId}MuleServer.MULE_SERVLET_URI;

- Change import from:
import org.soitoolkit.commons.mule.test.AbstractTestCase;
  to:
import org.soitoolkit.commons.mule.test.AbstractTestCaseWithServletEngine;

- Change base-class from:
AbstractTestCase
  to:
AbstractTestCaseWithServletEngine

- Initialize the embedded servlet-container in the constructor:

// Initialize servlet engine in baseclass with proper values
super(MULE_SERVER_ID, HTTP_PORT, CONTEXT_PATH, MULE_SERVLET_URI);

6. Change all exposed http(s) - endpoints to the servlet-transport in the 
config.properties-file

...example...

Original issue reported on code.google.com by magnus.l...@gmail.com on 17 Jun 2011 at 7:03

GoogleCodeExporter commented 9 years ago
Moved to 0.5.1

Original comment by magnus.l...@gmail.com on 30 Nov 2011 at 1:22

GoogleCodeExporter commented 9 years ago
Moved to 0.5.2

Original comment by magnus.l...@gmail.com on 6 Apr 2012 at 7:52

GoogleCodeExporter commented 9 years ago
Moved to 0.5.2

Original comment by magnus.l...@gmail.com on 6 Apr 2012 at 7:53

GoogleCodeExporter commented 9 years ago
Move all v0.5.2 issues to v0.6.2

Original comment by magnus.l...@gmail.com on 26 Jul 2012 at 4:17