Package org.openengsb.core.api

Examples of org.openengsb.core.api.ConnectorInstanceFactory


            Domain.class);

        DomainProvider authDomainProvider = createDomainProviderMock(AuthorizationDomain.class, "authorization");
        CompositeConnectorProvider compositeConnectorProvider = new CompositeConnectorProvider();
        compositeConnectorProvider.setBundleContext(bundleContext);
        ConnectorInstanceFactory cFactory = compositeConnectorProvider.createFactory(authDomainProvider);
        Connector instance = cFactory.createNewInstance("auth-admin");
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put("composite.strategy.name", "authorization");
        AffirmativeBasedAuthorizationStrategy service = new AffirmativeBasedAuthorizationStrategy();
        service.setUtilsService(serviceUtils);
        registerService(service, props, CompositeConnectorStrategy.class);

        instance = cFactory.applyAttributes(instance,
            ImmutableMap.of("compositeStrategy", "authorization", "queryString", "(location.root=authorization/*)"));
        registerServiceAtLocation(instance, "authorization-root", "root", AuthorizationDomain.class, Domain.class);
        context.putBean("authorizer", instance);

        OpenEngSBShiroAuthenticator openEngSBShiroAuthenticator = new OpenEngSBShiroAuthenticator();
View Full Code Here


    private void createProviderMocks() {
        createDomainProviderMock(TestDomainInterface.class, "testdomain");
        createDomainProviderMock(AnotherTestDomainInterface.class, "anotherTestDomain");
        createConnectorProviderMock("testconnector", "testdomain");
        ConnectorInstanceFactory factory = mock(ConnectorInstanceFactory.class);
        when(factory.createNewInstance(anyString())).thenAnswer(new Answer<Connector>() {
            @Override
            public Connector answer(InvocationOnMock invocation) throws Throwable {
                TestDomainInterface newMock = mock(TestDomainInterface.class);
                when(newMock.getInstanceId()).thenReturn((String) invocation.getArguments()[0]);
                return newMock;
            }
        });
        when(factory.applyAttributes(any(Connector.class), anyMap())).thenAnswer(new Answer<Connector>() {
            @Override
            public Connector answer(InvocationOnMock invocation) throws Throwable {
                return (Connector) invocation.getArguments()[0];
            }
        });
View Full Code Here

    private void createProviderMocks() {
        createDomainProviderMock(TestInterface.class, "testdomain");
        createDomainProviderMock(AnotherTestInterface.class, "anotherTestDomain");
        createConnectorProviderMock("testconnector", "testdomain");
        ConnectorInstanceFactory factory = mock(ConnectorInstanceFactory.class);
        when(factory.createNewInstance(anyString())).thenAnswer(new Answer<Connector>() {
            @Override
            public Connector answer(InvocationOnMock invocation) throws Throwable {
                TestInterface newMock = mock(TestInterface.class);
                testService = newMock;
                when(newMock.getInstanceId()).thenReturn((String) invocation.getArguments()[0]);
                return newMock;
            }
        });
        when(factory.applyAttributes(any(Connector.class), anyMap())).thenAnswer(new Answer<Connector>() {
            @Override
            public Connector answer(InvocationOnMock invocation) throws Throwable {
                return (Connector) invocation.getArguments()[0];
            }
        });
View Full Code Here

     * Also the factory is registered as a service with the required properties
     */
    protected ConnectorInstanceFactory createFactoryMock(String connector,
            final Class<? extends Connector> connectorClass,
            String... domains) throws Exception {
        ConnectorInstanceFactory factory = mock(ConnectorInstanceFactory.class);
        when(factory.createNewInstance(anyString())).thenAnswer(new Answer<Connector>() {
            @Override
            public Connector answer(InvocationOnMock invocation) throws Throwable {
                Connector result = mock(connectorClass);
                String id = (String) invocation.getArguments()[0];
                when(result.getInstanceId()).thenReturn(id);
                return result;
            }
        });
        when(factory.applyAttributes(any(Connector.class), anyMap())).thenAnswer(new Answer<Connector>() {
            @Override
            public Connector answer(InvocationOnMock invocation) throws Throwable {
                return (Connector) invocation.getArguments()[0];
            }
        });
View Full Code Here

        }
    }

    protected ServiceRegistration registerConnectorFactoryService(VirtualConnectorProvider virtualConnectorProvider,
            DomainProvider p) {
        ConnectorInstanceFactory factory = virtualConnectorProvider.createFactory(p);
        Dictionary<String, Object> properties = new Hashtable<String, Object>();
        properties.put(org.openengsb.core.api.Constants.DOMAIN_KEY, p.getId());
        properties.put(org.openengsb.core.api.Constants.CONNECTOR_KEY, virtualConnectorProvider.getId());
        return bundleContext.registerService(ConnectorInstanceFactory.class.getName(), factory, properties);
    }
View Full Code Here

        attributes.put("queryString", "(location.foo=authorization/*)");

        DomainProvider provider = createDomainProviderMock(AuthorizationDomain.class, "accessControl");
        CompositeConnectorProvider compositeConnectorProvider = new CompositeConnectorProvider();
        compositeConnectorProvider.setBundleContext(bundleContext);
        ConnectorInstanceFactory factory = compositeConnectorProvider.createFactory(provider);
        accessControl = (AuthorizationDomain) factory.createNewInstance("authProvider");

        factory.applyAttributes((Connector) accessControl, attributes);

        SecurityInterceptor interceptor = new SecurityInterceptor();
        interceptor.setAuthorizer(accessControl);
    }
View Full Code Here

        instances.remove(id);
    }

    private void createService(String id, ConnectorDescription description)
        throws ConnectorValidationFailedException {
        ConnectorInstanceFactory factory = getConnectorFactoryForDescription(description);
        Map<String, String> errors = factory.getValidationErrors(description.getAttributes());
        if (!errors.isEmpty()) {
            throw new ConnectorValidationFailedException(errors);
        }
        finishCreatingInstance(id, description, factory);
    }
View Full Code Here

        }
        finishCreatingInstance(id, description, factory);
    }

    private void forceCreateService(String id, ConnectorDescription description) {
        ConnectorInstanceFactory factory = getConnectorFactoryForDescription(description);
        finishCreatingInstance(id, description, factory);
    }
View Full Code Here

        result.put(org.osgi.framework.Constants.SERVICE_PID, id);
        return result;
    }

    private void forceUpdateAttributes(String id, ConnectorDescription description) {
        ConnectorInstanceFactory factory = getConnectorFactoryForDescription(description);
        Connector current = instances.get(id);
        doUpdateAttributes(id, description, factory, current);
    }
View Full Code Here

        doUpdateAttributes(id, description, factory, current);
    }

    private void updateAttributes(String id, ConnectorDescription description)
        throws ConnectorValidationFailedException {
        ConnectorInstanceFactory factory = getConnectorFactoryForDescription(description);
        Connector current = instances.get(id);
        Map<String, String> validationErrors = factory.getValidationErrors(current, description.getAttributes());
        if (!validationErrors.isEmpty()) {
            throw new ConnectorValidationFailedException(validationErrors);
        }
        doUpdateAttributes(id, description, factory, current);
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.ConnectorInstanceFactory

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.