Package org.apache.openejb.config

Examples of org.apache.openejb.config.EjbModule


      //If already running then avoid
      if(runningApps.get(bundle) != null)
        return;
     
      //Broken validation for persistence :(
      EjbModule ejbModule = new EjbModule(AriesFrameworkUtil.getClassLoaderForced(bundle), null, null, null);
      try {
        Field f = EjbModule.class.getDeclaredField("validation");
        f.setAccessible(true);
        f.set(ejbModule, new ValidationProofValidationContext(ejbModule));
      } catch (Exception e) {
        // Hmmm
      }
      addAltDDs(ejbModule, bundle);
      //We build our own because we can't trust anyone to get the classpath right otherwise!
      ejbModule.setFinder(new OSGiFinder(bundle));
     
      ConfigurationFactory configurationFactory = new ConfigurationFactory();
     
      EjbJarInfo ejbInfo = null;
      //Avoid yet another ClassLoading problem
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      try {
        Thread.currentThread().setContextClassLoader(new ClassLoader(OpenEjbVersion.class.getClassLoader()) {
          protected Class<?> findClass(String name) throws ClassNotFoundException {
            for(Bundle b : bundle.getBundleContext().getBundles()) {
              if(b.getSymbolicName().contains("jaxb-impl"))
                return b.loadClass(name);
           
            }
            throw new ClassNotFoundException(name);
          }
        });
       
        ejbInfo = configurationFactory.configureApplication(ejbModule);
        //Another oddity here
        ejbInfo.validationInfo = null;
      } finally {
        Thread.currentThread().setContextClassLoader(cl);
      }
     
      processJPAMappings(ejbInfo);
     
     
      Assembler assembler = (Assembler) SystemInstance.get().getComponent(Assembler.class);
      RunningApplication app = null;
      try {
        SystemInstance.get().setProperty("openejb.geronimo", "true");
        cl = Thread.currentThread().getContextClassLoader();
        try {
          Thread.currentThread().setContextClassLoader(OpenEjbVersion.class.getClassLoader());
          app = new RunningApplication(assembler.createApplication(ejbInfo,
              new AppClassLoader(ejbModule.getClassLoader())), bundle, ejbInfo.enterpriseBeans);
        } finally {
          Thread.currentThread().setContextClassLoader(cl);
        }
      } finally {
        SystemInstance.get().getProperties().remove("openejb.geronimo");
View Full Code Here


        String openejbJarXml = XmlUtil.loadOpenejbJarXml(null, moduleFile);
        OpenejbJar openejbJar = XmlUtil.unmarshal(OpenejbJar.class, openejbJarXml);

        // create the module object
        ClassLoader classLoader = new URLClassLoader(new URL[] {file.toURL()}, getClass().getClassLoader());
        EjbModule ejbModule = new EjbModule(classLoader, moduleFile.getName(), ejbJar, openejbJar);
        // configure the application
        EjbJarInfo ejbJarInfo = openEjbSystem.configureApplication(ejbModule);
        openEjbSystem.createEjbJar(ejbJarInfo, classLoader);
    }
View Full Code Here

            {
                ejbJar.addEnterpriseBean(new StatefulBean(clazz));
            }
        }

        return new EjbModule(ejbJar);

    }
View Full Code Here

    }

    private void ear(EjbJar... ejbJars) throws OpenEJBException, NamingException, IOException {
        AppModule app = new AppModule(this.getClass().getClassLoader(), "classpath-"+ejbJars.hashCode());
        for (EjbJar ejbJar : ejbJars) {
            app.getEjbModules().add(new EjbModule(ejbJar));
        }
        assembler.createApplication(config.configureApplication(app));
    }
View Full Code Here

    @Before
    public void initialize() {
        bean = new StatelessBean("CheeseEjb", "org.acme.CheeseEjb");
        bean.setTransactionType(CONTAINER);

        module = new EjbModule(new EjbJar());
        module.getEjbJar().addEnterpriseBean(bean);

        rule = new CheckUserTransactionRefs();
        rule.module = module;
    }
View Full Code Here

//        List<ContainerTransaction> declared = ejbJar.getAssemblyDescriptor().getContainerTransaction();

//        declared.add(new ContainerTransaction(TransAttribute.REQUIRED, ExtendedContextBean.class.getName(), "Extendedx5", "*"));
//        declared.add(new ContainerTransaction(TransAttribute.REQUIRED, ExtendedContextBean.class.getName(), "TransactionToExtended", "*"));       

        EjbModule ejbModule = new EjbModule(ejbJar);

        // Create an "ear"
        AppModule appModule = new AppModule(ejbModule.getClassLoader(), "test-app");

        // Add the ejb-jar.xml to the ear
        appModule.getEjbModules().add(ejbModule);

        // Create a persistence-unit for this app
View Full Code Here

        // generate ejb jar application
        EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(createJaxbMdb("JmsMdb", BasicMdbBean.class.getName(), MessageListener.class.getName()));
        ejbJar.addEnterpriseBean(createJaxbMdb("FakeMdb", FakeMdb.class.getName(), Runnable.class.getName()));
        EjbModule ejbModule = new EjbModule(getClass().getClassLoader(), "FakeEjbJar", "fake.jar", ejbJar, null);

        // configure and deploy it
        EjbJarInfo info = config.configureApplication(ejbModule);
        assembler.createEjbJar(info);
    }
View Full Code Here

        EjbJar ejbJar = new EjbJar();

        StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(EchoBean.class));
        bean.setServiceEndpoint(EchoServiceEndpoint.class.getName());

        return new EjbModule(this.getClass().getClassLoader(), this.getClass().getSimpleName(), "test", ejbJar, null);
    }
View Full Code Here

        EjbJar ejbJar = new EjbJar();

        StatefulBean bean = ejbJar.addEnterpriseBean(new StatefulBean(StatefulSessionBeanTest.TargetBean.class));
        bean.setHomeAndRemote(TargetHome.class, Target.class);

        return new EjbModule(this.getClass().getClassLoader(), this.getClass().getSimpleName(), "test", ejbJar, null);
    }
View Full Code Here

        EjbJar ejbJar = new EjbJar();

        StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(EchoBean.class));
        bean.setServiceEndpoint(EchoServiceEndpoint.class.getName());

        return new EjbModule(this.getClass().getClassLoader(), this.getClass().getSimpleName(), "test", ejbJar, null);
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.config.EjbModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.