ServiceAPI.java 4.69 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.jmx.statistics.StatisticsHost
 *  org.apache.commons.beanutils.BeanUtils
 *  org.apache.commons.lang.ClassUtils
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.service;

import com.adobe.jmx.statistics.StatisticsHost;
import com.adobe.service.*;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang.ClassUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.Properties;

public abstract class ServiceAPI
implements StatisticsHost,
ServiceMBean,
PoolingAttributes,
ProcessAttributes {
    public static int SERVICE_STARTING = 0;
    public static int SERVICE_RUNNING = 1;
    public static int SERVICE_STOPPING = 2;
    public static int SERVICE_STOPPED = 3;
    public static int SERVICE_FAILED = 4;
    public static String USE_CUSTOM_LAUNCHER = "UseCustomLauncher";
    private int serviceState = SERVICE_STARTING;
    private long startTime = 0;
    protected final Logger logger;
    protected boolean lazyInitialization;
    private ConnectionFactoryManager cfManager;
    private final String name;

    public ServiceAPI() {
        this.logger = LoggerFactory.getLogger(this.getClass());
        this.lazyInitialization = false;
        this.cfManager = null;
        this.name = ClassUtils.getShortClassName(this.getClass());
    }

    public String getName() {
        return this.name;
    }

    public String toString() {
        return this.getName();
    }

    public void setPoolMax(int inPoolMax) {
        this.cfManager.setPoolMax(inPoolMax);
    }

    public int getPoolMax() {
        return this.cfManager.getPoolMax();
    }

    public void setPoolMin(int inPoolMin) {
        this.cfManager.setPoolMin(inPoolMin);
    }

    public int getPoolMin() {
        return this.cfManager.getPoolMin();
    }

    public int getState() {
        return this.serviceState;
    }

    void setState(int state) {
        if (state >= SERVICE_STARTING && state <= SERVICE_FAILED) {
            this.serviceState = state;
        }
    }

    public long getStartTime() {
        return this.startTime;
    }

    public ConnectionFactoryManager getConnectionFactoryManager() {
        return this.cfManager;
    }

    public abstract void registerConnectionFactoryManager(ResourceFactoryManager var1);

    public abstract File getDeployedFile(String var1);

    public abstract File getNativeDir();

    public abstract File getPersistentDir();

    public abstract void disableService();

    public abstract File getTempDir();

    protected String getAttribute(String inName) {
        try {
            return BeanUtils.getProperty((Object)this, (String)inName);
        }
        catch (IllegalAccessException e) {
            throw new IllegalArgumentException("Error getting property '" + inName + "' for service '" + this.getName() + "'.", e);
        }
        catch (InvocationTargetException e) {
            throw new IllegalArgumentException("Error getting property '" + inName + "' for service '" + this.getName() + "'.", e);
        }
        catch (NoSuchMethodException e) {
            throw new IllegalArgumentException("Error getting property '" + inName + "' for service '" + this.getName() + "'.", e);
        }
    }

    protected void setAttribute(String inName, Object inValue) {
        this.logger.debug("Setting Attribute {} = {}", (Object)inName, (Object)inValue.toString());
        try {
            BeanUtils.copyProperty((Object)this, (String)inName, (Object)inValue);
        }
        catch (IllegalAccessException e) {
            throw new IllegalArgumentException("Error setting property '" + inName + "' for service '" + this.getName() + "'.", e);
        }
        catch (InvocationTargetException e) {
            throw new IllegalArgumentException("Error setting property '" + inName + "' for service '" + this.getName() + "'.", e);
        }
    }

    protected void setAttributes(Properties inAttributes) {
        try {
            BeanUtils.populate((Object)this, (Map)inAttributes);
        }
        catch (IllegalAccessException e) {
            throw new IllegalArgumentException("Error setting properties, nested exception - ", e);
        }
        catch (InvocationTargetException e) {
            throw new IllegalArgumentException("Error setting properties, nested exception - ", e);
        }
    }

    protected void setConnectionFactoryManager(ConnectionFactoryManager inCfManager) {
        this.cfManager = inCfManager;
    }

    protected void deferredInitialize() {
    }

    void setStartTime(long curTime) {
        this.startTime = curTime;
    }
}