Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
COOS - Connected Objects Operating System (www.connectedobjects.org). Copyright (C) 2009 Telenor ASA and Tellu AS. All rights reserved. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. You may also contact one of the following for additional information: Telenor ASA, Snaroyveien 30, N-1331 Fornebu, Norway (www.telenor.no) Tellu AS, Hagalokkveien 13, N-1383 Asker, Norway (www.tellu.no)
 
 package org.coos.messaging.plugin;
 
 

Author(s):
Knut Eilif Husa, Tellu AS A channel connecting plugins to coos instances (router nodes)
 
 public class PluginChannel extends DefaultChannel {
 
 	private static final String PROPERTY_CONNECTION_TIMEOUT = "connectionTimeout";
 	private static final String PROPERTY_STARTUP_ORDERED = "startupOrdered";
 
 	private int connectionTimeout = 10000; // Default value
 	private boolean startupOrdered = true// Default value
 
 	private String connectionErrorCause = null;
 
 	public PluginChannel() {
 	}
 
 	public long getConnectionTimeout() {
 	}
 
 	public void setConnectionTimeout(int connectionTimeout) {
 		this. = connectionTimeout;
 	}
 
 	public boolean isStartupOrdered() {
 		return ;
 	}
 
 	public void setStartupOrdered(boolean startupOrdered) {
 		this. = startupOrdered;
 	}
 
 	public void addInFilter(Processor filter) {
 	}
 
 	public void addOutFilter(Processor filter) {
 	}
 
 	public void setProperties(Hashtable properties) {
 		super.setProperties(properties);
 
 		if (properties.get() != null) {
 		}
 
 		String startupOrderedStr = (Stringproperties.get();
 		if (startupOrderedStr != null && startupOrderedStr.equals("false")) {
 			 = false;
 		}
 
 	}
 
 	public synchronized void connect(LinkManager linkManagerthrows ConnectingException {
		synchronized (linkManager) {
			if (!(linkManager instanceof Endpoint)) {
				throw new ConnectingException("This channel can only be connected to Endpoints.");
			}
			this. = linkManager;
			final Endpoint endpoint = (EndpointlinkManager;
						"This Endpoint is not in state ready and can not be connected to. It is in state: "
endpoint.getEndpointState());
			}
			try {
				if ( == null) {
					String className = "org.coos.messaging.transport.JvmTransport";
					Class transportClass = Class.forName(className);
					 = (TransporttransportClass.newInstance();
				}
					public void processMessage(Message msgthrows ProcessorException {
else if (msg.getName().equals()) {
							String routerUuid = msg.getHeader();
							if (allocUuid != null) {
								endpoint.setEndpointUuid(allocUuid);
								if (endpoint.getEndpointUri() == null) {
									endpoint.setName(allocUuid);
									endpoint.setEndpointUri("coos://" + allocUuid);
								}
							}
							 = true;
						}
					}
				});
				if (endpoint.getEndpointUuid() == null) {
					// must allocate a uuid
else {
					// has predefined uuid
				}
				// Set the aliases of the endpoint as a property in the body of
				// the message
				Hashtable props = new Hashtable();
				props.put(.endpoint.getAliases());
				msg.setBody(props);
				for (int i = 0; i < .size(); i++) {
				}
					try {
						// Waiting for the connecting thread to return
							if ( == null) {
								 = "Failure during endpoint startup";
							}
							throw new ConnectingException( + ", Endpoint: "
endpoint.getEndpointUri() + " in state " + endpoint.getEndpointState());
else if (endpoint.getEndpointState().equals(.)) {
									"Timeout, no response from connecting oos instance, Endpoint: "
endpoint.getEndpointUri() + " in state " + endpoint.getEndpointState());
						}
catch (InterruptedException e) {
					}
				}
catch (Exception e) {
				throw new ConnectingException("Connecting endpoint: " + endpoint.getEndpointUri() + " failed, cause: "
e.getMessage());
			}
		}
	}
	public void disconnect() {
		try {
			 = false;
			if ( != null) {
			}
			if ( != null) {
			}
catch (Exception e) {
		}
	}
	public boolean isConnected() {
		return ;
	}
New to GrepCode? Check out our FAQ X