Search in sources :

Example 1 with Space

use of org.jpos.space.Space in project jPOS by jpos.

the class FSDMsg method getSchema.

protected Element getSchema(String prefix, String suffix, String defSuffix) throws JDOMException, IOException {
    StringBuilder sb = new StringBuilder(basePath);
    sb.append(prefix);
    // little hack, we'll reuse later with defSuffix
    prefix = sb.toString();
    sb.append(suffix);
    sb.append(".xml");
    String uri = sb.toString();
    Space sp = SpaceFactory.getSpace();
    Element schema = (Element) sp.rdp(uri);
    if (schema == null) {
        schema = loadSchema(uri, defSuffix == null);
        if (schema == null && defSuffix != null) {
            sb = new StringBuilder(prefix);
            sb.append(defSuffix);
            sb.append(".xml");
            schema = loadSchema(sb.toString(), true);
        }
        sp.out(uri, schema);
    }
    return schema;
}
Also used : Space(org.jpos.space.Space) Element(org.jdom2.Element)

Example 2 with Space

use of org.jpos.space.Space in project jPOS by jpos.

the class QServer method grabSpace.

private LocalSpace grabSpace(Element e) throws ConfigurationException {
    String uri = e != null ? e.getText() : "";
    Space sp = SpaceFactory.getSpace(uri);
    if (sp instanceof LocalSpace) {
        return (LocalSpace) sp;
    }
    throw new ConfigurationException("Invalid space " + uri);
}
Also used : LocalSpace(org.jpos.space.LocalSpace) Space(org.jpos.space.Space) LocalSpace(org.jpos.space.LocalSpace) ConfigurationException(org.jpos.core.ConfigurationException)

Example 3 with Space

use of org.jpos.space.Space in project jPOS by jpos.

the class ChannelAdaptorTest method waitForWorkersOnStopDoesNotDeadlockWithUnfortunatelyTimedDisconnectReceivedBySender.

@Ignore("Failing and don't really know what this test tries to verify")
@Test
public void waitForWorkersOnStopDoesNotDeadlockWithUnfortunatelyTimedDisconnectReceivedBySender() throws Exception {
    // Ensure no deadlock between Sender trying to call disconnect() and stop() joining on Sender.
    StubISOChannel channel = new StubISOChannelThatThrowsExceptionOnSend();
    LogListener logListener = mock(LogListener.class);
    Space space = spy(new TSpace());
    ThreadTrap trap = new ThreadTrap(SENDER_THREAD_NAME).delegateAfterReleaseCall();
    trap.catchVictim().when(logListener).log(argThat(sendErrorLogEvent()));
    trap.release().when(space).out(eq(IN_SPACE_KEY), not(isA(ISOMsg.class)));
    channelAdaptor = configureAndStart(new ChannelAdaptorWithStubSpace(channel, space), new SimpleLogListener(), logListener);
    waitForSenderAndReceiverToStart();
    channelAdaptor.send(new ISOMsg("0800"));
    assertThat("Sender did not call log()", trap.catchesVictim(), is(true));
    // Once the sender thread is released it will try to call ChannelAdaptor.disconnect().
    // If disconnect() is synchronized on ChannelAdaptor the sender and stop caller will deadlock.
    assertCallToStopCompletes(1);
}
Also used : Space(org.jpos.space.Space) TSpace(org.jpos.space.TSpace) ISOMsg(org.jpos.iso.ISOMsg) TSpace(org.jpos.space.TSpace) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with Space

use of org.jpos.space.Space in project jPOS by jpos.

the class ChannelAdaptorTest method waitForWorkersOnStopDoesNotDeadlockWithUnfortunatelyTimedDisconnectReceivedByReceiver.

@Ignore("Failing and don't really know what this test tries to verify")
@Test
public void waitForWorkersOnStopDoesNotDeadlockWithUnfortunatelyTimedDisconnectReceivedByReceiver() throws Exception {
    // Ensure no deadlock between Receiver trying to call disconnect() and stop() joining on Receiver.
    StubISOChannel channel = new StubISOChannel();
    Space space = spy(new TSpace());
    ThreadTrap trap = new ThreadTrap(RECEIVER_THREAD_NAME).delegateAfterCatchCall().delegateAfterReleaseCall();
    trap.catchVictim().when(space).out(eq(RECONNECT_SPACE_KEY), any(), eq(RECONNECT_DELAY));
    trap.release().when(space).out(eq(READY_SPACE_KEY), not(isA(Date.class)));
    channelAdaptor = configureAndStart(new ChannelAdaptorWithStubSpace(channel, space));
    waitForSenderAndReceiverToStart();
    // to trap the receiver before it tries to call disconnect() we first need it to be blocked in BaseChannel.receive()
    channel.waitForReceiverToBlockInReceive();
    channel.disconnect();
    assertThat("Receiver did not call sp.out(" + RECONNECT_SPACE_KEY + ", new Object())", trap.catchesVictim(), is(true));
    // Once the receiver thread to is released it will try to call ChannelAdaptor.disconnect().
    // If disconnect() is synchronized on ChannelAdaptor the receiver and stop caller will deadlock.
    assertCallToStopCompletes(1);
}
Also used : Space(org.jpos.space.Space) TSpace(org.jpos.space.TSpace) TSpace(org.jpos.space.TSpace) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with Space

use of org.jpos.space.Space in project jPOS by jpos.

the class QMUXTestCase method getInternalSpace.

private Space getInternalSpace(MUX mux) throws NoSuchFieldException, IllegalAccessException {
    Field field = mux.getClass().getDeclaredField("isp");
    field.setAccessible(true);
    return (Space) field.get(mux);
}
Also used : Space(org.jpos.space.Space) Field(java.lang.reflect.Field)

Aggregations

Space (org.jpos.space.Space)6 ConfigurationException (org.jpos.core.ConfigurationException)2 LocalSpace (org.jpos.space.LocalSpace)2 TSpace (org.jpos.space.TSpace)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 Field (java.lang.reflect.Field)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Element (org.jdom2.Element)1 Configurable (org.jpos.core.Configurable)1 Configuration (org.jpos.core.Configuration)1 ISOMsg (org.jpos.iso.ISOMsg)1 SpaceFactory (org.jpos.space.SpaceFactory)1 SpaceSource (org.jpos.space.SpaceSource)1 Context (org.jpos.transaction.Context)1 ContextConstants (org.jpos.transaction.ContextConstants)1 Log (org.jpos.util.Log)1