Package org.apache.openejb.assembler.classic

Examples of org.apache.openejb.assembler.classic.Assembler


        super.setUp();

        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());

        ConfigurationFactory config = new ConfigurationFactory();
        Assembler assembler = new Assembler();

        assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

        // containers
        assembler.createContainer(config.configureService(SingletonSessionContainerInfo.class));

        // Setup the descriptor information

        SingletonBean bean = new SingletonBean(WidgetBean.class);
        bean.addBusinessLocal(Widget.class.getName());
        bean.addBusinessRemote(RemoteWidget.class.getName());
        bean.addPostConstruct("init");
        bean.addPreDestroy("destroy");
        bean.setLocalBean(new Empty());

        EjbJar ejbJar = new EjbJar();
        ejbJar.addEnterpriseBean(bean);

        assembler.createApplication(config.configureApplication(ejbJar));

    }
View Full Code Here


    private Assembler configureAssembler(String defaultUser) throws Exception {
        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());

       
        ConfigurationFactory config = new ConfigurationFactory();
        Assembler assembler = new Assembler();

        assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));

        SecurityServiceInfo serviceInfo = new SecurityServiceInfo();
        serviceInfo.service = "SecurityService";
        serviceInfo.className = SecurityServiceImpl.class.getName();
        serviceInfo.id = "New Security Service";
        serviceInfo.properties = new Properties();
        if (defaultUser != null) {
            // override the default user
            serviceInfo.properties.setProperty("DefaultUser", defaultUser);
           
        }

        assembler.createSecurityService(serviceInfo);

        // containers
        assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));

        EjbJar ejbJar = new EjbJar("SecurityTest");

        ejbJar.addEnterpriseBean(new StatelessBean(FooBean.class));
        ejbJar.addEnterpriseBean(new StatelessBean(BarBean.class));

        EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);

        assembler.createApplication(ejbJarInfo);

        return assembler;
    }
View Full Code Here

        objectName = new ObjectName("openejb.management:J2EEServer=openejb,J2EEApplication=null,EJBModule=" + moduleId + ",StatelessSessionBean=CounterBean,j2eeType=Pool,name=CounterBean");

        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, org.apache.openejb.core.LocalInitialContextFactory.class.getName());

        final ConfigurationFactory config = new ConfigurationFactory();
        final Assembler assembler = new Assembler();

        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

        // containers
        final StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
        statelessContainerInfo.properties.putAll(properties);

        assembler.createContainer(statelessContainerInfo);

        final EjbJar ejbJar = new EjbJar(moduleId);
        ejbJar.addEnterpriseBean(new StatelessBean(CounterBean.class));
        assembler.createApplication(config.configureApplication(ejbJar));

        final javax.naming.Context context = new InitialContext();
        return (CounterBean) context.lookup("CounterBeanLocalBean");
    }
View Full Code Here

        return assembler;
    }

    public void test() throws Exception {
        Assembler assembler = configureAssembler(null);

        Properties props = new Properties();
        props.setProperty(Context.SECURITY_PRINCIPAL, "jonathan");
        props.setProperty(Context.SECURITY_CREDENTIALS, "secret");

        InitialContext ctx = new InitialContext(props);

        Project foo = (Project) ctx.lookup("FooBeanLocal");

        foo.svnCheckout("");
        foo.svnCommit("");

        try {
            foo.deleteProject("");
            fail("Should not be allowed");
        } catch (Exception e) {
            // good.
        }

        assertTrue("not in role committer", foo.isCallerInRole("committer"));
        assertTrue("not in role community", foo.isCallerInRole("community"));
        assertFalse("in role contributor", foo.isCallerInRole("contributor"));
       
        ctx.close();
        assembler.destroy();
       
//        Project bar = (Project) ctx.lookup("BarBeanLocal");
//
//        bar.svnCheckout("");
//
View Full Code Here

//        assertTrue("not in role contributor", bar.isCallerInRole("contributor"));
    }
   
    // When no credentials are provided, the default user/role should be "guest"
    public void testUnauthenticatedUser() throws Exception {
        Assembler assembler = configureAssembler(null);

        // no credentials provided, the default user should be "guest"
        Properties props = new Properties();

        InitialContext ctx = new InitialContext(props);

        Project foo = (Project) ctx.lookup("FooBeanLocal");

        foo.svnCheckout("");
        try {
            foo.svnCommit("");
            fail("Should not be allowed");
        } catch (Exception e) {
            // good.
        }

        assertFalse("in role committer", foo.isCallerInRole("committer"));
        assertFalse("in role community", foo.isCallerInRole("community"));
        assertFalse("in role contributor", foo.isCallerInRole("contributor"));
        assertTrue("not in role guest", foo.isCallerInRole("guest"));
       
        ctx.close();
        assembler.destroy();
    }
View Full Code Here

        assembler.destroy();
    }
   
    // Just to be sure we can override the default user (ie. guest)
    public void testDefaultUser() throws Exception {
        Assembler assembler = configureAssembler("public");

        // no credentials provided, the default user should be "guest"
        Properties props = new Properties();

        InitialContext ctx = new InitialContext(props);

        Project foo = (Project) ctx.lookup("FooBeanLocal");

        foo.svnCheckout("");
        try {
            foo.svnCommit("");
            fail("Should not be allowed");
        } catch (Exception e) {
            // good.
        }

        assertFalse("in role committer", foo.isCallerInRole("committer"));
        assertFalse("in role community", foo.isCallerInRole("community"));
        assertFalse("in role contributor", foo.isCallerInRole("contributor"));
        assertFalse("in role guest", foo.isCallerInRole("guest"));
        assertTrue("not in role public", foo.isCallerInRole("public"));
       
        ctx.close();
        assembler.destroy();
    }
View Full Code Here

    public void test() throws Exception {
        System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());

        ConfigurationFactory config = new ConfigurationFactory();
        Assembler assembler = new Assembler();

        assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));

        // containers
        assembler.createContainer(config.configureService(StatefulSessionContainerInfo.class));

        EjbJarInfo ejbJar = config.configureApplication(buildTestApp());
        assertNotNull(ejbJar);
        assertEquals(1, ejbJar.enterpriseBeans.size());
        assertEquals(1, ejbJar.enterpriseBeans.get(0).aroundInvoke.size());
        assertEquals(1, ejbJar.enterpriseBeans.get(0).postConstruct.size());

        assertEquals(3, ejbJar.interceptors.size());
        assertEquals(1, ejbJar.interceptors.get(0).aroundInvoke.size());
        assertEquals(1, ejbJar.interceptors.get(0).postConstruct.size());

        assertEquals(3, ejbJar.interceptorBindings.size());

        assembler.createApplication(ejbJar);

        InitialContext ctx = new InitialContext();
        Target target = (Target) ctx.lookup("TargetBeanLocal");
        target.echo(new ArrayList());
View Full Code Here

                    logger.warning("configureApplication.loadFailed", e, appModule.getModuleId(), e.getMessage());

                    throw new ConfigureApplicationException(e);
                }

                final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);

                final AppContext appContext;

                try {
                    appContext = assembler.createApplication(appInfo, appModule.getClassLoader());
                } catch (ValidationException ve) {
                    throw ve;
                } catch (Exception e) {
                    throw new AssembleApplicationException(e);
                }
View Full Code Here

                    final ConfigurationFactory configurationFactory = new ConfigurationFactory();
                    final AppInfo appInfo = configurationFactory.configureApplication(appModule);
                    appInfo.appId = "bundle_" + bundle.getBundleId();

                    final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
                    final AppContext appContext = assembler.createApplication(appInfo, osgiCl);
                    LOGGER.info("Application deployed: " + appInfo.path);

                    paths.put(bundle, appInfo.path);

                    registrations.put(bundle, new ArrayList<ServiceRegistration>());
View Full Code Here

            registrations.remove(bundle);
        }

        if (paths.containsKey(bundle)) {
            try {
                final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
                if (assembler != null) { // openejb stopped before bundles when shuttind down the OSGi container
                    assembler.destroyApplication(paths.remove(bundle));
                }
            } catch (IllegalStateException ise) {
                LOGGER.error("Can't undeploy bundle #{0}", bundle.getBundleId());
            } catch (UndeployException e) {
                LOGGER.error("Can't undeploy bundle #{0}", bundle.getBundleId(), e);
View Full Code Here

TOP

Related Classes of org.apache.openejb.assembler.classic.Assembler

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.