문제

Sprocket is a Ruby library for managing JavaScript dependencies. It makes it possible to declare dependencies in specially formatted comments in the JavaScript files, and have all the required files concatenated server side. (Read more here: http://getsprockets.org/)

Where I work, we have a real need for such a framework, but it has to be in the form of a Java library.

Does such a thing exist? What other solutions have you come up with to manage JavaScript dependencies?

도움이 되었습니까?

해결책

예 :

public abstract class AbsFoo {
    protected AbsBoo boo;
}

public class Foo extends AbsFoo {
    @Inject
    public Foo(Boo boo) {
        super.boo = boo; // Boo extends AbsBoo
    }
} 
.

foo 인스턴스를 @Inject 또는 injector.getInstance () 로 구성해도 확인하십시오.

편집

공급자를 사용하여 주문시 인스턴스를 만들 수도 있습니다.

@Inject
Provider<Foo> fooProvider

//...

public void doSomething(){
    //need new foo:
    Foo foo = fooProvider.get();
}
.

다른 팁

You may have a look at this webutilities as well.

Such a feature exists in the Wicket framework. It is a component-oriented web framework for Java that is gaining momentum these days.

Wicket lets you define header resources in your components (eg, Javascript scripts, CSS files, etc.) and combines them at runtime, removing duplicates.

I know this was answered a long time ago but my vote is for JAWR!

You can run sprockets inside a java web application using jruby. It is not too difficult. You could disable sprockets in production and only use statically compiled assets if you are worried about performance. It's also possible with Servlet-3.0 to completely disable sprockets in production and have the same web.xml or you could do dodgy things with a proxy context listener and proxy servlet filter if you are concerned about having to load the jruby runtime and sprockets even when you are not using it.

I have an example here: https://github.com/benmmurphy/java_sprockets

Yes, it does exist and its even richer in functionality https://github.com/QubitProducts/miniMerge.

Ii is also very fast and very small (few kb)! All you need is java.

I use it in my all projects, it is not only for JS, I use it also with CSS and HTML.

One awesome thing is that you can specify file or directory as input and filter contents based on tagging!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top