org.atmosphere.config.managed.Encoder Maven / Gradle / Ivy
/*
* Copyright 2015 Async-IO.org
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.atmosphere.config.managed;
/**
* Encode a message returned by a method annotated with {@link org.atmosphere.config.service.Message} or a {@link org.atmosphere.config.service.ManagedService}
* annotated class. The encoded object will be written back to the client. For example
*
*
public final static class StringBufferEncoder implements Encoder>StringBuffer, String< {
@Override
public String encode(StringBuffer s) {
return s.toString() + "-yo!";
}
}
*
* will encode a StringBuffer into a String. The StringBuffer will be the object returned when a method annotated with @Message is invoked
*
@Message(encoders = {StringBufferEncoder.class})
public StringBuffer encode(String m) {
return new StringBuffer(m);
}
*
* You can chain Encoders by defining more than one. They will be invoked in the order they have been added and the last Encoder's value
* will be used for the write operation.
*
* @author Jeanfrancois Arcand
*/
public interface Encoder {
/**
* Encode the object of type U into an object of type T.
* @param s an object that has already been encoded or returned from an @Message annotated class.
* @return an encoded object.
*/
T encode(U s);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy