zoukankan      html  css  js  c++  java
  • Warbler, A Little Birdie To Introduce Your Rails App To Java

    Warbler, A Little Birdie To Introduce Your Rails App To Java

    Warbler, A Little Birdie To Introduce Your Rails App To Java

    Posted by Nick Sieger
    on 2007年9月4日

    This week I was working on integrating the latest JRuby 1.0.1 and Goldspike 1.3 releases into our environment, when my frustration hit a fever pitch.

    See, I had always thought that the .war packaging side of Goldspike was a little clunky and
    un-ruby-like, but I didn’t see a clear path to fixing it. I had heard little complaints about it here
    and there: the little configuration DSL didn’t give you enough control or wasn’t documented well
    enough; the fact that it downloads libraries from the internet during assembly (convenient, but not
    safe or reproducible for production deployments).

    Also, in my own opinion it took the wrong approach to packaging Rails in a .war file. It puts the
    Rails application directory structure into the root of the .war file where any web server or Java
    application server might mistakenly serve up your code as static content. The Java .war file spec has
    this special directory called WEB-INF expressly for the purpose of hiding that stuff away, so why
    not use it?

    And then, suddenly Goldspike was packaging up my entire Rails application directory, .svn directories
    and everything. So I set out to fix this once and for all.

    And so I present Warbler. A little bird who chirpily steps up to the task of assembling your
    Rails application into a Java Web Archive (.war). Here, get it:

    gem install warbler
    

    And then, in the top directory of your Rails application,

    warble
    

    Those two steps are all it takes to make a .war file, including your application and recent versions
    of JRuby and Goldspike, that’s deployable to your favorite Java application server.

    There are a number of points about Warbler worth mentioning.

    Does one thing, well

    Warbler only packages, and doesn’t care about anything else, like how to dispatch servlet requests to
    Rails. This will allow for more runtime servlet binding mechanisms to take advantage of Warbler in
    the future.

    Fast and lightweight

    50% less code than the Goldspike packaging plugin, yet does the job quickly and efficiently.

    Sane defaults

    Warbler only packages code that you need to run the application, omitting database migrations and
    tests. If your application is self-sufficient (no external dependencies), then the out-of-the-box
    configuration will probably work for you. Public HTML/images/javascript/stylesheets go in the root of
    the webapp, where Java webservers expect them to be.

    Documented, flexible configuration

    Need to customize your configuration? Run warble config and edit config/warble.rb. All the
    options are there, commented and documented.

    Need to change out the bundled JRuby/Goldspike versions? warble pluginize makes a copy of Warbler
    in the vendor/plugins area of your application, allowing you to change the .jar files in the
    vendor/plugins/warbler-0.9/lib directory. Warbler then makes his nest in your project’s list of
    rake tasks (as rake -T | grep war shows)

    rake war            # Create trunk.war
    rake war:app        # Copy all application files into the .war
    rake war:clean      # Clean up the .war file and the staging area
    rake war:gems       # Unpack all gems into WEB-INF/gems
    rake war:jar        # Run the jar command to create the .war
    rake war:java_libs  # Copy all java libraries into the .war
    rake war:public     # Copy all public HTML files to the root of the .war
    rake war:webxml     # Generate a web.xml file for the webapp
    

    Warbler even omits himself in the .war file produced when running in plugin mode, since you won’t
    need him at runtime. It’s the little details that matter.

    Give him a try and let me know if it makes your life deploying Rails applications to JRuby on Java appservers easier!

  • 相关阅读:
    Android pm命令用法
    SSH没有password安全日志
    使用reserve要再次避免不必要的分配
    找到最大的迭代次数串
    个人存储不同类型的对象有一些想法的碰撞检测
    [Android 4.4.3] 泛泰A870 Mokee4.4.3 20140610 RC2.0 通过刷第三版 by syhost
    zoj 3823 Excavator Contest(结构体)
    【Linux】CentOS系统
    Swift学习——Swift解释特定的基础(七)
    Android JNI开发提高篇
  • 原文地址:https://www.cnblogs.com/lexus/p/2397129.html
Copyright © 2011-2022 走看看