Giter VIP home page Giter VIP logo

frameworkinjector's Introduction

FrameworkInjector

中文说明

FrameworkInjector is an AOP framework for Java which is managing pointcut configurations by json and performing code weaving with Javassist.

At the begining, FrameworkInjector is designed for AOP code weaving of Android framework. This is the origin of the name.

Feature

  1. Managing AOP pointcut configurations by JSON
  2. Perform code weaving on specified Java class method
  3. Support wildcard while matching class and method name
  4. [BUG][TODO] Skipping interface class so that interface currently would not perform code weaving.

Setup

source build.sh

Run build.sh to compile by javac and package by jar. The final target is runnable jar.

Usage

The runnable jar of this program support parameters:

  1. --pointcuts_json Sets path of json that managing pointcut configurations
  2. -i Sets the input jar file which performing weaving from
  3. -o Sets the output jar file which is been injected
  4. -cplist Class Path List for Javassist. In case of class that exists in the input jar is not able to found in system class path, passing the path of the class to Javassist with this params to help Javassist load it. Every path is concat by ':'(Check it on JDK specifications).

Run the sample

source build_and_run_sample.sh

build_and_run_sample.sh contains a lot of steps. It will make this program by calling build.sh. And then runs the inside sample(sample/sample.json). The sample will make this program perform code weaving on the jar generated by build.sh

Run

Perform code weaving on foo.jar:

java -jar frameworkinjector.jar -cplist "libs" -pointcuts_json myPointcuts.json -i foo.jar -o injected_foo.jar

When error like "Class NotFound" happends, it is useful that add class path:

java -Xbootclasspath/a:/path/myPath:<other> <...other cmd parts...>

How it works

Sample

  1. Run build_and_run_sample.sh, which will perform code weaving configed by sample.json
  2. A new jar that is injected will be produced from step 1. It containes codes injected by this program. In the case of the sample, a new System.out.println call is injected which shown as below.

LICENSE

Copyright (C) <2022>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

frameworkinjector's People

Contributors

nasdaqgodzilla avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.