Examples of Pojoization


Examples of org.apache.felix.ipojo.manipulator.Pojoization

            composite.addMetadataProvider(provider);
        }

        ClassLoader classloader = new BridgeClassLoader(original, m_context);
        // Pojoization
        Pojoization pojoizator = new Pojoization(createModuleProvider());
        try {
            pojoizator.pojoization(store, composite, createVisitor(store, reporter), classloader);
        } catch (Exception e) {
            if (!pojoizator.getErrors().isEmpty()) {
                throw new IOException("Errors occurred during the manipulation : " + pojoizator.getErrors(), e);
            }
            e.printStackTrace();
            throw new IOException("Cannot manipulate the Url: " + url, e);
        }

        if (!pojoizator.getErrors().isEmpty()) {
            throw new IOException("Errors occurred during the manipulation : " + pojoizator.getErrors());
        }
        if (!pojoizator.getWarnings().isEmpty()) {
            logger.log(LOG_WARNING, format("Warnings occurred during the manipulation %s", pojoizator.getWarnings()));
        }

        logger.log(LOG_DEBUG, format("Manipulation done %s", out.exists()));

        // Cleanup
View Full Code Here

Examples of org.apache.felix.ipojo.manipulator.Pojoization

import org.apache.felix.ipojo.manipulator.Pojoization;

public class PojoizationTest extends TestCase {

  public void testJarManipulation() {
    Pojoization pojoization = new Pojoization();
        pojoization.setUseLocalXSD();
    File in = new File("target/test-classes/tests.manipulation-no-annotations.jar");
    File out = new File("target/test-classes/tests.manipulation-no-annotations-manipulated.jar");
    out.delete();
    File metadata = new File("target/test-classes/metadata.xml");
    pojoization.pojoization(in, out, metadata, null);

    Assert.assertTrue(out.exists());
  }
View Full Code Here

Examples of org.apache.felix.ipojo.manipulator.Pojoization

    Assert.assertTrue(out.exists());
  }

  public void testManipulationWithAnnotations() {
    Pojoization pojoization = new Pojoization();
        pojoization.setUseLocalXSD();
    File in = new File("target/test-classes/tests.manipulator-annotations.jar");
    File out = new File("target/test-classes/tests.manipulation-annotations-manipulated.jar");
    out.delete();
    pojoization.pojoization(in, out, (File) null, null);

    Assert.assertTrue(out.exists());
  }
View Full Code Here

Examples of org.apache.felix.ipojo.manipulator.Pojoization

    Assert.assertTrue(out.exists());
  }

  public void testJarManipulationJava5() {
    Pojoization pojoization = new Pojoization();
        pojoization.setUseLocalXSD();
    File in = new File("target/test-classes/tests.manipulation.java5.jar");
    File out = new File("target/test-classes/tests.manipulation.java5-manipulated.jar");
    out.delete();
    pojoization.pojoization(in, out, (File) null, null);

    Assert.assertTrue(out.exists());
  }
View Full Code Here

Examples of org.apache.felix.ipojo.manipulator.Pojoization

   *
   * @throws IOException
   */
  @Test
  public void testManifestLocationKept() throws IOException {
    Pojoization pojoizator = new Pojoization();
    File tmpDir = null, manifestFile = null, testClass = null;

    // To obtain OS's temp directory.
    File tmpFile = File.createTempFile("pojodir", ".dir");
    String tmpPath = tmpFile.getAbsolutePath();
    tmpFile.delete();

    // Creating directory on temp location
    tmpDir = new File(tmpPath);
    tmpDir.mkdir();
    tmpDir.deleteOnExit();

    // Create manifest file under temp directory
    manifestFile = new File(tmpDir, "MANIFEST.MF");
    new FileOutputStream(manifestFile).write("Manifest-Version: 1.0\r\n"
        .getBytes());
    manifestFile.deleteOnExit();

    // Just to ensure it is not deleted later from test classes.
    AnnotatedComponent safe;

    // Annotated Class File
    File annotedClassPackage = new File(tmpDir, "test");
    annotedClassPackage.deleteOnExit();
    annotedClassPackage.mkdir();
    testClass = new File(annotedClassPackage, "AnnotatedComponent.class");
    testClass.deleteOnExit();
    FileOutputStream os = new FileOutputStream(testClass);
    os.write(ManipulatorTest.getBytesFromFile(new File(
        "target/test-classes/test/AnnotatedComponent.class")));
    os.close();

    // Issue directory manipulation
    pojoizator.directoryPojoization(tmpDir, null, manifestFile, null);

    // Check if supplied manifest file is altered in place
    BufferedReader fi = new BufferedReader(new FileReader(manifestFile));
    String manifestLine;
    while ((manifestLine = fi.readLine()) != null) {
View Full Code Here

Examples of org.apache.felix.ipojo.manipulator.Pojoization

        }

        File out = new File(m_buildDirectory + File.separator + "_out.jar");

        Reporter reporter = new MavenReporter(getLog());
        Pojoization pojo = new Pojoization(reporter);
        if (m_ignoreAnnotations) {
            pojo.disableAnnotationProcessing();
        }
        if (!m_ignoreEmbeddedXSD) {
            pojo.setUseLocalXSD();
        }

        // Executes the pojoization.
        if (is == null) {
            if (metadata == null) { // No metadata.
                pojo.pojoization(in, out, (File) null, classpath.createClassLoader()); // Only annotations
            } else {
                pojo.pojoization(in, out, metadata, classpath.createClassLoader()); // Metadata set
            }
        } else { // In-Pom metadata.
            pojo.pojoization(in, out, is, classpath.createClassLoader());
        }

        for (int i = 0; i < reporter.getWarnings().size(); i++) {
            getLog().warn((String) reporter.getWarnings().get(i));
        }
View Full Code Here

Examples of org.apache.felix.ipojo.manipulator.Pojoization

        return false;
    }

    protected void manipulateComponents(BndReporter reporter, BndJarResourceStore store,
                                        CacheableMetadataProvider cache, ClassLoader classLoader) {
        Pojoization pojoization = new Pojoization(reporter);
        pojoization.disableAnnotationProcessing();
        if (m_useLocalSchemas) {
            pojoization.setUseLocalXSD();
        }

        pojoization.pojoization(store, cache, createVisitor(store, reporter), classLoader);
    }
View Full Code Here

Examples of org.apache.felix.ipojo.manipulator.Pojoization

                boolean r = m_output.delete();
                if (!r) { throw new BuildException("The file " + m_output.getAbsolutePath() + " cannot be deleted"); }
            }
        }

        Pojoization pojo = new Pojoization();
        if (m_ignoreAnnotations) {
            pojo.disableAnnotationProcessing();
        }
        if (! m_ignoreLocalXSD) {
            pojo.setUseLocalXSD();
        }
        if (m_input != null) {
            pojo.pojoization(m_input, m_output, m_metadata);
        } else {
            pojo.directoryPojoization(m_directory, m_metadata, m_manifest);
        }
        for (int i = 0; i < pojo.getWarnings().size(); i++) {
            log((String) pojo.getWarnings().get(i), Project.MSG_WARN);
        }
        if (pojo.getErrors().size() > 0) { throw new BuildException((String) pojo.getErrors().get(0)); }

        if (m_input != null) {
            String out;
            if (m_output.getName().equals("_out.jar")) {
                if (m_input.delete()) {
View Full Code Here

Examples of org.apache.felix.ipojo.manipulator.Pojoization

            JarFile jar = new JarFile(bundle);
            metadata = findMetadata(jar);
        }
       
        // Pojoization
        Pojoization pojoizator = new Pojoization();
        File out =  new File(m_temp, bundle.getName() + "-ipojo.jar");
        System.out.println("Pojoization " + bundle.exists() + " - " + metadata.exists());
        try {
            pojoizator.pojoization(bundle, out, metadata);
        } catch (Exception e) {
            if (! pojoizator.getErrors().isEmpty()) {
                throw new IOException("Errors occured during the manipulation : " + pojoizator.getErrors());
            }
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        }
       
        if (! pojoizator.getErrors().isEmpty()) {
            throw new IOException("Errors occured during the manipulation : " + pojoizator.getErrors());
        }
        if (! pojoizator.getWarnings().isEmpty()) {
            System.err.println("Warnings occured during the manipulation : " + pojoizator.getWarnings());
        }

        System.out.println("Manipulation done : " + out.exists());
       
        // Cleanup
View Full Code Here

Examples of org.apache.felix.ipojo.manipulator.Pojoization

          }
        }

        File out = new File(m_buildDirectory + File.separator + "_out.jar");

        Pojoization pojo = new Pojoization();
        if (m_ignoreAnnotations) { pojo.disableAnnotationProcessing(); }
        if (!m_ignoreEmbeddedXSD) { pojo.setUseLocalXSD(); }

        // Executes the pojoization.
        if (is == null) {
          if (metadata == null) { // No metadata.
            pojo.pojoization(in, out, (File) null); // Only annotations
          } else {
            pojo.pojoization(in, out, metadata); // Metadata set
          }
        } else  { // In-Pom metadata.
            pojo.pojoization(in, out, is);
        }

        for (int i = 0; i < pojo.getWarnings().size(); i++) {
            getLog().warn((String) pojo.getWarnings().get(i));
        }
        if (pojo.getErrors().size() > 0) { throw new MojoExecutionException((String) pojo.getErrors().get(0)); }

        if (m_classifier != null) {
            // The user want to attach the resulting jar
            // Do not delete in File
            m_helper.attachArtifact(m_project, "jar", m_classifier, out);
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.