@Override
  public void deploy(VFSDeploymentUnit unit, RackApplicationMetaData metaData)
      throws DeploymentException {
    String beanName = AttachmentUtils.beanName(unit, RackApplicationPool.class);
    BeanMetaDataBuilder builder =
        BeanMetaDataBuilder.createBuilder(beanName, RackApplicationPoolImpl.class.getName());

    metaData.setRackApplicationPoolName(beanName);

    String appfactoryBeanName = metaData.getRackApplicationFactoryName();
    if (appfactoryBeanName == null) {
      appfactoryBeanName = AttachmentUtils.beanName(unit, RackApplicationFactory.class);
    }

    String runtimePoolBeanName = metaData.getRubyRuntimePoolName();
    if (runtimePoolBeanName == null) {
      runtimePoolBeanName = AttachmentUtils.beanName(unit, RubyRuntimePool.class, POOL_NAME);
      metaData.setRubyRuntimePoolName(runtimePoolBeanName);
    }

    ValueMetaData runtimePoolInjection = builder.createInject(runtimePoolBeanName);
    ValueMetaData appFactoryInjection = builder.createInject(appfactoryBeanName);

    builder.addConstructorParameter(RubyRuntimePool.class.getName(), runtimePoolInjection);
    builder.addConstructorParameter(RackApplicationFactory.class.getName(), appFactoryInjection);

    AttachmentUtils.attach(unit, builder.getBeanMetaData());
    if (null == AttachmentUtils.getAttachment(unit, POOL_NAME, PoolMetaData.class)) {
      AttachmentUtils.multipleAttach(unit, new PoolMetaData(POOL_NAME), POOL_NAME);
    }
  }
Ejemplo n.º 2
0
  @Override
  public void deploy(DeploymentUnit unit) throws DeploymentException {
    log.debug("Deploying rails app as rack: " + unit);
    RailsApplicationMetaData railsAppMetaData = unit.getAttachment(RailsApplicationMetaData.class);

    try {
      RackApplicationMetaData rackMetaData = unit.getAttachment(RackApplicationMetaData.class);

      log.info(rackMetaData);
      log.info(railsAppMetaData);

      if (railsAppMetaData.isRails3()) {
        log.debug("Configuring up a rails 3 application: " + unit);
        rackMetaData.setRackUpScriptLocation("config.ru");
      } else {
        log.debug("Configuring up a rails 2 application: " + unit);
        rackMetaData.setRackUpScript(getRackUpScript(rackMetaData.getContextPath()));
        rackMetaData.setRackUpScriptLocation(null);
      }

      rackMetaData.setStaticPathPrefix(STATIC_PATH_PREFIX);
      log.debug("Configured rack deployment: " + unit + "\n" + rackMetaData);
    } catch (Exception e) {
      throw new DeploymentException(e);
    }
  }