Examples of ContextFactory


Examples of org.apache.hadoop.metrics.ContextFactory

    setupMetricsContext();
    return new ThriftMetrics(ThriftServerRunner.DEFAULT_LISTEN_PORT, conf, Hbase.Iface.class);
  }

  private static void setupMetricsContext() throws IOException {
    ContextFactory factory = ContextFactory.getFactory();
    factory.setAttribute(ThriftMetrics.CONTEXT_NAME + ".class",
        NoEmitMetricsContext.class.getName());
    MetricsUtil.getContext(ThriftMetrics.CONTEXT_NAME)
               .createRecord(ThriftMetrics.CONTEXT_NAME).remove();
  }
View Full Code Here

Examples of org.apache.tuscany.core.builder.ContextFactory

        Map<String, Component> compMap = new HashMap<String, Component>(components.size());

        for (Component component : components) {
            compMap.put(component.getName(), component);
            builder.build(component);
            ContextFactory contextFactory = (ContextFactory) component.getContextFactory();
            Assert.assertNotNull(contextFactory);
        }
        for (Component component : components) {
            ContextFactory<Context> source = (ContextFactory<Context>) component.getContextFactory();
            Assert.assertNotNull(source);
            for (SourceWireFactory pFactory : source.getSourceWireFactories()) {
                WireConfiguration pConfig = pFactory.getConfiguration();
                Component target = compMap.get(pConfig.getTargetName().getPartName());

                if (target != null) {
                    ContextFactory targetConfig = (ContextFactory) target.getContextFactory();
                    boolean downScope = strategy.downScopeReference(source.getScope(), targetConfig.getScope());
                    wireBuilder.connect(pFactory, targetConfig.getTargetWireFactory(pFactory.getConfiguration().getTargetName()
                            .getPortName()), targetConfig.getClass(), downScope, scopeContext);
                }
                pFactory.initialize();
            }
            scopeContext.registerFactory(source);
        }
        for (Component component : components) {
            ContextFactory config = (ContextFactory) component.getContextFactory();
            Context context = config.createContext();
            if ("source".equals(component.getName())) {
                ModuleScopeComponent source = (ModuleScopeComponent) context.getInstance(null);
                Assert.assertNotNull(source);
                GenericComponent gComp = source.getGenericComponent();
                gComp.getString();
View Full Code Here

Examples of org.apache.tuscany.core.builder.ContextFactory

            }
            if (scope != null && current != Scope.INSTANCE) {
                scope = current;
            }
        }
        ContextFactory contextFactory;
        try {
            contextFactory = createContextFactory(component.getName(), component.getImplementation(), scope);
            // create target-side wire invocation chains for each service offered by the implementation
            for (ConfiguredService configuredService : component.getConfiguredServices()) {
                Service service = configuredService.getPort();
                TargetWireFactory wireFactory = wireFactoryService.createTargetFactory(configuredService);
                contextFactory.addTargetWireFactory(service.getName(), wireFactory);
            }
            // handle properties
            List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
            if (configuredProperties != null) {
                for (ConfiguredProperty property : configuredProperties) {
                    contextFactory.addProperty(property.getName(), property.getValue());
                }
            }
            // handle references and source side reference chains
            List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
            if (configuredReferences != null) {
                for (ConfiguredReference reference : configuredReferences) {
                    if (reference.getPort().getMultiplicity() == Multiplicity.ZERO_N || reference.getPort().getMultiplicity() == Multiplicity.ZERO_ONE){
                        if (reference.getTargetConfiguredServices().size() < 1 && reference.getTargets().size() <1 ){
                            continue; // not required, not configured fix TUSCANY-299
                        }
                    }
                    List<SourceWireFactory> wireFactories = wireFactoryService.createSourceFactory(reference);
                    String refName = reference.getPort().getName();
                    Class refClass = reference.getPort().getServiceContract().getInterface();
                    boolean multiplicity = reference.getPort().getMultiplicity() == Multiplicity.ONE_N
                            || reference.getPort().getMultiplicity() == Multiplicity.ZERO_N;
                    contextFactory.addSourceWireFactories(refName, refClass, wireFactories, multiplicity);
                }
            }
            component.setContextFactory(contextFactory);
        } catch (BuilderException e) {
            e.addContextName(component.getName());
View Full Code Here

Examples of org.apache.webbeans.context.ContextFactory

* @version $Rev$ $Date$
*/
public class ContextsImpl implements org.jboss.jsr299.tck.spi.Contexts<AbstractContext> {

    public AbstractContext getRequestContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        RequestContext ctx = (RequestContext) contextFactory.getStandardContext(RequestScoped.class);

        if (ctx == null) {
            contextFactory.initRequestContext(null);
        }

        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.REQUEST);
    }
View Full Code Here

Examples of org.apache.webbeans.context.ContextFactory

    public void setInactive(AbstractContext context) {
        context.setActive(false);
    }

    public AbstractContext getDependentContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.DEPENDENT);
    }
View Full Code Here

Examples of org.apache.webbeans.context.ContextFactory

* @version $Rev$ $Date$
*/
public class ContextsImpl implements org.jboss.jsr299.tck.spi.Contexts<AbstractContext> {

    public AbstractContext getRequestContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        RequestContext ctx = (RequestContext) contextFactory.getStandardContext(RequestScoped.class);

        if (ctx == null) {
            contextFactory.initRequestContext(null);
        }

        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.REQUEST);
    }
View Full Code Here

Examples of org.apache.webbeans.context.ContextFactory

    public void setInactive(AbstractContext context) {
        context.setActive(false);
    }

    public AbstractContext getDependentContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.DEPENDENT);
    }
View Full Code Here

Examples of org.apache.webbeans.context.ContextFactory

* @version $Rev$ $Date$
*/
public class ContextsImpl implements org.jboss.jsr299.tck.spi.Contexts<AbstractContext> {

    public AbstractContext getRequestContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        RequestContext ctx = (RequestContext) contextFactory.getStandardContext(RequestScoped.class);

        if (ctx == null) {
            contextFactory.initRequestContext(null);
        }

        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.REQUEST);
    }
View Full Code Here

Examples of org.apache.webbeans.context.ContextFactory

    public void setInactive(AbstractContext context) {
        context.setActive(false);
    }

    public AbstractContext getDependentContext() {
        ContextFactory contextFactory = WebBeansContext.currentInstance().getContextFactory();
        return (AbstractContext) contextFactory.getStandardContext(ContextTypes.DEPENDENT);
    }
View Full Code Here

Examples of org.apache.webbeans.context.ContextFactory

        defineManagedBean(Producer1.class);
        defineManagedBean(Producer1ConsumerComponent.class);

        List<AbstractOwbBean<?>> comps = getComponents();

        ContextFactory contextFactory = WebBeansContext.getInstance().getContextFactory();
        contextFactory.initRequestContext(null);
        contextFactory.initApplicationContext(null);

        Assert.assertEquals(4, getDeployedComponents());

        Object obj = getManager().getInstance(comps.get(0));
       
        Assert.assertNotNull(obj);

        getInstanceByName("service");

        getManager().getInstance(comps.get(1));

        Object object = getManager().getInstance(comps.get(2));

        Assert.assertTrue(object instanceof Producer1ConsumerComponent);

        Producer1ConsumerComponent single = (Producer1ConsumerComponent) object;

        IService service = single.getService();

        Assert.assertNotNull(service);

        contextFactory.destroyApplicationContext(null);
        contextFactory.destroyRequestContext(null);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.