Skip to content

Commit

Permalink
Inital timer service implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Aug 8, 2011
1 parent b0a1500 commit 01924ed
Show file tree
Hide file tree
Showing 118 changed files with 5,146 additions and 932 deletions.
7 changes: 7 additions & 0 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@
<!-- TODO: this is not the final API -->
<maven-resource group="org.jboss.ejb3" artifact="jboss-ejb3-ext-api"/>


<maven-resource group="org.jboss.ejb3.context" artifact="jboss-ejb3-context-base"/>
<maven-resource group="org.jboss.ejb3.context" artifact="jboss-ejb3-context-spi"/>

Expand All @@ -656,6 +657,12 @@
<maven-resource group="org.jboss.ejb3.tx2" artifact="jboss-ejb3-tx2-spi"/>
</module-def>

<module-def name="org.jboss.ejb3.timerservice">
<maven-resource group="org.jboss.ejb3.timerservice" artifact="ejb31-calendar-expr-parser"/>
<maven-resource group="org.jboss.ejb3.timerservice" artifact="jboss-ejb3-timerservice-api"/>
<maven-resource group="org.jboss.ejb3.timerservice" artifact="jboss-ejb3-timerservice-mk2"/>
</module-def>

<module-def name="org.jboss.integration.ext-content">
<!-- Bundling external content into deployments -->
</module-def>
Expand Down
15 changes: 15 additions & 0 deletions build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,21 @@
<artifactId>jboss-ejb3-effigy-int2</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.ejb3.timerservice</groupId>
<artifactId>ejb31-calendar-expr-parser</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.ejb3.timerservice</groupId>
<artifactId>jboss-ejb3-timerservice-api</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.ejb3.timerservice</groupId>
<artifactId>jboss-ejb3-timerservice-mk2</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.ejb3.tx2</groupId>
<artifactId>jboss-ejb3-tx2-impl</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions build/src/main/resources/docs/schema/jboss-as-ee_1_0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
<xs:element name="subsystem" type="subsystem"/>

<xs:complexType name="subsystem">
<xs:choice>
<xs:sequence>
<xs:element name="global-modules" type="modulesType" minOccurs="0" maxOccurs="1"/>
<xs:element name="ear-subdeployments-isolated" default="false" type="ear-subdeployments-isolatedType" minOccurs="0" maxOccurs="1"/>
</xs:choice>
</xs:sequence>
</xs:complexType>

<xs:complexType name="modulesType">
Expand Down
32 changes: 26 additions & 6 deletions build/src/main/resources/docs/schema/jboss-as-ejb3_1_0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,35 @@
-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:jboss:domain:ejb3:1.0"
xmlns="urn:jboss:domain:ejb3:1.0"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0">
targetNamespace="urn:jboss:domain:ejb3:1.0"
xmlns="urn:jboss:domain:ejb3:1.0"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0">

<!-- The ejb3 subsystem root element -->
<xs:element name="subsystem" type="subsystem"/>

<xs:complexType name="subsystem"/>
<xs:complexType name="subsystem">
<xs:sequence>
<xs:element name="timer-service" type="timerServiceType" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="timerServiceType">
<xs:sequence>
<xs:element name="thread-pool" type="threadPoolType" minOccurs="0" maxOccurs="1"/>
<xs:element name="data-store" type="dataStoreType" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="threadPoolType">
<xs:attribute name="core-threads" type="xs:int"/>
</xs:complexType>

<xs:complexType name="dataStoreType">
<xs:attribute name="path" type="xs:string" />
<xs:attribute name="relative-to" type="xs:string" />
</xs:complexType>

</xs:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@
</datasources>
</subsystem>
<subsystem xmlns="urn:jboss:domain:ee:1.0"/>
<subsystem xmlns="urn:jboss:domain:ejb3:1.0" />
<subsystem xmlns="urn:jboss:domain:ejb3:1.0" >
<timer-service>
<thread-pool core-threads="1" />
<data-store path="timer-service-data" relative-to="jboss.server.data.dir" />
</timer-service>
</subsystem>
<subsystem xmlns="urn:jboss:domain:infinispan:1.0" default-cache-container="hibernate">
<cache-container name="hibernate" default-cache="local-query">
<local-cache name="entity">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
<module name="javax.ejb.api"/>
<module name="javax.interceptor.api"/>
<module name="javax.jms.api"/>
<module name="javax.persistence.api" />
<!-- For message inflow -->
<module name="javax.resource.api"/>
<module name="org.hibernate"/>
<module name="org.jboss.as.controller"/>
<!-- So we can access its integration API -->
<module name="org.jboss.as.connector"/>
Expand All @@ -47,6 +49,7 @@
<module name="org.jboss.jboss-transaction-spi"/>
<module name="org.jboss.common-core"/>
<module name="org.jboss.ejb3"/>
<module name="org.jboss.ejb3.timerservice"/>
<!-- For Interceptor -->
<module name="org.jboss.invocation"/>
<module name="org.jboss.ironjacamar.api"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@
</resources>

<dependencies>
<!-- EJB API -->
<module name="javax.ejb.api"/>
<!-- Interceptor API -->
<module name="javax.persistence.api"/>
<module name="javax.interceptor.api"/>
<!-- org.jboss.util.deadlock.ApplicationDeadlockException -->
<module name="org.jboss.common-core"/>
<!-- TX services -->
<module name="org.jboss.jboss-transaction-spi"/>
<!-- Logging -->
<module name="org.jboss.logging"/>
<!-- the EE metadata -->
<module name="org.jboss.marshalling"/>
<module name="org.jboss.marshalling.river"/>
<module name="org.jboss.metadata"/>
</dependencies>
</module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright (c) 2011, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<module xmlns="urn:jboss:module:1.0" name="org.jboss.ejb3.timerservice">

<resources>
<!-- Insert resources here -->
</resources>

<dependencies>
<module name="javax.ejb.api"/>
<module name="javax.persistence.api"/>
<module name="javax.interceptor.api"/>
<module name="org.jboss.ejb3"/>
<module name="org.jboss.jboss-transaction-spi"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.marshalling"/>
<module name="org.jboss.marshalling.river"/>
<module name="org.jboss.metadata"/>
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<module name="javax.persistence.api"/>
<module name="javax.servlet.api"/>
<module name="javax.servlet.jsp.api"/>
<module name="javax.xml.bind.api"/>
<module name="javax.xml.ws.api"/>
<module name="org.jboss.ejb3"/>
<module name="org.jboss.staxmapper"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@
<deployment-scanner scan-interval="5000" relative-to="jboss.server.base.dir" path="deployments" />
</subsystem>
<subsystem xmlns="urn:jboss:domain:ee:1.0" />
<subsystem xmlns="urn:jboss:domain:ejb3:1.0" />
<subsystem xmlns="urn:jboss:domain:ejb3:1.0" >
<timer-service>
<thread-pool core-threads="1" />
<data-store path="timer-service-data" relative-to="jboss.server.data.dir" />
</timer-service>
</subsystem>
<subsystem xmlns="urn:jboss:domain:infinispan:1.0" default-cache-container="hibernate">
<cache-container name="hibernate" default-cache="local-query">
<local-cache name="entity">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<bean-validation enabled="false" />
<default-workmanager>
<short-running-threads blocking="true">
<core-threads count="10" per-cpu="20"/>
<core-threads count="10" per-cpu="20"/>
<queue-length count="10" per-cpu="20"/>
<max-threads count="10" per-cpu="20"/>
<keepalive-time time="10" unit="seconds"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.jboss.invocation.Interceptor;
import org.jboss.invocation.InterceptorContext;
import org.jboss.invocation.InterceptorFactory;
import org.jboss.invocation.InterceptorFactoryContext;
import org.jboss.invocation.SimpleInterceptorFactoryContext;
import org.jboss.msc.service.StopContext;
import org.jboss.msc.value.ImmediateValue;
Expand Down Expand Up @@ -138,7 +139,7 @@ protected final BasicComponentInstance constructComponentInstance(ManagedReferen
}

// create the component instance
BasicComponentInstance basicComponentInstance = this.instantiateComponentInstance(instanceReference, componentInstancePreDestroyInterceptor, interceptorMap);
final BasicComponentInstance basicComponentInstance = this.instantiateComponentInstance(instanceReference, componentInstancePreDestroyInterceptor, interceptorMap, context);

// now invoke the postconstruct interceptors
final InterceptorContext interceptorContext = new InterceptorContext();
Expand All @@ -156,6 +157,7 @@ protected final BasicComponentInstance constructComponentInstance(ManagedReferen
return basicComponentInstance;
}


/**
* Responsible for instantiating the {@link BasicComponentInstance}. This method is *not* responsible for
* handling the post construct activities like injection and lifecycle invocation. That is handled by
Expand All @@ -164,7 +166,7 @@ protected final BasicComponentInstance constructComponentInstance(ManagedReferen
*
* @return
*/
protected BasicComponentInstance instantiateComponentInstance(final AtomicReference<ManagedReference> instanceReference, final Interceptor preDestroyInterceptor, final Map<Method, Interceptor> methodInterceptors) {
protected BasicComponentInstance instantiateComponentInstance(final AtomicReference<ManagedReference> instanceReference, final Interceptor preDestroyInterceptor, final Map<Method, Interceptor> methodInterceptors, final InterceptorFactoryContext interceptorContext) {
// create and return the component instance
return new BasicComponentInstance(this, instanceReference, preDestroyInterceptor, methodInterceptors);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -108,9 +109,7 @@ public Collection<Method> allowedMethods() {
*/
public void destroy() {
if (doneUpdater.compareAndSet(this, 0, 1)) try {
final InterceptorContext interceptorContext = new InterceptorContext();
interceptorContext.putPrivateData(Component.class, component);
interceptorContext.putPrivateData(ComponentInstance.class, this);
final InterceptorContext interceptorContext = prepareInterceptorContext();
preDestroy.processInvocation(interceptorContext);
} catch (Exception e) {
log.warn("Failed to destroy component instance " + this, e);
Expand All @@ -119,6 +118,14 @@ public void destroy() {
}
}

protected InterceptorContext prepareInterceptorContext() {
final InterceptorContext interceptorContext = new InterceptorContext();
interceptorContext.putPrivateData(Component.class, component);
interceptorContext.putPrivateData(ComponentInstance.class, this);
interceptorContext.setContextData(new HashMap<String, Object>());
return interceptorContext;
}

protected void finalize() {
destroy();
}
Expand Down
Loading

0 comments on commit 01924ed

Please sign in to comment.