Java 类com.sun.jna.Library 实例源码

项目:gstreamer1.x-java    文件:GNative.java   
private static <T extends Library> T loadNativeLibrary(String name, Class<T> interfaceClass, Map<String, ?> options) {
        T library = interfaceClass.cast(Native.loadLibrary(name, interfaceClass, options));
        boolean needCustom = false;
    search:
        for (Method m : interfaceClass.getMethods())
            for (Class<?> cls : m.getParameterTypes())
                if (cls.isArray() && getConverter(cls.getComponentType()) != null) {
                    needCustom = true;
                    break search;
                }
        if (!needCustom)
            return library;
//        System.out.println("Using custom library proxy for " + interfaceClass.getName());
        return interfaceClass.cast(
                Proxy.newProxyInstance(interfaceClass.getClassLoader(),
                        new Class[]{ interfaceClass }, 
                        new Handler<T>(library, options)));
    }
项目:gst1-java-core    文件:GNative.java   
private static <T extends Library> T loadNativeLibrary(String name, Class<T> interfaceClass, Map<String, ?> options) {
        T library = interfaceClass.cast(Native.loadLibrary(name, interfaceClass, options));
        boolean needCustom = false;
    search:
        for (Method m : interfaceClass.getMethods())
            for (Class<?> cls : m.getParameterTypes())
                if (cls.isArray() && getConverter(cls.getComponentType()) != null) {
                    needCustom = true;
                    break search;
                }
        if (!needCustom)
            return library;
//        System.out.println("Using custom library proxy for " + interfaceClass.getName());
        return interfaceClass.cast(
                Proxy.newProxyInstance(interfaceClass.getClassLoader(),
                        new Class[]{ interfaceClass }, 
                        new Handler<T>(library, options)));
    }
项目:java-gobject    文件:GNative.java   
private static <T extends Library> T loadNativeLibrary(String name, Class<T> interfaceClass, Map<String, ?> options) {
        T library = interfaceClass.cast(Native.loadLibrary(name, interfaceClass, options));
        boolean needCustom = false;
        for (Method m : interfaceClass.getMethods()) {
            for (Class<?> cls : m.getParameterTypes()) {
                if (cls.isArray() && getConverter(cls.getComponentType()) != null) {
                    needCustom = true;
                }
            }
        }

        //
        // If no custom conversions are needed, just return the JNA proxy
        //
        if (!needCustom) {
            return library;
        } else {
//            System.out.println("Using custom library proxy for " + interfaceClass.getName());
            return interfaceClass.cast(Proxy.newProxyInstance(interfaceClass.getClassLoader(), 
                new Class[]{ interfaceClass }, new Handler<T>(library, options)));
        }
    }
项目:java-gobject    文件:GNative.java   
private static <T extends Library> T loadWin32Library(String name, Class<T> interfaceClass, Map<String, ?> options) {        
    //
    // gstreamer on win32 names the dll files one of foo.dll, libfoo.dll and libfoo-0.dll
    //
    String[] nameFormats = { 
        "%s", "lib%s", "lib%s-0",                   
    };
    for (int i = 0; i < nameFormats.length; ++i) {
        try {
            return interfaceClass.cast(loadNativeLibrary(String.format(nameFormats[i], name), interfaceClass, options));
        } catch (UnsatisfiedLinkError ex) {                
            continue;
        }
    }
    throw new UnsatisfiedLinkError("Could not load library " + name);
}
项目:jnasmartcardio    文件:Winscard.java   
public static WinscardLibInfo openLib() {
    String libraryName = Platform.isWindows() ? WINDOWS_PATH : Platform.isMac() ? MAC_PATH : PCSC_PATH;
    HashMap<String, Object> options = new HashMap<String, Object>();
    if (Platform.isWindows()) {
        options.put(Library.OPTION_FUNCTION_MAPPER, new WindowsFunctionMapper());
    } else if (Platform.isMac()) {
        options.put(Library.OPTION_FUNCTION_MAPPER, new MacFunctionMapper());
    }
    WinscardLibrary lib = (WinscardLibrary) Native.loadLibrary(libraryName, WinscardLibrary.class, options);
    NativeLibrary nativeLibrary = NativeLibrary.getInstance(libraryName);
    // SCARD_PCI_* is #defined to the following symbols (both pcsclite and winscard)
    ScardIoRequest SCARD_PCI_T0 = new ScardIoRequest(nativeLibrary.getGlobalVariableAddress("g_rgSCardT0Pci"));
    ScardIoRequest SCARD_PCI_T1 = new ScardIoRequest(nativeLibrary.getGlobalVariableAddress("g_rgSCardT1Pci"));
    ScardIoRequest SCARD_PCI_RAW = new ScardIoRequest(nativeLibrary.getGlobalVariableAddress("g_rgSCardRawPci"));
    SCARD_PCI_T0.read();
    SCARD_PCI_T1.read();
    SCARD_PCI_RAW.read();
    SCARD_PCI_T0.setAutoSynch(false);
    SCARD_PCI_T1.setAutoSynch(false);
    SCARD_PCI_RAW.setAutoSynch(false);
    return new WinscardLibInfo(lib, SCARD_PCI_T0, SCARD_PCI_T1, SCARD_PCI_RAW);
}
项目:gstreamer1.x-java    文件:GNative.java   
public static synchronized <T extends Library> T loadLibrary(String name, Class<T> interfaceClass, Map<String, ?> options) {
    if (!Platform.isWindows())
        return loadNativeLibrary(name, interfaceClass, options);
    for (String format : windowsNameFormats)
        try {
            return interfaceClass.cast(loadNativeLibrary(String.format(format, name), interfaceClass, options));
        } catch (UnsatisfiedLinkError ex) {
            continue;
        }
    throw new UnsatisfiedLinkError("Could not load library: " + name);
}
项目:gstreamer1.x-java    文件:GstNative.java   
public static <T extends Library> T load(String libraryName, Class<T> interfaceClass) {
    for (String format : nameFormats)
        try {
            return GNative.loadLibrary(String.format(format, libraryName), interfaceClass, options);
        } catch (UnsatisfiedLinkError ex) {
            continue;
        }
    throw new UnsatisfiedLinkError("Could not load library: " + libraryName);
}
项目:gst1-java-core    文件:GNative.java   
public static synchronized <T extends Library> T loadLibrary(String name, Class<T> interfaceClass, Map<String, ?> options) {
    for (String format : nameFormats)
        try {
            return loadNativeLibrary(String.format(format, name), interfaceClass, options);
        } catch (UnsatisfiedLinkError ex) {
            continue;
        }
    throw new UnsatisfiedLinkError("Could not load library: " + name);
}
项目:gst1-java-core    文件:GstNative.java   
public static <T extends Library> T load(String libraryName, Class<T> interfaceClass) {
    for (String format : nameFormats)
        try {
            return GNative.loadLibrary(String.format(format, libraryName), interfaceClass, options);
        } catch (UnsatisfiedLinkError ex) {
            continue;
        }
    throw new UnsatisfiedLinkError("Could not load library: " + libraryName);
}
项目:space-cubes    文件:SystemNativesHelper.java   
/**
 * Returns the correct userDataFolder for the given application name.
 */
public static String defaultDirectory() {
    // default
    String folder = "." + File.separator;

    if (isMac()) {
        folder = System.getProperty("user.home") + File.separator + "Library" + File.separator
                 + "Application Support";
    } else if (isWindows()) {

        Map<String, Object> options = Maps.newHashMap();
        options.put(Library.OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
        options.put(Library.OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);

        HWND hwndOwner   = null;
        int nFolder      = Shell32.CSIDL_LOCAL_APPDATA;
        HANDLE hToken    = null;
        int dwFlags      = Shell32.SHGFP_TYPE_CURRENT;
        char pszPath[]   = new char[Shell32.MAX_PATH];
        Shell32 instance = (Shell32) Native.loadLibrary("shell32", Shell32.class, options);
        int hResult      = instance.SHGetFolderPath(hwndOwner, nFolder, hToken, dwFlags, pszPath);
        if (Shell32.S_OK == hResult) {

            String path = new String(pszPath);
            int len     = path.indexOf('\0');
            folder      = path.substring(0, len);
        } else {
            System.err.println("Error: " + hResult);
        }
    }

    folder = folder + File.separator + "SpaceCubes" + File.separator;

    return folder;
}
项目:openhab-hdl    文件:k8055Binding.java   
protected boolean connect() {
    try {
        if (sysLibrary == null) {
            logger.debug("Loading native code library...");
            sysLibrary = (LibK8055) Native
                    .synchronizedLibrary((Library) Native.loadLibrary(
                            "k8055", LibK8055.class));
            logger.debug("Done loading native code library");
        }

        if (!connected) {
            if (sysLibrary.OpenDevice(boardNo) == boardNo) {
                connected = true;

                // We don't really know the existing state - so this results
                // in the state of all inputs being republished
                lastDigitalInputs = -1;
                logger.info("K8055: Connect to board: " + boardNo
                        + " succeeeded.");
            } else {
                logger.error("K8055: Connect to board: " + boardNo
                        + " failed.");
            }
        }
        ;
    } catch (Exception e) {
        logger.error(
                "Failed to load K8055 native library.  Please check the libk8055 and jna native libraries are in the Java library path. ",
                e);
    }

    return connected;
}
项目:SPIM_Registration    文件:NativeLibraryTools.java   
public static < L extends Library > L loadNativeLibrary( ArrayList< String > potentialNames, final Class< L > library )
{
    final GenericDialogPlus gd = new GenericDialogPlus( "Specify path of native library" );

    final String directory;

    if ( defaultDirectory == null )
        directory = IJ.getDirectory( "ImageJ" );
    else
        directory = defaultDirectory;

    final File dir;

    if ( directory == null || directory.equals( "null/") )
        dir = new File( "" );
    else
        dir = new File( directory );

    gd.addDirectoryField( "CUDA_Directory", dir.getAbsolutePath(), 80 );

    gd.showDialog();

    if ( gd.wasCanceled() )
        return null;

    return loadNativeLibrary( potentialNames, new File( defaultDirectory = gd.getNextString() ), library );
}
项目:openhab1-addons    文件:k8055Binding.java   
protected boolean connect() {
    try {
        if (sysLibrary == null) {
            logger.debug("Loading native code library...");
            sysLibrary = (LibK8055) Native
                    .synchronizedLibrary((Library) Native.loadLibrary("k8055", LibK8055.class));
            logger.debug("Done loading native code library");
        }

        if (!connected) {
            if (sysLibrary.OpenDevice(boardNo) == boardNo) {
                connected = true;

                // We don't really know the existing state - so this results
                // in the state of all inputs being republished
                lastDigitalInputs = -1;
                logger.info("K8055: Connect to board: " + boardNo + " succeeeded.");
            } else {
                logger.error("K8055: Connect to board: " + boardNo + " failed.");
            }
        }
        ;
    } catch (Exception e) {
        logger.error(
                "Failed to load K8055 native library.  Please check the libk8055 and jna native libraries are in the Java library path. ",
                e);
    }

    return connected;
}
项目:native-c    文件:JnaNativeInterface.java   
@Override
public INativeLibrary createLibrary(String name, Object callingConvention) {
    Map<String, Object> options = new HashMap<>(2);
    if (callingConvention == INativeFunction.CallingConventionCdecl) {
        options.put(Library.OPTION_CALLING_CONVENTION,
                Function.C_CONVENTION);
    } else if (callingConvention == INativeFunction.CallingConventionStdcall) {
        options.put(Library.OPTION_CALLING_CONVENTION,
                Function.ALT_CONVENTION);
    } else {
        throw new IllegalArgumentException("illegal calling convention");
    }
    options.put(Library.OPTION_OPEN_FLAGS, -1);
    return new JnaNativeLibrary(this, name, options);
}
项目:gstreamer1.x-java    文件:GstNative.java   
public static <T extends Library> T load(Class<T> interfaceClass) {
    return load("gstreamer", interfaceClass);
}
项目:gst1-java-core    文件:GstNative.java   
public static <T extends Library> T load(Class<T> interfaceClass) {
    return load("gstreamer", interfaceClass);
}
项目:omr    文件:TestDll.java   
/**
 * @param args
 * @throws IOException 
 */
public static void main(final String[] args) throws IOException {

    Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);
    final IConsultaOnLineJNA consultaOnLine = (IConsultaOnLineJNA) library;

    String filepath = JOptionPane.showInputDialog("Digite o caminho do XML a ser enviado a DLL:");

    File file = new File(filepath);
    System.out.println("Buscando XML " + file.getAbsolutePath() + " ...");
    if(!file.exists()){
        System.out.println("Arquivo XML " + file.getAbsolutePath() + " n�o encontrado!");
        System.exit(1);
    }
    System.out.println("XML " + file.getAbsolutePath() + " encontrado!");

    System.out.println("Convertendo XML para String " + file.getAbsolutePath() + " ...");
    final String xml = obterXML(new BufferedReader(new FileReader(file)));
    System.out.println("XML convertido para String " + xml + " com sucesso!");

    int qtdeAcessos = Integer.parseInt(JOptionPane.showInputDialog("Digite o n�mero de threads a serem executadas:"));
    System.out.println("Quantidade de threads: " + qtdeAcessos);

    final String caminhoDLL = JOptionPane.showInputDialog("Digite o caminho do diret�rio EVServer:");
    System.out.println("Caminho real das DLLs: " + caminhoDLL);

    final String tipoServico = JOptionPane.showInputDialog("Digite o tipo de servi�o a ser consultado:");
    System.out.println();

    final JFrame frame = new JFrame("Resultado EV Server");
    final JTextArea textarea = new JTextArea();
    textarea.setColumns(100);
    textarea.setRows(40);
    final JScrollPane scroll = new JScrollPane(textarea);
    scroll.setAutoscrolls(true);
    frame.add(scroll);
    frame.setSize(200, 150);
    frame.pack();
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final ThreadGroup group = new ThreadGroup("Group");

    for(int i = 0; i < qtdeAcessos; i++){
        Thread thread = new Thread(group, new Runnable() {
            @Override
            public void run() {
                textarea.append("Iniciando thread " + Thread.currentThread().getName() + " ...\n");
                long time = System.currentTimeMillis();
                String retorno = consultaOnLine.DBI_EfetuaConsultaServico(Integer.parseInt(tipoServico), xml, caminhoDLL, caminhoDLL);
                textarea.append(Thread.currentThread().getName() + ": Retorno da DLL: \n" + retorno + "\n");
                textarea.append(Thread.currentThread().getName() + ": Tempo de resposta: " + ((System.currentTimeMillis() - time) / 1000) + "\n");
                textarea.setCaretPosition(textarea.getText().length());             
            }
        });
        thread.start();
    }

    while(group.activeCount() > 0);
    textarea.append("Fim da execu��o!");
}
项目:omr    文件:TestJNADll_CRM.java   
/**
     * @param args
     * @return 
     */
    public ResulConsVO testDllValidador(String cnpj,String estado) {
//      Native.setProtected(true);

        Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);

        //library = Native.synchronizedLibrary(library);

        IConsultaOnLineJNA consultaOnLine = (IConsultaOnLineJNA) library;




        long inicio = System.currentTimeMillis();


        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(8, 
                "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?> "
                + "<ParametrosConsulta Versao=\"1.0\">"
                + "<CRM>77342</CRM>"
                + "<Estado>SP</Estado>"
                + "<Proxy>"
                + "<Ativo>false</Ativo>"
                + "<Usuario/>"
                + "<Senha/>"
                + "<Host/>"
                + "<Porta/>"
                + "</Proxy>"
                + "</ParametrosConsulta>",

                "C:\\EV Server", "C:\\EV Server");      


        /*
        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(3,
        "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
        + "<ParametrosConsulta Versao=\"1.0\"> "
        + "<Municipio>CAMPINAS</Municipio>" + "<Estado>SP</Estado>"

        + "<Proxy>"
            + "<Ativo>true</Ativo>"
            + "<Usuario>/"
            + "<Senha/>"
            + "<Host/>"
            + "<Porta/>"
        + "</Proxy>" + 
        "</ParametrosConsulta>", 
        "C:\\EV Server", "C:\\EV Server");
        */
        System.out.println(resultado);


        ResulConsVO result = unMarshall(resultado);

        Set<DadosRetInstVO> dadosRetInst = result.getRegistrosRetorno();
        if(!result.getCodErro().equals(10000)){
        System.out.println("Inicio results..."+result.getCodErro()+" "+result.getErro());
        }

        for (DadosRetInstVO dadosRetInstVO : dadosRetInst) {
            RetornoCronometro retornoCronometro = new RetornoCronometro(dadosRetInstVO,inicio,System.currentTimeMillis());
            TestJNADll_CRM.retornos.add(retornoCronometro);

            System.out.print(retornoCronometro.fim - retornoCronometro.inicio+" ");
            System.out.print(retornoCronometro.dadosRetInstVO.getRazaoSocial());
            System.out.println();
        }
        //System.out.println("...fim results");



        return null;
    }
项目:omr    文件:TestJNADll_IBGE.java   
/**
     * @param args
     * @return 
     */
    public ResulConsVO testDllValidador(String cnpj,String estado) {
//      Native.setProtected(true);

        Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);

        //library = Native.synchronizedLibrary(library);

        IConsultaOnLineJNA consultaOnLine = (IConsultaOnLineJNA) library;




        long inicio = System.currentTimeMillis();


        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(10,    
                "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
                + "<ParametrosConsulta Versao=\"1.0\"> "
                + "<Municipio>campinas</Municipio>"
                + "<Estado>SP</Estado>"
                + "<Proxy>"
                    + "<Ativo>false</Ativo>"
                    + "<Usuario/>"
                    + "<Senha/>"
                    + "<Host/>"
                    + "<Porta/>"
                + "</Proxy>"
                + "</ParametrosConsulta>",

                "C:\\EV Server", "C:\\EV Server");      


        /*
        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(3,
        "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
        + "<ParametrosConsulta Versao=\"1.0\"> "
        + "<Municipio>CAMPINAS</Municipio>" + "<Estado>SP</Estado>"

        + "<Proxy>"
            + "<Ativo>true</Ativo>"
            + "<Usuario>/"
            + "<Senha/>"
            + "<Host/>"
            + "<Porta/>"
        + "</Proxy>" + 
        "</ParametrosConsulta>", 
        "C:\\EV Server", "C:\\EV Server");
        */
        System.out.println(resultado);


        ResulConsVO result = unMarshall(resultado);

        Set<DadosRetInstVO> dadosRetInst = result.getRegistrosRetorno();
        if(!result.getCodErro().equals(10000)){
        System.out.println("Inicio results..."+result.getCodErro()+" "+result.getErro());
        }

        for (DadosRetInstVO dadosRetInstVO : dadosRetInst) {
            RetornoCronometro retornoCronometro = new RetornoCronometro(dadosRetInstVO,inicio,System.currentTimeMillis());
            TestJNADll_IBGE.retornos.add(retornoCronometro);

            System.out.print(retornoCronometro.fim - retornoCronometro.inicio+" ");
            System.out.print(retornoCronometro.dadosRetInstVO.getRazaoSocial());
            System.out.println();
        }
        //System.out.println("...fim results");



        return null;
    }
项目:omr    文件:TestJNADll_SUFRAMA.java   
/**
     * @param args
     * @return 
     */
    public ResulConsVO testDllValidador(String cnpj,String estado) {
//      Native.setProtected(true);

        Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);

        //library = Native.synchronizedLibrary(library);

        IConsultaOnLineJNA consultaOnLine = (IConsultaOnLineJNA) library;




        long inicio = System.currentTimeMillis();


        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(5, 
                "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
                + "<ParametrosConsulta Versao=\"1.0\">"
                + "<Valor>05156224000100</Valor>"
                + "<Proxy>"
                + "<Ativo>false</Ativo>"
                + "<Usuario/>"
                + "<Senha/>"
                + "<Host/>"
                + "<Porta/>"
                + "</Proxy>"
                + "</ParametrosConsulta>",

                "C:\\EV Server", "C:\\EV Server");      


        /*
        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(3,
        "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
        + "<ParametrosConsulta Versao=\"1.0\"> "
        + "<Municipio>CAMPINAS</Municipio>" + "<Estado>SP</Estado>"

        + "<Proxy>"
            + "<Ativo>true</Ativo>"
            + "<Usuario>/"
            + "<Senha/>"
            + "<Host/>"
            + "<Porta/>"
        + "</Proxy>" + 
        "</ParametrosConsulta>", 
        "C:\\EV Server", "C:\\EV Server");
        */
        System.out.println(resultado);


        ResulConsVO result = unMarshall(resultado);

        Set<DadosRetInstVO> dadosRetInst = result.getRegistrosRetorno();
        if(!result.getCodErro().equals(10000)){
        System.out.println("Inicio results..."+result.getCodErro()+" "+result.getErro());
        }

        for (DadosRetInstVO dadosRetInstVO : dadosRetInst) {
            RetornoCronometro retornoCronometro = new RetornoCronometro(dadosRetInstVO,inicio,System.currentTimeMillis());
            TestJNADll_SUFRAMA.retornos.add(retornoCronometro);

            System.out.print(retornoCronometro.fim - retornoCronometro.inicio+" ");
            System.out.print(retornoCronometro.dadosRetInstVO.getRazaoSocial());
            System.out.println();
        }
        //System.out.println("...fim results");



        return null;
    }
项目:omr    文件:TestJNADll.java   
/**
     * @param args
     * @return 
     */
    public ResulConsVO testDllValidador(String cnpj,String estado) {
//      Native.setProtected(true);

        Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);

        //library = Native.synchronizedLibrary(library);

        IConsultaOnLineJNA consultaOnLine = (IConsultaOnLineJNA) library;




        long inicio = System.currentTimeMillis();


        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(3, 
                "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" +
                "<ParametrosConsulta Versao=\"1.0\">" +
                "<TipoConsulta>0</TipoConsulta>" +
                "<Valor>"+cnpj+"</Valor>" +
                "<Estado>"+estado+"</Estado>" +
                "<Proxy>" +
                "<Ativo>false</Ativo>" +
                    "<Usuario/>" +
                    "<Senha/>" +
                    "<Host/>" +
                    "<Porta/>" +
                "</Proxy>" +
                "</ParametrosConsulta>",

                "C:\\EV Server", "C:\\EV Server");      


        /*
        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(3,
        "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
        + "<ParametrosConsulta Versao=\"1.0\"> "
        + "<Municipio>CAMPINAS</Municipio>" + "<Estado>SP</Estado>"

        + "<Proxy>"
            + "<Ativo>true</Ativo>"
            + "<Usuario>/"
            + "<Senha/>"
            + "<Host/>"
            + "<Porta/>"
        + "</Proxy>" + 
        "</ParametrosConsulta>", 
        "C:\\EV Server", "C:\\EV Server");
        */
        System.out.println(resultado);


        ResulConsVO result = unMarshall(resultado);

        Set<DadosRetInstVO> dadosRetInst = result.getRegistrosRetorno();
        if(!result.getCodErro().equals(10000)){
        System.out.println("Inicio results..."+result.getCodErro()+" "+result.getErro());
        }

        for (DadosRetInstVO dadosRetInstVO : dadosRetInst) {
            RetornoCronometro retornoCronometro = new RetornoCronometro(dadosRetInstVO,inicio,System.currentTimeMillis());
            TestJNADll.retornos.add(retornoCronometro);

            System.out.print(retornoCronometro.fim - retornoCronometro.inicio+" ");
            System.out.print(retornoCronometro.dadosRetInstVO.getRazaoSocial());
            System.out.println();
        }
        //System.out.println("...fim results");



        return null;
    }
项目:omr    文件:TestJNADll_ANP.java   
/**
     * @param args
     * @return 
     */
    public ResulConsVO testDllValidador(String cnpj,String estado) {
//      Native.setProtected(true);

        Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);

        //library = Native.synchronizedLibrary(library);

        IConsultaOnLineJNA consultaOnLine = (IConsultaOnLineJNA) library;




        long inicio = System.currentTimeMillis();


        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(13,    
                "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
                + "<ParametrosConsulta Versao=\"1.0\">"
                + "<Valor>45544368000159</Valor>"
                + "<Proxy>"
                    + "<Ativo>false</Ativo>"
                    + "<Usuario/>"
                    + "<Senha/>"
                    + "<Host/>"
                    + "<Porta/>"
                + "</Proxy>"
                + "</ParametrosConsulta>",

                "C:\\EV Server", "C:\\EV Server");      


        /*
        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(3,
        "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
        + "<ParametrosConsulta Versao=\"1.0\"> "
        + "<Municipio>CAMPINAS</Municipio>" + "<Estado>SP</Estado>"

        + "<Proxy>"
            + "<Ativo>true</Ativo>"
            + "<Usuario>/"
            + "<Senha/>"
            + "<Host/>"
            + "<Porta/>"
        + "</Proxy>" + 
        "</ParametrosConsulta>", 
        "C:\\EV Server", "C:\\EV Server");
        */
        System.out.println(resultado);


        ResulConsVO result = unMarshall(resultado);

        Set<DadosRetInstVO> dadosRetInst = result.getRegistrosRetorno();
        if(!result.getCodErro().equals(10000)){
        System.out.println("Inicio results..."+result.getCodErro()+" "+result.getErro());
        }

        for (DadosRetInstVO dadosRetInstVO : dadosRetInst) {
            RetornoCronometro retornoCronometro = new RetornoCronometro(dadosRetInstVO,inicio,System.currentTimeMillis());
            TestJNADll_ANP.retornos.add(retornoCronometro);

            System.out.print(retornoCronometro.fim - retornoCronometro.inicio+" ");
            System.out.print(retornoCronometro.dadosRetInstVO.getRazaoSocial());
            System.out.println();
        }
        //System.out.println("...fim results");



        return null;
    }
项目:omr    文件:TestJNADll_ANVISA.java   
/**
     * @param args
     * @return 
     */
    public ResulConsVO testDllValidador(String cnpj,String estado) {
//      Native.setProtected(true);

        Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);

        //library = Native.synchronizedLibrary(library);

        IConsultaOnLineJNA consultaOnLine = (IConsultaOnLineJNA) library;




        long inicio = System.currentTimeMillis();


        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(9, 
                "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
                + "<ParametrosConsulta Versao=\"1.0\">"
                + "<CNPJ>61577870000112</CNPJ>"
                + "<Proxy>"
                + "<Ativo>false</Ativo>"
                + "<Usuario/>"
                + "<Senha/>"
                + "<Host/>"
                + "<Porta/>"
                + "</Proxy>"
                + "</ParametrosConsulta>",

                "C:\\EV Server", "C:\\EV Server");      


        /*
        String resultado  = consultaOnLine.DBI_EfetuaConsultaServico(3,
        "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
        + "<ParametrosConsulta Versao=\"1.0\"> "
        + "<Municipio>CAMPINAS</Municipio>" + "<Estado>SP</Estado>"

        + "<Proxy>"
            + "<Ativo>true</Ativo>"
            + "<Usuario>/"
            + "<Senha/>"
            + "<Host/>"
            + "<Porta/>"
        + "</Proxy>" + 
        "</ParametrosConsulta>", 
        "C:\\EV Server", "C:\\EV Server");
        */
        System.out.println(resultado);


        ResulConsVO result = unMarshall(resultado);

        Set<DadosRetInstVO> dadosRetInst = result.getRegistrosRetorno();
        if(!result.getCodErro().equals(10000)){
        System.out.println("Inicio results..."+result.getCodErro()+" "+result.getErro());
        }

        for (DadosRetInstVO dadosRetInstVO : dadosRetInst) {
            RetornoCronometro retornoCronometro = new RetornoCronometro(dadosRetInstVO,inicio,System.currentTimeMillis());
            TestJNADll_ANVISA.retornos.add(retornoCronometro);

            System.out.print(retornoCronometro.fim - retornoCronometro.inicio+" ");
            System.out.print(retornoCronometro.dadosRetInstVO.getRazaoSocial());
            System.out.println();
        }
        //System.out.println("...fim results");



        return null;
    }
项目:java-gobject    文件:GNative.java   
public static <T extends Library> T loadLibrary(String name, Class<T> interfaceClass) {
    return loadLibrary(name, interfaceClass, defaultOptions);
}
项目:java-gobject    文件:GNative.java   
public static <T extends Library> T loadLibrary(String name, Class<T> interfaceClass, Map<String, ?> options) {
    if (Platform.isWindows()) {
        return loadWin32Library(name, interfaceClass, options);
    }
    return loadNativeLibrary(name, interfaceClass, options);
}
项目:jpraat    文件:NativeLibraryOptions.java   
public NativeLibraryOptions() {
    super();

    put(Library.OPTION_TYPE_MAPPER, new NativeTypeMapper());
}
项目:SPIM_Registration    文件:NativeLibraryTools.java   
public static < L extends Library > L loadNativeLibrary( final Class< L > library )
{
    final ArrayList< String > names = new ArrayList< String >();
    return loadNativeLibrary( names, library );
}
项目:SPIM_Registration    文件:NativeLibraryTools.java   
public static < L extends Library > L loadNativeLibrary( final String potentialName, final Class< L > library )
{
    final ArrayList< String > names = new ArrayList< String >();
    names.add( potentialName );
    return loadNativeLibrary( names, library );
}
项目:omr    文件:ValidadorFacadeImpl.java   
public ValidadorFacadeImpl() {
    log.debug("Instanciando servico!");
    tipoServicoXML = new TiposServicoXMLFactory();
    Native.setProtected(true);



    Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);
    library = Native.synchronizedLibrary(library);


    consultaOnLine = (IConsultaOnLineJNA)library;
}
项目:omr    文件:ValidadorFacadeFakeImpl.java   
public ValidadorFacadeFakeImpl() {
    log.debug("Instanciando servico!");
    tipoServicoXML = new TiposServicoXMLFactory();
    Native.setProtected(true);



    Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);
    library = Native.synchronizedLibrary(library);


    consultaOnLine = (IConsultaOnLineJNA)library;
}
项目:omr    文件:ValidadorFacadeImpl.java   
public ValidadorFacadeImpl() {
    log.debug("Instanciando servico!");
    tipoServicoXML = new TiposServicoXMLFactory();
    Native.setProtected(true);



    Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);
    library = Native.synchronizedLibrary(library);


    consultaOnLine = (IConsultaOnLineJNA)library;
}
项目:omr    文件:ConsultaOnlineJNA.java   
public ConsultaOnlineJNA() {
    Native.setProtected(true);

    Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);

    this.consultaOnLine = (IConsultaOnLineJNA)Native.synchronizedLibrary(library); 
}
项目:omr    文件:ConsultaOnlineProcessoEscravo.java   
/**
 * Carrega dll de consulta on line
 */
protected IConsultaOnLineJNA getConsultaOnLineJNA() {
    Native.setProtected(true);

    Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);

    library = Native.synchronizedLibrary(library);

    IConsultaOnLineJNA consultaOnLine = (IConsultaOnLineJNA) library;

    return consultaOnLine;
}
项目:omr    文件:ValidadorFacadeFakeImpl.java   
public ValidadorFacadeFakeImpl() {
    if(log.isDebugEnabled()) log.debug("Instanciando servico!");
    tipoServicoXML = new TiposServicoXMLFactory();
    Native.setProtected(true);



    Library library = (Library) Native.loadLibrary("ConsultaOnLine", IConsultaOnLineJNA.class);
    library = Native.synchronizedLibrary(library);


    consultaOnLine = (IConsultaOnLineJNA)library;
}