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 2012/12/05 09:07:35 UTC
[7/11] ISIS-188: more refactoring of artifacts
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SmtpSnapshotAppender.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SmtpSnapshotAppender.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SmtpSnapshotAppender.java
deleted file mode 100644
index 0eef303..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SmtpSnapshotAppender.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.Socket;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.TriggeringEventEvaluator;
-
-public class SmtpSnapshotAppender extends SnapshotAppender {
- private static final Logger LOG = Logger.getLogger(SmtpSnapshotAppender.class);
- private String server;
- private String recipient;
- private int port = 25;
- private String senderDomain = "localhost";
-
- public SmtpSnapshotAppender(final TriggeringEventEvaluator evaluator) {
- super(evaluator);
- }
-
- public SmtpSnapshotAppender() {
- super();
- }
-
- public void setServer(final String mailServer) {
- if (mailServer == null) {
- throw new NullPointerException("mail server cannot be null");
- }
- this.server = mailServer;
- }
-
- public void setRecipient(final String recipient) {
- if (recipient == null) {
- throw new NullPointerException("recipient cannot be null");
- }
- this.recipient = recipient;
- }
-
- public void setPort(final int port) {
- this.port = port;
- }
-
- public void setSenderDomain(final String senderDomain) {
- if (senderDomain == null) {
- throw new NullPointerException("sender domain cannot be null");
- }
- this.senderDomain = senderDomain;
- }
-
- @Override
- protected void writeSnapshot(final String message, final String details) {
- try {
- if (server == null) {
- throw new NullPointerException("mail server must be specified");
- }
- if (recipient == null) {
- throw new NullPointerException("recipient must be specified");
- }
-
- final Socket s = new Socket(server, port);
- final BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream(), "8859_1"));
- final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(s.getOutputStream(), "8859_1"));
-
- send(in, out, "HELO " + senderDomain);
- // warning : some mail server validate the sender address
- // in the MAIL FROm command, put your real address here
-
- send(in, out, "MAIL FROM: <no-reply@" + senderDomain + ">");
- send(in, out, "RCPT TO: " + recipient);
- send(in, out, "DATA");
- send(out, "Subject: " + message);
- send(out, "From: Autosend");
- send(out, "Content-Type: " + layout.getContentType());
-
- send(out, "\r\n");
-
- // message body
- send(out, details);
- send(in, out, "\r\n.\r\n");
- send(in, out, "QUIT");
- s.close();
- } catch (final Exception e) {
- LOG.info("failed to send email with log", e);
- }
- }
-
- private void send(final BufferedReader in, final BufferedWriter out, final String s) throws IOException {
- out.write(s + "\r\n");
- out.flush();
- System.out.println("> " + s);
- final String r = in.readLine();
- System.out.println("< " + r);
- }
-
- private void send(final BufferedWriter out, final String s) throws IOException {
- out.write(s + "\r\n");
- out.flush();
- System.out.println(">> " + s);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotAppender.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotAppender.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotAppender.java
deleted file mode 100644
index ac222e9..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotAppender.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-import java.util.Date;
-
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.helpers.CyclicBuffer;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.TriggeringEventEvaluator;
-
-import org.apache.isis.core.runtime.about.AboutIsis;
-
-class DefaultEvaluator implements TriggeringEventEvaluator {
- @Override
- public boolean isTriggeringEvent(final LoggingEvent event) {
- return event.getLevel().isGreaterOrEqual(Level.ERROR);
- }
-}
-
-public abstract class SnapshotAppender extends AppenderSkeleton {
- private int bufferSize = 512;
- protected CyclicBuffer buffer = new CyclicBuffer(bufferSize);
- private boolean locationInfo = false;
- protected TriggeringEventEvaluator triggerEvaluator;
- private boolean addInfo;
-
- /**
- * The default constructor will instantiate the appender with a
- * {@link TriggeringEventEvaluator} that will trigger on events with level
- * ERROR or higher.
- */
- public SnapshotAppender() {
- this(new DefaultEvaluator());
- }
-
- public SnapshotAppender(final TriggeringEventEvaluator evaluator) {
- this.triggerEvaluator = evaluator;
- }
-
- @Override
- public void append(final LoggingEvent event) {
- if (shouldAppend()) {
- event.getThreadName();
- event.getNDC();
- if (locationInfo) {
- event.getLocationInformation();
- }
- buffer.add(event);
- if (triggerEvaluator.isTriggeringEvent(event)) {
- writeSnapshot(buffer);
- }
- }
- }
-
- public void forceSnapshot() {
- writeSnapshot(buffer);
- }
-
- /**
- * Send the contents of the cyclic buffer as an web server posting.
- */
- private void writeSnapshot(final CyclicBuffer buffer) {
- final StringBuffer details = new StringBuffer();
- final String header = layout.getHeader();
- if (header != null) {
- details.append(header);
- }
-
- if (addInfo) {
- final String user = System.getProperty("user.name");
- final String system = System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") " + System.getProperty("os.version");
- final String java = System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version");
- final String version = AboutIsis.getFrameworkVersion();
-
- final LoggingEvent infoEvent = new LoggingEvent("", Logger.getRootLogger(), Level.INFO, "Snapshot:- " + new Date() + "\n\t" + user + "\n\t" + system + "\n\t" + java + "\n\t" + version, null);
- details.append(layout.format(infoEvent));
- }
-
- final int len = buffer.length();
- String message = "";
- for (int i = 0; i < len; i++) {
- final LoggingEvent event = buffer.get();
- message = event.getLoggerName() + ": " + event.getMessage();
- details.append(layout.format(event));
- if (layout.ignoresThrowable()) {
- final String[] s = event.getThrowableStrRep();
- if (s != null) {
- for (final String element : s) {
- details.append(element);
- details.append('\n');
- }
- }
- }
- }
-
- final String footer = layout.getFooter();
- if (footer != null) {
- details.append(footer);
- }
-
- writeSnapshot(message, details.toString());
- }
-
- protected abstract void writeSnapshot(final String message, final String details);
-
- @Override
- synchronized public void close() {
- this.closed = true;
- }
-
- public int getBufferSize() {
- return bufferSize;
- }
-
- public String getEvaluatorClass() {
- return triggerEvaluator == null ? null : triggerEvaluator.getClass().getName();
- }
-
- public boolean getLocationInfo() {
- return locationInfo;
- }
-
- /**
- * returns true to show that this appender requires a
- * {@linkorg.apache.log4j.Layout layout}.
- */
- @Override
- public boolean requiresLayout() {
- return true;
- }
-
- public void setBufferSize(final int bufferSize) {
- this.bufferSize = bufferSize;
- buffer.resize(bufferSize);
- }
-
- public void setEvaluatorClass(final String value) {
- triggerEvaluator = (TriggeringEventEvaluator) OptionConverter.instantiateByClassName(value, TriggeringEventEvaluator.class, triggerEvaluator);
- }
-
- public void setAddInfo(final boolean addInfo) {
- this.addInfo = addInfo;
- }
-
- public void setLocationInfo(final boolean locationInfo) {
- this.locationInfo = locationInfo;
- }
-
- protected boolean shouldAppend() {
- if (triggerEvaluator == null) {
- errorHandler.error("No TriggeringEventEvaluator is set for appender [" + name + "].");
- return false;
- }
-
- if (layout == null) {
- errorHandler.error("No layout set for appender named [" + name + "].");
- return false;
- }
-
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotServer.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotServer.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotServer.java
deleted file mode 100644
index a8b05e3..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotServer.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.Properties;
-
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.Logger;
-
-public class SnapshotServer {
- private static final String SNAPSHOT_PROPERTIES = "snapshot.properties";
- private static final Logger LOG = Logger.getLogger(SnapshotServer.class);
-
- public static void main(final String[] args) {
- BasicConfigurator.configure();
-
- int port;
- String directoryPath;
- String fileName;
- String extension;
-
- final Properties prop = new Properties();
- FileInputStream propIn = null;
- try {
- propIn = new FileInputStream(SNAPSHOT_PROPERTIES);
- prop.load(propIn);
- } catch (final FileNotFoundException e) {
- LOG.error("failed to load properties file, " + SNAPSHOT_PROPERTIES);
- return;
- } catch (final IOException e) {
- LOG.error("failed to read properties file, " + SNAPSHOT_PROPERTIES, e);
- return;
- } finally {
- if (propIn != null) {
- try {
- propIn.close();
- } catch (final IOException e) {
- LOG.error("failed to close properties file, " + SNAPSHOT_PROPERTIES, e);
- return;
- }
- }
- }
-
- final String prefix = "isis.snapshot.";
- final String portString = prop.getProperty(prefix + "port", "9289");
- port = Integer.valueOf(portString).intValue();
- directoryPath = prop.getProperty(prefix + "directory", ".");
- fileName = prop.getProperty(prefix + "filename", "log-snapshot-");
- extension = prop.getProperty(prefix + "extension", "txt");
-
- ServerSocket server;
- try {
- server = new ServerSocket(port);
- } catch (final IOException e) {
- LOG.error("failed to start server", e);
- return;
- }
-
- while (true) {
- try {
- final Socket s = server.accept();
-
- LOG.info("receiving log from " + s.getInetAddress().getHostName());
-
- final BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream(), "8859_1"));
-
- final String message = in.readLine();
- final SnapshotWriter w = new SnapshotWriter(directoryPath, fileName, extension, message);
- String line;
- while ((line = in.readLine()) != null) {
- w.appendLog(line);
- }
- s.close();
-
- in.close();
- } catch (final IOException e) {
- LOG.error("failed to log", e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotWriter.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotWriter.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotWriter.java
deleted file mode 100644
index f1b56bf..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SnapshotWriter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.RandomAccessFile;
-import java.text.Format;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class SnapshotWriter {
- private static final Format FORMAT = new SimpleDateFormat("yyyyMMdd-HHmmss-SSS");
- private final PrintStream os;
-
- public SnapshotWriter(final String directoryPath, final String baseFileName, final String fileExtension, final String message) throws IOException {
- final File dir = new File(directoryPath == null || directoryPath.length() == 0 ? "." : directoryPath);
- if (!dir.exists()) {
- @SuppressWarnings("unused")
- final boolean created = dir.mkdirs();
- }
-
- final File indexFile = new File(dir, "index.txt");
- final Date date = new Date();
- final File logFile = new File(dir, baseFileName + FORMAT.format(date) + "." + fileExtension);
-
- final RandomAccessFile index = new RandomAccessFile(indexFile, "rw");
- index.seek(index.length());
- index.writeBytes(logFile.getName() + ": " + message + "\n");
- index.close();
-
- os = new PrintStream(new FileOutputStream(logFile));
- }
-
- public void appendLog(final String details) {
- os.println(details);
- }
-
- public void close() {
- if (os != null) {
- os.close();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SocketSnapshotAppender.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SocketSnapshotAppender.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SocketSnapshotAppender.java
deleted file mode 100644
index ba31bfd..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/SocketSnapshotAppender.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-import java.io.BufferedWriter;
-import java.io.OutputStreamWriter;
-import java.net.ConnectException;
-import java.net.Socket;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.TriggeringEventEvaluator;
-
-public class SocketSnapshotAppender extends SnapshotAppender {
- private static final Logger LOG = Logger.getLogger(SmtpSnapshotAppender.class);
- private int port = 9289;
- private String server;
-
- public SocketSnapshotAppender(final TriggeringEventEvaluator evaluator) {
- super(evaluator);
- }
-
- public SocketSnapshotAppender() {
- super();
- }
-
- public void setPort(final int port) {
- this.port = port;
- }
-
- public void setServer(final String mailServer) {
- if (mailServer == null) {
- throw new IllegalArgumentException("mail server not specified");
- }
- this.server = mailServer;
- }
-
- @Override
- protected void writeSnapshot(final String message, final String details) {
- try {
- if (server == null) {
- throw new IllegalStateException("mail server not specified");
- }
-
- final Socket s = new Socket(server, port);
-
- final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(s.getOutputStream(), "8859_1"));
-
- out.write(message + "\n");
- out.write(details + "\n");
-
- out.flush();
-
- s.close();
- } catch (final ConnectException e) {
- LOG.info("failed to connect to server " + server);
- } catch (final Exception e) {
- LOG.info("failed to send email with log", e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/WebSnapshotAppender.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/WebSnapshotAppender.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/WebSnapshotAppender.java
deleted file mode 100644
index edd25d9..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/logging/WebSnapshotAppender.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.logging;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLEncoder;
-import java.net.UnknownHostException;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.TriggeringEventEvaluator;
-
-public class WebSnapshotAppender extends SnapshotAppender {
- private static class HttpQueryWriter extends OutputStreamWriter {
-
- private int parameter = 1;
-
- public HttpQueryWriter(final OutputStream outputStream) throws UnsupportedEncodingException {
- super(outputStream, "ASCII");
- }
-
- public void addParameter(final String name, final String value) throws IOException {
- if (name == null || value == null) {
- return;
- }
-
- if (parameter > 1) {
- write("&");
- }
- parameter++;
- write(URLEncoder.encode(name, "UTF-8"));
- write("=");
- write(URLEncoder.encode(value, "UTF-8"));
- }
-
- @Override
- public void close() throws IOException {
- write("\r\n");
- flush();
- super.close();
- }
- }
-
- private static final Logger LOG = Logger.getLogger(WebSnapshotAppender.class);
- private String proxyAddress;
- private int proxyPort = -1;
-
- private String url_spec = "http://development.isis.net/errors/log.php";
-
- /**
- * The default constructor will instantiate the appender with a
- * {@link TriggeringEventEvaluator} that will trigger on events with level
- * ERROR or higher.
- */
- public WebSnapshotAppender() {
- }
-
- public WebSnapshotAppender(final TriggeringEventEvaluator evaluator) {
- super(evaluator);
- }
-
- public String getProxyAddress() {
- return proxyAddress;
- }
-
- public int getProxyPort() {
- return proxyPort;
- }
-
- public void setProxyAddress(final String proxyAddess) {
- this.proxyAddress = proxyAddess;
- }
-
- public void setProxyPort(final int proxyPort) {
- this.proxyPort = proxyPort;
- }
-
- public void setUrl(final String url) {
- url_spec = url;
- }
-
- @Override
- protected void writeSnapshot(final String message, final String details) {
- try {
- final URL url = proxyAddress == null ? new URL(url_spec) : new URL("http", proxyAddress, proxyPort, url_spec);
- LOG.info("connect to " + url);
- final URLConnection connection = url.openConnection();
- connection.setDoOutput(true);
- final HttpQueryWriter out = new HttpQueryWriter(connection.getOutputStream());
- out.addParameter("error", message);
- out.addParameter("trace", details);
- out.close();
-
- final InputStream in = connection.getInputStream();
- int c;
- final StringBuffer result = new StringBuffer();
- while ((c = in.read()) != -1) {
- result.append((char) c);
- }
- LOG.info(result);
-
- in.close();
-
- } catch (final UnknownHostException e) {
- LOG.info("could not find host (unknown host) to submit log to");
- } catch (final IOException e) {
- LOG.debug("i/o problem submitting log", e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/BootPrinter.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/BootPrinter.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/BootPrinter.java
deleted file mode 100644
index e74c698..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/BootPrinter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.optionhandler;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Options;
-
-import org.apache.isis.core.runtime.sysout.SystemPrinter;
-
-public class BootPrinter extends SystemPrinter {
-
- private final PrintWriter printWriter;
- private final String className;
-
- public BootPrinter(final Class<?> cls, final PrintStream output) {
- super(output);
- this.printWriter = new PrintWriter(getOutput());
- className = cls.getName().substring(cls.getName().lastIndexOf('.') + 1);
- }
-
- public BootPrinter(final Class<?> cls) {
- this(cls, System.out);
- }
-
- public void printErrorAndHelp(final Options options, final String formatStr, final Object... args) {
- getOutput().println(String.format(formatStr, args));
- printHelp(options);
- printWriter.flush();
- }
-
- public void printHelp(final Options options) {
- final HelpFormatter help = new HelpFormatter();
- help.printHelp(printWriter, 80, className + " [options]", null, options, 0, 0, null, false);
- printWriter.flush();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/OptionHandler.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/OptionHandler.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/OptionHandler.java
deleted file mode 100644
index f39cae5..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/OptionHandler.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.optionhandler;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-
-import org.apache.isis.core.commons.config.IsisConfigurationBuilderPrimer;
-
-public interface OptionHandler extends IsisConfigurationBuilderPrimer {
-
- public void addOption(Options options);
-
- public boolean handle(CommandLine commandLine, BootPrinter bootPrinter, Options options);
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/OptionHandlerAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/OptionHandlerAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/OptionHandlerAbstract.java
deleted file mode 100644
index 6e1ae09..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/optionhandler/OptionHandlerAbstract.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.optionhandler;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.cli.CommandLine;
-
-import org.apache.isis.core.commons.components.Installer;
-import org.apache.isis.core.commons.lang.ListUtils;
-
-public abstract class OptionHandlerAbstract implements OptionHandler {
-
- public OptionHandlerAbstract() {
- }
-
- protected StringBuffer availableInstallers(final Object[] factories) {
- final StringBuffer types = new StringBuffer();
- for (int i = 0; i < factories.length; i++) {
- if (i > 0) {
- types.append("; ");
- }
- types.append(((Installer) factories[i]).getName());
- }
- return types;
- }
-
- protected List<String> getOptionValues(final CommandLine commandLine, final String opt) {
- final List<String> list = new ArrayList<String>();
- final String[] optionValues = commandLine.getOptionValues(opt);
- if (optionValues != null) {
- for (final String optionValue : optionValues) {
- ListUtils.appendDelimitedStringToList(optionValue, list);
- }
- }
- return list;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/profiler/Profiler.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/profiler/Profiler.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/profiler/Profiler.java
deleted file mode 100644
index d3cdea0..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/profiler/Profiler.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.profiler;
-
-import java.text.NumberFormat;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-public class Profiler {
-
- private final static String DELIMITER = "\t";
- private static NumberFormat FLOAT_FORMAT = NumberFormat.getNumberInstance(Locale.UK);
- private static NumberFormat INTEGER_FORMAT = NumberFormat.getNumberInstance(Locale.UK);
-
- private final static Map<Thread, String> threads = new HashMap<Thread, String>();
-
- private static int nextId = 0;
- private static int nextThread = 0;
-
- protected static ProfilerSystem profilerSystem = new ProfilerSystem();
-
- /**
- * Primarily for testing.
- *
- * @param profilerSystem
- */
- public static void setProfilerSystem(final ProfilerSystem profilerSystem) {
- Profiler.profilerSystem = profilerSystem;
- }
-
- public static String memoryLog() {
- final long free = memory();
- return INTEGER_FORMAT.format(free) + " bytes";
- }
-
- private static long time() {
- return profilerSystem.time();
- }
-
- private static long memory() {
- return profilerSystem.memory();
- }
-
- // ////////////////////////////////////////////////////////////
- // Profiler instance, constructor
- // ////////////////////////////////////////////////////////////
-
- private final String thread;
-
- private final int id;
- private final String name;
-
- private long elapsedTime = 0;
- private long memory;
- private long start = 0;
- private boolean timing = false;
-
- public Profiler(final String name) {
- this.name = name;
- synchronized (Profiler.class) {
- this.id = nextId++;
- }
- final Thread t = Thread.currentThread();
- final String thread = threads.get(t);
- if (thread != null) {
- this.thread = thread;
- } else {
- this.thread = "t" + nextThread++;
- threads.put(t, this.thread);
- }
- memory = memory();
- }
-
- public String getName() {
- return name;
- }
-
- // ////////////////////////////////////////////////////////////
- // start, stop, reset
- // ////////////////////////////////////////////////////////////
-
- public void reset() {
- elapsedTime = 0;
- start = time();
- memory = memory();
- }
-
- public void start() {
- start = time();
- timing = true;
- }
-
- public void stop() {
- timing = false;
- final long end = time();
- elapsedTime += end - start;
- }
-
- // ////////////////////////////////////////////////////////////
- // MemoryUsage, ElapsedTime
- // ////////////////////////////////////////////////////////////
-
- public long getElapsedTime() {
- return timing ? time() - start : elapsedTime;
- }
-
- public long getMemoryUsage() {
- return memory() - memory;
- }
-
- // ////////////////////////////////////////////////////////////
- // logging
- // ////////////////////////////////////////////////////////////
-
- public String memoryUsageLog() {
- return INTEGER_FORMAT.format(getMemoryUsage()) + " bytes";
- }
-
- public String timeLog() {
- return FLOAT_FORMAT.format(getElapsedTime() / 1000.0) + " secs";
- }
-
- public String log() {
- return id + DELIMITER + thread + DELIMITER + getName() + DELIMITER + getMemoryUsage() + DELIMITER + getElapsedTime();
- }
-
- @Override
- public String toString() {
- return getElapsedTime() + "ms - " + name;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/profiler/ProfilerSystem.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/profiler/ProfilerSystem.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/profiler/ProfilerSystem.java
deleted file mode 100644
index e929799..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/profiler/ProfilerSystem.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.profiler;
-
-public class ProfilerSystem {
- protected long memory() {
- return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
- }
-
- protected long time() {
- return System.currentTimeMillis();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/DomSerializer.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/DomSerializer.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/DomSerializer.java
deleted file mode 100644
index 68e7a20..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/DomSerializer.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.snapshot;
-
-import java.io.OutputStream;
-import java.io.Writer;
-
-import org.w3c.dom.Element;
-
-public interface DomSerializer {
- public String serialize(final Element domElement);
-
- public void serializeTo(final Element domElement, final OutputStream os) throws Exception;
-
- public void serializeTo(final Element domElement, final Writer w) throws Exception;
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/DomSerializerJaxp.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/DomSerializerJaxp.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/DomSerializerJaxp.java
deleted file mode 100644
index bd9cce0..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/DomSerializerJaxp.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.snapshot;
-
-import java.io.CharArrayWriter;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Element;
-
-public class DomSerializerJaxp implements DomSerializer {
-
- private final TransformerFactory transformerFactory;
- private final Transformer newTransformer;
-
- public DomSerializerJaxp() throws TransformerConfigurationException {
- this.transformerFactory = TransformerFactory.newInstance();
- this.newTransformer = transformerFactory.newTransformer();
- }
-
- @Override
- public String serialize(final Element domElement) {
- final CharArrayWriter caw = new CharArrayWriter();
- try {
- serializeTo(domElement, caw);
- return caw.toString();
- } catch (final Exception e) {
- return null;
- }
- }
-
- @Override
- public void serializeTo(final Element domElement, final OutputStream os) throws Exception {
- final OutputStreamWriter osw = new OutputStreamWriter(os);
- serializeTo(domElement, osw);
- }
-
- @Override
- public void serializeTo(final Element domElement, final Writer writer) throws Exception {
- final Source source = new DOMSource(domElement);
- final Result result = new StreamResult(writer);
- newTransformer.transform(source, result);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/Helper.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/Helper.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/Helper.java
deleted file mode 100644
index 363aa92..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/Helper.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.snapshot;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Stateless utility methods for manipulating XML documents.
- */
-public final class Helper {
-
- /**
- * Helper method
- */
- String trailingSlash(final String str) {
- return str.endsWith("/") ? str : str + "/";
- }
-
- /**
- * Utility method that returns just the class's name for the supplied fully
- * qualified class name.
- *
- * cf 'basename' in Unix.
- */
- String classNameFor(final String fullyQualifiedClassName) {
- final int fullNameLastPeriodIdx = fullyQualifiedClassName.lastIndexOf('.');
- if (fullNameLastPeriodIdx > 0 && fullNameLastPeriodIdx < fullyQualifiedClassName.length()) {
- return fullyQualifiedClassName.substring(fullNameLastPeriodIdx + 1);
- } else {
- return fullyQualifiedClassName;
- }
- }
-
- /**
- * Utility method that returns the package name for the supplied fully
- * qualified class name, or <code>default</code> if the class is in no
- * namespace / in the default namespace.
- *
- * cf 'dirname' in Unix.
- */
- String packageNameFor(final String fullyQualifiedClassName) {
- final int fullNameLastPeriodIdx = fullyQualifiedClassName.lastIndexOf('.');
- if (fullNameLastPeriodIdx > 0) {
- return fullyQualifiedClassName.substring(0, fullNameLastPeriodIdx);
- } else {
- return "default"; // TODO: should provide a better way to specify
- // namespace.
- }
- }
-
- /**
- * Returns the root element for the element by looking up the owner document
- * for the element, and from that its document element.
- *
- * If no document element exists, just returns the supplied document.
- */
- Element rootElementFor(final Element element) {
- final Document doc = element.getOwnerDocument();
- if (doc == null) {
- return element;
- }
- final Element rootElement = doc.getDocumentElement();
- if (rootElement == null) {
- return element;
- }
- return rootElement;
- }
-
- Document docFor(final Element element) {
- return element.getOwnerDocument();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/IsisSchema.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/IsisSchema.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/IsisSchema.java
deleted file mode 100644
index ff4fbaa..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/IsisSchema.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.snapshot;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
-
-/**
- * Utility methods relating to the Isis meta model.
- */
-final class IsisSchema {
-
- /**
- * The generated XML schema references the NOF metamodel schema. This is the
- * default location for this schema.
- */
- public static final String DEFAULT_LOCATION = "isis.xsd";
- /**
- * The base of the namespace URI to use for application namespaces if none
- * explicitly supplied in the constructor.
- */
- public final static String DEFAULT_URI_BASE = "http://isis.apache.org/ns/app/";
-
- /**
- * Enumeration of isis:feature attribute representing a class
- */
- public static final String FEATURE_CLASS = "class";
- /**
- * Enumeration of isis:feature attribute representing a collection (1:n
- * association)
- */
- public static final String FEATURE_COLLECTION = "collection";
- /**
- * Enumeration of isis:feature attribute representing a reference (1:1
- * association)
- */
- public static final String FEATURE_REFERENCE = "reference";
- /**
- * Enumeration of isis:feature attribute representing a value field
- */
- public static final String FEATURE_VALUE = "value";
- /**
- * Namespace prefix for {@link NS_URI}.
- *
- * The NamespaceManager will not allow any namespace to use this prefix.
- */
- public static final String NS_PREFIX = "nof";
- /**
- * URI representing the namespace of ObjectAdapter framework's metamodel.
- *
- * The NamespaceManager will not allow any namespaces with this URI to be
- * added.
- */
- public static final String NS_URI = "http://isis.apache.org/ns/0.1/metamodel";
-
- private final Helper helper;
-
- public IsisSchema() {
- this.helper = new Helper();
- }
-
- void addNamespace(final Element element) {
- helper.rootElementFor(element).setAttributeNS(XsMetaModel.W3_ORG_XMLNS_URI, XsMetaModel.W3_ORG_XMLNS_PREFIX + ":" + IsisSchema.NS_PREFIX, IsisSchema.NS_URI);
- }
-
- /**
- * Creates an element in the NOF namespace, appends to parent, and adds NOF
- * namespace to the root element if required.
- */
- Element appendElement(final Element parentElement, final String localName) {
- final Element element = helper.docFor(parentElement).createElementNS(IsisSchema.NS_URI, IsisSchema.NS_PREFIX + ":" + localName);
- parentElement.appendChild(element);
- // addNamespace(parentElement);
- return element;
- }
-
- /**
- * Appends an <code>nof:title</code> element with the supplied title string
- * to the provided element.
- */
- public void appendNofTitle(final Element element, final String titleStr) {
- final Document doc = helper.docFor(element);
- final Element titleElement = appendElement(element, "title");
- titleElement.appendChild(doc.createTextNode(titleStr));
- }
-
- /**
- * Gets an attribute with the supplied name in the Isis namespace from the
- * supplied element
- */
- String getAttribute(final Element element, final String attributeName) {
- return element.getAttributeNS(IsisSchema.NS_URI, attributeName);
- }
-
- /**
- * Adds an <code>isis:annotation</code> attribute for the supplied class to
- * the supplied element.
- */
- void setAnnotationAttribute(final Element element, final String annotation) {
- setAttribute(element, "annotation", IsisSchema.NS_PREFIX + ":" + annotation);
- }
-
- /**
- * Sets an attribute of the supplied element with the attribute being in the
- * Isis namespace.
- */
- private void setAttribute(final Element element, final String attributeName, final String attributeValue) {
- element.setAttributeNS(IsisSchema.NS_URI, IsisSchema.NS_PREFIX + ":" + attributeName, attributeValue);
- }
-
- /**
- * Adds <code>isis:feature="class"</code> attribute and
- * <code>isis:oid="e;..."</code> for the supplied element.
- */
- void setAttributesForClass(final Element element, final String oid) {
- setAttribute(element, "feature", FEATURE_CLASS);
- setAttribute(element, "oid", oid);
- }
-
- /**
- * Adds <code>nof:feature="reference"</code> attribute and
- * <code>nof:type="e;..."</code> for the supplied element.
- */
- void setAttributesForReference(final Element element, final String prefix, final String fullyQualifiedClassName) {
- setAttribute(element, "feature", FEATURE_REFERENCE);
- setAttribute(element, "type", prefix + ":" + fullyQualifiedClassName);
- }
-
- /**
- * Adds <code>nof:feature="value"</code> attribute and
- * <code>nof:datatype="e;..."</code> for the supplied element.
- */
- void setAttributesForValue(final Element element, final String datatypeName) {
- setAttribute(element, "feature", FEATURE_VALUE);
- setAttribute(element, "datatype", IsisSchema.NS_PREFIX + ":" + datatypeName);
- }
-
- /**
- * Adds an <code>nof:isEmpty</code> attribute for the supplied class to the
- * supplied element.
- */
- void setIsEmptyAttribute(final Element element, final boolean isEmpty) {
- setAttribute(element, "isEmpty", "" + isEmpty);
- }
-
- /**
- * Adds <code>nof:feature="collection"</code> attribute, the
- * <code>nof:type="e;..."</code> and the
- * <code>nof:size="e;..."</code> for the supplied element.
- *
- * Additionally, if the <code>addOids</code> parameter is set, also adds
- * <code><oids></code> child elements.
- */
- void setIsisCollection(final Element element, final String prefix, final String fullyQualifiedClassName, final ObjectAdapter collection) {
- setAttribute(element, "feature", FEATURE_COLLECTION);
- setAttribute(element, "type", prefix + ":" + fullyQualifiedClassName);
- final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
- setAttribute(element, "size", "" + facet.size(collection));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de87443/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/Place.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/Place.java b/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/Place.java
deleted file mode 100644
index a979391..0000000
--- a/framework/core/runtime/src/main/java/org/apache/isis/core/runtime/snapshot/Place.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.snapshot;
-
-import org.w3c.dom.Element;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-
-/**
- * Represents a place in the graph to be navigated; really just wraps an object
- * and an XML Element in its XML document. Also provides the capability to
- * extract the corresponding XSD element (associated with each XML element).
- *
- * The XML element (its children) is mutated as the graph of objects is
- * navigated.
- */
-final class Place {
- private static final String USER_DATA_XSD_KEY = "XSD";
- private final ObjectAdapter object;
- private final Element element;
-
- Place(final ObjectAdapter object, final Element element) {
- this.object = object;
- this.element = element;
- }
-
- public Element getXmlElement() {
- return element;
- }
-
- public ObjectAdapter getObject() {
- return object;
- }
-
- public Element getXsdElement() {
- final Object o = element.getUserData(USER_DATA_XSD_KEY);
- if (o == null || !(o instanceof Element)) {
- return null;
- }
- return (Element) o;
- }
-
- // TODO: smelly; where should this responsibility lie?
- static void setXsdElement(final Element element, final Element xsElement) {
- element.setUserData(USER_DATA_XSD_KEY, xsElement, null);
- }
-
-}