Search in sources :

Example 1 with BundleInstantiationSpecification

use of com.yahoo.container.bundle.BundleInstantiationSpecification in project vespa by vespa-engine.

the class ContainerCluster method addMbusServer.

public void addMbusServer(ComponentId chainId) {
    ComponentId serviceId = chainId.nestInNamespace(ComponentId.fromString("MbusServer"));
    addComponent(new Component<>(new ComponentModel(new BundleInstantiationSpecification(serviceId, ComponentSpecification.fromString(MbusServerProvider.class.getName()), null))));
}
Also used : MbusServerProvider(com.yahoo.container.jdisc.messagebus.MbusServerProvider) ComponentModel(com.yahoo.osgi.provider.model.ComponentModel) BundleInstantiationSpecification(com.yahoo.container.bundle.BundleInstantiationSpecification) ComponentId(com.yahoo.component.ComponentId)

Example 2 with BundleInstantiationSpecification

use of com.yahoo.container.bundle.BundleInstantiationSpecification in project vespa by vespa-engine.

the class BundleInstantiationSpecificationBuilder method build.

public static BundleInstantiationSpecification build(Element spec, boolean legacyMode) {
    ComponentSpecification id = XmlHelper.getIdRef(spec);
    ComponentSpecification classId = getComponentSpecification(spec, "class");
    ComponentSpecification bundle = getComponentSpecification(spec, "bundle");
    BundleInstantiationSpecification instSpec = new BundleInstantiationSpecification(id, classId, bundle);
    if (// TODO: Remove?
    !legacyMode)
        validate(instSpec);
    return bundle == null ? setBundleForKnownClass(instSpec) : instSpec;
}
Also used : ComponentSpecification(com.yahoo.component.ComponentSpecification) BundleInstantiationSpecification(com.yahoo.container.bundle.BundleInstantiationSpecification)

Example 3 with BundleInstantiationSpecification

use of com.yahoo.container.bundle.BundleInstantiationSpecification in project vespa by vespa-engine.

the class JettyContainerModelBuilderTest method assertComponentHasClassNameAndBundle.

private static void assertComponentHasClassNameAndBundle(SimpleComponent simpleComponent, String className, String bundleName) {
    BundleInstantiationSpecification spec = simpleComponent.model.bundleInstantiationSpec;
    assertThat(spec.classId.toString(), is(className));
    assertThat(spec.bundle.toString(), is(bundleName));
}
Also used : BundleInstantiationSpecification(com.yahoo.container.bundle.BundleInstantiationSpecification)

Example 4 with BundleInstantiationSpecification

use of com.yahoo.container.bundle.BundleInstantiationSpecification in project vespa by vespa-engine.

the class DomComponentBuilderTest method ensureCorrectModel.

@Test
public void ensureCorrectModel() {
    Component<?, ?> handler = new DomComponentBuilder().doBuild(root, parse("<handler id='theId' class='theClass' bundle='theBundle' />"));
    BundleInstantiationSpecification instantiationSpecification = handler.model.bundleInstantiationSpec;
    assertThat(instantiationSpecification.id.stringValue(), is("theId"));
    assertThat(instantiationSpecification.classId.stringValue(), is("theClass"));
    assertThat(instantiationSpecification.bundle.stringValue(), is("theBundle"));
}
Also used : BundleInstantiationSpecification(com.yahoo.container.bundle.BundleInstantiationSpecification) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 5 with BundleInstantiationSpecification

use of com.yahoo.container.bundle.BundleInstantiationSpecification in project vespa by vespa-engine.

the class ContainerTestBase method complete.

public void complete() {
    try {
        Container container = new Container(new CloudSubscriberFactory(dirConfigSource().configSource()), dirConfigSource().configId(), new ContainerTest.TestDeconstructor(), new Osgi() {

            @SuppressWarnings("unchecked")
            @Override
            public Class<Object> resolveClass(BundleInstantiationSpecification spec) {
                try {
                    return (Class<Object>) Class.forName(spec.classId.getName());
                } catch (ClassNotFoundException e) {
                    throw new RuntimeException(e);
                }
            }

            @Override
            public BundleClasses getBundleClasses(ComponentSpecification bundle, Set<String> packagesToScan) {
                throw new UnsupportedOperationException("getBundleClasses not supported");
            }

            @Override
            public void useBundles(Collection<FileReference> bundles) {
            }

            @Override
            public Bundle getBundle(ComponentSpecification spec) {
                throw new UnsupportedOperationException("getBundle not supported.");
            }
        });
        componentGraph = container.runOnce(componentGraph, Guice.createInjector());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Osgi(com.yahoo.container.di.Osgi) ComponentSpecification(com.yahoo.component.ComponentSpecification) Bundle(org.osgi.framework.Bundle) CloudSubscriberFactory(com.yahoo.container.di.CloudSubscriberFactory) BundleInstantiationSpecification(com.yahoo.container.bundle.BundleInstantiationSpecification) ContainerTest(com.yahoo.container.di.ContainerTest) Container(com.yahoo.container.di.Container) FileReference(com.yahoo.config.FileReference)

Aggregations

BundleInstantiationSpecification (com.yahoo.container.bundle.BundleInstantiationSpecification)6 ComponentSpecification (com.yahoo.component.ComponentSpecification)2 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)2 Test (org.junit.Test)2 ComponentId (com.yahoo.component.ComponentId)1 ChainedComponentModel (com.yahoo.component.chain.model.ChainedComponentModel)1 FileReference (com.yahoo.config.FileReference)1 CloudSubscriberFactory (com.yahoo.container.di.CloudSubscriberFactory)1 Container (com.yahoo.container.di.Container)1 ContainerTest (com.yahoo.container.di.ContainerTest)1 Osgi (com.yahoo.container.di.Osgi)1 MbusServerProvider (com.yahoo.container.jdisc.messagebus.MbusServerProvider)1 ComponentModel (com.yahoo.osgi.provider.model.ComponentModel)1 Bundle (org.osgi.framework.Bundle)1