Package org.apache.hivemind.definition.impl

Examples of org.apache.hivemind.definition.impl.ModuleDefinitionImpl


     * separate implementation class.
     * @param manual  If true, the service is manually added to the {@link ShutdownCoordinator}
     */
    private Registry createRegistryWithSimpleService(final String serviceModel, final boolean manual)
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.lib.test");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);

        ServicePointDefinition sp1 = helper.addServicePoint("Simple", Simple.class.getName());

        // Define inline implementation constructor, that passes the ShutdownCoordinator service if manual is true
        ImplementationConstructor constructor = new AbstractServiceImplementationConstructor(module.getLocation())
        {
            public Object constructCoreServiceImplementation(ImplementationConstructionContext context)
            {
                Object result;
                if (manual) {
View Full Code Here


     * Creates a registry with one module, that defines a Service "RegistryShutdownBean" which
     * is a pojo
     */
    private Registry createRegistryWithPojo(final String serviceModel)
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.lib.test");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);

        ServicePointDefinition sp1 = helper.addServicePoint("RegistryShutdownBean", RegistryShutdownBean.class.getName());
        helper.addSimpleServiceImplementation(sp1, RegistryShutdownBean.class.getName(), serviceModel);

View Full Code Here

        }
       
        // The "hivemind" module is available here only if the HivemoduleProvider
        // has been executed before. This order is defined in the MANIFEST.MF file of the xml module
        // The cast is safe since the module is defined in the core.
        ModuleDefinitionImpl moduleDefinition = (ModuleDefinitionImpl) registryDefinition.getModule("hivemind");
        if (moduleDefinition == null) {
            throw new ApplicationRuntimeException("Module 'hivemind' not found.");
        }
       
        helper = new ModuleDefinitionHelper(moduleDefinition);
View Full Code Here

public class TestDependency extends FrameworkTestCase
{

    public void testMissingRequiredModule() throws Exception
    {
        ModuleDefinitionImpl dependingModule = createModuleDefinition(
                "dependency.declaring.module");

        dependingModule.addDependency("required.module");

        interceptLogging();

        buildFrameworkRegistry(new ModuleDefinition[] {dependingModule});
View Full Code Here

        assertLoggedMessage("Required module required.module does not exist.");
    }

    public void testDependency() throws Exception
    {
        ModuleDefinitionImpl dependingModule = createModuleDefinition(
                "dependency.declaring.module");

        ModuleDefinition requiredModule = createModuleDefinition("required.module");
       
        dependingModule.addDependency(requiredModule.getId());

        buildFrameworkRegistry(new ModuleDefinition[] {dependingModule, requiredModule});
    }
View Full Code Here

    {
        DefaultErrorHandler errorHandler = new DefaultErrorHandler();

      RegistryDefinition definition = new RegistryDefinitionImpl();
     
        ModuleDefinitionImpl fooBar = createModuleDefinition("foo.bar");

        ServicePointDefinitionImpl spd = createServicePointDefinition(fooBar, "sp1", Runnable.class);

        fooBar.addServicePoint(spd);

        ModuleDefinitionImpl zipZoop = createModuleDefinition("zip.zoop");

        ConfigurationPointDefinition cpd = createConfigurationPointDefinition(fooBar, "cp1");
       
        zipZoop.addConfigurationPoint(cpd);
       
        definition.addModule(fooBar);
        definition.addModule(zipZoop);

        RegistryInfrastructureConstructor ric = new RegistryInfrastructureConstructor(errorHandler,
View Full Code Here

     */
    private Registry createRegistry(ImplementationConstructor constructor)
    {
        RegistryDefinition definition = new RegistryDefinitionImpl();

        ModuleDefinitionImpl module = createModuleDefinition("hivemind.tests.serviceByInterface");
        definition.addModule(module);
       
        ServicePointDefinitionImpl sp1 = createServicePointDefinition(module, "BeanInterface", BeanInterface.class);
        ImplementationDefinition impl = new ImplementationDefinitionImpl(module, newLocation(),
                constructor, ServiceModel.SINGLETON, true);
        sp1.addImplementation(impl);
        module.addServicePoint(sp1);
        Registry reg = buildFrameworkRegistry(module);
        return reg;
    }
View Full Code Here

     * Builds a registry that contains a single service that is intercepted by logging interceptor.
     */
    private Registry createRegistryWithInterceptedService(String serviceName, String serviceInterface, String implementationClass,
            final List interceptedMethods)
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.test.services");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);
        ServicePointDefinition sp = helper.addServicePoint(serviceName, serviceInterface);
        helper.addSimpleServiceImplementation(sp, implementationClass, ServiceModel.SINGLETON);
       
        // Add logging interceptor
        InterceptorConstructor constructor = new AbstractServiceInterceptorConstructor(module.getLocation()) {

            public void constructServiceInterceptor(InterceptorStack interceptorStack, Module contributingModule)
            {
                ClassFactory cf = (ClassFactory) contributingModule.getService(ClassFactory.class);
                // Create the interceptor with the LoggingInterceptorClassFactory which is quite uncomfortable
                // in the moment
                LoggingInterceptorClassFactory f = new LoggingInterceptorClassFactory(cf);
                Class interceptorClass = f.constructInterceptorClass(interceptorStack, Collections.EMPTY_LIST);
                Constructor c = interceptorClass.getConstructors()[0];
                Object interceptor;
                try
                {
                    interceptor = c.newInstance(new Object[] { interceptorStack.getServiceLog(), interceptorStack.peek() });
                }
                catch (Exception e) {
                    throw new ApplicationRuntimeException(e);
                }
                interceptorStack.push(interceptor);
            }};
        InterceptorDefinition interceptor = new InterceptorDefinitionImpl(module, "hivemind.LoggingInterceptor", module.getLocation(), constructor);
        sp.addInterceptor(interceptor);
        return buildFrameworkRegistry(module);
    }
View Full Code Here

    /**
     * Builds a registry that contains a single service that references itself during construction
     */
    private Registry createRegistryWithRecursiveService()
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.test.services");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);
        ServicePointDefinition sp = helper.addServicePoint("Recursive", SimpleService.class.getName());

        ImplementationConstructor constructor = new AbstractServiceImplementationConstructor(module.getLocation())
        {
            public Object constructCoreServiceImplementation(ImplementationConstructionContext context)
            {
                Object result = new SimpleServiceImpl();
                // Here is the recursion
View Full Code Here

     * Creates a Registry with one module, that defines a Service "Loud" added to the EagerLoad
     * configuration.
     */
    private Registry createRegistry()
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.test.services");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);

        ServicePointDefinition sp1 = helper.addServicePoint("StartupRunnableFixture", StartupRunnableFixture.class.getName());
        helper.addSimpleServiceImplementation(sp1, StartupRunnableFixtureImpl.class.getName(), ServiceModel.SINGLETON);

View Full Code Here

TOP

Related Classes of org.apache.hivemind.definition.impl.ModuleDefinitionImpl

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.