當前位置: 首頁>>代碼示例>>Java>>正文


Java ComponentConfig.getRootLocation方法代碼示例

本文整理匯總了Java中org.ofbiz.base.component.ComponentConfig.getRootLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java ComponentConfig.getRootLocation方法的具體用法?Java ComponentConfig.getRootLocation怎麽用?Java ComponentConfig.getRootLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.ofbiz.base.component.ComponentConfig的用法示例。


在下文中一共展示了ComponentConfig.getRootLocation方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startFileListener

import org.ofbiz.base.component.ComponentConfig; //導入方法依賴的package包/類
/**
 * A service used to capture file changes on the system. Automatically implements file listeners for all components recursively.
 * 
 * @param dctx The DispatchContext that this service is operating in
 * @param context Map containing the input parameters
 * @return Map with the result of the service, the output parameters
 */
public static Map<String, Object> startFileListener(DispatchContext dctx, Map<String, ?> context) {
    //Delegator delegator = dctx.getDelegator();
    //LocalDispatcher dispatcher = dctx.getDispatcher();
    try {
        Collection<ComponentConfig> allComponents = ComponentConfig.getAllComponents();
        for (ComponentConfig config : allComponents) {
            String name = "component-"+config.getComponentName();
            String location = config.getRootLocation();
            FileListener.startFileListener(name,location); 
        }
        return ServiceUtil.returnSuccess("File event registered.");
    }
    catch(Exception e) {
        final String errorMsg = "Exception triggering File Event";
        Debug.logError(e, errorMsg, module);
        return ServiceUtil.returnError(errorMsg + ": " + e.getMessage());
    }
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:26,代碼來源:CommonServices.java

示例2: getBaseLocation

import org.ofbiz.base.component.ComponentConfig; //導入方法依賴的package包/類
public static StringBuilder getBaseLocation(String location) throws MalformedURLException {
    StringBuilder baseLocation = new StringBuilder(FlexibleLocation.stripLocationType(location));
    // componentName is between the first slash and the second
    int firstSlash = baseLocation.indexOf("/");
    int secondSlash = baseLocation.indexOf("/", firstSlash + 1);
    if (firstSlash != 0 || secondSlash == -1) {
        throw new MalformedURLException("Bad component location [" + location + "]: base location missing slashes [" + baseLocation + "], first = " + firstSlash + ", second = " + secondSlash + "; should be like: component://{component-name}/relative/path");
    }
    String componentName = baseLocation.substring(firstSlash + 1, secondSlash);
    // got the componentName, now remove it from the baseLocation, removing the second slash too (just in case the rootLocation has one)
    baseLocation.delete(0, secondSlash + 1);
    try {
        String rootLocation = ComponentConfig.getRootLocation(componentName);
        // if there is not a forward slash between the two, add it
        if (baseLocation.charAt(0) != '/' && rootLocation.charAt(rootLocation.length() - 1) != '/') {
            baseLocation.insert(0, '/');
        }
        // insert the root location and we're done
        baseLocation.insert(0, rootLocation);
        return baseLocation;
    } catch (ComponentException e) {
        String errMsg = "Could not get root location for component with name [" + componentName + "], error was: " + e.toString();
        Debug.logError(e, errMsg, module);
        throw new MalformedURLException(errMsg);
    }
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:27,代碼來源:ComponentLocationResolver.java

示例3: getBaseLocation

import org.ofbiz.base.component.ComponentConfig; //導入方法依賴的package包/類
public static StringBuilder getBaseLocation(String location) throws MalformedURLException {
    StringBuilder baseLocation = new StringBuilder(FlexibleLocation.stripLocationType(location));
    // componentName is between the first slash and the second
    int firstSlash = baseLocation.indexOf("/");
    int secondSlash = baseLocation.indexOf("/", firstSlash + 1);
    if (firstSlash != 0 || secondSlash == -1) {
        throw new MalformedURLException("Bad component location [" + location + "]: base location missing slashes [" + baseLocation + "], first = " + firstSlash + ", second = " + secondSlash + "; should be like: component://{component-name}/relative/path");
    }
    String componentName = baseLocation.substring(firstSlash + 1, secondSlash);
    // got the componentName, now remove it from the baseLocation, removing the second slash too (just in case the rootLocation has one)
    baseLocation.delete(0, secondSlash + 1);
    try {
        String rootLocation = ComponentConfig.getRootLocation(componentName);
        // if there is not a forward slash between the two, add it
        if (baseLocation.charAt(0) != '/' && rootLocation.charAt(rootLocation.length() - 1) != '/') {
            baseLocation.insert(0, '/');
        }
        // insert the root location and we're done
        baseLocation.insert(0, rootLocation);
        return baseLocation;
    } catch (ComponentException e) {
        String errMsg = "Could not get root location for component with name [" + componentName + "], error was: " + e.toString();
        // SCIPIO: 2017-08-03: do not log this anymore, because the caller may need to handle it
        //Debug.logError(e, errMsg, module);
        // SCIPIO: 2017-08-03: special new exception so callers can handle this case
        //throw new MalformedURLException(errMsg);
        throw ComponentURLException.fromComponentException(errMsg, e);
    }
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:30,代碼來源:ComponentLocationResolver.java

示例4: findRealPathAndFileForClass

import org.ofbiz.base.component.ComponentConfig; //導入方法依賴的package包/類
public static String findRealPathAndFileForClass(String fullyQualifiedClassName) {
    // search through the component directories, in the src directory for each, using the class path as the path within it

    String sourceSubPath = fullyQualifiedClassName.substring(0, fullyQualifiedClassName.lastIndexOf(".")).replace('.', File.separatorChar);
    String classFileName = fullyQualifiedClassName.substring(fullyQualifiedClassName.lastIndexOf(".")+1) + ".java";

    Collection<ComponentConfig> allComponentConfigs = ComponentConfig.getAllComponents();
    for (ComponentConfig cc: allComponentConfigs) {
        String rootDirectory = cc.getRootLocation();
        if (!rootDirectory.endsWith(File.separatorChar + "")) rootDirectory += File.separatorChar;
        rootDirectory += "src" + File.separatorChar;

        File rootDirFile = new File(rootDirectory);
        if (!rootDirFile.exists()) {
            // no src directory, move along
            continue;
        }

        String classDir = rootDirectory + sourceSubPath;
        File classDirFile = new File(classDir);
        if (!classDirFile.exists()) {
            // no src class sub-directory, move along
            continue;
        }

        String fullPathAndFile = classDir + File.separatorChar + classFileName;
        File classFile = new File(fullPathAndFile);
        if (classFile.exists()) {
            if (Debug.verboseOn()) Debug.logVerbose("In findRealPathAndFileForClass for [" + fullyQualifiedClassName + "]: [" + fullPathAndFile + "]", module);
            return fullPathAndFile;
        }
    }

    return null;
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:36,代碼來源:UtilJavaParse.java

示例5: LabelReferences

import org.ofbiz.base.component.ComponentConfig; //導入方法依賴的package包/類
public LabelReferences(Delegator delegator, LabelManagerFactory factory) {
    this.delegator = delegator;
    this.labels = factory.getLabels();
    DelegatorElement delegatorInfo = null;
    try {
        delegatorInfo = EntityConfig.getInstance().getDelegator(delegator.getDelegatorBaseName());
    } catch (GenericEntityConfException e) {
        Debug.logWarning(e, "Exception thrown while getting delegator config: ", module);
    }
    String modelName;
    if (delegatorInfo != null) {
        modelName = delegatorInfo.getEntityModelReader();
    } else {
        modelName = "main";
    }
    // since we do not associate a dispatcher to this DispatchContext, it is important to set a name of an existing entity model reader:
    // in this way it will be possible to retrieve the service models from the cache
    this.dispatchContext = new DispatchContext(modelName, this.getClass().getClassLoader(), null);
    Collection<LabelInfo> infoList = this.labels.values();
    for (LabelInfo labelInfo : infoList) {
        this.labelSet.add(labelInfo.getLabelKey());
    }
    Collection<ComponentConfig> componentConfigs = ComponentConfig.getAllComponents();
    for (ComponentConfig config : componentConfigs) {
        String rootFolder = config.getRootLocation();
        rootFolder = rootFolder.replace('\\', '/');
        if (!rootFolder.endsWith("/")) {
            rootFolder = rootFolder + "/";
        }
        this.rootFolders.add(rootFolder);
    }
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:33,代碼來源:LabelReferences.java

示例6: LabelReferences

import org.ofbiz.base.component.ComponentConfig; //導入方法依賴的package包/類
public LabelReferences(Delegator delegator, LabelManagerFactory factory) {
    this.delegator = delegator;
    this.labels = factory.getLabels();
    DelegatorElement delegatorInfo = null;
    try {
        delegatorInfo = EntityConfigUtil.getDelegator(delegator.getDelegatorBaseName());
    } catch (GenericEntityConfException e) {
        Debug.logWarning(e, "Exception thrown while getting delegator config: ", module);
    }
    String modelName;
    if (delegatorInfo != null) {
        modelName = delegatorInfo.getEntityModelReader();
    } else {
        modelName = "main";
    }
    // since we do not associate a dispatcher to this DispatchContext, it is important to set a name of an existing entity model reader:
    // in this way it will be possible to retrieve the service models from the cache
    this.dispatchContext = new DispatchContext(modelName, this.getClass().getClassLoader(), null);
    Collection<LabelInfo> infoList = this.labels.values();
    for (LabelInfo labelInfo : infoList) {
        this.labelSet.add(labelInfo.getLabelKey());
    }
    Collection<ComponentConfig> componentConfigs = ComponentConfig.getAllComponents();
    for (ComponentConfig config : componentConfigs) {
        String rootFolder = config.getRootLocation();
        rootFolder = rootFolder.replace('\\', '/');
        if (!rootFolder.endsWith("/")) {
            rootFolder = rootFolder + "/";
        }
        this.rootFolders.add(rootFolder);
    }
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:33,代碼來源:LabelReferences.java

示例7: loadComponent

import org.ofbiz.base.component.ComponentConfig; //導入方法依賴的package包/類
private void loadComponent(ComponentConfig config) {
    // make sure the component is enabled
    if (!config.enabled()) {
        Debug.logInfo("Not Loading component : [" + config.getComponentName() + "] (disabled)", module);
        return;
    }

    Debug.logInfo("Loading component : [" + config.getComponentName() + "]", module);
    List<ComponentConfig.ClasspathInfo> classpathInfos = config.getClasspathInfos();
    String configRoot = config.getRootLocation();
    configRoot = configRoot.replace('\\', '/');
    // set the root to have a trailing slash
    if (!configRoot.endsWith("/")) {
        configRoot = configRoot + "/";
    }
    if (classpathInfos != null) {
        String nativeLibExt = System.mapLibraryName("someLib").replace("someLib", "").toLowerCase();
        for (ComponentConfig.ClasspathInfo cp: classpathInfos) {
            String location = cp.location.replace('\\', '/');
            // set the location to not have a leading slash
            if (location.startsWith("/")) {
                location = location.substring(1);
            }
            if (!"jar".equals(cp.type) && !"dir".equals(cp.type)) {
                Debug.logError("Classpath type '" + cp.type + "' is not supported; '" + location + "' not loaded", module);
                continue;
            }
            String dirLoc = location;
            if (dirLoc.endsWith("/*")) {
                // strip off the slash splat
                dirLoc = location.substring(0, location.length() - 2);
            }
            File path = FileUtil.getFile(configRoot + dirLoc);
            if (path.exists()) {
                if (path.isDirectory()) {
                    if ("dir".equals(cp.type)) {
                        classPath.addComponent(configRoot + location);
                    }
                    // load all .jar, .zip files and native libs in this directory
                    boolean containsNativeLibs = false;
                    for (File file: path.listFiles()) {
                        String fileName = file.getName().toLowerCase();
                        if (fileName.endsWith(".jar") || fileName.endsWith(".zip")) {
                            classPath.addComponent(file);
                        } else if (fileName.endsWith(nativeLibExt)) {
                            containsNativeLibs = true;
                        }
                    }
                    if (containsNativeLibs) {
                        libraryPath.addComponent(path);
                    }
                } else {
                    // add a single file
                    classPath.addComponent(configRoot + location);
                }
            } else {
                Debug.logWarning("Location '" + configRoot + dirLoc + "' does not exist", module);
            }
        }
    }
}
 
開發者ID:gildaslemoal,項目名稱:elpi,代碼行數:62,代碼來源:ComponentContainer.java


注:本文中的org.ofbiz.base.component.ComponentConfig.getRootLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。