Java tutorial
/** * Copyright 2014 Otto (GmbH & Co KG) * * 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 com.ottogroup.bi.asap.component.strategy; import java.util.Properties; import org.apache.commons.lang3.StringUtils; import com.ottogroup.bi.asap.exception.RequiredInputMissingException; import com.ottogroup.bi.asap.mailbox.Mailbox; /** * Applies {@link Thread#yield()} as wait strategy * @author mnxfst * @since Dec 14, 2014 */ public class YieldMessageWaitStrategy implements MessageWaitStrategy { public static final String CFG_COMPONENT_ID = "id"; private String id = null; /** * @see com.ottogroup.bi.asap.component.Component#init(java.util.Properties) */ public void init(Properties settings) throws RequiredInputMissingException { this.id = settings.getProperty(CFG_COMPONENT_ID); if (StringUtils.isBlank(this.id)) throw new RequiredInputMissingException("Missing required input for '" + CFG_COMPONENT_ID + "'"); } /** * @see com.mnxfst.distos.strategy.MessageWaitStrategy#waitFor() */ public void waitFor() throws InterruptedException { Thread.yield(); } /** * @see com.ottogroup.bi.asap.component.Component#shutdown() */ public boolean shutdown() { return true; } /** * @see com.ottogroup.bi.asap.component.strategy.MessageWaitStrategy#setMailbox(com.ottogroup.bi.asap.mailbox.Mailbox) */ public void setMailbox(Mailbox mailbox) { } /** * @see com.ottogroup.bi.asap.component.Component#getId() */ public String getId() { return this.id; } /** * @see com.ottogroup.bi.asap.component.Component#setId(java.lang.String) */ public void setId(String id) { this.id = id; } }