| 1 | /* |
| 2 | * $Id: DispatchJavaInterface.java,v 1.2 2005/12/01 06:10:00 hastings Exp $ |
| 3 | * |
| 4 | * (c) Copyright, Moebius Solutions, Inc., 2004 |
| 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This material may be reproduced by or for the U. S. Government |
| 9 | * pursuant to the copyright license under the clause at |
| 10 | * DFARS 252.227-7014 (OCT 2001). |
| 11 | */ |
| 12 | package com.moesol.bindings; |
| 13 | |
| 14 | import com.moesol.bindings.platform_sdk.component_services.GUID; |
| 15 | |
| 16 | public class DispatchJavaInterface extends DispatchJavaCommon { |
| 17 | |
| 18 | protected DispatchJavaInterface() { |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Normally called from JNI code to learn enough information |
| 23 | * to lookup the ITypeInfo for the interface. |
| 24 | * |
| 25 | * @param c class of the interface |
| 26 | * @return DispatchJavaInterface information for {@code c}. |
| 27 | */ |
| 28 | public static DispatchJavaInterface forClass(Class c) { |
| 29 | DispatchJavaInterface r = new DispatchJavaInterface(); |
| 30 | try { |
| 31 | r.fillLibraryInfo(c); |
| 32 | r.fillInterfaceInfo(c); |
| 33 | |
| 34 | return r; |
| 35 | } catch (SecurityException e) { |
| 36 | throw new RuntimeException(e); |
| 37 | } catch (IllegalArgumentException e) { |
| 38 | throw new RuntimeException(e); |
| 39 | } catch (ClassNotFoundException e) { |
| 40 | throw new RuntimeException(e); |
| 41 | } catch (NoSuchFieldException e) { |
| 42 | throw new RuntimeException(e); |
| 43 | } catch (IllegalAccessException e) { |
| 44 | throw new RuntimeException(e); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | private void fillInterfaceInfo(Class c) throws SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException { |
| 49 | setUuid((GUID)getObjectField(c, "IID")); |
| 50 | } |
| 51 | } |