1 31 package org.objectweb.proactive.core.group; 32 33 import org.apache.log4j.Logger; 34 35 import org.objectweb.fractal.api.Interface; 36 import org.objectweb.fractal.api.NoSuchInterfaceException; 37 import org.objectweb.fractal.api.factory.InstantiationException; 38 import org.objectweb.fractal.api.type.InterfaceType; 39 40 import org.objectweb.proactive.core.component.ComponentParameters; 41 import org.objectweb.proactive.core.component.ControllerDescription; 42 import org.objectweb.proactive.core.component.ProActiveInterface; 43 import org.objectweb.proactive.core.component.representative.ProActiveComponentRepresentativeFactory; 44 import org.objectweb.proactive.core.component.type.ProActiveTypeFactory; 45 import org.objectweb.proactive.core.mop.ClassNotReifiableException; 46 import org.objectweb.proactive.core.mop.ConstructionOfProxyObjectFailedException; 47 import org.objectweb.proactive.core.mop.ConstructionOfReifiedObjectFailedException; 48 import org.objectweb.proactive.core.mop.InvalidProxyClassException; 49 import org.objectweb.proactive.core.mop.MOP; 50 import org.objectweb.proactive.core.mop.StubObject; 51 52 53 65 public class ProActiveComponentGroup { 66 protected static Logger logger = Logger.getLogger(ProActiveComponentGroup.class.getName()); 67 68 69 public static Object newActiveComponentGroup( 70 ComponentParameters componentParameters) 71 throws ClassNotFoundException , ClassNotReifiableException { 72 Object result = null; 73 74 try { 75 result = MOP.newInstance(ProActiveInterface.class.getName(), null, 76 ProActiveGroup.DEFAULT_PROXYFORGROUP_CLASS_NAME, 77 new Object [] { null, null, null }); 78 } catch (ClassNotReifiableException e) { 79 System.err.println("**** ClassNotReifiableException ****"); 80 } catch (InvalidProxyClassException e) { 81 System.err.println("**** InvalidProxyClassException ****"); 82 } catch (ConstructionOfProxyObjectFailedException e) { 83 System.err.println( 84 "**** ConstructionOfProxyObjectFailedException ****"); 85 } catch (ConstructionOfReifiedObjectFailedException e) { 86 System.err.println( 87 "**** ConstructionOfReifiedObjectFailedException ****"); 88 } 89 90 ((org.objectweb.proactive.core.group.ProxyForGroup) (((StubObject) result).getProxy())).className = Interface.class.getName(); 91 92 return ProActiveComponentRepresentativeFactory.instance() 93 .createComponentRepresentative(componentParameters, 94 ((StubObject) result).getProxy()); 95 } 96 97 105 public static ProActiveInterface newActiveComponentInterfaceGroup( 106 InterfaceType interfaceType) 107 throws ClassNotFoundException , ClassNotReifiableException { 108 try { 109 ComponentParameters component_parameters = new ComponentParameters(ProActiveTypeFactory.instance() 110 .createFcType(new InterfaceType[] { 111 interfaceType 112 }), new ControllerDescription(null, null)); 113 114 Object result = null; 115 116 result = MOP.newInstance(ProActiveInterface.class.getName(), null, 117 ProActiveGroup.DEFAULT_PROXYFORGROUP_CLASS_NAME, null); 118 119 ProxyForGroup proxy = (org.objectweb.proactive.core.group.ProxyForGroup) ((StubObject) result).getProxy(); 120 proxy.className = ProActiveInterface.class.getName(); 121 122 return (ProActiveInterface) (ProActiveComponentRepresentativeFactory.instance() 124 .createComponentRepresentative(component_parameters, 125 proxy)).getFcInterface(interfaceType.getFcItfName()); 126 } catch (InvalidProxyClassException e) { 127 logger.error("**** InvalidProxyClassException ****"); 128 } catch (ConstructionOfProxyObjectFailedException e) { 129 logger.error("**** ConstructionOfProxyObjectFailedException ****"); 130 } catch (ConstructionOfReifiedObjectFailedException e) { 131 logger.error("**** ConstructionOfReifiedObjectFailedException ****"); 132 } catch (NoSuchInterfaceException e) { 133 logger.error("**** Interface not found **** " + e.getMessage()); 134 } catch (InstantiationException e) { 135 logger.error("**** Cannot create component type **** " + 136 e.getMessage()); 137 } 138 return null; 139 } 140 141 143 } 171 | Popular Tags |