public void deploy(DeploymentUnit unit) throws DeploymentException {
    Set<? extends RubyEndpointMetaData> allMetaData =
        unit.getAllMetaData(RubyEndpointMetaData.class);

    if (allMetaData.size() == 0) {
      return;
    }

    log.debug("deploying for: " + unit);

    BeanMetaData busMetaData =
        unit.getAttachment(BeanMetaData.class + "$cxf.bus", BeanMetaData.class);

    RubyDynamicClassLoader classLoader = unit.getAttachment(RubyDynamicClassLoader.class);

    for (RubyEndpointMetaData endpointMetaData : allMetaData) {
      String beanName = getBeanName(unit, endpointMetaData.getName());
      BeanMetaDataBuilder builder =
          BeanMetaDataBuilder.createBuilder(beanName, RubyTypeSpace.class.getName());

      builder.addPropertyMetaData("rubyPath", "jboss/databinding/" + endpointMetaData.getName());
      builder.addPropertyMetaData("wsdlLocation", endpointMetaData.getWsdlLocation());
      builder.addPropertyMetaData("rubyDynamicClassLoader", classLoader);

      ValueMetaData busInjection = builder.createInject(busMetaData.getName());
      builder.addPropertyMetaData("bus", busInjection);

      BeanMetaData beanMetaData = builder.getBeanMetaData();
      unit.addAttachment(
          BeanMetaData.class.getName() + "$databinding." + endpointMetaData.getName(),
          beanMetaData,
          BeanMetaData.class);
    }
  }
  public void testProvidedMetaData() throws Throwable {
    MemoryMetaDataLoader memory =
        new MemoryMetaDataLoader(new ScopeKey(CommonLevels.INSTANCE, "foobar"));
    memory.addAnnotation(new AliasesImpl("alias"));
    MetaDataRetrieval retrieval = new AbstractMetaDataContext(null, memory);
    MetaData metaData = new MetaDataRetrievalToMetaDataBridge(retrieval);

    BeanMetaData bmd = AnnotationToBeanMetaDataFactory.createBeanMetaData(Object.class, metaData);
    assertNotNull(bmd);
    assertEquals(Collections.singleton((Object) "alias"), bmd.getAliases());
  }
  public void testDefaultAnnotation2BMDFactory() throws Throwable {
    BeanMetaData bmd1 = AnnotationToBeanMetaDataFactory.createBeanMetaData(AllIoCAnnotations.class);
    testBMD(bmd1);

    bmd1 =
        AnnotationToBeanMetaDataFactory.createBeanMetaData(
            AllIoCAnnotations.class, BeanAccessMode.ALL);
    testBMD(bmd1);

    bmd1 = AnnotationToBeanMetaDataFactory.createBeanMetaData(ConstructorAnnotationTester.class);
    ConstructorMetaData cmd = bmd1.getConstructor();
    assertNotNull(cmd);
    List<ParameterMetaData> parameters = cmd.getParameters();
    assertNotNull(parameters);
    assertEquals(1, parameters.size());
  }
 protected void setParameterizedMetaData(
     AbstractInstallMetaData parameterizedMetaData, BeanMetaData beanMetaData) {
   AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
   List<InstallMetaData> installs = beanMetaData.getInstalls();
   if (installs == null) {
     installs = new ArrayList<InstallMetaData>();
     abmd.setInstalls(installs);
   }
   installs.add(parameterizedMetaData);
 }
  protected void testBMD(BeanMetaData bmd) throws Throwable {
    assertNotNull(bmd);
    assertEquals(Collections.singleton((Object) "alias"), bmd.getAliases());
    assertEquals(
        Collections.singleton((SupplyMetaData) new AbstractSupplyMetaData("supply")),
        bmd.getSupplies());
    assertEquals(
        Collections.singleton((DemandMetaData) new AbstractDemandMetaData("demand")),
        bmd.getDemands());
    assertEquals(
        Collections.singleton((DependencyMetaData) new AbstractDependencyMetaData("depend")),
        bmd.getDepends());
    ConstructorMetaData cmd = bmd.getConstructor();
    assertNotNull(cmd);
    assertEquals(AnnotationTester.class.getName(), cmd.getFactoryClass());
    assertEquals("factoryMethod", cmd.getFactoryMethod());
    testInstalls(bmd.getInstalls());
    testInstalls(bmd.getUninstalls());

    List<CallbackMetaData> callbacks = bmd.getInstallCallbacks();
    assertNotNull(callbacks);
    assertEquals(1, callbacks.size());
    CallbackMetaData callback = callbacks.get(0);
    assertTrue(callback.getMethodName().contains("Something"));
    callbacks = bmd.getUninstallCallbacks();
    assertNotNull(callbacks);
    assertEquals(1, callbacks.size());
    callback = callbacks.get(0);
    assertTrue(callback.getMethodName().contains("Something"));

    BeanAccessMode mode = bmd.getAccessMode();
    if (mode == BeanAccessMode.ALL) {
      Set<PropertyMetaData> propertys = bmd.getProperties();
      assertNotNull(propertys);
      assertEquals(2, propertys.size());
    } else {
      Set<PropertyMetaData> propertys = bmd.getProperties();
      assertNotNull(propertys);
      assertEquals(1, propertys.size());
      PropertyMetaData pmd = propertys.iterator().next();
      assertEquals("number", pmd.getName());
      assertInstanceOf(pmd.getValue(), AbstractDependencyValueMetaData.class);
    }
    testLifecycle(bmd.getCreate(), "myCreate");
    testLifecycle(bmd.getStart(), "myStart");
    testLifecycle(bmd.getStop(), "myStop");
    testLifecycle(bmd.getDestroy(), "myDestroy");
  }
 public void testCustomAdapter() throws Throwable {
   BeanMetaData bmd =
       AnnotationToBeanMetaDataFactory.createBeanMetaData(
           Object.class, new SimpleBeanMetaDataAnnotationAdapter());
   assertEquals(ControllerMode.ASYNCHRONOUS, bmd.getMode());
 }
 public void applyAnnotations(BeanInfo beanInfo, MetaData metaData, BeanMetaData beanMetaData)
     throws Throwable {
   beanMetaData.setMode(ControllerMode.ASYNCHRONOUS);
 }
 protected List<InstallMetaData> getInstalls(BeanMetaData beanMetaData) {
   return beanMetaData.getInstalls();
 }