protected void initService () throws Exception { Element e = getPersist (); QFactory factory = getServer().getFactory(); sm = (SMAdapter) factory.newInstance (getImpl ()); factory.setLogger (sm, e); factory.setConfiguration (sm, e); }
@Test public void testGetAttributeName() throws Throwable { String result = new QFactory(new ObjectName(""), null).getAttributeName("testQFactoryName"); assertEquals("result", "TestQFactoryName", result); }
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 AttributeList getAttributeList(Element e) throws ConfigurationException { AttributeList attributeList = new AttributeList(); List childs = e.getChildren("attr"); for (Object child : childs) { Element childElement = (Element) child; String name = childElement.getAttributeValue("name"); name = getAttributeName(name); Attribute attr = new Attribute(name, getObject(childElement)); attributeList.add(attr); } return attributeList; }
public TransactionParticipant createParticipant (Element e) throws ConfigurationException { QFactory factory = getFactory(); TransactionParticipant participant = (TransactionParticipant) factory.newInstance (e.getAttributeValue ("class") ); factory.setLogger (participant, e); QFactory.invoke (participant, "setTransactionManager", this, TransactionManager.class); factory.setConfiguration (participant, e); String realm = e.getAttributeValue("realm"); if (realm != null && realm.trim().length() > 0) realm = ":" + realm; else realm = ""; names.put(participant, Caller.shortClassName(participant.getClass().getName())+realm); if (participant instanceof Destroyable) { destroyables.add((Destroyable) participant); } return participant; }
protected void initStatusListeners (Element config) throws ConfigurationException{ final Iterator iter = config.getChildren ("status-listener").iterator(); while (iter.hasNext()) { final Element e = (Element) iter.next(); final QFactory factory = getFactory(); final TransactionStatusListener listener = (TransactionStatusListener) factory.newInstance (e.getAttributeValue ("class")); factory.setConfiguration (listener, config); addListener(listener); } }
@Test public void testSetConfigurationThrowsNullPointerException() throws Throwable { String[] args = new String[0]; try { new QFactory(new ObjectName(""), new Q2(args)).setConfiguration(new IVA_ALPHANUM(true, 100, 1000, "testQFactoryDescription"), null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
protected void initService () throws Exception { QFactory factory = getServer().getFactory(); Element e = getPersist (); task = (Runnable) factory.newInstance (e.getChildTextTrim ("class")); factory.setLogger (task, e); } protected void startService () throws Exception {
); try { setAttribute (mserver, objectName, "Name", name); String logger = e.getAttributeValue ("logger"); if (logger != null) setAttribute (mserver, objectName, "Logger", logger); String realm = e.getAttributeValue ("realm"); if (realm != null) setAttribute (mserver, objectName, "Realm", realm); setAttribute (mserver, objectName, "Server", server); setAttribute (mserver, objectName, "Persist", e); configureQBean(mserver,objectName,e); setConfiguration (obj, e); // handle legacy (QSP v1) Configurables
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); } }
Object beanInstance = getFactory().newInstance(className); List propertyList = bean.getChildren("property"); for (Object aPropertyList : propertyList) { + pName.substring(1); if (pValue == null) { QFactory.invoke(beanInstance, methodName, getBean(pRef)); } else { QFactory.invoke(beanInstance, methodName, pValue); QFactory.invoke(beanInstance, startMethod, null);
public Object newInstance (String clazz) throws Exception { return getFactory().newInstance (clazz); } }
protected void startService () throws Exception { getServer().getFactory().setConfiguration(task, getPersist()); NameRegistrar.register (getName (), task); if (task instanceof Runnable) { new Thread ((Runnable) task).start (); } } protected void stopService () throws Exception {
@Test public void testCreateQBeanThrowsNullPointerException() throws Throwable { Element e = new Element("testQFactoryName", "testQFactoryPrefix", "testQFactoryUri"); try { new QFactory(new ObjectName(""), null).createQBean(null, e, new Join()); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertEquals("e.getName()", "testQFactoryName", e.getName()); } }
@Test public void testGetObjectThrowsNullPointerException() throws Throwable { QFactory qFactory = new QFactory(new ObjectName(""), null); try { qFactory.getObject(null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
@Test public void testInstantiateThrowsNullPointerException1() throws Throwable { String[] args = new String[0]; Q2 q2 = new Q2(args); QFactory qFactory = new QFactory(null, q2); Element e = new Element("testQFactoryName", "testQFactoryUri"); try { qFactory.instantiate(null, e); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertTrue("qFactory.classMapping.getKeys().hasMoreElements()", qFactory.classMapping .getKeys().hasMoreElements()); assertSame("qFactory.q2", q2, qFactory.q2); assertEquals("e.getName()", "testQFactoryName", e.getName()); } }
@Test public void testDestroyQBeanThrowsNullPointerException1() throws Throwable { String[] args = new String[0]; Hashtable<String, String> hashtable = new Hashtable<String, String>(100, 100.0F); hashtable.put("testString", "testString"); try { new QFactory(ObjectName.getInstance("testQFactoryParam1", hashtable), null).destroyQBean(new Q2(args), new ObjectName( "testQFactoryParam1", "testQFactoryParam2", "testQFactoryParam3"), new ChannelAdaptor()); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
@Test public void testStartQBeanThrowsNullPointerException() throws Throwable { String[] args = new String[0]; Q2 q2 = new Q2(args); try { new QFactory(null, q2).startQBean(q2, new ObjectName("")); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } } }
if (evt != null) evt.addMessage("deploy: " + f.getCanonicalPath()); Object obj = factory.instantiate (this, rootElement); qentry.setObject (obj); ObjectInstance instance = factory.createQBean ( this, doc.getRootElement(), obj );