Author: rhauch
Date: 2008-05-28 13:31:16 -0400 (Wed, 28 May 2008)
New Revision: 208
Modified:
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java
branches/federation/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties
Log:
Slight refactoring of the ServiceAdministrator base class.
Modified:
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java
===================================================================
---
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java 2008-05-28
17:20:32 UTC (rev 207)
+++
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java 2008-05-28
17:31:16 UTC (rev 208)
@@ -95,21 +95,13 @@
protected class Administrator extends AbstractServiceAdministrator {
protected Administrator() {
- super(State.STARTED);
+ super(RepositoryI18n.observationServiceName, State.STARTED);
}
/**
* {@inheritDoc}
*/
@Override
- protected String serviceName() {
- return "ObservationService";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
protected void doShutdown( State fromState ) {
super.doShutdown(fromState);
shutdownService();
Modified:
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java
===================================================================
---
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java 2008-05-28
17:20:32 UTC (rev 207)
+++
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java 2008-05-28
17:31:16 UTC (rev 208)
@@ -84,21 +84,13 @@
protected class Administrator extends AbstractServiceAdministrator {
protected Administrator() {
- super(State.PAUSED);
+ super(RepositoryI18n.ruleServiceName, State.PAUSED);
}
/**
* {@inheritDoc}
*/
@Override
- protected String serviceName() {
- return "RuleService";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
protected void doShutdown( State fromState ) {
super.doShutdown(fromState);
// Remove all rule sets ...
Modified:
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java
===================================================================
---
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java 2008-05-28
17:20:32 UTC (rev 207)
+++
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencingService.java 2008-05-28
17:31:16 UTC (rev 208)
@@ -149,21 +149,13 @@
protected class Administrator extends AbstractServiceAdministrator {
protected Administrator() {
- super(State.PAUSED);
+ super(RepositoryI18n.sequencingServiceName, State.PAUSED);
}
/**
* {@inheritDoc}
*/
@Override
- protected String serviceName() {
- return RepositoryI18n.sequencingServiceName.text();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
protected void doStart( State fromState ) {
super.doStart(fromState);
startService();
Modified:
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java
===================================================================
---
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java 2008-05-28
17:20:32 UTC (rev 207)
+++
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/services/AbstractServiceAdministrator.java 2008-05-28
17:31:16 UTC (rev 208)
@@ -21,9 +21,11 @@
*/
package org.jboss.dna.repository.services;
-import org.jboss.dna.repository.RepositoryI18n;
+import java.util.Locale;
import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.repository.RepositoryI18n;
/**
* Simple abstract implementation of the service administrator interface that can be
easily subclassed by services that require an
@@ -34,10 +36,13 @@
public abstract class AbstractServiceAdministrator implements ServiceAdministrator {
private volatile State state;
+ private final I18n serviceName;
- protected AbstractServiceAdministrator( State initialState ) {
+ protected AbstractServiceAdministrator( I18n serviceName, State initialState ) {
assert initialState != null;
+ assert serviceName != null;
this.state = initialState;
+ this.serviceName = serviceName;
}
/**
@@ -102,7 +107,7 @@
* @see #isStarted()
*/
public synchronized ServiceAdministrator start() {
- if (isShutdown()) throw new
IllegalStateException(RepositoryI18n.serviceShutdowAndMayNotBeStarted.text(serviceName()));
+ if (isShutdown()) throw new
IllegalStateException(RepositoryI18n.serviceShutdowAndMayNotBeStarted.text(getServiceName()));
if (this.state != State.STARTED) {
doStart(this.state);
this.state = State.STARTED;
@@ -131,7 +136,7 @@
* @see #isPaused()
*/
public synchronized ServiceAdministrator pause() {
- if (isShutdown()) throw new
IllegalStateException(RepositoryI18n.serviceShutdowAndMayNotBePaused.text(serviceName()));
+ if (isShutdown()) throw new
IllegalStateException(RepositoryI18n.serviceShutdowAndMayNotBePaused.text(getServiceName()));
if (this.state != State.PAUSED) {
doPause(this.state);
this.state = State.PAUSED;
@@ -212,5 +217,20 @@
return this.state == State.SHUTDOWN;
}
- protected abstract String serviceName();
+ /**
+ * Get the name of this service in the current locale.
+ * @return the service name
+ */
+ public String getServiceName() {
+ return this.serviceName.text();
+ }
+
+ /**
+ * Get the name of this service in the specified locale.
+ * @param locale the locale in which the service name is to be returned; may be null
if the default locale is to be used
+ * @return the service name
+ */
+ public String getServiceName( Locale locale ) {
+ return this.serviceName.text(locale);
+ }
}
Modified:
branches/federation/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties
===================================================================
---
branches/federation/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties 2008-05-28
17:20:32 UTC (rev 207)
+++
branches/federation/dna-repository/src/main/resources/org/jboss/dna/repository/RepositoryI18n.properties 2008-05-28
17:31:16 UTC (rev 208)
@@ -28,6 +28,9 @@
errorObtainingSessionToRepositoryWorkspace = Error obtaining JCR session to repository
workspace {0}
errorWritingProblemsOnRuleSet = Error while writing problems on rule set node {0}
+observationServiceName = Observation Service;
+ruleServiceName = Rule Service
+
sequencingServiceName = Sequencing Service
unableToChangeExecutionContextWhileRunning = Unable to change the execution context while
running
unableToStartSequencingServiceWithoutExecutionContext = Unable to start the Sequencing
Service without an execution context
Show replies by date