/** * Creates a new object, it takes the class from the value of the property * <code>propertyName</code> * @param propertyName Property whose value is the class name of * the object being created. */ public Object getObject (String propertyName) throws ConfigurationException{ try{ Object ret = Class.forName (get (propertyName)).newInstance(); if(ret instanceof Configurable) ((Configurable)ret).setConfiguration(this); return ret; } catch (Exception e){ throw new ConfigurationException ("Error trying to create an " + "object from property " + prefix + propertyName, e ); } } @Override
protected void startService () throws Exception { if (task instanceof Configurable) { Element e = getPersist (); QFactory factory = getServer().getFactory(); ((Configurable)task).setConfiguration ( factory.getConfiguration (e) ); } (thisThread = new Thread(this)).start(); } protected void stopService () throws Exception {
public void setConfiguration (Object obj, Element e) throws ConfigurationException { try { if (obj instanceof Configurable) ((Configurable)obj).setConfiguration (getConfiguration (e)); if (obj instanceof XmlConfigurable) ((XmlConfigurable)obj).setConfiguration(e); } catch (ConfigurationException ex) { throw new ConfigurationException (ex); } } /**
/** * requires <code>inner-packager</code> property * @param cfg Configuration object * @throws ConfigurationException */ public void setConfiguration (Configuration cfg) throws ConfigurationException { this.cfg = cfg; String packagerName = cfg.get ("inner-packager"); try { Class p = Class.forName(packagerName); setPackager ((ISOPackager) p.newInstance()); if (standardPackager instanceof Configurable) ((Configurable)standardPackager).setConfiguration (cfg); } catch (ClassNotFoundException e) { throw new ConfigurationException ("Invalid inner-packager", e); } catch (InstantiationException e) { throw new ConfigurationException ("Invalid inner-packager", e); } catch (IllegalAccessException e) { throw new ConfigurationException ("Invalid inner-packager", e); } } }
@Override public void setConfiguration (Configuration cfg) throws ConfigurationException { this.cfg = cfg; configureConnectionPerms(); backlog = cfg.getInt ("backlog", 0); ignoreISOExceptions = cfg.getBoolean("ignore-iso-exceptions"); String ip = cfg.get ("bind-address", null); if (ip != null) { try { bindAddr = InetAddress.getByName (ip); } catch (UnknownHostException e) { throw new ConfigurationException ("Invalid bind-address " + ip, e); } } if (socketFactory == null) { socketFactory = this; } if (socketFactory != this && socketFactory instanceof Configurable) { ((Configurable)socketFactory).setConfiguration (cfg); } }
protected void startService () throws Exception { Object obj = getObject(); if (obj instanceof Configurable) { QFactory factory = getServer().getFactory(); Element e = getPersist (); ((Configurable)obj).setConfiguration ( factory.getConfiguration (e) ); } CardAgentLookup.add ((CardAgent) getObject ()); } protected void stopService () throws Exception {
private void addListener (Element e) throws ConfigurationException { QFactory factory = getServer().getFactory(); String clazz = e.getAttributeValue ("class"); LogListener listener = (LogListener) factory.newInstance (clazz); if (listener instanceof Configurable) { try { ((Configurable) listener).setConfiguration ( factory.getConfiguration (e) ); } catch (ConfigurationException ex) { throw new ConfigurationException (ex); } } if (listener instanceof XmlConfigurable) { try { ((XmlConfigurable) listener).setConfiguration (e); } catch (ConfigurationException ex) { throw new ConfigurationException (ex); } } logger.addListener (listener); } }
roundRobin = cfg.getBoolean ("round-robin", false); if (socketFactory != this && socketFactory instanceof Configurable) ((Configurable)socketFactory).setConfiguration (cfg); try { setTimeout (cfg.getInt ("timeout", DEFAULT_TIMEOUT));
protected void initService () throws Exception { QFactory factory = getServer().getFactory(); dirPoll = createDirPoll(); dirPoll.setPath (getPath ()); dirPoll.setThreadPool (new ThreadPool (1, poolSize)); dirPoll.setPollInterval (pollInterval); if (priorities != null) dirPoll.setPriorities (priorities); dirPoll.setLogger (getLog().getLogger(), getLog().getRealm ()); Configuration cfg = factory.getConfiguration (getPersist()); dirPoll.setConfiguration (cfg); dirPoll.createDirs (); Object dpp = factory.newInstance (getProcessor()); if (dpp instanceof LogSource) { ((LogSource) dpp).setLogger ( getLog().getLogger(), getLog().getRealm () ); } if (dpp instanceof Configurable) { ((Configurable) dpp).setConfiguration (cfg); } dirPoll.setProcessor (dpp); }
((Configurable) processor).setConfiguration (cfg);