diff options
Diffstat (limited to 'plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal')
26 files changed, 0 insertions, 2079 deletions
diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/Server.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/Server.java deleted file mode 100644 index 0312925849..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/Server.java +++ /dev/null @@ -1,233 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server; - -import org.eclipse.net4j.internal.jms.ConnectionFactoryImpl; -import org.eclipse.net4j.internal.jms.JMSDestination; -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.util.lifecycle.QueueWorker; -import org.eclipse.net4j.jms.internal.server.bundle.OM; -import org.eclipse.net4j.jms.server.IDestination; -import org.eclipse.net4j.jms.server.IServer; -import org.eclipse.net4j.jms.server.IStore; -import org.eclipse.net4j.jms.server.IStoreTransaction; -import org.eclipse.net4j.util.HexUtil; -import org.eclipse.net4j.util.concurrent.NonBlockingLongCounter; - -import javax.jms.Destination; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * @author Eike Stepper - */ -public class Server extends QueueWorker<MessageImpl> implements IServer -{ - public static final Server INSTANCE = new Server(); - - private static final boolean REBIND_DESTINATIONS = true; - - private NonBlockingLongCounter messageIDCounter = new NonBlockingLongCounter(); - - private NonBlockingLongCounter consumerIDCounter = new NonBlockingLongCounter(); - - private IStore store = null; - - private Context jndiContext; - - private ConcurrentMap<String, ServerDestination> destinations = new ConcurrentHashMap<String, ServerDestination>(); - - private Set<ServerConnection> connections = new HashSet<ServerConnection>(); - - private ConcurrentMap<Long, ServerConsumer> consumers = new ConcurrentHashMap<Long, ServerConsumer>(); - - public Server() - { - } - - public IStore getStore() - { - return store; - } - - public void setStore(IStore store) - { - this.store = store; - } - - public IDestination createDestination(String name, IDestination.Type type) - { - ServerDestination destination = new ServerDestination(name, type); - ServerDestination existing = destinations.putIfAbsent(name, destination); - if (existing != null) - { - throw new IllegalStateException("Destination " + type + " " + name + " does already exist"); - } - - IStoreTransaction transaction = store.startTransaction(); - transaction.destinationAdded(destination); - store.commitTransaction(transaction); - - try - { - destination.bind(jndiContext, REBIND_DESTINATIONS); - } - catch (NamingException ex) - { - OM.LOG.error(ex); - destinations.remove(name); - destination = null; - } - - return destination; - } - - public ServerDestination getDestination(String name) - { - return destinations.get(name); - } - - public ServerDestination getServerDestination(Destination jmsDestination) - { - String name = ((JMSDestination)jmsDestination).getName(); - ServerDestination destination = destinations.get(name); - if (destination == null) - { - OM.LOG.error("Invalid destination: " + name); - return null; - } - - return destination; - } - - public ServerConnection logon(String userName, String password) - { - ServerConnection connection = new ServerConnection(this, userName); - synchronized (connections) - { - connections.add(connection); - } - - return connection; - } - - public ServerConsumer createConsumer(ServerDestination destination, String messageSelector, boolean noLocal, - boolean durable) - { - long consumerID = consumerIDCounter.increment(); - ServerConsumer consumer = new ServerConsumer(consumerID, destination, messageSelector, noLocal, durable); - consumers.put(consumer.getID(), consumer); - return consumer; - } - - public ServerConsumer getConsumer(long consumerID) - { - return consumers.get(consumerID); - } - - public String[] handleClientMessages(MessageImpl[] messages) - { - IStoreTransaction transaction = store.startTransaction(); - String[] messageIDs = handleClientMessagesInTransaction(transaction, messages); - store.commitTransaction(transaction); - return messageIDs; - } - - public String[] handleClientMessagesInTransaction(IStoreTransaction transaction, MessageImpl[] messages) - { - String[] messageIDs = new String[messages.length]; - for (int i = 0; i < messages.length; i++) - { - MessageImpl message = messages[i]; - if (getServerDestination(message.getJMSDestination()) == null) - { - return null; - } - - messageIDs[i] = "ID:NET4J:" + HexUtil.longToHex(messageIDCounter.increment()); - message.setJMSMessageID(messageIDs[i]); - } - - for (MessageImpl message : messages) - { - transaction.messageReceived(message); - addWork(message); - } - - return messageIDs; - } - - @Override - protected String getThreadName() - { - return "jms-server"; - } - - @Override - protected void work(WorkContext context, MessageImpl message) - { - ServerDestination destination = getServerDestination(message.getJMSDestination()); - IStoreTransaction transaction = store.startTransaction(); - destination.handleClientMessage(transaction, message); - store.commitTransaction(transaction); - } - - @Override - protected void doBeforeActivate() throws Exception - { - super.doBeforeActivate(); - if (store == null) - { - throw new IllegalStateException("store == null"); - } - } - - @Override - protected void doActivate() throws Exception - { - super.doActivate(); - String name = System.getProperty("net4j.jms.connection.factory.name", "net4j.jms.ConnectionFactory"); - String type = System.getProperty("net4j.jms.connector.type", "tcp"); - String desc = System.getProperty("net4j.jms.connector.description", "localhost"); - - jndiContext = new InitialContext(); - jndiContext.rebind(name, new ConnectionFactoryImpl(type, desc)); - } - - @Override - protected void doDeactivate() throws Exception - { - synchronized (connections) - { - for (ServerConnection connection : connections) - { - try - { - connection.close(); - } - catch (Exception ex) - { - OM.LOG.error(ex); - } - } - } - - jndiContext.close(); - jndiContext = null; - super.doDeactivate(); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConnection.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConnection.java deleted file mode 100644 index e7e26647e7..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConnection.java +++ /dev/null @@ -1,115 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server; - -import org.eclipse.net4j.jms.internal.server.protocol.JMSServerProtocol; -import org.eclipse.net4j.jms.server.IConnection; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class ServerConnection implements IConnection -{ - private Server server; - - private String userName; - - private List<ServerSession> sessions = new ArrayList<ServerSession>(0); - - private JMSServerProtocol protocol; - - public ServerConnection(Server server, String userName) - { - this.server = server; - this.userName = userName; - } - - public Server getServer() - { - return server; - } - - public String getUserName() - { - return userName; - } - - public JMSServerProtocol getProtocol() - { - return protocol; - } - - public void setProtocol(JMSServerProtocol protocol) - { - this.protocol = protocol; - } - - public ServerSession openSession(int sessionID) - { - ServerSession session = new ServerSession(this, sessionID); - synchronized (sessions) - { - while (sessionID >= sessions.size()) - { - sessions.add(null); - } - - sessions.set(sessionID, session); - } - - return session; - } - - public ServerSession getSession(int sessionID) - { - return sessions.get(sessionID); - } - - public ServerSession[] getSessions() - { - List<ServerSession> result = new ArrayList<ServerSession>(sessions.size()); - synchronized (sessions) - { - for (ServerSession session : sessions) - { - if (session != null) - { - result.add(session); - } - } - } - - return result.toArray(new ServerSession[result.size()]); - } - - public void close() - { - protocol.getChannel().close(); - } - - protected boolean removeSession(ServerSession session) - { - synchronized (sessions) - { - int sessionID = session.getID(); - if (sessions.get(sessionID) == session) - { - sessions.set(sessionID, null); - return true; - } - - return false; - } - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConsumer.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConsumer.java deleted file mode 100644 index f7d71e0d78..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerConsumer.java +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server; - -import org.eclipse.net4j.channel.IChannel; -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.jms.internal.server.bundle.OM; -import org.eclipse.net4j.jms.internal.server.protocol.JMSServerMessageRequest; -import org.eclipse.net4j.jms.server.IStoreTransaction; -import org.eclipse.net4j.util.io.IOUtil; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * @author Eike Stepper - */ -public class ServerConsumer -{ - private ServerSession session; - - private long id; - - private ServerDestination destination; - - private String messageSelector; - - private boolean noLocal; - - private boolean durable; - - private ConcurrentMap<String, MessageImpl> messages = new ConcurrentHashMap<String, MessageImpl>(); - - public ServerConsumer(long id, ServerDestination destination, String messageSelector, boolean noLocal, boolean durable) - { - this.id = id; - this.destination = destination; - this.messageSelector = messageSelector; - this.noLocal = noLocal; - this.durable = durable; - } - - public ServerSession getSession() - { - return session; - } - - public void setSession(ServerSession session) - { - this.session = session; - } - - public long getID() - { - return id; - } - - public ServerDestination getDestination() - { - return destination; - } - - public String getMessageSelector() - { - return messageSelector; - } - - public boolean isNoLocal() - { - return noLocal; - } - - public IChannel getChannel() - { - return session.getConnection().getProtocol().getChannel(); - } - - public boolean isDurable() - { - return durable; - } - - public boolean handleClientMessage(IStoreTransaction transaction, MessageImpl message) - { - try - { - String messageID = message.getJMSMessageID(); - synchronized (messages) - { - messages.put(messageID, message); - } - - new JMSServerMessageRequest(getChannel(), session.getID(), id, message).send(); - transaction.messageSent(message, id); - return true; - } - catch (Exception ex) - { - OM.LOG.error(ex); - return false; - } - } - - public void handleAcknowledge(IStoreTransaction transaction) - { - synchronized (messages) - { - if (messages.isEmpty()) - { - return; - } - - for (MessageImpl message : messages.values()) - { - transaction.messageAcknowledged(message, id); - IOUtil.OUT().println("\nMessage acknowledged: " + message.getJMSMessageID() + " (consumer=" + id + ")\n"); - } - - messages.clear(); - } - } - - public void handleRecover(IStoreTransaction transaction) - { - synchronized (messages) - { - if (messages.isEmpty()) - { - return; - } - - for (MessageImpl message : messages.values()) - { - IOUtil.OUT().println("\nRecovering message: " + message.getJMSMessageID() + " (consumer=" + id + ")\n"); - session.getConnection().getServer().addWork(message); - } - } - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerDestination.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerDestination.java deleted file mode 100644 index dcc9a6e6bb..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerDestination.java +++ /dev/null @@ -1,127 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server; - -import org.eclipse.net4j.internal.jms.DestinationImpl; -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.jms.QueueImpl; -import org.eclipse.net4j.internal.jms.TopicImpl; -import org.eclipse.net4j.internal.util.concurrent.RoundRobinList; -import org.eclipse.net4j.jms.server.IDestination; -import org.eclipse.net4j.jms.server.IStore; -import org.eclipse.net4j.jms.server.IStoreTransaction; - -import javax.naming.Context; -import javax.naming.NamingException; - -import java.util.Iterator; - -/** - * @author Eike Stepper - */ -public class ServerDestination implements IDestination -{ - private String name; - - private Type type; - - private RoundRobinList<ServerConsumer> consumers = new RoundRobinList<ServerConsumer>(); - - public ServerDestination(String name, Type type) - { - this.name = name; - this.type = type; - } - - public String getName() - { - return name; - } - - public Type getType() - { - return type; - } - - public DestinationImpl bind(Context context, boolean rebind) throws NamingException - { - DestinationImpl destination = type == Type.QUEUE ? new QueueImpl(name) : new TopicImpl(name); - if (rebind) - { - context.rebind(name, destination); - } - else - { - context.bind(name, destination); - } - - return destination; - } - - public boolean addConsumer(ServerConsumer consumer) - { - if (consumer.isDurable()) - { - IStore store = Server.INSTANCE.getStore(); - IStoreTransaction transaction = store.startTransaction(); - transaction.consumerAdded(consumer); - store.commitTransaction(transaction); - } - - return consumers.add(consumer); - } - - public boolean removeConsumer(final long consumerID) - { - final boolean[] modified = { false }; - consumers.executeWrites(new Runnable() - { - public void run() - { - for (Iterator<ServerConsumer> it = consumers.iterator(); it.hasNext();) - { - ServerConsumer consumer = it.next(); - if (consumer.getID() == consumerID) - { - it.remove(); - modified[0] = true; - return; - } - } - } - }); - - return modified[0]; - } - - /** - * Called by worker thread of the server - */ - public void handleClientMessage(IStoreTransaction transaction, MessageImpl message) - { - if (type == Type.QUEUE) - { - ServerConsumer consumer = consumers.element(); - if (consumer != null) - { - consumer.handleClientMessage(transaction, message); - } - } - else - { - ServerConsumer[] consumers = this.consumers.toArray(new ServerConsumer[0]); - for (ServerConsumer consumer : consumers) - { - consumer.handleClientMessage(transaction, message); - } - } - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerSession.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerSession.java deleted file mode 100644 index 98fafa6dcb..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/ServerSession.java +++ /dev/null @@ -1,111 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server; - -import org.eclipse.net4j.internal.jms.DestinationImpl; -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.jms.internal.server.bundle.OM; -import org.eclipse.net4j.jms.server.ISession; -import org.eclipse.net4j.jms.server.IStore; -import org.eclipse.net4j.jms.server.IStoreTransaction; - -import java.util.Collection; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * @author Eike Stepper - */ -public class ServerSession extends Lifecycle implements ISession -{ - private ServerConnection connection; - - private int id; - - private ConcurrentMap<Long, ServerConsumer> consumers = new ConcurrentHashMap<Long, ServerConsumer>(); - - public ServerSession(ServerConnection connection, int id) - { - this.connection = connection; - this.id = id; - } - - public ServerConnection getConnection() - { - return connection; - } - - public int getID() - { - return id; - } - - public long registerConsumer(DestinationImpl dest, String messageSelector, boolean noLocal, boolean durable) - { - Server server = connection.getServer(); - String name = dest.getName(); - ServerDestination destination = server.getDestination(name); - if (destination == null) - { - OM.LOG.error("Destination not found: " + name); - return -1; - } - - ServerConsumer consumer = server.createConsumer(destination, messageSelector, noLocal, durable); - consumer.setSession(this); - consumers.put(consumer.getID(), consumer); - destination.addConsumer(consumer); - return consumer.getID(); - } - - public void handleAcknowledge() - { - IStore store = connection.getServer().getStore(); - IStoreTransaction transaction = store.startTransaction(); - handleAcknowledgeInTransaction(transaction); - store.commitTransaction(transaction); - } - - public void handleAcknowledgeInTransaction(IStoreTransaction transaction) - { - for (ServerConsumer consumer : consumers.values()) - { - consumer.handleAcknowledge(transaction); - } - } - - public void handleRecover() - { - IStore store = connection.getServer().getStore(); - IStoreTransaction transaction = store.startTransaction(); - Collection<ServerConsumer> values = consumers.values(); - for (ServerConsumer consumer : values) - { - consumer.handleRecover(transaction); - } - - store.commitTransaction(transaction); - } - - public String[] handleCommit(MessageImpl[] messages) - { - Server server = connection.getServer(); - IStore store = server.getStore(); - - IStoreTransaction transaction = store.startTransaction(); - handleAcknowledgeInTransaction(transaction); - String[] messageIDs = server.handleClientMessagesInTransaction(transaction, messages); - store.commitTransaction(transaction); - - return messageIDs; - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/bundle/OM.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/bundle/OM.java deleted file mode 100644 index 0110f6ff46..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/bundle/OM.java +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.bundle; - -import org.eclipse.net4j.jms.internal.server.Server; -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OMPlatform; -import org.eclipse.net4j.util.om.OSGiActivator; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.trace.OMTracer; - -/** - * The <em>Operations & Maintenance</em> class of this bundle. - * - * @author Eike Stepper - */ -public abstract class OM -{ - public static final String BUNDLE_ID = "org.eclipse.net4j.jms.server"; //$NON-NLS-1$ - - public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); - - public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_STORE = DEBUG.tracer("store"); //$NON-NLS-1$ - - public static final OMLogger LOG = BUNDLE.logger(); - - static void start() throws Exception - { - Server.INSTANCE.activate(); - } - - static void stop() throws Exception - { - Server.INSTANCE.deactivate(); - } - - /** - * @author Eike Stepper - */ - public static final class Activator extends OSGiActivator - { - public Activator() - { - super(BUNDLE); - } - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java deleted file mode 100644 index 4b2a1d30bd..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSAcknowledgeIndication.java +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.jms.internal.server.ServerConnection; -import org.eclipse.net4j.jms.internal.server.ServerSession; -import org.eclipse.net4j.jms.internal.server.bundle.OM; -import org.eclipse.net4j.signal.Indication; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSAcknowledgeIndication extends Indication -{ - public JMSAcknowledgeIndication() - { - } - - @Override - protected short getSignalID() - { - return JMSProtocolConstants.SIGNAL_ACKNOWLEDGE; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws IOException - { - int sessionID = in.readInt(); - - JMSServerProtocol protocol = (JMSServerProtocol)getProtocol(); - ServerConnection connection = (ServerConnection)protocol.getInfraStructure(); - ServerSession session = connection.getSession(sessionID); - if (session == null) - { - OM.LOG.info("Session " + sessionID + " not found. Acknowledgement discarded."); - return; - } - - session.handleAcknowledge(); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java deleted file mode 100644 index 0ce93b1cde..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSClientMessageIndication.java +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.jms.util.MessageUtil; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.jms.internal.server.Server; -import org.eclipse.net4j.jms.internal.server.ServerConnection; -import org.eclipse.net4j.signal.IndicationWithResponse; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSClientMessageIndication extends IndicationWithResponse -{ - private String messageID; - - public JMSClientMessageIndication() - { - } - - @Override - protected short getSignalID() - { - return JMSProtocolConstants.SIGNAL_CLIENT_MESSAGE; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws IOException - { - MessageImpl[] messages = { MessageUtil.read(in) }; - JMSServerProtocol protocol = (JMSServerProtocol)getProtocol(); - ServerConnection connection = (ServerConnection)protocol.getInfraStructure(); - Server server = connection.getServer(); - String[] ids = server.handleClientMessages(messages); - if (ids != null && ids.length != 0) - { - messageID = ids[0]; - } - } - - @Override - protected void responding(ExtendedDataOutputStream out) throws IOException - { - out.writeString(messageID); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java deleted file mode 100644 index 364c3dd35a..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSCommitIndication.java +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.jms.util.MessageUtil; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.jms.internal.server.ServerConnection; -import org.eclipse.net4j.jms.internal.server.ServerSession; -import org.eclipse.net4j.jms.internal.server.bundle.OM; -import org.eclipse.net4j.signal.IndicationWithResponse; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSCommitIndication extends IndicationWithResponse -{ - private String[] messageIDs; - - public JMSCommitIndication() - { - } - - @Override - protected short getSignalID() - { - return JMSProtocolConstants.SIGNAL_COMMIT; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws IOException - { - int sessionID = in.readInt(); - int size = in.readInt(); - MessageImpl[] messages = new MessageImpl[size]; - for (int i = 0; i < messages.length; i++) - { - messages[i] = MessageUtil.read(in); - } - - JMSServerProtocol protocol = (JMSServerProtocol)getProtocol(); - ServerConnection connection = (ServerConnection)protocol.getInfraStructure(); - ServerSession session = connection.getSession(sessionID); - if (session == null) - { - OM.LOG.warn("Session " + sessionID + " not found"); - return; - } - - messageIDs = session.handleCommit(messages); - } - - @Override - protected void responding(ExtendedDataOutputStream out) throws IOException - { - if (messageIDs == null) - { - out.writeInt(-1); - } - else - { - out.writeInt(messageIDs.length); - for (String messageID : messageIDs) - { - out.writeString(messageID); - } - } - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java deleted file mode 100644 index 639928f44e..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSLogonIndication.java +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.jms.internal.server.Server; -import org.eclipse.net4j.jms.internal.server.ServerConnection; -import org.eclipse.net4j.jms.internal.server.bundle.OM; -import org.eclipse.net4j.signal.IndicationWithResponse; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSLogonIndication extends IndicationWithResponse -{ - private boolean ok; - - public JMSLogonIndication() - { - } - - @Override - protected short getSignalID() - { - return JMSProtocolConstants.SIGNAL_LOGON; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws IOException - { - String userName = in.readString(); - String password = in.readString(); - ServerConnection connection = Server.INSTANCE.logon(userName, password); - if (connection == null) - { - OM.LOG.error("Access to JMS server denied"); - return; - } - - JMSServerProtocol protocol = (JMSServerProtocol)getProtocol(); - connection.setProtocol(protocol); - protocol.setInfraStructure(connection); - ok = true; - } - - @Override - protected void responding(ExtendedDataOutputStream out) throws IOException - { - out.writeBoolean(ok); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java deleted file mode 100644 index c8c611bce3..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSOpenSessionIndication.java +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.jms.internal.server.ServerConnection; -import org.eclipse.net4j.jms.internal.server.ServerSession; -import org.eclipse.net4j.signal.IndicationWithResponse; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSOpenSessionIndication extends IndicationWithResponse -{ - private boolean ok; - - public JMSOpenSessionIndication() - { - } - - @Override - protected short getSignalID() - { - return JMSProtocolConstants.SIGNAL_OPEN_SESSION; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws IOException - { - int sessionID = in.readInt(); - JMSServerProtocol protocol = (JMSServerProtocol)getProtocol(); - ServerConnection connection = (ServerConnection)protocol.getInfraStructure(); - ServerSession session = connection.openSession(sessionID); - if (session != null) - { - ok = true; - } - } - - @Override - protected void responding(ExtendedDataOutputStream out) throws IOException - { - out.writeBoolean(ok); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java deleted file mode 100644 index f97ad56012..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRecoverIndication.java +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.jms.internal.server.ServerConnection; -import org.eclipse.net4j.jms.internal.server.ServerSession; -import org.eclipse.net4j.jms.internal.server.bundle.OM; -import org.eclipse.net4j.signal.IndicationWithResponse; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSRecoverIndication extends IndicationWithResponse -{ - public JMSRecoverIndication() - { - } - - @Override - protected short getSignalID() - { - return JMSProtocolConstants.SIGNAL_RECOVER; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws IOException - { - int sessionID = in.readInt(); - JMSServerProtocol protocol = (JMSServerProtocol)getProtocol(); - ServerConnection connection = (ServerConnection)protocol.getInfraStructure(); - ServerSession session = connection.getSession(sessionID); - if (session == null) - { - OM.LOG.warn("Session " + sessionID + " not found"); - return; - } - - session.handleRecover(); - } - - @Override - protected void responding(ExtendedDataOutputStream out) throws IOException - { - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java deleted file mode 100644 index 3678914912..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRegisterConsumerIndication.java +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.internal.jms.DestinationImpl; -import org.eclipse.net4j.internal.jms.util.DestinationUtil; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.jms.internal.server.ServerConnection; -import org.eclipse.net4j.jms.internal.server.ServerSession; -import org.eclipse.net4j.signal.IndicationWithResponse; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSRegisterConsumerIndication extends IndicationWithResponse -{ - private long consumerID; - - public JMSRegisterConsumerIndication() - { - } - - @Override - protected short getSignalID() - { - return JMSProtocolConstants.SIGNAL_REGISTER_CONSUMER; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws IOException - { - int sessionID = in.readInt(); - DestinationImpl destination = DestinationUtil.read(in); - String messageSelector = in.readString(); - boolean noLocal = in.readBoolean(); - boolean durable = in.readBoolean(); - JMSServerProtocol protocol = (JMSServerProtocol)getProtocol(); - ServerConnection connection = (ServerConnection)protocol.getInfraStructure(); - ServerSession session = connection.getSession(sessionID); - consumerID = session.registerConsumer(destination, messageSelector, noLocal, durable); - } - - @Override - protected void responding(ExtendedDataOutputStream out) throws IOException - { - out.writeLong(consumerID); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java deleted file mode 100644 index adf7d2408f..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSRollbackIndication.java +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.jms.internal.server.ServerConnection; -import org.eclipse.net4j.jms.internal.server.ServerSession; -import org.eclipse.net4j.jms.internal.server.bundle.OM; -import org.eclipse.net4j.signal.IndicationWithResponse; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSRollbackIndication extends IndicationWithResponse -{ - public JMSRollbackIndication() - { - } - - @Override - protected short getSignalID() - { - return JMSProtocolConstants.SIGNAL_ROLLBACK; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws IOException - { - int sessionID = in.readInt(); - JMSServerProtocol protocol = (JMSServerProtocol)getProtocol(); - ServerConnection connection = (ServerConnection)protocol.getInfraStructure(); - ServerSession session = connection.getSession(sessionID); - if (session == null) - { - OM.LOG.warn("Session " + sessionID + " not found"); - return; - } - - session.handleRecover(); - } - - @Override - protected void responding(ExtendedDataOutputStream out) throws IOException - { - out.writeBoolean(true); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerMessageRequest.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerMessageRequest.java deleted file mode 100644 index 6df0efbb37..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerMessageRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.channel.IChannel; -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.jms.util.MessageUtil; -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.Request; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSServerMessageRequest extends Request -{ - private int sessionID; - - private long consumerID; - - private MessageImpl message; - - public JMSServerMessageRequest(IChannel channel, int sessionID, long consumerID, MessageImpl message) - { - super(channel); - this.sessionID = sessionID; - this.consumerID = consumerID; - this.message = message; - } - - @Override - protected short getSignalID() - { - return JMSProtocolConstants.SIGNAL_SERVER_MESSAGE; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws IOException - { - out.writeInt(sessionID); - out.writeLong(consumerID); - MessageUtil.write(out, message); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocol.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocol.java deleted file mode 100644 index fb1707c0db..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocol.java +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.signal.SignalReactor; - -/** - * @author Eike Stepper - */ -public class JMSServerProtocol extends SignalProtocol -{ - public JMSServerProtocol() - { - } - - public String getType() - { - return JMSProtocolConstants.PROTOCOL_NAME; - } - - @Override - protected SignalReactor doCreateSignalReactor(short signalID) - { - switch (signalID) - { - case JMSProtocolConstants.SIGNAL_SYNC: - return new JMSSyncIndication(); - - case JMSProtocolConstants.SIGNAL_LOGON: - return new JMSLogonIndication(); - - case JMSProtocolConstants.SIGNAL_OPEN_SESSION: - return new JMSOpenSessionIndication(); - - case JMSProtocolConstants.SIGNAL_REGISTER_CONSUMER: - return new JMSRegisterConsumerIndication(); - - case JMSProtocolConstants.SIGNAL_CLIENT_MESSAGE: - return new JMSClientMessageIndication(); - - case JMSProtocolConstants.SIGNAL_ACKNOWLEDGE: - return new JMSAcknowledgeIndication(); - - case JMSProtocolConstants.SIGNAL_RECOVER: - return new JMSRecoverIndication(); - - case JMSProtocolConstants.SIGNAL_COMMIT: - return new JMSCommitIndication(); - - case JMSProtocolConstants.SIGNAL_ROLLBACK: - return new JMSRollbackIndication(); - } - - return null; - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java deleted file mode 100644 index 739e8ba53c..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSServerProtocolFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.util.container.IManagedContainer; - -import org.eclipse.internal.net4j.protocol.ServerProtocolFactory; - -/** - * @author Eike Stepper - */ -public final class JMSServerProtocolFactory extends ServerProtocolFactory -{ - public static final String TYPE = JMSProtocolConstants.PROTOCOL_NAME; - - public JMSServerProtocolFactory() - { - super(TYPE); - } - - public JMSServerProtocol create(String description) - { - return new JMSServerProtocol(); - } - - public static JMSServerProtocol get(IManagedContainer container, String description) - { - return (JMSServerProtocol)container.getElement(PRODUCT_GROUP, TYPE, description); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSSyncIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSSyncIndication.java deleted file mode 100644 index 01577a56cf..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/JMSSyncIndication.java +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol; - -import org.eclipse.net4j.jms.JMSProtocolConstants; -import org.eclipse.net4j.signal.IndicationWithResponse; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSSyncIndication extends IndicationWithResponse -{ - public JMSSyncIndication() - { - } - - @Override - protected short getSignalID() - { - return JMSProtocolConstants.SIGNAL_SYNC; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws IOException - { - } - - @Override - protected void responding(ExtendedDataOutputStream out) throws IOException - { - out.writeLong(System.currentTimeMillis()); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocol.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocol.java deleted file mode 100644 index 7778f463e0..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocol.java +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol.admin; - -import org.eclipse.net4j.jms.JMSAdminProtocolConstants; -import org.eclipse.net4j.jms.server.IServer; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.signal.SignalReactor; - -/** - * @author Eike Stepper - */ -public class JMSAdminServerProtocol extends SignalProtocol -{ - public JMSAdminServerProtocol() - { - } - - public String getType() - { - return JMSAdminProtocolConstants.PROTOCOL_NAME; - } - - @Override - protected SignalReactor doCreateSignalReactor(short signalID) - { - switch (signalID) - { - case JMSAdminProtocolConstants.SIGNAL_CREATE_DESTINATION: - return new JMSCreateDestinationIndication(); - } - - return null; - } - - public IServer getServer() - { - return IServer.INSTANCE; - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java deleted file mode 100644 index e9dff046a1..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSAdminServerProtocolFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol.admin; - -import org.eclipse.net4j.jms.JMSAdminProtocolConstants; -import org.eclipse.net4j.util.container.IManagedContainer; - -import org.eclipse.internal.net4j.protocol.ServerProtocolFactory; - -/** - * @author Eike Stepper - */ -public final class JMSAdminServerProtocolFactory extends ServerProtocolFactory -{ - public static final String TYPE = JMSAdminProtocolConstants.PROTOCOL_NAME; - - public JMSAdminServerProtocolFactory() - { - super(TYPE); - } - - public JMSAdminServerProtocol create(String description) - { - return new JMSAdminServerProtocol(); - } - - public static JMSAdminServerProtocol get(IManagedContainer container, String description) - { - return (JMSAdminServerProtocol)container.getElement(PRODUCT_GROUP, TYPE, description); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSCreateDestinationIndication.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSCreateDestinationIndication.java deleted file mode 100644 index 3649a2149a..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/protocol/admin/JMSCreateDestinationIndication.java +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.protocol.admin; - -import org.eclipse.net4j.jms.JMSAdminProtocolConstants; -import org.eclipse.net4j.jms.server.IDestination; -import org.eclipse.net4j.jms.server.IServer; -import org.eclipse.net4j.jms.server.IDestination.Type; -import org.eclipse.net4j.signal.IndicationWithResponse; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class JMSCreateDestinationIndication extends IndicationWithResponse -{ - private boolean ok; - - public JMSCreateDestinationIndication() - { - } - - @Override - protected short getSignalID() - { - return JMSAdminProtocolConstants.SIGNAL_CREATE_DESTINATION; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws IOException - { - byte type = in.readByte(); - String name = in.readString(); - JMSAdminServerProtocol protocol = (JMSAdminServerProtocol)getProtocol(); - IServer server = protocol.getServer(); - IDestination destination = server.createDestination(name, getDestinationType(type)); - if (destination != null) - { - ok = true; - } - } - - @Override - protected void responding(ExtendedDataOutputStream out) throws IOException - { - out.writeBoolean(ok); - } - - private Type getDestinationType(byte type) - { - switch (type) - { - case JMSAdminProtocolConstants.DESTINATION_TYPE_QUEUE: - return IDestination.Type.QUEUE; - case JMSAdminProtocolConstants.DESTINATION_TYPE_TOPIC: - return IDestination.Type.TOPIC; - } - - throw new IllegalArgumentException("type: " + type); - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/AbstractStore.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/AbstractStore.java deleted file mode 100644 index aa1bfa8305..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/AbstractStore.java +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.store; - -import org.eclipse.net4j.internal.util.lifecycle.Lifecycle; -import org.eclipse.net4j.jms.server.IStore; - -/** - * @author Eike Stepper - */ -public abstract class AbstractStore extends Lifecycle implements IStore -{ - private String storeType; - - private String instanceID; - - public AbstractStore(String storeType) - { - this.storeType = storeType; - } - - public String getStoreType() - { - return storeType; - } - - public String getInstanceID() - { - return instanceID; - } - - public void setInstanceID(String instanceID) - { - this.instanceID = instanceID; - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/AbstractTransaction.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/AbstractTransaction.java deleted file mode 100644 index 6deb70ed1c..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/AbstractTransaction.java +++ /dev/null @@ -1,226 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.store; - -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.internal.util.om.trace.ContextTracer; -import org.eclipse.net4j.jms.internal.server.ServerConsumer; -import org.eclipse.net4j.jms.internal.server.ServerDestination; -import org.eclipse.net4j.jms.internal.server.bundle.OM; -import org.eclipse.net4j.jms.server.IStoreTransaction; - -/** - * @author Eike Stepper - */ -public abstract class AbstractTransaction implements IStoreTransaction -{ - public static final String[] NO_DESTINATION_NAMES = new String[0]; - - public static final long[] NO_CONSUMER_IDS = new long[0]; - - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_STORE, AbstractTransaction.class); - - private AbstractStore store; - - public AbstractTransaction(AbstractStore store) - { - this.store = store; - } - - public AbstractStore getStore() - { - return store; - } - - public String[] getDestinationNames() - { - if (TRACER.isEnabled()) - { - TRACER.trace("Getting destination names"); - } - - String[] names = doGetDestinationNames(); - if (TRACER.isEnabled()) - { - TRACER.trace("Got destination names " + names); - } - - return names; - } - - public ServerDestination getDestination(String name) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Getting destination " + name); - } - - ServerDestination destination = doGetDestination(name); - if (TRACER.isEnabled()) - { - TRACER.trace("Got destination " + destination); - } - - return destination; - } - - public long[] getConsumerIDs() - { - if (TRACER.isEnabled()) - { - TRACER.trace("Getting consumer IDs"); - } - - long[] ids = doGetConsumerIDs(); - if (TRACER.isEnabled()) - { - TRACER.trace("Got consumer IDs " + ids); - } - - return ids; - } - - public ServerConsumer getConsumer(long id) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Getting consumer " + id); - } - - ServerConsumer consumer = doGetConsumer(id); - if (TRACER.isEnabled()) - { - TRACER.trace("Got consumer " + consumer); - } - - return consumer; - } - - public void destinationAdded(ServerDestination destination) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Adding destination " + destination); - } - - doDestinationAdded(destination); - if (TRACER.isEnabled()) - { - TRACER.trace("Added destination " + destination); - } - } - - public void destinationRemoved(ServerDestination destination) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Removing destination " + destination); - } - - doDestinationRemoved(destination); - if (TRACER.isEnabled()) - { - TRACER.trace("Removed destination " + destination); - } - } - - public void consumerAdded(ServerConsumer consumer) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Adding consumer " + consumer); - } - - doConsumerAdded(consumer); - if (TRACER.isEnabled()) - { - TRACER.trace("Added consumer " + consumer); - } - } - - public void consumerRemoved(ServerConsumer consumer) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Removing consumer " + consumer); - } - - doConsumerRemoved(consumer); - if (TRACER.isEnabled()) - { - TRACER.trace("Removed consumer " + consumer); - } - } - - public void messageReceived(MessageImpl message) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Logging received message " + message); - } - - doMessageReceived(message); - if (TRACER.isEnabled()) - { - TRACER.trace("Logged received message " + message); - } - } - - public void messageSent(MessageImpl message, long consumerID) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Logging sent message " + message); - } - - doMessageSent(message, consumerID); - if (TRACER.isEnabled()) - { - TRACER.trace("Logged sent message " + message); - } - } - - public void messageAcknowledged(MessageImpl message, long consumerID) - { - if (TRACER.isEnabled()) - { - TRACER.trace("Logging acknowledged message " + message); - } - - doMessageAcknowledged(message, consumerID); - if (TRACER.isEnabled()) - { - TRACER.trace("Logged acknowledged message " + message); - } - } - - protected abstract String[] doGetDestinationNames(); - - protected abstract ServerDestination doGetDestination(String name); - - protected abstract long[] doGetConsumerIDs(); - - protected abstract ServerConsumer doGetConsumer(long id); - - protected abstract void doDestinationAdded(ServerDestination destination); - - protected abstract void doDestinationRemoved(ServerDestination destination); - - protected abstract void doConsumerAdded(ServerConsumer consumer); - - protected abstract void doConsumerRemoved(ServerConsumer consumer); - - protected abstract void doMessageReceived(MessageImpl message); - - protected abstract void doMessageSent(MessageImpl message, long consumerID); - - protected abstract void doMessageAcknowledged(MessageImpl message, long consumerID); -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/NOOPStore.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/NOOPStore.java deleted file mode 100644 index 0699374396..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/NOOPStore.java +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.store; - -import org.eclipse.net4j.jms.server.IStoreTransaction; - -/** - * @author Eike Stepper - */ -public class NOOPStore extends AbstractStore -{ - private static final String STORE_TYPE = "NOOP"; - - public NOOPStore() - { - super(STORE_TYPE); - setInstanceID(STORE_TYPE); - } - - public IStoreTransaction startTransaction() - { - return new NOOPTransaction(this); - } - - public void commitTransaction(IStoreTransaction transaction) - { - } - - public void rollbackTransaction(IStoreTransaction transaction) - { - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/NOOPTransaction.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/NOOPTransaction.java deleted file mode 100644 index 58f93624d4..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/NOOPTransaction.java +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.store; - -import org.eclipse.net4j.internal.jms.MessageImpl; -import org.eclipse.net4j.jms.internal.server.ServerConsumer; -import org.eclipse.net4j.jms.internal.server.ServerDestination; - -/** - * @author Eike Stepper - */ -public class NOOPTransaction extends AbstractTransaction -{ - public NOOPTransaction(AbstractStore store) - { - super(store); - } - - @Override - protected String[] doGetDestinationNames() - { - return NO_DESTINATION_NAMES; - } - - @Override - protected ServerDestination doGetDestination(String name) - { - return null; - } - - @Override - protected long[] doGetConsumerIDs() - { - return NO_CONSUMER_IDS; - } - - @Override - protected ServerConsumer doGetConsumer(long id) - { - return null; - } - - @Override - protected void doDestinationAdded(ServerDestination destination) - { - } - - @Override - protected void doDestinationRemoved(ServerDestination destination) - { - } - - @Override - protected void doConsumerAdded(ServerConsumer consumer) - { - } - - @Override - protected void doConsumerRemoved(ServerConsumer consumer) - { - } - - @Override - protected void doMessageReceived(MessageImpl message) - { - } - - @Override - protected void doMessageSent(MessageImpl message, long consumerID) - { - } - - @Override - protected void doMessageAcknowledged(MessageImpl message, long consumerID) - { - } -} diff --git a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/StoreException.java b/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/StoreException.java deleted file mode 100644 index 87736e7d46..0000000000 --- a/plugins/org.eclipse.net4j.jms.server/src/org/eclipse/net4j/jms/internal/server/store/StoreException.java +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2008 Eike Stepper, Germany. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eike Stepper - initial API and implementation - **************************************************************************/ -package org.eclipse.net4j.jms.internal.server.store; - -/** - * @author Eike Stepper - */ -public class StoreException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public StoreException() - { - } - - public StoreException(String message) - { - super(message); - } - - public StoreException(Throwable cause) - { - super(cause); - } - - public StoreException(String message, Throwable cause) - { - super(message, cause); - } -} |