GithubHelp home page GithubHelp logo

cbjavaloader's Introduction


Copyright Since 2005 ColdBox Platform by Luis Majano and Ortus Solutions, Corp
www.coldbox.org | www.ortussolutions.com


Welcome to the cbJavaloader Project

This module will allow your ColdBox applications to class load different Java classes and libraries at runtime via the JavaLoader project. It also registers a WireBox DSL so you can easily inject Java classes into your objects using WireBox.

License

Apache License, Version 2.0.

Important Links

System Requirements

  • Lucee 5+
  • ColdFusion 2016+

Instructions

Just drop into your modules folder or use the box-cli to install

box install cbjavaloader

The module has a default folder called lib where any jars you drop there will be class loaded automatically. However, we recommend using the loadpaths setting for selecting an array of locations to class load, so when the module updates you won't lose those files.

Models

The module registers the following mapping in WireBox: loader@cbjavaloader. Which is the class you will use to class load, append paths and much more. Check out the included API Docs for much more information. The main methods of importance of the java loader are:

  • create( class ) - Create a loaded Java class
  • appendPath( dirPath, filter) - Appends a directory path of .jar's,.classes to the current loaded class loader.
  • getLoadedURLs() - Get all the loaded URLs

WireBox DSL

The module also registers a new WireBox DSL called javaloader. You can then use this custom DSL for injecting direct java class loaded classes very easily:

property name="name"  inject="javaloader:{class-path}";
property name="hello" inject="javaloader:HelloWorld";
property name="buffer" inject="javaloader:org.class.path.StringBuffer";

Settings

Here are the module settings you can place in your ColdBox.cfc under an moduleSettings.cbJavaLoader structure:

moduleSettings = {
	cbJavaLoader = {
		// A single path, and array of paths or a single Jar
		loadPaths = [],
		// Load ColdFusion classes with loader
		loadColdFusionClassPath = false,
		// Attach a custom class loader as a parent
		parentClassLoader = "",
		// Directories that contain Java source code that are to be dynamically compiled
		sourceDirectories = [],
		// the directory to build the .jar file for dynamic compilation in, defaults to ./tmp
		compileDirectory = "models/javaloader/tmp",
		// Whether or not the source is trusted, i.e. it is going to change? Defaults to false, so changes will be recompiled and loaded
		trustedSource = false
	}
};

Below is a simple example:

/**
* My Event Handler Hint
*/
component{
	// Inject JavaLoader
	property name="javaloader" inject="loader@cbjavaloader";

	// Index
	any function index( event,rc, prc ){
		// creat a java class
		prc.hello = javaloader.create( "HelloWorld" ).init().hello();
	}

	// Run on first init
	any function onAppInit( event, rc, prc ){
		// on application start, load up more jars
		javaloader.appendPaths( getSetting( "ApplicationPath" ) & "jars" );
	}

}


Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com


HONOR GOES TO GOD ABOVE ALL

Because of His grace, this project exists. If you don't like this, then don't read it, its not for you.

"Therefore being justified by faith, we have peace with God through our Lord Jesus Christ: By whom also we have access by faith into this grace wherein we stand, and rejoice in hope of the glory of God. And not only so, but we glory in tribulations also: knowing that tribulation worketh patience; And patience, experience; and experience, hope: And hope maketh not ashamed; because the love of God is shed abroad in our hearts by the Holy Ghost which is given unto us. ." Romans 5:5

THE DAILY BREAD

"I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12

cbjavaloader's People

Contributors

andrew-dixon avatar balbinoortus avatar bdw429s avatar jclausen avatar lmajano avatar sanaullah avatar stephen-condon avatar timmaybrown avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

cbjavaloader's Issues

v 1.1.0 issue loading config

I installed v 1.1.0 via :

box install cbjavaloader

and it failed to load my jars with this config in ColdBox.cfc:

        javaloader = {
            // The array paths to load
            loadPaths = directoryList( expandPath("./lib/"), true, "array", "*.jar", "name desc" )

        };

which works ok in v 1.0.0. The error in ModuleConfig.cfc reported that the path ./ib/myjar.jar was not a directory. Is this a bug or has the API changed?

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.