Using package loader
This commit is contained in:
		@@ -1,7 +1,9 @@
 | 
				
			|||||||
 | 
					var cl = global.botanLoader;
 | 
				
			||||||
var Dragonfly = global.Dragonfly;
 | 
					var Dragonfly = global.Dragonfly;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var domain = require('domain');
 | 
					var domain = require('domain');
 | 
				
			||||||
var FatalError = require( '../errors/FatalError' );
 | 
					
 | 
				
			||||||
 | 
					var FatalError = cl.load( "botanss.errors.FatalError" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Message is hardcoded to prevent further exceptions occured
 | 
					// Message is hardcoded to prevent further exceptions occured
 | 
				
			||||||
// This function must be bug-free
 | 
					// This function must be bug-free
 | 
				
			||||||
@@ -52,7 +54,7 @@ function serverHandle( server, request, response, rHandle )
 | 
				
			|||||||
// Construncor
 | 
					// Construncor
 | 
				
			||||||
function AppDomain( handler, port, cluster )
 | 
					function AppDomain( handler, port, cluster )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	var http = require('http');
 | 
						var http = require( "http" );
 | 
				
			||||||
	var server = http.createServer(
 | 
						var server = http.createServer(
 | 
				
			||||||
		function(req, res) {
 | 
							function(req, res) {
 | 
				
			||||||
			serverHandle( server, req, res, handler );
 | 
								serverHandle( server, req, res, handler );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,7 @@
 | 
				
			|||||||
 | 
					var cl = global.botanLoader;
 | 
				
			||||||
var Dragonfly = global.Dragonfly;
 | 
					var Dragonfly = global.Dragonfly;
 | 
				
			||||||
var Cookie = require( "./Components/Cookie" );
 | 
					
 | 
				
			||||||
 | 
					var Cookie = cl.load( "botanss.net.components.Cookie" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var HTTP = function( req, res )
 | 
					var HTTP = function( req, res )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -1,9 +1,11 @@
 | 
				
			|||||||
 | 
					var cl = global.botanLoader;
 | 
				
			||||||
var Dragonfly = global.Dragonfly;
 | 
					var Dragonfly = global.Dragonfly;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var util = require( "util" )
 | 
					var util = require( "util" );
 | 
				
			||||||
	, events = require( "events" )
 | 
					var events = require( "events" );
 | 
				
			||||||
	, FatalError = require( '../errors/FatalError.js' )
 | 
					
 | 
				
			||||||
;
 | 
					var FatalError = cl.load( "botanss.errors.FatalError" )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var MaxRedirect = 10;
 | 
					var MaxRedirect = 10;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,7 @@
 | 
				
			|||||||
 | 
					var cl = global.botanLoader;
 | 
				
			||||||
var Dragonfly = global.Dragonfly;
 | 
					var Dragonfly = global.Dragonfly;
 | 
				
			||||||
var FatalError = require( '../errors/FatalError.js' );
 | 
					
 | 
				
			||||||
 | 
					var FatalError = cl.load( "botanss.errors.FatalError" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var Framework = function( garden )
 | 
					var Framework = function( garden )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -11,7 +13,7 @@ var Framework = function( garden )
 | 
				
			|||||||
	this.requestStr = "";
 | 
						this.requestStr = "";
 | 
				
			||||||
	this.requestObj = {};
 | 
						this.requestObj = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var Router = require( "./Router" );
 | 
						var Router = cl.load( "botanss.net.Router" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var router = new Router( garden );
 | 
						var router = new Router( garden );
 | 
				
			||||||
	router.addRoute( "302", false, "302" );
 | 
						router.addRoute( "302", false, "302" );
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										30
									
								
								package.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								package.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					// The Package Loader
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var fs = require( "fs" );
 | 
				
			||||||
 | 
					var rootNS = {
 | 
				
			||||||
 | 
						botanss: "./"
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var Package = function() { };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Package.prototype.rootNS = function( name, path )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if( rootNS[ name ] ) return;
 | 
				
			||||||
 | 
						rootNS[ name ] = fs.realpathSync( path ) + "/";
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Package.prototype.load = function( _class )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						var fSep = _class.indexOf( "." );
 | 
				
			||||||
 | 
						var nsdomain = _class.substr( 0, fSep );
 | 
				
			||||||
 | 
						_class = _class.substr( fSep + 1 ).replace( /\./g, "/" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var file = rootNS[ nsdomain ] + _class;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var lClass = require( file );
 | 
				
			||||||
 | 
						// TODO: Implements filewatcher
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return lClass;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					global.botanLoader = new Package();
 | 
				
			||||||
		Reference in New Issue
	
	Block a user