Skip to content

Commit

Permalink
point commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Oct 4, 2012
1 parent 1148d97 commit adf245f
Show file tree
Hide file tree
Showing 28 changed files with 926 additions and 202 deletions.
39 changes: 39 additions & 0 deletions api/src/main/java/org/jboss/mgmt/Controller.java
@@ -0,0 +1,39 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, 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.
*/

package org.jboss.mgmt;

import java.util.concurrent.Future;

/**
* A controller for a resource.
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public interface Controller<R extends Resource> {

Future<R> read();

Future<Void> remove();

<B extends NestedBuilder<Future<R>>> B writeAttributes(BuilderFactory<Future<R>, B> factory);
}
7 changes: 3 additions & 4 deletions api/src/main/java/org/jboss/mgmt/ModelChangeContext.java
Expand Up @@ -22,11 +22,10 @@

package org.jboss.mgmt;

import org.jboss.msc.txn.ExecutionContext;

/**
*
*/
public interface ModelChangeContext {
void completed();

void failed(Exception cause);
public interface ModelChangeContext extends ExecutionContext<Void> {
}
2 changes: 2 additions & 0 deletions api/src/main/java/org/jboss/mgmt/ResourceListener.java
Expand Up @@ -30,4 +30,6 @@ public interface ResourceListener<R> {
void resourceRemoved(ModelChangeContext context, R resource);

void resourceAdded(ModelChangeContext context, R resource);

void resourceChanged(ModelChangeContext context, R original, R updated);
}
33 changes: 33 additions & 0 deletions api/src/main/java/org/jboss/mgmt/ResourceOperation.java
@@ -0,0 +1,33 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, 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.
*/

package org.jboss.mgmt;

/**
* @param <R> the affected resource type
* @param <P> the payload type
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public interface ResourceOperation<R extends Resource, P> {
void execute(ResourceOperationContext context, R resource, P payload);
}
35 changes: 35 additions & 0 deletions api/src/main/java/org/jboss/mgmt/ResourceOperationContext.java
@@ -0,0 +1,35 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, 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.
*/

package org.jboss.mgmt;

import org.jboss.msc.txn.ExecutionContext;

/**
* A resource operation context.
*
* @param <T> the operation result type
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public interface ResourceOperationContext<T> extends ExecutionContext<T> {

}
34 changes: 34 additions & 0 deletions api/src/main/java/org/jboss/mgmt/RunLevel.java
@@ -0,0 +1,34 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, 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.
*/

package org.jboss.mgmt;

/**
* The run level of a managed node.
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public enum RunLevel {
STOPPED,
MANAGEMENT,
RUNNING,
}
3 changes: 3 additions & 0 deletions example/src/main/java/example1/FileHandlerListener.java
Expand Up @@ -35,4 +35,7 @@ public void resourceRemoved(final ModelChangeContext context, final FileHandlerR

public void resourceAdded(final ModelChangeContext context, final FileHandlerResource resource) {
}

public void resourceChanged(final ModelChangeContext context, final FileHandlerResource original, final FileHandlerResource updated) {
}
}
3 changes: 2 additions & 1 deletion example/src/main/java/example1/Profile.java
Expand Up @@ -23,14 +23,15 @@
package example1;

import java.util.List;
import org.jboss.mgmt.annotation.RunLevel;
import org.jboss.mgmt.annotation.SubResource;

/**
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public interface Profile {

@SubResource(requiresUniqueProvider = true, type = "subsystem")
@SubResource(requiresUniqueProvider = true, type = "subsystem", addLevel = RunLevel.MANAGEMENT, removeLevel = RunLevel.MANAGEMENT)
List<String> getSubsystemNames();

LoggingSubsystemResource getSubsystem(String name);
Expand Down
33 changes: 33 additions & 0 deletions example/src/main/java/example1/SubsystemResource.java
@@ -0,0 +1,33 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, 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.
*/

package example1;

import org.jboss.mgmt.annotation.ResourceType;

/**
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
@ResourceType(name = "subsystem")
public interface SubsystemResource {

}
20 changes: 20 additions & 0 deletions tool/src/main/java/org/jboss/mgmt/annotation/Attribute.java
Expand Up @@ -47,8 +47,28 @@
public @interface Attribute {
String name() default "";

/**
* The accessibility of the value of this attribute.
*
* @return the accessibility
*/
Access access() default Access.READ_WRITE;

/**
* The maximum run level at which this attribute can be mutated.
*
* @return the run level
*/
RunLevel changeRunLevel() default RunLevel.RUNNING;

/**
* The minimum run level at which this attribute can be observed. Only applies to
* virtual attributes. The visibility run level must be less than the change run level.
*
* @return the visibility run level
*/
RunLevel visibleRunLevel() default RunLevel.STOPPED;

Class<? extends VirtualAttribute> virtual() default VirtualAttribute.class;

String defaultValue() default "";
Expand Down
60 changes: 60 additions & 0 deletions tool/src/main/java/org/jboss/mgmt/annotation/Dependency.java
@@ -0,0 +1,60 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, 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.
*/

package org.jboss.mgmt.annotation;

/**
* Declare that this resource depends on a specific {@link Provides} from a specific {@link ResourceType}.
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
public @interface Dependency {

/**
* The resource type required.
*
* @return the resource type
*/
Class<?> type();

/**
* The names required.
*
* @return the names
*/
String[] names();

/**
* Dependency is optional ({@code true}) or required ({@code false}).
*
* @return {@code true} for optional, {@code false} for required
*/
boolean optional() default false;

/**
* The maximum run level that must be used to modify this dependency.
*
* @return the run level
*/
RunLevel runLevel() default RunLevel.STOPPED;


}
34 changes: 33 additions & 1 deletion tool/src/main/java/org/jboss/mgmt/annotation/Listener.java
Expand Up @@ -22,9 +22,41 @@

package org.jboss.mgmt.annotation;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import org.jboss.mgmt.Resource;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.CLASS;

/**
*
* A listener on an attribute or resource.
*/
@Retention(CLASS)
@Target({TYPE, METHOD})
public @interface Listener {

/**
* The listener type.
*
* @return the listener type
*/
Class<?> value();

/**
* The run level at which the listener applies. In order to transition between run levels, all
* matching listeners must be invoked successfully.
*
* @return the run level
*/
RunLevel runLevel() default RunLevel.RUNNING;

/**
* The resource root under which this listener applies. This listener will
* not execute under any other root.
*
* @return the resource root
*/
Class<? extends Resource> root() default Resource.class;
}

0 comments on commit adf245f

Please sign in to comment.