Methods Summary |
---|
public abstract void | abort(EntryContext context)Abort the servicegroup. Unused. For future!
|
public void | abortChildren(EntryContext context)
Iterator it = serviceGroupIterator();
while (it.hasNext()) {
ServiceGroup sg = (ServiceGroup) it.next();
if (sg.getState() != STOPPED) {
sg.abort(context);
}
}
|
public void | addServiceGroup(com.sun.enterprise.server.ondemand.ServiceGroup group)Add a servicegroup as child of this servicegroup.
sgList.add(group);
|
public static void | addServiceGroupListener(ServiceGroupListener listener)
listeners.add(listener);
|
public abstract boolean | analyseEntryContext(EntryContext context)Analyse the entrycontext and specifies whether this servicegroup
can be started or not.
|
public int | getState()Return the state of the servicegroup.
return this.state;
|
public boolean | isNotified(EntryContext context)If atleast one of the servicegroup that need to be started
is interested in this context, then the servicegroup is
not notified.
Iterator it = serviceGroupIterator();
while (it.hasNext()) {
final ServiceGroup sg = (ServiceGroup) it.next();
if (sg.getState() != STARTED) {
if (sg.analyseEntryContext(context)) {
return false;
}
}
}
return true;
|
private void | notifyListener(int state, com.sun.enterprise.server.ondemand.ServiceGroup sg)
listeners = new ArrayList();
String extListener =
System.getProperty("com.sun.enterprise.server.ondemand.ExternalListener");
if(extListener != null) {
try {
ServiceGroupListener servicegrouplistener =
(ServiceGroupListener)Class.forName(extListener).newInstance();
listeners.add(servicegrouplistener);
} catch(Throwable t) {
t.printStackTrace();
}
}
for (ServiceGroupListener l : listeners) {
try {
switch (state) {
case STARTING :
l.beforeStart(sg.getClass().getName());
break;
case STARTED :
l.afterStart(sg.getClass().getName());
}
} catch (Throwable t) {
t.printStackTrace();
}
}
|
private void | postInvoke(com.sun.enterprise.ComponentInvocation dummy)See the comment on preInvoke.
InvocationManager im = Switch.getSwitch().getInvocationManager();
im.postInvoke(dummy);
|
private com.sun.enterprise.ComponentInvocation | preInvoke()The preInvoke is used to insert a dummy invocation context to the
invocation chain for everything that happens within the service
startup. This is detected by the InvocationManager and the
threads created from within this context will not inherit the
context of the parent.
This is required since an application thread might end up in starting
a container. Thread pools managed by that container should not
inherit the properties by the application, since both are unrelated.
InvocationManager im = Switch.getSwitch().getInvocationManager();
ComponentInvocation dummy =
new ComponentInvocation(ComponentInvocation.SERVICE_STARTUP);
im.preInvoke(dummy);
return dummy;
|
public void | removeServiceGroup(com.sun.enterprise.server.ondemand.ServiceGroup group)Remove a servicegroup from its children.
sgList.remove(group);
|
public static void | removeServiceGroupListener(ServiceGroupListener listener)
listeners.remove(listener);
|
public java.util.Iterator | serviceGroupIterator()Iterator of children.
return sgList.iterator();
|
public void | setState(int state)Set the state of the servicegroup.
this.state = state;
|
public abstract void | start(EntryContext context)Triggers the start of the servicegroup. The entry context
that caused this startup is used by the servicegroup to obtain
any startup information it require.
|
public void | startChildren(EntryContext context)Logic to start all children based on entrycontext, If any of the child
recognises the entrycontext, then this will attempt to start that
servicegroup.
Iterator it = serviceGroupIterator();
while (it.hasNext()) {
final ServiceGroup sg = (ServiceGroup) it.next();
if (_logger.isLoggable(Level.FINER)) {
_logger.finer("Trying " + sg + " servicegroup");
}
if (sg.getState() != STARTED) {
if (sg.analyseEntryContext(context)) {
synchronized (sg) {
if (sg.getState() == NOTSTARTED) {
sg.setState(STARTING);
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Starting " + sg + " servicegroup with context :" + context);
}
notifyListener(STARTING, sg);
ComponentInvocation dummy = preInvoke();
try {
AccessController.doPrivileged
(new PrivilegedExceptionAction() {
public Object run() throws Exception {
sg.start(context);
return null;
}
});
} catch (PrivilegedActionException pae) {
throw new ServiceGroupException(
pae.getException());
} finally {
postInvoke(dummy);
}
notifyListener(STARTED, sg);
sg.setState(STARTED);
}
}
}
}
}
|
protected void | startLifecycleServices(java.lang.String[][] s, com.sun.enterprise.server.ServerContext sc)
services = new ServerLifecycle[s.length];
for (int i =0; i < s.length; i ++) {
try {
String service = s[i][1];
ServerLifecycle slc = (ServerLifecycle)
Class.forName(service).newInstance();
services[i] = slc;
slc.onInitialization(sc);
} catch (Exception e) {
_logger.log(Level.WARNING, e.getMessage(), e);
}
}
for (ServerLifecycle slc : services) {
try {
slc.onStartup(sc);
} catch (Exception e) {
e.printStackTrace();
}
}
for (ServerLifecycle slc : services) {
try {
slc.onReady(sc);
} catch (Exception e) {
_logger.log(Level.WARNING, e.getMessage(), e);
}
}
|
public abstract void | stop(EntryContext context)Stop the servicegroup.
|
public void | stopChildren(EntryContext context)
Iterator it = serviceGroupIterator();
while (it.hasNext()) {
ServiceGroup sg = (ServiceGroup) it.next();
if (sg.getState() != STOPPED && sg.getState() != NOTSTARTED) {
sg.stop(context);
}
}
|
protected void | stopLifecycleServices()
for (ServerLifecycle slc : services) {
try {
slc.onShutdown();
} catch (Exception e) {
_logger.log(Level.WARNING, e.getMessage(), e);
}
}
for (ServerLifecycle slc : services) {
try {
slc.onTermination();
} catch (Exception e) {
_logger.log(Level.WARNING, e.getMessage(), e);
}
}
|