private MessageSelection loadMessageSelection(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { Location location = reader.getLocation(); String selector = reader.getAttributeValue(null, "selector"); if (selector == null) { MissingAttribute error = new MissingAttribute("Selector not specified for message selection", location); context.addError(error); selector = "invalid"; } MessageSelection messageSelection = new MessageSelection(selector); loadProperties(reader, messageSelection, "messageSelection"); return messageSelection; }
public void index(Resource resource, XMLStreamReader reader, IntrospectionContext context) throws InstallException { QName qname = reader.getName(); assert PLAN.equals(qname); String name = reader.getAttributeValue(null, "name"); if (name == null) { context.addError(new MissingAttribute("Deployment plan name not specified", reader)); return; } QName planQName = new QName(PLAN_NAMESPACE, name); QNameSymbol symbol = new QNameSymbol(planQName); ResourceElement<QNameSymbol, DeploymentPlan> element = new ResourceElement<QNameSymbol, DeploymentPlan>(symbol); resource.addResourceElement(element); }
/** * Parses a deployable mapping * * @param plan the deployment plan * @param reader the XML reader * @param context the validation context * @return true if the mapping was processed successfully, false if there was a validation error */ private boolean processDeployableMapping(DeploymentPlan plan, XMLStreamReader reader, IntrospectionContext context) { String deployableName = reader.getAttributeValue(null, "deployable"); if (deployableName == null) { context.addError(new MissingAttribute("Deployable name not specified in mapping", reader)); return false; } QName deployable = LoaderUtil.getQName(deployableName, null, reader.getNamespaceContext()); String zoneName = reader.getAttributeValue(null, "zone"); if (zoneName == null) { context.addError(new MissingAttribute("Zone not specified in mapping", reader)); return false; } plan.addDeployableMapping(deployable, zoneName); return true; }
public FileBinding load(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { Location startLocation = reader.getLocation(); String bindingName = reader.getAttributeValue(null, "name"); String location = reader.getAttributeValue(null, "location"); if (location == null) { MissingAttribute error = new MissingAttribute("The location attribute must be specified", startLocation); context.addError(error); } String archiveLocation = reader.getAttributeValue(null, "archive.location"); Strategy strategy = parseStrategy(reader); if (Strategy.ARCHIVE == strategy && archiveLocation == null) { MissingAttribute error = new MissingAttribute("An archive location must be specified", startLocation); context.addError(error); } String errorLocation = reader.getAttributeValue(null, "error.location"); String adapterClass = reader.getAttributeValue(null, "adapter"); String adapterUri = reader.getAttributeValue(null, "adapter.component"); String pattern = reader.getAttributeValue(null, "pattern"); long delay = parseDelay(reader, context); FileBinding binding = new FileBinding(bindingName, pattern, location, strategy, archiveLocation, errorLocation, adapterClass, adapterUri, delay); validateAttributes(reader, context, binding); LoaderUtil.skipToEndElement(reader); return binding; }
public ComponentAppenderDefinition load(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { addAttributes("name"); validateAttributes(reader, context); String componentName = reader.getAttributeValue(null, "name"); if (componentName == null) { ComponentAppenderDefinition definition = new ComponentAppenderDefinition(""); MissingAttribute error = new MissingAttribute("A component name must be defined for the appender", reader.getLocation(), definition); context.addError(error); return definition; } return new ComponentAppenderDefinition(componentName); } }
public CacheSetResourceDefinition load(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { CacheSetResourceDefinition definition = new CacheSetResourceDefinition(); validateAttributes(reader, context, definition); while (true) { switch (reader.next()) { case XMLStreamConstants.START_ELEMENT: if ("cache".equals(reader.getName().getLocalPart())) { Location location = reader.getLocation(); String name = reader.getAttributeValue(null, "name"); if (null == name) { MissingAttribute error = new MissingAttribute("Cache name not specified", location); context.addError(error); name = "default"; } reader.nextTag(); CacheResourceDefinition configuration = registry.load(reader, CacheResourceDefinition.class, context); if (configuration == null) { continue; } configuration.setCacheName(name); definition.addDefinition(configuration); } break; case XMLStreamConstants.END_ELEMENT: if ("caches".equals(reader.getName().getLocalPart())) { return definition; } } } }
private WsdlServiceContract processInterface(XMLStreamReader reader, Location location, IntrospectionContext context) { Location startLocation = reader.getLocation(); String interfaze = reader.getAttributeValue(null, "interface"); if (interfaze == null) { MissingAttribute failure = new MissingAttribute("Interface attribute is required", startLocation); context.addError(failure); return new WsdlServiceContract(null, null); } QName portTypeName = parseQName(interfaze, location, context); if (portTypeName == null) { return new WsdlServiceContract(null, null); } return resolveContract(portTypeName, reader, context); }
public ComponentAppenderDefinition load(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { addAttributes("name"); validateAttributes(reader, context); String componentName = reader.getAttributeValue(null, "name"); if (componentName == null) { ComponentAppenderDefinition definition = new ComponentAppenderDefinition(""); MissingAttribute error = new MissingAttribute("A component name must be defined for the appender", reader.getLocation(), definition); context.addError(error); return definition; } return new ComponentAppenderDefinition(componentName); } }
public PropertyValue load(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { validateAttributes(reader, context); String name = reader.getAttributeValue(null, "name"); if (name == null || name.length() == 0) { MissingAttribute failure = new MissingAttribute("Missing name attribute", reader); context.addError(failure); return null; } String source = reader.getAttributeValue(null, "source"); String file = reader.getAttributeValue(null, "file"); if (source != null) { LoaderUtil.skipToEndElement(reader); return new PropertyValue(name, source); } else if (file != null) { try { URI uri = new URI(file); if (!uri.isAbsolute()) { uri = context.getSourceBase().toURI().resolve(uri); } LoaderUtil.skipToEndElement(reader); return new PropertyValue(name, uri); } catch (URISyntaxException e) { InvalidValue failure = new InvalidValue("File specified for property " + name + " is invalid: " + file, reader, e); context.addError(failure); return null; } } else { return loadInlinePropertyValue(name, reader, context); } }
public OperationDefinition load(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { validateAttributes(reader, context); OperationDefinition operationDefinition = new OperationDefinition(); String name = reader.getAttributeValue(null, "name"); if (name == null) { MissingAttribute failure = new MissingAttribute("Operation name not specified", reader); context.addError(failure); } operationDefinition.setName(name); loaderHelper.loadPolicySetsAndIntents(operationDefinition, reader, context); LoaderUtil.skipToEndElement(reader); return operationDefinition; }
private boolean processImplementationClass(TimerImplementation implementation, XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { Location startLocation = reader.getLocation(); String implClass = reader.getAttributeValue(null, "class"); if (implClass == null) { MissingAttribute failure = new MissingAttribute("The class attribute was not specified", startLocation); context.addError(failure); LoaderUtil.skipToEndElement(reader); return false; } implementation.setImplementationClass(implClass); try { Class<?> clazz = context.getClassLoader().loadClass(implClass); if (!(Runnable.class.isAssignableFrom(clazz))) { InvalidTimerInterface failure = new InvalidTimerInterface(clazz, implementation); context.addError(failure); LoaderUtil.skipToEndElement(reader); return false; } } catch (ClassNotFoundException e) { ImplementationArtifactNotFound failure = new ImplementationArtifactNotFound(implClass, e.getMessage(), implementation); context.addError(failure); LoaderUtil.skipToEndElement(reader); return false; } return true; }
String name = reader.getAttributeValue(null, "name"); if (id == null && name == null) { MissingAttribute failure = new MissingAttribute("A bean id or name must be specified", location); context.addError(failure); return false;
private Destination loadDestination(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { Location location = reader.getLocation(); Destination destination = new Destination(); String jndiName = reader.getAttributeValue(null, "jndiName"); if (jndiName != null) { destination.setName(jndiName); } else { // support name attribute as well String name = reader.getAttributeValue(null, "name"); if (name == null) { MissingAttribute error = new MissingAttribute("Destination must have either a jndiName or name attribute set", location); context.addError(error); } } CreateOption create = parseCreate(reader, context); destination.setCreate(create); String type = reader.getAttributeValue(null, "type"); if (type != null) { if ("queue".equalsIgnoreCase(type)) { destination.setType(DestinationType.QUEUE); } else if ("topic".equalsIgnoreCase(type)) { destination.setType(DestinationType.TOPIC); } else { InvalidValue error = new InvalidValue("Invalid value specified for destination type: " + type, location); context.addError(error); } } loadProperties(reader, destination, "destination"); return destination; }
String name = reader.getAttributeValue(null, "name"); if (id == null && name == null) { MissingAttribute failure = new MissingAttribute("A bean id or name must be specified", location); context.addError(failure); return false;
public TimerPoolResource load(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { Location startLocation = reader.getLocation(); String name = reader.getAttributeValue(null, "name"); if (name == null) { MissingAttribute error = new MissingAttribute("Name not specified for timer pool", startLocation); context.addError(error); return new TimerPoolResource("error"); } String coreSizeAttr = reader.getAttributeValue(null, "size"); TimerPoolResource resource; if (coreSizeAttr == null) { resource = new TimerPoolResource(name); } else { try { int coreSize = Integer.parseInt(coreSizeAttr); resource = new TimerPoolResource(name, coreSize); } catch (NumberFormatException e) { InvalidValue error = new InvalidValue("Invalid core size specified for timer pool", startLocation, e); context.addError(error); return new TimerPoolResource(name); } } validateAttributes(reader, context, resource); LoaderUtil.skipToEndElement(reader); return resource; }
public TimerPoolResource load(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { Location startLocation = reader.getLocation(); String name = reader.getAttributeValue(null, "name"); if (name == null) { MissingAttribute error = new MissingAttribute("Name not specified for timer pool", startLocation); context.addError(error); return new TimerPoolResource("error"); } String coreSizeAttr = reader.getAttributeValue(null, "size"); TimerPoolResource resource; if (coreSizeAttr == null) { resource = new TimerPoolResource(name); } else { try { int coreSize = Integer.parseInt(coreSizeAttr); resource = new TimerPoolResource(name, coreSize); } catch (NumberFormatException e) { InvalidValue error = new InvalidValue("Invalid core size specified for timer pool", startLocation, e); context.addError(error); return new TimerPoolResource(name); } } validateAttributes(reader, context, resource); LoaderUtil.skipToEndElement(reader); return resource; }
private void validateData(Location startLocation, IntrospectionContext context, TimerData data) { if (!data.isIntervalMethod() && data.getIntervalClass() == null && data.getFixedRate() == UNSPECIFIED && data.getRepeatInterval() == UNSPECIFIED && data.getFireOnce() == UNSPECIFIED) { MissingAttribute failure = new MissingAttribute("A task, fixed rate, repeat interval, or time must be specified on the timer component", startLocation); context.addError(failure); } }
public SystemImplementation load(XMLStreamReader reader, IntrospectionContext introspectionContext) throws XMLStreamException { Location startLocation = reader.getLocation(); SystemImplementation implementation = new SystemImplementation(); validateAttributes(reader, introspectionContext, implementation); String implClass = reader.getAttributeValue(null, "class"); if (implClass == null) { MissingAttribute failure = new MissingAttribute("Implementation class must be specified using the class attribute", startLocation); introspectionContext.addError(failure); return null; } Class<?> clazz; try { clazz = introspectionContext.getClassLoader().loadClass(implClass); } catch (ClassNotFoundException e) { InvalidValue failure = new InvalidValue("Implementation class not found:" + implClass, startLocation); introspectionContext.addError(failure); return null; } LoaderUtil.skipToEndElement(reader); implementation.setImplementationClass(clazz); InjectingComponentType componentType = new InjectingComponentType(clazz); implementationIntrospector.introspect(componentType, introspectionContext); implementation.setComponentType(componentType); return implementation; }
public JavaImplementation load(XMLStreamReader reader, IntrospectionContext introspectionContext) throws XMLStreamException { Location startLocation = reader.getLocation(); JavaImplementation implementation = new JavaImplementation(); validateAttributes(reader, introspectionContext, implementation); String implClass = reader.getAttributeValue(null, "class"); if (implClass == null) { MissingAttribute failure = new MissingAttribute("The class attribute was not specified", startLocation); introspectionContext.addError(failure); LoaderUtil.skipToEndElement(reader); return implementation; } Class<?> clazz; try { clazz = introspectionContext.getClassLoader().loadClass(implClass); } catch (ClassNotFoundException e) { ImplementationArtifactNotFound failure = new ImplementationArtifactNotFound(implClass, e.getMessage(), implementation); introspectionContext.addError(failure); LoaderUtil.skipToEndElement(reader); return null; } LoaderUtil.skipToEndElement(reader); implementation.setImplementationClass(clazz); InjectingComponentType componentType = new InjectingComponentType(clazz); introspector.introspect(componentType, introspectionContext); implementation.setComponentType(componentType); return implementation; }
MissingAttribute failure = new MissingAttribute("An interface must be specified using the class attribute", reader); context.addError(failure); return null;