/**Adds a Method Descriptor. Methods <b>must</b> be added in the same order as they appear in the IDL. * * <p> Please note that overloaded methods are not allowed. * @param methodDescriptor * @throws IllegalArgumentException if a method by the same name already exists. */ public void addMethodDescriptor(JILocalMethodDescriptor methodDescriptor) { if (nameVsMethodInfo.containsKey(methodDescriptor.getMethodName())) { throw new IllegalArgumentException(JISystem.getLocalizedMessage(JIErrorCodes.JI_CALLBACK_OVERLOADS_NOTALLOWED)); } methodDescriptor.setMethodNum(nextNum); nextNum++; opnumVsMethodInfo.put(new Integer(methodDescriptor.getMethodNum()),methodDescriptor); if (dispInterface) { if (methodDescriptor.getMethodDispID() == -1) { throw new IllegalArgumentException(JISystem.getLocalizedMessage(JIErrorCodes.JI_METHODDESC_DISPID_MISSING)); } dispIdVsMethodInfo.put(new Integer(methodDescriptor.getMethodDispID()),methodDescriptor); } nameVsMethodInfo.put(methodDescriptor.getMethodName(),methodDescriptor); }
/**Creates the method descriptor. The method number is set by the order in which this instance is * added to the <code>JILocalInterfaceDefinition</code>. This number is incremented by 1 for each subsequent * and new addition into interface definition. * * @param methodName name of the method. * @param parameters pass <code>null</code> if the method has no parameters. */ public JILocalMethodDescriptor(String methodName,JILocalParamsDescriptor parameters) { this.methodName = methodName; setParameterObject(parameters); }
dispIds[0] = new Integer ( info.getMethodNum () ); methodDescriptor.getParameterObject ().setSession ( this.session ); params = methodDescriptor.getParameterObject ().read ( ndr ); execute = true; try logger.info ( "methodDescriptor: {}", methodDescriptor.getMethodName () ); method = calleeClazz.getDeclaredMethod ( methodDescriptor.getMethodName (), methodDescriptor.getInparametersAsClass () ); final Object calleeInstance = interfaceDefinitionOfClass.instance == null ? calleeClazz.newInstance () : interfaceDefinitionOfClass.instance; logger.info ( "Call Back Method to be executed: {} , to be executed on {}", method, calleeInstance );
void AttachEventListener() throws JIException { //6FBA474D-43AC-11CE-9A0E-00AA0062BB4C JILocalCoClass javaComponent = new JILocalCoClass(new JILocalInterfaceDefinition("6FBA474D-43AC-11CE-9A0E-00AA0062BB4C"),SysInfoEvents.class); javaComponent.getInterfaceDefinition().addMethodDescriptor(new JILocalMethodDescriptor("PowerStatusChanged",8,null)); javaComponent.getInterfaceDefinition().addMethodDescriptor(new JILocalMethodDescriptor("TimeChanged",3,null)); identifier = JIObjectFactory.attachEventHandler(sysInfoServer,"6FBA474D-43AC-11CE-9A0E-00AA0062BB4C",JIObjectFactory.buildObject(session,javaComponent)); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } //for call backs }
/**Removes the method descriptor identified by it's name. <p> * <p> * Please note that removal of a sequential method can have unpredictable results during a call. <br> * @param methodName * @see #addMethodDescriptor(JILocalMethodDescriptor) */ public void removeMethodDescriptor(String methodName) { JILocalMethodDescriptor methodDescriptor = (JILocalMethodDescriptor)nameVsMethodInfo.remove(methodName); if (methodDescriptor != null) { nameVsMethodInfo.remove(new Integer(methodDescriptor.getMethodNum())); } }
/**Removes the method descriptor identified by it's number. * <p> * Please note that removal of a sequential method can have unpredictable results during a call. <br> * @param opnum * @see #addMethodDescriptor(JILocalMethodDescriptor) */ public void removeMethodDescriptor(int opnum) { JILocalMethodDescriptor methodDescriptor = (JILocalMethodDescriptor)opnumVsMethodInfo.remove(new Integer(opnum)); if (methodDescriptor != null) { nameVsMethodInfo.remove(methodDescriptor.getMethodName()); } }
dispIds[0] = new Integer(info.getMethodNum()); methodDescriptor.getParameterObject().setSession(session); params = methodDescriptor.getParameterObject().read(ndr); execute = true; if (JISystem.getLogger().isLoggable(Level.INFO)) JISystem.getLogger().info("methodDescriptor: " + methodDescriptor.getMethodName()); method = calleeClazz.getDeclaredMethod(methodDescriptor.getMethodName(),methodDescriptor.getInparametersAsClass()); Object calleeInstance = interfaceDefinitionOfClass.instance == null ? calleeClazz.newInstance() : interfaceDefinitionOfClass.instance; if (JISystem.getLogger().isLoggable(Level.INFO))
void AttachEventListener() throws JIException { //6FBA474D-43AC-11CE-9A0E-00AA0062BB4C JILocalCoClass javaComponent = new JILocalCoClass(new JILocalInterfaceDefinition("6FBA474D-43AC-11CE-9A0E-00AA0062BB4C"),SysInfoEvents.class); javaComponent.getInterfaceDefinition().addMethodDescriptor(new JILocalMethodDescriptor("PowerStatusChanged",8,null)); javaComponent.getInterfaceDefinition().addMethodDescriptor(new JILocalMethodDescriptor("TimeChanged",3,null)); identifier = JIObjectFactory.attachEventHandler(sysInfoServer,"6FBA474D-43AC-11CE-9A0E-00AA0062BB4C",JIObjectFactory.buildObject(session,javaComponent)); try { Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } //for call backs }
/**Removes the method descriptor identified by it's name. <p> * <p> * Please note that removal of a sequential method can have unpredictable results during a call. <br> * @param methodName * @see #addMethodDescriptor(JILocalMethodDescriptor) */ public void removeMethodDescriptor(String methodName) { JILocalMethodDescriptor methodDescriptor = (JILocalMethodDescriptor)nameVsMethodInfo.remove(methodName); if (methodDescriptor != null) { nameVsMethodInfo.remove(new Integer(methodDescriptor.getMethodNum())); } }
/**Removes the method descriptor identified by it's number. * <p> * Please note that removal of a sequential method can have unpredictable results during a call. <br> * @param opnum * @see #addMethodDescriptor(JILocalMethodDescriptor) */ public void removeMethodDescriptor(int opnum) { JILocalMethodDescriptor methodDescriptor = (JILocalMethodDescriptor)opnumVsMethodInfo.remove(new Integer(opnum)); if (methodDescriptor != null) { nameVsMethodInfo.remove(methodDescriptor.getMethodName()); } }
/**Adds a Method Descriptor. Methods <b>must</b> be added in the same order as they appear in the IDL. * * <p> Please note that overloaded methods are not allowed. * @param methodDescriptor * @throws IllegalArgumentException if a method by the same name already exists. */ public void addMethodDescriptor(JILocalMethodDescriptor methodDescriptor) { if (nameVsMethodInfo.containsKey(methodDescriptor.getMethodName())) { throw new IllegalArgumentException(JISystem.getLocalizedMessage(JIErrorCodes.JI_CALLBACK_OVERLOADS_NOTALLOWED)); } methodDescriptor.setMethodNum(nextNum); nextNum++; opnumVsMethodInfo.put(new Integer(methodDescriptor.getMethodNum()),methodDescriptor); if (dispInterface) { if (methodDescriptor.getMethodDispID() == -1) { throw new IllegalArgumentException(JISystem.getLocalizedMessage(JIErrorCodes.JI_METHODDESC_DISPID_MISSING)); } dispIdVsMethodInfo.put(new Integer(methodDescriptor.getMethodDispID()),methodDescriptor); } nameVsMethodInfo.put(methodDescriptor.getMethodName(),methodDescriptor); }
dispIds[0] = new Integer(info.getMethodNum()); methodDescriptor.getParameterObject().setSession(session); params = methodDescriptor.getParameterObject().read(ndr); execute = true; if (JISystem.getLogger().isLoggable(Level.INFO)) JISystem.getLogger().info("methodDescriptor: " + methodDescriptor.getMethodName()); method = calleeClazz.getDeclaredMethod(methodDescriptor.getMethodName(),methodDescriptor.getInparametersAsClass()); Object calleeInstance = interfaceDefinitionOfClass.instance == null ? calleeClazz.newInstance() : interfaceDefinitionOfClass.instance; if (JISystem.getLogger().isLoggable(Level.INFO))
void AttachEventListener () throws JIException { //6FBA474D-43AC-11CE-9A0E-00AA0062BB4C final JILocalCoClass javaComponent = new JILocalCoClass ( new JILocalInterfaceDefinition ( "6FBA474D-43AC-11CE-9A0E-00AA0062BB4C" ), SysInfoEvents.class ); javaComponent.getInterfaceDefinition ().addMethodDescriptor ( new JILocalMethodDescriptor ( "PowerStatusChanged", 8, null ) ); javaComponent.getInterfaceDefinition ().addMethodDescriptor ( new JILocalMethodDescriptor ( "TimeChanged", 3, null ) ); this.identifier = JIObjectFactory.attachEventHandler ( this.sysInfoServer, "6FBA474D-43AC-11CE-9A0E-00AA0062BB4C", JIObjectFactory.buildObject ( this.session, javaComponent ) ); try { Thread.sleep ( 3000 ); } catch ( final InterruptedException e ) { // TODO Auto-generated catch block e.printStackTrace (); } //for call backs }
/**Creates the method descriptor. The method number is set by the order in which this instance is * added to the <code>JILocalInterfaceDefinition</code>. This number is incremented by 1 for each subsequent * and new addition into interface definition. * * @param methodName name of the method. * @param parameters pass <code>null</code> if the method has no parameters. */ public JILocalMethodDescriptor(String methodName,JILocalParamsDescriptor parameters) { this.methodName = methodName; setParameterObject(parameters); }
/** * Removes the method descriptor identified by it's name. * <p> * <p> * Please note that removal of a sequential method can have unpredictable * results during a call. <br> * * @param methodName * @see #addMethodDescriptor(JILocalMethodDescriptor) */ public void removeMethodDescriptor ( final String methodName ) { final JILocalMethodDescriptor methodDescriptor = (JILocalMethodDescriptor)this.nameVsMethodInfo.remove ( methodName ); if ( methodDescriptor != null ) { this.nameVsMethodInfo.remove ( new Integer ( methodDescriptor.getMethodNum () ) ); } }
/** * Removes the method descriptor identified by it's number. * <p> * Please note that removal of a sequential method can have unpredictable * results during a call. <br> * * @param opnum * @see #addMethodDescriptor(JILocalMethodDescriptor) */ public void removeMethodDescriptor ( final int opnum ) { final JILocalMethodDescriptor methodDescriptor = (JILocalMethodDescriptor)this.opnumVsMethodInfo.remove ( new Integer ( opnum ) ); if ( methodDescriptor != null ) { this.nameVsMethodInfo.remove ( methodDescriptor.getMethodName () ); } }
/** * Adds a Method Descriptor. Methods <b>must</b> be added in the same order * as they appear in the IDL. * <p> * Please note that overloaded methods are not allowed. * * @param methodDescriptor * @throws IllegalArgumentException * if a method by the same name already exists. */ public void addMethodDescriptor ( final JILocalMethodDescriptor methodDescriptor ) { if ( this.nameVsMethodInfo.containsKey ( methodDescriptor.getMethodName () ) ) { throw new IllegalArgumentException ( JISystem.getLocalizedMessage ( JIErrorCodes.JI_CALLBACK_OVERLOADS_NOTALLOWED ) ); } methodDescriptor.setMethodNum ( this.nextNum ); this.nextNum++; this.opnumVsMethodInfo.put ( new Integer ( methodDescriptor.getMethodNum () ), methodDescriptor ); if ( this.dispInterface ) { if ( methodDescriptor.getMethodDispID () == -1 ) { throw new IllegalArgumentException ( JISystem.getLocalizedMessage ( JIErrorCodes.JI_METHODDESC_DISPID_MISSING ) ); } this.dispIdVsMethodInfo.put ( new Integer ( methodDescriptor.getMethodDispID () ), methodDescriptor ); } this.nameVsMethodInfo.put ( methodDescriptor.getMethodName (), methodDescriptor ); }
public static final JILocalCoClass getCoClass(JIOPCEventSink instance){ //Define the onEvent method for this interface JILocalParamsDescriptor oeParams=new JILocalParamsDescriptor(); oeParams.addInParamAsType(Integer.class, JIFlags.FLAG_NULL); oeParams.addInParamAsType(Integer.class, JIFlags.FLAG_NULL); oeParams.addInParamAsType(Integer.class, JIFlags.FLAG_NULL); oeParams.addInParamAsType(Integer.class, JIFlags.FLAG_NULL); oeParams.addInParamAsObject(new JIArray(outStruct(),null,1,true), JIFlags.FLAG_NULL); JILocalMethodDescriptor oeMethod=new JILocalMethodDescriptor("onEvent",0,oeParams); //This identify the JIOPCEventSink and not the interface JILocalInterfaceDefinition def=new JILocalInterfaceDefinition(LOCAL_CLASS_IID,false); def.addMethodDescriptor(oeMethod); JILocalCoClass coClass=(instance==null) ? new JILocalCoClass(def,JIOPCEventSink.class) : new JILocalCoClass(def,instance); ArrayList list = new ArrayList(); //Supported interface list.add(OPC_IID); coClass.setSupportedEventInterfaces(list); return coClass; } }
/** Creates the method descriptor. * * @param methodName name of the method. * @param dispId <code>DISPID</code> of this method as in the <code>IDL</code> or the TypeLibrary. * @param parameters pass <code>null</code> if the method has no parameters. */ public JILocalMethodDescriptor(String methodName,int dispId, JILocalParamsDescriptor parameters) { this.methodName = methodName; this.dispId = dispId; setParameterObject(parameters); }
public static final JILocalCoClass getCoClass ( final JIOPCEventSink instance ) { //Define the onEvent method for this interface final JILocalParamsDescriptor oeParams = new JILocalParamsDescriptor (); oeParams.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL ); oeParams.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL ); oeParams.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL ); oeParams.addInParamAsType ( Integer.class, JIFlags.FLAG_NULL ); oeParams.addInParamAsObject ( new JIArray ( outStruct (), null, 1, true ), JIFlags.FLAG_NULL ); final JILocalMethodDescriptor oeMethod = new JILocalMethodDescriptor ( "onEvent", 0, oeParams ); //This identify the JIOPCEventSink and not the interface final JILocalInterfaceDefinition def = new JILocalInterfaceDefinition ( LOCAL_CLASS_IID, false ); def.addMethodDescriptor ( oeMethod ); final JILocalCoClass coClass = instance == null ? new JILocalCoClass ( def, JIOPCEventSink.class ) : new JILocalCoClass ( def, instance ); final ArrayList list = new ArrayList (); //Supported interface list.add ( OPC_IID ); coClass.setSupportedEventInterfaces ( list ); return coClass; } }