当前位置: 首页>>代码示例>>Java>>正文


Java Provider类代码示例

本文整理汇总了Java中org.netbeans.modules.j2ee.persistence.provider.Provider的典型用法代码示例。如果您正苦于以下问题:Java Provider类的具体用法?Java Provider怎么用?Java Provider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Provider类属于org.netbeans.modules.j2ee.persistence.provider包,在下文中一共展示了Provider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setSelectedLibrary

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
/**
 * Sets selected item in library combo box.
 */
private void setSelectedLibrary(){
    ArrayList<Provider> providers = new ArrayList<Provider>();
    for(int i=0; i<libraryComboBox.getItemCount(); i++){
        Object obj = libraryComboBox.getItemAt(i);
        if(obj instanceof Provider){
            providers.add((Provider) obj);
        }
    }
    Provider selected = ProviderUtil.getProvider(persistenceUnit, providers.toArray(new Provider[]{}));
    
    if (selected == null){
        return;
    }
    for(int i = 0; i < libraryComboBox.getItemCount(); i++){
        Object item = libraryComboBox.getItemAt(i);
        Provider provider = (Provider) (item instanceof Provider ? item : null);
        if (provider!= null && provider.equals(selected)){
            libraryComboBox.setSelectedIndex(i);
            break;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:PersistenceUnitPanel.java

示例2: setTableGeneration

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
/**
 * Selects appropriate table generation radio button.
 */
private void setTableGeneration(){
    Provider provider = getSelectedProvider();
    // issue 123224. The user can have a persistence.xml in J2SE project without provider specified
    Property tableGeneration = (provider == null) ? null : ProviderUtil.getProperty(persistenceUnit, provider.getTableGenerationPropertyName());
    if (tableGeneration != null){
        if (provider.getTableGenerationCreateValue().equals(tableGeneration.getValue())){
            ddCreate.setSelected(true);
        } else if (provider.getTableGenerationDropCreateValue().equals(tableGeneration.getValue())){
            ddDropCreate.setSelected(true);
        }
    } else {
        ddUnknown.setSelected(true);
    }
    boolean toggle = (provider == null) ? false : provider.supportsTableGeneration();
    
    ddCreate.setEnabled(toggle);
    ddDropCreate.setEnabled(toggle);
    ddUnknown.setEnabled(toggle);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:PersistenceUnitPanel.java

示例3: getAvailPropNames

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
/**
 * Gets the properties that are not defined in the configuration file yet
 * 
 * @param propCat The property category(persistence provider)
 * @param pu persistence unit that contains the properties
 * @return Array of property names
 */
public static ArrayList<String> getAvailPropNames(Provider propCat, PersistenceUnit pu) {

    List<String> propsList = getPropsNamesExceptGeneral(propCat);

    if (pu != null) {
        ArrayList<String> availProps = new ArrayList<String>(propsList);
        if(pu.getProperties() != null) {
            for (int i = 0; i < pu.getProperties().sizeProperty2(); i++) {
                String propName = pu.getProperties().getProperty2(i).getName();
                if (!availProps.remove(propName)
                        && availProps.contains("javax.persistence." + propName)) {
                    availProps.remove(propName);
                }
            }
        }

        return availProps;
    }

    return new ArrayList<String>();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:Util.java

示例4: getKeys

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
/**
 * return list of pu properties for a provider including default properties
 * return default 2.0 if provider is null
 * @param provider
 * @return 
 */
public static List<String> getKeys(Provider provider){
    //TODO: cache lists?
    ArrayList<String> ret = new ArrayList<String>();
    String ver = provider == null ? null : ProviderUtil.getVersion(provider);
    if(provider == null || (ver!=null && !Persistence.VERSION_1_0.equals(ver))) {
        ret.addAll(possiblePropertyValues.get(null).keySet());
    }
    if(provider !=null ) {
        Map<String, String[]> props = possiblePropertyValues.get(provider);
        if(props!=null) {
            ret.addAll(props.keySet());
        }
    }
    Collections.sort(ret, new KeyOrder());
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:PersistenceCfgProperties.java

示例5: getPreferredProvider

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
/**
 * check all available providers and return default/first/or ECLIPSELINK if prefereed
 * @param project
 * @return
 */
public static Provider getPreferredProvider(Project project){
    //choose default/first provider
    ArrayList<Provider> providers = getProviders(project);
    int defIndex = 0;
    if(providers.size()>1){//if it's possible to select preferred jpa2.0 provider, we'll select instead of jpa1.0 default one
        String defProviderVersion = ProviderUtil.getVersion((Provider) providers.get(0));
        boolean specialCase = (Util.isJPAVersionSupported(project, Persistence.VERSION_2_0) || Util.isJPAVersionSupported(project, Persistence.VERSION_2_1)) && (defProviderVersion == null || defProviderVersion.equals(Persistence.VERSION_1_0));//jpa 2.0 is supported by default (or first) is jpa1.0 or udefined version provider
        if(specialCase){
            for (int i = 1; i<providers.size() ; i++){
                if(ProviderUtil.ECLIPSELINK_PROVIDER.equals(providers.get(i))){//eclipselink jpa2.1 is preferred provider
                    defIndex = i;
                    break;
                }
            }
        }
    }
    if(providers.isEmpty()) {
        Logger.getLogger(RelatedCMPWizard.class.getName()).log(Level.INFO, "Can't find any providers supported by the project: {0}", project); //NOI18N
    }
    return providers.size()>0 ? providers.get(defIndex) : null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:Util.java

示例6: getSupportedProviders

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
@Override
public List<Provider> getSupportedProviders() {
    List<Provider> model = new ArrayList<Provider>();
    //get all, but remove duplicates
    for (Provider each : PersistenceLibrarySupport.getProvidersFromLibraries()) {
        boolean found = false;
        for (int i = 0; i < model.size(); i++) {
            Object elem = model.get(i);
            if (elem instanceof Provider && each.equals(elem)) {
                found = true;
                break;
            }
        }
        if (!found) {
            model.add(each);
        }
    }
    return model;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Util.java

示例7: createLibraries

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
private static List<ProviderLibrary> createLibraries(String providerClass) {
    List<ProviderLibrary> providerLibs = new ArrayList<ProviderLibrary>();
    for (Library each : LibraryManager.getDefault().getLibraries()) {
        if (!"j2se".equals(each.getType())) { // NOI18N
            continue;
        }
        ClassPath cp = getLibraryClassPath(each);
        Provider provider = extractProvider(cp, providerClass);
        if (provider != null && containsClass(cp, "javax.persistence.EntityManager")) { //NOI18N
            providerLibs.add(new ProviderLibrary(each, cp, provider));
        }
    }
    Collections.sort(providerLibs, new Comparator<ProviderLibrary>() {

        @Override
        public int compare(ProviderLibrary l1, ProviderLibrary l2) {
            String name1 = l1.getLibrary().getDisplayName();
            String name2 = l2.getLibrary().getDisplayName();
            return name1.compareToIgnoreCase(name2);
        }
    });
    return providerLibs;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:PersistenceLibrarySupport.java

示例8: getProvidersFromLibraries

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
/**
 * Gets the persistence providers that are defined in the libraries
 * of the IDE.
 * 
 * @return list of the providers that are defined in the IDE's libraries.
 */
public static List<Provider> getProvidersFromLibraries() {
    List<Provider> providerLibs = new ArrayList<Provider>();
    for (ProviderLibrary each : createLibraries()) {
        providerLibs.add(each.getProvider());
    }
    Collections.sort(providerLibs, new Comparator<Provider>() {

        @Override
        public int compare(Provider p1, Provider p2) {
            String name1 = p1.getDisplayName();
            String name2 = p2.getDisplayName();
            return name1.compareToIgnoreCase(name2);
        }
    });
    return providerLibs;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:PersistenceLibrarySupport.java

示例9: substitutePersistenceProperties

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
/**
 * test persistence unit and produce properties to sunstitute ee environment
 * with se environment (to execut jpql on se level)
 *
 * @param pe
 * @param pu
 * @param props - map will be filled with properties
 * @return return possible problems (missed paths etc.)
 */
public static List<String> substitutePersistenceProperties(PersistenceEnvironment pe, PersistenceUnit pu, DatabaseConnection dbconn, Map<String, String> props) {
    final boolean containerManaged = Util.isSupportedJavaEEVersion(pe.getProject());
    final Provider provider = ProviderUtil.getProvider(pu.getProvider(), pe.getProject());
    ArrayList<String> problems = new ArrayList<String>();
    if (containerManaged) {
        props.put("javax.persistence.provider", provider.getProviderClass());//NOI18N
        props.put("javax.persistence.transactionType", "RESOURCE_LOCAL");//NOI18N
        if (dbconn != null) {
            props.put(provider.getJdbcUrl(), dbconn.getDatabaseURL());
            props.put(provider.getJdbcDriver(), dbconn.getDriverClass());
            props.put(provider.getJdbcUsername(), dbconn.getUser());
            props.put(provider.getJdbcPassword(), dbconn.getPassword());
        } 
    }
    return problems;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:Utils.java

示例10: getSupportedProviders

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
@Override
public List<Provider> getSupportedProviders() {
    ArrayList<Provider> providers = new ArrayList<Provider>();
    for (Provider each : PersistenceLibrarySupport.getProvidersFromLibraries()){
        boolean found = false;
        for (int i = 0; i < providers.size(); i++) {
            Object elem = providers.get(i);
            if (elem instanceof Provider && each.equals(elem)){
                found = true;
                break;
            }
        }
        if (!found){
           providers.add(each);
        }
    }
    return providers;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:PersistenceProviderComboboxHelper.java

示例11: setSelectedConnection

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
/**
 * Sets the selected item in connection combo box.
 */
private void setSelectedConnection(){
    DatabaseConnection connection = ProviderUtil.getConnection(persistenceUnit);
    if (connection != null){
        jdbcComboBox.setSelectedItem(connection);
    } else {
        // custom connection (i.e. connection not registered in netbeans)
        Properties props = persistenceUnit.getProperties();
        if (props != null){
            Property[] properties = props.getProperty2();
            String url = null;
            ArrayList<Provider> providers = new ArrayList<Provider>();
            JComboBox activeCB = providerCombo.isVisible() ? providerCombo : libraryComboBox;
            for(int i=0; i<activeCB.getItemCount(); i++){
                Object obj = activeCB.getItemAt(i);
                if(obj instanceof Provider){
                    providers.add((Provider) obj);
                }
            }
            Provider provider = ProviderUtil.getProvider(persistenceUnit, providers.toArray(new Provider[]{}));
            for (int i = 0; i < properties.length; i++) {
                String key = properties[i].getName();
                if (provider.getJdbcUrl().equals(key)) {
                    url = properties[i].getValue();
                    break;
                }
            }
            if (url == null) {
                url = NbBundle.getMessage(PersistenceUnitPanel.class, "LBL_CustomConnection");//NOI18N
            }
            jdbcComboBox.addItem(url);
            jdbcComboBox.setSelectedItem(url);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:PersistenceUnitPanel.java

示例12: getTableGeneration

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
/**
 *@return selected table generation strategy.
 */
private String getTableGeneration(){
    if (ddCreate.isSelected()){
        return Provider.TABLE_GENERATION_CREATE;
    } else if (ddDropCreate.isSelected()){
        return Provider.TABLE_GENERATION_DROPCREATE;
    } else {
        return Provider.TABLE_GENERATTION_UNKOWN;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:PersistenceUnitPanel.java

示例13: getPropsNamesExceptGeneral

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
public static List<String> getPropsNamesExceptGeneral(Provider propCat) {
    List<String> propsList = getAllPropNames(propCat);
    if(propCat != null){
        propsList.remove(propCat.getJdbcDriver());
        propsList.remove(propCat.getJdbcUsername());
        propsList.remove(propCat.getJdbcUrl());
        propsList.remove(propCat.getJdbcPassword());
        propsList.remove(propCat.getTableGenerationPropertyName());
    }
    return propsList;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:Util.java

示例14: getPossiblePropertyValue

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
public static Object  getPossiblePropertyValue( Provider provider, String propName ) {
    if(provider == null) {
        provider = ProviderUtil.ECLIPSELINK_PROVIDER2_0;
    }//TODO, some logic to add, either search for all providers or some other
    Map<String, String[]> firstMap = possiblePropertyValues.get(provider);
    return firstMap != null ? firstMap.get(propName) : null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:PersistenceCfgProperties.java

示例15: getProviders

import org.netbeans.modules.j2ee.persistence.provider.Provider; //导入依赖的package包/类
/**
 * return list of supported(by this class) providers with some known properties
 * @return 
 */
public static List<Provider> getProviders(){
    ArrayList<Provider> ret = new ArrayList<Provider>();
    ret.add(ProviderUtil.ECLIPSELINK_PROVIDER2_0);
    ret.add(ProviderUtil.HIBERNATE_PROVIDER2_0);
    return ret;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:PersistenceCfgProperties.java


注:本文中的org.netbeans.modules.j2ee.persistence.provider.Provider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。