Example usage for java.lang Class getClassLoader

List of usage examples for java.lang Class getClassLoader

Introduction

In this page you can find the example usage for java.lang Class getClassLoader.

Prototype

@CallerSensitive
@ForceInline 
public ClassLoader getClassLoader() 

Source Link

Document

Returns the class loader for the class.

Usage

From source file:org.codice.ddf.cxf.SecureCxfClientFactory.java

/**
 * Constructs a factory that will return security-aware cxf clients. Once constructed,
 * use the getClient* methods to retrieve a fresh client  with the same configuration.
 * <p>//from  w  w  w.  j  av  a 2 s .co  m
 * This factory can and should be cached. The clients it constructs should not be.
 *
 * @param endpointUrl    the remote url to connect to
 * @param interfaceClass an interface representing the resource at the remote url
 * @param providers      optional list of providers to further configure the client
 * @param interceptor    optional message interceptor for the client
 * @param disableCnCheck disable ssl check for common name / host name match
 * @param allowRedirects allow this client to follow redirects
 */
public SecureCxfClientFactory(String endpointUrl, Class<T> interfaceClass, List<?> providers,
        Interceptor<? extends Message> interceptor, boolean disableCnCheck, boolean allowRedirects) {
    if (StringUtils.isEmpty(endpointUrl) || interfaceClass == null) {
        throw new IllegalArgumentException("Called without a valid URL, will not be able to connect.");
    }

    this.interfaceClass = interfaceClass;
    this.disableCnCheck = disableCnCheck;
    this.allowRedirects = allowRedirects;

    JAXRSClientFactoryBean jaxrsClientFactoryBean = new JAXRSClientFactoryBean();
    jaxrsClientFactoryBean.setServiceClass(interfaceClass);
    jaxrsClientFactoryBean.setAddress(endpointUrl);
    jaxrsClientFactoryBean.setClassLoader(interfaceClass.getClassLoader());
    jaxrsClientFactoryBean.getInInterceptors().add(new LoggingInInterceptor());
    jaxrsClientFactoryBean.getOutInterceptors().add(new LoggingOutInterceptor());

    if (CollectionUtils.isNotEmpty(providers)) {
        jaxrsClientFactoryBean.setProviders(providers);
    }

    if (interceptor != null) {
        jaxrsClientFactoryBean.getInInterceptors().add(interceptor);
    }

    this.clientFactory = jaxrsClientFactoryBean;
}

From source file:org.apache.slider.common.tools.SliderUtils.java

/**
 * Find a containing JAR/*  ww w .jav  a2  s.  c o  m*/
 * @param my_class class to find
 * @return the file or null if it is not found
 * @throws IOException any IO problem, including the class not having a
 * classloader
 */
public static File findContainingJar(Class my_class) throws IOException {
    ClassLoader loader = my_class.getClassLoader();
    if (loader == null) {
        throw new IOException("Class " + my_class + " does not have a classloader!");
    }
    String class_file = my_class.getName().replaceAll("\\.", "/") + ".class";
    Enumeration<URL> urlEnumeration = loader.getResources(class_file);
    if (urlEnumeration == null) {
        throw new IOException("Unable to find resources for class " + my_class);
    }

    for (; urlEnumeration.hasMoreElements();) {
        URL url = urlEnumeration.nextElement();
        if ("jar".equals(url.getProtocol())) {
            String toReturn = url.getPath();
            if (toReturn.startsWith("file:")) {
                toReturn = toReturn.substring("file:".length());
            }
            // URLDecoder is a misnamed class, since it actually decodes
            // x-www-form-urlencoded MIME type rather than actual
            // URL encoding (which the file path has). Therefore it would
            // decode +s to ' 's which is incorrect (spaces are actually
            // either unencoded or encoded as "%20"). Replace +s first, so
            // that they are kept sacred during the decoding process.
            toReturn = toReturn.replaceAll("\\+", "%2B");
            toReturn = URLDecoder.decode(toReturn, "UTF-8");
            String jarFilePath = toReturn.replaceAll("!.*$", "");
            return new File(jarFilePath);
        } else {
            log.info("could not locate JAR containing {} URL={}", my_class, url);
        }
    }
    return null;
}

From source file:com.dilmus.dilshad.scabi.core.DComputeSync.java

public String executeClass(Class<? extends DComputeUnit> cls) throws ClientProtocolException, IOException {
    HttpPost postRequest = new HttpPost("/Compute/Execute/Class");

    Class<? extends DComputeUnit> p = cls;

    String className = p.getName();
    log.debug("executeClass() className  : {}", className);
    String classAsPath = className.replace('.', '/') + ".class";
    log.debug("executeClass() classAsPath  : {}", classAsPath);

    InputStream in = p.getClassLoader().getResourceAsStream(classAsPath);
    byte b[] = DMUtil.toBytesFromInStreamForJavaFiles(in);
    in.close();/*from  w  ww .  ja v  a  2  s . c o  m*/
    //log.debug("executeClass() b[] as string : {}", b.toString());
    String hexStr = DMUtil.toHexString(b);
    //log.debug("executeClass() Hex string is : {}", hexStr);

    DMJson djson1 = new DMJson("TotalComputeUnit", "" + m_TU);
    DMJson djson2 = djson1.add("SplitComputeUnit", "" + m_SU);
    DMJson djson3 = djson2.add("JsonInput", "" + m_jsonStrInput);
    DMJson djson4 = djson3.add("ClassName", className);
    DMJson djson5 = djson4.add("ClassBytes", hexStr);

    log.debug("executeClass() m_jarFilePathList.size() : {}", m_jarFilePathList.size());
    if (m_jarFilePathList.size() > 0) {
        djson5 = addJars(djson5);
        m_jarFilePathList.clear();
    }

    log.debug("executeClass() m_isComputeUnitJarsSet : {}", m_isComputeUnitJarsSet);
    if (m_isComputeUnitJarsSet) {
        djson5 = addComputeUnitJars(djson5);
        m_isComputeUnitJarsSet = false;
        m_dcl = null;
    }

    //StringEntity params = new StringEntity(djson5.toString());
    //postRequest.addHeader("content-type", "application/json");
    //postRequest.setEntity(params);

    postRequest.addHeader("Content-Encoding", "gzip");
    postRequest.addHeader("Accept-Encoding", "gzip");

    //=====================================================================
    ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
    try (GZIPOutputStream gzipstream = new GZIPOutputStream(bytestream)) {
        gzipstream.write(djson5.toString().getBytes("UTF-8"));
    }
    byte[] gzipBytes = bytestream.toByteArray();
    bytestream.close();
    ByteArrayEntity byteEntity = new ByteArrayEntity(gzipBytes);
    postRequest.setEntity(byteEntity);
    //======================================================================

    log.debug("executeClass() executing request to " + m_target + "/Compute/Execute/Class");

    HttpResponse httpResponse = m_httpClient.execute(m_target, postRequest);
    HttpEntity entity = httpResponse.getEntity();

    /* Debugging
    log.debug("executeClass()----------------------------------------");
    log.debug("executeClass() {}",httpResponse.getStatusLine());
    Header[] headers = httpResponse.getAllHeaders();
    for (int i = 0; i < headers.length; i++) {
       log.debug("executeClass() {}", headers[i]);
    }
    log.debug("executeClass()----------------------------------------");
    */

    String jsonString = null;
    if (entity != null) {
        jsonString = EntityUtils.toString(entity);
        log.debug("executeClass() jsonString : {}", jsonString);
    }
    if (null == jsonString)
        return DMJson.error("null");

    return jsonString;
}

From source file:com.dilmus.dilshad.scabi.core.DComputeSync.java

public String executeObject(DComputeUnit obj) throws ClientProtocolException, IOException {
    HttpPost postRequest = new HttpPost("/Compute/Execute/ClassFromObject");

    Class<? extends DComputeUnit> p = obj.getClass();
    String className = p.getName();
    log.debug("executeObject() className  : {}", className);
    String classAsPath = className.replace('.', '/') + ".class";
    log.debug("executeObject() classAsPath  : {}", classAsPath);

    InputStream in = p.getClassLoader().getResourceAsStream(classAsPath);
    byte b[] = DMUtil.toBytesFromInStreamForJavaFiles(in);
    in.close();//from   ww  w. j av  a 2s.c  o  m
    //log.debug("executeObject() b[] as string : {}", b.toString());
    String hexStr = DMUtil.toHexString(b);
    //log.debug("executeObject() Hex string is : {}", hexStr);

    DMJson djson1 = new DMJson("TotalComputeUnit", "" + m_TU);
    DMJson djson2 = djson1.add("SplitComputeUnit", "" + m_SU);
    DMJson djson3 = djson2.add("JsonInput", "" + m_jsonStrInput);
    DMJson djson4 = djson3.add("ClassName", className);
    DMJson djson5 = djson4.add("ClassBytes", hexStr);

    log.debug("executeObject() m_jarFilePathList.size() : {}", m_jarFilePathList.size());
    if (m_jarFilePathList.size() > 0) {
        djson5 = addJars(djson5);
        m_jarFilePathList.clear();
    }

    log.debug("executeObject() m_isComputeUnitJarsSet : {}", m_isComputeUnitJarsSet);
    if (m_isComputeUnitJarsSet) {
        djson5 = addComputeUnitJars(djson5);
        m_isComputeUnitJarsSet = false;
        m_dcl = null;
    }

    //works StringEntity params = new StringEntity(djson5.toString());
    //works postRequest.addHeader("content-type", "application/json");
    //works postRequest.setEntity(params);

    postRequest.addHeader("Content-Encoding", "gzip");
    postRequest.addHeader("Accept-Encoding", "gzip");

    //=====================================================================
    ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
    try (GZIPOutputStream gzipstream = new GZIPOutputStream(bytestream)) {
        gzipstream.write(djson5.toString().getBytes("UTF-8"));
    }
    byte[] gzipBytes = bytestream.toByteArray();
    bytestream.close();
    ByteArrayEntity byteEntity = new ByteArrayEntity(gzipBytes);
    postRequest.setEntity(byteEntity);
    //======================================================================

    log.debug("executeObject() executing request to " + m_target + "/Compute/Execute/ClassFromObject");

    HttpResponse httpResponse = m_httpClient.execute(m_target, postRequest);
    HttpEntity entity = httpResponse.getEntity();

    /* Debugging
    log.debug("executeObject()----------------------------------------");
    log.debug("executeObject() {}",httpResponse.getStatusLine());
    Header[] headers = httpResponse.getAllHeaders();
    for (int i = 0; i < headers.length; i++) {
       log.debug("executeObject() {}", headers[i]);
    }
    log.debug("executeObject()----------------------------------------");
    */

    String jsonString = null;
    if (entity != null) {
        jsonString = EntityUtils.toString(entity);
        log.debug("executeObject() jsonString : {}", jsonString);
    }
    if (null == jsonString)
        return DMJson.error("null");

    return jsonString;
}

From source file:com.panet.imeta.core.plugins.PluginLoader.java

private void fromAnnotation(Annotation annot, FileObject directory, Class<?> match) throws IOException {
    Class type = annot.annotationType();

    if (type == Job.class) {
        Job jobAnnot = (Job) annot;/*from   ww  w  . j  av  a  2s.  c o m*/
        String[] libs = getLibs(directory);
        Set<JobPlugin> jps = (Set<JobPlugin>) this.plugins.get(Job.class);
        JobPlugin pg = new JobPlugin(Plugin.TYPE_PLUGIN, jobAnnot.id(), jobAnnot.type().getDescription(),
                jobAnnot.tooltip(), directory.getURL().getFile(), libs, jobAnnot.image(), match.getName(),
                jobAnnot.categoryDescription());

        pg.setClassLoader(match.getClassLoader());

        jps.add(pg);

    } else if (type == Step.class) {
        Step jobAnnot = (Step) annot;
        String[] libs = getLibs(directory);
        Set<StepPlugin> jps = (Set<StepPlugin>) this.plugins.get(Step.class);
        StepPlugin pg = new StepPlugin(Plugin.TYPE_PLUGIN, jobAnnot.name(), jobAnnot.description(),
                jobAnnot.tooltip(), directory.getURL().getFile(), libs, jobAnnot.image(), match.getName(),
                jobAnnot.categoryDescription(), Const.EMPTY_STRING);

        pg.setClassLoader(match.getClassLoader());

        jps.add(pg);
    }
}

From source file:org.eclipse.jubula.rc.common.AUTServerConfiguration.java

/**
 * Returns an instance of the implementation class for
 * <code>componentClassName</code>.
 * //from  w  w  w  .  j  a  v  a  2 s  .  c  o  m
 * @param componentClass
 *            the class name of the component, e.g javax.swing.JButton
 * @throws UnsupportedComponentException
 *             If the <code>componentClassName</code> has no registered
 *             implementation class.
 * @throws IllegalArgumentException
 *             if the <code>componentClassName</code> is <code>null</code>.
 * @return An instance of the implementation class.
 */
public Object getImplementationClass(Class componentClass)
        throws UnsupportedComponentException, IllegalArgumentException {

    Validate.notNull(componentClass);
    Class currentClass = componentClass;

    String implClassName = (String) m_implClassNames.get(currentClass.getName());
    while (implClassName == null && currentClass.getSuperclass() != null) {
        currentClass = currentClass.getSuperclass();
        implClassName = (String) m_implClassNames.get(currentClass.getName());
    }
    return createInstance(componentClass.getName(), implClassName, currentClass.getClassLoader());
}

From source file:org.bigtester.ate.model.caserunner.CaseRunnerGenerator.java

private String getAllJarsClassPathInMavenLocalRepo() {

    Class cls;
    String retVal;// w  w w .  ja va  2  s  .c  om
    try {
        cls = Class.forName("org.bigtester.ate.TestProjectRunner");//NOPMD
    } catch (ClassNotFoundException e) {
        retVal = System.getProperty("java.class.path") + ":dist/InlineCompiler.jar:target/*.jar";
        return retVal;//NOPMD
    }

    // returns the ClassLoader object associated with this Class
    ClassLoader cLoader = cls.getClassLoader();

    URL[] paths = ((URLClassLoader) cLoader).getURLs();
    OSinfo osinfo = new OSinfo();
    EPlatform platform = osinfo.getOSname();
    String pathSep;
    if (platform == EPlatform.Windows_64 || platform == EPlatform.Windows_32) {
        pathSep = ";";
    } else {
        pathSep = ":";
    }

    retVal = "target" + System.getProperty("file.separator") + "classes" + pathSep + "target"
            + System.getProperty("file.separator") + "*.jar" + pathSep + "dist"
            + System.getProperty("file.separator") + "InlineCompiler.jar";
    for (URL path : paths) {
        try {
            retVal = retVal + pathSep + Paths.get(path.toURI()).toString();
        } catch (URISyntaxException e) {
            throw GlobalUtils.createInternalError("class path resolving error");
        } //NOPMD
    }

    return retVal;
    // String classPath =
    // "target/classes:target/*.jar:/home/peidong/.m2/repository/org/hibernate/hibernate-entitymanager/4.3.6.Final/hibernate-entitymanager-4.3.6.Final.jar:/home/peidong/.m2/repository/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA.jar:/home/peidong/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar:/home/peidong/.m2/repository/org/hibernate/hibernate-core/4.3.6.Final/hibernate-core-4.3.6.Final.jar:/home/peidong/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/home/peidong/.m2/repository/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar:/home/peidong/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/home/peidong/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar:/home/peidong/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar:/home/peidong/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final.jar:/home/peidong/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar:/home/peidong/.m2/repository/org/springframework/spring-orm/4.0.5.RELEASE/spring-orm-4.0.5.RELEASE.jar:/home/peidong/.m2/repository/org/springframework/spring-beans/4.0.5.RELEASE/spring-beans-4.0.5.RELEASE.jar:/home/peidong/.m2/repository/org/springframework/spring-core/4.0.5.RELEASE/spring-core-4.0.5.RELEASE.jar:/home/peidong/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/home/peidong/.m2/repository/org/springframework/spring-jdbc/4.0.5.RELEASE/spring-jdbc-4.0.5.RELEASE.jar:/home/peidong/.m2/repository/org/springframework/spring-tx/4.0.5.RELEASE/spring-tx-4.0.5.RELEASE.jar:/home/peidong/.m2/repository/org/hsqldb/hsqldb/2.3.2/hsqldb-2.3.2.jar:/home/peidong/.m2/repository/org/testng/testng/6.8.8/testng-6.8.8.jar:/home/peidong/.m2/repository/org/beanshell/bsh/2.0b4/bsh-2.0b4.jar:/home/peidong/.m2/repository/com/beust/jcommander/1.27/jcommander-1.27.jar:/home/peidong/.m2/repository/org/seleniumhq/selenium/selenium-java/2.43.1/selenium-java-2.43.1.jar:/home/peidong/.m2/repository/org/seleniumhq/selenium/selenium-chrome-driver/2.43.1/selenium-chrome-driver-2.43.1.jar:/home/peidong/.m2/repository/org/seleniumhq/selenium/selenium-remote-driver/2.43.1/selenium-remote-driver-2.43.1.jar:/home/peidong/.m2/repository/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar:/home/peidong/.m2/repository/org/json/json/20080701/json-20080701.jar:/home/peidong/.m2/repository/org/seleniumhq/selenium/selenium-api/2.43.1/selenium-api-2.43.1.jar:/home/peidong/.m2/repository/org/seleniumhq/selenium/selenium-htmlunit-driver/2.43.1/selenium-htmlunit-driver-2.43.1.jar:/home/peidong/.m2/repository/net/sourceforge/htmlunit/htmlunit/2.15/htmlunit-2.15.jar:/home/peidong/.m2/repository/org/apache/commons/commons-lang3/3.3.2/commons-lang3-3.3.2.jar:/home/peidong/.m2/repository/org/apache/httpcomponents/httpmime/4.3.3/httpmime-4.3.3.jar:/home/peidong/.m2/repository/net/sourceforge/htmlunit/htmlunit-core-js/2.15/htmlunit-core-js-2.15.jar:/home/peidong/.m2/repository/xerces/xercesImpl/2.11.0/xercesImpl-2.11.0.jar:/home/peidong/.m2/repository/net/sourceforge/nekohtml/nekohtml/1.9.21/nekohtml-1.9.21.jar:/home/peidong/.m2/repository/net/sourceforge/cssparser/cssparser/0.9.14/cssparser-0.9.14.jar:/home/peidong/.m2/repository/org/w3c/css/sac/1.3/sac-1.3.jar:/home/peidong/.m2/repository/org/eclipse/jetty/jetty-websocket/8.1.15.v20140411/jetty-websocket-8.1.15.v20140411.jar:/home/peidong/.m2/repository/org/eclipse/jetty/jetty-util/8.1.15.v20140411/jetty-util-8.1.15.v20140411.jar:/home/peidong/.m2/repository/org/eclipse/jetty/jetty-io/8.1.15.v20140411/jetty-io-8.1.15.v20140411.jar:/home/peidong/.m2/repository/org/eclipse/jetty/jetty-http/8.1.15.v20140411/jetty-http-8.1.15.v20140411.jar:/home/peidong/.m2/repository/org/seleniumhq/selenium/selenium-firefox-driver/2.43.1/selenium-firefox-driver-2.43.1.jar:/home/peidong/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/home/peidong/.m2/repository/org/apache/commons/commons-exec/1.1/commons-exec-1.1.jar:/home/peidong/.m2/repository/org/seleniumhq/selenium/selenium-ie-driver/2.43.1/selenium-ie-driver-2.43.1.jar:/home/peidong/.m2/repository/net/java/dev/jna/jna/3.4.0/jna-3.4.0.jar:/home/peidong/.m2/repository/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar:/home/peidong/.m2/repository/org/seleniumhq/selenium/selenium-safari-driver/2.43.1/selenium-safari-driver-2.43.1.jar:/home/peidong/.m2/repository/org/seleniumhq/selenium/selenium-support/2.43.1/selenium-support-2.43.1.jar:/home/peidong/.m2/repository/org/webbitserver/webbit/0.4.15/webbit-0.4.15.jar:/home/peidong/.m2/repository/io/netty/netty/3.5.5.Final/netty-3.5.5.Final.jar:/home/peidong/.m2/repository/org/springframework/spring-test/4.0.5.RELEASE/spring-test-4.0.5.RELEASE.jar:/home/peidong/.m2/repository/org/springframework/spring-context/4.0.5.RELEASE/spring-context-4.0.5.RELEASE.jar:/home/peidong/.m2/repository/org/springframework/spring-expression/4.0.5.RELEASE/spring-expression-4.0.5.RELEASE.jar:/home/peidong/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.7/jcl-over-slf4j-1.7.7.jar:/home/peidong/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar:/home/peidong/.m2/repository/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar:/home/peidong/.m2/repository/ch/qos/logback/logback-core/1.1.2/logback-core-1.1.2.jar:/home/peidong/.m2/repository/ch/qos/logback/logback-access/1.1.2/logback-access-1.1.2.jar:/home/peidong/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar:/home/peidong/.m2/repository/org/springframework/spring-aop/4.0.5.RELEASE/spring-aop-4.0.5.RELEASE.jar:/home/peidong/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/home/peidong/.m2/repository/com/jamonapi/jamon/2.78/jamon-2.78.jar:/home/peidong/.m2/repository/com/hazelcast/hazelcast-all/3.2.3/hazelcast-all-3.2.3.jar:/home/peidong/.m2/repository/net/sourceforge/findbugs/annotations/1.3.2/annotations-1.3.2.jar:/home/peidong/.m2/repository/org/springframework/spring-aspects/4.0.5.RELEASE/spring-aspects-4.0.5.RELEASE.jar:/home/peidong/.m2/repository/cglib/cglib/2.2/cglib-2.2.jar:/home/peidong/.m2/repository/asm/asm/3.1/asm-3.1.jar:/home/peidong/.m2/repository/org/aspectj/aspectjrt/1.7.3/aspectjrt-1.7.3.jar:/home/peidong/.m2/repository/org/aspectj/aspectjweaver/1.7.3/aspectjweaver-1.7.3.jar:/home/peidong/git/problomatic2/problomatic2/problomatic2/target/classes:/home/peidong/Downloads/sts/sts-bundle/sts-3.6.2.RELEASE/plugins/org.junit_4.11.0.v201303080030/junit.jar:/home/peidong/Downloads/sts/sts-bundle/sts-3.6.2.RELEASE/plugins/org.hamcrest.core_1.3.0.v201303031735.jar:/home/peidong/.m2/repository/org/apache/xmlbeans/xmlbeans/2.4.0/xmlbeans-2.4.0.jar:/home/peidong/.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1.jar:/home/peidong/.m2/repository/xalan/xalan/2.7.1/xalan-2.7.1.jar:/home/peidong/.m2/repository/xalan/serializer/2.7.1/serializer-2.7.1.jar:/home/peidong/.m2/repository/com/sun/mail/smtp/1.4.5/smtp-1.4.5.jar:/home/peidong/.m2/repository/com/sun/mail/pop3/1.4.5/pop3-1.4.5.jar:/home/peidong/.m2/repository/com/sun/mail/mailapi/1.4.5/mailapi-1.4.5.jar:/home/peidong/.m2/repository/javax/xml/jsr173/1.0/jsr173-1.0.jar:/home/peidong/.m2/repository/org/apache/bcel/bcel/5.2/bcel-5.2.jar:/home/peidong/.m2/repository/jakarta-regexp/jakarta-regexp/1.4/jakarta-regexp-1.4.jar:/home/peidong/.m2/repository/javax/activation/activation/1.1.1/activation-1.1.1.jar:/home/peidong/.m2/repository/org/apache/ant/ant/1.8.4/ant-1.8.4.jar:/home/peidong/.m2/repository/org/apache/ant/ant-launcher/1.8.4/ant-launcher-1.8.4.jar:/home/peidong/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/peidong/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/peidong/.m2/repository/org/springframework/plugin/spring-plugin-core/1.1.0.RELEASE/spring-plugin-core-1.1.0.RELEASE.jar:/home/peidong/.m2/repository/org/springframework/plugin/spring-plugin-integration/1.0.0.RELEASE/spring-plugin-integration-1.0.0.RELEASE.jar:/home/peidong/.m2/repository/org/springframework/integration/spring-integration-core/2.1.4.RELEASE/spring-integration-core-2.1.4.RELEASE.jar:/home/peidong/.m2/repository/org/springframework/plugin/spring-plugin-metadata/1.1.0.RELEASE/spring-plugin-metadata-1.1.0.RELEASE.jar:/home/peidong/.m2/repository/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar:/home/peidong/.m2/repository/org/codehaus/janino/janino/2.5.16/janino-2.5.16.jar:/home/peidong/.m2/repository/org/projectlombok/lombok/1.14.8/lombok-1.14.8.jar:/home/peidong/.m2/repository/org/dbunit/dbunit/2.5.0/dbunit-2.5.0.jar:/home/peidong/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar:/home/peidong/.m2/repository/org/eclipse/jdt/org.eclipse.jdt.annotation/1.1.0/org.eclipse.jdt.annotation-1.1.0.jar:/home/peidong/.m2/repository/com/google/inject/guice/4.0-beta5/guice-4.0-beta5.jar:/home/peidong/.m2/repository/javax/inject/javax.inject/1/javax.inject-1.jar:/home/peidong/.m2/repository/com/google/guava/guava/16.0.1/guava-16.0.1.jar:/home/peidong/.m2/repository/net/jodah/typetools/0.4.0/typetools-0.4.0.jar:/home/peidong/.m2/repository/com/github/javaparser/javaparser-core/2.0.0/javaparser-core-2.0.0.jar:/home/peidong/.m2/repository/org/jodd/jodd/3.3.8/jodd-3.3.8.jar:/home/peidong/.m2/repository/org/eclipse/aether/aether-api/1.0.2.v20150114/aether-api-1.0.2.v20150114.jar:/home/peidong/.m2/repository/org/apache/maven/maven-aether-provider/3.2.5/maven-aether-provider-3.2.5.jar:/home/peidong/.m2/repository/org/apache/maven/maven-model/3.2.5/maven-model-3.2.5.jar:/home/peidong/.m2/repository/org/apache/maven/maven-model-builder/3.2.5/maven-model-builder-3.2.5.jar:/home/peidong/.m2/repository/org/apache/maven/maven-repository-metadata/3.2.5/maven-repository-metadata-3.2.5.jar:/home/peidong/.m2/repository/org/eclipse/aether/aether-spi/1.0.0.v20140518/aether-spi-1.0.0.v20140518.jar:/home/peidong/.m2/repository/org/eclipse/aether/aether-util/1.0.0.v20140518/aether-util-1.0.0.v20140518.jar:/home/peidong/.m2/repository/org/eclipse/aether/aether-impl/1.0.0.v20140518/aether-impl-1.0.0.v20140518.jar:/home/peidong/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar:/home/peidong/.m2/repository/org/eclipse/aether/aether-connector-basic/1.0.2.v20150114/aether-connector-basic-1.0.2.v20150114.jar:/home/peidong/.m2/repository/org/eclipse/aether/aether-transport-http/1.0.2.v20150114/aether-transport-http-1.0.2.v20150114.jar:/home/peidong/.m2/repository/org/eclipse/aether/aether-transport-file/1.0.2.v20150114/aether-transport-file-1.0.2.v20150114.jar:/home/peidong/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.jar:/home/peidong/.m2/repository/org/apache/maven/maven-compat/3.2.5/maven-compat-3.2.5.jar:/home/peidong/.m2/repository/org/apache/maven/maven-settings/3.2.5/maven-settings-3.2.5.jar:/home/peidong/.m2/repository/org/apache/maven/maven-artifact/3.2.5/maven-artifact-3.2.5.jar:/home/peidong/.m2/repository/org/apache/maven/maven-core/3.2.5/maven-core-3.2.5.jar:/home/peidong/.m2/repository/org/apache/maven/maven-settings-builder/3.2.5/maven-settings-builder-3.2.5.jar:/home/peidong/.m2/repository/org/sonatype/sisu/sisu-guice/3.2.3/sisu-guice-3.2.3-no_aop.jar:/home/peidong/.m2/repository/org/codehaus/plexus/plexus-classworlds/2.5.2/plexus-classworlds-2.5.2.jar:/home/peidong/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar:/home/peidong/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar:/home/peidong/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.21/plexus-interpolation-1.21.jar:/home/peidong/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.plexus/0.3.0.M1/org.eclipse.sisu.plexus-0.3.0.M1.jar:/home/peidong/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar:/home/peidong/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar:/home/peidong/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.0.M1/org.eclipse.sisu.inject-0.3.0.M1.jar:/home/peidong/.m2/repository/org/apache/maven/wagon/wagon-provider-api/2.8/wagon-provider-api-2.8.jar:/home/peidong/.m2/repository/org/apache/maven/wagon/wagon-http-lightweight/2.8/wagon-http-lightweight-2.8.jar:/home/peidong/.m2/repository/org/apache/maven/wagon/wagon-http-shared/2.8/wagon-http-shared-2.8.jar:/home/peidong/.m2/repository/org/jsoup/jsoup/1.7.2/jsoup-1.7.2.jar:/home/peidong/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/home/peidong/.m2/repository/org/apache/httpcomponents/httpclient/4.3.6/httpclient-4.3.6.jar:/home/peidong/.m2/repository/org/apache/httpcomponents/httpcore/4.3.3/httpcore-4.3.3.jar:/home/peidong/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/home/peidong/.m2/repository/org/bigtester/org.bigtester.ate.core/0.0.4-SNAPSHOT/org.bigtester.ate.core-0.0.4-SNAPSHOT.jar";//NOPMD
    // classPath = StringUtils.replace(classPath, "/home/peidong/.m2/",
    // System.getProperty("user.home")+System.getProperty("file.separator")
    // +".m2" + System.getProperty("file.separator"));
    // classPath = StringUtils.replace(classPath, "/",
    // System.getProperty("file.separator"));
    //
    // OSinfo osinfo = new OSinfo();
    // EPlatform platform = osinfo.getOSname();
    // if (platform == EPlatform.Windows_64 ||platform ==
    // EPlatform.Windows_32)
    // {
    // classPath = StringUtils.replace(classPath, ":", ";");
    // }
    //
    // if (classPath == null) classPath = "";
    // return classPath;
    // File localRepoDir = new File( System.getProperty("user.home") +
    // System.getProperty("file.separator") + ".m2" +
    // System.getProperty("file.separator"));
    // Collection<File> files = FileUtils.listFiles(
    // localRepoDir,
    // new RegexFileFilter(".*.(jar)"),
    // DirectoryFileFilter.DIRECTORY
    // );
    // String retVal = "";
    // for (File jar : files) {
    // retVal = retVal + jar.getCanonicalPath() + ":";
    // }
    // return retVal;
}

From source file:org.apache.servicemix.camel.nmr.AttachmentTest.java

private <T> T createPort(QName serviceName, QName portName, Class<T> serviceEndpointInterface,
        boolean enableMTOM) throws Exception {
    Bus bus = BusFactory.getDefaultBus();
    ReflectionServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(bus);/*from w ww.j  a v  a  2  s  . c  om*/
    serviceFactory.setServiceName(serviceName);
    serviceFactory.setServiceClass(serviceEndpointInterface);
    serviceFactory.setWsdlURL(getClass().getResource("/wsdl/mtom_xop.wsdl"));
    Service service = serviceFactory.create();
    EndpointInfo ei = service.getEndpointInfo(portName);
    JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service, ei);
    SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding());
    jaxWsSoapBinding.setMTOMEnabled(enableMTOM);

    Client client = new ClientImpl(bus, jaxwsEndpoint);
    InvocationHandler ih = new JaxWsClientProxy(client, jaxwsEndpoint.getJaxwsBinding());
    Object obj = Proxy.newProxyInstance(serviceEndpointInterface.getClassLoader(),
            new Class[] { serviceEndpointInterface, BindingProvider.class }, ih);
    return serviceEndpointInterface.cast(obj);
}

From source file:it.cnr.icar.eric.client.ui.common.ReferenceAssociation.java

public void setReferenceAttributeOnSourceObject() throws JAXRException {
    String referenceAttribute = this.getReferenceAttribute();

    //Now use Refelection API to add target to src
    try {/*from   ww  w.ja  va 2  s. co m*/
        Class<? extends RegistryObject> srcClass = src.getClass();
        Class<?> targetClass = target.getClass();
        Class<?> registryObjectClass = null;

        String targetInterfaceName = targetClass.getName();
        targetInterfaceName = targetInterfaceName.substring(targetInterfaceName.lastIndexOf(".") + 1);

        if (targetInterfaceName.endsWith("Impl")) {
            //Remove Impl suffix for JAXR provider Impl classes
            targetInterfaceName = targetInterfaceName.substring(0, targetInterfaceName.length() - 4);
        }

        targetInterfaceName = "javax.xml.registry.infomodel." + targetInterfaceName;

        ClassLoader classLoader = srcClass.getClassLoader();

        try {
            targetClass = classLoader.loadClass(targetInterfaceName);
            registryObjectClass = classLoader.loadClass("javax.xml.registry.infomodel.RegistryObject");
        } catch (ClassNotFoundException e) {
            throw new JAXRException("No JAXR interface found by name " + targetInterfaceName);
        }

        @SuppressWarnings("static-access")
        String suffix = UIUtility.getInstance().initCapString(referenceAttribute);
        Method method = null;
        Class<?>[] paramTypes = new Class[1];

        //See if there is a simple attribute of this name using type of targetObject
        try {
            paramTypes[0] = targetClass;
            method = srcClass.getMethod("set" + suffix, paramTypes);

            Object[] params = new Object[1];
            params[0] = target;
            method.invoke(src, params);
            isCollectionRef = false;

            return;
        } catch (NoSuchMethodException | IllegalAccessException e) {
            method = null;
        }

        //See if there is a simple attribute of this name using base type RegistryObject
        try {
            paramTypes[0] = registryObjectClass;
            method = srcClass.getMethod("set" + suffix, paramTypes);

            Object[] params = new Object[1];
            params[0] = target;
            method.invoke(src, params);
            isCollectionRef = false;

            return;
        } catch (NoSuchMethodException | IllegalAccessException e) {
            method = null;
        }

        //See if there is a addCXXX method for suffix of XXX ending in "s" for plural
        if (suffix.endsWith("s")) {
            suffix = suffix.substring(0, suffix.length() - 1);
        }

        try {
            paramTypes[0] = targetClass;
            method = srcClass.getMethod("add" + suffix, paramTypes);

            Object[] params = new Object[1];
            params[0] = target;
            method.invoke(src, params);
            isCollectionRef = true;

            return;
        } catch (NoSuchMethodException | IllegalAccessException e) {
            method = null;
        }

        //See if there is a addCXXX method for suffix of XXX ending in "es" for plural
        if (suffix.endsWith("e")) {
            suffix = suffix.substring(0, suffix.length() - 1);
        }

        try {
            paramTypes[0] = targetClass;
            method = srcClass.getMethod("add" + suffix, paramTypes);

            Object[] params = new Object[1];
            params[0] = target;
            method.invoke(src, params);
            isCollectionRef = true;

            return;
        } catch (NoSuchMethodException | IllegalAccessException e) {
            method = null;
        }

        //Special case while adding child organization to an organization
        if (src instanceof Organization && target instanceof Organization) {
            try {
                paramTypes[0] = targetClass;
                method = srcClass.getMethod("addChildOrganization", paramTypes);

                Object[] params = new Object[1];
                params[0] = target;
                method.invoke(src, params);
                isCollectionRef = true;

                return;
            } catch (NoSuchMethodException | IllegalAccessException e) {
                method = null;
            }
        }
        throw new JAXRException("No method found for reference attribute " + referenceAttribute
                + " for src object of type " + srcClass.getName());
    } catch (IllegalArgumentException e) {
        throw new JAXRException(e);
    } catch (InvocationTargetException e) {
        throw new JAXRException(e.getCause());
    } catch (ExceptionInInitializerError e) {
        throw new JAXRException(e);
    }
}

From source file:com.google.dexmaker.ProxyBuilder.java

public Class<? extends T> buildProxyClass() throws IOException {
    Class<? extends T> proxyClass = null;
    synchronized (baseClass) {
        // we only populate the map with matching types
        proxyClass = (Class) generatedProxyClasses.get(baseClass);
        if (proxyClass != null && proxyClass.getClassLoader().getParent() == parentClassLoader
                && interfaces.equals(asSet(proxyClass.getInterfaces()))) {
            return proxyClass; // cache hit!
        }/*from ww  w.  j  a v  a 2 s . co  m*/
        // ---------------------------------------------------------------------------------------
        // ??class??class
        DexMaker dexMaker = new DexMaker(application);
        String generatedName = getMethodNameForProxyOf(baseClass);

        ClassLoader classLoader = dexMaker.getJarClassLoader(parentClassLoader, dexCache, generatedName);
        ArrayList<MethodEntity> entities = null;
        if (proxy.containsKey(generatedName)) {
            entities = proxy.get(generatedName);
        } else {
            entities = getObject(generatedName);
            if (null != entities) {
                proxy.put(generatedName, methods);
            }
        }
        Method[] methodsToProxy = null;
        if (classLoader == null || entities == null) {
            // the cache missed; generate the class
            TypeId<? extends T> generatedType = TypeId.get("L" + generatedName + ";");
            TypeId<T> superType = TypeId.get(baseClass);
            generateConstructorsAndFields(dexMaker, generatedType, superType, baseClass);
            methodsToProxy = getMethodsToProxyRecursive();

            generateCodeForAllMethods(dexMaker, generatedType, methodsToProxy, superType);
            dexMaker.declare(generatedType, generatedName + ".generated", PUBLIC, superType,
                    getInterfacesAsTypeIds());

            classLoader = dexMaker.generateAndLoad(parentClassLoader, dexCache, generatedName);

            setObject(generatedName, methods);
            proxy.put(generatedName, methods);
        } else {
            methodsToProxy = new Method[entities.size()];
            int i = 0;
            for (MethodEntity entity : entities) {
                Method method = null;
                try {
                    method = entity.clazz.getDeclaredMethod(entity.name, entity.params);
                } catch (NoSuchMethodException e) {
                    e.printStackTrace();
                }
                methodsToProxy[i++] = method;
            }
        }
        try {
            proxyClass = loadClass(classLoader, generatedName);
        } catch (IllegalAccessError e) {
            throw new UnsupportedOperationException("cannot proxy inaccessible class " + baseClass, e);
        } catch (ClassNotFoundException e) {
            throw new AssertionError(e);
        } catch (Exception e) {
            e.printStackTrace();
        }
        setMethodsStaticField(proxyClass, methodsToProxy);
        generatedProxyClasses.put(baseClass, proxyClass);
    }
    return proxyClass;
}