org/objectweb/proactive/core/descriptor/Launcher.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.core.descriptor;
00032 
00033 import java.io.IOException;
00034 import java.lang.reflect.InvocationTargetException;
00035 
00036 import org.objectweb.proactive.ProActive;
00037 import org.objectweb.proactive.core.ProActiveException;
00038 import org.objectweb.proactive.core.descriptor.data.MainDefinition;
00039 import org.objectweb.proactive.core.descriptor.data.ProActiveDescriptor;
00040 import org.objectweb.proactive.core.descriptor.data.VirtualNode;
00041 import org.objectweb.proactive.core.node.Node;
00042 import org.objectweb.proactive.core.node.NodeException;
00043 
00044 
00057 public class Launcher {
00058     private ProActiveDescriptor pad;
00059     private boolean activated;
00060 
00074     public Launcher(String fileDescriptorPath)
00075         throws ProActiveException, NodeException {
00076         // replace spaces by %20 char (hexadecimal space code) to avoid bug with the property
00077         String filePathWithoutSpaces = fileDescriptorPath.replaceAll(" ", "%20");
00078 
00079         // parse and reify the descriptor
00080         pad = ProActive.getProactiveDescriptor(filePathWithoutSpaces);
00081         activated = false;
00082     }
00083 
00091     public void activate()
00092         throws ProActiveException, NodeException, ClassNotFoundException, 
00093             NoSuchMethodException {
00094         MainDefinition[] mainDefinitions = pad.getMainDefinitions();
00095 
00096         // activate mains
00097         pad.activateMains();
00098 
00099         // launch the main classes
00100         for (int i = 0; i < mainDefinitions.length; i++) {
00101             MainDefinition mainDefinition = mainDefinitions[i];
00102             VirtualNode[] virtualNodes = mainDefinition.getVirtualNodes();
00103             for (int j = 0; j < virtualNodes.length; j++) {
00104                 VirtualNode virtualNode = virtualNodes[j];
00105                 Node node = virtualNode.getNode();
00106 
00107                 ProActive.newMain(mainDefinition.getMainClass(),
00108                     mainDefinition.getParameters(), node);
00109             }
00110         }
00111         activated = true;
00112     }
00113 
00118     public ProActiveDescriptor getProActiveDescriptor() {
00119         return pad;
00120     }
00121 
00126     public boolean isActivated() {
00127         return activated;
00128     }
00129 }

Generated on Mon Jan 22 15:16:06 2007 for ProActive by  doxygen 1.5.1