/** * Coerce the given type to {@link Dom}. * Only handles those types that are valid to the {@link #set(Dom, Object)} method. */ protected final Dom toDom(Object arg) { if(arg==null) return null; if(arg instanceof Dom) return (Dom)arg; if(arg instanceof ConfigBeanProxy) return Dom.unwrap((ConfigBeanProxy)arg); throw new IllegalArgumentException("Unexpected type "+arg.getClass()+" for "+xmlName); } }
@Override String elementValue(Object element) { return Dom.unwrap((ConfigBeanProxy) element).getKey(); } }
public void add(int index, Object element) { // update the master children list, as well as this view 'v' Dom child = Dom.unwrap((ConfigBeanProxy) element); dom.insertAfter( index==0 ? null : v.get(index-1), xmlName, child); v.add(index,child); }
public Object set(int index, Object element) { Dom child = Dom.unwrap((ConfigBeanProxy) element); String name = "*".equals(xmlName) ? child.model.injector.getName() : xmlName; dom.replaceChild(v.get(index), name, child); return v.set(index,child).createProxy(); }
public static <T extends ConfigBeanProxy> T getParent(ConfigBeanProxy self, Class<T> c) { Dom dom = Dom.unwrap(self); if (dom.parent()!=null) { return dom.parent().createProxy(c); } else { return null; } }
public static ConfigBeanProxy getParent(ConfigBeanProxy self) { Dom dom = Dom.unwrap(self); if (dom.parent()!=null) { return dom.parent().createProxy(); } else { return null; } }
private ConfigBean _createAndSet( final ConfigBean parent, final Class<? extends ConfigBeanProxy> childType, final List<AttributeChanges> attributes, final TransactionCallBack<WriteableView> runnable) throws TransactionFailure { ConfigBeanProxy readableView = parent.getProxy(parent.getProxyType()); ConfigBeanProxy readableChild = (ConfigBeanProxy) apply(new SingleConfigCode<ConfigBeanProxy>() { public Object run(ConfigBeanProxy param) throws PropertyVetoException, TransactionFailure { return addChildWithAttributes(param, parent, childType, attributes, runnable); } }, readableView); return (ConfigBean) Dom.unwrap(readableChild); }
public void testDom() { SimpleConnector sc = habitat.getService(SimpleConnector.class); EjbContainerAvailability ejb = sc.getEjbContainerAvailability(); assert(Dom.class.isAssignableFrom(Dom.unwrap(ejb).getClass()) && ConfigBeanProxy.class.isAssignableFrom(ejb.getClass())); }
public static Class<? extends ConfigBeanProxy> getElementTypeByName(ConfigBeanProxy parent, String elementName) throws ClassNotFoundException { final Dom parentDom = Dom.unwrap(parent); DomDocument document = parentDom.document; ConfigModel.Property a = parentDom.model.elements.get(elementName); if (a!=null) { if (a.isLeaf()) { // dochez : I am not too sure, but that should be a String @Element return null; } else { ConfigModel childModel = ((ConfigModel.Node) a).model; return (Class<? extends ConfigBeanProxy>) childModel.classLoaderHolder.loadClass(childModel.targetTypeName); } } // global lookup ConfigModel model = document.getModelByElementName(elementName); if (model!=null) { return (Class<? extends ConfigBeanProxy>) model.classLoaderHolder.loadClass(model.targetTypeName); } return null; }
final Object toBeRemovedObj = event.getOldValue(); if ( toBeRemovedObj instanceof ConfigBeanProxy ) { final Dom toBeRemoved = Dom.unwrap((ConfigBeanProxy)toBeRemovedObj); for (int index=0;index<originalList.size();index++) { Object element = originalList.get(index); Dom dom = Dom.unwrap((ConfigBeanProxy) element); if (dom==toBeRemoved) { Object newValue = event.getNewValue();
Dom cbo = Dom.unwrap((ConfigBeanProxy) o); String cboKey = cbo.model.key; if(cboKey != null && key.equals(cboKey.substring(1))){ Dom parent = Dom.unwrap(readView); throw new IllegalArgumentException("A " + master.getProxyType().getSimpleName() + " with the same key \"" + keyValue + "\" already exists in " +
Object oldValue = event.getOldValue(); if (oldValue instanceof ConfigBeanProxy) { Dom domOldValue = Dom.unwrap((ConfigBeanProxy) oldValue); Set<ConfigListener> typedListeners = typeListeners.get(domOldValue.<ConfigBeanProxy>getProxyType()); if (typedListeners!=null) {
public static ConfigBeanProxy deepCopy(ConfigBeanProxy self, ConfigBeanProxy parent) throws TransactionFailure { ConfigBean configBean = (ConfigBean) Dom.unwrap(self); // ensure the parent is locked Transaction t = Transaction.getTransaction(parent); if (t==null) { throw new TransactionFailure("Must use a locked parent config object for copying new config object"); } ConfigBean copy = configBean.copy(configBean.parent()); return t.enroll(copy.createProxy()); }
Dom dom = Dom.unwrap(child);
Dom thisview = Dom.unwrap(defaultView);
public void testHabitatFromDom() { SimpleConnector sc = habitat.getService(SimpleConnector.class); EjbContainerAvailability ejb = sc.getEjbContainerAvailability(); Dom ejbDom = Dom.unwrap(ejb); assert(ejbDom.getHabitat() != null); }
public void testDomTx() { SimpleConnector sc = habitat.getService(SimpleConnector.class); EjbContainerAvailability ejb = sc.getEjbContainerAvailability(); Dom ejbDom = Dom.unwrap(ejb); assert(ejbDom.getHabitat() != null); String avEnabled = ejb.getAvailabilityEnabled(); try { ConfigSupport.apply(new SingleConfigCode<EjbContainerAvailability>() { @Override public Object run(EjbContainerAvailability param) throws PropertyVetoException, TransactionFailure { param.setSfsbHaPersistenceType("coherence"); param.setSfsbCheckpointEnabled("**MUST BE**"); return null; } }, ejb); //printEjb("AFTER CHANGES", ejb); assert(ejb.getSfsbHaPersistenceType().equals("coherence") && ejb.getSfsbCheckpointEnabled().equals("**MUST BE**") && ejb.getAvailabilityEnabled().equals(avEnabled)); } catch (Exception e) { e.printStackTrace(); assert(false); } }
public void testDomTxReadOnlyAttributes() { SimpleConnector sc = habitat.getService(SimpleConnector.class); final EjbContainerAvailability ejb = sc.getEjbContainerAvailability(); Dom ejbDom = Dom.unwrap(ejb); assert(ejbDom.getHabitat() != null); String origAVEnabled = ejb.getAvailabilityEnabled(); final String origSFSBHaPersistenceType = ejb.getSfsbHaPersistenceType(); try { ConfigSupport.apply(new SingleConfigCode<EjbContainerAvailability>() { @Override public Object run(EjbContainerAvailability param) throws PropertyVetoException, TransactionFailure { param.setSfsbHaPersistenceType("99999.999"); param.setSfsbCheckpointEnabled("**MUST BE**"); assert(origSFSBHaPersistenceType.equals(ejb.getSfsbHaPersistenceType())); assert(! ejb.getSfsbHaPersistenceType().equals(param.getSfsbHaPersistenceType())); return null; } }, ejb); //printEjb("AFTER CHANGES", ejb); assert(ejb.getSfsbHaPersistenceType().equals("99999.999") && ejb.getSfsbCheckpointEnabled().equals("**MUST BE**") && ejb.getAvailabilityEnabled().equals(origAVEnabled)); } catch (Exception e) { e.printStackTrace(); assert(false); } }
public static <T extends ConfigBeanProxy> T getParent(ConfigBeanProxy self, Class<T> c) { Dom dom = Dom.unwrap(self); if (dom.parent()!=null) { return dom.parent().createProxy(c); } else { return null; } }