From: changhyun1.lee Date: Fri, 21 Feb 2014 07:59:15 +0000 (+0900) Subject: LIVERELOAD: Fixed indentation X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7af9cccb3c6d2fb588108f45722835781ba674ff;p=sdk%2Fide%2Fcommon-eplugin.git LIVERELOAD: Fixed indentation Change-Id: Ida623113fad86f6dfbc74c5ca395731086c5df51 Signed-off-by: changhyun1.lee --- diff --git a/org.tizen.common/src/org/tizen/common/daemon/AbstractServer.java b/org.tizen.common/src/org/tizen/common/daemon/AbstractServer.java index aae5780..173fb41 100755 --- a/org.tizen.common/src/org/tizen/common/daemon/AbstractServer.java +++ b/org.tizen.common/src/org/tizen/common/daemon/AbstractServer.java @@ -39,70 +39,60 @@ import org.slf4j.LoggerFactory; * @author BonYong Lee{@literal } (S-Core) * */ -abstract public class -AbstractServer -implements Server, Runnable -{ +abstract public class AbstractServer implements Server, Runnable { + /** * logger for this object */ protected final Logger logger = LoggerFactory.getLogger( getClass() ); - + /** * {@link Thread} to use in this server */ protected Thread thread = null; - + /** * lock for #state */ protected Lock lock = new ReentrantLock(); - + /** * server state * @see ServerState */ protected ServerState state = ServerState.Terminated; - + /** * Server name to use thread name */ protected final String name; - + /** * default constructor */ - public AbstractServer() - { + public AbstractServer() { this( null ); } - + /** * constructor with name * * @param name server name */ - public - AbstractServer( - final String name - ) - { + public AbstractServer( final String name ) { this.name = name; } - + /** * return server name * @return server name * * @see #name */ - public - String - getName() - { + public String getName() { return name; } - + /** * return server status * @return server status @@ -110,21 +100,15 @@ implements Server, Runnable * @see #state * @see ServerState */ - public - ServerState - getStatus() - { + public ServerState getStatus() { lock.lock(); - try - { + try { return this.state; - } - finally - { + } finally { lock.unlock(); } } - + /** * Change server state * @@ -133,27 +117,18 @@ implements Server, Runnable * @see #state * @see ServerState */ - protected - void - setStatus( - final ServerState state - ) - { + protected void setStatus( final ServerState state ) { lock.lock(); - try - { + try { this.state = state; - } - finally - { + } finally { lock.unlock(); - synchronized ( this ) - { + synchronized ( this ) { this.notifyAll(); } } } - + /** * check server state is one of states * @@ -161,135 +136,91 @@ implements Server, Runnable * * @return boolean value if server state is one of states */ - public - boolean - isState( - final ServerState... states - ) - { + public boolean isState( final ServerState... states ) { lock.lock(); - try - { - for ( final ServerState state : states ) - { - if ( this.state.equals( state ) ) - { + try { + for ( final ServerState state : states ) { + if ( this.state.equals( state ) ) { return true; } } return false; - } - finally - { + } finally { lock.unlock(); } } - + /** * wait until server state become one of states * * @param states server states */ - public - void - waitState( - final ServerState... states - ) - { + public void waitState( final ServerState... states ) { while ( !isState( states ) ) { - try - { - synchronized ( this ) - { + try { + synchronized ( this ) { this.wait(); } - } catch ( final InterruptedException e ) - { + } catch ( final InterruptedException e ) { + logger.error(e.getMessage(), e); } } } - - /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override - public - void - run() - { - if ( isState( ServerState.Halting ) ) - { + public void run() { + if ( isState( ServerState.Halting ) ) { setStatus( ServerState.Terminated ); return ; } - try - { + try { initialize(); - + lock.lock(); - try - { - if ( isState( ServerState.Halting ) ) - { + try { + if ( isState( ServerState.Halting ) ) { return ; } setStatus( ServerState.Running ); - } - finally - { + } finally { lock.unlock(); } - while ( !isState( ServerState.Halting ) ) - { + + while ( !isState( ServerState.Halting ) ) { process(); } - } - catch ( Exception e ) - { + } catch ( Exception e ) { logger.error( "Error occurred:", e ); - } - finally - { + } finally { terminate(); setStatus( ServerState.Terminated ); } - } /* (non-Javadoc) * @see org.tizen.common.daemon.Server#boot() */ @Override - public - void - boot() - throws ServerException - { + public void boot() throws ServerException { lock.lock(); - try - { - if ( !isState( ServerState.Terminated ) ) - { + try { + if ( !isState( ServerState.Terminated ) ) { throw new IllegalStateException(); } - + final String name = getName(); - if ( null == name ) - { + if ( null == name ) { thread = new Thread( this ); - } - else - { + } else { thread = new Thread( this, name ); } thread.setDaemon( true ); thread.start(); setStatus( ServerState.Initializing ); - } - finally - { + } finally { lock.unlock(); } } @@ -298,24 +229,16 @@ implements Server, Runnable * @see org.tizen.common.daemon.Server#down() */ @Override - public - void - down() - throws ServerException - { + public void down() throws ServerException { lock.lock(); - try - { + try { if ( isState( ServerState.Terminated, ServerState.Halting ) ) { throw new IllegalStateException(); } setStatus( ServerState.Halting ); - } - finally - { + } finally { lock.unlock(); } - } /** @@ -324,16 +247,17 @@ implements Server, Runnable * @throws Exception If exception is occurred */ abstract protected void initialize() throws ServerException; - + /** * Unit process of main job * * @throws Exception If exception is occurred */ abstract protected void process() throws Exception; - + /** * Server clean-up process */ abstract protected void terminate(); + } diff --git a/org.tizen.common/src/org/tizen/common/daemon/Server.java b/org.tizen.common/src/org/tizen/common/daemon/Server.java index d0aa687..64990cf 100755 --- a/org.tizen.common/src/org/tizen/common/daemon/Server.java +++ b/org.tizen.common/src/org/tizen/common/daemon/Server.java @@ -34,16 +34,15 @@ package org.tizen.common.daemon; * * @author BonYong Lee{@literal } (S-Core) */ -public interface -Server -{ +public interface Server { + /** * boot daemon up * * @throws ServerException If process is failed */ void boot() throws ServerException; - + /** * shut daemon down * @throws ServerException If process is failed diff --git a/org.tizen.common/src/org/tizen/common/daemon/ServerState.java b/org.tizen.common/src/org/tizen/common/daemon/ServerState.java index 949f00d..693bd16 100755 --- a/org.tizen.common/src/org/tizen/common/daemon/ServerState.java +++ b/org.tizen.common/src/org/tizen/common/daemon/ServerState.java @@ -38,26 +38,24 @@ package org.tizen.common.daemon; * @author BonYong Lee{@literal } (S-Core) * */ -public enum ServerState -{ +public enum ServerState { /** * Stopped state */ Terminated, - + /** * State to request boot */ Initializing, - + /** * State to run */ Running, - + /** * State to request down */ Halting - } diff --git a/org.tizen.common/src/org/tizen/common/util/DeferredTaskManager.java b/org.tizen.common/src/org/tizen/common/util/DeferredTaskManager.java index c8e167e..d58ad8c 100755 --- a/org.tizen.common/src/org/tizen/common/util/DeferredTaskManager.java +++ b/org.tizen.common/src/org/tizen/common/util/DeferredTaskManager.java @@ -43,41 +43,39 @@ import org.slf4j.LoggerFactory; * * @author BonYong Lee{@literal } (S-Core) */ -public class -DeferredTaskManager -{ +public class DeferredTaskManager { /** * Default value for idle time * * 3 seconds */ protected static final long DEFAULT_IDLE_TIME = 3 * 1000; - + /** * Logger for this class */ protected final Logger logger = LoggerFactory.getLogger( getClass() ); - + /** * Idle time */ protected long idleTime; - + /** * last scheduled time */ protected long scheduledTime = DEFAULT_IDLE_TIME; - + /** * timer for schedule */ protected Timer timer = null; - + /** * Task */ protected final Runnable task; - + /** * Constructor with task * @@ -85,14 +83,10 @@ DeferredTaskManager * * @see #DefferedTaskManager(Runnable, long) */ - public - DeferredTaskManager( - final Runnable task - ) - { + public DeferredTaskManager( final Runnable task ) { this( task, DEFAULT_IDLE_TIME ); } - + /** * Constructor with task and ide time * @@ -101,28 +95,20 @@ DeferredTaskManager * * @see #setIdleTime(long) */ - public - DeferredTaskManager( - final Runnable task, - final long idleTime - ) - { + public DeferredTaskManager( final Runnable task, final long idleTime ) { // Fast-fail notNull( task ); this.task = task; this.idleTime = idleTime; logger.debug( "Idle time: {}", idleTime ); } - + /** * Return idle time for deferring * * @return idle time */ - synchronized public - long - getIdleTime() - { + synchronized public long getIdleTime() { return this.idleTime; } @@ -131,72 +117,50 @@ DeferredTaskManager * * @param idleTime time to wait */ - synchronized public - void - setIdleTime( final long idleTime ) - { + synchronized public void setIdleTime( final long idleTime ) { this.idleTime = idleTime; - - if ( null != this.timer ) - { + + if ( null != this.timer ) { schedule( this.idleTime + this.scheduledTime - System.currentTimeMillis() ); } - } - + /** * Schedule to run task after {@code delay} * * @param delay delay time in milliseconds */ - synchronized public - void - schedule( long delay ) - { + synchronized public void schedule( long delay ) { cancel(); - if ( 0 < delay ) - { + if ( 0 < delay ) { this.timer = new Timer(); scheduledTime = System.currentTimeMillis(); - this.timer.schedule( new TimerTask() - { - + this.timer.schedule( new TimerTask() { @Override - public void run() - { + public void run() { task.run(); logger.debug( "{} was run", task ); } }, delay ); logger.debug( "{} will be run after {}", task, delay ); - } - else - { + } else { task.run(); logger.debug( "{} was run", task ); } - } - + /** * Notify any change */ - synchronized public - void - tick() - { + synchronized public void tick() { schedule( this.idleTime ); } - + /** * Cancel scheduled task */ - synchronized public - void - cancel() - { - if ( null != timer ) - { + synchronized public void cancel() { + if ( null != timer ) { timer.cancel(); timer = null; logger.debug( "{} canceled", task );