org.apache.felix.ipojo.manipulator
Class Pojoization

java.lang.Object
  extended by org.apache.felix.ipojo.manipulator.Pojoization

public class Pojoization
extends Object

Pojoization allows creating an iPOJO bundle from a "normal" bundle.

Author:
Felix Project Team

Field Summary
static String IPOJO_PACKAGE_VERSION
          iPOJO Imported Package Version.
 
Constructor Summary
Pojoization()
           
 
Method Summary
 void addManifestAttributeFilters(ManifestAttributeFilter filter)
          Adds a Manifest attribute filter to the list
 void directoryPojoization(File directory, File metadataFile, File manifestFile)
          Manipulates an expanded bundles.
 void disableAnnotationProcessing()
          Activates annotation processing.
protected  void error(String mes)
          Add an error in the error list.
protected  byte[] getBytecode(String classname)
          Gets a byte array that contains the bytecode of the given classname.
 List getErrors()
           
protected  InputStream getInputStream(String classname)
          Gets an input stream on the given class.
protected  InputStream getManifestInputStream()
          Retrieves an InputStream to read the Manifest.
 List getWarnings()
           
 Map parseHeader(String value)
          Standard OSGi header parser.
 void pojoization(File in, File out, File metadataFile)
          Manipulates an input bundle.
 void pojoization(File in, File out, InputStream metadata)
          Manipulates an input bundle.
 String printClauses(Map exports, String allowedDirectives)
          Print a standard Map based OSGi header.
protected  void searchClassFiles(File dir, List classes)
          Navigates across directories to find class files.
protected  void setBytecode(File classFile, byte[] rawClass)
          Writes the .class raw data to the storage support
 void setUseLocalXSD()
          Activates the entity resolver loading XSD files from the classloader.
 void warn(String mes)
          Add a warning in the warning list.
protected  void writeManifest(Manifest mf)
          Retrieves an OutputStream to write in the Manifest.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IPOJO_PACKAGE_VERSION

public static final String IPOJO_PACKAGE_VERSION
iPOJO Imported Package Version.

See Also:
Constant Field Values
Constructor Detail

Pojoization

public Pojoization()
Method Detail

error

protected void error(String mes)
Add an error in the error list.

Parameters:
mes - : error message.

warn

public void warn(String mes)
Add a warning in the warning list.

Parameters:
mes - : warning message

getErrors

public List getErrors()

disableAnnotationProcessing

public void disableAnnotationProcessing()
Activates annotation processing.


setUseLocalXSD

public void setUseLocalXSD()
Activates the entity resolver loading XSD files from the classloader.


pojoization

public void pojoization(File in,
                        File out,
                        InputStream metadata)
Manipulates an input bundle. This method creates an iPOJO bundle based on the given metadata file. The original and final bundles must be different.

Parameters:
in - the original bundle.
out - the final bundle.
metadata - the iPOJO metadata input stream.

pojoization

public void pojoization(File in,
                        File out,
                        File metadataFile)
Manipulates an input bundle. This method creates an iPOJO bundle based on the given metadata file. The original and final bundles must be different.

Parameters:
in - the original bundle.
out - the final bundle.
metadataFile - the iPOJO metadata file (XML).

directoryPojoization

public void directoryPojoization(File directory,
                                 File metadataFile,
                                 File manifestFile)
Manipulates an expanded bundles. Classes are in the specified directory. this method allows to update a customized manifest.

Parameters:
directory - the directory containing classes
metadataFile - the metadata file
manifestFile - the manifest file. null to use directory/META-INF/MANIFEST.mf

getBytecode

protected byte[] getBytecode(String classname)
                      throws IOException
Gets a byte array that contains the bytecode of the given classname. This method can be overridden by sub-classes.

Parameters:
classname - name of a class to be read
Returns:
a byte array
Throws:
IOException - if the classname cannot be read

getInputStream

protected InputStream getInputStream(String classname)
                              throws IOException
Gets an input stream on the given class. This methods manages Jar files and directories. If also looks into WEB-INF/classes to support WAR files. This method may be overridden.

Parameters:
classname - the class name
Returns:
the input stream
Throws:
IOException - if the file cannot be read

searchClassFiles

protected void searchClassFiles(File dir,
                                List classes)
Navigates across directories to find class files. Sub-classes can override this method to customize the searched files.

Parameters:
dir - the directory to analyze
classes - discovered classes

parseHeader

public Map parseHeader(String value)
Standard OSGi header parser. This parser can handle the format clauses ::= clause ( ',' clause ) + clause ::= name ( ';' name ) (';' key '=' value ) This is mapped to a Map { name => Map { attr|directive => value } }

Parameters:
value - : String to parse.
Returns:
parsed map.

printClauses

public String printClauses(Map exports,
                           String allowedDirectives)
Print a standard Map based OSGi header.

Parameters:
exports - : map { name => Map { attribute|directive => value } }
allowedDirectives - : list of allowed directives.
Returns:
the clauses

addManifestAttributeFilters

public void addManifestAttributeFilters(ManifestAttributeFilter filter)
Adds a Manifest attribute filter to the list

Parameters:
filter - The new Manifest attribute filter

writeManifest

protected void writeManifest(Manifest mf)
                      throws IOException
Retrieves an OutputStream to write in the Manifest.

Throws:
IOException

getManifestInputStream

protected InputStream getManifestInputStream()
                                      throws IOException
Retrieves an InputStream to read the Manifest.

Returns:
A valid input stream
Throws:
IOException

setBytecode

protected void setBytecode(File classFile,
                           byte[] rawClass)
                    throws IOException
Writes the .class raw data to the storage support

Parameters:
classFile - - Output .class file
rawClass - - Raw class representation
Throws:
IOException - - Something wrong occurred while writing the file

getWarnings

public List getWarnings()


Copyright © 2011 Apache Software Foundation. All Rights Reserved.