/*
 * Copyright 2008 GigaSpaces Technologies LTD. All rights reserved.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY AND 
 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. GIGASPACES WILL NOT 
 * BE LIABLE FOR ANY DAMAGE OR LOSS IN CONNECTION WITH THE SOFTWARE.
 */

package com.gigaspaces.examples.tutorials.queries.codebasedfeeder;

import org.openspaces.core.GigaSpace;
import org.openspaces.core.GigaSpaceConfigurer;
import org.openspaces.core.space.UrlSpaceConfigurer;
import com.j_spaces.core.IJSpace;
import com.gigaspaces.examples.tutorials.queries.feeder.AccountPreLoader;
import com.gigaspaces.examples.tutorials.queries.feeder.OrderEventFeeder;

/** 
 * The feeder connects to the remote space and:
 * 1. Pre-loads the space with 100 accounts.
 * 2. Starts feeding the space with orderEvent objects, type set
 *    randomly as "Normal" or "Insecure". <p>
 * 
 * This "CodeBased" version of the feeder is configured inside the main() method.
 * The Processing Unit version of the feeder uses a pu.xml configuration file and can 
 * run inside a stand alone container or deployed onto GigaSpaces' ServiceGrid. 
 */
public class CodeBasedFeeder {

	public static IJSpace space;
	public static GigaSpace gigaSpace;
	
	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		
		// Connect to the space
		// ====================
		// Connect to a remote space.	
		space = new UrlSpaceConfigurer("jini://*/*/spaceQueries").space();
        // Create a GigaSpace simpler interface to interact with the space
		gigaSpace = new GigaSpaceConfigurer(space).gigaSpace();
		
		// Create the account pre-loader, connect it to the space, and initiate it.
		// (The pre-loader writes 100 unique accounts to the space).
		// =========================================================
		AccountPreLoader accountPreLoader = new AccountPreLoader();
		accountPreLoader.setGigaSpace(gigaSpace);
		accountPreLoader.init();
		
		// Create the orderEvent feeder, connect it to the space, and initiate it.
		// (The feeder starts cycles of "New", "Normal"/"Insecure" order feeding task).
		// ==========================================================================
		OrderEventFeeder orderEventFeeder = new OrderEventFeeder();
		orderEventFeeder.setGigaSpace(gigaSpace);
		orderEventFeeder.init();	
	}
}
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence