Package java.net

Examples of java.net.URLClassLoader.loadClass()


                }
            }
            URLClassLoader loader = new URLClassLoader(list.toArray(new URL[list.size()]),
                    DatabasePoolPortlet.class.getClassLoader());
            try {
                return loader.loadClass(data.driverClass);
            } catch (ClassNotFoundException e) {
                return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here


        String[] arguments = Axis2BuilderUtil.buildArguments(classPath, sei, bindingType, moduleBaseDir, portInfo);
        log.info("wsgen - Generating WSDL with SOAP 1.1 binding type, based on type " + bindingType);
       
        try {
            URLClassLoader loader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
            Class clazz = loader.loadClass("com.sun.tools.ws.spi.WSToolsObjectFactory");
            Method method = clazz.getMethod("newInstance");
            Object factory = method.invoke(null);
            Method method2 = clazz.getMethod("wsgen", OutputStream.class, String[].class);
            OutputStream os = new ByteArrayOutputStream();
            Boolean result = (Boolean) method2.invoke(factory, os, arguments);
View Full Code Here

                // Use reflection to load a class to normally load the
                // rest of the app. Reflection will use the Thread's context class loader
                // and therefore pick up the rest of our libraries.

                Class appClass = classLoader.loadClass("samples.util.SampleAxis2Server");
                Object app = appClass.newInstance();

                Method m = app.getClass().getMethod("startServer",
                        new Class[]{String[].class});
                m.invoke(app, new Object[]{args});
View Full Code Here

    });

    List<Class<?>> found = search.findClasses();

    Assert.assertEquals(1, found.size());
    Assert.assertTrue(found.contains(cl.loadClass(SimpleJarBangClass.class.getName())));

    Assert.assertTrue(search.getJarHits().contains(new File(jarBang.getFile().split("!")[0]).getName()));

    filter = new ClassPathSearchFilter();
    filter.includePackage("com.avaje.ebeaninternal.server");
View Full Code Here

        StatefulKnowledgeSession ksession = kagent.getKnowledgeBase().newStatefulKnowledgeSession();
        List<String> list = new ArrayList<String>();
        ksession.setGlobal("list", list);

        //Create a new KnowledgeAgentInstance and set its instanceId = 2
        Class<?> modelClass = ucl.loadClass("org.drools.agent.test.KnowledgeAgentInstance");
        Object modelInstance = modelClass.newInstance();
        modelClass.getMethod("setInstanceId", int.class).invoke(modelInstance, 2);

        //insert the KnowledgeAgentInstance
        ksession.insert(modelInstance);
View Full Code Here

      cache.start();

      URLClassLoader ucl1 = createOrphanClassLoader();
      Thread.currentThread().setContextClassLoader(ucl1);

      Class clazz1 = ucl1.loadClass(INSTANCE_CLASS_NAME);
      cache.put(fqn("/a"), "key", clazz1.newInstance());

      Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
      try
      {
View Full Code Here

      Region region = cache.getRegion(fqn("/"), true);
      region.registerContextClassLoader(Thread.currentThread().getContextClassLoader());
      region.activate();

      Class clazz1 = ucl1.loadClass(INSTANCE_CLASS_NAME);
      cache.put(fqn("/a"), "key", clazz1.newInstance());

      region.deactivate();
      region.unregisterContextClassLoader();
View Full Code Here

                        .getResourceAsStream("ReferencingAuthenticator.class");
                byte b[] = IOUtils.readBytesFromStream(ins);
               
                ReflectionUtil.setAccessible(m).invoke(loader, ReferencingAuthenticator.class.getName(),
                                                       b, 0, b.length);
                Class<?> cls = loader.loadClass(ReferencingAuthenticator.class.getName());
                Authenticator auth = (Authenticator)cls.getConstructor(Authenticator.class, Authenticator.class)
                    .newInstance(instance, wrapped);
               
                Authenticator.setDefault(auth);
            } catch (Throwable t) {
View Full Code Here

        assertTrue(jarFile.exists());

        URL jarURL = jarFile.toURI().toURL();
        ClassLoader loader = new URLClassLoader(new URL[]{jarURL});
        Class<?> typeInSignedJar = loader.loadClass("TypeInSignedJar");

        assertTrue(imposteriser.canImposterise(typeInSignedJar));
        Object o = imposteriser.imposterise(new VoidAction(), typeInSignedJar);

        assertTrue(typeInSignedJar.isInstance(o));
View Full Code Here

        Collections.reverse(urls);
        URL[] urlArray = urls.toArray(new URL[urls.size()]);
        URLClassLoader cl = new MainClassLoader(urlArray);
        Thread.currentThread().setContextClassLoader(cl);
        try {
            Class clazz = cl.loadClass(program);
            Method main = clazz.getDeclaredMethod("main", new Class[]{String[].class});
            main.invoke(null, new Object[]{programArgs});
        } catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.