Modified: river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/StreamPool.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/StreamPool.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/StreamPool.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/StreamPool.java Sun Jul 5 11:41:39 2020 @@ -1,294 +1,296 @@ -/* - * 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.river.mercury; - -import org.apache.river.logging.Levels; - -import java.io.EOFException; -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.RandomAccessFile; -import java.io.SyncFailedException; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * This class provides a pool of <tt>LogStream</tt> objects. Each - * <tt>LogStream</tt> has an associated <tt>FileDescriptor</tt>, which - * is the system resource we are trying to manage. This pool limits the - * (user configurable) number of concurrent, open <tt>FileDescriptor</tt>s. - * - * @author Sun Microsystems, Inc. - * - * @since 1.1 - */ -class StreamPool { - // Class fields - /** Logger for lease related messages */ - private static final Logger persistenceLogger = - MailboxImpl.PERSISTENCE_LOGGER; - - /** - * Maximum limit for the number of concurrent <tt>LogStream</tt>s - * in the stream pool. - */ - private final int maxPoolSize; - - /** Holds stream references by associated key */ - private final HashMap pool; - - /** - * Holds stream references in least recently used (released) order. - * It's used in order determine which stream to discard upon - * reaching the maximum pool limit. - */ - private final LinkedList freeList; - - /** - * Simple constructor that creates a pool of given <code>size</code>. - * - * @exception IllegalArgumentException Thrown if the value of - * <tt>maxPoolSize</tt> is less than 1. - */ - StreamPool(int size) { - if (size < 1) - throw new IllegalArgumentException( - "Pool size must be greater than 0."); - maxPoolSize = size; - pool = new HashMap(maxPoolSize); - freeList = new LinkedList(); - - if (persistenceLogger.isLoggable(Level.FINEST)) { - persistenceLogger.log(Level.FINEST, - "Created StreamPool of size {0}", - Integer.valueOf(maxPoolSize)); - } - } - - /** - * Returns a <tt>ControlLog</tt> object for the specified <tt>file</tt> - * from the pool if it already exists. - * Otherwise, it creates a new instance and adds it to the pool. - * - * @exception IOException if an I/O error occurs - */ - synchronized ControlLog getControlLog(File file) - throws IOException - { - StreamKey key = new StreamKey(file, StreamType.CONTROL); - ControlLog log = (ControlLog)pool.get(key); - if (log != null) { // found it! - if (freeList.remove(key) == false) - throw new InternalMailboxException("Did not find re-used control log " - + "stream in freeList."); - } else { // Log was not found, so attempt to add it - - ensurePoolSpace(); - - // - // Create new ControlLog and add it the pool. - // - log = new ControlLog(file, key); - pool.put(key, log); - - if(freeList.remove(key)) - throw new InternalMailboxException("Found newly created ControlLog " - + "in freeList"); - } - - return log; - } - - /** - * Returns a <tt>LogInputStream</tt> object from the pool if it - * already exists. Otherwise, it creates a new instance and adds - * it to the pool. - * - * @exception IOException if an I/O error occurs - */ - synchronized LogInputStream getLogInputStream(File file, long offset) - throws IOException - { - StreamKey key = new StreamKey(file, StreamType.INPUT); - LogInputStream in = (LogInputStream)pool.get(key); - if (in != null) { //found it! - if (freeList.remove(key) == false) - throw new InternalMailboxException("Did not find re-used input log " - + "stream in freelist."); - } - - if (in == null || // if log not found OR - in.getOffset() > offset) // current read offset is past desired - { // then create a new log and add it - ensurePoolSpace(); - - in = new LogInputStream(file, key); - pool.put(key, in); - - if(freeList.remove(key)) - throw new InternalMailboxException("Found newly created ControlLog " - + "on freeList"); - } - - // Sanity check for offset value - if (offset > file.length()) - throw new EOFException("Attempting to read past end of file."); - - // Check if log offset needs adjusting. - // By this point in.offset <= offset. - while (in.getOffset() < offset) { - in.skip(offset - in.getOffset()); - } - - return in; - } - - /** - * Returns a <tt>LogOutputStream</tt> object for the specified <tt>file</tt> - * from the pool if it already exists. - * Otherwise, it creates a new instance and adds it to the pool. - * - * @exception IOException if an I/O error occurs - */ - synchronized LogOutputStream getLogOutputStream(File file, long offset) - throws IOException - { - StreamKey key = new StreamKey(file, StreamType.OUTPUT); - LogOutputStream out = (LogOutputStream)pool.get(key); - - if (out != null) { // found it! - if (freeList.remove(key) == false) - throw new InternalMailboxException("Did not find re-used output log " - + "stream in freelist"); - - // Sanity check to see if we are still in sync. If not, - // then we need to close this stream and create another - // one (done in the next code block). - if (out.getOffset() != offset) { - removeLogStream(out); - out = null; - } - } - - // Check to see if we need to create another log. - if (out == null) { - - ensurePoolSpace(); - - if (offset == 0L) { // Create new log, without appending - out = new LogOutputStream(file, key, false); - } else { // Create new log, appending to existing file - long len = file.length(); - - if (offset > len) - throw new EOFException("Attempting to write past end " - + "of file"); - - if (offset < len) { - RandomAccessFile raf = new RandomAccessFile(file, "rw"); - raf.setLength(offset); - raf.close(); - } - - out = new LogOutputStream(file, key, true); - } - - pool.put(key, out); - - if (freeList.remove(key)) - throw new InternalMailboxException("Found newly created output log " - + "in freeList"); - - } - - return out; - } - - /** - * Ensures that room is available in the pool. If the pool is currently - * full, then the least recently used <tt>LogStream</tt> will be removed - * and closed to make room. This method will block if the pool is full and - * no <tt>LogStream</tt> objects can be closed. - * - * @exception IOException if an I/O error occurs - */ - private synchronized void ensurePoolSpace() throws IOException { - if (pool.size() >= maxPoolSize) { - while(freeList.size() < 1) { - try { - wait(); - } catch (InterruptedException ie) { ; } - } - StreamKey key = (StreamKey)freeList.removeFirst(); - LogStream els = (LogStream)pool.remove(key); - els.close(); - } - } - - /** - * Marks a stream as available for closing. - * A log will only be closed if a new log is requested and the - * pool has reached its maximum size. - */ - synchronized void releaseLogStream(LogStream stream) { - StreamKey key = (StreamKey)stream.getKey(); - if (pool.get(key) == null) - throw new InternalMailboxException("Not managing stream: " - + stream + ":" + key + " -- release failed"); - freeList.add(key); - notifyAll(); - } - - /** - * Removes the given <tt>LogStream</tt> from the pool and closes it, - * if possible. The intent is for this method to be called for - * unusable logs so that they will no longer be returned by a - * subsequent call to one of the "get" methods. - */ - synchronized void removeLogStream(LogStream stream) { - StreamKey key = (StreamKey)stream.getKey(); - if (pool.remove(key) == null) - throw new InternalMailboxException("Not managing stream: " - + stream + ":" + key + " -- remove failed"); - - // Remove it from freeList, if present - freeList.remove(key); - try { - stream.close(); - } catch (IOException ioe) { - // Note the exception, but otherwise ignore - if (persistenceLogger.isLoggable(Levels.HANDLED)) { - persistenceLogger.log(Levels.HANDLED, - "Exception closing Log", ioe); - } - } - } - - // - // Debug use only! - // - synchronized int getPoolSize() { return pool.size(); } - synchronized int getFreeSize() { return freeList.size(); } - synchronized void dump() { - System.out.println("Pool:\n" + pool); - System.out.println("Free:\n" + freeList); - } -} +/* + * 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.river.mercury; + +import org.apache.river.logging.Levels; + +import java.io.EOFException; +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.RandomAccessFile; +import java.io.SyncFailedException; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.river.mercury.proxy.InternalMailboxException; + +/** + * This class provides a pool of <tt>LogStream</tt> objects. Each + * <tt>LogStream</tt> has an associated <tt>FileDescriptor</tt>, which + * is the system resource we are trying to manage. This pool limits the + * (user configurable) number of concurrent, open <tt>FileDescriptor</tt>s. + * + * @author Sun Microsystems, Inc. + * + * @since 1.1 + */ +class StreamPool { + // Class fields + /** Logger for lease related messages */ + private static final Logger persistenceLogger = + MailboxImpl.PERSISTENCE_LOGGER; + + /** + * Maximum limit for the number of concurrent <tt>LogStream</tt>s + * in the stream pool. + */ + private final int maxPoolSize; + + /** Holds stream references by associated key */ + private final HashMap pool; + + /** + * Holds stream references in least recently used (released) order. + * It's used in order determine which stream to discard upon + * reaching the maximum pool limit. + */ + private final LinkedList freeList; + + /** + * Simple constructor that creates a pool of given <code>size</code>. + * + * @exception IllegalArgumentException Thrown if the value of + * <tt>maxPoolSize</tt> is less than 1. + */ + StreamPool(int size) { + if (size < 1) + throw new IllegalArgumentException( + "Pool size must be greater than 0."); + maxPoolSize = size; + pool = new HashMap(maxPoolSize); + freeList = new LinkedList(); + + if (persistenceLogger.isLoggable(Level.FINEST)) { + persistenceLogger.log(Level.FINEST, + "Created StreamPool of size {0}", + Integer.valueOf(maxPoolSize)); + } + } + + /** + * Returns a <tt>ControlLog</tt> object for the specified <tt>file</tt> + * from the pool if it already exists. + * Otherwise, it creates a new instance and adds it to the pool. + * + * @exception IOException if an I/O error occurs + */ + synchronized ControlLog getControlLog(File file) + throws IOException + { + StreamKey key = new StreamKey(file, StreamType.CONTROL); + ControlLog log = (ControlLog)pool.get(key); + if (log != null) { // found it! + if (freeList.remove(key) == false) + throw new InternalMailboxException("Did not find re-used control log " + + "stream in freeList."); + } else { // Log was not found, so attempt to add it + + ensurePoolSpace(); + + // + // Create new ControlLog and add it the pool. + // + log = new ControlLog(file, key); + pool.put(key, log); + + if(freeList.remove(key)) + throw new InternalMailboxException("Found newly created ControlLog " + + "in freeList"); + } + + return log; + } + + /** + * Returns a <tt>LogInputStream</tt> object from the pool if it + * already exists. Otherwise, it creates a new instance and adds + * it to the pool. + * + * @exception IOException if an I/O error occurs + */ + synchronized LogInputStream getLogInputStream(File file, long offset) + throws IOException + { + StreamKey key = new StreamKey(file, StreamType.INPUT); + LogInputStream in = (LogInputStream)pool.get(key); + if (in != null) { //found it! + if (freeList.remove(key) == false) + throw new InternalMailboxException("Did not find re-used input log " + + "stream in freelist."); + } + + if (in == null || // if log not found OR + in.getOffset() > offset) // current read offset is past desired + { // then create a new log and add it + ensurePoolSpace(); + + in = new LogInputStream(file, key); + pool.put(key, in); + + if(freeList.remove(key)) + throw new InternalMailboxException("Found newly created ControlLog " + + "on freeList"); + } + + // Sanity check for offset value + if (offset > file.length()) + throw new EOFException("Attempting to read past end of file."); + + // Check if log offset needs adjusting. + // By this point in.offset <= offset. + while (in.getOffset() < offset) { + in.skip(offset - in.getOffset()); + } + + return in; + } + + /** + * Returns a <tt>LogOutputStream</tt> object for the specified <tt>file</tt> + * from the pool if it already exists. + * Otherwise, it creates a new instance and adds it to the pool. + * + * @exception IOException if an I/O error occurs + */ + synchronized LogOutputStream getLogOutputStream(File file, long offset) + throws IOException + { + StreamKey key = new StreamKey(file, StreamType.OUTPUT); + LogOutputStream out = (LogOutputStream)pool.get(key); + + if (out != null) { // found it! + if (freeList.remove(key) == false) + throw new InternalMailboxException("Did not find re-used output log " + + "stream in freelist"); + + // Sanity check to see if we are still in sync. If not, + // then we need to close this stream and create another + // one (done in the next code block). + if (out.getOffset() != offset) { + removeLogStream(out); + out = null; + } + } + + // Check to see if we need to create another log. + if (out == null) { + + ensurePoolSpace(); + + if (offset == 0L) { // Create new log, without appending + out = new LogOutputStream(file, key, false); + } else { // Create new log, appending to existing file + long len = file.length(); + + if (offset > len) + throw new EOFException("Attempting to write past end " + + "of file"); + + if (offset < len) { + RandomAccessFile raf = new RandomAccessFile(file, "rw"); + raf.setLength(offset); + raf.close(); + } + + out = new LogOutputStream(file, key, true); + } + + pool.put(key, out); + + if (freeList.remove(key)) + throw new InternalMailboxException("Found newly created output log " + + "in freeList"); + + } + + return out; + } + + /** + * Ensures that room is available in the pool. If the pool is currently + * full, then the least recently used <tt>LogStream</tt> will be removed + * and closed to make room. This method will block if the pool is full and + * no <tt>LogStream</tt> objects can be closed. + * + * @exception IOException if an I/O error occurs + */ + private synchronized void ensurePoolSpace() throws IOException { + if (pool.size() >= maxPoolSize) { + while(freeList.size() < 1) { + try { + wait(); + } catch (InterruptedException ie) { ; } + } + StreamKey key = (StreamKey)freeList.removeFirst(); + LogStream els = (LogStream)pool.remove(key); + els.close(); + } + } + + /** + * Marks a stream as available for closing. + * A log will only be closed if a new log is requested and the + * pool has reached its maximum size. + */ + synchronized void releaseLogStream(LogStream stream) { + StreamKey key = (StreamKey)stream.getKey(); + if (pool.get(key) == null) + throw new InternalMailboxException("Not managing stream: " + + stream + ":" + key + " -- release failed"); + freeList.add(key); + notifyAll(); + } + + /** + * Removes the given <tt>LogStream</tt> from the pool and closes it, + * if possible. The intent is for this method to be called for + * unusable logs so that they will no longer be returned by a + * subsequent call to one of the "get" methods. + */ + synchronized void removeLogStream(LogStream stream) { + StreamKey key = (StreamKey)stream.getKey(); + if (pool.remove(key) == null) + throw new InternalMailboxException("Not managing stream: " + + stream + ":" + key + " -- remove failed"); + + // Remove it from freeList, if present + freeList.remove(key); + try { + stream.close(); + } catch (IOException ioe) { + // Note the exception, but otherwise ignore + if (persistenceLogger.isLoggable(Levels.HANDLED)) { + persistenceLogger.log(Levels.HANDLED, + "Exception closing Log", ioe); + } + } + } + + // + // Debug use only! + // + synchronized int getPoolSize() { return pool.size(); } + synchronized int getFreeSize() { return freeList.size(); } + synchronized void dump() { + System.out.println("Pool:\n" + pool); + System.out.println("Free:\n" + freeList); + } +}
Modified: river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/TransientEventLog.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/TransientEventLog.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/TransientEventLog.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/TransientEventLog.java Sun Jul 5 11:41:39 2020 @@ -1,282 +1,284 @@ -/* - * 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.river.mercury; - -import net.jini.id.Uuid; -import net.jini.core.event.RemoteEvent; - -import java.io.IOException; - -import org.apache.river.logging.Levels; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.NoSuchElementException; -import java.util.concurrent.atomic.AtomicLong; - -/** - * Class that implements the interface for an <tt>EventLog</tt>. - * This class encapsulates the details of reading/writing events from/to - * some non-persistent mechanism. - * - * This class makes certain assumptions. First, the <tt>next</tt> and - * <tt>remove</tt> methods are intended to be called in pairs. If - * <tt>remove</tt> is not called, then subsequent calls to <tt>next</tt> - * will attempt to return the same object. Calling <tt>remove</tt> - * essentially advances the read pointer to the next object, if any. - * - * There is also an implicit assumption of external synchronization by the - * caller. That is, only one calling thread will be accessing the log at a time. - * - * @author Sun Microsystems, Inc. - * - * @since 2.0 - */ - -class TransientEventLog implements EventLog { - - // - // Class fields - // - - /** <tt>Logger</tt> used for persistence-related debugging messages */ - private static final Logger persistenceLogger = - MailboxImpl.PERSISTENCE_LOGGER; - - // - // Object fields - // - - /** The associated <tt>Uuid</tt> for this <tt>EventLog</tt>. */ - private final Uuid uuid; - - /** The associated, non-persistent storage for events */ - private final List entries; - - /** - * Flag that is used to determine whether or not this object - * has been closed. - */ - private volatile boolean closed = false; - - /** - * Flag that is used to determine whether or not this object - * has been initialized. - */ - private volatile boolean initialized = false; - - /** - * Helper class used to hold a remote event and a sequence id. - */ - private static class RemoteEventHolder { - private final long id; - private final RemoteEvent remoteEvent; - RemoteEventHolder(long stamp, RemoteEvent re) { - id = stamp; - remoteEvent = re; - } - long getID() { return id; } - RemoteEvent getRemoteEvent() { return remoteEvent; } - } - - /** - * Counter used to produce event ids. - */ - private AtomicLong eventCounter = new AtomicLong(1); - - /** - * Simple constructor that takes a <tt>Uuid</tt> argument. - * - * @exception IllegalArgumentException if the argument is null - */ - TransientEventLog(Uuid uuid) { - if (uuid == null) - throw new IllegalArgumentException("Uuid cannot be null"); - this.uuid = uuid; - entries = Collections.synchronizedList(new LinkedList()); - - if (persistenceLogger.isLoggable(Level.FINEST)) { - persistenceLogger.log(Level.FINEST, - "TransientEventLog for: {0}", uuid); - } - } - - // Inherit documentation from supertype - public void init() throws IOException { - if (initialized) - throw new InternalMailboxException( - "Trying to re-initialize event log " - + "for: " + uuid); - initialized = true; - } - - /** - * Asserts that the log is in a valid state. - * - * @exception IOException if the log is in an invalid state - */ - private void stateCheck() throws IOException { - if (!initialized) - throw new IOException("Trying to use an uninitialized " - + "event log for: " + uuid); - if (closed) - throw new IOException("Attempt to access closed log file for : " - + uuid); - } - - // Inherit documentation from supertype - public void add(RemoteEvent event) throws IOException { - stateCheck(); - long id = eventCounter.getAndIncrement(); - RemoteEventHolder data = new RemoteEventHolder(id, event); - entries.add(data); - printControlData(persistenceLogger, "TransientEventLog::add"); - } - - // Inherit documentation from supertype - public RemoteEvent next() throws IOException { - stateCheck(); - // Check if empty - if (isEmpty()) - throw new NoSuchElementException(); - - printControlData(persistenceLogger, "TransientEventLog::next"); - RemoteEventHolder data = (RemoteEventHolder)entries.get(0); - return (RemoteEvent)data.getRemoteEvent(); - } - - // Inherit documentation from supertype - public RemoteEventData[] readAhead(int maxEvents) throws IOException { - stateCheck(); - - if (maxEvents < 0) - throw new IllegalArgumentException(); - - if (maxEvents == 0) - return new RemoteEventData[0]; - - // Check if empty - if (isEmpty()) - throw new NoSuchElementException(); - - printControlData(persistenceLogger, "TransientEventLog::readAhead"); - int limit = (maxEvents < entries.size())?maxEvents:entries.size(); - RemoteEventHolder[] evts = (RemoteEventHolder[]) - entries.subList(0, limit).toArray(new RemoteEventHolder[0]); - RemoteEventData[] set = new RemoteEventData[evts.length]; - for (int i=0; i<set.length; i++) { - set[i] = new RemoteEventData( - evts[i].getRemoteEvent(), Long.valueOf(evts[i].getID())); - } - return set; - } - - // Inherit documentation from supertype - public boolean isEmpty() throws IOException { - stateCheck(); - return entries.isEmpty(); - } - - // Inherit documentation from supertype - public void remove() throws IOException { - stateCheck(); - try { - entries.remove(0); - } catch (IndexOutOfBoundsException iob) { - throw new NoSuchElementException(); - } - printControlData(persistenceLogger, "TransientEventLog::remove"); - } - - // Inherit documentation from supertype - public void moveAhead(Object cookie) throws IOException { - stateCheck(); - - if (cookie == null) return; - - if (persistenceLogger.isLoggable(Level.FINEST)) { - persistenceLogger.log(Level.FINEST, - "moveAhead past {0}", - cookie); - } - // TODO - trap ClassCastException and throw? - long lastID = ((Long)cookie).longValue(); - - if (lastID >= eventCounter.get()) { - throw new NoSuchElementException(); - } - - RemoteEventHolder rh = null; - ListIterator iter = entries.listIterator(); - while (iter.hasNext()) { - rh = (RemoteEventHolder)iter.next(); - if (rh.getID() <= lastID) { - iter.remove(); - if (persistenceLogger.isLoggable(Level.FINEST)) { - persistenceLogger.log(Level.FINEST, - "Removing event with ID {0}", - Long.valueOf(rh.getID())); - } - } else { - break; - } - - } - printControlData(persistenceLogger, "TransientEventLog::moveAhead"); - } - - // Inherit documentation from supertype - public void close() throws IOException { - stateCheck(); - closed = true; - if (persistenceLogger.isLoggable(Level.FINEST)) { - persistenceLogger.log(Level.FINEST, - "TransientEventLog::close for {0}", uuid); - } - // Do nothing - } - - // Inherit documentation from supertype - public void delete() throws IOException { - if (!closed) - throw new IOException("Cannot delete log until it is closed"); - entries.clear(); - if (persistenceLogger.isLoggable(Level.FINEST)) { - persistenceLogger.log(Level.FINEST, - "TransientEventLog::destroy for {0}", uuid); - } - } - - - /** - * Output state information to the given <tt>Logger</tt>. - * This is intended for debugging purposes only. - */ - private void printControlData(Logger logger, String msg) { - if (logger.isLoggable(Level.FINEST)) { - logger.log(Level.FINEST, "{0}", msg); - logger.log(Level.FINEST, "ID: {0}", uuid); - logger.log(Level.FINEST, "NumEvents: {0}", - Long.valueOf(entries.size())); - } - } -} +/* + * 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.river.mercury; + +import net.jini.id.Uuid; +import net.jini.core.event.RemoteEvent; +import org.apache.river.mercury.proxy.RemoteEventData; + +import java.io.IOException; + +import org.apache.river.logging.Levels; +import org.apache.river.mercury.proxy.InternalMailboxException; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.NoSuchElementException; +import java.util.concurrent.atomic.AtomicLong; + +/** + * Class that implements the interface for an <tt>EventLog</tt>. + * This class encapsulates the details of reading/writing events from/to + * some non-persistent mechanism. + * + * This class makes certain assumptions. First, the <tt>next</tt> and + * <tt>remove</tt> methods are intended to be called in pairs. If + * <tt>remove</tt> is not called, then subsequent calls to <tt>next</tt> + * will attempt to return the same object. Calling <tt>remove</tt> + * essentially advances the read pointer to the next object, if any. + * + * There is also an implicit assumption of external synchronization by the + * caller. That is, only one calling thread will be accessing the log at a time. + * + * @author Sun Microsystems, Inc. + * + * @since 2.0 + */ + +class TransientEventLog implements EventLog { + + // + // Class fields + // + + /** <tt>Logger</tt> used for persistence-related debugging messages */ + private static final Logger persistenceLogger = + MailboxImpl.PERSISTENCE_LOGGER; + + // + // Object fields + // + + /** The associated <tt>Uuid</tt> for this <tt>EventLog</tt>. */ + private final Uuid uuid; + + /** The associated, non-persistent storage for events */ + private final List entries; + + /** + * Flag that is used to determine whether or not this object + * has been closed. + */ + private volatile boolean closed = false; + + /** + * Flag that is used to determine whether or not this object + * has been initialized. + */ + private volatile boolean initialized = false; + + /** + * Helper class used to hold a remote event and a sequence id. + */ + private static class RemoteEventHolder { + private final long id; + private final RemoteEvent remoteEvent; + RemoteEventHolder(long stamp, RemoteEvent re) { + id = stamp; + remoteEvent = re; + } + long getID() { return id; } + RemoteEvent getRemoteEvent() { return remoteEvent; } + } + + /** + * Counter used to produce event ids. + */ + private AtomicLong eventCounter = new AtomicLong(1); + + /** + * Simple constructor that takes a <tt>Uuid</tt> argument. + * + * @exception IllegalArgumentException if the argument is null + */ + TransientEventLog(Uuid uuid) { + if (uuid == null) + throw new IllegalArgumentException("Uuid cannot be null"); + this.uuid = uuid; + entries = Collections.synchronizedList(new LinkedList()); + + if (persistenceLogger.isLoggable(Level.FINEST)) { + persistenceLogger.log(Level.FINEST, + "TransientEventLog for: {0}", uuid); + } + } + + // Inherit documentation from supertype + public void init() throws IOException { + if (initialized) + throw new InternalMailboxException( + "Trying to re-initialize event log " + + "for: " + uuid); + initialized = true; + } + + /** + * Asserts that the log is in a valid state. + * + * @exception IOException if the log is in an invalid state + */ + private void stateCheck() throws IOException { + if (!initialized) + throw new IOException("Trying to use an uninitialized " + + "event log for: " + uuid); + if (closed) + throw new IOException("Attempt to access closed log file for : " + + uuid); + } + + // Inherit documentation from supertype + public void add(RemoteEvent event) throws IOException { + stateCheck(); + long id = eventCounter.getAndIncrement(); + RemoteEventHolder data = new RemoteEventHolder(id, event); + entries.add(data); + printControlData(persistenceLogger, "TransientEventLog::add"); + } + + // Inherit documentation from supertype + public RemoteEvent next() throws IOException { + stateCheck(); + // Check if empty + if (isEmpty()) + throw new NoSuchElementException(); + + printControlData(persistenceLogger, "TransientEventLog::next"); + RemoteEventHolder data = (RemoteEventHolder)entries.get(0); + return (RemoteEvent)data.getRemoteEvent(); + } + + // Inherit documentation from supertype + public RemoteEventData[] readAhead(int maxEvents) throws IOException { + stateCheck(); + + if (maxEvents < 0) + throw new IllegalArgumentException(); + + if (maxEvents == 0) + return new RemoteEventData[0]; + + // Check if empty + if (isEmpty()) + throw new NoSuchElementException(); + + printControlData(persistenceLogger, "TransientEventLog::readAhead"); + int limit = (maxEvents < entries.size())?maxEvents:entries.size(); + RemoteEventHolder[] evts = (RemoteEventHolder[]) + entries.subList(0, limit).toArray(new RemoteEventHolder[0]); + RemoteEventData[] set = new RemoteEventData[evts.length]; + for (int i=0; i<set.length; i++) { + set[i] = new RemoteEventData( + evts[i].getRemoteEvent(), Long.valueOf(evts[i].getID())); + } + return set; + } + + // Inherit documentation from supertype + public boolean isEmpty() throws IOException { + stateCheck(); + return entries.isEmpty(); + } + + // Inherit documentation from supertype + public void remove() throws IOException { + stateCheck(); + try { + entries.remove(0); + } catch (IndexOutOfBoundsException iob) { + throw new NoSuchElementException(); + } + printControlData(persistenceLogger, "TransientEventLog::remove"); + } + + // Inherit documentation from supertype + public void moveAhead(Object cookie) throws IOException { + stateCheck(); + + if (cookie == null) return; + + if (persistenceLogger.isLoggable(Level.FINEST)) { + persistenceLogger.log(Level.FINEST, + "moveAhead past {0}", + cookie); + } + // TODO - trap ClassCastException and throw? + long lastID = ((Long)cookie).longValue(); + + if (lastID >= eventCounter.get()) { + throw new NoSuchElementException(); + } + + RemoteEventHolder rh = null; + ListIterator iter = entries.listIterator(); + while (iter.hasNext()) { + rh = (RemoteEventHolder)iter.next(); + if (rh.getID() <= lastID) { + iter.remove(); + if (persistenceLogger.isLoggable(Level.FINEST)) { + persistenceLogger.log(Level.FINEST, + "Removing event with ID {0}", + Long.valueOf(rh.getID())); + } + } else { + break; + } + + } + printControlData(persistenceLogger, "TransientEventLog::moveAhead"); + } + + // Inherit documentation from supertype + public void close() throws IOException { + stateCheck(); + closed = true; + if (persistenceLogger.isLoggable(Level.FINEST)) { + persistenceLogger.log(Level.FINEST, + "TransientEventLog::close for {0}", uuid); + } + // Do nothing + } + + // Inherit documentation from supertype + public void delete() throws IOException { + if (!closed) + throw new IOException("Cannot delete log until it is closed"); + entries.clear(); + if (persistenceLogger.isLoggable(Level.FINEST)) { + persistenceLogger.log(Level.FINEST, + "TransientEventLog::destroy for {0}", uuid); + } + } + + + /** + * Output state information to the given <tt>Logger</tt>. + * This is intended for debugging purposes only. + */ + private void printControlData(Logger logger, String msg) { + if (logger.isLoggable(Level.FINEST)) { + logger.log(Level.FINEST, "{0}", msg); + logger.log(Level.FINEST, "ID: {0}", uuid); + logger.log(Level.FINEST, "NumEvents: {0}", + Long.valueOf(entries.size())); + } + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/TransientMercuryImpl.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/TransientMercuryImpl.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/TransientMercuryImpl.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-service/src/main/java/org/apache/river/mercury/TransientMercuryImpl.java Sun Jul 5 11:41:39 2020 @@ -1,56 +1,56 @@ -/* - * 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.river.mercury; - -import org.apache.river.start.LifeCycle; - -/** - * Convenience class intended for use with the - * {@link org.apache.river.start.ServiceStarter} framework to start - * a <i>transient</i> (non-activatable, non-persistent) implementation - * of Mercury. - * - * @author Sun Microsystems, Inc. - * @since 2.0 - */ -class TransientMercuryImpl extends MailboxImpl { - - /** - * Constructs a new instance of <code>MercuryImpl</code> that is not - * activatable, and which will not persist its state. - * - * @param configArgs <code>String</code> array whose elements are - * the arguments to use when creating the server. - * @param lifeCycle instance of <code>LifeCycle</code> that, if - * non-<code>null</code>, will cause this object's - * <code>unregister</code> method to be invoked during - * shutdown to notify the service starter framework that - * the reference to this service's implementation can be - * 'released' for garbage collection. A value of - * <code>null</code> for this argument is allowed. - * - * @throws Exception If there was a problem initializing the service. - */ - TransientMercuryImpl(String[] configArgs, LifeCycle lifeCycle) - throws Exception - { - super(configArgs, lifeCycle, false);//false ==> not persistent - }//end constructor - -}//end class TransientMercuryImpl - +/* + * 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.river.mercury; + +import org.apache.river.start.lifecycle.LifeCycle; + +/** + * Convenience class intended for use with the + * {@link org.apache.river.start.ServiceStarter} framework to start + * a <i>transient</i> (non-activatable, non-persistent) implementation + * of Mercury. + * + * @author Sun Microsystems, Inc. + * @since 2.0 + */ +class TransientMercuryImpl extends MailboxImpl { + + /** + * Constructs a new instance of <code>MercuryImpl</code> that is not + * activatable, and which will not persist its state. + * + * @param configArgs <code>String</code> array whose elements are + * the arguments to use when creating the server. + * @param lifeCycle instance of <code>LifeCycle</code> that, if + * non-<code>null</code>, will cause this object's + * <code>unregister</code> method to be invoked during + * shutdown to notify the service starter framework that + * the reference to this service's implementation can be + * 'released' for garbage collection. A value of + * <code>null</code> for this argument is allowed. + * + * @throws Exception If there was a problem initializing the service. + */ + TransientMercuryImpl(String[] configArgs, LifeCycle lifeCycle) + throws Exception + { + super(configArgs, lifeCycle, false);//false ==> not persistent + }//end constructor + +}//end class TransientMercuryImpl + Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/AbstractProxy.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/AbstractProxy.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/AbstractProxy.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/AbstractProxy.java Sun Jul 5 11:41:39 2020 @@ -1,97 +1,97 @@ -/* - * 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.river.norm; - -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectInputStream; -import java.io.Serializable; -import net.jini.id.ReferentUuid; -import net.jini.id.ReferentUuids; -import net.jini.id.Uuid; - -/** - * Defines an abstract class that supplies basic referent UUID and - * serialization behavior for Norm proxies. - * - * @author Sun Microsystems, Inc. - * @since 2.0 - */ -abstract class AbstractProxy implements ReferentUuid, Serializable { - private static final long serialVersionUID = 1; - - /** - * The server. - * - * @serial - */ - final NormServer server; - - /** - * The unique identifier for this proxy. - * - * @serial - */ - final Uuid uuid; - - /** Creates an instance of this class. */ - AbstractProxy(NormServer server, Uuid uuid) { - if (server == null) { - throw new NullPointerException("server cannot be null"); - } else if (uuid == null) { - throw new NullPointerException("uuid cannot be null"); - } - this.server = server; - this.uuid = uuid; - } - - /** Require fields to be non-null. */ - private void readObjectNoData() throws InvalidObjectException { - throw new InvalidObjectException( - "server and uuid must be non-null"); - } - - /** Require fields to be non-null. */ - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - if (server == null || uuid == null) { - throw new InvalidObjectException( - "server and uuid must be non-null"); - } - } - - /** Returns true if the object has the same UUID as this instance. */ - public boolean equals(Object object) { - return ReferentUuids.compare(this, object); - } - - /** Returns a hash code for this object. */ - public int hashCode() { - return uuid.hashCode(); - } - - /* -- Implement ReferentUuid -- */ - - /* inherit javadoc */ - public Uuid getReferentUuid() { - return uuid; - } -} +/* + * 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.river.norm.proxy; + +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; +import java.io.Serializable; +import net.jini.id.ReferentUuid; +import net.jini.id.ReferentUuids; +import net.jini.id.Uuid; + +/** + * Defines an abstract class that supplies basic referent UUID and + * serialization behavior for Norm proxies. + * + * @author Sun Microsystems, Inc. + * @since 2.0 + */ +abstract class AbstractProxy implements ReferentUuid, Serializable { + private static final long serialVersionUID = 1; + + /** + * The server. + * + * @serial + */ + final NormServer server; + + /** + * The unique identifier for this proxy. + * + * @serial + */ + final Uuid uuid; + + /** Creates an instance of this class. */ + AbstractProxy(NormServer server, Uuid uuid) { + if (server == null) { + throw new NullPointerException("server cannot be null"); + } else if (uuid == null) { + throw new NullPointerException("uuid cannot be null"); + } + this.server = server; + this.uuid = uuid; + } + + /** Require fields to be non-null. */ + private void readObjectNoData() throws InvalidObjectException { + throw new InvalidObjectException( + "server and uuid must be non-null"); + } + + /** Require fields to be non-null. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + in.defaultReadObject(); + if (server == null || uuid == null) { + throw new InvalidObjectException( + "server and uuid must be non-null"); + } + } + + /** Returns true if the object has the same UUID as this instance. */ + public boolean equals(Object object) { + return ReferentUuids.compare(this, object); + } + + /** Returns a hash code for this object. */ + public int hashCode() { + return uuid.hashCode(); + } + + /* -- Implement ReferentUuid -- */ + + /* inherit javadoc */ + public Uuid getReferentUuid() { + return uuid; + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/AdminProxy.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/AdminProxy.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/AdminProxy.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/AdminProxy.java Sun Jul 5 11:41:39 2020 @@ -1,186 +1,186 @@ -/* - * 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.river.norm; - -import org.apache.river.admin.DestroyAdmin; -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectInputStream; -import java.rmi.RemoteException; -import net.jini.admin.JoinAdmin; -import net.jini.core.constraint.MethodConstraints; -import net.jini.core.constraint.RemoteMethodControl; -import net.jini.core.discovery.LookupLocator; -import net.jini.core.entry.Entry; -import net.jini.id.Uuid; -import net.jini.security.proxytrust.ProxyTrustIterator; -import net.jini.security.proxytrust.SingletonProxyTrustIterator; - -/** - * Defines a proxy for a Norm server's admin object. - * - * @author Sun Microsystems, Inc. - * @since 2.0 - */ -class AdminProxy extends AbstractProxy implements JoinAdmin, DestroyAdmin { - private static final long serialVersionUID = 1; - - /** - * Creates an admin proxy, returning an instance that implements - * RemoteMethodControl if the server does. - */ - static AdminProxy create(NormServer server, Uuid serverUuid) { - if (server instanceof RemoteMethodControl) { - return new ConstrainableAdminProxy(server, serverUuid); - } else { - return new AdminProxy(server, serverUuid); - } - } - - /** Creates an instance of this class. */ - AdminProxy(NormServer server, Uuid serverUuid) { - super(server, serverUuid); - } - - /** Require fields to be non-null. */ - private void readObjectNoData() throws InvalidObjectException { - throw new InvalidObjectException( - "server and uuid must be non-null"); - } - - /* -- Implement JoinAdmin -- */ - - /* inherit javadoc */ - public Entry[] getLookupAttributes() throws RemoteException { - return server.getLookupAttributes(); - } - - /* inherit javadoc */ - public void addLookupAttributes(Entry[] attrSets) throws RemoteException { - server.addLookupAttributes(attrSets); - } - - /* inherit javadoc */ - public void modifyLookupAttributes(Entry[] attrSetTemplates, - Entry[] attrSets) - throws RemoteException - { - server.modifyLookupAttributes(attrSetTemplates, attrSets); - } - - /* inherit javadoc */ - public String[] getLookupGroups() throws RemoteException { - return server.getLookupGroups(); - } - - /* inherit javadoc */ - public void addLookupGroups(String[] groups) throws RemoteException { - server.addLookupGroups(groups); - } - - /* inherit javadoc */ - public void removeLookupGroups(String[] groups) throws RemoteException { - server.removeLookupGroups(groups); - } - - /* inherit javadoc */ - public void setLookupGroups(String[] groups) throws RemoteException { - server.setLookupGroups(groups); - } - - /* inherit javadoc */ - public LookupLocator[] getLookupLocators() throws RemoteException { - return server.getLookupLocators(); - } - - /* inherit javadoc */ - public void addLookupLocators(LookupLocator[] locators) - throws RemoteException - { - server.addLookupLocators(locators); - } - - /* inherit javadoc */ - public void removeLookupLocators(LookupLocator[] locators) - throws RemoteException - { - server.removeLookupLocators(locators); - } - - /* inherit javadoc */ - public void setLookupLocators(LookupLocator[] locators) - throws RemoteException - { - server.setLookupLocators(locators); - } - - /* -- Implement DestroyAdmin -- */ - - /* inherit javadoc */ - public void destroy() throws RemoteException { - server.destroy(); - } - - /** Defines a subclass that implements RemoteMethodControl. */ - static final class ConstrainableAdminProxy extends AdminProxy - implements RemoteMethodControl - { - private static final long serialVersionUID = 1; - - /** Creates an instance of this class. */ - ConstrainableAdminProxy(NormServer server, Uuid serverUuid) { - super(server, serverUuid); - if (!(server instanceof RemoteMethodControl)) { - throw new IllegalArgumentException( - "server must implement RemoteMethodControl"); - } - } - - /** Require server to implement RemoteMethodControl. */ - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - if (!(server instanceof RemoteMethodControl)) { - throw new InvalidObjectException( - "server must implement RemoteMethodControl"); - } - } - - /* inherit javadoc */ - public RemoteMethodControl setConstraints( - MethodConstraints constraints) - { - NormServer constrainedServer = (NormServer) - ((RemoteMethodControl) server).setConstraints(constraints); - return new ConstrainableAdminProxy(constrainedServer, uuid); - } - - /* inherit javadoc */ - public MethodConstraints getConstraints() { - return ((RemoteMethodControl) server).getConstraints(); - } - - /** - * Returns a proxy trust iterator that yields this object's server. - */ - private ProxyTrustIterator getProxyTrustIterator() { - return new SingletonProxyTrustIterator(server); - } - } -} +/* + * 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.river.norm.proxy; + +import org.apache.river.admin.DestroyAdmin; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; +import java.rmi.RemoteException; +import net.jini.admin.JoinAdmin; +import net.jini.core.constraint.MethodConstraints; +import net.jini.core.constraint.RemoteMethodControl; +import net.jini.core.discovery.LookupLocator; +import net.jini.core.entry.Entry; +import net.jini.id.Uuid; +import net.jini.security.proxytrust.ProxyTrustIterator; +import net.jini.security.proxytrust.SingletonProxyTrustIterator; + +/** + * Defines a proxy for a Norm server's admin object. + * + * @author Sun Microsystems, Inc. + * @since 2.0 + */ +public class AdminProxy extends AbstractProxy implements JoinAdmin, DestroyAdmin { + private static final long serialVersionUID = 1; + + /** + * Creates an admin proxy, returning an instance that implements + * RemoteMethodControl if the server does. + */ + public static AdminProxy create(NormServer server, Uuid serverUuid) { + if (server instanceof RemoteMethodControl) { + return new ConstrainableAdminProxy(server, serverUuid); + } else { + return new AdminProxy(server, serverUuid); + } + } + + /** Creates an instance of this class. */ + AdminProxy(NormServer server, Uuid serverUuid) { + super(server, serverUuid); + } + + /** Require fields to be non-null. */ + private void readObjectNoData() throws InvalidObjectException { + throw new InvalidObjectException( + "server and uuid must be non-null"); + } + + /* -- Implement JoinAdmin -- */ + + /* inherit javadoc */ + public Entry[] getLookupAttributes() throws RemoteException { + return server.getLookupAttributes(); + } + + /* inherit javadoc */ + public void addLookupAttributes(Entry[] attrSets) throws RemoteException { + server.addLookupAttributes(attrSets); + } + + /* inherit javadoc */ + public void modifyLookupAttributes(Entry[] attrSetTemplates, + Entry[] attrSets) + throws RemoteException + { + server.modifyLookupAttributes(attrSetTemplates, attrSets); + } + + /* inherit javadoc */ + public String[] getLookupGroups() throws RemoteException { + return server.getLookupGroups(); + } + + /* inherit javadoc */ + public void addLookupGroups(String[] groups) throws RemoteException { + server.addLookupGroups(groups); + } + + /* inherit javadoc */ + public void removeLookupGroups(String[] groups) throws RemoteException { + server.removeLookupGroups(groups); + } + + /* inherit javadoc */ + public void setLookupGroups(String[] groups) throws RemoteException { + server.setLookupGroups(groups); + } + + /* inherit javadoc */ + public LookupLocator[] getLookupLocators() throws RemoteException { + return server.getLookupLocators(); + } + + /* inherit javadoc */ + public void addLookupLocators(LookupLocator[] locators) + throws RemoteException + { + server.addLookupLocators(locators); + } + + /* inherit javadoc */ + public void removeLookupLocators(LookupLocator[] locators) + throws RemoteException + { + server.removeLookupLocators(locators); + } + + /* inherit javadoc */ + public void setLookupLocators(LookupLocator[] locators) + throws RemoteException + { + server.setLookupLocators(locators); + } + + /* -- Implement DestroyAdmin -- */ + + /* inherit javadoc */ + public void destroy() throws RemoteException { + server.destroy(); + } + + /** Defines a subclass that implements RemoteMethodControl. */ + static final class ConstrainableAdminProxy extends AdminProxy + implements RemoteMethodControl + { + private static final long serialVersionUID = 1; + + /** Creates an instance of this class. */ + ConstrainableAdminProxy(NormServer server, Uuid serverUuid) { + super(server, serverUuid); + if (!(server instanceof RemoteMethodControl)) { + throw new IllegalArgumentException( + "server must implement RemoteMethodControl"); + } + } + + /** Require server to implement RemoteMethodControl. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + in.defaultReadObject(); + if (!(server instanceof RemoteMethodControl)) { + throw new InvalidObjectException( + "server must implement RemoteMethodControl"); + } + } + + /* inherit javadoc */ + public RemoteMethodControl setConstraints( + MethodConstraints constraints) + { + NormServer constrainedServer = (NormServer) + ((RemoteMethodControl) server).setConstraints(constraints); + return new ConstrainableAdminProxy(constrainedServer, uuid); + } + + /* inherit javadoc */ + public MethodConstraints getConstraints() { + return ((RemoteMethodControl) server).getConstraints(); + } + + /** + * Returns a proxy trust iterator that yields this object's server. + */ + private ProxyTrustIterator getProxyTrustIterator() { + return new SingletonProxyTrustIterator(server); + } + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/CorruptedStoreException.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/CorruptedStoreException.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/CorruptedStoreException.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/CorruptedStoreException.java Sun Jul 5 11:41:39 2020 @@ -1,48 +1,48 @@ -/* - * 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.river.norm; - -/** - * Exception thrown by <code>PersistentStore</code> when it discovers - * the store has become corrupted. - * - * @author Sun Microsystems, Inc. - * - */ -class CorruptedStoreException extends StoreException { - private static final long serialVersionUID = 1L; - - /** - * Constructs an <code>CorruptedStoreException</code> with a detail - * message. - * @param s the detailed message - */ - CorruptedStoreException(String s) { - super(s); - } - - /** - * Constructs an <code>CorruptedStoreException</code> with a detail - * message and a nested exception. - * @param s the detailed message - * @param t root cause for exception, may be <code>null</code> - */ - CorruptedStoreException(String s, Throwable t) { - super(s, t); - } -} +/* + * 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.river.norm.proxy; + +/** + * Exception thrown by <code>PersistentStore</code> when it discovers + * the store has become corrupted. + * + * @author Sun Microsystems, Inc. + * + */ +public class CorruptedStoreException extends StoreException { + private static final long serialVersionUID = 1L; + + /** + * Constructs an <code>CorruptedStoreException</code> with a detail + * message. + * @param s the detailed message + */ + public CorruptedStoreException(String s) { + super(s); + } + + /** + * Constructs an <code>CorruptedStoreException</code> with a detail + * message and a nested exception. + * @param s the detailed message + * @param t root cause for exception, may be <code>null</code> + */ + public CorruptedStoreException(String s, Throwable t) { + super(s, t); + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/GetLeasesResult.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/GetLeasesResult.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/GetLeasesResult.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/GetLeasesResult.java Sun Jul 5 11:41:39 2020 @@ -1,74 +1,74 @@ -/* - * 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.river.norm; - -import org.apache.river.proxy.MarshalledWrapper; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectStreamField; -import java.io.Serializable; -import net.jini.io.MarshalledInstance; - -/** - * Holds the results of a call to {@link NormServer#getLeases - * NormServer.getLeases}. - */ -final class GetLeasesResult implements Serializable { - private static final long serialVersionUID = 1; - - /** - * @serialField marshalledLeases MarshalledInstance[] The marshalled - * leases. - */ - private static final ObjectStreamField[] serialPersistentFields = { - /* Make sure the marshalled leases array is not shared */ - new ObjectStreamField( - "marshalledLeases", MarshalledInstance[].class, true) - }; - - /** Whether to verify codebase integrity. */ - private transient boolean verifyCodebaseIntegrity; - - /** The marshalled leases. */ - final MarshalledInstance[] marshalledLeases; - - /** - * Creates an object that holds the results of a call to {@link NormServerBaseImpl#getLeases - * getLeases}. - * - * @param marshalledLeases the leases being returned by the call - */ - GetLeasesResult(MarshalledInstance[] marshalledLeases) { - this.marshalledLeases = marshalledLeases; - } - - /** - * Returns whether to verify codebase integrity when unmarshalling leases. - */ - boolean verifyCodebaseIntegrity() { - return verifyCodebaseIntegrity; - } - - /* Set transient fields. */ - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - verifyCodebaseIntegrity = MarshalledWrapper.integrityEnforced(in); - } -} +/* + * 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.river.norm.proxy; + +import org.apache.river.proxy.MarshalledWrapper; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectStreamField; +import java.io.Serializable; +import net.jini.io.MarshalledInstance; + +/** + * Holds the results of a call to {@link NormServer#getLeases + * NormServer.getLeases}. + */ +public final class GetLeasesResult implements Serializable { + private static final long serialVersionUID = 1; + + /** + * @serialField marshalledLeases MarshalledInstance[] The marshalled + * leases. + */ + private static final ObjectStreamField[] serialPersistentFields = { + /* Make sure the marshalled leases array is not shared */ + new ObjectStreamField( + "marshalledLeases", MarshalledInstance[].class, true) + }; + + /** Whether to verify codebase integrity. */ + private transient boolean verifyCodebaseIntegrity; + + /** The marshalled leases. */ + final MarshalledInstance[] marshalledLeases; + + /** + * Creates an object that holds the results of a call to {@link NormServerBaseImpl#getLeases + * getLeases}. + * + * @param marshalledLeases the leases being returned by the call + */ + public GetLeasesResult(MarshalledInstance[] marshalledLeases) { + this.marshalledLeases = marshalledLeases; + } + + /** + * Returns whether to verify codebase integrity when unmarshalling leases. + */ + boolean verifyCodebaseIntegrity() { + return verifyCodebaseIntegrity; + } + + /* Set transient fields. */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + in.defaultReadObject(); + verifyCodebaseIntegrity = MarshalledWrapper.integrityEnforced(in); + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/InternalNormException.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/InternalNormException.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/InternalNormException.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/InternalNormException.java Sun Jul 5 11:41:39 2020 @@ -1,95 +1,95 @@ -/* - * 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.river.norm; - -import java.io.PrintStream; -import java.io.PrintWriter; - -/** - * This exception denotes a problem with the local implementation of a - * Norm server. The <code>detail</code> field will give a description - * that can be reported to Norm's developer (and may be documented - * in that Norm's documentation). - * - * @author Sun Microsystems, Inc. - */ -public class InternalNormException extends RuntimeException { - private static final long serialVersionUID = 1L; - - /** - * The exception (if any) that triggered the internal exception. This - * may be <code>null</code>. - * - * @serial - */ - public final Throwable nestedException; - - /** - * Create an exception, forwarding a string to the superclass constructor. - * - * @param str the detail message - */ - public InternalNormException(String str) { - super(str); - nestedException = null; - } - - /** - * Create an exception, forwarding a string and exception to the - * superclass constructor. - * - * @param str the detail message - * @param ex the cause - */ - public InternalNormException(String str, Throwable ex) { - super(str); - nestedException = ex; - } - - /** - * Print the stack trace of this exception, plus that of the nested - * exception, if any. - */ - public void printStackTrace() { - printStackTrace(System.err); - } - - /** - * Print the stack trace of this exception, plus that of the nested - * exception, if any. - */ - public void printStackTrace(PrintStream out) { - super.printStackTrace(out); - if (nestedException != null) { - out.println("nested exception:"); - nestedException.printStackTrace(out); - } - } - - /** - * Print the stack trace of this exception, plus that of the nested - * exception, if any. - */ - public void printStackTrace(PrintWriter out) { - super.printStackTrace(out); - if (nestedException != null) { - out.println("nested exception:"); - nestedException.printStackTrace(out); - } - } -} +/* + * 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.river.norm.proxy; + +import java.io.PrintStream; +import java.io.PrintWriter; + +/** + * This exception denotes a problem with the local implementation of a + * Norm server. The <code>detail</code> field will give a description + * that can be reported to Norm's developer (and may be documented + * in that Norm's documentation). + * + * @author Sun Microsystems, Inc. + */ +public class InternalNormException extends RuntimeException { + private static final long serialVersionUID = 1L; + + /** + * The exception (if any) that triggered the internal exception. This + * may be <code>null</code>. + * + * @serial + */ + public final Throwable nestedException; + + /** + * Create an exception, forwarding a string to the superclass constructor. + * + * @param str the detail message + */ + public InternalNormException(String str) { + super(str); + nestedException = null; + } + + /** + * Create an exception, forwarding a string and exception to the + * superclass constructor. + * + * @param str the detail message + * @param ex the cause + */ + public InternalNormException(String str, Throwable ex) { + super(str); + nestedException = ex; + } + + /** + * Print the stack trace of this exception, plus that of the nested + * exception, if any. + */ + public void printStackTrace() { + printStackTrace(System.err); + } + + /** + * Print the stack trace of this exception, plus that of the nested + * exception, if any. + */ + public void printStackTrace(PrintStream out) { + super.printStackTrace(out); + if (nestedException != null) { + out.println("nested exception:"); + nestedException.printStackTrace(out); + } + } + + /** + * Print the stack trace of this exception, plus that of the nested + * exception, if any. + */ + public void printStackTrace(PrintWriter out) { + super.printStackTrace(out); + if (nestedException != null) { + out.println("nested exception:"); + nestedException.printStackTrace(out); + } + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormPermission.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormPermission.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormPermission.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormPermission.java Sun Jul 5 11:41:39 2020 @@ -1,65 +1,65 @@ -/* - * 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.river.norm; - -import org.apache.river.admin.DestroyAdmin; -import net.jini.admin.Administrable; -import net.jini.admin.JoinAdmin; -import net.jini.core.lease.Lease; -import net.jini.core.lease.LeaseMap; -import net.jini.jeri.BasicInvocationDispatcher; -import net.jini.jeri.BasicJeriExporter; -import net.jini.lease.LeaseRenewalService; -import net.jini.lease.LeaseRenewalSet; -import net.jini.security.AccessPermission; - -/** - * Represents permissions that can be used to express the access control policy - * for the a Norm server exported with a {@link BasicJeriExporter}. This class - * can be passed to {@link BasicInvocationDispatcher}, and then used in - * security policy permission grants. <p> - * - * An instance contains a name (also referred to as a "target name") but no - * actions list; you either have the named permission or you don't. The - * convention is that the target name is the non-qualified name of the remote - * method being invoked. Wildcard matches are supported using the syntax - * specified by {@link AccessPermission}. <p> - * - * The possible target names for use with a Norm server are specified in the - * package documentation for {@link org.apache.river.norm}. - * - * @author Sun Microsystems, Inc. - * @since 2.0 - */ -public class NormPermission extends AccessPermission { - private static final long serialVersionUID = 1; - - /** - * Creates an instance with the specified target name. - * - * @param name the target name - * @throws NullPointerException if the target name is <code>null</code> - * @throws IllegalArgumentException if the target name does not match - * the syntax specified in the comments at the beginning of the {@link - * AccessPermission} class - */ - public NormPermission(String name) { - super(name); - } -} +/* + * 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.river.norm.proxy; + +import org.apache.river.admin.DestroyAdmin; +import net.jini.admin.Administrable; +import net.jini.admin.JoinAdmin; +import net.jini.core.lease.Lease; +import net.jini.core.lease.LeaseMap; +import net.jini.jeri.BasicInvocationDispatcher; +import net.jini.jeri.BasicJeriExporter; +import net.jini.lease.LeaseRenewalService; +import net.jini.lease.LeaseRenewalSet; +import net.jini.security.AccessPermission; + +/** + * Represents permissions that can be used to express the access control policy + * for the a Norm server exported with a {@link BasicJeriExporter}. This class + * can be passed to {@link BasicInvocationDispatcher}, and then used in + * security policy permission grants. <p> + * + * An instance contains a name (also referred to as a "target name") but no + * actions list; you either have the named permission or you don't. The + * convention is that the target name is the non-qualified name of the remote + * method being invoked. Wildcard matches are supported using the syntax + * specified by {@link AccessPermission}. <p> + * + * The possible target names for use with a Norm server are specified in the + * package documentation for {@link org.apache.river.norm}. + * + * @author Sun Microsystems, Inc. + * @since 2.0 + */ +public class NormPermission extends AccessPermission { + private static final long serialVersionUID = 1; + + /** + * Creates an instance with the specified target name. + * + * @param name the target name + * @throws NullPointerException if the target name is <code>null</code> + * @throws IllegalArgumentException if the target name does not match + * the syntax specified in the comments at the beginning of the {@link + * AccessPermission} class + */ + public NormPermission(String name) { + super(name); + } +}
