JRubyによるエンタープライズweb開発

Naoto Takai
JRuby
                                                  Webwith JRuby
                  Enterprise Web Application Development
                        2010 12 4               Akasaka.rb




Photo by Michael Pick
Photo by Koichiro Ohba
JRubyによるエンタープライズweb開発
JRubyによるエンタープライズweb開発
JRubyによるエンタープライズweb開発
JRubyによるエンタープライズweb開発
Rubyist
Struts
Front Controller
ActionServlet             RequestProcessor             Action




                                     processActionPerform
                process

                                             execute
Front Controller
ActionServlet             RequestProcessor             Action




                                     processActionPerform
                process

                                             execute
JRubyRequestController

Struts               RequestProcessor
 Ruby
class   RubyActionRequestProcessor
  def   process_action_form req, res, mapping
    #   do something
  end
  def   process_action_perform req, res, action, form, mapping
    #   do something
  end
end
JRubyRequestController.java
public class JRubyRequestProcessor
    extends RequestProcessor {
...
    @Override
    public void init(ActionServlet servlet,
                     ModuleConfig moduleConfig)
        throws ServletException {

        super.init(servlet, moduleConfig);
...
struts-config.xml
<struts-config>
...
  <controller
    processorClass="n.r.s.JRubyRequestProcessor">
    <set-property
       key="scriptPath"
       value="/WEB-INF/request-processor.rb"
    />
  </controller>
...
</struts-config>
JRubyRequestController#init()
container = new ScriptingContainer(
                  LocalContextScope.THREADSAFE
                );

•
• LocalContextScope.THREADSAFE
                    Ruby
JRubyRequestController#init()
container.put("SERVLET_CONTEXT",
              servlet.getServletContext());

• ServletContext
  SERVLET_CONTEXT
JRubyRequestController#init()
String path =
    moduleConfig.getControllerConfig()
                .getProperty("scriptPath");
InputStream stream =
    servlet.getServletContext()
           .getResourceAsStream(path);
EmbedEvalUnit unit =
    container.parse(stream, path);
requestProcessor = unit.run();

• scriptPath
                  requestProcessor
JRubyRequestController#init()
String[] names =
    container.callMethod(requestProcessor,
                         "public_methods",
                         false,
                         String[].class);
supportedMethods =
    new HashSet<String>(Arrays.asList(names));

• requestProcessor
  public_methods                false
JRubyRequestController.java
@Override
protected ActionForward process...(
    HttpServletRequest request...) throws ...{
    if (supportedMethods.contains("process...")){
        return container.callMethod(
            requestProcessor,
            "process...",
            new Object[] { request, ... },
            ActionForward.class);
        } else {
            return super.process...
        }
...
requestProcessor
               JRubyRequsetProcessor
                                                  :IRubyObject




processActionPerform

                             process_action_perform




            Ruby
JRubyRequestProcessor
SinatraRequestProcessor
class SinatraRequestProcessor
  def initialize
    @app = SinatraHelloAction.new
  end

  def process req, res
    servlet_env = ServletRackEnvironment.new req
    env = Rack::Handler::LazyEnv.new servlet_env

   status, header, body = @app.call env.to_hash

    res.setStatus(status)
    header.each do |k, v|
      res.setHeader(k, v)
    end
    out = res.getOutputStream
    out.print(body.join)
  end
end
JRubyによるエンタープライズweb開発
Happy Hacking!
     and
 Good Carling!
1 of 22

Recommended

JRuby on Rails and Thread Safety by
JRuby on Rails and Thread SafetyJRuby on Rails and Thread Safety
JRuby on Rails and Thread SafetyNaoto Takai
4.4K views20 slides
JS everywhere 2011 by
JS everywhere 2011JS everywhere 2011
JS everywhere 2011Oleg Podsechin
1.5K views68 slides
Bootstrap by
BootstrapBootstrap
BootstrapNexThoughts Technologies
286 views8 slides
Security Challenges in Node.js by
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.jsWebsecurify
3.3K views46 slides
Akka Cluster in Java - JCConf 2015 by
Akka Cluster in Java - JCConf 2015Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015Jiayun Zhou
4K views63 slides
How to Begin Developing Ruby Core by
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHiroshi SHIBATA
1.9K views27 slides

More Related Content

What's hot

Nodejs Explained with Examples by
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with ExamplesGabriele Lana
112.3K views78 slides
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf by
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev ConfTom Croucher
22.7K views51 slides
Data processing with celery and rabbit mq by
Data processing with celery and rabbit mqData processing with celery and rabbit mq
Data processing with celery and rabbit mqJeff Peck
1.6K views29 slides
NoSQL Injections in Node.js - The case of MongoDB by
NoSQL Injections in Node.js - The case of MongoDBNoSQL Injections in Node.js - The case of MongoDB
NoSQL Injections in Node.js - The case of MongoDBSqreen
54.5K views14 slides
Practical ngx_mruby by
Practical ngx_mrubyPractical ngx_mruby
Practical ngx_mrubyHiroshi SHIBATA
5.9K views27 slides
Elastic search 클러스터관리 by
Elastic search 클러스터관리Elastic search 클러스터관리
Elastic search 클러스터관리HyeonSeok Choi
656 views17 slides

What's hot(20)

Nodejs Explained with Examples by Gabriele Lana
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
Gabriele Lana112.3K views
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf by Tom Croucher
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Tom Croucher22.7K views
Data processing with celery and rabbit mq by Jeff Peck
Data processing with celery and rabbit mqData processing with celery and rabbit mq
Data processing with celery and rabbit mq
Jeff Peck1.6K views
NoSQL Injections in Node.js - The case of MongoDB by Sqreen
NoSQL Injections in Node.js - The case of MongoDBNoSQL Injections in Node.js - The case of MongoDB
NoSQL Injections in Node.js - The case of MongoDB
Sqreen54.5K views
Elastic search 클러스터관리 by HyeonSeok Choi
Elastic search 클러스터관리Elastic search 클러스터관리
Elastic search 클러스터관리
HyeonSeok Choi656 views
Introduction to reactive programming & ReactiveCocoa by Florent Pillet
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoa
Florent Pillet7.1K views
Building your first Node app with Connect & Express by Christian Joudrey
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & Express
Christian Joudrey21.2K views
Large-scaled Deploy Over 100 Servers in 3 Minutes by Hiroshi SHIBATA
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA3.8K views
Celery - A Distributed Task Queue by Duy Do
Celery - A Distributed Task QueueCelery - A Distributed Task Queue
Celery - A Distributed Task Queue
Duy Do3.2K views
Django Celery by Mat Clayton
Django Celery Django Celery
Django Celery
Mat Clayton12.7K views
How to test code with mruby by Hiroshi SHIBATA
How to test code with mrubyHow to test code with mruby
How to test code with mruby
Hiroshi SHIBATA10.1K views
Middleware as Code with mruby by Hiroshi SHIBATA
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
Hiroshi SHIBATA4.8K views

Similar to JRubyによるエンタープライズweb開発

How and why i roll my own node.js framework by
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js frameworkBen Lin
3.3K views62 slides
Fast Web Applications Development with Ruby on Rails on Oracle by
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleRaimonds Simanovskis
3.3K views32 slides
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011 by
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
3.6K views70 slides
JRuby - Programmer's Best Friend on JVM by
JRuby - Programmer's Best Friend on JVMJRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMRaimonds Simanovskis
1.6K views41 slides
JavaScript Growing Up by
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
14.1K views57 slides
Training: Day Four - Struts, Tiles, Renders and Faces by
Training: Day Four - Struts, Tiles, Renders and FacesTraining: Day Four - Struts, Tiles, Renders and Faces
Training: Day Four - Struts, Tiles, Renders and FacesArtur Ventura
926 views42 slides

Similar to JRubyによるエンタープライズweb開発(20)

How and why i roll my own node.js framework by Ben Lin
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
Ben Lin3.3K views
Fast Web Applications Development with Ruby on Rails on Oracle by Raimonds Simanovskis
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011 by Nick Sieger
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger3.6K views
JavaScript Growing Up by David Padbury
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury14.1K views
Training: Day Four - Struts, Tiles, Renders and Faces by Artur Ventura
Training: Day Four - Struts, Tiles, Renders and FacesTraining: Day Four - Struts, Tiles, Renders and Faces
Training: Day Four - Struts, Tiles, Renders and Faces
Artur Ventura926 views
Project Description Of Incident Management System Developed by PRS (CRIS) , N... by varunsunny21
Project Description Of Incident Management System Developed by PRS (CRIS) , N...Project Description Of Incident Management System Developed by PRS (CRIS) , N...
Project Description Of Incident Management System Developed by PRS (CRIS) , N...
varunsunny212K views
Introduction tomcat7 servlet3 by JavaEE Trainers
Introduction tomcat7 servlet3Introduction tomcat7 servlet3
Introduction tomcat7 servlet3
JavaEE Trainers1.7K views
Activator and Reactive at Play NYC meetup by Henrik Engström
Activator and Reactive at Play NYC meetupActivator and Reactive at Play NYC meetup
Activator and Reactive at Play NYC meetup
Henrik Engström1.7K views
Clojure and the Web by nickmbailey
Clojure and the WebClojure and the Web
Clojure and the Web
nickmbailey1.9K views
Практики применения JRuby by .toster
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby
.toster967 views
Building Web Apps with Express by Aaron Stannard
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
Aaron Stannard10.3K views
Ember.js - A JavaScript framework for creating ambitious web applications by Juliana Lucena
Ember.js - A JavaScript framework for creating ambitious web applications  Ember.js - A JavaScript framework for creating ambitious web applications
Ember.js - A JavaScript framework for creating ambitious web applications
Juliana Lucena9.7K views
Unit Testing Express and Koa Middleware in ES2015 by Morris Singer
Unit Testing Express and Koa Middleware in ES2015Unit Testing Express and Koa Middleware in ES2015
Unit Testing Express and Koa Middleware in ES2015
Morris Singer5.2K views

More from Naoto Takai

私と自分戦略 by
私と自分戦略私と自分戦略
私と自分戦略Naoto Takai
4K views22 slides
地域.rbのご提案 by
地域.rbのご提案地域.rbのご提案
地域.rbのご提案Naoto Takai
2K views12 slides
JRuby最新事情@札幌 by
JRuby最新事情@札幌JRuby最新事情@札幌
JRuby最新事情@札幌Naoto Takai
1.4K views10 slides
JRoRでGAE/Jの手引き by
JRoRでGAE/Jの手引きJRoRでGAE/Jの手引き
JRoRでGAE/Jの手引きNaoto Takai
1.4K views16 slides
『エンタープライズRails』に学ぶ企業ユーザのためのRailsアーキテクチャ by
『エンタープライズRails』に学ぶ企業ユーザのためのRailsアーキテクチャ『エンタープライズRails』に学ぶ企業ユーザのためのRailsアーキテクチャ
『エンタープライズRails』に学ぶ企業ユーザのためのRailsアーキテクチャNaoto Takai
3.3K views42 slides
5分でわかるJRuby最新事情 by
5分でわかるJRuby最新事情5分でわかるJRuby最新事情
5分でわかるJRuby最新事情Naoto Takai
1.5K views10 slides

More from Naoto Takai(6)

地域.rbのご提案 by Naoto Takai
地域.rbのご提案地域.rbのご提案
地域.rbのご提案
Naoto Takai2K views
JRuby最新事情@札幌 by Naoto Takai
JRuby最新事情@札幌JRuby最新事情@札幌
JRuby最新事情@札幌
Naoto Takai1.4K views
JRoRでGAE/Jの手引き by Naoto Takai
JRoRでGAE/Jの手引きJRoRでGAE/Jの手引き
JRoRでGAE/Jの手引き
Naoto Takai1.4K views
『エンタープライズRails』に学ぶ企業ユーザのためのRailsアーキテクチャ by Naoto Takai
『エンタープライズRails』に学ぶ企業ユーザのためのRailsアーキテクチャ『エンタープライズRails』に学ぶ企業ユーザのためのRailsアーキテクチャ
『エンタープライズRails』に学ぶ企業ユーザのためのRailsアーキテクチャ
Naoto Takai3.3K views
5分でわかるJRuby最新事情 by Naoto Takai
5分でわかるJRuby最新事情5分でわかるJRuby最新事情
5分でわかるJRuby最新事情
Naoto Takai1.5K views

Recently uploaded

DRBD Deep Dive - Philipp Reisner - LINBIT by
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBITShapeBlue
140 views21 slides
The Power of Heat Decarbonisation Plans in the Built Environment by
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built EnvironmentIES VE
69 views20 slides
Future of AR - Facebook Presentation by
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook PresentationRob McCarty
62 views27 slides
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...ShapeBlue
132 views15 slides
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...ShapeBlue
138 views18 slides
Data Integrity for Banking and Financial Services by
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial ServicesPrecisely
78 views26 slides

Recently uploaded(20)

DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue140 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE69 views
Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty62 views
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue132 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... by ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue138 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely78 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue79 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc160 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue163 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software385 views
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue123 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue120 views
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ by ShapeBlue
Confidence in CloudStack - Aron Wagner, Nathan Gleason - AmericConfidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
Confidence in CloudStack - Aron Wagner, Nathan Gleason - Americ
ShapeBlue88 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue144 views
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li80 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue93 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue166 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue146 views

JRubyによるエンタープライズweb開発

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n