Package org.apache.hivemind.definition.impl

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


     * @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) {
                    ShutdownCoordinator coordinator = (ShutdownCoordinator) context.getService(ShutdownCoordinator.class);
                    result = new SimpleImpl(coordinator);
                } else {
                    result = new SimpleImpl();
                }
                return result;
            }
        };
       
        helper.addServiceImplementation(sp1, constructor, serviceModel);

        return buildFrameworkRegistry(module);
    }
View Full Code Here


     * 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);

        return buildFrameworkRegistry(module);
    }
View Full Code Here

        ModuleDefinitionImpl moduleDefinition = (ModuleDefinitionImpl) registryDefinition.getModule("hivemind");
        if (moduleDefinition == null) {
            throw new ApplicationRuntimeException("Module 'hivemind' not found.");
        }
       
        helper = new ModuleDefinitionHelper(moduleDefinition);
       
        addTranslatorManager(moduleDefinition, errorHandler);
       
        addSymbolSourcesConfiguration(moduleDefinition);
       
View Full Code Here

     */
    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)
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
                context.getService("hivemind.test.services.Recursive", SimpleService.class);
                return result;
            }
        };

        helper.addServiceImplementation(sp, constructor, ServiceModel.PRIMITIVE);
       
        return buildFrameworkRegistry(module);
    }
View Full Code Here

     * 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);

        // Add service point "StartupRunnableFixture" to Startup configuration point
        helper.addContributionDefinition("hivemind.Startup", new Contribution()
        {
            public void contribute(ContributionContext context)
            {
                List contribution = new ArrayList();
                contribution.add(context.getService(StartupRunnableFixture.class));
View Full Code Here

     * @param implementationClass  implementation class of the service
     */
    private Registry createRegistryShutdownListener(Class implementationClass)
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.test.services");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);

        ServicePointDefinition sp1 = helper.addServicePoint("StringHolder", StringHolder.class.getName());
        helper.addSimpleServiceImplementation(sp1, implementationClass.getName(), ServiceModel.THREADED);

        return buildFrameworkRegistry(module);
   
View Full Code Here

                    resolver, null);
            registryDefinition.addModule(md);
        }

        // The cast to ModuleDefinitionImpl is save, since we exactly now the origin
        helper = new ModuleDefinitionHelper((ModuleDefinitionImpl) md);
       
        addClassFactory(md);

        addThreadEventNotifier(md);
View Full Code Here

{
    public SimpleModule()
    {
        super("hivemind.test.services", createLocation(), new DefaultClassResolver(), null);
       
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(this);
        ServicePointDefinition sp = helper.addServicePoint("Simple", SimpleService.class.getName());
        helper.addSimpleServiceImplementation(sp, SimpleServiceImpl.class.getName(), ServiceModel.SINGLETON);
    }
View Full Code Here

     * configuration.
     */
    private Registry createEagerLoadModule(final String serviceModel)
    {
        ModuleDefinitionImpl module = createModuleDefinition("hivemind.test.services");
        ModuleDefinitionHelper helper = new ModuleDefinitionHelper(module);

        ServicePointDefinition sp1 = helper.addServicePoint("Loud", Runnable.class.getName());
        helper.addSimpleServiceImplementation(sp1, LoudRunner.class.getName(), serviceModel);

        // Add service point "Loud" to EagerLoad configuration point
        helper.addContributionDefinition("hivemind.EagerLoad", new Contribution()
        {
            public void contribute(ContributionContext context)
            {
                List contribution = new ArrayList();
                contribution.add(context.getDefiningModule().getServicePoint("hivemind.test.services.Loud"));
View Full Code Here

TOP

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

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.