directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r782980 [2/8] - in /directory/sandbox/slp/src/main/java/org/apache/directory/slp: ./ codec/ extensions/ impl/ impl/da/ impl/filter/ messages/
Date Tue, 09 Jun 2009 12:50:47 GMT
Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceURL.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceURL.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceURL.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/ServiceURL.java Tue Jun  9 12:50:45 2009
@@ -95,27 +95,21 @@
 	private String path = "";
 
 	/**
-	 * 
-	 * 
-	 */
-	private ServiceURL() {
-	}
-
-	/**
 	 * create a new ServiceURL instance from a String.
 	 * 
 	 * @param serviceURL
 	 *            the string representation of a ServiceURL like
 	 * 
-	 * <pre>
+	 *            <pre>
 	 *                 service::&quot;serviceType&quot;://&quot;addrspec&quot;
 	 * </pre>
 	 * 
-	 * where servicetype should be of the form abstractType:concreteType and
-	 * addrspec is the hostname or dotted decimal notation of the host's address
-	 * followed by an optional :portNumber. Example:
+	 *            where servicetype should be of the form
+	 *            abstractType:concreteType and addrspec is the hostname or
+	 *            dotted decimal notation of the host's address followed by an
+	 *            optional :portNumber. Example:
 	 * 
-	 * <pre>
+	 *            <pre>
 	 *                     service:osgi:remote://my.host.ch:9200
 	 * </pre>
 	 * 
@@ -131,14 +125,13 @@
 
 		try {
 			parse();
-		} catch (Exception ex) {
+		} catch (final Exception ex) {
 			throw new ServiceLocationException(
 					ServiceLocationException.PARSE_ERROR,
 					"service url is malformed: [" + url + "]. ");
 		}
 	}
-	
-	
+
 	/**
 	 * create a new ServiceURL instance from a <code>ServiceType</code>.
 	 * 
@@ -146,19 +139,19 @@
 	 *            the ServiceType
 	 * 
 	 * 
-	 * This constructor was added by Lorenz Breu during the initial porting of jSLP
-	 * to the Apache Mina framework due to type incompatibilities between the original
-	 * jSLP implementation and the Codecs for Mina designed by Jan Rellermeyer. 
+	 *            This constructor was added by Lorenz Breu during the initial
+	 *            porting of jSLP to the Apache Mina framework due to type
+	 *            incompatibilities between the original jSLP implementation and
+	 *            the Codecs for Mina designed by Jan Rellermeyer.
 	 * 
 	 * @param lifeTime
 	 *            the lifetime of the ServiceURL in seconds.
 	 */
-	public ServiceURL(final ServiceType serviceType, final int lifeTime){
-		type=serviceType;
-		url=serviceType.toString();
-		lifetime=lifeTime;
+	public ServiceURL(final ServiceType serviceType, final int lifeTime) {
+		type = serviceType;
+		url = serviceType.toString();
+		lifetime = lifeTime;
 	}
-	
 
 	/**
 	 * parse the url string.
@@ -168,7 +161,7 @@
 		int pos1 = url.indexOf("://");
 		type = new ServiceType(url.substring(0, pos1++));
 
-		int pos2 = url.indexOf("://", pos1 + 1);
+		final int pos2 = url.indexOf("://", pos1 + 1);
 		if (pos2 > -1) {
 			protocol = url.substring(pos1 + 2, pos2);
 			pos1 = pos2 + 1;
@@ -200,8 +193,7 @@
 		} else {
 			path = url.substring(pathStart);
 		}
-		
-		
+
 	}
 
 	/**
@@ -212,14 +204,15 @@
 	 *            the object to compare to.
 	 * @return true if the instances are equal.
 	 */
+	@Override
 	public boolean equals(final Object obj) {
 		if (obj instanceof ServiceURL) {
 			final ServiceURL u = (ServiceURL) obj;
-			return (type.equals(u.type)
+			return type.equals(u.type)
 					&& host.equals(u.host)
 					&& port == u.port
-					&& ((protocol == null && u.protocol == null) || protocol
-							.equals(u.protocol)) && path.equals(u.path));
+					&& (protocol == null && u.protocol == null || protocol
+							.equals(u.protocol)) && path.equals(u.path);
 		}
 		return false;
 	}
@@ -249,12 +242,13 @@
 	 * 
 	 * @return the String representation.
 	 */
+	@Override
 	public String toString() {
-		String res = type.toString() + "://"
+		final String res = type.toString() + "://"
 				+ (protocol != "" ? protocol + "://" : "") + host
-				+ (port != NO_PORT ? (":" + port) : "") + path;
-		if (res.lastIndexOf("://")==res.length()-3){
-			return res.substring(0,res.length()-3);
+				+ (port != NO_PORT ? ":" + port : "") + path;
+		if (res.lastIndexOf("://") == res.length() - 3) {
+			return res.substring(0, res.length() - 3);
 		}
 		return res.replace("://://", "://");
 	}
@@ -264,6 +258,7 @@
 	 * 
 	 * @return the hashCode.
 	 */
+	@Override
 	public int hashCode() {
 		return url.hashCode();
 	}
@@ -283,6 +278,7 @@
 	 * @return the transport method. IP returns empty string.
 	 * @deprecated
 	 */
+	@Deprecated
 	public String getTransport() {
 		return "";
 	}
@@ -293,7 +289,7 @@
 	 * @return the protocol, if specified. Otherwise, returns null.
 	 */
 	public String getProtocol() {
-		if (protocol.equals("")){
+		if (protocol.equals("")) {
 			return null;
 		}
 		return protocol;
@@ -307,15 +303,15 @@
 	public String getHost() {
 		return host;
 	}
-	
+
 	/**
 	 * set the host
 	 * 
 	 * @param s
-	 * 		the host part of this service url
+	 *            the host part of this service url
 	 */
-	public void setHost(String s){
-		host=s;
+	public void setHost(final String s) {
+		host = s;
 	}
 
 	/**
@@ -352,7 +348,7 @@
 	 * @throws IOException
 	 *             if an internal processing error occurs.
 	 */
-	public void writeTo(DataOutputStream out) throws IOException {
+	public void writeTo(final DataOutputStream out) throws IOException {
 		out.write(0);
 		out.writeShort((short) lifetime);
 		out.writeUTF(toString());
@@ -360,37 +356,37 @@
 	}
 
 	/**
-	 * Get the length of the Strig representation of this URL for encoding into a SLP message
+	 * Get the length of the Strig representation of this URL for encoding into
+	 * a SLP message
 	 * 
-	 * @return
-	 * 		the length
+	 * @return the length
 	 */
 	public int getLength() {
 		return 1 + 2 + 2 + toString().length(); // + getAuthBlockLength();
 	}
-	
-	
+
 	/**
 	 * Get the URL
 	 * 
-	 * @return
-	 * 		The URL
+	 * @return The URL
 	 */
-	public String getURL(){
-		// somewhere along the way of porting jSLP to MINA and moving to java5 the trio Service, ServiceURL and ServiceType and their conversion back and forth caused some mix-ups...
-		if (url.lastIndexOf("://")==url.length()-3){
-			return url.substring(0,url.length()-3);
+	public String getURL() {
+		// somewhere along the way of porting jSLP to MINA and moving to java5
+		// the trio Service, ServiceURL and ServiceType and their conversion
+		// back and forth caused some mix-ups...
+		if (url.lastIndexOf("://") == url.length() - 3) {
+			return url.substring(0, url.length() - 3);
 		}
 		return url;
 	}
-	
+
 	/**
 	 * Set the URL
 	 * 
 	 * @param u
-	 * 		The URL
+	 *            The URL
 	 */
-	public void setURL(String u){
-		url=u;
+	public void setURL(final String u) {
+		url = u;
 	}
 }

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AbstractSLPMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AbstractSLPMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AbstractSLPMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AbstractSLPMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -72,14 +72,15 @@
 	protected static CharsetEncoder ENCODER = CHARSET.newEncoder();
 
 	private final byte type;
-	
+
 	private boolean hasExtensions = false;
 
 	public AbstractSLPMessageCodec(final byte type) {
 		this.type = type;
 	}
 
-	public MessageDecoderResult decodable(IoSession session, IoBuffer in) {
+	public MessageDecoderResult decodable(final IoSession session,
+			final IoBuffer in) {
 		if (in.remaining() < 2) {
 			return MessageDecoderResult.NEED_DATA;
 		}
@@ -88,9 +89,9 @@
 			return MessageDecoderResult.NOT_OK;
 		}
 		final byte funcID = in.get(); // funcID
-		int a = in.get()<<16;
-		int b = in.get()<<8;
-		int c = in.get();
+		final int a = in.get() << 16;
+		final int b = in.get() << 8;
+		final int c = in.get();
 		final int len = a + b + c;
 		if (in.remaining() < len - 5) {
 			return MessageDecoderResult.NEED_DATA;
@@ -99,31 +100,31 @@
 				: MessageDecoderResult.NOT_OK;
 	}
 
-	public MessageDecoderResult decode(IoSession session, IoBuffer in,
-			ProtocolDecoderOutput out) throws Exception {
+	public MessageDecoderResult decode(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
 		try {
-			
+
 			in.skip(5); // version and funcID are already parsed
 
-			byte flags = (byte) (in.getShort() >> 8);
-			IoSessionConfig cfg = session.getConfig();
-			if ((cfg instanceof DatagramSessionConfig) && (flags & 0x80) != 0) {
+			final byte flags = (byte) (in.getShort() >> 8);
+			final IoSessionConfig cfg = session.getConfig();
+			if (cfg instanceof DatagramSessionConfig && (flags & 0x80) != 0) {
 				throw new ProtocolException(
 						"Multicast message does not have the correct flag set.");
 			}
-			
 
 			// we don't process extensions, we simply ignore them
 			// TODO: clean extensions from the pipe
-			
-			int a = in.get()<<16;
-			int b = in.get()<<8;
-			int c = in.get();
+
+			final int a = in.get() << 16;
+			final int b = in.get() << 8;
+			final int c = in.get();
 			final int nextOffset = a + b + c;
-			if (nextOffset>0){
+			if (nextOffset > 0) {
 				hasExtensions = true;
 			}
-			
+
 			final short xid = in.getShort(); // XID
 
 			final Locale locale = new Locale(decodeString(in), "");
@@ -131,23 +132,23 @@
 			final AbstractSLPMessage msg = decodeBody(session, in, out);
 			msg.setXid(xid);
 			msg.setLocale(locale);
-			if (cfg instanceof DatagramSessionConfig){
+			if (cfg instanceof DatagramSessionConfig) {
 				msg.setTcp(false);
 			} else {
 				msg.setTcp(true);
 			}
-			//msg.setMulticast(((flags & 0x2000) >> 13) == 1 ? true : false);
-			msg.setMulticast(((flags & 0x20) >> 5) == 1 ? true : false);
-			msg.setFresh(((flags & 0x40) >> 6) == 1 ? true : false);
-			
-			if (hasExtensions){
+			// msg.setMulticast(((flags & 0x2000) >> 13) == 1 ? true : false);
+			msg.setMulticast((flags & 0x20) >> 5 == 1 ? true : false);
+			msg.setFresh((flags & 0x40) >> 6 == 1 ? true : false);
+
+			if (hasExtensions) {
 				decodeExtensions(session, in, out, msg);
 			}
-			
+
 			out.write(msg);
 
 			return MessageDecoderResult.OK;
-		} catch (Exception t) {
+		} catch (final Exception t) {
 			t.printStackTrace();
 			throw t;
 		}
@@ -167,61 +168,59 @@
 	protected abstract AbstractSLPMessage decodeBody(final IoSession session,
 			final IoBuffer in, final ProtocolDecoderOutput out)
 			throws Exception;
-	
-/*	 9.1. Service Location Protocol Extensions
 
-	   The format of a Service Location Extension is:
+	/*
+	 * 9.1. Service Location Protocol Extensions
+	 * 
+	 * The format of a Service Location Extension is:
+	 * 
+	 * 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+	 * Extension ID | Next Extension Offset |
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+	 * Offset, contd.| Extension Data \
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+	 * 
+	 * Extension IDs are assigned in the following way:
+	 * 
+	 * 0x0000-0x3FFF Standardized. Optional to implement. Ignore if
+	 * unrecognized. 0x4000-0x7FFF Standardized. Mandatory to implement. A UA or
+	 * SA which receives this option in a reply and does not understand it MUST
+	 * silently discard the reply. A DA or SA which receives this option in a
+	 * request and does not understand it MUST return an OPTION_NOT_UNDERSTOOD
+	 * error. 0x8000-0x8FFF For private use (not standardized). Optional to
+	 * implement. Ignore if unrecognized. 0x9000-0xFFFF Reserved.
+	 * 
+	 * The three byte offset to next extension indicates the position of the
+	 * next extension as offset from the beginning of the SLP message.
+	 * 
+	 * The offset value is 0 if there are no extensions following the current
+	 * extension.
+	 * 
+	 * If the offset is 0, the length of the current Extension Data is
+	 * determined by subtracting total length of the SLP message as given in the
+	 * SLP message header minus the offset of the current extension.
+	 */
 
-	      0                   1                   2                   3
-	      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-	     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-	     |         Extension ID          |       Next Extension Offset   |
-	     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-	     | Offset, contd.|                Extension Data                 \
-	     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
-	   Extension IDs are assigned in the following way:
-
-	   0x0000-0x3FFF Standardized.  Optional to implement.  Ignore if
-	         unrecognized.
-	   0x4000-0x7FFF Standardized.  Mandatory to implement.  A UA or SA
-	         which receives this option in a reply and does not understand
-	         it MUST silently discard the reply.  A DA or SA which receives
-	         this option in a request and does not understand it MUST return
-	         an OPTION_NOT_UNDERSTOOD error.
-	   0x8000-0x8FFF For private use (not standardized).  Optional to
-	         implement.  Ignore if unrecognized.
-	   0x9000-0xFFFF Reserved.
-
-	   The three byte offset to next extension indicates the position of the
-	   next extension as offset from the beginning of the SLP message.
-
-	   The offset value is 0 if there are no extensions following the
-	   current extension.
-
-	   If the offset is 0, the length of the current Extension Data is
-	   determined by subtracting total length of the SLP message as given in
-	   the SLP message header minus the offset of the current extension.*/
-	
-	protected static void decodeExtensions(IoSession session, IoBuffer in,
-			ProtocolDecoderOutput out, AbstractSLPMessage msg) {
+	protected static void decodeExtensions(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out,
+			final AbstractSLPMessage msg) {
 		boolean hasMoreExtensions = true;
-		while (hasMoreExtensions){
-			short id = in.getShort();
-			int a = (0x00FF0000 & (in.get()<<16));
-			int b = (0x0000FF00 & (in.get()<<8));
-			int c = (0x000000FF & (in.get())); 
-			int nextOffset = a+b+c;
+		while (hasMoreExtensions) {
+			final short id = in.getShort();
+			final int a = 0x00FF0000 & in.get() << 16;
+			final int b = 0x0000FF00 & in.get() << 8;
+			final int c = 0x000000FF & in.get();
+			final int nextOffset = a + b + c;
 			msg.addExtension(AbstractExtension.decode(in, id, nextOffset));
-			if (nextOffset==0){
+			if (nextOffset == 0) {
 				hasMoreExtensions = false;
 			}
 		}
 	}
-	
 
-	public void finishDecode(IoSession session, ProtocolDecoderOutput out)
-			throws Exception {
+	public void finishDecode(final IoSession session,
+			final ProtocolDecoderOutput out) throws Exception {
 		// TODO Auto-generated method stub
 
 	}
@@ -241,7 +240,9 @@
 	 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 	 *   |# of URL auths |            Auth. blocks (if any)              \
 	 *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-	 * </pre>.
+	 * </pre>
+	 * 
+	 * .
 	 * </p>
 	 * 
 	 * @param input
@@ -287,10 +288,10 @@
 	 */
 	protected final AuthenticationBlock[] decodeAuthBlocks(
 			final IoSession session, final IoBuffer in) throws Exception {
-		final short blocks = (short) in.get();
+		final short blocks = in.get();
 		final AuthenticationBlock[] result = new AuthenticationBlock[blocks];
 		for (int i = 0; i < blocks; i++) {
-			final short bsd = (short) in.getShort();
+			final short bsd = in.getShort();
 			if (bsd != AuthenticationBlock.BSD_DSA) {
 				throw new ServiceLocationException(
 						ServiceLocationException.AUTHENTICATION_FAILED, "BSD "
@@ -336,7 +337,8 @@
 		final StringTokenizer tokenizer = new StringTokenizer(strFixed, ",");
 		final String[] result = new String[tokenizer.countTokens()];
 		for (int i = 0; i < result.length; i++) {
-			result[i] = tokenizer.nextToken().replace("SLP_ESCAPED_COMMA", "\\,");
+			result[i] = tokenizer.nextToken().replace("SLP_ESCAPED_COMMA",
+					"\\,");
 		}
 		return result;
 	}
@@ -367,9 +369,9 @@
 	 * @throws Exception
 	 *             if the message violated protocol specification
 	 */
-	public void encode(IoSession session, Object message,
-			ProtocolEncoderOutput out) throws Exception {
-		AbstractSLPMessage msg = (AbstractSLPMessage) message;
+	public void encode(final IoSession session, final Object message,
+			final ProtocolEncoderOutput out) throws Exception {
+		final AbstractSLPMessage msg = (AbstractSLPMessage) message;
 		final IoBuffer buf = IoBuffer.allocate(128);
 		buf.setAutoExpand(true); // Enable auto-expand for easier encoding
 
@@ -381,13 +383,15 @@
 		 * if (msg .funcID == SRVREG) { flags |= 0x40; }
 		 */
 		byte flags = 0;
-		if (msg instanceof ServiceRegistrationMessage && msg.isFresh()) { flags |= 0x40; }
+		if (msg instanceof ServiceRegistrationMessage && msg.isFresh()) {
+			flags |= 0x40;
+		}
 		if (msg.isMulticast()) {
 			flags |= 0x20;
 		}
 		/*
-		 * if (!msg.isTcp() && msg.getSize() > SLPCore.CONFIG.getMTU()) { flags |=
-		 * 0x80; }
+		 * if (!msg.isTcp() && msg.getSize() > SLPCore.CONFIG.getMTU()) { flags
+		 * |= 0x80; }
 		 */
 		buf.put(flags);
 		buf.skip(1); // reserved
@@ -396,54 +400,55 @@
 		encodeString(buf, msg.getLocale().getLanguage()); // language tag
 		encodeBody(session, msg, buf);
 		// fill in the message length
-		
-		if (msg.hasExtensions()){
+
+		if (msg.hasExtensions()) {
 			final int offset = buf.position();
 			buf.put(7, (byte) (offset >> 16));
-			buf.put(8, (byte) ((offset >> 8) & 0xFF));
-			buf.put(9, (byte) ((offset) & 0xFF));
+			buf.put(8, (byte) (offset >> 8 & 0xFF));
+			buf.put(9, (byte) (offset & 0xFF));
 			encodeExtensions(session, msg, buf);
 		} else {
-			buf.put(7, (byte) (0));
-			buf.put(8, (byte) (0));
-			buf.put(9, (byte) (0));
+			buf.put(7, (byte) 0);
+			buf.put(8, (byte) 0);
+			buf.put(9, (byte) 0);
 		}
 		final int len = buf.position();
 		buf.put(2, (byte) (len >> 16));
-		buf.put(3, (byte) ((len >> 8) & 0xFF));
-		buf.put(4, (byte) ((len) & 0xFF));
+		buf.put(3, (byte) (len >> 8 & 0xFF));
+		buf.put(4, (byte) (len & 0xFF));
 		buf.flip();
 		out.write(buf);
 	}
 
 	protected abstract void encodeBody(final IoSession session,
-			final AbstractSLPMessage msg, final IoBuffer buf)
-			throws Exception;
-	
-	
-	protected void encodeExtensions(final IoSession session, final AbstractSLPMessage msg, final IoBuffer buf) throws Exception{
+			final AbstractSLPMessage msg, final IoBuffer buf) throws Exception;
+
+	protected void encodeExtensions(final IoSession session,
+			final AbstractSLPMessage msg, final IoBuffer buf) throws Exception {
 		int i = 0;
 		AbstractExtension ae;
-		for (i = 0; i < msg.getExtensions().length-1; i++){
+		for (i = 0; i < msg.getExtensions().length - 1; i++) {
 			ae = msg.getExtensions()[i];
 			buf.putShort(ae.getId());
-			int nextOffset = buf.position() + ae.getLength() - 2; //have already added a short
-			byte b =(byte) ((nextOffset>>16) & 0x000000FF);
+			final int nextOffset = buf.position() + ae.getLength() - 2; // have
+																		// already
+																		// added
+																		// a
+																		// short
+			byte b = (byte) (nextOffset >> 16 & 0x000000FF);
 			buf.put(b);
-			b =(byte) ((nextOffset>>8) & 0x000000FF);
+			b = (byte) (nextOffset >> 8 & 0x000000FF);
 			buf.put(b);
-			b =(byte) (nextOffset & 0x000000FF);
+			b = (byte) (nextOffset & 0x000000FF);
 			buf.put(b);
 			ae.encodeBody(buf);
 		}
 		ae = msg.getExtensions()[i];
 		buf.putShort(ae.getId());
-		buf.put((byte)0);
-		buf.put((byte)0);
-		buf.put((byte)0);
+		buf.put((byte) 0);
+		buf.put((byte) 0);
+		buf.put((byte) 0);
 		ae.encodeBody(buf);
 	}
-	
-}
-
 
+}

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AttributeReplyMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AttributeReplyMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AttributeReplyMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AttributeReplyMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -25,14 +25,12 @@
 import java.util.HashSet;
 import java.util.Set;
 
-
 import org.apache.directory.slp.messages.AbstractSLPMessage;
 import org.apache.directory.slp.messages.AttributeReplyMessage;
 import org.apache.mina.core.buffer.IoBuffer;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
-
 /**
  * 
  * <pre>
@@ -47,7 +45,9 @@
  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *   |# of AttrAuths |  Attribute Authentication Block (if present)  \
  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * </pre>.
+ * </pre>
+ * 
+ * .
  * 
  * @author Jan S. Rellermeyer
  * 
@@ -65,19 +65,22 @@
 		super(AttributeReplyMessage.FUNC_ID);
 	}
 
-	protected AbstractSLPMessage decodeBody(IoSession session, IoBuffer in,
-			ProtocolDecoderOutput out) throws Exception {
+	@Override
+	protected AbstractSLPMessage decodeBody(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
 		final AttributeReplyMessage msg = new AttributeReplyMessage();
 		msg.setErrorCode(in.getShort());
 		msg.setAttributes(stringToArray(decodeString(in)));
 		msg.setAuthBlocks(decodeAuthBlocks(session, in));
-		//msg.verify();
-		//Set the source address from session info
-		msg.setSource(((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress());
-		//Weird behaviour in Debian and co. binds the local hostname to 
-		//127.0.1.1 in the hosts file...Replace all such occurences with 
-		//127.0.0.1
-		if (msg.getSource()=="127.0.1.1"){
+		// msg.verify();
+		// Set the source address from session info
+		msg.setSource(((InetSocketAddress) session.getRemoteAddress())
+				.getAddress().getHostAddress());
+		// Weird behaviour in Debian and co. binds the local hostname to
+		// 127.0.1.1 in the hosts file...Replace all such occurences with
+		// 127.0.0.1
+		if (msg.getSource() == "127.0.1.1") {
 			msg.setSource("127.0.0.1");
 		}
 		// Set the source port of the message
@@ -85,8 +88,9 @@
 		return msg;
 	}
 
-	protected void encodeBody(IoSession session, AbstractSLPMessage msg,
-			IoBuffer out) throws Exception {
+	@Override
+	protected void encodeBody(final IoSession session,
+			final AbstractSLPMessage msg, final IoBuffer out) throws Exception {
 		final AttributeReplyMessage message = (AttributeReplyMessage) msg;
 		out.putShort(message.getErrorCode());
 		encodeString(out, arrayToString(message.getAttributes()));

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AttributeRequestMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AttributeRequestMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AttributeRequestMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/AttributeRequestMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -34,7 +34,6 @@
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
-
 /**
  * <pre>
  *   0                   1                   2                   3
@@ -72,14 +71,16 @@
 				.asList(new Class[] { AttributeRequestMessage.class })));
 	}
 
-	protected AbstractSLPMessage decodeBody(IoSession session, IoBuffer in,
-			ProtocolDecoderOutput out) throws Exception {
+	@Override
+	protected AbstractSLPMessage decodeBody(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
 		final AttributeRequestMessage msg = new AttributeRequestMessage();
 		msg.setPrevResponders(stringToArray(decodeString(in)));
-		String srv = decodeString(in);
+		final String srv = decodeString(in);
 		try {
 			msg.setServiceURL(new ServiceURL(srv, 0));
-		} catch (ServiceLocationException sle) {
+		} catch (final ServiceLocationException sle) {
 			msg.setServiceURL(new ServiceURL(new ServiceType(srv), 0));
 		}
 
@@ -92,8 +93,9 @@
 		return msg;
 	}
 
-	protected void encodeBody(IoSession session, AbstractSLPMessage msg,
-			IoBuffer buf) throws Exception {
+	@Override
+	protected void encodeBody(final IoSession session,
+			final AbstractSLPMessage msg, final IoBuffer buf) throws Exception {
 		final AttributeRequestMessage req = (AttributeRequestMessage) msg;
 		encodeString(buf, arrayToString(req.getPrevResponders()));
 		encodeString(buf, req.getServiceUrl().getURL());

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/DAAdvertisementMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/DAAdvertisementMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/DAAdvertisementMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/DAAdvertisementMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -32,7 +32,6 @@
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
-
 /**
  * <pre>
  *  0                   1                   2                   3
@@ -73,8 +72,10 @@
 		super(DAAdvertisementMessage.FUNC_ID);
 	}
 
-	protected AbstractSLPMessage decodeBody(IoSession session, IoBuffer in,
-			ProtocolDecoderOutput out) throws Exception {
+	@Override
+	protected AbstractSLPMessage decodeBody(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
 		final DAAdvertisementMessage msg = new DAAdvertisementMessage();
 		msg.setErrorCode(in.getShort());
 		msg.setStatelessBootTimestamp(in.getInt());
@@ -90,8 +91,10 @@
 		return msg;
 	}
 
-	protected void encodeBody(IoSession session, AbstractSLPMessage message,
-			IoBuffer buf) throws Exception {
+	@Override
+	protected void encodeBody(final IoSession session,
+			final AbstractSLPMessage message, final IoBuffer buf)
+			throws Exception {
 		final DAAdvertisementMessage msg = (DAAdvertisementMessage) message;
 		buf.putShort(msg.getErrorCode());
 		buf.putInt(msg.getStatelessBootTimestamp());

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/SLPProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/SLPProtocolCodecFactory.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/SLPProtocolCodecFactory.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/SLPProtocolCodecFactory.java Tue Jun  9 12:50:45 2009
@@ -19,7 +19,6 @@
  */
 package org.apache.directory.slp.codec;
 
-
 import org.apache.directory.slp.messages.AttributeReplyMessage;
 import org.apache.directory.slp.messages.AttributeRequestMessage;
 import org.apache.directory.slp.messages.DAAdvertisementMessage;
@@ -32,7 +31,6 @@
 import org.apache.directory.slp.messages.ServiceTypeRequestMessage;
 import org.apache.mina.filter.codec.demux.DemuxingProtocolCodecFactory;
 
-
 /**
  * Protocol codec factory for the SLP protocol.
  * 
@@ -42,26 +40,36 @@
 
 	public SLPProtocolCodecFactory() {
 		addMessageDecoder(AttributeReplyMessageCodec.class);
-		addMessageEncoder(AttributeReplyMessage.class,AttributeReplyMessageCodec.class);
+		addMessageEncoder(AttributeReplyMessage.class,
+				AttributeReplyMessageCodec.class);
 		addMessageDecoder(AttributeRequestMessageCodec.class);
-		addMessageEncoder(AttributeRequestMessage.class,AttributeRequestMessageCodec.class);
+		addMessageEncoder(AttributeRequestMessage.class,
+				AttributeRequestMessageCodec.class);
 		addMessageDecoder(DAAdvertisementMessageCodec.class);
-		addMessageEncoder(DAAdvertisementMessage.class,DAAdvertisementMessageCodec.class);
+		addMessageEncoder(DAAdvertisementMessage.class,
+				DAAdvertisementMessageCodec.class);
 		addMessageDecoder(ServiceAcknowledgementMessageCodec.class);
-		addMessageEncoder(ServiceAcknowledgementMessage.class,ServiceAcknowledgementMessageCodec.class);
+		addMessageEncoder(ServiceAcknowledgementMessage.class,
+				ServiceAcknowledgementMessageCodec.class);
 		addMessageDecoder(ServiceDeregistrationMessageCodec.class);
-		addMessageEncoder(ServiceDeregistrationMessage.class,ServiceDeregistrationMessageCodec.class);
+		addMessageEncoder(ServiceDeregistrationMessage.class,
+				ServiceDeregistrationMessageCodec.class);
 		addMessageDecoder(ServiceRegistrationMessageCodec.class);
-		addMessageEncoder(ServiceRegistrationMessage.class,ServiceRegistrationMessageCodec.class);
+		addMessageEncoder(ServiceRegistrationMessage.class,
+				ServiceRegistrationMessageCodec.class);
 		addMessageDecoder(ServiceReplyMessageCodec.class);
-		addMessageEncoder(ServiceReplyMessage.class,ServiceReplyMessageCodec.class);
+		addMessageEncoder(ServiceReplyMessage.class,
+				ServiceReplyMessageCodec.class);
 		addMessageDecoder(ServiceRequestMessageCodec.class);
-		addMessageEncoder(ServiceRequestMessage.class,ServiceRequestMessageCodec.class);
+		addMessageEncoder(ServiceRequestMessage.class,
+				ServiceRequestMessageCodec.class);
 		addMessageDecoder(ServiceTypeReplyMessageCodec.class);
-		addMessageEncoder(ServiceTypeReplyMessage.class,ServiceTypeReplyMessageCodec.class);
+		addMessageEncoder(ServiceTypeReplyMessage.class,
+				ServiceTypeReplyMessageCodec.class);
 		addMessageDecoder(ServiceTypeRequestMessageCodec.class);
-		addMessageEncoder(ServiceTypeRequestMessage.class,ServiceTypeRequestMessageCodec.class);
-		
+		addMessageEncoder(ServiceTypeRequestMessage.class,
+				ServiceTypeRequestMessageCodec.class);
+
 	}
 
 }

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceAcknowledgementMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceAcknowledgementMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceAcknowledgementMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceAcknowledgementMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -31,7 +31,6 @@
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
-
 /**
  * <pre>
  *       0                   1                   2                   3
@@ -58,8 +57,10 @@
 		super(ServiceAcknowledgementMessage.FUNC_ID);
 	}
 
-	protected AbstractSLPMessage decodeBody(IoSession session, IoBuffer in,
-			ProtocolDecoderOutput out) throws Exception {
+	@Override
+	protected AbstractSLPMessage decodeBody(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
 		final ServiceAcknowledgementMessage msg = new ServiceAcknowledgementMessage();
 		msg.setErrorCode(in.getShort());
 		msg.setSource(((InetSocketAddress) session.getRemoteAddress())
@@ -68,8 +69,9 @@
 		return msg;
 	}
 
-	protected void encodeBody(IoSession session, AbstractSLPMessage msg,
-			IoBuffer buf) throws Exception {
+	@Override
+	protected void encodeBody(final IoSession session,
+			final AbstractSLPMessage msg, final IoBuffer buf) throws Exception {
 		final ServiceAcknowledgementMessage ack = (ServiceAcknowledgementMessage) msg;
 		buf.putShort(ack.getErrorCode());
 	}

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceDeregistrationMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceDeregistrationMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceDeregistrationMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceDeregistrationMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -31,8 +31,6 @@
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
-
-
 /**
  * <pre>
  *  0                   1                   2                   3
@@ -46,44 +44,50 @@
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  * |      Length of &lt;tag-list&gt;     |            &lt;tag-list&gt;         \
  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * </pre>. 
+ * </pre>
+ * 
+ * .
  * 
  * @author Jan S. Rellermeyer
  */
 public class ServiceDeregistrationMessageCodec extends AbstractSLPMessageCodec {
 
-    private static final Set MESSAGE_TYPE;
+	private static final Set MESSAGE_TYPE;
 
-    static {
-        MESSAGE_TYPE = Collections.unmodifiableSet(new HashSet(Arrays
-                .asList(new Class[] { ServiceDeregistrationMessage.class })));
-    }
-
-    public ServiceDeregistrationMessageCodec() {
-        super(ServiceDeregistrationMessage.FUNC_ID);
-    }
-
-    protected AbstractSLPMessage decodeBody(IoSession session, IoBuffer in,
-            ProtocolDecoderOutput out) throws Exception {
-        final ServiceDeregistrationMessage msg = new ServiceDeregistrationMessage();
-        msg.setScopes(stringToArray(decodeString(in)));
-        msg.setServiceURL(decodeServiceURL(session, in));
-        msg.setTags(stringToArray(decodeString(in)));
-        msg.setSource(((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress());
+	static {
+		MESSAGE_TYPE = Collections.unmodifiableSet(new HashSet(Arrays
+				.asList(new Class[] { ServiceDeregistrationMessage.class })));
+	}
+
+	public ServiceDeregistrationMessageCodec() {
+		super(ServiceDeregistrationMessage.FUNC_ID);
+	}
+
+	@Override
+	protected AbstractSLPMessage decodeBody(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
+		final ServiceDeregistrationMessage msg = new ServiceDeregistrationMessage();
+		msg.setScopes(stringToArray(decodeString(in)));
+		msg.setServiceURL(decodeServiceURL(session, in));
+		msg.setTags(stringToArray(decodeString(in)));
+		msg.setSource(((InetSocketAddress) session.getRemoteAddress())
+				.getAddress().getHostAddress());
 		msg.setPort(((InetSocketAddress) session.getRemoteAddress()).getPort());
-        return msg;
-    }
+		return msg;
+	}
 
-    protected void encodeBody(IoSession session, AbstractSLPMessage msg, IoBuffer buf)
-            throws Exception {
-        final ServiceDeregistrationMessage sdreg = (ServiceDeregistrationMessage) msg;
-        encodeString(buf, arrayToString(sdreg.getScopes()));
-        encodeServiceURL(sdreg.getServiceURL(), session, buf);
-        encodeString(buf, arrayToString(sdreg.getTags()));
-    }
-
-    public Set getMessageTypes() {
-        return MESSAGE_TYPE;
-    }
+	@Override
+	protected void encodeBody(final IoSession session,
+			final AbstractSLPMessage msg, final IoBuffer buf) throws Exception {
+		final ServiceDeregistrationMessage sdreg = (ServiceDeregistrationMessage) msg;
+		encodeString(buf, arrayToString(sdreg.getScopes()));
+		encodeServiceURL(sdreg.getServiceURL(), session, buf);
+		encodeString(buf, arrayToString(sdreg.getTags()));
+	}
+
+	public Set getMessageTypes() {
+		return MESSAGE_TYPE;
+	}
 
 }

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceRegistrationMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceRegistrationMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceRegistrationMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceRegistrationMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -20,11 +20,9 @@
 package org.apache.directory.slp.codec;
 
 import java.net.InetSocketAddress;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
 import org.apache.directory.slp.ServiceType;
@@ -34,7 +32,6 @@
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
-
 /**
  * Encodes and decodes a service registration message with the following body:
  * <p>
@@ -55,52 +52,56 @@
  *        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *        |# of AttrAuths |(if present) Attribute Authentication Blocks...\
  *        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * </pre>.
+ * </pre>
+ * 
+ * .
  * </p>
  * 
  * @author Jan S. Rellermeyer
  */
 public class ServiceRegistrationMessageCodec extends AbstractSLPMessageCodec {
 
-    private static final Set MESSAGE_TYPE;
+	private static final Set MESSAGE_TYPE;
 
-    static {
-        MESSAGE_TYPE = Collections.unmodifiableSet(new HashSet(Arrays
-                .asList(new Class[] { ServiceRegistrationMessage.class })));
-    }
-
-    public ServiceRegistrationMessageCodec() {
-        super(ServiceRegistrationMessage.FUNC_ID);
-    }
-
-    protected AbstractSLPMessage decodeBody(IoSession session, IoBuffer in,
-            ProtocolDecoderOutput out) throws Exception {
-        final ServiceRegistrationMessage msg = new ServiceRegistrationMessage();
-        msg.setServiceURL(decodeServiceURL(session, in));
-        msg.setServiceType(new ServiceType(decodeString(in)));
-        msg.setScopes(stringToArray(decodeString(in)));
-        msg.setAttributes(decodeString(in));
-        msg.setAuthBlocks(decodeAuthBlocks(session, in));
-        msg.setSource(((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress());
+	static {
+		MESSAGE_TYPE = Collections.unmodifiableSet(new HashSet(Arrays
+				.asList(new Class[] { ServiceRegistrationMessage.class })));
+	}
+
+	public ServiceRegistrationMessageCodec() {
+		super(ServiceRegistrationMessage.FUNC_ID);
+	}
+
+	@Override
+	protected AbstractSLPMessage decodeBody(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
+		final ServiceRegistrationMessage msg = new ServiceRegistrationMessage();
+		msg.setServiceURL(decodeServiceURL(session, in));
+		msg.setServiceType(new ServiceType(decodeString(in)));
+		msg.setScopes(stringToArray(decodeString(in)));
+		msg.setAttributes(decodeString(in));
+		msg.setAuthBlocks(decodeAuthBlocks(session, in));
+		msg.setSource(((InetSocketAddress) session.getRemoteAddress())
+				.getAddress().getHostAddress());
 		msg.setPort(((InetSocketAddress) session.getRemoteAddress()).getPort());
-        msg.verify();
-        return msg;
-    }
-
-    protected void encodeBody(IoSession session, AbstractSLPMessage msg, IoBuffer buf)
-            throws Exception {
-        final ServiceRegistrationMessage sreg = (ServiceRegistrationMessage) msg;
-        encodeServiceURL(sreg.getServiceURL(), session, buf);
-        encodeString(buf, sreg.getServiceType().toString());
-        encodeString(buf, arrayToString(sreg.getScopes()));
-        encodeString(buf, arrayToString(sreg.getAttrList()));
-        encodeAuthBlocks(sreg.getAuthBlocks(), session, buf);
-    }
-
-    public Set getMessageTypes() {
-        return MESSAGE_TYPE;
-    }
+		msg.verify();
+		return msg;
+	}
+
+	@Override
+	protected void encodeBody(final IoSession session,
+			final AbstractSLPMessage msg, final IoBuffer buf) throws Exception {
+		final ServiceRegistrationMessage sreg = (ServiceRegistrationMessage) msg;
+		encodeServiceURL(sreg.getServiceURL(), session, buf);
+		encodeString(buf, sreg.getServiceType().toString());
+		encodeString(buf, arrayToString(sreg.getScopes()));
+		encodeString(buf, arrayToString(sreg.getAttrList()));
+		encodeAuthBlocks(sreg.getAuthBlocks(), session, buf);
+	}
+
+	public Set getMessageTypes() {
+		return MESSAGE_TYPE;
+	}
 
-    
-    
 }

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceReplyMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceReplyMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceReplyMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceReplyMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -32,8 +32,6 @@
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
-
-
 /**
  * <pre>
  *  0                   1                   2                   3
@@ -52,45 +50,49 @@
  */
 public class ServiceReplyMessageCodec extends AbstractSLPMessageCodec {
 
-    private static final Set MESSAGE_TYPE;
+	private static final Set MESSAGE_TYPE;
 
-    static {
-        MESSAGE_TYPE = Collections.unmodifiableSet(new HashSet(Arrays
-                .asList(new Class[] { ServiceReplyMessage.class })));
-    }
-
-    public ServiceReplyMessageCodec() {
-        super(ServiceReplyMessage.FUNC_ID);
-    }
-
-    protected AbstractSLPMessage decodeBody(IoSession session, IoBuffer in,
-            ProtocolDecoderOutput out) throws Exception {
-        final ServiceReplyMessage msg = new ServiceReplyMessage();
-        msg.setErrorCode(in.getShort());
-        final short count = in.getShort();
-        final ServiceURL[] serviceURLs = new ServiceURL[count];
-        for (int i = 0; i < count; i++) {
-            serviceURLs[i] = decodeServiceURL(session, in);
-        }
-        msg.setServiceURLs(serviceURLs);
-        msg.setSource(((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress());
+	static {
+		MESSAGE_TYPE = Collections.unmodifiableSet(new HashSet(Arrays
+				.asList(new Class[] { ServiceReplyMessage.class })));
+	}
+
+	public ServiceReplyMessageCodec() {
+		super(ServiceReplyMessage.FUNC_ID);
+	}
+
+	@Override
+	protected AbstractSLPMessage decodeBody(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
+		final ServiceReplyMessage msg = new ServiceReplyMessage();
+		msg.setErrorCode(in.getShort());
+		final short count = in.getShort();
+		final ServiceURL[] serviceURLs = new ServiceURL[count];
+		for (int i = 0; i < count; i++) {
+			serviceURLs[i] = decodeServiceURL(session, in);
+		}
+		msg.setServiceURLs(serviceURLs);
+		msg.setSource(((InetSocketAddress) session.getRemoteAddress())
+				.getAddress().getHostAddress());
 		msg.setPort(((InetSocketAddress) session.getRemoteAddress()).getPort());
-        return msg;
-    }
+		return msg;
+	}
 
-    protected void encodeBody(IoSession session, AbstractSLPMessage msg, IoBuffer buf)
-            throws Exception {
-        final ServiceReplyMessage repl = (ServiceReplyMessage) msg;
-        buf.putShort(repl.getErrorCode());
-        final int count = repl.getServiceURLs().length;
-        buf.putShort((short) count);
-        for (int i = 0; i < count; i++) {
-            encodeServiceURL(repl.getServiceURLs()[i], session, buf);
-        }
-    }
-
-    public Set getMessageTypes() {
-        return MESSAGE_TYPE;
-    }
+	@Override
+	protected void encodeBody(final IoSession session,
+			final AbstractSLPMessage msg, final IoBuffer buf) throws Exception {
+		final ServiceReplyMessage repl = (ServiceReplyMessage) msg;
+		buf.putShort(repl.getErrorCode());
+		final int count = repl.getServiceURLs().length;
+		buf.putShort((short) count);
+		for (int i = 0; i < count; i++) {
+			encodeServiceURL(repl.getServiceURLs()[i], session, buf);
+		}
+	}
+
+	public Set getMessageTypes() {
+		return MESSAGE_TYPE;
+	}
 
 }

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceRequestMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceRequestMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceRequestMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceRequestMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -66,8 +66,10 @@
 		super(ServiceRequestMessage.FUNC_ID);
 	}
 
-	protected AbstractSLPMessage decodeBody(IoSession session, IoBuffer in,
-			ProtocolDecoderOutput out) throws Exception {
+	@Override
+	protected AbstractSLPMessage decodeBody(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
 		final ServiceRequestMessage msg = new ServiceRequestMessage();
 		msg.setPrevResponders(stringToArray(decodeString(in)));
 		msg.setServiceType(new ServiceType(decodeString(in)));
@@ -80,8 +82,9 @@
 		return msg;
 	}
 
-	protected void encodeBody(IoSession session, AbstractSLPMessage msg,
-			IoBuffer buf) throws Exception {
+	@Override
+	protected void encodeBody(final IoSession session,
+			final AbstractSLPMessage msg, final IoBuffer buf) throws Exception {
 		final ServiceRequestMessage sreq = (ServiceRequestMessage) msg;
 		encodeString(buf, arrayToString(sreq.getPrevResponders()));
 		encodeString(buf, sreq.getServiceType().toString());

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceTypeReplyMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceTypeReplyMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceTypeReplyMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceTypeReplyMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -32,9 +32,9 @@
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
-
 /**
  * <p>
+ * 
  * <pre>
  *    0                   1                   2                   3
  *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
@@ -45,53 +45,59 @@
  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *   |                       &lt;srvtype--list&gt;                         \
  *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * </pre>.
+ * </pre>
+ * 
+ * .
  * </p>
  * 
  * @author Jan S. Rellermeyer
  */
 public class ServiceTypeReplyMessageCodec extends AbstractSLPMessageCodec {
 
-    private static final Set MESSAGE_TYPE;
+	private static final Set MESSAGE_TYPE;
 
-    static {
-        MESSAGE_TYPE = Collections.unmodifiableSet(new HashSet(Arrays
-                .asList(new Class[] { ServiceTypeReplyMessage.class })));
-    }
-
-    public ServiceTypeReplyMessageCodec() {
-        super(ServiceTypeReplyMessage.FUNC_ID);
-    }
-
-    protected AbstractSLPMessage decodeBody(IoSession session, IoBuffer in,
-            ProtocolDecoderOutput out) throws Exception {
-        final ServiceTypeReplyMessage msg = new ServiceTypeReplyMessage();
-        msg.setErrorCode(in.getShort());
-        final String[] res = stringToArray(decodeString(in));
-        final ServiceType[] result = new ServiceType[res.length];
-        for (int i = 0; i < result.length; i++) {
-            result[i] = new ServiceType(res[i]);
-        }
-        msg.setServiceTypes(result);
-        msg.setSource(((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress());
+	static {
+		MESSAGE_TYPE = Collections.unmodifiableSet(new HashSet(Arrays
+				.asList(new Class[] { ServiceTypeReplyMessage.class })));
+	}
+
+	public ServiceTypeReplyMessageCodec() {
+		super(ServiceTypeReplyMessage.FUNC_ID);
+	}
+
+	@Override
+	protected AbstractSLPMessage decodeBody(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
+		final ServiceTypeReplyMessage msg = new ServiceTypeReplyMessage();
+		msg.setErrorCode(in.getShort());
+		final String[] res = stringToArray(decodeString(in));
+		final ServiceType[] result = new ServiceType[res.length];
+		for (int i = 0; i < result.length; i++) {
+			result[i] = new ServiceType(res[i]);
+		}
+		msg.setServiceTypes(result);
+		msg.setSource(((InetSocketAddress) session.getRemoteAddress())
+				.getAddress().getHostAddress());
 		msg.setPort(((InetSocketAddress) session.getRemoteAddress()).getPort());
-        return msg;
-    }
+		return msg;
+	}
 
-    protected void encodeBody(IoSession session, AbstractSLPMessage msg, IoBuffer buf)
-            throws Exception {
-        final ServiceTypeReplyMessage repl = (ServiceTypeReplyMessage) msg;
-        buf.putShort(repl.getErrorCode());
-        final ServiceType[] res = repl.getServiceTypes();
-        final String[] result = new String[res.length];
-        for (int i = 0; i < result.length; i++) {
-            result[i] = res[i].toString();
-        }
-        encodeString(buf, arrayToString(result));
-    }
-
-    public Set getMessageTypes() {
-        return MESSAGE_TYPE;
-    }
+	@Override
+	protected void encodeBody(final IoSession session,
+			final AbstractSLPMessage msg, final IoBuffer buf) throws Exception {
+		final ServiceTypeReplyMessage repl = (ServiceTypeReplyMessage) msg;
+		buf.putShort(repl.getErrorCode());
+		final ServiceType[] res = repl.getServiceTypes();
+		final String[] result = new String[res.length];
+		for (int i = 0; i < result.length; i++) {
+			result[i] = res[i].toString();
+		}
+		encodeString(buf, arrayToString(result));
+	}
+
+	public Set getMessageTypes() {
+		return MESSAGE_TYPE;
+	}
 
 }

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceTypeRequestMessageCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceTypeRequestMessageCodec.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceTypeRequestMessageCodec.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/codec/ServiceTypeRequestMessageCodec.java Tue Jun  9 12:50:45 2009
@@ -25,14 +25,12 @@
 import java.util.HashSet;
 import java.util.Set;
 
-
 import org.apache.directory.slp.messages.AbstractSLPMessage;
 import org.apache.directory.slp.messages.ServiceTypeRequestMessage;
 import org.apache.mina.core.buffer.IoBuffer;
 import org.apache.mina.core.session.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
-
 /**
  * <pre>
  *   0                   1                   2                   3
@@ -46,44 +44,51 @@
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *  |     length of &lt;scope-list&gt;    |      &lt;scope-list&gt; String      \
  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * </pre>.
- *
+ * </pre>
+ * 
+ * .
+ * 
  * @author Jan S. Rellermeyer
  */
 public class ServiceTypeRequestMessageCodec extends AbstractSLPMessageCodec {
 
-    private static final Set MESSAGE_TYPE;
+	private static final Set MESSAGE_TYPE;
 
-    static {
-        MESSAGE_TYPE = Collections.unmodifiableSet(new HashSet(Arrays
-                .asList(new Class[] { ServiceTypeRequestMessage.class })));
-    }
-
-    public ServiceTypeRequestMessageCodec() {
-        super(ServiceTypeRequestMessage.FUNC_ID);
-    }
-
-    protected AbstractSLPMessage decodeBody(IoSession session, IoBuffer in,
-            ProtocolDecoderOutput out) throws Exception {
-        final ServiceTypeRequestMessage msg = new ServiceTypeRequestMessage();
-        msg.setPrevResponders(stringToArray(decodeString(in)));
-        msg.setNamingAuthority(decodeString(in));
-        msg.setScopes(stringToArray(decodeString(in)));
-        msg.setSource(((InetSocketAddress) session.getRemoteAddress()).getAddress().getHostAddress());
+	static {
+		MESSAGE_TYPE = Collections.unmodifiableSet(new HashSet(Arrays
+				.asList(new Class[] { ServiceTypeRequestMessage.class })));
+	}
+
+	public ServiceTypeRequestMessageCodec() {
+		super(ServiceTypeRequestMessage.FUNC_ID);
+	}
+
+	@Override
+	protected AbstractSLPMessage decodeBody(final IoSession session,
+			final IoBuffer in, final ProtocolDecoderOutput out)
+			throws Exception {
+		final ServiceTypeRequestMessage msg = new ServiceTypeRequestMessage();
+		msg.setPrevResponders(stringToArray(decodeString(in)));
+		msg.setNamingAuthority(decodeString(in));
+		msg.setScopes(stringToArray(decodeString(in)));
+		msg.setSource(((InetSocketAddress) session.getRemoteAddress())
+				.getAddress().getHostAddress());
 		msg.setPort(((InetSocketAddress) session.getRemoteAddress()).getPort());
-        return msg;
-    }
+		return msg;
+	}
 
-    protected void encodeBody(IoSession session, AbstractSLPMessage message,
-            IoBuffer buf) throws Exception {
-        final ServiceTypeRequestMessage msg = (ServiceTypeRequestMessage) message;
-        encodeString(buf, arrayToString(msg.getPrevResponders()));
-        encodeString(buf, msg.getNamingAuthority());
-        encodeString(buf, arrayToString(msg.getScopes()));
-    }
-
-    public Set getMessageTypes() {
-        return MESSAGE_TYPE;
-    }
+	@Override
+	protected void encodeBody(final IoSession session,
+			final AbstractSLPMessage message, final IoBuffer buf)
+			throws Exception {
+		final ServiceTypeRequestMessage msg = (ServiceTypeRequestMessage) message;
+		encodeString(buf, arrayToString(msg.getPrevResponders()));
+		encodeString(buf, msg.getNamingAuthority());
+		encodeString(buf, arrayToString(msg.getScopes()));
+	}
+
+	public Set getMessageTypes() {
+		return MESSAGE_TYPE;
+	}
 
 }

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/AbstractExtension.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/AbstractExtension.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/AbstractExtension.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/AbstractExtension.java Tue Jun  9 12:50:45 2009
@@ -28,7 +28,6 @@
 import org.apache.directory.slp.impl.SLPCore;
 import org.apache.mina.core.buffer.IoBuffer;
 
-
 /**
  * The base abstract class representing SLP extensions
  * 
@@ -40,58 +39,50 @@
 	private static Charset CHARSET = Charset.forName("UTF-8");
 	protected static CharsetDecoder DECODER = CHARSET.newDecoder();
 	protected static CharsetEncoder ENCODER = CHARSET.newEncoder();
-	
-	public static final short ATTRIBUTE_LIST_EXTENSION = 2; 
-	public static final short SORT_EXTENSION = 0x4003; // decoder implemented, processing not
-	public static final short SELECT_EXTENSION = 0x4002; // decoder implemented, processing not
+
+	public static final short ATTRIBUTE_LIST_EXTENSION = 2;
+	public static final short SORT_EXTENSION = 0x4003; // decoder implemented,
+														// processing not
+	public static final short SELECT_EXTENSION = 0x4002; // decoder implemented,
+															// processing not
 
 	private short id;
 
 	private int length;
-	
-	
+
 	/*
-	0x0000-0x3FFF Standardized.  Optional to implement.  Ignore if
-     		unrecognized.
-	0x4000-0x7FFF Standardized.  Mandatory to implement.  A UA or SA
-     		which receives this option in a reply and does not understand
-     		it MUST silently discard the reply.  A DA or SA which receives
-     		this option in a request and does not understand it MUST return
-     		an OPTION_NOT_UNDERSTOOD error.
-	0x8000-0x8FFF For private use (not standardized).  Optional to
-     		implement.  Ignore if unrecognized.
-	0x9000-0xFFFF Reserved.
-	
-	*/
-	
-	public boolean isOptional(){
-		return (id<=0x3FFF || isPrivate());
-	}
-	
-	public boolean isMandatory(){
-		return ((id>=0x4000) && (id<=0x7FFF));
-	}
-	
-	public boolean isPrivate(){
-		return ((id>=0x8000) && (id<=0x8FFF));
-	}
-	
-	public boolean isReserved(){
-		return ((id>=0x9000) && (id<=0xFFFF));
-	}
-	
-
-	
-	
-	
-	
+	 * 0x0000-0x3FFF Standardized. Optional to implement. Ignore if
+	 * unrecognized. 0x4000-0x7FFF Standardized. Mandatory to implement. A UA or
+	 * SA which receives this option in a reply and does not understand it MUST
+	 * silently discard the reply. A DA or SA which receives this option in a
+	 * request and does not understand it MUST return an OPTION_NOT_UNDERSTOOD
+	 * error. 0x8000-0x8FFF For private use (not standardized). Optional to
+	 * implement. Ignore if unrecognized. 0x9000-0xFFFF Reserved.
+	 */
+
+	public boolean isOptional() {
+		return id <= 0x3FFF || isPrivate();
+	}
+
+	public boolean isMandatory() {
+		return id >= 0x4000 && id <= 0x7FFF;
+	}
+
+	public boolean isPrivate() {
+		return id >= 0x8000 && id <= 0x8FFF;
+	}
+
+	public boolean isReserved() {
+		return id >= 0x9000 && id <= 0xFFFF;
+	}
+
 	/**
 	 * Create a new SLP extension of the given id
 	 * 
 	 * @param id
-	 * 		the id
+	 *            the id
 	 */
-	public AbstractExtension(short id){
+	public AbstractExtension(final short id) {
 		this.id = id;
 	}
 
@@ -99,20 +90,18 @@
 	 * Sets the ID
 	 * 
 	 * @param id
-	 * 		the slp extension ID
+	 *            the slp extension ID
 	 */
-	public void setId(short id){
-		this.id=id;
+	public void setId(final short id) {
+		this.id = id;
 	}
 
-	
 	/**
 	 * Gets the ID
 	 * 
-	 * @return
-	 * 		the slp extension ID
+	 * @return the slp extension ID
 	 */
-	public short getId(){
+	public short getId() {
 		return id;
 	}
 
@@ -120,92 +109,93 @@
 	 * Sets the length in bytes
 	 * 
 	 * @param l
-	 * 		The length in bytes
+	 *            The length in bytes
 	 */
-	public void setLength(int l){
-		length=l;
+	public void setLength(final int l) {
+		length = l;
 	}
 
 	/**
 	 * Returns the length of the extension in bytes for encoding
 	 * 
-	 * @return
-	 * 		the length in bytes
+	 * @return the length in bytes
 	 */
-	public int getLength(){
+	public int getLength() {
 		return length;
 	}
 
-
 	/**
 	 * Encodes the extension body to the given buffer
 	 * 
 	 * @param buf
-	 * 			an IoBuffer used by MINA to build messages
+	 *            an IoBuffer used by MINA to build messages
 	 */
 	public abstract void encodeBody(final IoBuffer buf);
-	
-	
+
 	/**
-	 * Decodes the extension body from the given buffer to an SLP extension ibject of the given type with the given offset to the next extension
+	 * Decodes the extension body from the given buffer to an SLP extension
+	 * ibject of the given type with the given offset to the next extension
 	 * 
 	 * @param buf
-	 * 			The buffer containing the data to be decoded
+	 *            The buffer containing the data to be decoded
 	 * @param id
-	 * 			The SLP extension ID (decoded from header)
+	 *            The SLP extension ID (decoded from header)
 	 * @param nextOffset
-	 * 			The offset to the next extension (decoded from header)
+	 *            The offset to the next extension (decoded from header)
 	 * @throws Exception
 	 */
-	protected abstract void decodeBody(final IoBuffer buf, final short id, final int nextOffset) throws Exception;
+	protected abstract void decodeBody(final IoBuffer buf, final short id,
+			final int nextOffset) throws Exception;
 
-	
 	/**
 	 * Decodes the data in the given buffer to an SLP extension object
 	 * 
 	 *@param buf
-	 * 			The buffer containing the data to be decoded
+	 *            The buffer containing the data to be decoded
 	 * @param id
-	 * 			The SLP extension ID (decoded from header)
+	 *            The SLP extension ID (decoded from header)
 	 * @param nextOffset
-	 * 			The offset to the next extension (decoded from header)
+	 *            The offset to the next extension (decoded from header)
 	 * @return
 	 */
-	public static AbstractExtension decode(final IoBuffer buf, final short id, final int nextOffset){
+	public static AbstractExtension decode(final IoBuffer buf, final short id,
+			final int nextOffset) {
 		AbstractExtension ext;
-		switch(id){
+		switch (id) {
 		case ATTRIBUTE_LIST_EXTENSION:
-			try{
+			try {
 				ext = new AttributeListExtension();
-				ext = (AttributeListExtension) ext;
+				ext = ext;
 				ext.decodeBody(buf, id, nextOffset);
 				break;
-			} catch (Exception e){
-				SLPCore.getPlatform().logDebug("[Extensions]: Error decoding Attribute List Extension: "+e.getMessage());
+			} catch (final Exception e) {
+				SLPCore.getPlatform().logDebug(
+						"[Extensions]: Error decoding Attribute List Extension: "
+								+ e.getMessage());
 				ext = new UnsupportedExtension(id);
 			}
 		default:
 			ext = new UnsupportedExtension(id);
-		if (nextOffset>0){
-			buf.skip(nextOffset-buf.position());
-		} else {
-			buf.position(buf.limit());
-		}
+			if (nextOffset > 0) {
+				buf.skip(nextOffset - buf.position());
+			} else {
+				buf.position(buf.limit());
+			}
 		}
 		return ext;
 	}
 
 	/**
-	 * encodes a string to a buffer 
+	 * encodes a string to a buffer
 	 * 
 	 * @param out
-	 * 		The buffer into which the encoded string is to be written
+	 *            The buffer into which the encoded string is to be written
 	 * @param s
-	 * 		The string to encode
+	 *            The string to encode
 	 * @throws IOException
 	 */
 	protected static final void encodeString(final IoBuffer out, final String s)
-	throws IOException {
+			throws IOException {
 		out.putShort((short) s.length());
 		out.putString(s, ENCODER);
 	}
@@ -214,29 +204,29 @@
 	 * decodes a string from a buffer
 	 * 
 	 * @param in
-	 * 		The buffer containing the data
-	 * @return
-	 * 		The decoded string
+	 *            The buffer containing the data
+	 * @return The decoded string
 	 * @throws IOException
 	 */
-	protected static final String decodeString(final IoBuffer in) throws IOException {
+	protected static final String decodeString(final IoBuffer in)
+			throws IOException {
 		final short len = in.getShort();
 		return in.getString(len, DECODER);
 	}
-	
+
 	/**
 	 * verifies the extension if security is enabled
 	 * 
-	 * @return
-	 * 		True if verification passes, else false
+	 * @return True if verification passes, else false
 	 */
 	public abstract boolean verify();
-	
+
 	/**
-	 * Signs an extension using the specified SPI	
+	 * Signs an extension using the specified SPI
 	 * 
 	 * @param spi
-	 * 		The string representation of the SLP SPI to be ised for signing
+	 *            The string representation of the SLP SPI to be ised for
+	 *            signing
 	 * @throws ServiceLocationException
 	 */
 	public abstract void sign(String spi) throws ServiceLocationException;

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/AttributeListExtension.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/AttributeListExtension.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/AttributeListExtension.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/AttributeListExtension.java Tue Jun  9 12:50:45 2009
@@ -30,79 +30,74 @@
 import org.apache.directory.slp.impl.SLPUtils;
 import org.apache.mina.core.buffer.IoBuffer;
 
-
 /**
  * The attribute list extension for SLP as described in rfc 3059
  * 
  * @author Lorenz Breu
  */
-public class AttributeListExtension extends AbstractExtension{
-
-
-	/*The format of the Attribute List Extension is as follows:
-
-	       0                   1                   2                   3
-	       0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-	      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-	      |      Extension ID = 0x0002    |     Next Extension Offset     |
-	      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-	      | Offset, contd.|      Service URL Length       |  Service URL  /
-	      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-	      |     Attribute List Length     |         Attribute List        /
-	      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-	      |# of AttrAuths |-(if present) Attribute Authentication Blocks.../
-	      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+public class AttributeListExtension extends AbstractExtension {
 
-	   The Extension ID is 0x0002.
+	/*
+	 * The format of the Attribute List Extension is as follows:
+	 * 
+	 * 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+	 * Extension ID = 0x0002 | Next Extension Offset |
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+	 * Offset, contd.| Service URL Length | Service URL /
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+	 * Attribute List Length | Attribute List /
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |# of
+	 * AttrAuths |-(if present) Attribute Authentication Blocks.../
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+	 * 
+	 * The Extension ID is 0x0002.
 	 */
 
-
-
-
 	private int nextExtensionOffset;
 
 	private String url;
 
 	private String attributeList;
 
-	private AuthenticationBlock[] authBlocks = new AuthenticationBlock[]{};
+	private AuthenticationBlock[] authBlocks = new AuthenticationBlock[] {};
 
-	public AttributeListExtension(){
+	public AttributeListExtension() {
 		super(ATTRIBUTE_LIST_EXTENSION);
 	}
-	
-	public AttributeListExtension(String url, String attributes){
+
+	public AttributeListExtension(final String url, final String attributes) {
 		super(ATTRIBUTE_LIST_EXTENSION);
 		this.url = url;
-		this.attributeList = attributes;
+		attributeList = attributes;
 	}
 
-	public void setNextExtensionOffset(int neo){
+	public void setNextExtensionOffset(final int neo) {
 		nextExtensionOffset = neo;
 	}
 
-	public int getNextExtensionOffset(){
+	public int getNextExtensionOffset() {
 		return nextExtensionOffset;
 	}
 
-	public void setUrl(String serviceUrl){
+	public void setUrl(final String serviceUrl) {
 		url = serviceUrl;
 	}
 
-
-	public String getUrl(){
+	public String getUrl() {
 		return url;
 	}
 
-	public void setAttributeList(String attributeList){
+	public void setAttributeList(final String attributeList) {
 		this.attributeList = attributeList;
 	}
 
-	public String getAttributeList(){
+	public String getAttributeList() {
 		return attributeList;
 	}
 
-	public void setAuthenticationBlocks(AuthenticationBlock[] authenticationBlocks){
+	public void setAuthenticationBlocks(
+			final AuthenticationBlock[] authenticationBlocks) {
 		authBlocks = authenticationBlocks;
 	}
 
@@ -110,34 +105,37 @@
 		return authBlocks;
 	}
 
-
 	@Override
-	public int getLength(){
+	public int getLength() {
 		int authLength = 0;
-		for (AuthenticationBlock ab : authBlocks){
-			authLength+=ab.getLength();
+		for (final AuthenticationBlock ab : authBlocks) {
+			authLength += ab.getLength();
 		}
-		return (2 + 3 + 2 + url.length() + 2 + attributeList.length() + 1 + authLength);
+		return 2 + 3 + 2 + url.length() + 2 + attributeList.length() + 1
+				+ authLength;
 	}
 
-
-	protected void decodeBody(final IoBuffer buf, final short id, final int nextOffset) throws Exception{
+	@Override
+	protected void decodeBody(final IoBuffer buf, final short id,
+			final int nextOffset) throws Exception {
 		url = decodeString(buf);
 		attributeList = decodeString(buf);
-		authBlocks=decodeAuthBlocks(buf);
+		authBlocks = decodeAuthBlocks(buf);
 	}
 
-	public void encodeBody(IoBuffer buf){
+	@Override
+	public void encodeBody(final IoBuffer buf) {
 		try {
 			encodeString(buf, url);
 			encodeString(buf, attributeList);
 			encodeAuthBlocks(authBlocks, buf);
-		} catch (Exception e){
-			SLPCore.getPlatform().logDebug("[Extensions]: Error encoding an Attribute List Extension: " + e.getMessage());
+		} catch (final Exception e) {
+			SLPCore.getPlatform().logDebug(
+					"[Extensions]: Error encoding an Attribute List Extension: "
+							+ e.getMessage());
 		}
 	}
 
-
 	/**
 	 * 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Block
@@ -154,21 +152,22 @@
 	 * @param in
 	 * @return
 	 */
-	protected final AuthenticationBlock[] decodeAuthBlocks(final IoBuffer in) throws Exception {
-		final short blocks = (short) in.get();
+	protected final AuthenticationBlock[] decodeAuthBlocks(final IoBuffer in)
+			throws Exception {
+		final short blocks = in.get();
 		final AuthenticationBlock[] result = new AuthenticationBlock[blocks];
 		for (int i = 0; i < blocks; i++) {
-			final short bsd = (short) in.getShort();
+			final short bsd = in.getShort();
 			if (bsd != AuthenticationBlock.BSD_DSA) {
 				throw new ServiceLocationException(
 						ServiceLocationException.AUTHENTICATION_FAILED, "BSD "
-						+ bsd + " is not supported.");
+								+ bsd + " is not supported.");
 			}
 			final int size = in.getShort();
 			final int timestamp = in.getInt();
 			final String spi = decodeString(in);
 			final byte[] sig = new byte[size - 2 - 2 - 4 - 2
-			                            - spi.getBytes().length];
+					- spi.getBytes().length];
 			in.get(sig);
 			result[i] = new AuthenticationBlock(timestamp, spi, sig);
 		}
@@ -179,8 +178,8 @@
 	}
 
 	protected final void encodeAuthBlocks(
-			final AuthenticationBlock[] authBlocks,
-			final IoBuffer out) throws Exception {
+			final AuthenticationBlock[] authBlocks, final IoBuffer out)
+			throws Exception {
 		// FIXME: hack
 		if (authBlocks == null) {
 			out.put((byte) 0);
@@ -199,30 +198,31 @@
 		}
 	}
 
-	
+	@Override
 	public void sign(final String spiStr) throws ServiceLocationException {
-		List spiList = SLPUtils.stringToList(spiStr, ",");
+		final List spiList = SLPUtils.stringToList(spiStr, ",");
 		authBlocks = new AuthenticationBlock[spiList.size()];
 		for (int k = 0; k < spiList.size(); k++) {
-			int timestamp = SLPUtils.getTimestamp();
+			final int timestamp = SLPUtils.getTimestamp();
 
-			String spi = (String) spiList.get(k);
-			byte[] data = getAuthData(spi, timestamp);
+			final String spi = (String) spiList.get(k);
+			final byte[] data = getAuthData(spi, timestamp);
 			byte[] sig;
 			try {
-				sig = AuthenticationBlock.sign(spi,data);
-			} catch (Exception e) {
-				//SLPCore.platform.logError(e.getMessage(), e.fillInStackTrace());
+				sig = AuthenticationBlock.sign(spi, data);
+			} catch (final Exception e) {
+				// SLPCore.platform.logError(e.getMessage(),
+				// e.fillInStackTrace());
 				throw new ServiceLocationException(
 						ServiceLocationException.AUTHENTICATION_FAILED,
 						"Could not sign data");
 			}
-			
-			
-			authBlocks[k] = new AuthenticationBlock(timestamp,spi,sig);
+
+			authBlocks[k] = new AuthenticationBlock(timestamp, spi, sig);
 		}
 	}
-	
+
+	@Override
 	public boolean verify() {
 		try {
 			for (int i = 0; i < authBlocks.length; i++) {
@@ -233,27 +233,25 @@
 				}
 			}
 			return false;
-		} catch (ServiceLocationException sle){
+		} catch (final ServiceLocationException sle) {
 			return false;
 		}
 	}
-	
-	
-	private byte[] getAuthData(final String spiStr, final int timestamp)
-	throws ServiceLocationException {
-try {
-	ByteArrayOutputStream bos = new ByteArrayOutputStream();
-	DataOutputStream dos = new DataOutputStream(bos);
-	dos.writeUTF(spiStr);
-	dos.writeUTF(attributeList);
-	dos.writeInt(timestamp);
-	return bos.toByteArray();
-} catch (IOException ioe) {
-	throw new ServiceLocationException(
-			ServiceLocationException.INTERNAL_SYSTEM_ERROR, ioe
-					.getMessage());
-}
-}
 
+	private byte[] getAuthData(final String spiStr, final int timestamp)
+			throws ServiceLocationException {
+		try {
+			final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+			final DataOutputStream dos = new DataOutputStream(bos);
+			dos.writeUTF(spiStr);
+			dos.writeUTF(attributeList);
+			dos.writeInt(timestamp);
+			return bos.toByteArray();
+		} catch (final IOException ioe) {
+			throw new ServiceLocationException(
+					ServiceLocationException.INTERNAL_SYSTEM_ERROR, ioe
+							.getMessage());
+		}
+	}
 
 }

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/SelectExtension.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/SelectExtension.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/SelectExtension.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/SelectExtension.java Tue Jun  9 12:50:45 2009
@@ -23,8 +23,6 @@
 import org.apache.directory.slp.impl.SLPCore;
 import org.apache.mina.core.buffer.IoBuffer;
 
-
-
 /**
  * The select extension as defined in RFC 3421
  * 
@@ -32,52 +30,52 @@
  * 
  * @author Lorenz Breu
  */
-public class SelectExtension extends AbstractExtension{
+public class SelectExtension extends AbstractExtension {
 
-	
 	/*
-	 *  0                   1                   2                   3
-    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-   | Select Extension ID = 0x4002  |  Next Extension Offset (NEO)  |
-   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-   | NEO, cont'd   |      Number of URL Entries    |
-   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+	 * 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
+	 * Select Extension ID = 0x4002 | Next Extension Offset (NEO) |
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | NEO,
+	 * cont'd | Number of URL Entries |
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 	 */
-	
-	
+
 	// The number of entries to be returned
 	private short numberOfEntries = 0;
 
-	public SelectExtension(){
+	public SelectExtension() {
 		super(SELECT_EXTENSION);
 	}
-	
-	public SelectExtension(short n){
+
+	public SelectExtension(final short n) {
 		super(SELECT_EXTENSION);
 		numberOfEntries = n;
 	}
-	
+
 	@Override
-	protected void decodeBody(IoBuffer buf, short id, int nextOffset) throws Exception {
+	protected void decodeBody(final IoBuffer buf, final short id,
+			final int nextOffset) throws Exception {
 		numberOfEntries = buf.getShort();
-		
+
 	}
 
 	@Override
-	public void encodeBody(IoBuffer buf) {
+	public void encodeBody(final IoBuffer buf) {
 		try {
 			buf.putShort(numberOfEntries);
-		} catch (Exception e){
-			SLPCore.getPlatform().logDebug("[Extensions]: Error encoding a Select Extension: " + e.getMessage());
+		} catch (final Exception e) {
+			SLPCore.getPlatform().logDebug(
+					"[Extensions]: Error encoding a Select Extension: "
+							+ e.getMessage());
 		}
-		
+
 	}
 
 	@Override
-	public void sign(String spi) throws ServiceLocationException {
+	public void sign(final String spi) throws ServiceLocationException {
 		// TODO Auto-generated method stub
-		
+
 	}
 
 	@Override
@@ -89,7 +87,7 @@
 		return numberOfEntries;
 	}
 
-	public void setNumberOfEntries(short numberOfEntries) {
+	public void setNumberOfEntries(final short numberOfEntries) {
 		this.numberOfEntries = numberOfEntries;
 	}
 

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/SortExtension.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/SortExtension.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/SortExtension.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/SortExtension.java Tue Jun  9 12:50:45 2009
@@ -27,7 +27,6 @@
 import org.apache.directory.slp.impl.SLPUtils;
 import org.apache.mina.core.buffer.IoBuffer;
 
-
 /**
  * The sort extension as defined in RFC 3421
  * 
@@ -35,50 +34,52 @@
  * 
  * @author Lorenz Breu
  */
-public class SortExtension extends AbstractExtension{
-	
+public class SortExtension extends AbstractExtension {
+
 	/*
-	 *  0                   1                   2                   3
-    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-   |  Sort Extension ID = 0x4003   |  Next Extension Offset (NEO)  |
-   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-   | NEO, cont'd   |   length of <sort-key-list>   |<sort-key-list>\
-   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-	 * 
+	 * 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sort
+	 * Extension ID = 0x4003 | Next Extension Offset (NEO) |
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | NEO,
+	 * cont'd | length of <sort-key-list> |<sort-key-list>\
+	 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 	 */
-	
+
 	// The key list for sorting
 	private List<String> sortKeyList = new ArrayList<String>();
-	
-	public SortExtension(){
+
+	public SortExtension() {
 		super(SORT_EXTENSION);
 	}
-	
-	public SortExtension(String sortKeyList){
+
+	public SortExtension(final String sortKeyList) {
 		super(SORT_EXTENSION);
 		this.sortKeyList = SLPUtils.stringToList(sortKeyList, ",");
 	}
 
 	@Override
-	protected void decodeBody(IoBuffer buf, short id, int nextOffset) throws Exception {
+	protected void decodeBody(final IoBuffer buf, final short id,
+			final int nextOffset) throws Exception {
 		sortKeyList = SLPUtils.stringToList(decodeString(buf), ",");
-		
+
 	}
 
 	@Override
-	public void encodeBody(IoBuffer buf) {
-		try{
-		encodeString(buf, SLPUtils.arrayToString(SLPUtils.listToStringArray(sortKeyList),","));
-		} catch (Exception e){
-			SLPCore.getPlatform().logDebug("[Extensions]: Error encoding a Sort Extension: " + e.getMessage());
+	public void encodeBody(final IoBuffer buf) {
+		try {
+			encodeString(buf, SLPUtils.arrayToString(SLPUtils
+					.listToStringArray(sortKeyList), ","));
+		} catch (final Exception e) {
+			SLPCore.getPlatform().logDebug(
+					"[Extensions]: Error encoding a Sort Extension: "
+							+ e.getMessage());
 		}
 	}
 
 	@Override
-	public void sign(String spi) throws ServiceLocationException {
+	public void sign(final String spi) throws ServiceLocationException {
 		return;
-		
+
 	}
 
 	@Override
@@ -90,7 +91,7 @@
 		return sortKeyList;
 	}
 
-	public void setSortKeyList(List<String> sortKeyList) {
+	public void setSortKeyList(final List<String> sortKeyList) {
 		this.sortKeyList = sortKeyList;
 	}
 

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/UnsupportedExtension.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/UnsupportedExtension.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/UnsupportedExtension.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/extensions/UnsupportedExtension.java Tue Jun  9 12:50:45 2009
@@ -26,35 +26,31 @@
  * 
  * @author Lorenz Breu
  */
-public class UnsupportedExtension extends AbstractExtension{
+public class UnsupportedExtension extends AbstractExtension {
 
-	public UnsupportedExtension(short id){
+	public UnsupportedExtension(final short id) {
 		super(id);
 	}
 
 	@Override
-	protected void decodeBody(IoBuffer buf, short id, int nextOffset) throws Exception {
-		
-		
+	protected void decodeBody(final IoBuffer buf, final short id,
+			final int nextOffset) throws Exception {
+
 	}
 
 	@Override
-	public void encodeBody(IoBuffer buf) {
-		
-		
+	public void encodeBody(final IoBuffer buf) {
+
 	}
-	
-	
-	public boolean verify(){
+
+	@Override
+	public boolean verify() {
 		return true;
 	}
-	
-	public void sign(String spi){
-		
-	}
-	
-	
-	
 
+	@Override
+	public void sign(final String spi) {
+
+	}
 
 }

Modified: directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/Activator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/Activator.java?rev=782980&r1=782979&r2=782980&view=diff
==============================================================================
--- directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/Activator.java (original)
+++ directory/sandbox/slp/src/main/java/org/apache/directory/slp/impl/Activator.java Tue Jun  9 12:50:45 2009
@@ -44,46 +44,61 @@
 		// create the platform abstraction layer but do not initialize!!!
 		SLPCore.platform = new OSGiPlatformAbstraction(context);
 
-		// register the service factories so each consumer gets its own Locator/Activator instance
-		context.registerService("ch.ethz.iks.slp.Advertiser", new ServiceFactory() {
-			public Object getService(Bundle bundle, ServiceRegistration registration) {
-				SLPCore.initSA();
-				return new AdvertiserImpl();
-			}
-			public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
-			}
-		}, null);
-		context.registerService("ch.ethz.iks.slp.Locator", new ServiceFactory() {
-			public Object getService(Bundle bundle, ServiceRegistration registration) {
-				SLPCore.init();
-				return new LocatorImpl();
-			}
-			public void ungetService(Bundle bundle,	ServiceRegistration registration, Object service) {
-			}
-		}, null);
-		
-		
-		
-		
-        final ServiceStore finalStore = new SimpleServiceStore();
-		context.registerService("ch.ethz.iks.slp.DirectoryAgent", new ServiceFactory() {
-			public Object getService(Bundle bundle, ServiceRegistration registration) {
-				SLPCore.initDA(finalStore);
-				return new DirectoryAgentImpl();
-			}
-			public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
-			}
-		}, null);
-		
-		
-//		context.registerService("ch.ethz.iks.slp.DirectoryAgent", new ServiceFactory() {
-//			public Object getService(Bundle bundle, ServiceRegistration registration) {
-//				SLPCore.initDA(new SimpleServiceStore());
-//				return new DirectoryAgentImpl();
-//			}
-//			public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
-//			}
-//		}, null);
+		// register the service factories so each consumer gets its own
+		// Locator/Activator instance
+		context.registerService("ch.ethz.iks.slp.Advertiser",
+				new ServiceFactory() {
+					public Object getService(final Bundle bundle,
+							final ServiceRegistration registration) {
+						SLPCore.initSA();
+						return new AdvertiserImpl();
+					}
+
+					public void ungetService(final Bundle bundle,
+							final ServiceRegistration registration,
+							final Object service) {
+					}
+				}, null);
+		context.registerService("ch.ethz.iks.slp.Locator",
+				new ServiceFactory() {
+					public Object getService(final Bundle bundle,
+							final ServiceRegistration registration) {
+						SLPCore.init();
+						return new LocatorImpl();
+					}
+
+					public void ungetService(final Bundle bundle,
+							final ServiceRegistration registration,
+							final Object service) {
+					}
+				}, null);
+
+		final ServiceStore finalStore = new SimpleServiceStore();
+		context.registerService("ch.ethz.iks.slp.DirectoryAgent",
+				new ServiceFactory() {
+					public Object getService(final Bundle bundle,
+							final ServiceRegistration registration) {
+						SLPCore.initDA(finalStore);
+						return new DirectoryAgentImpl();
+					}
+
+					public void ungetService(final Bundle bundle,
+							final ServiceRegistration registration,
+							final Object service) {
+					}
+				}, null);
+
+		// context.registerService("ch.ethz.iks.slp.DirectoryAgent", new
+		// ServiceFactory() {
+		// public Object getService(Bundle bundle, ServiceRegistration
+		// registration) {
+		// SLPCore.initDA(new SimpleServiceStore());
+		// return new DirectoryAgentImpl();
+		// }
+		// public void ungetService(Bundle bundle, ServiceRegistration
+		// registration, Object service) {
+		// }
+		// }, null);
 	}
 
 	/**
@@ -91,6 +106,6 @@
 	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
 	 */
 	public void stop(final BundleContext context) throws Exception {
-		
+
 	}
 }



Mime
View raw message