private boolean register (File f) { boolean rc = false; if (f.isDirectory()) { File file[] = f.listFiles (this); for (File aFile : file) { if (register(aFile)) rc = true; } } else if (dirMap.get (f) == null) { dirMap.put (f, new QEntry (isBundle(f))); rc = true; } return rc; }
File f = entry.getKey (); QEntry qentry = entry.getValue (); long deployed = qentry.getDeployed (); if (deployed == 0) { if (qentry.isOSGIBundle()) { osgiBundelList.add(f); qentry.setDeployed (f.lastModified ()); if (qentry.isQBean ()) startList.add (qentry.getInstance()); qentry.setDeployed (f.lastModified ()); } else {
private void undeploy (File f) { QEntry qentry = (QEntry) dirMap.get (f); try { if (log != null) log.trace ("undeploying:" + f.getCanonicalPath()); if (qentry.isQBean()) { Object obj = qentry.getObject (); ObjectName name = qentry.getObjectName (); factory.destroyQBean (this, name, obj); } else if (qentry.isOSGIBundle()) { getLog().warn("OSGI bundle " + f.getName() + " no longer available in deploy directory"); } if (log != null) log.info ("undeployed:" + f.getCanonicalPath()); } catch (Exception e) { getLog().warn ("undeploy", e); } }
evt.addMessage("deploy: " + f.getCanonicalPath()); Object obj = factory.instantiate (this, rootElement); qentry.setObject (obj); qentry.setInstance (instance); } else if (evt != null) { evt.addMessage("deploy ignored (enabled='" + enabledAttribute + "'): " + f.getCanonicalPath());
private void checkModified () { Iterator iter = dirMap.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); File f = (File) entry.getKey (); QEntry qentry = (QEntry) entry.getValue (); if (qentry.isQBean() && qentry.isQPersist()) { ObjectName name = qentry.getObjectName (); if (getState (name) == QBean.STARTED && isModified (name)) { qentry.setDeployed (persist (f, name)); } } } }
@Test public void testQEntryGetDeployed1() throws Throwable { long result = new Q2.QEntry(100L, new ObjectInstance(new ObjectName("testQEntryParam1", "testQEntryParam2", "testQEntryParam3"), "testQEntryParam2")).getDeployed(); assertEquals("result", 100L, result); }
@Test public void testQEntryConstructor() throws Throwable { ObjectInstance instance = new ObjectInstance(new ObjectName("testQEntryParam1", "testQEntryParam2", "testQEntryParam3"), "testQEntryParam2"); Q2.QEntry qEntry = new Q2.QEntry(100L, instance); assertEquals("qEntry.deployed", 100L, qEntry.deployed); assertSame("qEntry.instance", instance, qEntry.instance); }
@Test public void testQEntryGetObjectName1() throws Throwable { ObjectName objectName = new ObjectName("testQEntryParam1", "testQEntryParam2", "testQEntryParam3"); ObjectName result = new Q2.QEntry(100L, new ObjectInstance(objectName, "testQEntryParam2")).getObjectName(); assertSame("result", objectName, result); }
@Test public void testQEntrySetInstance() throws Throwable { ObjectInstance instance = new ObjectInstance(new ObjectName("testQEntryParam1", "testQEntryParam2", "testQEntryParam3"), "testQEntryParam2"); Q2.QEntry qEntry = new Q2.QEntry(100L, instance); qEntry.setInstance(instance); assertSame("qEntry.instance", instance, qEntry.instance); }
@Test public void testQEntryGetObjectName() throws Throwable { ObjectName result = new Q2.QEntry(100L, null).getObjectName(); assertNull("result", result); }
@Test public void testQEntryIsQPersist1() throws Throwable { boolean result = new Q2.QEntry(100L, new ObjectInstance(new ObjectName("testQEntryParam1", "testQEntryParam2", "testQEntryParam3"), "testQEntryParam2")).isQPersist(); assertFalse("result", result); }
@Test public void testQEntryGetInstance() throws Throwable { ObjectInstance instance = new ObjectInstance(new ObjectName("testQEntryParam1", "testQEntryParam2", "testQEntryParam3"), "testQEntryParam2"); ObjectInstance result = new Q2.QEntry(100L, instance).getInstance(); assertSame("result", instance, result); }
@Test public void testQEntryGetObject1() throws Throwable { Q2.QEntry qEntry = new Q2.QEntry(100L, new ObjectInstance(new ObjectName("testQEntryParam1", "testQEntryParam2", "testQEntryParam3"), "testQEntryParam2")); Object obj = new Object(); qEntry.setObject(obj); Object result = qEntry.getObject(); assertSame("result", obj, result); }
@Test public void testQEntryIsQBean1() throws Throwable { Q2.QEntry qEntry = new Q2.QEntry(100L, new ObjectInstance(new ObjectName("testQEntryParam1", "testQEntryParam2", "testQEntryParam3"), "testQEntryParam2")); qEntry.setObject(new SystemMonitor()); boolean result = qEntry.isQBean(); assertTrue("result", result); }
@Test public void testQEntryGetDeployed() throws Throwable { long result = new Q2.QEntry(0L, new ObjectInstance( new ObjectName("testQEntryParam1", "testQEntryParam2", "testQEntryParam3"), "testQEntryParam2")).getDeployed(); assertEquals("result", 0L, result); }