public MockStateManager(final Object component) { final Stateful stateful = component.getClass().getAnnotation(Stateful.class); if (stateful == null) { usesLocalState = false; usesClusterState = false; } else { final Scope[] scopes = stateful.scopes(); boolean local = false; boolean cluster = false; for (final Scope scope : scopes) { if (scope == Scope.LOCAL) { local = true; } else if (scope == Scope.CLUSTER) { cluster = true; } } usesLocalState = local; usesClusterState = cluster; } }
/** * Write the description of the Stateful annotation if provided in this component. * * @param configurableComponent the component to describe * @param xmlStreamWriter the stream writer to use * @throws XMLStreamException thrown if there was a problem writing the XML */ private void writeStatefulInfo(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter) throws XMLStreamException { final Stateful stateful = configurableComponent.getClass().getAnnotation(Stateful.class); writeSimpleElement(xmlStreamWriter, "h3", "State management: "); if(stateful != null) { xmlStreamWriter.writeStartElement("table"); xmlStreamWriter.writeAttribute("id", "stateful"); xmlStreamWriter.writeStartElement("tr"); writeSimpleElement(xmlStreamWriter, "th", "Scope"); writeSimpleElement(xmlStreamWriter, "th", "Description"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeStartElement("tr"); writeSimpleElement(xmlStreamWriter, "td", join(stateful.scopes(), ", ")); writeSimpleElement(xmlStreamWriter, "td", stateful.description()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); } else { xmlStreamWriter.writeCharacters("This component does not store state."); } }
@Override protected void writeStatefulInfo(final Stateful stateful) throws IOException { writeStartElement("stateful"); if (stateful != null) { writeTextElement("description", stateful.description()); writeArray("scopes", Arrays.asList(stateful.scopes()), scope -> writeTextElement("scope", scope.name())); } writeEndElement(); }
public MockStateManager(final Object component) { final Stateful stateful = component.getClass().getAnnotation(Stateful.class); if (stateful == null) { usesLocalState = false; usesClusterState = false; } else { final Scope[] scopes = stateful.scopes(); boolean local = false; boolean cluster = false; for (final Scope scope : scopes) { if (scope == Scope.LOCAL) { local = true; } else if (scope == Scope.CLUSTER) { cluster = true; } } usesLocalState = local; usesClusterState = cluster; } }