Skip to content

Commit

Permalink
almost looks like progress, but not really
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Sep 25, 2012
1 parent f5d5f18 commit 6521fd3
Show file tree
Hide file tree
Showing 25 changed files with 482 additions and 288 deletions.
7 changes: 7 additions & 0 deletions api/pom.xml
Expand Up @@ -11,4 +11,11 @@
</parent>

<artifactId>jboss-mgmt-api</artifactId>

<dependencies>
<dependency>
<groupId>org.jboss.msc</groupId>
<artifactId>jboss-msc2</artifactId>
</dependency>
</dependencies>
</project>
6 changes: 4 additions & 2 deletions api/src/main/java/org/jboss/mgmt/AbstractResource.java
Expand Up @@ -23,15 +23,17 @@
package org.jboss.mgmt;

/**
* Base class for resource data objects.
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public abstract class AbstractResource implements Resource {
private final String preComment;
private final String postComment;
private final String name;
private final Resource parent;
private final ResourceNode<?> parent;

protected AbstractResource(final String preComment, final String postComment, final String name, final Resource parent) {
protected AbstractResource(final String preComment, final String postComment, final String name, final ResourceNode<?> parent) {
this.preComment = preComment;
this.postComment = postComment;
this.name = name;
Expand Down
Expand Up @@ -23,12 +23,17 @@
package org.jboss.mgmt;

/**
* A builder for attributes of a map type whose values are complex.
* Infrastructure class used by generated resource implementations.
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public interface BuilderMapBuilder<P, K, V extends NestedBuilder<BuilderMapBuilder<P, K, V>>> extends NestedBuilder<P> {
V put(K key);
public abstract class AbstractResourceBuilder<R extends Resource, P extends NestedBuilder<?>, THIS extends AbstractResourceBuilder<R, P, THIS>> implements NestedBuilder<P> {
protected final ResourceNode<R> construct(ResourceNode<?> parentNode) {
return null;
}

BuilderMapBuilder<P, K, V> remove(K key);
@SuppressWarnings("unchecked")
protected final THIS _this() {
return (THIS) this;
}
}
Expand Up @@ -27,6 +27,6 @@
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public interface ResourceBuilderFactory<P, B extends NestedBuilder<P>> {
public interface BuilderFactory<P, B extends NestedBuilder<P>> {
B construct(P parent);
}
Expand Up @@ -22,9 +22,31 @@

package org.jboss.mgmt;

import java.util.Map;

/**
* An immutable map entry, used by builder classes.
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public interface BuilderCollectionBuilder<P, E extends NestedBuilder<BuilderCollectionBuilder<P, E>>> extends NestedBuilder<P> {
E add();
public final class Entry<K, V> implements Map.Entry<K, V> {
private final K key;
private final V value;

Entry(final K key, final V value) {
this.value = value;
this.key = key;
}

public K getKey() {
return key;
}

public V getValue() {
return value;
}

public V setValue(final V value) {
throw new UnsupportedOperationException();
}
}
Expand Up @@ -20,19 +20,24 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.mgmt.model;
package org.jboss.mgmt;

import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import org.jboss.msc.txn.WorkContext;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

/**
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public abstract class ResourceNode<R> {
public abstract class ResourceNode<R extends Resource> implements Resource {
private volatile int state;
private volatile R current;
private volatile Object owningTxn;
private volatile Thread waiter;
private final ResourceNode<?> parent;

private static final AtomicIntegerFieldUpdater<ResourceNode> stateUpdater = AtomicIntegerFieldUpdater.newUpdater(ResourceNode.class, "state");
private static final AtomicReferenceFieldUpdater<ResourceNode, Object> currentUpdater = AtomicReferenceFieldUpdater.newUpdater(ResourceNode.class, Object.class, "current");
Expand All @@ -43,6 +48,10 @@ public abstract class ResourceNode<R> {
private static final int INTENT_WRITE_LOCK = (1 << 30);
private static final int READERS = INTENT_WRITE_LOCK - 1;

protected ResourceNode(final ResourceNode<?> parent) {
this.parent = parent;
}

private static Object currentTransaction() {
return null; // todo once msc-2 stabilizes...
}
Expand All @@ -69,4 +78,33 @@ private void lockRead(final Object txn) {
private void lockWrite(final Object txn) {
// set write flag or block with txn
}

public String getPreComment() {
return current.getPreComment();
}

public String getPostComment() {
return current.getPostComment();
}

public String getName() {
return current.getName();
}

public Resource getParent() {
return parent;
}

public Resource navigate(final String key, final String value) {
return null;
}

protected abstract R writeAttribute(WorkContext workContext, String name, Object value);

protected abstract void persist(XMLStreamWriter writer) throws XMLStreamException;

@SuppressWarnings("unchecked")
R asResource() {
return (R) this;
}
}
30 changes: 0 additions & 30 deletions api/src/main/java/org/jboss/mgmt/SimpleCollectionBuilder.java

This file was deleted.

30 changes: 0 additions & 30 deletions api/src/main/java/org/jboss/mgmt/SimpleMapBuilder.java

This file was deleted.

3 changes: 2 additions & 1 deletion example/src/main/java/example1/DomainResource.java
Expand Up @@ -35,8 +35,9 @@
@RootResource(
type = "top",
namespace = "jboss",
version = "1.0",
version = "8.0",
kind = RootResource.Kind.SYSTEM,
schemaLocation = "http://www.jboss.org/schema/jbossas/jboss_8_0.xsd",
compatibilityNamespaces = { "urn:jboss:domain:1.0" }
)
public interface DomainResource extends Resource {
Expand Down
3 changes: 2 additions & 1 deletion example/src/main/java/example1/LoggingSubsystemResource.java
Expand Up @@ -37,7 +37,8 @@
type = "subsystem",
name = "logging",
namespace = "core.logging",
version = "1.0"
schemaLocation = "http://www.jboss.org/schema/jbossas/jboss-core-logging_8_0.xsd",
version = "8.0"
)
@XmlName("subsystem")
public interface LoggingSubsystemResource extends Resource {
Expand Down
12 changes: 9 additions & 3 deletions example/src/main/java/example1/StandaloneServerResource.java
Expand Up @@ -24,13 +24,19 @@

import org.jboss.mgmt.annotation.AttributeGroup;
import org.jboss.mgmt.annotation.RootResource;
import org.jboss.mgmt.annotation.xml.XmlName;

/**
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
@RootResource(type = "model", kind = RootResource.Kind.SYSTEM, name = "standalone", version = "1.0", namespace = "jboss")
@XmlName("standalone")
@RootResource(
name = "server",
type = "top",
namespace = "jboss",
version = "8.0",
kind = RootResource.Kind.SYSTEM,
schemaLocation = "http://www.jboss.org/schema/jbossas/jboss_8_0.xsd",
compatibilityNamespaces = { "urn:jboss:domain:1.0" }
)
public interface StandaloneServerResource extends ServerResource {

@AttributeGroup
Expand Down
18 changes: 9 additions & 9 deletions pom.xml
Expand Up @@ -39,8 +39,8 @@
</parent>
<properties>
<version.compiler.plugin>2.5.1</version.compiler.plugin>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.6</maven.compiler.source>
</properties>


Expand All @@ -57,8 +57,8 @@
<version>${version.compiler.plugin}</version>
<configuration>
<compilerArguments>
<XprintRounds />
<XprintProcessorInfo/>
<!--<XprintRounds />-->
<!--<XprintProcessorInfo/>-->
</compilerArguments>
</configuration>
</plugin>
Expand All @@ -76,11 +76,11 @@
<artifactId>jboss-mgmt-tool</artifactId>
<version>${project.version}</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.jboss.msc</groupId>-->
<!--<artifactId>jboss-msc2</artifactId>-->
<!--<version>2.0.0.Beta1-SNAPSHOT</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.jboss.msc</groupId>
<artifactId>jboss-msc2</artifactId>
<version>2.0.0.Beta1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions tool/pom.xml
Expand Up @@ -29,10 +29,10 @@
<groupId>org.jboss.mgmt</groupId>
<artifactId>jboss-mgmt-api</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.jboss.msc2</groupId>-->
<!--<artifactId>jboss-msc2</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.jboss.msc</groupId>
<artifactId>jboss-msc2</artifactId>
</dependency>
<dependency>
<groupId>com.sun.codemodel</groupId>
<artifactId>codemodel</artifactId>
Expand Down
Expand Up @@ -29,6 +29,8 @@
import static java.lang.annotation.RetentionPolicy.CLASS;

/**
* Declare a class to be an attribute type. Attribute types are read and written as one attribute.
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
@Retention(CLASS)
Expand Down
39 changes: 0 additions & 39 deletions tool/src/main/java/org/jboss/mgmt/annotation/Description.java

This file was deleted.

Expand Up @@ -71,6 +71,13 @@
*/
String namespace();

/**
* The schema location. This URL string will be used to determine the target filename of the generated schema.
*
* @return the URL
*/
String schemaLocation();

/**
* Compatibility namespaces that should also be recognized (but not generated).
*
Expand Down

0 comments on commit 6521fd3

Please sign in to comment.