You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2011/05/03 08:33:49 UTC
svn commit: r1098939 [10/11] - in /incubator/isis/trunk/runtimes/dflt:
profilestores/dflt/src/main/java/org/apache/isis/runtimes/dflt/profilestores/dflt/
profilestores/xml/src/main/java/org/apache/isis/runtimes/dflt/profilestores/xml/
profilestores/xml...
Modified: incubator/isis/trunk/runtimes/dflt/remoting/common/src/test/java/org/apache/isis/runtimes/dflt/remoting/common/server/ServerFacadeImpl_RemoteActionTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/common/src/test/java/org/apache/isis/runtimes/dflt/remoting/common/server/ServerFacadeImpl_RemoteActionTest.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/common/src/test/java/org/apache/isis/runtimes/dflt/remoting/common/server/ServerFacadeImpl_RemoteActionTest.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/common/src/test/java/org/apache/isis/runtimes/dflt/remoting/common/server/ServerFacadeImpl_RemoteActionTest.java Tue May 3 06:33:43 2011
@@ -17,14 +17,18 @@
* under the License.
*/
+package org.apache.isis.runtimes.dflt.remoting.common.server;
-package org.apache.isis.runtimes.dflt.remoting.common.server;
-
-
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertEquals;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.spec.ActionType;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.testspec.TestProxySpecification;
+import org.apache.isis.core.runtime.authentication.AuthenticationManager;
import org.apache.isis.runtimes.dflt.remoting.common.data.DummyIdentityData;
import org.apache.isis.runtimes.dflt.remoting.common.data.DummyObjectData;
import org.apache.isis.runtimes.dflt.remoting.common.data.DummyReferenceData;
@@ -34,12 +38,6 @@ import org.apache.isis.runtimes.dflt.rem
import org.apache.isis.runtimes.dflt.remoting.common.exchange.ExecuteServerActionResponse;
import org.apache.isis.runtimes.dflt.remoting.common.facade.impl.ServerFacadeImpl;
import org.apache.isis.runtimes.dflt.remoting.common.protocol.ObjectEncoderDecoder;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.testspec.TestProxySpecification;
-import org.apache.isis.core.runtime.authentication.AuthenticationManager;
import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyAdapter;
import org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxySession;
@@ -56,218 +54,185 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-
-
-
-@RunWith(JMock.class)
-public class ServerFacadeImpl_RemoteActionTest {
-
- private Mockery mockery = new JUnit4Mockery();
-
- private AuthenticationManager mockAuthenticationManager;
- private ObjectEncoderDecoder mockEncoder;
-
- private ServerFacadeImpl server;
- private TestProxySystem system;
- private ObjectAdapter adapter;
- private Oid oid;
- private DummyIdentityData targetData;
- private ReferenceData[] parameterData;
- private ObjectAction mockAction;
-
- /*
- * Testing the Distribution implementation ServerDistribution. This uses the encoder to unmarshall objects
- * and then calls the persistor and reflector; all of which should be mocked.
- */
- @Before
- public void setUp() throws Exception {
- BasicConfigurator.configure();
- LogManager.getRootLogger().setLevel(Level.OFF);
-
- mockAuthenticationManager = mockery.mock(AuthenticationManager.class);
- mockEncoder = mockery.mock(ObjectEncoderDecoder.class);
-
- server = new ServerFacadeImpl(mockAuthenticationManager);
- server.setEncoder(mockEncoder);
-
- server.init();
-
-
- system = new TestProxySystem();
- system.init();
-
- adapter = system.createPersistentTestObject();
- oid = adapter.getOid();
-
- targetData = new DummyIdentityData(oid, TestProxyAdapter.class.getName(), new TestProxyVersion(1));
- parameterData = new ReferenceData[] {};
- final TestProxySpecification proxySpecification = (TestProxySpecification) adapter.getSpecification();
-
- mockAction = mockery.mock(ObjectAction.class);
- proxySpecification.setupAction(mockAction);
-
- mockery.checking(new Expectations() {
- {
- one(mockAction).getId();
- will(returnValue("action"));
-
- one(mockAction).execute(with(equalTo(adapter)), with(equalTo(new ObjectAdapter[0])));
- will(returnValue(adapter));
- }
- });
- }
-
- @After
- public void tearDown() throws Exception {
- system.shutdown();
- }
-
- @Test
- public void testExecuteOK() {
- final ExecuteServerActionResponse results = null;
- mockery.checking(new Expectations() {
- {
- one(mockEncoder).encodeServerActionResult(
- with(equalTo(adapter)),
- with(equalTo(new ObjectData[0])),
- with(equalTo(new ReferenceData[0])),
- with(nullValue(ObjectData.class)),
- with(equalTo(new ObjectData[0])),
- with(equalTo(new String[0])),
- with(equalTo(new String[0])));
- will(returnValue(results));
-
- }
- });
-
- IsisContext.getTransactionManager().startTransaction();
- ExecuteServerActionRequest request = new ExecuteServerActionRequest(new TestProxySession(),
- ActionType.USER,
- "action()",
- targetData,
- parameterData);
- final ExecuteServerActionResponse result =
- server.executeServerAction(
- request);
- IsisContext.getTransactionManager().endTransaction();
-
- assertEquals(results, result);
- }
-
- @Test
- public void testExecuteWhereObjectDeleted() {
- final ExecuteServerActionResponse results = null;
-
- mockery.checking(new Expectations() {
- {
- final ReferenceData deletedObjectIdentityData = new DummyReferenceData(adapter.getOid(), "", adapter.getVersion());
- one(mockEncoder).encodeIdentityData(adapter);
- will(returnValue(deletedObjectIdentityData));
-
- one(mockEncoder).encodeServerActionResult(
- with(equalTo(adapter)),
- with(equalTo(new ObjectData[0])),
- with(equalTo(new ReferenceData[] { deletedObjectIdentityData })),
- with(nullValue(ObjectData.class)),
- with(equalTo(new ObjectData[0])),
- with(equalTo(new String[0])),
- with(equalTo(new String[0])));
- will(returnValue(null));
- }
- });
-
- IsisContext.getTransactionManager().startTransaction();
-
- IsisContext.getUpdateNotifier().addDisposedObject(adapter);
- ExecuteServerActionRequest request = new ExecuteServerActionRequest(new TestProxySession(),
- ActionType.USER,
- "action()",
- targetData,
- parameterData);
- final ExecuteServerActionResponse result = server.executeServerAction(
- request );
-
- IsisContext.getTransactionManager().endTransaction();
-
- assertEquals(results, result);
- }
-
- @Test
- public void testExecuteWhereObjectChanged() {
-
- final ExecuteServerActionResponse results = null;
- mockery.checking(new Expectations() {
- {
- final ObjectData changedObjectData = new DummyObjectData();
- one(mockEncoder).encodeForUpdate(adapter);
- will(returnValue(changedObjectData));
-
- one(mockEncoder).encodeServerActionResult(
- with(equalTo(adapter)),
- with(equalTo(new ObjectData[] { changedObjectData })),
- with(equalTo(new ReferenceData[0] )),
- with(nullValue(ObjectData.class)),
- with(equalTo(new ObjectData[0])),
- with(equalTo(new String[0])),
- with(equalTo(new String[0])));
- will(returnValue(null));
- }
- });
-
- IsisContext.getTransactionManager().startTransaction();
-
- IsisContext.getUpdateNotifier().addChangedObject(adapter);
-
- ExecuteServerActionRequest request = new ExecuteServerActionRequest(new TestProxySession(),
- ActionType.USER,
- "action()",
- targetData,
- parameterData);
- final ExecuteServerActionResponse result = server.executeServerAction(
- request);
-
- IsisContext.getTransactionManager().endTransaction();
-
- assertEquals(results, result);
- }
-
- @Test
- public void testExecuteWhereMessagesAndWarningGenerated() {
- final ExecuteServerActionResponse results = null;
- mockery.checking(new Expectations() {
- {
- one(mockEncoder).encodeServerActionResult(
- with(equalTo(adapter)),
- with(equalTo(new ObjectData[0])),
- with(equalTo(new ReferenceData[0] )),
- with(nullValue(ObjectData.class)),
- with(equalTo(new ObjectData[0])),
- with(equalTo(new String[] { "message 1", "message 2" })),
- with(equalTo(new String[] { "warning 1", "warning 2" })));
- will(returnValue(null));
- }
- });
-
- IsisContext.getTransactionManager().startTransaction();
-
- IsisContext.getMessageBroker().addMessage("message 1");
- IsisContext.getMessageBroker().addMessage("message 2");
-
- IsisContext.getMessageBroker().addWarning("warning 1");
- IsisContext.getMessageBroker().addWarning("warning 2");
-
-
- ExecuteServerActionRequest request = new ExecuteServerActionRequest(new TestProxySession(),
- ActionType.USER,
- "action()",
- targetData,
- parameterData);
- final ExecuteServerActionResponse result = server.executeServerAction(
- request);
-
- IsisContext.getTransactionManager().endTransaction();
-
- assertEquals(results, result);
- }
-
-}
+
+@RunWith(JMock.class)
+public class ServerFacadeImpl_RemoteActionTest {
+
+ private final Mockery mockery = new JUnit4Mockery();
+
+ private AuthenticationManager mockAuthenticationManager;
+ private ObjectEncoderDecoder mockEncoder;
+
+ private ServerFacadeImpl server;
+ private TestProxySystem system;
+ private ObjectAdapter adapter;
+ private Oid oid;
+ private DummyIdentityData targetData;
+ private ReferenceData[] parameterData;
+ private ObjectAction mockAction;
+
+ /*
+ * Testing the Distribution implementation ServerDistribution. This uses the encoder to unmarshall objects and then
+ * calls the persistor and reflector; all of which should be mocked.
+ */
+ @Before
+ public void setUp() throws Exception {
+ BasicConfigurator.configure();
+ LogManager.getRootLogger().setLevel(Level.OFF);
+
+ mockAuthenticationManager = mockery.mock(AuthenticationManager.class);
+ mockEncoder = mockery.mock(ObjectEncoderDecoder.class);
+
+ server = new ServerFacadeImpl(mockAuthenticationManager);
+ server.setEncoder(mockEncoder);
+
+ server.init();
+
+ system = new TestProxySystem();
+ system.init();
+
+ adapter = system.createPersistentTestObject();
+ oid = adapter.getOid();
+
+ targetData = new DummyIdentityData(oid, TestProxyAdapter.class.getName(), new TestProxyVersion(1));
+ parameterData = new ReferenceData[] {};
+ final TestProxySpecification proxySpecification = (TestProxySpecification) adapter.getSpecification();
+
+ mockAction = mockery.mock(ObjectAction.class);
+ proxySpecification.setupAction(mockAction);
+
+ mockery.checking(new Expectations() {
+ {
+ one(mockAction).getId();
+ will(returnValue("action"));
+
+ one(mockAction).execute(with(equalTo(adapter)), with(equalTo(new ObjectAdapter[0])));
+ will(returnValue(adapter));
+ }
+ });
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ system.shutdown();
+ }
+
+ @Test
+ public void testExecuteOK() {
+ final ExecuteServerActionResponse results = null;
+ mockery.checking(new Expectations() {
+ {
+ one(mockEncoder).encodeServerActionResult(with(equalTo(adapter)), with(equalTo(new ObjectData[0])),
+ with(equalTo(new ReferenceData[0])), with(nullValue(ObjectData.class)),
+ with(equalTo(new ObjectData[0])), with(equalTo(new String[0])), with(equalTo(new String[0])));
+ will(returnValue(results));
+
+ }
+ });
+
+ IsisContext.getTransactionManager().startTransaction();
+ final ExecuteServerActionRequest request =
+ new ExecuteServerActionRequest(new TestProxySession(), ActionType.USER, "action()", targetData,
+ parameterData);
+ final ExecuteServerActionResponse result = server.executeServerAction(request);
+ IsisContext.getTransactionManager().endTransaction();
+
+ assertEquals(results, result);
+ }
+
+ @Test
+ public void testExecuteWhereObjectDeleted() {
+ final ExecuteServerActionResponse results = null;
+
+ mockery.checking(new Expectations() {
+ {
+ final ReferenceData deletedObjectIdentityData =
+ new DummyReferenceData(adapter.getOid(), "", adapter.getVersion());
+ one(mockEncoder).encodeIdentityData(adapter);
+ will(returnValue(deletedObjectIdentityData));
+
+ one(mockEncoder).encodeServerActionResult(with(equalTo(adapter)), with(equalTo(new ObjectData[0])),
+ with(equalTo(new ReferenceData[] { deletedObjectIdentityData })),
+ with(nullValue(ObjectData.class)), with(equalTo(new ObjectData[0])), with(equalTo(new String[0])),
+ with(equalTo(new String[0])));
+ will(returnValue(null));
+ }
+ });
+
+ IsisContext.getTransactionManager().startTransaction();
+
+ IsisContext.getUpdateNotifier().addDisposedObject(adapter);
+ final ExecuteServerActionRequest request =
+ new ExecuteServerActionRequest(new TestProxySession(), ActionType.USER, "action()", targetData,
+ parameterData);
+ final ExecuteServerActionResponse result = server.executeServerAction(request);
+
+ IsisContext.getTransactionManager().endTransaction();
+
+ assertEquals(results, result);
+ }
+
+ @Test
+ public void testExecuteWhereObjectChanged() {
+
+ final ExecuteServerActionResponse results = null;
+ mockery.checking(new Expectations() {
+ {
+ final ObjectData changedObjectData = new DummyObjectData();
+ one(mockEncoder).encodeForUpdate(adapter);
+ will(returnValue(changedObjectData));
+
+ one(mockEncoder).encodeServerActionResult(with(equalTo(adapter)),
+ with(equalTo(new ObjectData[] { changedObjectData })), with(equalTo(new ReferenceData[0])),
+ with(nullValue(ObjectData.class)), with(equalTo(new ObjectData[0])), with(equalTo(new String[0])),
+ with(equalTo(new String[0])));
+ will(returnValue(null));
+ }
+ });
+
+ IsisContext.getTransactionManager().startTransaction();
+
+ IsisContext.getUpdateNotifier().addChangedObject(adapter);
+
+ final ExecuteServerActionRequest request =
+ new ExecuteServerActionRequest(new TestProxySession(), ActionType.USER, "action()", targetData,
+ parameterData);
+ final ExecuteServerActionResponse result = server.executeServerAction(request);
+
+ IsisContext.getTransactionManager().endTransaction();
+
+ assertEquals(results, result);
+ }
+
+ @Test
+ public void testExecuteWhereMessagesAndWarningGenerated() {
+ final ExecuteServerActionResponse results = null;
+ mockery.checking(new Expectations() {
+ {
+ one(mockEncoder).encodeServerActionResult(with(equalTo(adapter)), with(equalTo(new ObjectData[0])),
+ with(equalTo(new ReferenceData[0])), with(nullValue(ObjectData.class)),
+ with(equalTo(new ObjectData[0])), with(equalTo(new String[] { "message 1", "message 2" })),
+ with(equalTo(new String[] { "warning 1", "warning 2" })));
+ will(returnValue(null));
+ }
+ });
+
+ IsisContext.getTransactionManager().startTransaction();
+
+ IsisContext.getMessageBroker().addMessage("message 1");
+ IsisContext.getMessageBroker().addMessage("message 2");
+
+ IsisContext.getMessageBroker().addWarning("warning 1");
+ IsisContext.getMessageBroker().addWarning("warning 2");
+
+ final ExecuteServerActionRequest request =
+ new ExecuteServerActionRequest(new TestProxySession(), ActionType.USER, "action()", targetData,
+ parameterData);
+ final ExecuteServerActionResponse result = server.executeServerAction(request);
+
+ IsisContext.getTransactionManager().endTransaction();
+
+ assertEquals(results, result);
+ }
+
+}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/marshalling-encode/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/encode/EncodingMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/marshalling-encode/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/encode/EncodingMarshaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/marshalling-encode/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/encode/EncodingMarshaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/marshalling-encode/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/encode/EncodingMarshaller.java Tue May 3 06:33:43 2011
@@ -24,10 +24,6 @@ import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;
-import org.apache.isis.runtimes.dflt.remoting.common.exchange.Request;
-import org.apache.isis.runtimes.dflt.remoting.common.marshalling.MarshallerAbstract;
-import org.apache.isis.runtimes.dflt.remoting.common.marshalling.MarshallingConstants;
-import org.apache.isis.runtimes.dflt.remoting.transport.Transport;
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.commons.encoding.DataInputExtended;
import org.apache.isis.core.commons.encoding.DataInputStreamExtended;
@@ -37,6 +33,10 @@ import org.apache.isis.core.commons.enco
import org.apache.isis.core.commons.encoding.DebugDataOutputExtended;
import org.apache.isis.core.commons.encoding.Encodable;
import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.runtimes.dflt.remoting.common.exchange.Request;
+import org.apache.isis.runtimes.dflt.remoting.common.marshalling.MarshallerAbstract;
+import org.apache.isis.runtimes.dflt.remoting.common.marshalling.MarshallingConstants;
+import org.apache.isis.runtimes.dflt.remoting.transport.Transport;
import org.apache.log4j.Logger;
public class EncodingMarshaller extends MarshallerAbstract {
@@ -50,13 +50,13 @@ public class EncodingMarshaller extends
private static enum As {
ENCODABLE(0) {
@Override
- public void writeObject(DataOutputExtended output, Object object) throws IOException {
+ public void writeObject(final DataOutputExtended output, final Object object) throws IOException {
writeTo(output);
output.writeEncodable(object);
}
@Override
- public <T> T readObject(DataInputExtended input, Class<T> cls) throws IOException {
+ public <T> T readObject(final DataInputExtended input, final Class<T> cls) throws IOException {
// not quite symmetrical with write; the byte has already been read from stream
// to determine which As instance to delegate to
return input.readEncodable(cls);
@@ -64,13 +64,13 @@ public class EncodingMarshaller extends
},
SERIALIZABLE(1) {
@Override
- public void writeObject(DataOutputExtended output, Object object) throws IOException {
+ public void writeObject(final DataOutputExtended output, final Object object) throws IOException {
writeTo(output);
output.writeSerializable(object);
}
@Override
- public <T> T readObject(DataInputExtended input, Class<T> cls) throws IOException {
+ public <T> T readObject(final DataInputExtended input, final Class<T> cls) throws IOException {
// not quite symmetrical with write; the byte has already been read from stream
// to determine which As instance to delegate to
return input.readSerializable(cls);
@@ -78,25 +78,25 @@ public class EncodingMarshaller extends
};
static Map<Integer, As> cache = new HashMap<Integer, As>();
static {
- for (As as : values()) {
+ for (final As as : values()) {
cache.put(as.idx, as);
}
}
private final int idx;
- private As(int idx) {
+ private As(final int idx) {
this.idx = idx;
}
- static As get(int idx) {
+ static As get(final int idx) {
return cache.get(idx);
}
- public static As readFrom(DataInputExtended input) throws IOException {
+ public static As readFrom(final DataInputExtended input) throws IOException {
return get(input.readByte());
}
- public void writeTo(DataOutputExtended output) throws IOException {
+ public void writeTo(final DataOutputExtended output) throws IOException {
output.writeByte(idx);
}
@@ -155,8 +155,8 @@ public class EncodingMarshaller extends
output.flush();
}
- private <T> T readFromInput(Class<T> cls) throws IOException {
- As as = As.readFrom(input);
+ private <T> T readFromInput(final Class<T> cls) throws IOException {
+ final As as = As.readFrom(input);
return as.readObject(input, cls);
}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/marshalling-serialize/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/serialize/SerializingMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/marshalling-serialize/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/serialize/SerializingMarshaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/marshalling-serialize/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/serialize/SerializingMarshaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/marshalling-serialize/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/serialize/SerializingMarshaller.java Tue May 3 06:33:43 2011
@@ -25,13 +25,13 @@ import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.SocketException;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.exceptions.IsisException;
import org.apache.isis.runtimes.dflt.remoting.common.exchange.Request;
import org.apache.isis.runtimes.dflt.remoting.common.marshalling.MarshallerAbstract;
import org.apache.isis.runtimes.dflt.remoting.common.protocol.IllegalRequestException;
import org.apache.isis.runtimes.dflt.remoting.transport.ConnectionException;
import org.apache.isis.runtimes.dflt.remoting.transport.Transport;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.exceptions.IsisException;
import org.apache.log4j.Logger;
import edu.umd.cs.findbugs.annotations.SuppressWarnings;
@@ -69,7 +69,7 @@ public class SerializingMarshaller exten
if (LOG.isDebugEnabled()) {
LOG.debug("sending request" + request);
}
- Serializable serializableRequest = asSerializable(request);
+ final Serializable serializableRequest = asSerializable(request);
try {
output.writeObject(serializableRequest);
} catch (final SocketException e) {
Modified: incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/client/XStreamOverSocketsProxyDecoratorInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/client/XStreamOverSocketsProxyDecoratorInstaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/client/XStreamOverSocketsProxyDecoratorInstaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/client/XStreamOverSocketsProxyDecoratorInstaller.java Tue May 3 06:33:43 2011
@@ -34,7 +34,7 @@ public class XStreamOverSocketsProxyDeco
}
@Override
- protected void addConfigurationResources(List<String> configurationResources) {
+ protected void addConfigurationResources(final List<String> configurationResources) {
super.addConfigurationResources(configurationResources);
// TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
// and Transport using the installers.
@@ -50,7 +50,7 @@ public class XStreamOverSocketsProxyDeco
}
@Override
- protected ClientMarshaller createMarshaller(Transport transport) {
+ protected ClientMarshaller createMarshaller(final Transport transport) {
return new XStreamMarshaller(getConfiguration(), transport);
}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/server/XStreamOverSocketsViewer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/server/XStreamOverSocketsViewer.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/server/XStreamOverSocketsViewer.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/server/XStreamOverSocketsViewer.java Tue May 3 06:33:43 2011
@@ -34,18 +34,18 @@ import org.apache.isis.runtimes.dflt.rem
public class XStreamOverSocketsViewer extends SocketsViewerAbstract {
- public XStreamOverSocketsViewer(ObjectEncoderDecoder objectEncoderDecoder) {
+ public XStreamOverSocketsViewer(final ObjectEncoderDecoder objectEncoderDecoder) {
super(objectEncoderDecoder);
}
@Override
protected ServerConnection createServerConnection(final InputStream input, final OutputStream output,
final ServerFacade distribution) {
- SimpleTransport transport = new SimpleTransport(getConfiguration(), input, output);
- XStreamMarshaller serverMarshaller = new XStreamMarshaller(getConfiguration(), transport);
+ final SimpleTransport transport = new SimpleTransport(getConfiguration(), input, output);
+ final XStreamMarshaller serverMarshaller = new XStreamMarshaller(getConfiguration(), transport);
try {
serverMarshaller.connect();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new ConnectionException(e);
}
return new ServerConnectionDefault(distribution, serverMarshaller);
Modified: incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/server/XStreamOverSocketsViewerInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/server/XStreamOverSocketsViewerInstaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/server/XStreamOverSocketsViewerInstaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/server/XStreamOverSocketsViewerInstaller.java Tue May 3 06:33:43 2011
@@ -42,7 +42,7 @@ public class XStreamOverSocketsViewerIns
}
@Override
- protected void addConfigurationResources(List<String> configurationResources) {
+ protected void addConfigurationResources(final List<String> configurationResources) {
super.addConfigurationResources(configurationResources);
// TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
// and Transport using the installers.
@@ -53,7 +53,7 @@ public class XStreamOverSocketsViewerIns
}
@Override
- protected SocketsViewerAbstract createSocketsViewer(ObjectEncoderDecoder objectEncoderDecoder) {
+ protected SocketsViewerAbstract createSocketsViewer(final ObjectEncoderDecoder objectEncoderDecoder) {
return new XStreamOverSocketsViewer(objectEncoderDecoder);
}
}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/shared/XStreamMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/shared/XStreamMarshaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/shared/XStreamMarshaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/marshalling-xstream/src/main/java/org/apache/isis/runtimes/dflt/remoting/marshalling/xstream/shared/XStreamMarshaller.java Tue May 3 06:33:43 2011
@@ -25,13 +25,13 @@ import java.io.ObjectOutputStream;
import java.io.StreamCorruptedException;
import java.net.SocketException;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.exceptions.IsisException;
import org.apache.isis.runtimes.dflt.remoting.common.exchange.Request;
import org.apache.isis.runtimes.dflt.remoting.common.marshalling.MarshallerAbstract;
import org.apache.isis.runtimes.dflt.remoting.common.protocol.IllegalRequestException;
import org.apache.isis.runtimes.dflt.remoting.transport.ConnectionException;
import org.apache.isis.runtimes.dflt.remoting.transport.Transport;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.exceptions.IsisException;
import org.apache.log4j.Logger;
import com.thoughtworks.xstream.XStream;
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/EncodingOverHttpProxyInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/EncodingOverHttpProxyInstaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/EncodingOverHttpProxyInstaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/EncodingOverHttpProxyInstaller.java Tue May 3 06:33:43 2011
@@ -32,7 +32,7 @@ public class EncodingOverHttpProxyInstal
}
@Override
- protected void addConfigurationResources(List<String> configurationResources) {
+ protected void addConfigurationResources(final List<String> configurationResources) {
super.addConfigurationResources(configurationResources);
// TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
// and Transport using the installers.
@@ -43,7 +43,7 @@ public class EncodingOverHttpProxyInstal
}
@Override
- protected EncodingMarshaller createMarshaller(Transport transport) {
+ protected EncodingMarshaller createMarshaller(final Transport transport) {
return new EncodingMarshaller(getConfiguration(), transport);
}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/HttpClientTransport.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/HttpClientTransport.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/HttpClientTransport.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/HttpClientTransport.java Tue May 3 06:33:43 2011
@@ -28,9 +28,9 @@ import java.io.OutputStream;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.isis.runtimes.dflt.remoting.transport.TransportAbstract;
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.commons.io.LazyInputStream;
+import org.apache.isis.runtimes.dflt.remoting.transport.TransportAbstract;
public class HttpClientTransport extends TransportAbstract {
@@ -40,7 +40,7 @@ public class HttpClientTransport extends
private ByteArrayOutputStream outputStream;
private InputStream inputStream;
- public HttpClientTransport(IsisConfiguration configuration) {
+ public HttpClientTransport(final IsisConfiguration configuration) {
super(configuration);
}
@@ -48,11 +48,13 @@ public class HttpClientTransport extends
// init, shutdown
// ///////////////////////////////////////////////////////////
+ @Override
public void init() {
httpClient = new HttpClient();
url = getConfiguration().getString(HttpRemotingConstants.URL_KEY, HttpRemotingConstants.URL_DEFAULT);
}
+ @Override
public void shutdown() {
httpClient = null;
}
@@ -61,10 +63,12 @@ public class HttpClientTransport extends
// connect, disconnect
// ///////////////////////////////////////////////////////////
+ @Override
public void connect() throws IOException {
outputStream = new ByteArrayOutputStream();
}
+ @Override
public void disconnect() {
inputStream = null;
outputStream = null;
@@ -78,6 +82,7 @@ public class HttpClientTransport extends
* Returns an {@link OutputStream} that writes into the request body of an HTTP POST, and will send on
* {@link OutputStream#flush() flush}.
*/
+ @Override
public OutputStream getOutputStream() {
return outputStream;
}
@@ -88,15 +93,16 @@ public class HttpClientTransport extends
* <p>
* Subsequent calls return the same input stream, at whatever position they have been processed.
*/
+ @Override
public InputStream getInputStream() throws IOException {
if (inputStream == null) {
inputStream = new LazyInputStream(new LazyInputStream.InputStreamProvider() {
@Override
public InputStream getInputStream() throws IOException {
- PostMethod postMethod = new PostMethod(url);
+ final PostMethod postMethod = new PostMethod(url);
// copy over
- InputStreamRequestEntity requestEntity =
+ final InputStreamRequestEntity requestEntity =
new InputStreamRequestEntity(new ByteArrayInputStream(outputStream.toByteArray()));
postMethod.setRequestEntity(requestEntity);
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/HttpRemotingConstants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/HttpRemotingConstants.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/HttpRemotingConstants.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-http/client/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/client/HttpRemotingConstants.java Tue May 3 06:33:43 2011
@@ -17,24 +17,24 @@
* under the License.
*/
+package org.apache.isis.runtimes.dflt.remoting.transport.http.client;
-package org.apache.isis.runtimes.dflt.remoting.transport.http.client;
-
import org.apache.isis.core.commons.config.ConfigurationConstants;
-
-public class HttpRemotingConstants {
-
- private static final String ROOT = ConfigurationConstants.ROOT + "transport.http.";
-
- /**
- * Key used to lookup URL to which the <tt>EncodingOverHttpRemotingServlet</tt> is mapped.
- */
- public static final String URL_KEY = ROOT + "url";
- /**
- * Default value for {@link #URL_KEY}.
- */
- public static final String URL_DEFAULT = "http://localhost:8080/remoting.svc";
-
- private HttpRemotingConstants(){}
-
-}
+
+public class HttpRemotingConstants {
+
+ private static final String ROOT = ConfigurationConstants.ROOT + "transport.http.";
+
+ /**
+ * Key used to lookup URL to which the <tt>EncodingOverHttpRemotingServlet</tt> is mapped.
+ */
+ public static final String URL_KEY = ROOT + "url";
+ /**
+ * Default value for {@link #URL_KEY}.
+ */
+ public static final String URL_DEFAULT = "http://localhost:8080/remoting.svc";
+
+ private HttpRemotingConstants() {
+ }
+
+}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-http/server/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/server/EncodingOverHttpRemotingServlet.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-http/server/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/server/EncodingOverHttpRemotingServlet.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-http/server/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/server/EncodingOverHttpRemotingServlet.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-http/server/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/server/EncodingOverHttpRemotingServlet.java Tue May 3 06:33:43 2011
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.runtimes.dflt.remoting.common.facade.impl.ServerFacadeImpl;
import org.apache.isis.runtimes.dflt.remoting.marshalling.encode.EncodingMarshaller;
import org.apache.isis.runtimes.dflt.remoting.protocol.internal.ObjectEncoderDecoderDefault;
@@ -35,7 +36,6 @@ import org.apache.isis.runtimes.dflt.rem
import org.apache.isis.runtimes.dflt.remoting.server.ServerConnectionDefault;
import org.apache.isis.runtimes.dflt.remoting.transport.ServerConnectionHandler;
import org.apache.isis.runtimes.dflt.remoting.transport.simple.SimpleTransport;
-import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.runtimes.dflt.runtime.system.IsisSystem;
import org.apache.isis.runtimes.dflt.webapp.IsisWebAppBootstrapper;
@@ -62,16 +62,16 @@ public class EncodingOverHttpRemotingSer
}
@Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
- IOException {
- ServletInputStream inputStream = request.getInputStream();
- ServletOutputStream outputStream = response.getOutputStream();
+ protected void doPost(final HttpServletRequest request, final HttpServletResponse response)
+ throws ServletException, IOException {
+ final ServletInputStream inputStream = request.getInputStream();
+ final ServletOutputStream outputStream = response.getOutputStream();
- ServerConnection serverConnection = createConnection(inputStream, outputStream);
+ final ServerConnection serverConnection = createConnection(inputStream, outputStream);
try {
new ServerConnectionHandler(serverConnection).handleRequest();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
// REVIEW: is this enough, or should we try to return a more
// user-friendly exception or status?
throw ex;
@@ -80,13 +80,13 @@ public class EncodingOverHttpRemotingSer
}
}
- private ServerConnection createConnection(ServletInputStream inputStream, ServletOutputStream outputStream)
- throws IOException {
+ private ServerConnection createConnection(final ServletInputStream inputStream,
+ final ServletOutputStream outputStream) throws IOException {
// TODO: should use installers to create these,
// provides the opportunity to read in installer-specific config files.
- SimpleTransport transport = new SimpleTransport(configuration, inputStream, outputStream);
- EncodingMarshaller marshaller = new EncodingMarshaller(configuration, transport);
+ final SimpleTransport transport = new SimpleTransport(configuration, inputStream, outputStream);
+ final EncodingMarshaller marshaller = new EncodingMarshaller(configuration, transport);
// this is a no-op with the SimpleTransport, but include for consistency
marshaller.connect();
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-http/server/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/server/EncodingOverHttpRemotingViewerInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-http/server/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/server/EncodingOverHttpRemotingViewerInstaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-http/server/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/server/EncodingOverHttpRemotingViewerInstaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-http/server/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/http/server/EncodingOverHttpRemotingViewerInstaller.java Tue May 3 06:33:43 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.remoting.transport.http.server;
import java.util.List;
@@ -29,54 +28,48 @@ import org.apache.isis.runtimes.dflt.run
import org.apache.isis.runtimes.dflt.runtime.web.EmbeddedWebViewer;
/**
- * Convenience implementation of a {@link IsisViewer} providing the
- * ability to run a Jetty web server configured for http remoting from the
- * {@link Isis command line}.
+ * Convenience implementation of a {@link IsisViewer} providing the ability to run a Jetty web server configured for
+ * http remoting from the {@link Isis command line}.
*
* <p>
- * To run, use the <tt>--viewer encoding-http</tt> flag. The client-side should
- * run using <tt>--connector encoding-http</tt> flag.
+ * To run, use the <tt>--viewer encoding-http</tt> flag. The client-side should run using
+ * <tt>--connector encoding-http</tt> flag.
*
* <p>
- * In a production deployment the configuration represented by the
- * {@link WebAppSpecification} would be specified in the <tt>web.xml<tt> file.
+ * In a production deployment the configuration represented by the {@link WebAppSpecification} would be specified in the
+ * <tt>web.xml<tt> file.
*/
-public class EncodingOverHttpRemotingViewerInstaller extends
- IsisViewerInstallerAbstract {
-
- private static final String REMOTING_SERVLET_MAPPED = "/remoting.svc";
-
- public EncodingOverHttpRemotingViewerInstaller() {
- super("encoding-http");
- }
-
- @Override
- protected void addConfigurationResources(List<String> configurationResources) {
- super.addConfigurationResources(configurationResources);
- // TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
- // and Transport using the installers.
- configurationResources.add("protocol.properties");
- configurationResources.add("protocol_encoding.properties");
- configurationResources.add("transport.properties");
- configurationResources.add("transport_http.properties");
- }
-
-
- @Override
- public IsisViewer doCreateViewer() {
- return new EmbeddedWebViewer() {
- public WebAppSpecification getWebAppSpecification() {
-
- WebAppSpecification webAppSpec = new WebAppSpecification();
- webAppSpec.addServletSpecification(
- EncodingOverHttpRemotingServlet.class,
- REMOTING_SERVLET_MAPPED);
-
- return webAppSpec;
- }
- };
- }
+public class EncodingOverHttpRemotingViewerInstaller extends IsisViewerInstallerAbstract {
-}
+ private static final String REMOTING_SERVLET_MAPPED = "/remoting.svc";
+ public EncodingOverHttpRemotingViewerInstaller() {
+ super("encoding-http");
+ }
+
+ @Override
+ protected void addConfigurationResources(final List<String> configurationResources) {
+ super.addConfigurationResources(configurationResources);
+ // TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
+ // and Transport using the installers.
+ configurationResources.add("protocol.properties");
+ configurationResources.add("protocol_encoding.properties");
+ configurationResources.add("transport.properties");
+ configurationResources.add("transport_http.properties");
+ }
+
+ @Override
+ public IsisViewer doCreateViewer() {
+ return new EmbeddedWebViewer() {
+ @Override
+ public WebAppSpecification getWebAppSpecification() {
+
+ final WebAppSpecification webAppSpec = new WebAppSpecification();
+ webAppSpec.addServletSpecification(EncodingOverHttpRemotingServlet.class, REMOTING_SERVLET_MAPPED);
+
+ return webAppSpec;
+ }
+ };
+ }
+}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/client/EncodingOverSocketsProxyInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/client/EncodingOverSocketsProxyInstaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/client/EncodingOverSocketsProxyInstaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/client/EncodingOverSocketsProxyInstaller.java Tue May 3 06:33:43 2011
@@ -34,7 +34,7 @@ public class EncodingOverSocketsProxyIns
}
@Override
- protected void addConfigurationResources(List<String> configurationResources) {
+ protected void addConfigurationResources(final List<String> configurationResources) {
super.addConfigurationResources(configurationResources);
// TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
// and Transport using the installers.
@@ -50,7 +50,7 @@ public class EncodingOverSocketsProxyIns
}
@Override
- protected ClientMarshaller createMarshaller(Transport transport) {
+ protected ClientMarshaller createMarshaller(final Transport transport) {
return new EncodingMarshaller(getConfiguration(), transport);
}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/client/SerializingOverSocketsProxyInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/client/SerializingOverSocketsProxyInstaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/client/SerializingOverSocketsProxyInstaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/client/SerializingOverSocketsProxyInstaller.java Tue May 3 06:33:43 2011
@@ -34,7 +34,7 @@ public class SerializingOverSocketsProxy
}
@Override
- protected void addConfigurationResources(List<String> configurationResources) {
+ protected void addConfigurationResources(final List<String> configurationResources) {
super.addConfigurationResources(configurationResources);
// TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
// and Transport using the installers.
@@ -50,7 +50,7 @@ public class SerializingOverSocketsProxy
}
@Override
- protected ClientMarshaller createMarshaller(Transport transport) {
+ protected ClientMarshaller createMarshaller(final Transport transport) {
return new SerializingMarshaller(getConfiguration(), transport);
}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/EncodingOverSocketsViewer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/EncodingOverSocketsViewer.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/EncodingOverSocketsViewer.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/EncodingOverSocketsViewer.java Tue May 3 06:33:43 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.remoting.transport.sockets.server;
import java.io.IOException;
@@ -31,26 +30,22 @@ import org.apache.isis.runtimes.dflt.rem
import org.apache.isis.runtimes.dflt.remoting.transport.ConnectionException;
import org.apache.isis.runtimes.dflt.remoting.transport.simple.SimpleTransport;
-
public class EncodingOverSocketsViewer extends SocketsViewerAbstract {
-
- public EncodingOverSocketsViewer(ObjectEncoderDecoder objectEncoderDecoder) {
- super(objectEncoderDecoder);
- }
-
+
+ public EncodingOverSocketsViewer(final ObjectEncoderDecoder objectEncoderDecoder) {
+ super(objectEncoderDecoder);
+ }
+
@Override
- protected ServerConnectionDefault createServerConnection(
- final InputStream input,
- final OutputStream output,
- final ServerFacade serverFacade) {
- SimpleTransport transport = new SimpleTransport(getConfiguration(), input, output);
- EncodingMarshaller marshaller = new EncodingMarshaller(getConfiguration(), transport);
+ protected ServerConnectionDefault createServerConnection(final InputStream input, final OutputStream output,
+ final ServerFacade serverFacade) {
+ final SimpleTransport transport = new SimpleTransport(getConfiguration(), input, output);
+ final EncodingMarshaller marshaller = new EncodingMarshaller(getConfiguration(), transport);
try {
marshaller.connect();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new ConnectionException(e);
}
return new ServerConnectionDefault(serverFacade, marshaller);
}
}
-
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/EncodingOverSocketsViewerInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/EncodingOverSocketsViewerInstaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/EncodingOverSocketsViewerInstaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/EncodingOverSocketsViewerInstaller.java Tue May 3 06:33:43 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.remoting.transport.sockets.server;
import java.util.List;
@@ -27,36 +26,33 @@ import org.apache.isis.runtimes.dflt.run
import org.apache.isis.runtimes.dflt.runtime.viewer.IsisViewer;
/**
- * Implementation of a {@link IsisViewer} providing the ability to run
- * from server as a {@link Isis command line} application.
+ * Implementation of a {@link IsisViewer} providing the ability to run from server as a {@link Isis command line}
+ * application.
*
* <p>
- * To run, use the <tt>--viewer encoding-sockets</tt> flag. The client-side
- * should run using <tt>--connector encoding-sockets</tt> flag.
+ * To run, use the <tt>--viewer encoding-sockets</tt> flag. The client-side should run using
+ * <tt>--connector encoding-sockets</tt> flag.
*/
-public class EncodingOverSocketsViewerInstaller extends
- SocketsViewerInstallerAbstract {
+public class EncodingOverSocketsViewerInstaller extends SocketsViewerInstallerAbstract {
- public EncodingOverSocketsViewerInstaller() {
- super("encoding-sockets");
- }
-
- @Override
- protected void addConfigurationResources(List<String> configurationResources) {
- super.addConfigurationResources(configurationResources);
- // TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
- // and Transport using the installers.
- configurationResources.add("protocol.properties");
- configurationResources.add("protocol_encoding.properties");
- configurationResources.add("transport.properties");
- configurationResources.add("transport_sockets.properties");
- }
-
- @Override
- protected SocketsViewerAbstract createSocketsViewer(
- final ObjectEncoderDecoder objectEncoderDecoder) {
- return new EncodingOverSocketsViewer(objectEncoderDecoder);
- }
+ public EncodingOverSocketsViewerInstaller() {
+ super("encoding-sockets");
+ }
+
+ @Override
+ protected void addConfigurationResources(final List<String> configurationResources) {
+ super.addConfigurationResources(configurationResources);
+ // TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
+ // and Transport using the installers.
+ configurationResources.add("protocol.properties");
+ configurationResources.add("protocol_encoding.properties");
+ configurationResources.add("transport.properties");
+ configurationResources.add("transport_sockets.properties");
+ }
+
+ @Override
+ protected SocketsViewerAbstract createSocketsViewer(final ObjectEncoderDecoder objectEncoderDecoder) {
+ return new EncodingOverSocketsViewer(objectEncoderDecoder);
+ }
}
-
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SerializingOverSocketsViewer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SerializingOverSocketsViewer.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SerializingOverSocketsViewer.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SerializingOverSocketsViewer.java Tue May 3 06:33:43 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.remoting.transport.sockets.server;
import java.io.IOException;
@@ -32,28 +31,22 @@ import org.apache.isis.runtimes.dflt.rem
import org.apache.isis.runtimes.dflt.remoting.transport.ConnectionException;
import org.apache.isis.runtimes.dflt.remoting.transport.simple.SimpleTransport;
-
public class SerializingOverSocketsViewer extends SocketsViewerAbstract {
-
-
- public SerializingOverSocketsViewer(
- ObjectEncoderDecoder objectEncoderDecoder) {
- super(objectEncoderDecoder);
- }
-
- @Override
- protected ServerConnection createServerConnection(
- final InputStream input,
- final OutputStream output,
- final ServerFacade serverFacade) {
- SimpleTransport transport = new SimpleTransport(getConfiguration(), input, output);
- SerializingMarshaller serverMarshaller = new SerializingMarshaller(getConfiguration(), transport);
+
+ public SerializingOverSocketsViewer(final ObjectEncoderDecoder objectEncoderDecoder) {
+ super(objectEncoderDecoder);
+ }
+
+ @Override
+ protected ServerConnection createServerConnection(final InputStream input, final OutputStream output,
+ final ServerFacade serverFacade) {
+ final SimpleTransport transport = new SimpleTransport(getConfiguration(), input, output);
+ final SerializingMarshaller serverMarshaller = new SerializingMarshaller(getConfiguration(), transport);
try {
- serverMarshaller.connect();
- } catch (IOException e) {
+ serverMarshaller.connect();
+ } catch (final IOException e) {
throw new ConnectionException(e);
}
return new ServerConnectionDefault(serverFacade, serverMarshaller);
}
}
-
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SerializingOverSocketsViewerInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SerializingOverSocketsViewerInstaller.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SerializingOverSocketsViewerInstaller.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SerializingOverSocketsViewerInstaller.java Tue May 3 06:33:43 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.remoting.transport.sockets.server;
import java.util.List;
@@ -26,37 +25,34 @@ import org.apache.isis.runtimes.dflt.rem
import org.apache.isis.runtimes.dflt.runtime.Isis;
import org.apache.isis.runtimes.dflt.runtime.viewer.IsisViewer;
-
/**
- * Implementation of a {@link IsisViewer} providing the ability to run
- * from server as a {@link Isis command line} application.
+ * Implementation of a {@link IsisViewer} providing the ability to run from server as a {@link Isis command line}
+ * application.
*
* <p>
- * To run, use the <tt>--viewer serializing-sockets</tt> flag. The client-side
- * should run using <tt>--connector serializing-sockets</tt> flag.
+ * To run, use the <tt>--viewer serializing-sockets</tt> flag. The client-side should run using
+ * <tt>--connector serializing-sockets</tt> flag.
*/
public class SerializingOverSocketsViewerInstaller extends SocketsViewerInstallerAbstract {
public SerializingOverSocketsViewerInstaller() {
- super("serializing-sockets");
- }
-
- @Override
- protected void addConfigurationResources(List<String> configurationResources) {
- super.addConfigurationResources(configurationResources);
- // TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
- // and Transport using the installers.
- configurationResources.add("protocol.properties");
- configurationResources.add("protocol_serializing.properties");
- configurationResources.add("transport.properties");
- configurationResources.add("transport_sockets.properties");
- }
+ super("serializing-sockets");
+ }
+ @Override
+ protected void addConfigurationResources(final List<String> configurationResources) {
+ super.addConfigurationResources(configurationResources);
+ // TODO: this (small) hack is because we don't load up the Protocol (Marshaller)
+ // and Transport using the installers.
+ configurationResources.add("protocol.properties");
+ configurationResources.add("protocol_serializing.properties");
+ configurationResources.add("transport.properties");
+ configurationResources.add("transport_sockets.properties");
+ }
- @Override
- protected SocketsViewerAbstract createSocketsViewer(ObjectEncoderDecoder objectEncoderDecoder) {
+ @Override
+ protected SocketsViewerAbstract createSocketsViewer(final ObjectEncoderDecoder objectEncoderDecoder) {
return new SerializingOverSocketsViewer(objectEncoderDecoder);
}
}
-
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerAbstract.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerAbstract.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerAbstract.java Tue May 3 06:33:43 2011
@@ -17,7 +17,6 @@
* under the License.
*/
-
package org.apache.isis.runtimes.dflt.remoting.transport.sockets.server;
import java.io.IOException;
@@ -48,7 +47,6 @@ import org.apache.isis.runtimes.dflt.run
import org.apache.isis.runtimes.dflt.runtime.viewer.IsisViewerAbstract;
import org.apache.log4j.Logger;
-
public abstract class SocketsViewerAbstract extends IsisViewerAbstract implements DebuggableWithTitle {
private static final Logger LOG = Logger.getLogger(SocketsViewerAbstract.class);
@@ -59,7 +57,7 @@ public abstract class SocketsViewerAbstr
private WorkerPool workerPool;
private Boolean shutdown = Boolean.FALSE;
- private Object shutdownGuard = new Object();
+ private final Object shutdownGuard = new Object();
public SocketsViewerAbstract(final ObjectEncoderDecoder encoderDecoder) {
this.encoderDecoder = encoderDecoder;
@@ -72,10 +70,12 @@ public abstract class SocketsViewerAbstr
/**
* TODO: generalize so can listen on multi-homed hosts using new Socket(port, 2, address);
*/
+ @Override
public void init() {
super.init();
- final int port = getConfiguration().getInteger(SocketsViewerConstants.SERVER_PORT, SocketTransportConstants.PORT_DEFAULT);
+ final int port =
+ getConfiguration().getInteger(SocketsViewerConstants.SERVER_PORT, SocketTransportConstants.PORT_DEFAULT);
workerPool = new WorkerPool(5);
@@ -95,7 +95,7 @@ public abstract class SocketsViewerAbstr
private ServerSocket newServerSocket(final int port) {
try {
- ServerSocket socket = new ServerSocket(port);
+ final ServerSocket socket = new ServerSocket(port);
LOG.info("nof listener started on " + socket);
socket.setSoTimeout(1000);
return socket;
@@ -160,6 +160,7 @@ public abstract class SocketsViewerAbstr
// shutdown
// ////////////////////////////////////////////////////////////////
+ @Override
public void shutdown() {
LOG.info("stopping listener");
synchronized (shutdownGuard) {
@@ -167,7 +168,6 @@ public abstract class SocketsViewerAbstr
}
}
-
private void shutdownListener() {
shutdown(socket);
socket = null;
@@ -209,21 +209,21 @@ public abstract class SocketsViewerAbstr
/**
* Hook method.
*/
- protected abstract ServerConnection createServerConnection(
- final InputStream input,
- final OutputStream output,
- final ServerFacade serverFacade);
+ protected abstract ServerConnection createServerConnection(final InputStream input, final OutputStream output,
+ final ServerFacade serverFacade);
// ////////////////////////////////////////////////////////////////
// debugging
// ////////////////////////////////////////////////////////////////
+ @Override
public void debugData(final DebugBuilder debug) {
debug.appendln("Listener on", socket.toString());
debug.appendln("Workers", workerPool);
workerPool.debug(debug);
}
+ @Override
public String debugTitle() {
return "Server Listener";
}
@@ -239,7 +239,8 @@ public abstract class SocketsViewerAbstr
@SuppressWarnings("unused")
private void startMonitors(final IsisSystem system) {
if (system.getDeploymentType().shouldMonitor()) {
- Runnable serverMonitorRunnable = new Runnable() {
+ final Runnable serverMonitorRunnable = new Runnable() {
+ @Override
public void run() {
final SocketServerMonitor serverMonitor = new SocketServerMonitor();
serverMonitor.setTarget(system);
@@ -249,7 +250,8 @@ public abstract class SocketsViewerAbstr
Threads.startThread(serverMonitorRunnable, "Monitor-1");
- Runnable httpServerMonitorRunnable = new Runnable() {
+ final Runnable httpServerMonitorRunnable = new Runnable() {
+ @Override
public void run() {
final HttpServerMonitor httpServerMonitor = new HttpServerMonitor();
httpServerMonitor.setTarget(system);
@@ -261,4 +263,3 @@ public abstract class SocketsViewerAbstr
}
}
-
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerConstants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerConstants.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerConstants.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerConstants.java Tue May 3 06:33:43 2011
@@ -17,27 +17,25 @@
* under the License.
*/
+package org.apache.isis.runtimes.dflt.remoting.transport.sockets.server;
-package org.apache.isis.runtimes.dflt.remoting.transport.sockets.server;
-
-import org.apache.isis.runtimes.dflt.remoting.transport.sockets.shared.SocketTransportConstants;
import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.runtimes.dflt.remoting.transport.sockets.shared.SocketTransportConstants;
import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.IsisViewerInstaller;
-
-
-public final class SocketsViewerConstants {
-
- private static final String ROOT =
- ConfigurationConstants.ROOT + IsisViewerInstaller.TYPE + ".";
-
- /**
- * Used by all the XxxOverSockets viewers.
- *
- * <p>
- * Equivalent to {@link SocketTransportConstants#PORT_KEY}.
- */
- public static final String SERVER_PORT = ROOT + "sockets.port";
-
- private SocketsViewerConstants() {}
-
-}
+
+public final class SocketsViewerConstants {
+
+ private static final String ROOT = ConfigurationConstants.ROOT + IsisViewerInstaller.TYPE + ".";
+
+ /**
+ * Used by all the XxxOverSockets viewers.
+ *
+ * <p>
+ * Equivalent to {@link SocketTransportConstants#PORT_KEY}.
+ */
+ public static final String SERVER_PORT = ROOT + "sockets.port";
+
+ private SocketsViewerConstants() {
+ }
+
+}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerInstallerAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerInstallerAbstract.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerInstallerAbstract.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/server/SocketsViewerInstallerAbstract.java Tue May 3 06:33:43 2011
@@ -26,13 +26,13 @@ import org.apache.isis.runtimes.dflt.run
public abstract class SocketsViewerInstallerAbstract extends IsisViewerInstallerAbstract {
- public SocketsViewerInstallerAbstract(String name) {
+ public SocketsViewerInstallerAbstract(final String name) {
super(name);
}
@Override
public IsisViewer doCreateViewer() {
- ObjectEncoderDecoderDefault encoder = ObjectEncoderDecoderDefault.create(getConfiguration());
+ final ObjectEncoderDecoderDefault encoder = ObjectEncoderDecoderDefault.create(getConfiguration());
return createSocketsViewer(encoder);
}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/shared/SocketTransport.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/shared/SocketTransport.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/shared/SocketTransport.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/shared/SocketTransport.java Tue May 3 06:33:43 2011
@@ -17,9 +17,8 @@
* under the License.
*/
+package org.apache.isis.runtimes.dflt.remoting.transport.sockets.shared;
-package org.apache.isis.runtimes.dflt.remoting.transport.sockets.shared;
-
import static org.apache.isis.runtimes.dflt.remoting.transport.sockets.shared.SocketTransportConstants.PORT_DEFAULT;
import java.io.IOException;
@@ -30,103 +29,108 @@ import java.net.MalformedURLException;
import java.net.Socket;
import java.net.UnknownHostException;
+import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.runtimes.dflt.remoting.transport.ConnectionException;
import org.apache.isis.runtimes.dflt.remoting.transport.ProfilingInputStream;
import org.apache.isis.runtimes.dflt.remoting.transport.ProfilingOutputStream;
import org.apache.isis.runtimes.dflt.remoting.transport.TransportAbstract;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-
import org.apache.log4j.Logger;
-
-public class SocketTransport extends TransportAbstract {
-
- private static final Logger LOG = Logger.getLogger(SocketTransport.class);
-
- private Socket socket;
- private int port;
- private String host;
- private boolean profiling;
-
- private OutputStream outputStream;
- private InputStream inputStream;
-
- public SocketTransport(IsisConfiguration configuration) {
- super(configuration);
- }
-
- //////////////////////////////////////////////////////////
- // init, shutdown
- //////////////////////////////////////////////////////////
-
- public void init() {
- port = getConfiguration().getInteger(SocketTransportConstants.PORT_KEY, PORT_DEFAULT);
- host = getConfiguration().getString(SocketTransportConstants.HOST_KEY, SocketTransportConstants.HOST_DEFAULT);
- profiling = getConfiguration().getBoolean(SocketTransportConstants.PROFILING_KEY, SocketTransportConstants.PROFILING_DEFAULT);
- LOG.info("connections will be made to " + host + " " + port);
- }
-
- public void shutdown() {
- // does nothing
- }
-
- //////////////////////////////////////////////////////////
- // Configuration
- //////////////////////////////////////////////////////////
-
- protected boolean isProfiling() {
- return profiling;
- }
-
-
- //////////////////////////////////////////////////////////
- // connect, disconnect
- //////////////////////////////////////////////////////////
-
- public void connect() {
- if (socket != null) {
- return;
- }
-
- try {
- socket = new Socket(host, port);
- inputStream = socket.getInputStream();
- outputStream = socket.getOutputStream();
- if (isProfiling()) {
- inputStream = new ProfilingInputStream(inputStream);
- outputStream = new ProfilingOutputStream(outputStream);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("connection established " + socket);
- }
- } catch (final MalformedURLException e) {
- throw new ConnectionException("Connection failure", e);
- } catch (final UnknownHostException e) {
- throw new ConnectionException("Connection failure", e);
- } catch (final ConnectException e) {
- throw new ConnectionException("Failed to connect to " + host + "/" + port, e);
- } catch (final IOException e) {
- throw new ConnectionException("Connection failure", e);
- }
- }
-
- public InputStream getInputStream() {
- return inputStream;
- }
-
- public OutputStream getOutputStream() {
- return outputStream;
- }
-
- public void disconnect() {
- if (socket != null) {
- try {
- socket.close();
- socket = null;
- } catch (final IOException e) {
- LOG.error("failed to close connection", e);
- }
- }
- }
-
-
-}
+
+public class SocketTransport extends TransportAbstract {
+
+ private static final Logger LOG = Logger.getLogger(SocketTransport.class);
+
+ private Socket socket;
+ private int port;
+ private String host;
+ private boolean profiling;
+
+ private OutputStream outputStream;
+ private InputStream inputStream;
+
+ public SocketTransport(final IsisConfiguration configuration) {
+ super(configuration);
+ }
+
+ // ////////////////////////////////////////////////////////
+ // init, shutdown
+ // ////////////////////////////////////////////////////////
+
+ @Override
+ public void init() {
+ port = getConfiguration().getInteger(SocketTransportConstants.PORT_KEY, PORT_DEFAULT);
+ host = getConfiguration().getString(SocketTransportConstants.HOST_KEY, SocketTransportConstants.HOST_DEFAULT);
+ profiling =
+ getConfiguration().getBoolean(SocketTransportConstants.PROFILING_KEY,
+ SocketTransportConstants.PROFILING_DEFAULT);
+ LOG.info("connections will be made to " + host + " " + port);
+ }
+
+ @Override
+ public void shutdown() {
+ // does nothing
+ }
+
+ // ////////////////////////////////////////////////////////
+ // Configuration
+ // ////////////////////////////////////////////////////////
+
+ protected boolean isProfiling() {
+ return profiling;
+ }
+
+ // ////////////////////////////////////////////////////////
+ // connect, disconnect
+ // ////////////////////////////////////////////////////////
+
+ @Override
+ public void connect() {
+ if (socket != null) {
+ return;
+ }
+
+ try {
+ socket = new Socket(host, port);
+ inputStream = socket.getInputStream();
+ outputStream = socket.getOutputStream();
+ if (isProfiling()) {
+ inputStream = new ProfilingInputStream(inputStream);
+ outputStream = new ProfilingOutputStream(outputStream);
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("connection established " + socket);
+ }
+ } catch (final MalformedURLException e) {
+ throw new ConnectionException("Connection failure", e);
+ } catch (final UnknownHostException e) {
+ throw new ConnectionException("Connection failure", e);
+ } catch (final ConnectException e) {
+ throw new ConnectionException("Failed to connect to " + host + "/" + port, e);
+ } catch (final IOException e) {
+ throw new ConnectionException("Connection failure", e);
+ }
+ }
+
+ @Override
+ public InputStream getInputStream() {
+ return inputStream;
+ }
+
+ @Override
+ public OutputStream getOutputStream() {
+ return outputStream;
+ }
+
+ @Override
+ public void disconnect() {
+ if (socket != null) {
+ try {
+ socket.close();
+ socket = null;
+ } catch (final IOException e) {
+ LOG.error("failed to close connection", e);
+ }
+ }
+ }
+
+}
Modified: incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/shared/SocketTransportConstants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/shared/SocketTransportConstants.java?rev=1098939&r1=1098938&r2=1098939&view=diff
==============================================================================
--- incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/shared/SocketTransportConstants.java (original)
+++ incubator/isis/trunk/runtimes/dflt/remoting/transport-sockets/src/main/java/org/apache/isis/runtimes/dflt/remoting/transport/sockets/shared/SocketTransportConstants.java Tue May 3 06:33:43 2011
@@ -17,28 +17,25 @@
* under the License.
*/
+package org.apache.isis.runtimes.dflt.remoting.transport.sockets.shared;
-package org.apache.isis.runtimes.dflt.remoting.transport.sockets.shared;
-
-import org.apache.isis.runtimes.dflt.remoting.transport.TransportInstaller;
import org.apache.isis.core.commons.config.ConfigurationConstants;
-
-
-public final class SocketTransportConstants {
-
- public static final String ROOT =
- ConfigurationConstants.ROOT + TransportInstaller.TYPE + "." + "sockets.";
-
- public static final String PORT_KEY = ROOT + "port";
- public static final int PORT_DEFAULT = 9580;
-
- public static final String HOST_KEY = ROOT + "host";
- public static final String HOST_DEFAULT = "localhost";
-
- public static final String PROFILING_KEY = ROOT + "profiling";
- public static final boolean PROFILING_DEFAULT = true;
-
-
- private SocketTransportConstants() {}
-
-}
+import org.apache.isis.runtimes.dflt.remoting.transport.TransportInstaller;
+
+public final class SocketTransportConstants {
+
+ public static final String ROOT = ConfigurationConstants.ROOT + TransportInstaller.TYPE + "." + "sockets.";
+
+ public static final String PORT_KEY = ROOT + "port";
+ public static final int PORT_DEFAULT = 9580;
+
+ public static final String HOST_KEY = ROOT + "host";
+ public static final String HOST_DEFAULT = "localhost";
+
+ public static final String PROFILING_KEY = ROOT + "profiling";
+ public static final boolean PROFILING_DEFAULT = true;
+
+ private SocketTransportConstants() {
+ }
+
+}