GithubHelp home page GithubHelp logo

zyz1990 / sp_f Goto Github PK

View Code? Open in Web Editor NEW

This project forked from luqinx/sp

0.0 0.0 0.0 889 KB

sp(a)是一个SPI(Service Provider Interface)框架, 他具有跨模块(无任何依赖关系的模块)创建对象的能力。使用简单、功能强大、性能损耗极低,是组件化开发、模块解耦合的不二之选。由于sp(a)灵活的配置能力,使得它很容易扩展出更多的跨模块通信能力,如组件热插拔、路由、事件分发、rpc通信等。如果您正在使用组件化开发,或者您有多项目需要做差异化处理,强烈推荐您使用sp(a)。

License: Apache License 2.0

Shell 0.11% Java 99.89%

sp_f's Introduction

ServicePool

GitHub license build release 掘金

ServicePool接入方法

spa已迁移至mavenCentral, groupId已修正为io.github.luqinx, 包名还保持原来的包名

在项目根目录的build.gradle中引入

allprojects {
    repositories {
        ...
        mavenCentral()
    }
}

buildscript {

    repositories {
        ...
        mavenCentral()
    }
    dependencies {
        ...
        classpath 'io.github.luqinx:autoservice:1.7.0'
    }
}

在主Module目录(一般是app目录)的build.gradle中添加

apply plugin: 'sp.autoservice'

...

** 其他Module下按需添加依赖 **

dependencies {
    implementation 'io.github.luqinx:sp:1.7.0' //servicepool核心库, 是java库, 非android环境用这个就可以了
    implementation 'io.github.luqinx:spa:1.7.0' // servicepool的Android支持(spa), 只依赖spa也是可以的
    implementation 'io.github.luqinx:sprouter:1.7.0' // 基于spa的页面路由
}

** 混淆配置 **


-ignorewarnings

-dontwarn com.google.common.**

-dontwarn net.bytebuddy.**

-keep class net.bytebuddy.** {*;}
-keep class com.android.** {*;}

-keep @chao.java.tools.servicepool.annotation.* class *
-keep @chao.android.tools.rpc.annotation.* class ** {*;}

-keep class chao.android.tools.** {*;}
-keep class chao.java.tools.** {*;}

ServicePool使用方式

在Application的onCreate()/onAttachBaseContext()方法中初始化

ServicePool使用懒加载**,所有服务Service对象都是在真正使用的时刻才会去创建和初始化。这里主要是因为Android部分功能依赖Context, 初始化时可注入ApplicationContext。还有有些特定的服务有预加载的需求(如业务组件可能需要一个特定的初始化场景,而不是去依赖Application的onCreate()方法)

   Spa.init(this); //初始化耗时10ms左右, 设备不同可能会有些差异, 我测试的设备是小米mix3

Spa的更多使用细节,请参考博客Android端简单易用的SPI框架 - SPA

sp_f's People

Contributors

luqinx 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.