[Design of JBossXB] - Re: How to force strict validation?
by rob.stryker@jboss.com
Thanks for the replies:
Just setting validation and schema validation to true did not accomplish what I needed it to do. I still was unable to access the parser to set the properties needed. I ended up cloning UnmarshallerImpl and making the getParser() method public (rather than package private) to do what I needed it to.
| public class ParseTest extends TestCase {
| private static final String SCHEMA = "/home/rob/apps/eclipse/workspaces/work/garbage/src/schema.xsd";
| private static final String DATA = "/home/rob/apps/eclipse/workspaces/work/garbage/data/test.xml";
| public void testABC() {
| try {
| File f = new File(SCHEMA);
| InputStream stream = new FileInputStream(f);
| SchemaBinding binding = XsdBinder.bind(stream, "UTF-8", (String)null);
| stream.close();
| binding.setStrictSchema(true);
| UnmarshallerImpl unmarshaller = new UnmarshallerImpl();
| String schemaLocation = new File("/home/rob/apps/eclipse/workspaces/work/garbage/src/schema.xsd").toURI().toURL().toExternalForm();
| unmarshaller.setValidation(true);
| unmarshaller.getParser().setFeature("http://apache.org/xml/features/validation/schema", true);
| unmarshaller.getParser().setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
| schemaLocation);
| FileInputStream dataStream = new FileInputStream(new File(DATA));
| Object xmlObject = unmarshaller.unmarshal(dataStream, binding);
| System.out.println("object is " + xmlObject);
| } catch( Exception e ) {
| // GOOD! I want XB to fail!
| return;
| }
| fail("data file should not have validated!");
| }
| }
|
Now I'm just looking via APIs to find a similar way to enforce strict validation when writing / marshalling the files as well ;)
Again, thanks for the help.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133030#4133030
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133030
16 years, 8 months
[Design of JBoss Portal] - Re: Event debugger
by julien@jboss.com
Here is the EventPhaseSession interface:
| public interface EventPhaseSession
| {
|
| /**
| * Queue an event for consumption. The queue is a FIFO queue.
| *
| * @param event an event
| * @throws IllegalArgumentException if the event is null
| * @throws IllegalStateException if an event cannot be published
| */
| void queueEvent(Event event) throws IllegalArgumentException, IllegalStateException;
|
| /**
| * Stop processing of all events and returns from the controller.
| *
| * @throws IllegalStateException if the session cannot be interrupted.
| */
| void interrupt() throws IllegalStateException;
|
| }
|
It is usable really only during the routing phase and the event controller context can use it to queue events.
the interrupt method is used by the controller context can be used to interrupt the event phase (for instance a portal logout event could do that).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133025#4133025
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133025
16 years, 8 months
[Design of JBoss Portal] - Re: Event debugger
by julien@jboss.com
here are the relevant methods of the event controller context
| /**
| * <p>Give control to the context when an event is produced. The session
| * argument gives to the context the capability to queue events in response
| * of the produced event or to interrupt the session. It has also access
| * to the full history of distributed events in order to provide advanced
| * implementation of event cycle detection.</p>
| *
| * <p>During the invocation of this method, any runtime exception thrown will signal
| * a failure and the produced event will be discarded although the event
| * distribution will continue.</p>
| *
| * <p>During the invocation of this method, any error thrown will be propagated
| * to the portlet controller invoker.</p>
| *
| * @param session the session
| * @param sourceEvent the source event
| * @param producedEvent the produced event
| */
| void eventProduced(EventPhaseSession session, Event sourceEvent, Event producedEvent);
|
| /**
| * <p>Signal to the context when an event is consumed by a portlet. The session argument
| * only provides querying capabilities and it is not possible to queue event
| * or interrupt the session.</p>
| *
| * <p>During the invocation of this method, any runtime exception thrown will
| * be ignored by the controller.</p>
| *
| * <p>During the invocation of this method, any error thrown will be propagated
| * to the portlet controller invoker.</p>
| *
| * @param session the session
| * @param sourceEvent the source event
| * @param consumedEvent the consumed event
| */
| void eventConsumed(EventPhaseSession session, Event sourceEvent, Event consumedEvent);
|
the first method is used to route an produced event to create events in reaction.
the second method is more an acknowledgement method that say that en event was consumed.
I plan to add other callbacks for ignored events or failures.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4133024#4133024
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4133024
16 years, 8 months