Search in sources :

Example 71 with DeploymentDescriptor

use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.

the class JaxbMarshalingTest method testJaxbDeploymentDescriptorSerialization.

@Test
public void testJaxbDeploymentDescriptorSerialization() throws Exception {
    DeploymentDescriptor descriptor = new DeploymentDescriptorImpl();
    descriptor.getBuilder().addTaskEventListener(new ObjectModel("org.jbpm.task.Listener", new Object[] { "test", "another" }));
    String output = convertJaxbObjectToString(descriptor);
    logger.debug(output);
    assertNotNull(output);
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) Test(org.junit.Test)

Example 72 with DeploymentDescriptor

use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.

the class DeploymentDescriptorIO method fromXml.

/**
 * Reads XML data from given input stream and produces valid instance of
 * <code>DeploymentDescriptor</code>
 * @param inputStream input stream that comes with xml data of the descriptor
 * @return instance of the descriptor after deserialization
 */
public static DeploymentDescriptor fromXml(InputStream inputStream) {
    try {
        Unmarshaller unmarshaller = getContext().createUnmarshaller();
        unmarshaller.setSchema(schema);
        DeploymentDescriptor descriptor = (DeploymentDescriptor) unmarshaller.unmarshal(inputStream);
        return descriptor;
    } catch (Exception e) {
        throw new RuntimeException("Unable to read deployment descriptor from xml", e);
    }
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) Unmarshaller(javax.xml.bind.Unmarshaller) SAXException(org.xml.sax.SAXException) JAXBException(javax.xml.bind.JAXBException)

Example 73 with DeploymentDescriptor

use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.

the class DeploymentDescriptorManager method getDeploymentDescriptorHierarchy.

public List<DeploymentDescriptor> getDeploymentDescriptorHierarchy(KieContainer kieContainer) {
    List<DeploymentDescriptor> descriptorHierarchy = new ArrayList<DeploymentDescriptor>();
    InternalKieModule module = ((KieModuleKieProject) ((KieContainerImpl) kieContainer).getKieProject()).getInternalKieModule();
    collectDeploymentDescriptors(module, descriptorHierarchy);
    // last is the default descriptor
    descriptorHierarchy.add(getDefaultDescriptor());
    return descriptorHierarchy;
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) ArrayList(java.util.ArrayList) KieModuleKieProject(org.drools.compiler.kie.builder.impl.KieModuleKieProject) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule)

Example 74 with DeploymentDescriptor

use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.

the class DeploymentDescriptorManager method getDefaultDescriptor.

public DeploymentDescriptor getDefaultDescriptor() {
    DeploymentDescriptor defaultDesc = null;
    URL defaultDescriptorLocation = getDefaultdescriptorlocation();
    if (defaultDescriptorLocation != null) {
        try {
            logger.debug("Reading default descriptor from " + defaultDescriptorLocation);
            defaultDesc = DeploymentDescriptorIO.fromXml(defaultDescriptorLocation.openStream());
        } catch (IOException e) {
            throw new RuntimeException("Unable to read default deployment descriptor from " + defaultDescriptorLocation, e);
        }
    } else {
        logger.debug("No descriptor found returning default instance");
        defaultDesc = new DeploymentDescriptorImpl(defaultPU);
    }
    return defaultDesc;
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) IOException(java.io.IOException) URL(java.net.URL)

Example 75 with DeploymentDescriptor

use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.

the class DeploymentDescriptorManager method getDescriptorFromKModule.

protected DeploymentDescriptor getDescriptorFromKModule(InternalKieModule kmodule) {
    DeploymentDescriptor desc = null;
    if (kmodule.isAvailable(DeploymentDescriptor.META_INF_LOCATION)) {
        byte[] content = kmodule.getBytes(DeploymentDescriptor.META_INF_LOCATION);
        ByteArrayInputStream input = new ByteArrayInputStream(content);
        try {
            desc = DeploymentDescriptorIO.fromXml(input);
        } finally {
            try {
                input.close();
            } catch (IOException e) {
                logger.debug("Error when closing stream of kie-deployment-descriptor.xml");
            }
        }
    }
    return desc;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) IOException(java.io.IOException)

Aggregations

DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)78 Test (org.junit.Test)39 NamedObjectModel (org.kie.internal.runtime.conf.NamedObjectModel)30 HashMap (java.util.HashMap)27 DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)26 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)23 ObjectModel (org.kie.internal.runtime.conf.ObjectModel)23 KieServices (org.kie.api.KieServices)22 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)21 ReleaseId (org.kie.api.builder.ReleaseId)21 ArrayList (java.util.ArrayList)18 File (java.io.File)13 KieMavenRepository (org.kie.scanner.KieMavenRepository)12 FileOutputStream (java.io.FileOutputStream)11 KieMavenRepository.getKieMavenRepository (org.kie.scanner.KieMavenRepository.getKieMavenRepository)11 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)9 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)8 DeploymentDescriptorManager (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorManager)6