Example usage for java.lang InstantiationException toString

List of usage examples for java.lang InstantiationException toString

Introduction

In this page you can find the example usage for java.lang InstantiationException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.dspace.content.packager.AbstractMETSDisseminator.java

/**
 * Create an element wrapped around a metadata reference (either mdWrap
 * or mdRef); i.e. dmdSec, techMd, sourceMd, etc.  Checks for
 * XML-DOM oriented crosswalk first, then if not found looks for
 * stream crosswalk of the same name./*from   w  w  w  .  jav a2  s  .co m*/
 *
 * @param context DSpace Context
 * @param dso DSpace Object we are generating METS manifest for
 * @param mdSecClass class of mdSec (TechMD, RightsMD, DigiProvMD, etc)
 * @param typeSpec Type of metadata going into this mdSec (e.g. MODS, DC, PREMIS, etc)
 * @param params the PackageParameters
 * @param extraStreams list of extra files which need to be added to final dissemination package
 * 
 * @return mdSec element or null if xwalk returns empty results.
 * 
 * @throws SQLException
 * @throws PackageValidationException
 * @throws CrosswalkException
 * @throws IOException
 * @throws AuthorizeException
 */
protected MdSec makeMdSec(Context context, DSpaceObject dso, Class mdSecClass, String typeSpec,
        PackageParameters params, MdStreamCache extraStreams)
        throws SQLException, PackageValidationException, CrosswalkException, IOException, AuthorizeException {
    try {
        //create our metadata element (dmdSec, techMd, sourceMd, rightsMD etc.)
        MdSec mdSec = (MdSec) mdSecClass.newInstance();
        mdSec.setID(gensym(mdSec.getLocalName()));
        String parts[] = typeSpec.split(":", 2);
        String xwalkName, metsName;

        //determine the name of the crosswalk to use to generate metadata
        // for dmdSecs this is the part *after* the colon in the 'type' (see getDmdTypes())
        // for all other mdSecs this is usually just corresponds to type name.
        if (parts.length > 1) {
            metsName = parts[0];
            xwalkName = parts[1];
        } else {
            metsName = typeSpec;
            xwalkName = typeSpec;
        }

        // First, check to see if the crosswalk we are using is a normal DisseminationCrosswalk
        boolean xwalkFound = PluginManager.hasNamedPlugin(DisseminationCrosswalk.class, xwalkName);

        if (xwalkFound) {
            // Find the crosswalk we will be using to generate the metadata for this mdSec
            DisseminationCrosswalk xwalk = (DisseminationCrosswalk) PluginManager
                    .getNamedPlugin(DisseminationCrosswalk.class, xwalkName);

            if (xwalk.canDisseminate(dso)) {
                // Check if our Crosswalk actually wraps another Packager Plugin
                if (xwalk instanceof AbstractPackagerWrappingCrosswalk) {
                    // If this crosswalk wraps another Packager Plugin, we can pass it our Packaging Parameters
                    // (which essentially allow us to customize the output of the crosswalk)
                    AbstractPackagerWrappingCrosswalk wrapper = (AbstractPackagerWrappingCrosswalk) xwalk;
                    wrapper.setPackagingParameters(params);
                }

                //For a normal DisseminationCrosswalk, we will be expecting an XML (DOM) based result.
                // So, we are going to wrap this XML result in an <mdWrap> element
                MdWrap mdWrap = new MdWrap();
                setMdType(mdWrap, metsName);
                XmlData xmlData = new XmlData();
                if (crosswalkToMetsElement(xwalk, dso, xmlData) != null) {
                    mdWrap.getContent().add(xmlData);
                    mdSec.getContent().add(mdWrap);
                    return mdSec;
                } else {
                    return null;
                }
            } else {
                return null;
            }
        }
        // If we didn't find the correct crosswalk, we will check to see if this is
        // a StreamDisseminationCrosswalk -- a Stream crosswalk disseminates to an OutputStream
        else {
            StreamDisseminationCrosswalk sxwalk = (StreamDisseminationCrosswalk) PluginManager
                    .getNamedPlugin(StreamDisseminationCrosswalk.class, xwalkName);
            if (sxwalk != null) {
                if (sxwalk.canDisseminate(context, dso)) {
                    // Check if our Crosswalk actually wraps another Packager Plugin
                    if (sxwalk instanceof AbstractPackagerWrappingCrosswalk) {
                        // If this crosswalk wraps another Packager Plugin, we can pass it our Packaging Parameters
                        // (which essentially allow us to customize the output of the crosswalk)
                        AbstractPackagerWrappingCrosswalk wrapper = (AbstractPackagerWrappingCrosswalk) sxwalk;
                        wrapper.setPackagingParameters(params);
                    }

                    // Disseminate crosswalk output to an outputstream
                    ByteArrayOutputStream disseminateOutput = new ByteArrayOutputStream();
                    sxwalk.disseminate(context, dso, disseminateOutput);
                    // Convert output to an inputstream, so we can write to manifest or Zip file
                    ByteArrayInputStream crosswalkedStream = new ByteArrayInputStream(
                            disseminateOutput.toByteArray());

                    //If we are capturing extra files to put into a Zip package
                    if (extraStreams != null) {
                        //Create an <mdRef> -- we'll just reference the file by name in Zip package
                        MdRef mdRef = new MdRef();
                        //add the crosswalked Stream to list of files to add to Zip package later
                        extraStreams.addStream(mdRef, crosswalkedStream);

                        //set properties on <mdRef>
                        // Note, filename will get set on this <mdRef> later,
                        // when we process all the 'extraStreams'
                        mdRef.setMIMETYPE(sxwalk.getMIMEType());
                        setMdType(mdRef, metsName);
                        mdRef.setLOCTYPE(Loctype.URL);
                        mdSec.getContent().add(mdRef);
                    } else {
                        //If we are *not* capturing extra streams to add to Zip package later,
                        // that means we are likely only generating a METS manifest
                        // (i.e. manifestOnly = true)
                        // In this case, the best we can do is take the crosswalked
                        // Stream, base64 encode it, and add in an <mdWrap> field

                        // First, create our <mdWrap>
                        MdWrap mdWrap = new MdWrap();
                        mdWrap.setMIMETYPE(sxwalk.getMIMEType());
                        setMdType(mdWrap, metsName);

                        // Now, create our <binData> and add base64 encoded contents to it.
                        BinData binData = new BinData();
                        Base64 base64 = new Base64(crosswalkedStream);
                        binData.getContent().add(base64);
                        mdWrap.getContent().add(binData);
                        mdSec.getContent().add(mdWrap);
                    }

                    return mdSec;
                } else {
                    return null;
                }
            } else {
                throw new PackageValidationException("Cannot find " + xwalkName
                        + " crosswalk plugin, either DisseminationCrosswalk or StreamDisseminationCrosswalk");
            }
        }
    } catch (InstantiationException e) {
        throw new PackageValidationException("Error instantiating Mdsec object: " + e.toString(), e);
    } catch (IllegalAccessException e) {
        throw new PackageValidationException("Error instantiating Mdsec object: " + e.toString(), e);
    }
}

From source file:dk.defxws.fedoragsearch.server.Config.java

public SearchResultFiltering getSearchResultFiltering() throws ConfigException {
    SearchResultFiltering srfInstance = null;
    if (searchResultFilteringModuleProperty != null && searchResultFilteringModuleProperty.length() > 0) {
        try {//from w  w w.j  a va  2 s.c  o m
            Class srfClass = Class.forName(searchResultFilteringModuleProperty);
            try {
                srfInstance = (SearchResultFiltering) srfClass.getConstructor(new Class[] {})
                        .newInstance(new Object[] {});
            } catch (InstantiationException e) {
                throw new ConfigException("\n*** " + configName + ": fedoragsearch.searchResultFilteringModule="
                        + searchResultFilteringModuleProperty + ": instantiation error.\n" + e.toString());
            } catch (IllegalAccessException e) {
                throw new ConfigException("\n*** " + configName + ": fedoragsearch.searchResultFilteringModule="
                        + searchResultFilteringModuleProperty + ": instantiation error.\n" + e.toString());
            } catch (InvocationTargetException e) {
                throw new ConfigException("\n*** " + configName + ": fedoragsearch.searchResultFilteringModule="
                        + searchResultFilteringModuleProperty + ": instantiation error.\n" + e.toString());
            } catch (NoSuchMethodException e) {
                throw new ConfigException("\n*** " + configName + ": fedoragsearch.searchResultFilteringModule="
                        + searchResultFilteringModuleProperty + ": instantiation error.\n" + e.toString());
            }
        } catch (ClassNotFoundException e) {
            throw new ConfigException("\n*** " + configName + ": fedoragsearch.searchResultFilteringModule="
                    + searchResultFilteringModuleProperty + ": class not found.\n" + e);
        }
    }
    return srfInstance;
}

From source file:com.t2.compassionMeditation.MeditationActivity.java

/** Called when the activity is first created. */
@Override// ww  w.  ja v a  2 s  .c om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(TAG, this.getClass().getSimpleName() + ".onCreate()");

    mInstance = this;
    mRateOfChange = new RateOfChange(mRateOfChangeSize);

    mIntroFade = 255;

    // We don't want the screen to timeout in this activity
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE); // This needs to happen BEFORE setContentView

    setContentView(R.layout.buddah_activity_layout);

    sharedPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    currentMindsetData = new MindsetData(this);
    mSaveRawWave = SharedPref.getBoolean(this, BioZenConstants.PREF_SAVE_RAW_WAVE,
            BioZenConstants.PREF_SAVE_RAW_WAVE_DEFAULT);

    mShowAGain = SharedPref.getBoolean(this, BioZenConstants.PREF_SHOW_A_GAIN,
            BioZenConstants.PREF_SHOW_A_GAIN_DEFAULT);

    mAllowComments = SharedPref.getBoolean(this, BioZenConstants.PREF_COMMENTS,
            BioZenConstants.PREF_COMMENTS_DEFAULT);

    mShowForeground = SharedPref.getBoolean(this, "show_lotus", true);
    mShowToast = SharedPref.getBoolean(this, "show_toast", true);

    mAudioTrackResourceName = SharedPref.getString(this, "audio_track", "None");
    mBaseImageResourceName = SharedPref.getString(this, "background_images", "Sunset");

    mBioHarnessParameters = getResources().getStringArray(R.array.bioharness_parameters_array);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    String s = SharedPref.getString(this, BioZenConstants.PREF_SESSION_LENGTH, "10");
    mSecondsRemaining = Integer.parseInt(s) * 60;
    mSecondsTotal = mSecondsRemaining;

    s = SharedPref.getString(this, BioZenConstants.PREF_ALPHA_GAIN, "5");
    mAlphaGain = Float.parseFloat(s);

    mMovingAverage = new TMovingAverageFilter(mMovingAverageSize);
    mMovingAverageROC = new TMovingAverageFilter(mMovingAverageSizeROC);

    View v1 = findViewById(R.id.buddahView);
    v1.setOnTouchListener(this);

    Resources resources = this.getResources();
    AssetManager assetManager = resources.getAssets();

    // Set up member variables to UI Elements
    mTextInfoView = (TextView) findViewById(R.id.textViewInfo);
    mTextBioHarnessView = (TextView) findViewById(R.id.textViewBioHarness);
    mCountdownTextView = (TextView) findViewById(R.id.countdownTextView);
    mCountdownImageView = (ImageView) findViewById(R.id.imageViewCountdown);

    mPauseButton = (ImageButton) findViewById(R.id.buttonPause);
    mSignalImage = (ImageView) findViewById(R.id.imageView1);
    mTextViewInstructions = (TextView) findViewById(R.id.textViewInstructions);

    // Note that the seek bar is a debug thing - used only to set the
    // alpha of the buddah image manually for visual testing
    mSeekBar = (SeekBar) findViewById(R.id.seekBar1);
    mSeekBar.setOnSeekBarChangeListener(this);

    // Scale such that values to the right of center are scaled 1 - 10
    // and values to the left of center are scaled 0 = .99999
    if (mAlphaGain > 1.0) {
        mSeekBar.setProgress(50 + (int) (mAlphaGain * 5));
    } else {
        int i = (int) (mAlphaGain * 50);
        mSeekBar.setProgress(i);
    }
    //      mSeekBar.setProgress((int) mAlphaGain * 10);      

    // Controls start as invisible, need to touch screen to activate them
    mCountdownTextView.setVisibility(View.INVISIBLE);
    mCountdownImageView.setVisibility(View.INVISIBLE);
    mTextInfoView.setVisibility(View.INVISIBLE);
    mTextBioHarnessView.setVisibility(View.INVISIBLE);
    mPauseButton.setVisibility(View.INVISIBLE);
    mPauseButton.setVisibility(View.VISIBLE);
    mSeekBar.setVisibility(View.INVISIBLE);

    mBackgroundImage = (ImageView) findViewById(R.id.buddahView);
    mForegroundImage = (ImageView) findViewById(R.id.lotusView);
    mBaseImage = (ImageView) findViewById(R.id.backgroundView);

    if (!mShowForeground) {
        mForegroundImage.setVisibility(View.INVISIBLE);
    }

    int resource = 0;
    if (mBaseImageResourceName.equalsIgnoreCase("Buddah")) {
        mBackgroundImage.setImageResource(R.drawable.buddha);
        mForegroundImage.setImageResource(R.drawable.lotus_flower);
        mBaseImage.setImageResource(R.drawable.none_bg);
    } else if (mBaseImageResourceName.equalsIgnoreCase("Bob")) {
        mBackgroundImage.setImageResource(R.drawable.bigbob);
        mForegroundImage.setImageResource(R.drawable.red_nose);
        mBaseImage.setImageResource(R.drawable.none_bg);
    } else if (mBaseImageResourceName.equalsIgnoreCase("Sunset")) {
        mBackgroundImage.setImageResource(R.drawable.eeg_layer);
        mForegroundImage.setImageResource(R.drawable.breathing_rate);
        mBaseImage.setImageResource(R.drawable.meditation_bg);
    }

    // Initialize SPINE by passing the fileName with the configuration properties
    try {
        mManager = SPINEFactory.createSPINEManager("SPINETestApp.properties", resources);
    } catch (InstantiationException e) {
        Log.e(TAG, "Exception creating SPINE manager: " + e.toString());
        e.printStackTrace();
    }

    // Since Mindset is a static node we have to manually put it in the active node list
    // Note that the sensor id 0xfff1 (-15) is a reserved id for this particular sensor
    Node mindsetNode = null;
    mindsetNode = new Node(new Address("" + Constants.RESERVED_ADDRESS_MINDSET));
    mManager.getActiveNodes().add(mindsetNode);

    Node zepherNode = null;
    zepherNode = new Node(new Address("" + Constants.RESERVED_ADDRESS_ZEPHYR));
    mManager.getActiveNodes().add(zepherNode);

    // The arduino node is programmed to look like a static Spine node
    // Note that currently we don't have  to turn it on or off - it's always streaming
    // Since Spine (in this case) is a static node we have to manually put it in the active node list
    // Since the 
    final int RESERVED_ADDRESS_ARDUINO_SPINE = 1; // 0x0001
    mSpineNode = new Node(new Address("" + RESERVED_ADDRESS_ARDUINO_SPINE));
    mManager.getActiveNodes().add(mSpineNode);

    // Create a broadcast receiver. Note that this is used ONLY for command messages from the service
    // All data from the service goes through the mail SPINE mechanism (received(Data data)).
    // See public void received(Data data)
    this.mCommandReceiver = new SpineReceiver(this);

    try {
        PackageManager packageManager = this.getPackageManager();
        PackageInfo info = packageManager.getPackageInfo(this.getPackageName(), 0);
        mApplicationVersion = info.versionName;
        Log.i(TAG, "BioZen Application Version: " + mApplicationVersion + ", Activity Version: "
                + mActivityVersion);
    } catch (NameNotFoundException e) {
        Log.e(TAG, e.toString());
    }

    // First create GraphBioParameters for each of the ECG static params (ie mindset)      
    int itemId = 0;
    eegPos = itemId; // eeg always comes first
    mBioParameters.clear();

    for (itemId = 0; itemId < MindsetData.NUM_BANDS + 2; itemId++) { // 2 extra, for attention and meditation
        GraphBioParameter param = new GraphBioParameter(itemId, MindsetData.spectralNames[itemId], "", true);
        param.isShimmer = false;
        mBioParameters.add(param);
    }

    // Now create all of the potential dynamic GBraphBioParameters (GSR, EMG, ECG, HR, Skin Temp, Resp Rate
    String[] paramNamesStringArray = getResources().getStringArray(R.array.parameter_names);

    for (String paramName : paramNamesStringArray) {
        if (paramName.equalsIgnoreCase("not assigned"))
            continue;

        if (paramName.equalsIgnoreCase("EEG"))
            continue;

        GraphBioParameter param = new GraphBioParameter(itemId, paramName, "", true);

        if (paramName.equalsIgnoreCase("gsr")) {
            gsrPos = itemId;
            param.isShimmer = true;
            param.shimmerSensorConstant = SPINESensorConstants.SHIMMER_GSR_SENSOR;
            param.shimmerNode = getShimmerNode();
        }

        if (paramName.equalsIgnoreCase("emg")) {
            emgPos = itemId;
            param.isShimmer = true;
            param.shimmerSensorConstant = SPINESensorConstants.SHIMMER_EMG_SENSOR;
            param.shimmerNode = getShimmerNode();
        }

        if (paramName.equalsIgnoreCase("ecg")) {
            ecgPos = itemId;
            param.isShimmer = true;
            param.shimmerSensorConstant = SPINESensorConstants.SHIMMER_ECG_SENSOR;
            param.shimmerNode = getShimmerNode();
        }

        if (paramName.equalsIgnoreCase("heart rate")) {
            heartRatePos = itemId;
            param.isShimmer = false;
        }

        if (paramName.equalsIgnoreCase("resp rate")) {
            respRatePos = itemId;
            param.isShimmer = false;
        }

        if (paramName.equalsIgnoreCase("skin temp")) {
            skinTempPos = itemId;
            param.isShimmer = false;
        }

        if (paramName.equalsIgnoreCase("EHealth Airflow")) {
            eHealthAirFlowPos = itemId;
            param.isShimmer = false;
        }

        if (paramName.equalsIgnoreCase("EHealth Temp")) {
            eHealthTempPos = itemId;
            param.isShimmer = false;
        }

        if (paramName.equalsIgnoreCase("EHealth SpO2")) {
            eHealthSpO2Pos = itemId;
            param.isShimmer = false;
        }

        if (paramName.equalsIgnoreCase("EHealth Heartrate")) {
            eHealthHeartRatePos = itemId;
            param.isShimmer = false;
        }

        if (paramName.equalsIgnoreCase("EHealth GSR")) {
            eHealthGSRPos = itemId;
            param.isShimmer = false;
        }

        itemId++;
        mBioParameters.add(param);
    }

    // The session start time will be used as session id
    // Note this also sets session start time
    // **** This session ID will be prepended to all JSON data stored
    //      in the external database until it's changed (by the start
    //      of a new session.
    Calendar cal = Calendar.getInstance();
    SharedPref.setBioSessionId(sharedPref, cal.getTimeInMillis());

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.US);
    String sessionDate = sdf.format(new Date());
    long sessionId = SharedPref.getLong(this, "bio_session_start_time", 0);

    mUserId = SharedPref.getString(this, "SelectedUser", "");

    // Now get the database object associated with this user

    try {
        mBioUserDao = getHelper().getBioUserDao();
        mBioSessionDao = getHelper().getBioSessionDao();

        QueryBuilder<BioUser, Integer> builder = mBioUserDao.queryBuilder();
        builder.where().eq(BioUser.NAME_FIELD_NAME, mUserId);
        builder.limit(1);
        //         builder.orderBy(ClickCount.DATE_FIELD_NAME, false).limit(30);
        List<BioUser> list = mBioUserDao.query(builder.prepare());

        if (list.size() == 1) {
            mCurrentBioUser = list.get(0);
        } else if (list.size() == 0) {
            try {
                mCurrentBioUser = new BioUser(mUserId, System.currentTimeMillis());
                mBioUserDao.create(mCurrentBioUser);
            } catch (SQLException e1) {
                Log.e(TAG, "Error creating user " + mUserId, e1);
            }
        } else {
            Log.e(TAG, "General Database error" + mUserId);
        }

    } catch (SQLException e) {
        Log.e(TAG, "Can't find user: " + mUserId, e);

    }

    mSignalImage.setImageResource(R.drawable.signal_bars0);

    // Check to see of there a device configured for EEG, if so then show the skin conductance meter
    String tmp = SharedPref.getString(this, "EEG", null);

    if (tmp != null) {
        mSignalImage.setVisibility(View.VISIBLE);
        mTextViewInstructions.setVisibility(View.VISIBLE);

    } else {
        mSignalImage.setVisibility(View.INVISIBLE);
        mTextViewInstructions.setVisibility(View.INVISIBLE);
    }

    mDataOutHandler = new DataOutHandler(this, mUserId, sessionDate, mAppId,
            DataOutHandler.DATA_TYPE_EXTERNAL_SENSOR, sessionId);

    if (mDatabaseEnabled) {
        TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
        String myNumber = telephonyManager.getLine1Number();

        String remoteDatabaseUri = SharedPref.getString(this, "database_sync_name",
                getString(R.string.database_uri));
        //            remoteDatabaseUri += myNumber; 

        Log.d(TAG, "Initializing database at " + remoteDatabaseUri); // TODO: remove
        try {
            mDataOutHandler.initializeDatabase(dDatabaseName, dDesignDocName, dDesignDocId, byDateViewName,
                    remoteDatabaseUri);
        } catch (DataOutHandlerException e) {
            Log.e(TAG, e.toString());
            e.printStackTrace();
        }
        mDataOutHandler.setRequiresAuthentication(false);
    }

    mBioDataProcessor.initialize(mDataOutHandler);

    mLoggingEnabled = SharedPref.getBoolean(this, "enable_logging", true);
    mDatabaseEnabled = SharedPref.getBoolean(this, "database_enabled", false);
    mAntHrmEnabled = SharedPref.getBoolean(this, "enable_ant_hrm", false);

    mInternalSensorMonitoring = SharedPref.getBoolean(this, "inernal_sensor_monitoring_enabled", false);

    if (mAntHrmEnabled) {
        mHeartRateSource = HEARTRATE_ANT;
    } else {
        mHeartRateSource = HEARTRATE_ZEPHYR;
    }

    if (mLoggingEnabled) {
        mDataOutHandler.enableLogging(this);
    }

    if (mLogCatEnabled) {
        mDataOutHandler.enableLogCat();
    }

    // Log the version
    try {
        PackageManager packageManager = getPackageManager();
        PackageInfo info = packageManager.getPackageInfo(getPackageName(), 0);
        mApplicationVersion = info.versionName;
        String versionString = mAppId + " application version: " + mApplicationVersion;

        DataOutPacket packet = new DataOutPacket();
        packet.add(DataOutHandlerTags.version, versionString);
        try {
            mDataOutHandler.handleDataOut(packet);
        } catch (DataOutHandlerException e) {
            Log.e(TAG, e.toString());
            e.printStackTrace();
        }

    } catch (NameNotFoundException e) {
        Log.e(TAG, e.toString());
    }

    if (mInternalSensorMonitoring) {
        // IntentSender Launches our service scheduled with with the alarm manager 
        mBigBrotherService = PendingIntent.getService(MeditationActivity.this, 0,
                new Intent(MeditationActivity.this, BigBrotherService.class), 0);

        long firstTime = SystemClock.elapsedRealtime();
        // Schedule the alarm!
        AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
        am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, mPollingPeriod * 1000,
                mBigBrotherService);

        // Tell the user about what we did.
        Toast.makeText(MeditationActivity.this, R.string.service_scheduled, Toast.LENGTH_LONG).show();

    }

}

From source file:com.netscape.cmscore.apps.CMSEngine.java

/**
 * load subsystems//  www  .j a va 2  s . com
 */
protected void loadSubsystems() throws EBaseException {

    logger.debug("CMSEngine: loading static subsystems");

    staticSubsystems.clear();

    staticSubsystems.put(Debug.ID, new SubsystemInfo(Debug.ID, Debug.getInstance()));
    staticSubsystems.put(LogSubsystem.ID, new SubsystemInfo(LogSubsystem.ID, LogSubsystem.getInstance()));
    staticSubsystems.put(JssSubsystem.ID, new SubsystemInfo(JssSubsystem.ID, JssSubsystem.getInstance()));
    staticSubsystems.put(DBSubsystem.ID, new SubsystemInfo(DBSubsystem.ID, DBSubsystem.getInstance()));
    staticSubsystems.put(UGSubsystem.ID, new SubsystemInfo(UGSubsystem.ID, UGSubsystem.getInstance()));
    staticSubsystems.put(PluginRegistry.ID, new SubsystemInfo(PluginRegistry.ID, new PluginRegistry()));
    staticSubsystems.put(OidLoaderSubsystem.ID,
            new SubsystemInfo(OidLoaderSubsystem.ID, OidLoaderSubsystem.getInstance()));
    staticSubsystems.put(X500NameSubsystem.ID,
            new SubsystemInfo(X500NameSubsystem.ID, X500NameSubsystem.getInstance()));
    // skip TP subsystem;
    // problem in needing dbsubsystem in constructor. and it's not used.
    staticSubsystems.put(RequestSubsystem.ID,
            new SubsystemInfo(RequestSubsystem.ID, RequestSubsystem.getInstance()));

    logger.debug("CMSEngine: loading dyn subsystems");

    dynSubsystems.clear();

    ArrayList<String> ssNames = getDynSubsystemNames();
    IConfigStore ssconfig = mConfig.getSubStore(PROP_SUBSYSTEM);

    for (String ssName : ssNames) {
        IConfigStore config = ssconfig.getSubStore(ssName);

        String id = config.getString(PROP_ID);
        String classname = config.getString(PROP_CLASS);
        boolean enabled = config.getBoolean(PROP_ENABLED, true);

        ISubsystem ss = null;
        try {
            ss = (ISubsystem) Class.forName(classname).newInstance();
        } catch (InstantiationException e) {
            throw new EBaseException(CMS.getUserMessage("CMS_BASE_LOAD_FAILED_1", id, e.toString()), e);
        } catch (IllegalAccessException e) {
            throw new EBaseException(CMS.getUserMessage("CMS_BASE_LOAD_FAILED_1", id, e.toString()), e);
        } catch (ClassNotFoundException e) {
            throw new EBaseException(CMS.getUserMessage("CMS_BASE_LOAD_FAILED_1", id, e.toString()), e);
        }

        dynSubsystems.put(id, new SubsystemInfo(id, ss, enabled, true));
        logger.debug("CMSEngine: loaded dyn subsystem " + id);
    }

    logger.debug("CMSEngine: loading final subsystems");

    finalSubsystems.clear();

    finalSubsystems.put(AuthSubsystem.ID, new SubsystemInfo(AuthSubsystem.ID, AuthSubsystem.getInstance()));
    finalSubsystems.put(AuthzSubsystem.ID, new SubsystemInfo(AuthzSubsystem.ID, AuthzSubsystem.getInstance()));
    finalSubsystems.put(JobsScheduler.ID, new SubsystemInfo(JobsScheduler.ID, JobsScheduler.getInstance()));

    if (isPreOpMode()) {
        // Disable some subsystems before database initialization
        // in pre-op mode to prevent errors.
        SubsystemInfo si = staticSubsystems.get(UGSubsystem.ID);
        si.enabled = false;
    }
}