Examples of Manipulator


Examples of net.sourceforge.jpowergraph.manipulator.Manipulator

     *
     * @param name
     *            the name of the manpulator
     */
    public void removeManipulator(String name) {
        Manipulator manipulator = m_manipulatorsByName.remove(name);
        if (manipulator != null) {
            m_manipulators.remove(manipulator);
            manipulator.setGraphPane(null);
           
            SWTManipulatorListener manipulatorListener = manipulatorListenerMap.get(manipulator);
            if (manipulatorListener != null){
                manipulatorListenerMap.remove(manipulator);
                this.removeMouseListener(manipulatorListener);
View Full Code Here

Examples of org.apache.felix.ipojo.manipulation.Manipulator

    /**
     * Manipulates the implementation class.
     * @return the manipulated class
     */
    private byte[] manipulate() {
        Manipulator manipulator = new Manipulator(new ClassLoader() {
            @Override
            public Class<?> loadClass(String name) throws ClassNotFoundException {
                try {
                    return m_context.getBundle().loadClass(name);
                } catch (ClassNotFoundException e) {
                    return this.getClass().getClassLoader().loadClass(name);
                }
            }
        });
        try {
            byte[] array = getClassByteArray();

            // Step 1 - preparation
            manipulator.prepare(array);

            byte[] newclazz = new byte[0];
            if (!manipulator.isAlreadyManipulated()) {
                // Step 2 - manipulation
                newclazz = manipulator.manipulate(array);
            }
            m_manipulation = manipulator.getManipulationMetadata();
            m_alreadyManipulated = manipulator.isAlreadyManipulated();
            return newclazz;
        } catch (IOException e) {
            throw new IllegalStateException("An exception occurs during implementation class manipulation", e);
        }
    }
View Full Code Here

Examples of org.apache.felix.ipojo.manipulation.Manipulator

        } catch (ClassNotFoundException e1) {
            // The class has already be loaded.
            return null;
        }
        byte[] pojo = POJOWriter.dump(clazz, m_name, getFieldList(), getMethodList(), m_handler);
        Manipulator manipulator = new Manipulator(this.getClass().getClassLoader());
        try {
            manipulator.prepare(pojo);
            byte[] newclazz = manipulator.manipulate(pojo);
            m_manipulation = manipulator.getManipulationMetadata();
            return newclazz;
        } catch (IOException e) {
            m_handler.error("An error occurs during the composite implementation creation : " + e.getMessage(), e);
        }
        return null;
View Full Code Here

Examples of org.apache.felix.ipojo.manipulation.Manipulator

    /**
     * Manipulates the implementation class.
     * @return the manipulated class
     */
    private byte[] manipulate() {
        Manipulator manipulator = new Manipulator();
        try {
            byte[] array = getClassByteArray();
            byte[] newclazz = manipulator.manipulate(array);
            m_manipulation = manipulator.getManipulationMetadata();
            return newclazz;
        } catch (IOException e) {
            throw new IllegalStateException("An exception occurs during implementation class manipulation : " + e.getMessage());
        }
    }
View Full Code Here

Examples of org.apache.felix.ipojo.manipulation.Manipulator

        } catch (ClassNotFoundException e1) {
            // The class has already be loaded.
            return null;
        }
        byte[] pojo = POJOWriter.dump(clazz, m_name, getFieldList(), getMethodList(), m_handler);
        Manipulator manipulator = new Manipulator();
        try {
            byte[] newclazz = manipulator.manipulate(pojo);
            m_manipulation = manipulator.getManipulationMetadata();
            return newclazz;
        } catch (IOException e) {
            m_handler.error("An error occurs during the composite implementation creation : " + e.getMessage(), e);
        }
        return null;
View Full Code Here

Examples of org.apache.felix.ipojo.manipulation.Manipulator

            if (result != null) {
                // Should always be the case

                // Manipulation preparation
                Manipulator manipulator = new Manipulator(m_classLoader);
                try {
                    manipulator.prepare(bytecode);
                } catch (IOException e) {
                    m_reporter.error("Cannot analyze the class " + info.getClassName() + " : " + e.getMessage());
                    return;
                }

                // Inner class preparation
                for (String inner : manipulator.getInnerClasses()) {
                    // Get the bytecode and start manipulation
                    String resourcePath = inner + ".class";
                    String outerClassInternalName = info.getClassName().replace('.', '/');
                    byte[] innerClassBytecode;
                    try {
                        innerClassBytecode = m_store.read(resourcePath);
                        manipulator.prepareInnerClass(inner, innerClassBytecode);
                    } catch (IOException e) {
                        m_reporter.error("Cannot find or analyze inner class '" + resourcePath + "'");
                        return;
                    }
                }

                // Now manipulate the classes.
                try {
                    byte[] out = manipulator.manipulate(bytecode);
                    // Call the visitor
                    result.visitManipulatedResource(info.getResourcePath(), out);
                } catch (IOException e) {
                    m_reporter.error("Cannot manipulate the class " + info.getClassName() + " : " + e.getMessage());
                    return;
                }

                // Visit inner classes
                for (String inner : manipulator.getInnerClasses()) {
                    // Get the bytecode and start manipulation
                    String resourcePath = inner + ".class";
                    String outerClassInternalName = info.getClassName().replace('.', '/');
                    byte[] innerClassBytecode;
                    try {
                        innerClassBytecode = m_store.read(resourcePath);
                    } catch (IOException e) {
                        m_reporter.error("Cannot find inner class '" + resourcePath + "'");
                        return;
                    }

                    // Manipulate inner class
                    // Notice that (for performance reason) re-use the class version information
                    // discovered in the main class instead of re-parsing the inner class to find
                    // its own class version
                    try {
                        byte[] manipulated = manipulator.manipulateInnerClass(inner, innerClassBytecode);
                        // Propagate manipulated resource
                        result.visitManipulatedResource(resourcePath, manipulated);
                    } catch (IOException e) {
                        m_reporter.error("Cannot manipulate inner class '" + resourcePath + "'");
                        return;
                    }
                }

                // Compute manipulation metadata
                result.visitClassStructure(manipulator.getManipulationMetadata());

                // All resources have been manipulated for this component
                result.visitEnd();
            }
        }
View Full Code Here

Examples of org.apache.felix.ipojo.manipulation.Manipulator

     * @param in : the byte array of the class to manipulate
     * @param ci : attached component info (containing metadata and manipulation metadata)
     * @return the generated class (byte array)
     */
    private byte[] manipulateComponent(byte[] in, ComponentInfo ci) {
        Manipulator man = new Manipulator();
        try {
            byte[] out = man.manipulate(in); // iPOJO manipulation
            ci.detectMissingFields(man.getFields()); // Detect missing field
            // Insert information to metadata
            ci.m_componentMetadata.addElement(man.getManipulationMetadata());
            ci.m_isManipulated = true;
            ci.m_inners = man.getInnerClasses();
            ci.m_fields = man.getFields().keySet();
            return out;
        } catch (IOException e) {
            error("Cannot manipulate the class " + ci.m_classname + " : " + e.getMessage());
            return 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.