Package net.xeoh.plugins.base.util

Examples of net.xeoh.plugins.base.util.PluginConfigurationUtil


        // too long for us. If you set this variable the check will be skipped
        // and the request should take place much faster.
        // Appears to work(tm).
        ServiceResolver.ANNOUNCE_OVERRIDE = true;

        final PluginConfigurationUtil pcu = new PluginConfigurationUtil(this.pluginConfiguration);
        this.startupLock = pcu.getInt(RemoteDiscovery.class, "startup.locktime", 1000);
        this.lockMode = pcu.getString(RemoteDiscovery.class, "startup.lockmode", "onepass");

        // TODO put this in a thread
        this.checkCache.loadCache();

        try {
View Full Code Here


        // Appears to work(tm).
        ServiceResolver.ANNOUNCE_OVERRIDE = true;

        this.logger.status("backgroundinit/start");

        final PluginConfigurationUtil pcu = new PluginConfigurationUtil(this.pluginConfiguration);
        this.startupLock = pcu.getInt(RemoteDiscovery.class, "startup.locktime", 1000);
        this.lockMode = pcu.getString(RemoteDiscovery.class, "startup.lockmode", "onepass");

        try {
            this.logger.status("backgroundinit/lock");

            this.jmdnsLock.lock();
View Full Code Here

        this.logger.info("Trying to retrieve remote proxy for " + url);

        final String address = url.getHost() + ":" + url.getPort();
        final String name = url.getPath().substring(1);

        final PluginConfigurationUtil pcu = new PluginConfigurationUtil(this.configuration);

        // Obtain timeout when creating proxy
        final int timeout = pcu.getInt(RemoteAPI.class, "proxy.timeout", 500);

        // Tricky part, obtaining the proxy works fast, but we only know everything works fine after the first call,
        // so lets try that ...
        final R newClient = Proxies.newClient(name, address, remote);
View Full Code Here

    /**
     * Apply things from the config.
     */
    @SuppressWarnings("boxing")
    private void applyConfig() {
        final PluginConfigurationUtil pcu = new PluginConfigurationUtil(this.configuration);

        final String cachePath = this.configuration.getConfiguration(PluginManager.class, "cache.file");

        this.classPathManager.getCache().setEnabled(pcu.getBoolean(PluginManager.class, "cache.enabled", false));
        this.classPathManager.getCache().setCachePath(cachePath);

        // Check if we should enable weak mode
        final String mode = pcu.getString(PluginManager.class, "cache.mode", "strong");
        if (mode.equals("weak")) {
            this.classPathManager.getCache().setWeakMode(true);
        }

    }
View Full Code Here

            //
        }

        this.remoteAPIDiscoveryUtil = new RemoteAPIDiscoveryUtil(this.discovery, this);

        this.port = new PluginConfigurationUtil(this.configuration).getInt(getClass(), "export.port", getFreePort());

        this.callHandler = new CallHandler();
        this.lipeServer = new Server();
        try {
            this.lipeServer.bind(this.port, this.callHandler);
View Full Code Here

    /** Opens all required streams */
    @SuppressWarnings("boxing")
    // This MUST NOT be tagged with @Init, as it will be executed manually by the PluginManager.
    public void init() {
        final PluginConfigurationUtil util = new PluginConfigurationUtil(this.configuration);

        this.isDisabled = !util.getBoolean(Diagnosis.class, "general.enabled", true);
        this.recordingEnabled = util.getBoolean(Diagnosis.class, "recording.enabled", false);
        this.recordingFile = util.getString(Diagnosis.class, "recording.file", "diagnosis.record");
        this.useStackTraces = util.getBoolean(Diagnosis.class, "analysis.stacktraces.enabled", false);
        this.stackTracesDepth = util.getInt(Diagnosis.class, "analysis.stacktraces.depth", 1);

        String mode = util.getString(Diagnosis.class, "recording.format", "java/serialization/gzip");
        if ("java/serialization/gzip".equals(mode)) {
            this.compressOutput = true;
        }

        if ("java/serialization".equals(mode)) {
View Full Code Here

        // Obtain some shared objects
        // final JARCache jarCache = this.pluginManager.getJARCache();
        final ClassPathManager classPathManager = this.pluginManager.getClassPathManager();
        final PluginRegistry pluginRegistry = this.pluginManager.getPluginRegistry();
        final PluginConfigurationUtil pcu = new PluginConfigurationUtil(this.pluginManager.getPluginConfiguration());
        final Spawner spawner = this.pluginManager.getSpawner();

        // Obtain information
        // final JARInformation jarInformation = jarCache.getJARInformation(name);
        // final String file = jarCache.classTofile(name);

        try {
            // Get class of the candidate
            final Class<?> possiblePlugin = classPathManager.loadClass(location, name);

            // Don't load plugins already spawned.
            if (name.startsWith("net.xeoh.plugins.base") ||
                name.startsWith("net.xeoh.plugins.diagnosis.") ||
                name.startsWith("net.xeoh.plugins.informationbroker.")) return;
           
            // Get the plugin's annotation
            final PluginImplementation annotation = possiblePlugin.getAnnotation(PluginImplementation.class);

            // Nothing to load here if no annotation is present
            if (annotation == null) { return; }


           
            // Don't load classes already loaded from this location
            final PluginClassMetaInformation preexistingMeta = pluginRegistry.getMetaInformationFor((Class<? extends Plugin>) possiblePlugin);
            if (preexistingMeta != null) {
                this.logger.info("Skipping plugin " + possiblePlugin + " because we already have it ");
                return;
            }

           
            // Register class at registry
            final PluginClassMetaInformation metaInformation = new PluginClassMetaInformation();
            metaInformation.pluginClassStatus = PluginClassStatus.ACCEPTED;
            if (location != null) {
                metaInformation.pluginOrigin = location.getToplevelLocation();
            } else {
                metaInformation.pluginOrigin = new URI("classpath://UNDEFINED");
            }
            pluginRegistry.registerPluginClass((Class<? extends Plugin>) possiblePlugin, metaInformation);

            // Update the class information of the corresponding cache entry
            this.logger.finer("Updating cache information");

            // Avoid loading if annotation request it.
            if (pcu.getBoolean(possiblePlugin, "plugin.disabled", false) || possiblePlugin.getAnnotation(IsDisabled.class) != null) {
                metaInformation.pluginClassStatus = PluginClassStatus.DISABLED;
                this.logger.fine("Ignoring " + name + " due to request.");
                return;
            }
           
            // Up from here we know we will (eventually) use the plugin. So load its
            // configuration.
            final String properties = (possiblePlugin.getAnnotation(ConfigurationFile.class) != null) ? possiblePlugin.getAnnotation(ConfigurationFile.class).file() : null;
            if (properties != null && properties.length() > 0) {
                final String resourcePath = name.replaceAll("\\.", "/").replaceAll(possiblePlugin.getSimpleName(), "") + properties;
                this.logger.fine("Adding configuration from " + resourcePath + " for plugin " + name);

                final Properties p = new Properties();

                // Try to load resource by special classloader
                try {
                    p.load(classPathManager.getResourceAsStream(location, resourcePath));

                    final Set<Object> keys = p.keySet();

                    // Add every string that is not already in the configuration.
                    for (final Object object : keys) {
                        if (pcu.getString(null, (String) object) != null) {
                            this.pluginManager.getPluginConfiguration().setConfiguration(null, (String) object, p.getProperty((String) object));
                        }
                    }
                } catch (final IOException e) {
                    this.logger.warning("Unable to load properties " + resourcePath + " although requested");
View Full Code Here

        channel.status("findinclasspath/start");
        final Collection<AbstractClassPathLocation> rval = new ArrayList<AbstractClassPathLocation>();

        // Get our current classpath (TODO: Better get this using
        // ClassLoader.getSystemClassLoader()?)
        final boolean filter = new PluginConfigurationUtil(this.pluginManager.getPluginConfiguration()).getBoolean(PluginManager.class, "classpath.filter.default.enabled", true);
        final String blacklist[] = new PluginConfigurationUtil(this.pluginManager.getPluginConfiguration()).getString(PluginManager.class, "classpath.filter.default.pattern", "/jre/lib/;/jdk/lib/;/lib/rt.jar").split(";");
        final String pathSep = System.getProperty("path.separator");
        final String classpath = System.getProperty("java.class.path");
        final List<URL> toFilter = new ArrayList<URL>();

        // Get the starting point
View Full Code Here

    /**
     * Apply things from the config.
     */
    @SuppressWarnings("boxing")
    private void applyConfig() {
        final PluginConfigurationUtil pcu = new PluginConfigurationUtil(this.configuration);

        final String cachePath = this.configuration.getConfiguration(PluginManager.class, "cache.file");

        this.classPathManager.getCache().setEnabled(pcu.getBoolean(PluginManager.class, "cache.enabled", false));
        this.classPathManager.getCache().setCachePath(cachePath);

        // Check if we should enable weak mode
        final String mode = pcu.getString(PluginManager.class, "cache.mode", "strong");
        if (mode.equals("weak")) {
            this.classPathManager.getCache().setWeakMode(true);
        }

    }
View Full Code Here

        // Obtain some shared objects
        // final JARCache jarCache = this.pluginManager.getJARCache();
        final ClassPathManager classPathManager = this.pluginManager.getClassPathManager();
        final PluginRegistry pluginRegistry = this.pluginManager.getPluginRegistry();
        final PluginConfigurationUtil pcu = new PluginConfigurationUtil(this.pluginManager.getPluginConfiguration());
        final Spawner spawner = this.pluginManager.getSpawner();

        // Obtain information
        // final JARInformation jarInformation = jarCache.getJARInformation(name);
        // final String file = jarCache.classTofile(name);

        try {
            // Get class of the candidate
            final Class<?> possiblePlugin = classPathManager.loadClass(location, name);

            // Don't load plugins already spawned.
            if (name.startsWith("net.xeoh.plugins.base") ||
                name.startsWith("net.xeoh.plugins.diagnosis.") ||
                name.startsWith("net.xeoh.plugins.informationbroker.")) return;
           
            // Get the plugin's annotation
            final PluginImplementation annotation = possiblePlugin.getAnnotation(PluginImplementation.class);

            // Nothing to load here if no annotation is present
            if (annotation == null) { return; }


           
            // Don't load classes already loaded from this location
            final PluginClassMetaInformation preexistingMeta = pluginRegistry.getMetaInformationFor((Class<? extends Plugin>) possiblePlugin);
            if (preexistingMeta != null) {
                this.logger.info("Skipping plugin " + possiblePlugin + " because we already have it ");
                return;
            }

           
            // Register class at registry
            final PluginClassMetaInformation metaInformation = new PluginClassMetaInformation();
            metaInformation.pluginClassStatus = PluginClassStatus.ACCEPTED;
            if (location != null) {
                metaInformation.pluginOrigin = location.getToplevelLocation();
            } else {
                metaInformation.pluginOrigin = new URI("classpath://UNDEFINED");
            }
            pluginRegistry.registerPluginClass((Class<? extends Plugin>) possiblePlugin, metaInformation);

            // Update the class information of the corresponding cache entry
            this.logger.finer("Updating cache information");

            // Avoid loading if annotation request it.
            if (pcu.getBoolean(possiblePlugin, "plugin.disabled", false) || possiblePlugin.getAnnotation(IsDisabled.class) != null) {
                metaInformation.pluginClassStatus = PluginClassStatus.DISABLED;
                this.logger.fine("Ignoring " + name + " due to request.");
                return;
            }
           
            // Up from here we know we will (eventually) use the plugin. So load its
            // configuration.
            final String properties = (possiblePlugin.getAnnotation(ConfigurationFile.class) != null) ? possiblePlugin.getAnnotation(ConfigurationFile.class).file() : null;
            if (properties != null && properties.length() > 0) {
                final String resourcePath = name.replaceAll("\\.", "/").replaceAll(possiblePlugin.getSimpleName(), "") + properties;
                this.logger.fine("Adding configuration from " + resourcePath + " for plugin " + name);

                final Properties p = new Properties();

                // Try to load resource by special classloader
                InputStream ism = null;
                try {
                   ism = classPathManager.getResourceAsStream(location, resourcePath);
                    p.load(ism);

                    final Set<Object> keys = p.keySet();

                    // Add every string that is not already in the configuration.
                    for (final Object object : keys) {
                        if (pcu.getString(null, (String) object) != null) {
                            this.pluginManager.getPluginConfiguration().setConfiguration(null, (String) object, p.getProperty((String) object));
                        }
                    }
                } catch (final IOException e) {
                    this.logger.warning("Unable to load properties " + resourcePath + " although requested");
View Full Code Here

TOP

Related Classes of net.xeoh.plugins.base.util.PluginConfigurationUtil

Copyright © 2018 www.massapicom. 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.