/*
 * #%L
 * mosaic-components-container
 * %%
 * Copyright (C) 2010 - 2012 Institute e-Austria Timisoara (Romania)
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

package eu.mosaic_cloud.components.implementations.basic;


import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import eu.mosaic_cloud.tools.miscellaneous.BrokenInputStream;
import eu.mosaic_cloud.tools.miscellaneous.BrokenPrintStream;

import com.google.common.base.Preconditions;


public final class BasicComponentHarnessPreMain
		extends Object
{
	private BasicComponentHarnessPreMain ()
	{
		super ();
		throw (new UnsupportedOperationException ());
	}
	
	static {
		stdin = System.in;
		stdout = System.out;
		System.setIn (BrokenInputStream.create ());
		System.setOut (BrokenPrintStream.create ());
	}
	
	public static final void main (final String callbacksClass, final String[] arguments)
			throws Throwable
	{
		Preconditions.checkArgument (arguments != null, "invalid arguments; expected arguments");
		final String[] finalArguments = new String[arguments.length + 2];
		finalArguments[0] = "--component-callbacks-class";
		finalArguments[1] = callbacksClass;
		System.arraycopy (arguments, 0, finalArguments, 2, arguments.length);
		BasicComponentHarnessPreMain.main (finalArguments);
	}
	
	public static final void main (final String[] arguments)
			throws Throwable
	{
		final Class<?> mainClass = BasicComponentHarnessPreMain.class.getClassLoader ().loadClass (BasicComponentHarnessPreMain.class.getName ().replace ("PreMain", "Main"));
		final Method mainMethod = mainClass.getMethod ("main", String[].class);
		try {
			mainMethod.invoke (null, new Object[] {arguments});
		} catch (final InvocationTargetException exception) {
			throw (exception.getCause ());
		}
	}
	
	static final InputStream stdin;
	static final OutputStream stdout;
}

@@ -1465,32 +1465,59 @@
 ring%5B%5D arguments
+, final int argumentsOffset
 )%0A%09%09%09throws Thro
@@ -1617,16 +1617,137 @@
 ents%22);%0A
+%09%09Preconditions.checkArgument (argumentsOffset %3E= 0 && argumentsOffset %3C= arguments.length, %22invalid arguments offset%22);%0A
 %09%09final 
@@ -1783,16 +1783,17 @@
  String%5B
+(
 argument
@@ -1804,16 +1804,35 @@
 ngth + 2
+) - argumentsOffset
 %5D;%0A%09%09fin
@@ -1948,17 +1948,31 @@
 uments, 
-0
+argumentsOffset
 , finalA
@@ -2000,16 +2000,34 @@
 s.length
+ - argumentsOffset
 );%0A%09%09Bas

Update various components bootstrap code (step 2)